/**
 * Gallery Slideshow Styles
 * Fullscreen slideshow/autoplay overlay for photo galleries
 * Uses native <dialog> for the modal
 * @version 2.0.0
 */

/* ========================================
   DIALOG CONTAINER
   ======================================== */

.gallery-slideshow {
    border: none;
    padding: 0;
    margin: 0;
    background: transparent;
    max-width: 100vw;
    max-height: 100vh;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    color: #fff;
}

.gallery-slideshow[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-slideshow::backdrop {
    background: rgba(0, 0, 0, 0.97);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

/* ========================================
   INNER LAYOUT
   ======================================== */

.gallery-slideshow__inner {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
}

/* ========================================
   IMAGE
   ======================================== */

.gallery-slideshow__img-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 60px 80px 100px;
}

.gallery-slideshow__img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.35s ease;
    border-radius: 4px;
}

.gallery-slideshow__img.is-loaded {
    opacity: 1;
}

/* ========================================
   COUNTER (top-center)
   ======================================== */

.gallery-slideshow__counter {
    position: absolute;
    top: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    font-size: 0.875rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(0, 0, 0, 0.5);
    padding: 0.35rem 0.9rem;
    border-radius: 20px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    pointer-events: none;
}

/* ========================================
   CLOSE BUTTON (top-right)
   ======================================== */

