/* story.css: a work card's story (story.js, story-render.js). Layout A, approved 2026-10-14. Page tokens only. */

/* ---- the page behind: fades to paper and stops; the scrollbar keeps its room so the card never moves ---- */
:root.story-open { overflow: hidden; scrollbar-gutter: stable; }
:root.story-fade body { transition: opacity 320ms ease, background-color 500ms var(--ease-out), color 500ms var(--ease-out); }
:root.story-open body { opacity: 0; }
:root.story-open.story-sheet body { opacity: 1; } /* phone: the page stays in view and shrinks back (story-phone.js) */
.card__media.is-away { visibility: hidden; }

/* ---- the layer: plain paper (the page fading out under it is what the eye reads as the page clearing) ---- */
.story { position: fixed; inset: 0; z-index: 80; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable;
         outline: none; color: var(--ink); font-family: var(--font); font-size: var(--fs-body); line-height: 1.45;
         -webkit-font-smoothing: antialiased; /* it lives outside <body>, so it sets body's type itself */ --st-col: min(calc(min(100vw, 1440px) - 2 * var(--gap)), 900px, calc((100vh - 170px) * var(--st-arn, 1.3333))); }
.story[hidden] { display: none; }
.story__body { width: var(--st-col); margin: 0 auto; padding: 84px 0 clamp(4rem, 10vh, 6rem); }

/* desktop: no bar, only the X, fixed top right */
.story__bar { position: fixed; top: 20px; right: 24px; z-index: 2; }
.story__label { display: none; }
.story__x { width: 44px; height: 44px; border-radius: 999px; display: grid; place-items: center; cursor: pointer;
            border: 1px solid var(--line); background: var(--paper); color: var(--ink);
            transition: transform 220ms var(--ease-out), opacity 300ms ease 200ms, background-color var(--theme-t) var(--theme-ease),
                        color var(--theme-t) var(--theme-ease); }
@media (hover: hover) { .story__x:hover { transform: scale(1.05); } }

/* everything but the film rises in after it starts moving, and fades first on the way out */
.story__body > :not(.st-film) { transition: opacity 420ms ease 180ms, transform 520ms var(--ease-out) 180ms; }
.story.is-pre .story__body > :not(.st-film), .story.is-pre .story__x { opacity: 0; transform: translateY(16px); }
.story.is-going .story__body > :not(.st-film), .story.is-going .story__x { opacity: 0; transition-delay: 0s; transition-duration: 200ms; }

/* ---- the film ---- */
.st-film { position: relative; aspect-ratio: var(--st-ar, 4 / 3); border-radius: var(--radius-media); overflow: hidden;
           background: var(--paper-2); cursor: pointer; will-change: transform; }
.st-film video, .st-film__still { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; }
.st-film.is-flying { z-index: 3; }
/* the visitor's own pause: the card's pause mark, held for as long as the film stays paused */
.st-film__pause { position: absolute; left: 16px; bottom: 16px; z-index: 2; width: 40px; height: 40px; border-radius: 999px;
                  display: grid; place-items: center; background: var(--tab-bg); color: var(--tab-text); pointer-events: none;
                  opacity: 0; transform: scale(.92); transition: opacity 700ms var(--ix-ease), transform 700ms var(--ix-ease); }
.st-film__pause svg { width: 16px; height: 16px; fill: currentColor; }
.st-film.is-paused .st-film__pause { opacity: 1; transform: none; transition: opacity 200ms var(--ix-ease), transform 260ms var(--ease-out); }
.st-film:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---- header: title, lede, meta ---- */
.st-head { display: grid; gap: 1.25rem; margin-top: clamp(2.5rem, 5vw, 4rem); }
.st-pill { display: inline-block; padding: .3em .75em; border-radius: 999px; background: var(--paper-2); color: var(--ink-2); font-size: 13px; }
.st-title { margin: .5rem 0 0; font-size: clamp(2rem, 3.4vw, 3rem); font-weight: 450; letter-spacing: -0.025em; line-height: 1.05; }
.st-lede { margin: 0; font-size: clamp(1.15rem, 1.45vw, 1.35rem); line-height: 1.5; color: var(--ink-2); max-width: 56ch; }
.st-lede b { display: block; margin-bottom: .35em; color: var(--ink); font-weight: 500; font-size: clamp(1.4rem, 2vw, 1.85rem);
             letter-spacing: -0.015em; line-height: 1.2; }
