/* ───────────────────────────────────────────────
   Story mode — scroll-snap block engine
   Loaded only on single-work posts with _eh_story_mode = 'story'.
   ─────────────────────────────────────────────── */

body.eh-story,
html:has(body.eh-story) {
    overflow: hidden;
    height: 100vh;
}

body.eh-story .site-footer { display: none; }

/* Scroll container — owns the snap behaviour. */
.story-stage {
    position: fixed;
    inset: 0;
    overflow-y: scroll;
    overflow-x: hidden;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
    z-index: 1;
}
.story-stage::-webkit-scrollbar { display: none; }

.story-screen {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    overflow: hidden;
    display: flex;
}

.story-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
}
.story-bg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ── HERO SCREEN ── */
.story-hero { align-items: flex-end; padding: 3rem 2.5rem; }
.story-hero .story-bg img { opacity: 0.5; }
.story-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(8,8,8,0.95) 0%, rgba(8,8,8,0.2) 60%, transparent 100%);
    z-index: 0;
}
.story-hero-inner {
    position: relative;
    z-index: 1;
    max-width: 900px;
}

/* ── IMAGE + OVERLAY ── */
.story-overlay { padding: 4rem 3rem; }
.story-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 35%, rgba(0,0,0,0) 65%, rgba(0,0,0,0.55) 100%);
    z-index: 0;
}
.story-overlay-text {
    position: relative;
    z-index: 1;
    max-width: 640px;
}
.story-overlay-text h2 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(2.4rem, 6vw, 5rem);
    letter-spacing: 0.05em;
    line-height: 0.95;
    margin-bottom: 1rem;
}
.story-overlay-text p {
    font-size: 1.05rem;
    line-height: 1.65;
    font-weight: 300;
}

