/**
 * Lista Recurring Events - Offcanvas Styles
 *
 * Accessible slide-in panel for event details.
 *
 * @package Listapage\RecurringEvents
 */

/* Shared Variables - these are set by inline CSS from CalendarThemes */
:root {
    /* Fallback values only - actual values come from inline CSS */
    --lre-panel-bg: var(--lre-offcanvas-bg, #ffffff);
    --lre-panel-text: var(--lre-offcanvas-text, #333333);
    --lre-panel-accent: var(--lre-primary-color, #3788d8);
    --lre-panel-radius: var(--lre-border-radius, 8px);
    --lre-panel-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    
    /* Animation timing - PowerInOut-like bezier curve */
    --lre-ease-power: cubic-bezier(0.65, 0, 0.35, 1);
    --lre-ease-power-out: cubic-bezier(0.33, 1, 0.68, 1);
    --lre-ease-power-in: cubic-bezier(0.32, 0, 0.67, 0);
    
    /* Smooth elastic feel */
    --lre-ease-smooth: cubic-bezier(0.22, 1, 0.36, 1);
    
    /* Animation durations */
    --lre-duration-panel: 450ms;
    --lre-duration-backdrop: 350ms;
    --lre-duration-content: 400ms;
    --lre-stagger-delay: 60ms;
}

/* Body Lock */
body.lre-offcanvas-open {
    overflow: hidden;
}

/* ============================================
   OFFCANVAS PANEL
   ============================================ */

/* Backdrop */
.lre-offcanvas-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    opacity: 0;
    visibility: hidden;
    transition: 
        opacity var(--lre-duration-backdrop) var(--lre-ease-power-out),
        visibility var(--lre-duration-backdrop) var(--lre-ease-power-out),
        background var(--lre-duration-backdrop) var(--lre-ease-power-out),
        backdrop-filter var(--lre-duration-backdrop) var(--lre-ease-power-out);
    z-index: 99998;
}

.lre-offcanvas-backdrop.lre-visible {
    opacity: 1;
    visibility: visible;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* Offcanvas Container */
.lre-offcanvas {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 400px;
    max-width: 100%;
    background: var(--lre-panel-bg);
    box-shadow: none;
    opacity: 0;
    visibility: hidden;
    transition: 
        opacity var(--lre-duration-panel) var(--lre-ease-smooth),
        visibility var(--lre-duration-panel) var(--lre-ease-smooth),
        transform var(--lre-duration-panel) var(--lre-ease-smooth),
        box-shadow var(--lre-duration-panel) var(--lre-ease-smooth);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    will-change: transform, opacity;
}

.lre-offcanvas.lre-visible {
    opacity: 1;
    visibility: visible;
    box-shadow: var(--lre-panel-shadow);
}

/* Right Position */
.lre-offcanvas.lre-offcanvas-right {
    right: 0;
    transform: translateX(100%);
}

.lre-offcanvas.lre-offcanvas-right.lre-visible {
    transform: translateX(0);
}

/* Left Position */
.lre-offcanvas.lre-offcanvas-left {
    left: 0;
    transform: translateX(-100%);
}

.lre-offcanvas.lre-offcanvas-left.lre-visible {
    transform: translateX(0);
}

/* Body - now handles everything including image */
.lre-offcanvas-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    position: relative;
}

/* Close Button - absolutely positioned over image */
.lre-offcanvas-close {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 10;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 
        background 0.2s var(--lre-ease-power),
        transform 0.2s var(--lre-ease-power);
    color: #ffffff;
}

.lre-offcanvas-close:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.05);
}

.lre-offcanvas-close:active {
    transform: scale(0.95);
}

.lre-offcanvas-close svg {
    width: 22px;
    height: 22px;
}

/* Loading */
.lre-offcanvas-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--lre-panel-text);
    opacity: 0.7;
}

/* Error */
.lre-offcanvas-error {
    padding: 40px 20px;
    text-align: center;
    color: #dc3545;
}

/* ============================================
   CONTENT ANIMATIONS - FadeInUp
   ============================================ */

