/* ============================================================================
   Corey & Sarah — Wedding Photo Album
   style.css
   ============================================================================

   EASY SETTINGS
   Change the values in :root below to adjust colours, font and overlay.
   Timing for slides (5 seconds, fade length, Ken Burns) lives in
   js/slideshow.js, in the CONFIG block at the top.
   ========================================================================== */

:root {
    /* Colours */
    --color-background: #000000;         /* behind everything */
    --color-text: #f6f1ea;               /* names and date, a soft ivory */
    --color-text-muted: rgba(246, 241, 234, 0.82);

    /* Typeface — change here and in the Google Fonts link in index.php */
    --font-display: "Cormorant Garamond", "Cormorant", Garamond, "Times New Roman", serif;

    /* Blurred background that fills the empty space around portrait/landscape
       photos. Increase blur for softer, lower brightness for darker. */
    --backdrop-blur: 44px;
    --backdrop-brightness: 0.5;

    /* How dark the gradient behind the names is (0 = none, 1 = black). */
    --shade-strength: 0.6;

    /* Default fade length. JavaScript overrides this per transition. */
    --fade: 1600ms;

    /* Distance of the caption from the screen edges. */
    --edge: clamp(1.5rem, 4.5vw, 4rem);
}

/* ---------------------------------------------------------------------------
   Base: full screen, no scrolling, no selection highlights
   ------------------------------------------------------------------------ */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--color-background);
    color: var(--color-text);
    overscroll-behavior: none;          /* stops pull-to-refresh bounce */
}

body {
    position: fixed;
    inset: 0;
    font-family: var(--font-display);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: pinch-zoom;           /* allow zoom, block panning/scrolling */
}

/* Mouse cursor hides after a few seconds of no movement (set in JS). */
body.is-idle,
body.is-idle * {
    cursor: none;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   Slideshow stage and slides
   ------------------------------------------------------------------------ */

.stage {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;                     /* correct height on mobile browsers */
    overflow: hidden;
    background: var(--color-background);
}

.slide {
    position: absolute;
    inset: 0;
    overflow: hidden;
    opacity: 0;
    z-index: 0;
    transition: opacity var(--fade) cubic-bezier(0.45, 0, 0.25, 1);
    will-change: opacity;
    backface-visibility: hidden;
}

/* Incoming photo: sits on top and fades in. */
.slide.is-active {
    opacity: 1;
    z-index: 2;
}

/* Outgoing photo: stays fully visible underneath while the new one fades in,
   so there is never a dip to black or a flicker between photos. */
.slide.is-leaving {
    opacity: 1;
    z-index: 1;
    transition: none;
}

/* Used briefly by JS to hide a finished slide instantly. */
.slide.is-reset {
    transition: none;
}

/* Blurred, darkened copy of the photo filling the whole screen, so portrait
   photos on a wide screen (or landscape on a phone) never sit on flat black. */
.slide__backdrop {
    position: absolute;
    inset: -12%;
    background-color: var(--color-background);
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    filter: blur(var(--backdrop-blur)) brightness(var(--backdrop-brightness)) saturate(1.15);
    transform: translateZ(0);
}

/* The photo itself: as large as possible while keeping its shape. */
.slide__photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    transform-origin: center center;
    backface-visibility: hidden;
    pointer-events: none;
}

/* ---------------------------------------------------------------------------
   Ken Burns slow zoom (turn on/off in js/slideshow.js → CONFIG.kenBurns)
   JS sets the start/end values randomly for each photo.
   ------------------------------------------------------------------------ */

.slide__photo.kb {
    animation: ken-burns var(--kb-duration, 8s) linear forwards;
    will-change: transform;
}

@keyframes ken-burns {
    from {
        transform: translate3d(var(--kb-x0, 0%), var(--kb-y0, 0%), 0) scale(var(--kb-s0, 1));
    }
    to {
        transform: translate3d(var(--kb-x1, 0%), var(--kb-y1, 0%), 0) scale(var(--kb-s1, 1.08));
    }
}

/* ---------------------------------------------------------------------------
   Dark gradient behind the caption
   ------------------------------------------------------------------------ */