.gallery-slideshow__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 10;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.gallery-slideshow__close:hover {
    background: rgba(220, 38, 38, 0.8);
    border-color: var(--accent-red, #dc2626);
    transform: scale(1.1);
}

.gallery-slideshow__close:active {
    transform: scale(0.95);
}

/* ========================================
   NAVIGATION ARROWS (sides)
   ======================================== */

.gallery-slideshow__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 56px;
    height: 56px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.gallery-slideshow__nav--prev {
    left: 1rem;
}

.gallery-slideshow__nav--next {
    right: 1rem;
}

.gallery-slideshow__nav:hover {
    background: rgba(220, 38, 38, 0.8);
    border-color: var(--accent-red, #dc2626);
    transform: translateY(-50%) scale(1.1);
}

.gallery-slideshow__nav:active {
    transform: translateY(-50%) scale(0.95);
}

/* ========================================
   PLAY/PAUSE BUTTON (bottom-center-left)
   ======================================== */

.gallery-slideshow__controls {
    position: absolute;
    bottom: 5.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(0, 0, 0, 0.5);
    padding: 0.5rem 1rem;
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.gallery-slideshow__play-pause {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.gallery-slideshow__play-pause:hover {
    background: rgba(220, 38, 38, 0.8);
    border-color: var(--accent-red, #dc2626);
    transform: scale(1.1);
}

.gallery-slideshow__play-pause:active {
    transform: scale(0.95);
}

.gallery-slideshow__play-icon,
.gallery-slideshow__pause-icon {
    pointer-events: none;
}

/* When playing, show pause icon; when paused, show play icon */
.gallery-slideshow__play-pause .gallery-slideshow__pause-icon {
    display: none;
}
.gallery-slideshow__play-pause .gallery-slideshow__play-icon {
    display: block;
}

.gallery-slideshow__play-pause[data-playing="true"] .gallery-slideshow__pause-icon {
    display: block;
}
.gallery-slideshow__play-pause[data-playing="true"] .gallery-slideshow__play-icon {
    display: none;
}

/* ========================================
   CAPTION (bottom-center, above controls)
   ======================================== */

.gallery-slideshow__caption {
    position: absolute;
    bottom: 9rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    max-width: 70%;
    text-align: center;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(0, 0, 0, 0.5);
    padding: 0.4rem 1rem;
    border-radius: 8px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-slideshow__caption.is-visible {
    opacity: 1;
}

/* ========================================
   TIMER BAR (thin progress bar at bottom)
   ======================================== */

.gallery-slideshow__timer-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    z-index: 10;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.gallery-slideshow__timer-fill {
    width: 0%;
    height: 100%;
    background: var(--accent-red, #dc2626);
    transition: none;
}

.gallery-slideshow__timer-fill.is-running {
    animation: slideshow-timer-fill var(--slideshow-interval, 4s) linear forwards;
}

@keyframes slideshow-timer-fill {
    from { width: 0%; }
    to   { width: 100%; }
}

/* ========================================
   SLIDESHOW TRIGGER BUTTON (gallery page)
   ======================================== */

.gallery-slideshow-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    background: rgba(220, 38, 38, 0.15);
    border: 1px solid rgba(220, 38, 38, 0.4);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.gallery-slideshow-btn:hover {
    background: rgba(220, 38, 38, 0.3);
    border-color: var(--accent-red, #dc2626);
    transform: translateY(-1px);
}

.gallery-slideshow-btn:active {
    transform: translateY(0) scale(0.98);
}

.gallery-slideshow-btn svg {
    flex-shrink: 0;
}

/* ========================================
   RESPONSIVE: MOBILE
   ======================================== */

@media (max-width: 768px) {
    .gallery-slideshow__nav {
        width: 44px;
        height: 44px;
    }

    .gallery-slideshow__nav--prev {
        left: 0.5rem;
    }

    .gallery-slideshow__nav--next {
        right: 0.5rem;
    }

    .gallery-slideshow__close {
        top: 0.5rem;
        right: 0.5rem;
        width: 40px;
        height: 40px;
    }

    .gallery-slideshow__counter {
        top: 0.75rem;
        font-size: 0.75rem;
    }

    .gallery-slideshow__img-wrap {
        padding: 50px 1rem 80px;
    }

    .gallery-slideshow__controls {
        bottom: 4.5rem;
        padding: 0.35rem 0.75rem;
        gap: 0.5rem;
    }

    .gallery-slideshow__play-pause {
        width: 36px;
        height: 36px;
    }

    .gallery-slideshow__caption {
        bottom: 7.5rem;
        max-width: 85%;
        font-size: 0.8rem;
    }
}

/* Touch targets for mobile */
@media (hover: none) and (pointer: coarse) {
    .gallery-slideshow__close,
    .gallery-slideshow__nav,
    .gallery-slideshow__play-pause {
        min-width: 44px;
        min-height: 44px;
    }

    .gallery-slideshow__close:active,
    .gallery-slideshow__nav:active,
    .gallery-slideshow__play-pause:active {
        opacity: 0.7;
    }
}

/* ========================================
   FOCUS STATES
   ======================================== */

.gallery-slideshow__close:focus-visible,
.gallery-slideshow__nav:focus-visible,
.gallery-slideshow__play-pause:focus-visible {
    outline: 3px solid var(--accent-red, #dc2626);
    outline-offset: 2px;
}

/* ========================================
   REDUCED MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .gallery-slideshow__img {
        transition: none;
    }

    .gallery-slideshow__caption {
        transition: none;
    }

    .gallery-slideshow__close,
    .gallery-slideshow__nav,
    .gallery-slideshow__play-pause {
        transition: none;
    }

    .gallery-slideshow-btn {
        transition: none;
    }

    /* Disable timer bar animation; fill instantly */
    .gallery-slideshow__timer-fill.is-running {
        animation: none;
        width: 100%;
    }
}

/* ========================================
   THUMBNAIL STRIP (bottom, above timer bar)
   ======================================== */

.gallery-slideshow__thumb-strip {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    z-index: 10;
    height: 72px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
    mask-image: linear-gradient(to right, transparent 0, #000 2%, #000 98%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 2%, #000 98%, transparent 100%);
}

.gallery-slideshow__thumb-strip::-webkit-scrollbar {
    height: 4px;
}

.gallery-slideshow__thumb-strip::-webkit-scrollbar-track {
    background: transparent;
}

.gallery-slideshow__thumb-strip::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 2px;
}

.gallery-slideshow__thumb-track {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 3%;
    min-width: max-content;
    height: 100%;
}

.gallery-slideshow__thumb {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
    padding: 0;
    transition: border-color 0.2s ease, opacity 0.2s ease, transform 0.15s ease;
    opacity: 0.55;
}

.gallery-slideshow__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    display: block;
}

.gallery-slideshow__thumb:hover {
    opacity: 0.85;
    transform: scale(1.08);
}

.gallery-slideshow__thumb.is-active {
    border-color: var(--accent-red, #dc2626);
    opacity: 1;
    transform: scale(1.05);
    box-shadow: 0 0 12px rgba(220, 38, 38, 0.5);
}

.gallery-slideshow__thumb:focus-visible {
    outline: 2px solid var(--accent-red, #dc2626);
    outline-offset: 2px;
    opacity: 1;
}

/* ========================================
   CONTROLS ROW + PHOTO COUNT BADGE
   (gallery detail page header area)
   ======================================== */

.gallery-slideshow-controls-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

.gallery-photo-count-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.75);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
}

.gallery-photo-count-badge svg {
    flex-shrink: 0;
    opacity: 0.7;
}

/* ========================================
   RESPONSIVE: THUMBNAIL STRIP MOBILE
   ======================================== */

@media (max-width: 768px) {
    .gallery-slideshow__thumb-strip {
        height: 56px;
        bottom: 8px;
    }

    .gallery-slideshow__thumb {
        width: 44px;
        height: 44px;
        border-radius: 4px;
    }

    .gallery-slideshow__thumb-track {
        gap: 4px;
        padding: 4px 4%;
    }

    /* Adjust controls position to account for thumb strip */
    .gallery-slideshow__controls {
        bottom: 5.5rem;
    }

    .gallery-slideshow__caption {
        bottom: 8rem;
    }

    .gallery-slideshow-controls-row {
        margin-top: 0.75rem;
        gap: 0.75rem;
    }
}

/* ========================================
   REDUCED MOTION: THUMBNAILS
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .gallery-slideshow__thumb {
        transition: none;
    }
}

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

@media print {
    .gallery-slideshow,
    .gallery-slideshow-btn,
    .gallery-slideshow-controls-row {
        display: none !important;
    }
}
