/* ============================================================
   The Waters of Destiny — A Chozla Chronicle
   Palette: royal blue #0B132B · charcoal #111111 · gold #D4AF37 · crimson #8E1616
   ============================================================ */

:root {
    --royal-blue: #0B132B;
    --charcoal: #111111;
    --ink: #050811;
    --gold: #D4AF37;
    --gold-soft: rgba(212, 175, 55, 0.55);
    --crimson: #8E1616;
    --crimson-bright: #C0392B;
    --emerald: #1E6B4F;
    --emerald-bright: #2E9E74;
    --teal: #1F6E8C;
    --teal-bright: #3AA6C9;
    --parchment: #E2E8F0;
    --body-dim: #B8C0CF;
    --font-heading: 'Cinzel', serif;
    --font-body: 'Inter', sans-serif;
}

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

html {
    scroll-behavior: auto; /* Lenis owns smoothing */
}

body {
    font-family: var(--font-body);
    background-color: var(--ink);
    color: var(--parchment);
    overflow-x: hidden;
}

::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--ink);
}
::-webkit-scrollbar-thumb {
    background: var(--gold);
    border-radius: 4px;
}

/* ---------- Fixed chrome ---------- */

.wordmark {
    position: fixed;
    top: 1.4rem;
    left: 1.6rem;
    z-index: 40;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: var(--gold);
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

.progress {
    position: fixed;
    bottom: 1.4rem;
    right: 1.6rem;
    z-index: 40;
    font-family: var(--font-heading);
    font-size: 0.72rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--gold-soft);
    border-bottom: 1px solid rgba(212, 175, 55, 0.35);
    padding-bottom: 0.3rem;
    pointer-events: none;
}

.scroll-hint {
    position: fixed;
    bottom: 2.2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    color: var(--gold);
    pointer-events: none;
}

.scroll-hint__text {
    font-size: 0.7rem;
    letter-spacing: 0.4em;
    text-transform: uppercase;
}

.scroll-hint__arrow {
    font-size: 1.1rem;
    animation: hint-bounce 1.6s ease-in-out infinite;
}

@keyframes hint-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(7px); }
}

/* ---------- Pinned stage ---------- */

.scrolly {
    position: relative;
    width: 100%;
}

.stage {
    position: sticky;
    top: 0;
    width: 100%;
    height: 100vh;
    height: 100svh;
    overflow: hidden;
    background: var(--royal-blue);
}

.scene-bg {
    position: absolute;
    inset: 0;
}

/* <picture> is inline by default, which would leave the img with no box to
   fill; make it a plain block so the img still sizes against .scene-bg. */
.scene-bg picture {
    display: block;
    width: 100%;
    height: 100%;
}

.scene-bg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    will-change: transform;
}

/* Every scene after the first starts hidden; ScrollTrigger fades each in. */
.scene-bg:not(#bg-scene-1) {
    opacity: 0;
}

.vignette {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(to bottom,
            rgba(5, 8, 17, 0.55) 0%,
            rgba(5, 8, 17, 0.05) 30%,
            rgba(5, 8, 17, 0.05) 62%,
            rgba(5, 8, 17, 0.65) 100%),
        radial-gradient(ellipse at center,
            transparent 55%,
            rgba(5, 8, 17, 0.45) 100%);
    pointer-events: none;
}

/* ---------- Dialogue overlays ---------- */

.dialogue {
    position: absolute;
    bottom: 10%;
    left: 50%;
    transform: translateX(-50%);
    width: min(94%, 38rem);
    padding: 1.4rem 1.8rem;
    background: rgba(5, 8, 17, 0.92);
    border: 1px solid var(--gold-soft);
    border-radius: 1rem;
    box-shadow: 0 14px 45px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
}

.dialogue--crimson {
    border-color: rgba(192, 57, 43, 0.6);
}

.dialogue--emerald {
    border-color: rgba(46, 158, 116, 0.6);
}

.dialogue--teal {
    border-color: rgba(58, 166, 201, 0.6);
}

/* Most scenes are a two-speaker exchange: the turns stack inside one panel,
   separated by a hairline in the panel's own accent colour. */
.dialogue__line + .dialogue__line {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(212, 175, 55, 0.28);
}

.dialogue--crimson .dialogue__line + .dialogue__line {
    border-top-color: rgba(192, 57, 43, 0.32);
}

.dialogue--emerald .dialogue__line + .dialogue__line {
    border-top-color: rgba(46, 158, 116, 0.32);
}

.dialogue--teal .dialogue__line + .dialogue__line {
    border-top-color: rgba(58, 166, 201, 0.32);
}

/* A line that is thought rather than spoken. Applied per line, not per panel,
   because a scene can pair one character's speech with another's thought. */
.dialogue__line--thought {
    border-left: 2px dashed var(--gold-soft);
    padding-left: 0.9rem;
}

.dialogue--crimson .dialogue__line--thought {
    border-left-color: rgba(192, 57, 43, 0.6);
}

.dialogue--emerald .dialogue__line--thought {
    border-left-color: rgba(46, 158, 116, 0.6);
}

.dialogue--teal .dialogue__line--thought {
    border-left-color: rgba(58, 166, 201, 0.6);
}

.dialogue__speaker {
    font-family: var(--font-heading);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 0.45rem;
}

.dialogue--crimson .dialogue__speaker {
    color: var(--crimson-bright);
}