/* Keyframe animation for fade in up */
@keyframes lreFadeInUp {
    0% {
        opacity: 0;
        transform: translateY(24px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Base state for animatable items - hidden until animation triggers */
.lre-animate-item {
    opacity: 0;
    transform: translateY(24px);
}

/* Animated state - uses keyframe animation */
.lre-animate-item.lre-animate-in {
    animation-name: lreFadeInUp;
    animation-duration: 400ms;
    animation-duration: var(--lre-duration-content, 400ms);
    animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
    animation-timing-function: var(--lre-ease-smooth, cubic-bezier(0.22, 1, 0.36, 1));
    animation-fill-mode: forwards;
    animation-delay: calc(var(--animation-order, 0) * 60ms);
    animation-delay: calc(var(--animation-order, 0) * var(--lre-stagger-delay, 60ms));
}

/* ============================================
   IMAGE (No animation - appears immediately)
   ============================================ */

.lre-offcanvas-image {
    position: relative;
    width: 100%;
    height: 250px;
    overflow: hidden;
    background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
    border-radius: 0;
}

.lre-offcanvas-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lre-offcanvas-image img.loaded,
.lre-offcanvas-image img[src] {
    opacity: 1;
}

/* Title */
.lre-offcanvas-title {
    font-size: 1.6em;
    font-weight: 600;
    color: var(--lre-panel-text);
    margin: 0;
    padding: 25px 25px 15px;
}

/* Date */
.lre-offcanvas-date {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 25px 10px;
    color: var(--lre-panel-text);
    font-weight: 500;
    font-size: 1.05em;
}

/* When date is followed by time, reduce gap */
.lre-offcanvas-date + .lre-offcanvas-time {
    padding-top: 0;
    line-height: 1;
}

.lre-offcanvas-date svg,
.lre-offcanvas-date .lre-offcanvas-icon {
    flex-shrink: 0;
}

/* Time */
.lre-offcanvas-time {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 25px 15px;
    color: var(--lre-panel-text);
    font-weight: 500;
    font-size: 1.05em;
}

.lre-offcanvas-time svg,
.lre-offcanvas-time .lre-offcanvas-icon {
    flex-shrink: 0;
}

/* Custom Icons */
.lre-offcanvas-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.lre-offcanvas-icon img.lre-custom-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

/* Custom Fields */
.lre-offcanvas-custom-fields {
    padding: 0 25px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.lre-offcanvas-field {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 15px;
}

.lre-offcanvas-field:last-child {
    margin-bottom: 0;
}

.lre-offcanvas-field .lre-offcanvas-icon {
    flex-shrink: 0;
    margin-top: 2px;
}

.lre-offcanvas-field-label {
    font-weight: 600;
    font-size: 0.9em;
    color: var(--lre-panel-text);
    opacity: 0.7;
    white-space: nowrap;
}

.lre-offcanvas-field-value {
    color: var(--lre-panel-text);
    font-size: 1em;
}

/* Excerpt */
.lre-offcanvas-excerpt {
    padding: 20px 25px;
    color: var(--lre-panel-text);
    line-height: 1.7;
    font-size: 1em;
}

/* Button */
.lre-offcanvas-button {
    display: block;
    margin: 20px 25px 30px;
    padding: 14px 28px;
    background: var(--lre-panel-accent);
    color: #ffffff !important;
    text-align: center;
    text-decoration: none;
    border-radius: var(--lre-panel-radius);
    font-weight: 600;
    font-size: 1.05em;
    transition: 
        background 0.25s var(--lre-ease-power),
        transform 0.2s var(--lre-ease-power),
        box-shadow 0.25s var(--lre-ease-power);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.lre-offcanvas-button:hover {
    background: var(--lre-primary-hover, #2c6cb5);
    color: #ffffff !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.lre-offcanvas-button:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 600px) {
    .lre-offcanvas {
        width: 100% !important;
    }

    .lre-offcanvas-image {
        height: 200px;
    }

    .lre-offcanvas-title {
        font-size: 1.4em;
        padding: 20px 20px 10px;
    }

    .lre-offcanvas-date,
    .lre-offcanvas-time,
    .lre-offcanvas-custom-fields,
    .lre-offcanvas-excerpt {
        padding-left: 20px;
        padding-right: 20px;
    }

    .lre-offcanvas-button {
        margin: 15px 20px 20px;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus styles */
.lre-offcanvas-close:focus,
.lre-offcanvas-button:focus {
    outline: 2px solid var(--lre-panel-accent);
    outline-offset: 2px;
}

/* Reduced motion - disable all animations */
@media (prefers-reduced-motion: reduce) {
    :root {
        --lre-duration-panel: 0ms;
        --lre-duration-backdrop: 0ms;
        --lre-duration-content: 0ms;
        --lre-stagger-delay: 0ms;
    }
    
    .lre-offcanvas,
    .lre-offcanvas-backdrop,
    .lre-offcanvas-button,
    .lre-offcanvas-close {
        transition: none !important;
    }
    
    .lre-animate-item {
        opacity: 1 !important;
        animation: none !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .lre-offcanvas {
        border: 2px solid var(--lre-panel-text);
    }

    .lre-offcanvas-button {
        border: 2px solid currentColor;
    }
}

/* ============================================
   PRINT
   ============================================ */

@media print {
    .lre-offcanvas-backdrop,
    .lre-offcanvas {
        display: none !important;
    }
}
