/* ===========================================================
   SSK deck carousel + rotating disk
   Scroll-cycle behaviour ported from the BigHeadz town portal.
   =========================================================== */

.deck-section {
    background: linear-gradient(135deg, #0a1628 0%, #1a365d 100%);
    padding: 1rem 0;
    position: relative;
    overflow: hidden;
}

.deck-section .section-title h2 { color: #fff; }

.visually-hidden-deck {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Self-describing header: swaps to the current slide instead of a
   standing "The Deck" title. */
.deck-nowplaying {
    text-align: center;
    margin: 0 auto 0.6rem;
    min-height: 3rem;
}

.deck-now-kind {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 0.6rem;
    transition: opacity 0.3s ease;
}

.deck-now-title {
    font-family: 'Syne', sans-serif;
    font-size: clamp(1.4rem, 3.4vw, 2.1rem);
    font-weight: 700;
    line-height: 1.1;
    color: #fff;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    transition: opacity 0.3s ease, transform 0.45s cubic-bezier(0.22, 0.85, 0.24, 1);
}

.deck-nowplaying.is-changing .deck-now-title,
.deck-nowplaying.is-changing .deck-now-kind {
    opacity: 0;
    transform: translateY(10px);
}

.deck-shell {
    /* Was 1100px -- the stage measured only 58% of viewport width / 65% of
       viewport height at 1440x900, nowhere near "closer to full screen".
       Widened so the active slide reads as the dominant thing on the
       section rather than a card floating in a lot of navy. */
    max-width: 1480px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ---------- stage ---------- */
/* 3D coverflow stage.
   Aspect comes from the real slide dimensions (set by JS from deck.json) —
   the deck pages are 1.42:1, not 16:9.
   overflow is visible so neighbouring slides can sit outside the frame. */
/* Height-capped so the whole carousel — title, stage and controls — fits
   between the sticky header and the fold. Without this the stage was taller
   than the usable viewport and the sticky header sat on top of the slide
   title while you were cycling. */
.deck-stage {
    position: relative;
    aspect-ratio: var(--deck-aspect, 1.42);
    /* Was 100vh - 312px. The 312px reserve covered the header, now-playing
       title, and the controls/dots row below -- tightened those (see the
       rules further down) to free real height rather than just shrinking
       this number and risking the stage clipping under the header again. */
    max-height: calc(100vh - 250px);
    width: auto;
    max-width: 100%;
    margin: 0 auto;
    perspective: 2200px;
    perspective-origin: 50% 50%;
    transform-style: preserve-3d;
    overflow: visible;
}

/* The frame behind the active slide.
   This used to be filled #060d18. That fill is what everyone kept seeing as
   "a black screen between slides": any moment a slide wasn't painted — mid
   3D transition, or while its artwork decoded — the fill showed through as a
   solid black rectangle exactly the size of a slide. It was never a missing
   image; the measured artwork is normally lit and every file returns 200.
   Transparent now, so the worst case is the section's own navy gradient. The
   border and shadow still read as a frame. */
.deck-stage::before {
    content: '';
    position: absolute;
    inset: 0;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
    z-index: 0;
}

/* Coverflow slide.
   JS sets --i (signed offset from the active slide) and the transform is
   derived from it, so neighbours fan out in 3D either side of the current
   page. Same idea as the BigHeadz town portal ring, adapted for 21 slides:
   a full 360/21 ring would be unreadable, so only +/-3 are kept on stage. */
.deck-slide {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    transform-origin: 50% 50%;
    transition:
        transform 0.75s cubic-bezier(0.22, 0.85, 0.24, 1),
        opacity 0.55s ease,
        filter 0.55s ease;
    will-change: transform, opacity;

    /* default: parked offstage.
       Spread values are custom properties so narrow screens can pull the
       neighbours in — at 700px a 54% offset threw them right off the
       section and only the clip on .deck-section kept the page from
       scrolling sideways. */
    opacity: 0;
    pointer-events: none;
    z-index: 0;
    transform:
        translateX(calc(var(--i, 0) * var(--deck-spread, 54%)))
        translateZ(var(--deck-depth, -460px))
        rotateY(calc(var(--i, 0) * var(--deck-tilt, -38deg)))
        scale(var(--deck-shrink, 0.82));
}

/* neighbours: visible, angled, dimmed */
.deck-slide.is-near {
    opacity: calc(1 - (var(--d, 1) * 0.26));
    filter: brightness(calc(1 - (var(--d, 1) * 0.28))) saturate(0.85);
    z-index: calc(10 - var(--d, 1));
    cursor: pointer;
    pointer-events: auto;
}

/* the current page: square on, front and centre */
.deck-slide.is-active {
    opacity: 1;
    filter: none;
    z-index: 20;
    pointer-events: auto;
    transform: translateX(0) translateZ(0) rotateY(0deg) scale(1);
    box-shadow: 0 26px 70px rgba(0, 0, 0, 0.55);
}

/* the global `img{height:auto!important}` rule in index.html would squash
   these, so the class has to win on specificity */
.deck-slide img.deck-slide-img {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    /* contain, never cover — a pitch deck must not lose its edges */
    object-fit: contain;
    display: block;
}

.deck-slide picture {
    display: block;
    width: 100%;
    height: 100%;
}

.deck-slide-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    padding: 2.5rem 1.75rem 1.25rem;
    background: linear-gradient(transparent, rgba(4, 10, 20, 0.92));
    color: #fff;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    pointer-events: none;
}

.deck-slide-title {
    font-family: 'Syne', sans-serif;
    font-size: clamp(1rem, 2.2vw, 1.5rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0;
}

.deck-slide-kind {
    font-size: 0.625rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 0.35rem;
}

/* ---------- controls ---------- */
.deck-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    margin-top: 0.6rem;
    flex-wrap: wrap;
}

.deck-arrow {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

.deck-arrow:hover:not(:disabled) {
    background: #fff;
    color: #0a1628;
    transform: scale(1.06);
}

.deck-arrow:disabled { opacity: 0.3; cursor: default; }

.deck-dots {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    /* margin:0 auto was missing, so this 560px box sat flush-left in the
       1100px shell while the dots centred inside it — the row read as
       left-aligned against centred arrows. */
    max-width: 560px;
    margin: 0.85rem auto 0;
}

.deck-dot {
    width: 9px;
    height: 9px;
    padding: 0;
    border: none;
    background: rgba(255, 255, 255, 0.28);
    cursor: pointer;
    transition: background 0.25s ease, transform 0.25s ease;
}

.deck-dot:hover { background: rgba(255, 255, 255, 0.6); }

.deck-dot.is-active {
    background: #fff;
    transform: scale(1.5);
}

.deck-counter {
    font-family: 'Syne', sans-serif;
    font-size: 0.8rem;
    letter-spacing: 0.18em;
    color: rgba(255, 255, 255, 0.75);
    min-width: 76px;
    text-align: center;
}

.deck-hint {
    text-align: center;
    margin-top: 0.55rem;
    font-size: 0.625rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.35);
    transition: opacity 0.3s ease;
}

.deck-shell.is-engaged .deck-hint { opacity: 0; }

/* progress bar across the top of the stage */
.deck-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 3px;
    background: #fff;
    z-index: 5;
    transition: width 0.45s ease;
}

/* ===========================================================
   Rotating disk
   =========================================================== */
.deck-disk {
    position: absolute;
    right: 1.75rem;
    bottom: 1.75rem;
    z-index: 4;
    width: clamp(88px, 13vw, 132px);
    aspect-ratio: 1;
    border: none;
    padding: 0;
    background: none;
    cursor: pointer;
    border-radius: 50%;
    filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.55));
    transition: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

.deck-disk:hover,
.deck-disk:focus-visible { transform: scale(1.08); }

/* Idle "click me" aurora.
   Nothing on the disk said it was interactive until you hovered it, and by
   then you'd already found it by accident. A soft pulsing ring behind the
   disk invites the first click; it hands off to the existing .is-playing
   glow once there's actually something to signal, so the two states never
   compete. Sits behind the disk's own children (z-index: -1 inside the
   disk's own stacking context, which .deck-disk establishes via
   position: absolute), so it can't intercept clicks meant for the disk. */
.deck-disk::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: 50%;
    /* box-shadow rather than a background gradient: a gradient's own alpha
       falloff got lost against a real photo behind it -- confirmed by
       swapping in a solid debug colour, which rendered perfectly, proving
       the stacking was fine and the effect was just too subtle to read.
       box-shadow paints its blur outside the circle regardless of what's
       underneath, which is far more reliable across 21 different slide
       photos than a translucent gradient competing with image detail. */
    box-shadow:
        0 0 30px 8px rgba(140, 205, 255, 0.85),
        0 0 55px 18px rgba(150, 190, 255, 0.6),
        0 0 90px 32px rgba(180, 140, 255, 0.35);
    opacity: 0;
    animation: deck-disk-aurora 2.6s ease-in-out infinite;
    pointer-events: none;
}

