/* =============================================
   Ken Burns Slideshow Overlay
   ============================================= */

/* ---- Overlay container ---- */
#slideshowOverlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: #000;
    overflow: hidden;
    cursor: none; /* hidden until interaction */
}

#slideshowOverlay.ss-controls-visible {
    cursor: default;
}

/* ---- Image layers (A/B crossfade) ---- */
.ss-layer {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    will-change: transform, opacity;
    opacity: 0;
}

.ss-layer.ss-active {
    opacity: 1;
}

.ss-layer.ss-fade-in {
    animation: ss-fade-in 0.8s ease forwards;
}

.ss-layer.ss-fade-out {
    animation: ss-fade-out 0.8s ease forwards;
}

@keyframes ss-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes ss-fade-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* ---- Ken Burns animation variants ---- */
/* All run for 7s — slightly longer than SLIDE_DURATION so the effect never
   reaches its end and snaps back before the crossfade begins.              */

.ss-layer.kb-tl {
    animation: kb-tl 7s ease-in-out forwards;
}
.ss-layer.kb-tr {
    animation: kb-tr 7s ease-in-out forwards;
}
.ss-layer.kb-bl {
    animation: kb-bl 7s ease-in-out forwards;
}
.ss-layer.kb-br {
    animation: kb-br 7s ease-in-out forwards;
}
.ss-layer.kb-out-c {
    animation: kb-out-c 7s ease-in-out forwards;
}
.ss-layer.kb-out-l {
    animation: kb-out-l 7s ease-in-out forwards;
}
.ss-layer.kb-in-r {
    animation: kb-in-r 7s ease-in-out forwards;
}
.ss-layer.kb-in-l {
    animation: kb-in-l 7s ease-in-out forwards;
}

/* Zoom in, pan toward corners */
@keyframes kb-tl {
    from { transform: scale(1.0)  translate( 0%,    0%); }
    to   { transform: scale(1.18) translate(-3.5%, -3%); }
}
@keyframes kb-tr {
    from { transform: scale(1.0)  translate( 0%,   0%); }
    to   { transform: scale(1.18) translate( 3.5%, -3%); }
}
@keyframes kb-bl {
    from { transform: scale(1.0)  translate( 0%,   0%); }
    to   { transform: scale(1.18) translate(-3.5%, 3%); }
}
@keyframes kb-br {
    from { transform: scale(1.0)  translate(0%,   0%); }
    to   { transform: scale(1.18) translate(3.5%, 3%); }
}

/* Slow zoom out from center */
@keyframes kb-out-c {
    from { transform: scale(1.18) translate(0%, 0%); }
    to   { transform: scale(1.0)  translate(0%, 0%); }
}

/* Zoom out, drift left→right */
@keyframes kb-out-l {
    from { transform: scale(1.15) translate(-3%, 0%); }
    to   { transform: scale(1.0)  translate( 3%, 0%); }
}

/* Zoom in from right side */
@keyframes kb-in-r {
    from { transform: scale(1.0)  translate( 3%, 0%); }
    to   { transform: scale(1.18) translate(-2%, 0%); }
}

/* Zoom in from left side */
@keyframes kb-in-l {
    from { transform: scale(1.0)  translate(-3%, 0%); }
    to   { transform: scale(1.18) translate( 2%, 0%); }
}

/* When slideshow is paused, freeze the KB animation */
#slideshowOverlay.ss-paused .ss-layer {
    animation-play-state: paused;
}

/* ---- UI overlay ---- */
.ss-ui {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none; /* let clicks fall through to layer beneath */
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 10;
}

#slideshowOverlay.ss-controls-visible .ss-ui {
    opacity: 1;
}

/* Top bar: counter + right icons */
.ss-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 10px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.65) 0%, transparent 100%);
    pointer-events: all;
}

.ss-counter {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-shadow: 0 1px 4px rgba(0,0,0,0.6);
    font-family: 'Segoe UI', sans-serif;
}

.ss-top-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Bottom bar: prev / play-pause / next */
.ss-bottom {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 10px 20px 22px;
    background: linear-gradient(to top, rgba(0,0,0,0.65) 0%, transparent 100%);
    pointer-events: all;
}

/* Progress bar — hidden while controls are visible */
#slideshowOverlay.ss-controls-visible .ss-progress-track {
    opacity: 0;
}

.ss-progress-track {
    transition: opacity 0.4s ease;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255,255,255,0.2);
    pointer-events: none;
    z-index: 11;
}

.ss-progress-fill {
    height: 100%;
    width: 0%;
    background: rgba(255,255,255,0.85);
    transition: width linear; /* duration set by JS */
}

/* ---- Buttons ---- */
.ss-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 8px 12px;
    transition: background 0.2s ease, transform 0.15s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    pointer-events: all;
    font-family: 'Segoe UI', sans-serif;
}

.ss-btn:hover {
    background: rgba(255,255,255,0.28);
    transform: scale(1.08);
}

.ss-btn:active {
    transform: scale(0.96);
}

/* Larger nav arrows */
.ss-btn.ss-nav {
    font-size: 1.8rem;
    padding: 6px 16px;
    line-height: 1.1;
}

/* Slightly larger play/pause */
.ss-btn.ss-play {
    font-size: 1.4rem;
    padding: 8px 18px;
}

/* Close button */
.ss-btn.ss-close {
    font-size: 1.2rem;
    padding: 7px 11px;
}

/* ---- Music picker panel ---- */
.ss-music-panel {
    position: absolute;
    top: 64px;
    right: 16px;
    background: rgba(20, 20, 30, 0.88);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 12px;
    padding: 16px 20px;
    color: #fff;
    font-family: 'Segoe UI', sans-serif;
    font-size: 0.9rem;
    z-index: 20;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    min-width: 200px;
    pointer-events: all;
    animation: ss-panel-in 0.2s ease;
}

@keyframes ss-panel-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ss-music-panel p {
    margin: 0 0 10px;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.6);
}

.ss-music-panel label {
    display: block;
    padding: 6px 0;
    cursor: pointer;
    color: rgba(255,255,255,0.9);
    transition: color 0.15s;
}

.ss-music-panel label:hover {
    color: #fff;
}

.ss-music-panel input[type="radio"] {
    accent-color: #fff;
    margin-right: 8px;
}

/* ---- Responsive / mobile ---- */
@media (max-width: 600px) {
    .ss-btn {
        padding: 9px 11px;
        font-size: 1rem;
    }
    .ss-btn.ss-nav {
        font-size: 1.5rem;
        padding: 6px 14px;
    }
    .ss-top, .ss-bottom {
        padding-left: 12px;
        padding-right: 12px;
    }
}