.st-meta { display: flex; flex-wrap: wrap; gap: 1rem 3rem; margin: 0; padding: 1.25rem 0 0; border-top: 1px solid var(--line); }
.st-meta dt { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.st-meta dd { margin: .35rem 0 0; font-size: 15px; color: var(--ink); }

/* ---- a decision: still, then number, title, body (largest to smallest) ---- */
.st-dec { margin-top: clamp(3rem, 7vw, 5.5rem); }
.st-dec__copy { margin-top: 1.5rem; }
.st-dec__n { display: block; font-size: clamp(2.25rem, 3.4vw, 3rem); font-weight: 300; line-height: 1; letter-spacing: -0.03em;
             color: var(--ink); font-variant-numeric: tabular-nums; }
.st-dec__t { margin: .85rem 0 .75rem; font-size: clamp(1.35rem, 1.9vw, 1.75rem); font-weight: 500; letter-spacing: -0.015em;
             line-height: 1.2; max-width: 30ch; }
.st-dec__p { margin: 0; font-size: clamp(1rem, 1.1vw, 1.0625rem); line-height: 1.65; color: var(--ink-2); max-width: 60ch; }
.st-dec__p + .st-dec__p { margin-top: .85em; }
.st-close { display: block; margin: clamp(3rem, 7vw, 5rem) auto 0; padding: 14px 28px; border-radius: 999px; cursor: pointer;
            border: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; font-size: 15px;
            transition: background-color 220ms ease; }
@media (hover: hover) { .st-close:hover { background: var(--paper-2); } }

/* ---- annotated still: boxes, arrows and chips in the page's green ---- */
.st-shot { position: relative; margin: 0; border-radius: var(--radius-media); overflow: hidden; background: var(--paper-2); border: 1px solid var(--line); }
.st-shot img { display: block; width: 100%; height: auto; }
.st-shot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.st-shot rect, .st-shot path { fill: none; stroke: var(--accent); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.st-shot__head { fill: var(--accent); stroke: none; }
.st-chip { position: absolute; padding: .35em .7em; border-radius: 999px; background: var(--accent); color: var(--on-accent);
           font-size: clamp(10px, .95vw, 13px); font-weight: 500; white-space: nowrap; line-height: 1.2; box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .18); }
.st-chip[data-a="l"] { transform: translateY(-50%); }
.st-chip[data-a="r"] { transform: translate(-100%, -50%); }
.st-chip[data-placed] { transform: none; } /* aim() has placed it by its top-left corner */
.st-chip.is-wrap { white-space: normal; width: max-content; max-width: 8em; text-align: center; }
@media (prefers-reduced-motion: no-preference) {
  .st-shot rect, .st-shot path { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 700ms var(--ease-out) 150ms; }
  .st-shot__head, .st-chip { opacity: 0; transition: opacity 300ms ease 600ms; }
  .st-shot.is-in rect, .st-shot.is-in path { stroke-dashoffset: 0; }
  .st-shot.is-in .st-shot__head, .st-shot.is-in .st-chip { opacity: 1; }
}

/* ---- phone: a sheet over the page, with a grabber, the title and the X in a sticky bar ---- */
.card__freeze { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.story-dim { position: fixed; inset: 0; z-index: 79; background: #000; opacity: 0; pointer-events: none; }
@media (max-width: 760px) {
  /* overscroll none: no bounce at the top, so a pull there is the sheet's alone (story-phone.js). The second shadow is
     paper below the sheet, so stretching it up past its resting place never shows a gap underneath. */
  .story { --st-col: calc(100vw - 48px); top: calc(env(safe-area-inset-top) + 14px); border-radius: 14px 14px 0 0;
           overscroll-behavior: none; background: var(--paper); box-shadow: 0 -10px 34px rgba(0, 0, 0, .2), 0 60vh 0 0 var(--paper);
           transition: background-color var(--theme-t) var(--theme-ease); }
  .story__bar { position: sticky; top: 0; right: auto; display: flex; align-items: center; justify-content: space-between; gap: 12px;
                padding: 24px 18px 12px 24px; border-radius: 14px 14px 0 0; background: var(--paper);
                transition: background-color var(--theme-t) var(--theme-ease); }
  .story__bar::before { content: ""; position: absolute; top: 8px; left: 50%; width: 36px; height: 5px; margin-left: -18px;
                        border-radius: 3px; background: color-mix(in srgb, var(--ink) 22%, transparent); }
  .story__label { display: grid; gap: 2px; min-width: 0; }
  .story__pill { font-size: 12px; color: var(--ink-3); }
  .story__label strong { font-size: 1.15rem; font-weight: 500; letter-spacing: -0.01em; }
  .story__x { width: 40px; height: 40px; flex: none; }
  /* the sheet itself is the movement: its content is in place from the start */
  .story:is(.is-pre, .is-going) :is(.story__body > *, .story__x) { opacity: 1; transform: none; transition: none; }
  .story__body { padding-top: 8px; }
  .st-head > div:first-child { display: none; } /* the bar carries the title */
  .st-head { margin-top: 1.75rem; }
  .st-lede { font-size: 1.15rem; }
  .st-meta { gap: .9rem 1.5rem; padding-top: 1rem; }
  .st-dec { margin-top: 3rem; }
  .st-dec__copy { margin-top: 1.25rem; }
  .st-dec__n { font-size: 2rem; }
  .st-dec__t { font-size: 1.3rem; }
  .st-chip { font-size: 10px; }
  .st-close { width: 100%; margin-top: 3rem; }
}

@media (prefers-reduced-motion: reduce) {
  :root.story-fade body, .story__body > *, .story__x, .story__bar { transition: none; }
}