/* Pausing an animation freezes it wherever it was mid-cycle rather than
   hiding it — the ring was showing up to 85% opacity on hover, whatever
   point the pulse happened to be at. animation: none removes the keyframe's
   hold on the property entirely, so the plain opacity: 0 below it actually
   applies. */
.deck-disk.is-playing::before,
.deck-disk:hover::before,
.deck-disk:focus-visible::before {
    animation: none;
    opacity: 0;
}

@keyframes deck-disk-aurora {
    0%, 100% { opacity: 0; }
    50%      { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    /* Still an invitation to click, just not a moving one. */
    .deck-disk::before {
        animation: none;
        opacity: 0.4;
        transform: scale(1.05);
    }
    .deck-disk.is-playing::before { opacity: 0; }
}

.deck-disk-face {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background:
        radial-gradient(circle at 50% 50%,
            #d8d2c4 0 17%,
            #12100e 17.5% 19%,
            #1b1917 19% 100%),
        repeating-radial-gradient(circle at 50% 50%,
            rgba(255, 255, 255, 0.05) 0 1px,
            rgba(0, 0, 0, 0) 1px 4px);
    background-blend-mode: overlay;
    box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.85);
    animation: deck-disk-spin 3.2s linear infinite;
    animation-play-state: paused;
}

/* artwork sits in the label area */
.deck-disk-label {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 34%;
    height: 34%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    object-fit: cover;
    z-index: 2;
    animation: deck-disk-spin 3.2s linear infinite;
    animation-play-state: paused;
    max-width: none !important;
    height: 34% !important;
}

/* spindle hole */
.deck-disk-face::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6%;
    height: 6%;
    transform: translate(-50%, -50%);
    background: #060d18;
    border-radius: 50%;
    z-index: 3;
}