.shade {
    position: fixed;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    background:
        linear-gradient(
            to top,
            rgba(0, 0, 0, var(--shade-strength)) 0%,
            rgba(0, 0, 0, calc(var(--shade-strength) * 0.45)) 18%,
            rgba(0, 0, 0, 0) 42%
        );
    opacity: 0;
    transition: opacity 2.4s ease;
}

/* ---------------------------------------------------------------------------
   Names & date overlay
   ------------------------------------------------------------------------ */

.caption {
    position: fixed;
    z-index: 6;
    left: 0;
    right: 0;
    bottom: 0;
    padding:
        0
        max(var(--edge), env(safe-area-inset-right, 0px))
        max(var(--edge), env(safe-area-inset-bottom, 0px))
        max(var(--edge), env(safe-area-inset-left, 0px));
    text-align: center;
    pointer-events: none;
    text-shadow: 0 1px 24px rgba(0, 0, 0, 0.45);
    opacity: 0;
    transform: translateY(0.6rem);
    transition:
        opacity 2.4s ease 0.6s,
        transform 2.4s cubic-bezier(0.2, 0.7, 0.2, 1) 0.6s;
}

.caption__names {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 300;
    font-size: clamp(2.4rem, 7vw, 5.25rem);
    line-height: 1.05;
    letter-spacing: 0.01em;
    color: var(--color-text);
}

.caption__date {
    margin-top: clamp(0.35rem, 1vw, 0.75rem);
    font-family: var(--font-display);
    font-style: normal;
    font-weight: 500;
    font-size: clamp(0.95rem, 1.7vw, 1.3rem);
    letter-spacing: 0.14em;
    font-variant-numeric: oldstyle-nums;
    color: var(--color-text-muted);
}

/* Caption and shade fade in once the first photo is showing. */
body.is-ready .shade {
    opacity: 1;
}

body.is-ready .caption {
    opacity: 1;
    transform: translateY(0);
}

/* On short landscape phone screens, keep the caption compact. */
@media (max-height: 480px) and (orientation: landscape) {
    .caption__names {
        font-size: clamp(1.8rem, 5vw, 2.6rem);
    }

    .caption__date {
        font-size: 0.9rem;
    }
}

/* ---------------------------------------------------------------------------
   Loading animation: two rings drawing themselves
   ------------------------------------------------------------------------ */

.loader {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: grid;
    place-items: center;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.8s ease, visibility 0s linear 0.8s;
}

.loader.is-visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.6s ease, visibility 0s linear 0s;
}

.loader__rings {
    width: clamp(84px, 14vw, 120px);
    height: auto;
    overflow: visible;
}

.loader__ring {
    fill: none;
    stroke: var(--color-text);
    stroke-width: 1.1;
    stroke-linecap: round;
    stroke-dasharray: 139;              /* ≈ circumference of r=22 */
    stroke-dashoffset: 139;
    transform-box: fill-box;
    transform-origin: center;
    opacity: 0.85;
    animation: ring-draw 2.8s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

.loader__ring--left {
    transform: rotate(-90deg);
}

.loader__ring--right {
    transform: rotate(90deg);
    animation-delay: 0.35s;
}

@keyframes ring-draw {
    0%   { stroke-dashoffset: 139;  opacity: 0.2; }
    45%  { stroke-dashoffset: 0;    opacity: 0.9; }
    60%  { stroke-dashoffset: 0;    opacity: 0.9; }
    100% { stroke-dashoffset: -139; opacity: 0.2; }
}

/* ---------------------------------------------------------------------------
   Empty folder / no JavaScript message
   ------------------------------------------------------------------------ */

.empty {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 2rem;
    max-width: 34rem;
    margin: 0 auto;
    text-align: center;
    font-family: var(--font-display);
    font-size: clamp(1.1rem, 2.4vw, 1.4rem);
    line-height: 1.55;
    color: var(--color-text-muted);
}

.empty[hidden] {
    display: none;
}

/* ---------------------------------------------------------------------------
   Reduced motion: no zoom, gentler fades (respects device accessibility setting)
   ------------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
    .slide__photo.kb {
        animation: none;
    }

    .caption {
        transform: none;
    }

    .loader__ring {
        animation-duration: 5s;
    }
}