.story-overlay.theme-light .story-overlay-text { color: #fff; text-shadow: 0 1px 12px rgba(0,0,0,0.45); }
.story-overlay.theme-light .story-overlay-text p { color: #ececec; }
.story-overlay.theme-dark  .story-overlay-text { color: #0a0a0a; text-shadow: 0 1px 8px rgba(255,255,255,0.35); }
.story-overlay.theme-dark  .story-overlay-text p { color: #1a1a1a; }
.story-overlay.theme-dark::after {
    background: linear-gradient(180deg, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0) 35%, rgba(255,255,255,0) 65%, rgba(255,255,255,0.28) 100%);
}

/* 9-position grid for overlay text */
.story-overlay { align-items: center; justify-content: center; }
.story-overlay.pos-top-left      { align-items: flex-start; justify-content: flex-start; }
.story-overlay.pos-top-center    { align-items: flex-start; justify-content: center; text-align: center; }
.story-overlay.pos-top-right     { align-items: flex-start; justify-content: flex-end; text-align: right; }
.story-overlay.pos-middle-left   { align-items: center; justify-content: flex-start; }
.story-overlay.pos-middle-center { align-items: center; justify-content: center; text-align: center; }
.story-overlay.pos-middle-right  { align-items: center; justify-content: flex-end; text-align: right; }
.story-overlay.pos-bottom-left   { align-items: flex-end; justify-content: flex-start; }
.story-overlay.pos-bottom-center { align-items: flex-end; justify-content: center; text-align: center; }
.story-overlay.pos-bottom-right  { align-items: flex-end; justify-content: flex-end; text-align: right; }

/* ── SPLIT ── */
.story-split { padding: 0; }
.story-split-media,
.story-split-text { flex: 1 1 50%; min-width: 0; height: 100%; position: relative; }
.story-split-media { background: #0f0f0f; overflow: hidden; }
.story-split-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.story-split-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4rem 3.5rem;
    background: var(--dark);
}
.story-split.side-right { flex-direction: row-reverse; }
.story-split-text h2 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(2rem, 4.5vw, 3.6rem);
    letter-spacing: 0.05em;
    line-height: 0.98;
    margin-bottom: 1.2rem;
    color: var(--text);
}
.story-split-text p {
    font-size: 1.05rem;
    line-height: 1.7;
    color: #b0b0b0;
    max-width: 540px;
}

/* ── TEXT / QUOTE ── */
.story-text {
    align-items: center;
    justify-content: center;
    padding: 4rem 3rem;
    background: var(--dark);
}
.story-text-inner { max-width: 1000px; width: 100%; }
.story-text.align-center .story-text-inner { text-align: center; margin: 0 auto; }
.story-text.align-left   .story-text-inner { text-align: left; margin-right: auto; }

.story-text h2 {
    font-family: 'Bebas Neue', sans-serif;
    letter-spacing: 0.05em;
    line-height: 0.95;
    color: var(--text);
    margin-bottom: 1.2rem;
}
.story-text p {
    font-weight: 300;
    color: #cfcfcf;
    line-height: 1.5;
}
.story-text.size-large h2 { font-size: clamp(3rem, 7vw, 6rem); }
.story-text.size-large p  { font-size: clamp(1.4rem, 2.5vw, 2.1rem); line-height: 1.4; }
.story-text.size-regular h2 { font-size: clamp(2rem, 4vw, 3rem); }
.story-text.size-regular p  { font-size: 1.1rem; line-height: 1.7; }

/* big quote dressing when no title is set */
.story-text.size-large .story-text-inner:not(:has(h2)) p::before { content: '"'; color: var(--accent); margin-right: 0.1em; }
.story-text.size-large .story-text-inner:not(:has(h2)) p::after  { content: '"'; color: var(--accent); margin-left: 0.1em; }

/* ── OUTRO ── */
.story-outro {
    align-items: center;
    justify-content: center;
    text-align: center;
    background: var(--dark);
    padding: 4rem 3rem;
}
.story-outro-inner { display: flex; flex-direction: column; align-items: center; gap: 1.4rem; }
.outro-eyebrow {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.8rem;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: var(--accent);
}
.outro-next {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(2.4rem, 6vw, 5rem);
    letter-spacing: 0.05em;
    line-height: 1;
    color: var(--text);
    text-decoration: none;
    transition: color 0.2s;
}
.outro-next:hover { color: var(--accent); }
.outro-home {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.78rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--dim);
    text-decoration: none;
    margin-top: 0.8rem;
    transition: color 0.2s;
}
.outro-home:hover { color: var(--text); }

/* ── NAVIGATION CHROME ── */
.story-nav {
    position: fixed;
    right: 1.6rem;
    z-index: 50;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 50%;
    background: rgba(8,8,8,0.65);
    border: 1px solid #2a2a2a;
    color: var(--text);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    transition: opacity 0.2s, transform 0.2s, border-color 0.2s, background 0.2s;
}
.story-nav:hover { border-color: var(--accent); background: rgba(8,8,8,0.85); }
.story-nav-prev { bottom: calc(50% + 1.6rem); }
.story-nav-next { top: calc(50% + 1.6rem); }
.story-nav[disabled] { opacity: 0.2; pointer-events: none; }

.story-dots {
    position: fixed;
    right: 2.55rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 49;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    pointer-events: none;
}
.story-dot {
    pointer-events: auto;
    width: 0.5rem;
    height: 0.5rem;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    border: 1px solid #555;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
}
.story-dot:hover { border-color: var(--text); }
.story-dot.is-active {
    background: var(--accent);
    border-color: var(--accent);
    transform: scale(1.25);
}

/* Header tweaks on story mode — keep it but subdue it. */
body.eh-story .site-header {
    background: transparent;
    border-bottom: none;
    backdrop-filter: none;
    mix-blend-mode: difference;
}

/* ── MOBILE ── */
@media (max-width: 760px) {
    .story-split { flex-direction: column !important; }
    .story-split-media { flex: 0 0 45%; }
    .story-split-text { flex: 1 1 auto; padding: 2rem 1.5rem; }
    .story-overlay { padding: 3rem 1.5rem; }
    .story-hero { padding: 2rem 1.5rem; }
    .story-text { padding: 3rem 1.5rem; }
    .story-nav { right: 0.8rem; width: 2.2rem; height: 2.2rem; }
    .story-nav-prev { bottom: calc(50% + 1.2rem); }
    .story-nav-next { top: calc(50% + 1.2rem); }
    .story-dots { right: 1.55rem; }
}

/* ───────────────────────────────────────────────
   Overflow handling — when a screen's copy is taller
   than the viewport, scroll it inside the screen
   instead of clipping it (overflow:hidden above).
   Wheel/touch keep using native scroll-snap; the
   inner scroller consumes the gesture first, then a
   second gesture snaps onward (overscroll: contain).
   Added 2026-06-11.
   ─────────────────────────────────────────────── */

.story-hero-inner,
.story-overlay-text,
.story-text-inner {
    max-height: 100%;                  /* never taller than its screen's content box */
    overflow-y: auto;                  /* scrollbar only appears when it actually overflows */
    overscroll-behavior: contain;      /* don't chain-snap to the next screen until the end */
    -webkit-overflow-scrolling: touch; /* momentum scrolling on iOS */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.35) transparent;
}

/* The split panel has no inner wrapper — let the text column scroll
   itself, and keep it vertically centred only while the copy fits
   (safe center falls back to top-aligned once it overflows, so the
   first line stays reachable). */
.story-split-text {
    overflow-y: auto;
    justify-content: safe center;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.35) transparent;
}

/* Slim WebKit/Blink scrollbar to match the dark UI. */
.story-hero-inner::-webkit-scrollbar,
.story-overlay-text::-webkit-scrollbar,
.story-text-inner::-webkit-scrollbar,
.story-split-text::-webkit-scrollbar { width: 6px; }
.story-hero-inner::-webkit-scrollbar-thumb,
.story-overlay-text::-webkit-scrollbar-thumb,
.story-text-inner::-webkit-scrollbar-thumb,
.story-split-text::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
}
.story-hero-inner::-webkit-scrollbar-track,
.story-overlay-text::-webkit-scrollbar-track,
.story-text-inner::-webkit-scrollbar-track,
.story-split-text::-webkit-scrollbar-track { background: transparent; }

/* Dark-theme overlay text sits on a light image — use a dark thumb there. */
.story-overlay.theme-dark .story-overlay-text { scrollbar-color: rgba(0,0,0,0.4) transparent; }
.story-overlay.theme-dark .story-overlay-text::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.4); }