.dialogue--emerald .dialogue__speaker {
    color: var(--emerald-bright);
}

.dialogue--teal .dialogue__speaker {
    color: var(--teal-bright);
}

.dialogue__speaker em {
    font-family: var(--font-body);
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0.05em;
    opacity: 0.75;
}

.dialogue__text {
    font-size: clamp(0.9rem, 1.4vw, 1.05rem);
    font-style: italic;
    font-weight: 300;
    line-height: 1.65;
    color: var(--parchment);
}

/* ---------- Narrative tracks & cards ---------- */

.scene-track {
    position: relative;
    z-index: 10;
    height: 250vh;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 0 clamp(1rem, 7vw, 7rem);
    pointer-events: none;
}

.narrative-card {
    pointer-events: auto;
    width: min(100%, 30rem);
    padding: 2.2rem 2.4rem;
    background: rgba(5, 8, 17, 0.82);
    border-left: 3px solid var(--gold);
    border-radius: 0 1rem 1rem 0;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    will-change: transform, opacity;
}

.narrative-card--crimson {
    border-left-color: var(--crimson);
}

.narrative-card--emerald {
    border-left-color: var(--emerald);
}

.narrative-card--teal {
    border-left-color: var(--teal);
}

.narrative-card__kicker {
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.45em;
    text-transform: uppercase;
    color: var(--gold-soft);
    margin-bottom: 0.8rem;
}

.narrative-card--crimson .narrative-card__kicker {
    color: rgba(192, 57, 43, 0.8);
}

.narrative-card--emerald .narrative-card__kicker {
    color: rgba(46, 158, 116, 0.8);
}

.narrative-card--teal .narrative-card__kicker {
    color: rgba(58, 166, 201, 0.8);
}

.narrative-card__title {
    font-family: var(--font-heading);
    font-size: clamp(1.4rem, 2.6vw, 1.9rem);
    font-weight: 700;
    line-height: 1.25;
    color: var(--gold);
}

.narrative-card--crimson .narrative-card__title {
    color: var(--crimson-bright);
}

.narrative-card--emerald .narrative-card__title {
    color: var(--emerald-bright);
}

.narrative-card--teal .narrative-card__title {
    color: var(--teal-bright);
}

.narrative-card__subtitle {
    display: block;
    font-size: 0.62em;
    font-weight: 500;
    letter-spacing: 0.14em;
    color: var(--parchment);
    opacity: 0.75;
    margin-top: 0.35rem;
}

.ornament {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 1.1rem 0 1.2rem;
}

.ornament span:not(.ornament__gem) {
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--gold-soft), transparent);
}

.ornament__gem {
    width: 7px;
    height: 7px;
    background: var(--gold);
    transform: rotate(45deg);
    flex: none;
}

.narrative-card--crimson .ornament__gem {
    background: var(--crimson-bright);
}

.narrative-card--emerald .ornament__gem {
    background: var(--emerald-bright);
}

.narrative-card--teal .ornament__gem {
    background: var(--teal-bright);
}

.narrative-card__body {
    font-size: clamp(0.92rem, 1.3vw, 1.02rem);
    font-weight: 300;
    line-height: 1.8;
    color: var(--body-dim);
}

/* ---------- Outro ---------- */

.outro {
    position: relative;
    min-height: 120vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: clamp(4rem, 12vh, 8rem) 1.5rem;
    background:
        linear-gradient(to bottom, rgba(5, 8, 17, 0) 0%, var(--ink) 18%),
        var(--ink);
    text-align: center;
}

.outro__card {
    max-width: 38rem;
}

.outro__kicker {
    font-family: var(--font-heading);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.45em;
    text-transform: uppercase;
    color: var(--gold-soft);
    margin-bottom: 1rem;
}

.outro__title {
    font-family: var(--font-heading);
    font-size: clamp(1.7rem, 4vw, 2.6rem);
    font-weight: 700;
    line-height: 1.3;
    color: var(--gold);
}

.outro .ornament {
    max-width: 16rem;
    margin: 1.4rem auto 1.5rem;
}

.outro__body {
    font-size: clamp(0.95rem, 1.4vw, 1.05rem);
    font-weight: 300;
    line-height: 1.85;
    color: var(--body-dim);
}

.outro__credits {
    margin-top: 2.6rem;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    color: var(--gold-soft);
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    .scroll-hint__arrow {
        animation: none;
    }
    .scene-bg,
    .dialogue,
    .narrative-card {
        transition: opacity 0.4s ease;
    }
}

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
    .scene-track {
        justify-content: center;
        padding: 0 1rem;
    }
    .narrative-card {
        padding: 1.6rem 1.5rem;
    }
    .dialogue {
        bottom: 6%;
        padding: 1.1rem 1.3rem;
    }
    /* Two stacked turns need the vertical room on a phone. */
    .dialogue__line + .dialogue__line {
        margin-top: 0.7rem;
        padding-top: 0.7rem;
    }
    .dialogue__line--thought {
        padding-left: 0.7rem;
    }
    .wordmark {
        font-size: 0.68rem;
        left: 1rem;
    }
}

/* Scenes 2-15 are loaded by JS, so with scripts off the stage would be blank.
   The <noscript> fallback stacks the art plainly; only parsed when JS is off. */
.noscript-scenes {
    position: relative;
    z-index: 3;
}

.noscript-scenes img {
    width: 100%;
    height: auto;
    display: block;
}