.deck-disk.is-playing .deck-disk-face,
.deck-disk.is-playing .deck-disk-label,
.deck-disk.is-spinning .deck-disk-face,
.deck-disk.is-spinning .deck-disk-label { animation-play-state: running; }

.deck-disk.is-playing {
    box-shadow:
        0 0 0 2px rgba(255, 255, 255, 0.5),
        0 0 34px 8px rgba(120, 180, 255, 0.55);
}

/* little play/pause badge */
.deck-disk-badge {
    position: absolute;
    right: -4px;
    bottom: -4px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #fff;
    color: #0a1628;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    z-index: 4;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

.deck-disk[hidden] { display: none; }

/* Only the front slide offers a record — neighbours showing theirs put
   stray discs floating in the fan. */
.deck-slide:not(.is-active) .deck-disk {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

@keyframes deck-disk-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* label needs to keep its centring translate while spinning */
@keyframes deck-disk-spin-label {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to   { transform: translate(-50%, -50%) rotate(360deg); }
}

.deck-disk-label { animation-name: deck-disk-spin-label; }

/* ===========================================================
   Responsive
   =========================================================== */
@media (max-width: 1100px) {
    .deck-stage { --deck-spread: 42%; --deck-depth: -360px; --deck-tilt: -32deg; }
}

@media (max-width: 768px) {
    /* neighbours only peek in; a wide fan is unreadable at this size */
    .deck-stage {
        --deck-spread: 30%;
        --deck-depth: -260px;
        --deck-tilt: -26deg;
        --deck-shrink: 0.86;
        perspective: 1400px;
    }

    .deck-section { padding: 3rem 0; }
    .deck-shell { padding: 0 0.75rem; }
    .deck-slide-caption { padding: 2rem 1rem 0.9rem; }
    .deck-disk { right: 0.9rem; bottom: 0.9rem; }
    .deck-controls { gap: 0.75rem; }
    .deck-dots { max-width: 100%; gap: 0.3rem; }
    .deck-dot { width: 7px; height: 7px; }
    .deck-counter { min-width: 64px; font-size: 0.7rem; }
}

/* ===========================================================
   Reduced motion: no scroll hijack, no spin.
   JS reads this same query and disables the wheel handler, so the
   section degrades to a plain horizontal scroll-snap strip.
   =========================================================== */
@media (prefers-reduced-motion: reduce) {
    .deck-stage {
        aspect-ratio: auto;
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        gap: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }

    .deck-slide {
        position: relative;
        inset: auto;
        opacity: 1;
        visibility: visible;
        transform: none;
        transition: none;
        flex: 0 0 88%;
        scroll-snap-align: center;
        aspect-ratio: 16 / 9;
    }

    .deck-disk-face,
    .deck-disk-label { animation: none !important; }

    .deck-progress { display: none; }
}

/* ---- loading state -------------------------------------------------------
   Each slide carries a 24px blurred copy of its own artwork as an inline
   data URI (see scripts/add-deck-lqip.py), painted as the element's
   background. It costs no request, so it's on screen in the first frame and
   the slide is never an empty box while the full image downloads.

   An earlier attempt used a navy gradient plus a shimmer, which changed
   nothing visible: the frame behind the slides is #060d18, so that was one
   near-black box swapped for another. A blurred version of the actual slide
   reads instantly as "this is arriving". */
.deck-slide {
    background-repeat: no-repeat;
    background-position: center;
    /* contain, to match object-fit on the img — a pitch deck must keep its
       edges, and a cover-sized blur behind a contained image misaligns. */
    background-size: contain;
}

/* Fade the real artwork in over its own placeholder. */
.deck-slide img.deck-slide-img {
    opacity: 0;
    transition: opacity 0.35s ease;
}
.deck-slide.is-loaded img.deck-slide-img { opacity: 1; }

/* Belt and braces: if the load event never arrives (cache quirk, decode
   failure), don't strand the slide on its blur forever. */
.deck-slide img.deck-slide-img[src]:not([src=""]) { animation: deck-reveal 0s 4s forwards; }
@keyframes deck-reveal { to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
    .deck-slide img.deck-slide-img { transition: none; }
}
