/* Homepage scroll story (section#how). Markup: lib/story.mjs at build time; motion: story.js.
   Static by default, which is also the no-JS, reduced-motion and saveData version: four frames, the end state of
   each scene with its line above, in a row (wide) or a column (narrow). With .is-motion (story.js) the stage pins
   and one comment travels through the scenes; story.js writes only transform and opacity, once per frame.
   Stage canvases have fixed design sizes (wide 680 x 620, compact 350 x 520), scaled to fit their box. */
.story {
  --story-header: 65px; /* the site's sticky header: the pinned stage sits below it */
  --story-seg: 75vh; /* scroll per scene */
  --story-stage-bg: var(--ink-3);
  --story-shadow: 0 1px 2px rgb(15 17 21 / 0.06), 0 8px 24px rgb(15 17 21 / 0.06); /* the comment card's */
  --story-lift-shadow: 0 2px 6px rgb(15 17 21 / 0.05), 0 30px 60px -18px rgb(15 17 21 / 0.34); /* in flight, by opacity */
  position: relative;
}

/* ---- Static (default) ---------------------------------------------------------------------------------------- */
.story-head { max-width: 44em; }
.story-head h2 { margin-bottom: 0; }
.story-steps { margin-top: 36px; }
.story-rail, .story-stage, .story-track { display: none; }
.story-scenes { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: auto auto; gap: 16px 24px; }
.story-scene { display: grid; grid-row: span 2; grid-template-rows: subgrid; row-gap: 16px; }
.story-line { margin: 0; color: var(--ink-80); font-size: 16px; line-height: 1.5; }
.story-num { display: block; margin-bottom: 6px; color: var(--signal); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.story-frame { position: relative; margin: 0; overflow: hidden; aspect-ratio: 350 / 520; border-radius: 16px; background: var(--story-stage-bg); container-type: inline-size; }
.story-frame .st-canvas { scale: tan(atan2(100cqw, 350px)); }
@media (max-width: 767.98px) {
  .story-scenes { grid-template-columns: minmax(0, 1fr); row-gap: 14px; }
  .story:not(.is-motion) .story-scene + .story-scene { margin-top: 26px; }
  .story-frame { max-width: 440px; }
}

/* ---- Motion: the pinned stage --------------------------------------------------------------------------------- */
.story.is-motion { padding-top: 0; padding-bottom: 0; }
.story.is-motion .story-pin { position: sticky; top: 0; height: 100vh; height: 100svh; padding-top: var(--story-header); display: flex; align-items: center; }
.story.is-motion .story-grid { display: grid; grid-template-columns: minmax(0, 1fr) min(680px, 60%); align-items: center; column-gap: 48px; }
.story.is-motion .story-track { display: block; height: calc(4 * var(--story-seg)); }
.story.is-motion .story-stage { display: block; position: relative; pointer-events: none; user-select: none; justify-self: end; width: min(100%, calc((100svh - var(--story-header) - 64px) * 680 / 620)); aspect-ratio: 680 / 620; overflow: hidden; border-radius: 20px; background: var(--story-stage-bg); container-type: inline-size; }
.story.is-motion .story-stage .st-canvas { scale: tan(atan2(100cqw, 680px)); }
.story.is-motion .story-stage .st-canvas.st-compact { scale: tan(atan2(100cqw, 350px)); }
.story.is-motion .story-frame { display: none; }
.story.is-motion .story-steps { display: grid; grid-template-columns: 12px minmax(0, 1fr); column-gap: 28px; margin-top: 40px; }
.story.is-motion .story-rail { display: block; position: relative; height: 102px; margin-top: 4px; }
.story.is-motion .story-scenes { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
.story.is-motion .story-scene { grid-area: 1 / 1; display: block; }
.story.is-motion .story-line { max-width: 17em; color: var(--ink); font-size: 22px; font-weight: 500; line-height: 1.4; letter-spacing: -0.015em; }
.story.is-motion .story-num { margin-bottom: 10px; }

/* Progress rail: four dots on a hairline; the line fills with progress, the active dot fills --signal. */
.story-rail::before { content: ''; position: absolute; left: 5.5px; top: 6px; bottom: 6px; width: 1px; background: var(--ink-12); }
.story-rail-fill { position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--signal); transform-origin: 50% 0; }
.story-dot { position: absolute; left: 0; width: 12px; height: 12px; border: 1.5px solid var(--ink-12); border-radius: 50%; background: var(--white); }
.story-dot:nth-child(2 of .story-dot) { top: 30px; }
.story-dot:nth-child(3 of .story-dot) { top: 60px; }
.story-dot:nth-child(4 of .story-dot) { top: 90px; }
.story-dot-fill { position: absolute; inset: -1.5px; border-radius: 50%; background: var(--signal); }

/* Stacked (narrower than the two columns): the scene line above the stage. The pin sticks with the heading scrolled
   away under the site header (story.js measures --story-pin-lift: where the scene line starts in the pin). */
@media (max-width: 1023.98px) {
  .story.is-motion .story-pin { height: auto; top: calc(var(--story-header) + 12px - var(--story-pin-lift, 0px)); display: block; padding-top: calc(var(--story-header) + 32px); padding-bottom: 20px; }
  .story.is-motion .story-grid { grid-template-columns: minmax(0, 1fr); row-gap: 20px; }
  .story.is-motion .story-steps { margin-top: 28px; }
  .story.is-motion .story-stage { justify-self: center; width: min(100%, calc((100svh - var(--story-header) - 200px) * 680 / 620)); }
}
@media (max-width: 767.98px) {
  .story { --story-seg: 80vh; }
  .story.is-motion .story-pin { padding-top: calc(var(--story-header) + 24px); padding-bottom: 12px; }
  .story.is-motion .story-steps { grid-template-columns: 10px minmax(0, 1fr); column-gap: 18px; margin-top: 24px; }
  .story.is-motion .story-rail { height: 76px; margin-top: 2px; }
  .story.is-motion .story-rail::before { left: 4.5px; }
  .story.is-motion .story-rail-fill { left: 4px; }
  .story.is-motion .story-dot { width: 10px; height: 10px; }
  .story.is-motion .story-dot:nth-child(2 of .story-dot) { top: 22px; }
  .story.is-motion .story-dot:nth-child(3 of .story-dot) { top: 44px; }
  .story.is-motion .story-dot:nth-child(4 of .story-dot) { top: 66px; }
  .story.is-motion .story-line { font-size: 18px; line-height: 1.4; min-height: 2.8em; }
  .story.is-motion .story-num { margin-bottom: 6px; font-size: 12px; }
  /* Full width: out to the screen edges (the .wrap gutters are 20px), about 70vh tall. */
  .story.is-motion .story-stage { width: min(100% + 40px, calc(70svh * 350 / 520)); margin-inline: -20px; justify-self: center; aspect-ratio: 350 / 520; border-radius: 0; }
}

/* The "Example data" tag: on the stage and on every frame, outside the scaled canvas. */
.st-example { position: absolute; z-index: 1; top: 12px; right: 12px; margin: 0; padding: 1px 9px; border: 1px dashed rgb(15 17 21 / 0.2); border-radius: 999px; background: var(--white); color: var(--ink-64); font-size: 12px; line-height: 20px; }
.story-frame .st-example { top: 8px; right: 8px; padding: 0 8px; font-size: 11px; line-height: 18px; }

/* ---- Stage canvas: home positions (wide 680 x 620) --------------------------------------------------------------- */
.st-canvas { --card-w: 300px; --card-h: 208px; --card-ratio: 300 / 208; position: absolute; left: 0; top: 0; width: 680px; height: 620px; transform-origin: 0 0; color: var(--ink); font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; line-height: 1.5; text-align: left; }
.st-canvas > * { position: absolute; }
.st-canvas > .st-page { left: 56px; top: 92px; width: 520px; height: 352px; }
.st-canvas > .st-card { left: 330px; top: 288px; } /* shown at 1.12 as the popup (story.js) */
.st-canvas > .st-panel { left: 180px; top: 82px; width: 320px; height: 456px; }
.st-canvas > .st-issue { left: 40px; top: 130px; width: 600px; height: 360px; }
.st-canvas > .st-pr { left: 20px; top: 214px; width: 640px; height: 341px; }
/* Compact (narrow stage and the static frames): 350 x 520. */
.st-compact { --card-w: 280px; --card-h: 196px; --card-ratio: 280 / 196; width: 350px; height: 520px; }
.st-compact > .st-page { left: 10px; top: 56px; width: 330px; height: 272px; }
.st-compact > .st-card { left: 35px; top: 296px; }
.st-compact > .st-panel { left: 14px; top: 46px; width: 322px; height: 458px; }
.st-compact > .st-issue { --issue-top: 161px; --issue-h: 198px; left: 10px; top: var(--issue-top); width: 330px; height: var(--issue-h); }
.st-compact > .st-pr { left: 10px; top: 259px; width: 330px; height: 176px; }
/* Frame 4: the issue up and back as story.js leaves it at the end: scaled 0.92 around its centre, its top at 85px. */
.st-compact > .st-issue.st-back { transform: translateY(calc(85px - var(--issue-top) - 0.04 * var(--issue-h))) scale(0.92); opacity: 0.5; }

/* ---- The example page (Fieldnote, from the demo page) ------------------------------------------------------------ */
.st-page { --fn-bg: #faf8f4; --fn-ink: #2b2925; --fn-ink-2: #6b665d; --fn-line: #e6e0d6; --fn-dark: #2f2c27; overflow: hidden; border: 1px solid var(--fn-line); border-radius: 14px; background: var(--fn-bg); color: var(--fn-ink); box-shadow: var(--story-shadow); }
.st-page-top { display: flex; align-items: center; justify-content: space-between; height: 44px; padding: 0 22px; border-bottom: 1px solid var(--fn-line); }
.st-logo { font-size: 14px; font-weight: 600; letter-spacing: -0.02em; }
.st-nav { display: flex; gap: 16px; color: var(--fn-ink-2); font-size: 11px; }
.st-hero { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 26px; padding: 34px 22px 0; }
.st-eyebrow { margin: 0 0 10px; color: var(--fn-ink-2); font-size: 9px; font-weight: 600; line-height: 12px; letter-spacing: 0.07em; text-transform: uppercase; }
.st-h1 { position: relative; display: block; width: 198px; margin: 0; font-size: 31px; font-weight: 600; line-height: 33px; letter-spacing: -0.03em; }
.st-h1-text { display: block; }
.st-ring { position: absolute; inset: -6px -8px; border: 2px dashed var(--signal); border-radius: 8px; pointer-events: none; }
/* The client's pointer: its tip on the headline (story.js brings it in from lower right). */
.st-pointer { position: absolute; left: 156px; top: 120px; width: 18px; height: 26px; transform-origin: 1.5px 1.5px; }
.st-pointer svg { display: block; }
.st-compact .st-pointer { left: 196px; top: 96px; width: 26px; height: 26px; margin: -13px 0 0 -13px; border: 1.5px solid rgb(15 17 21 / 0.32); border-radius: 50%; background: rgb(15 17 21 / 0.14); transform-origin: 50% 50%; }
.st-compact .st-pointer svg { display: none; }
.st-lede { margin: 16px 0 18px; color: var(--fn-ink-2); font-size: 11px; line-height: 1.55; }
.st-actions { display: flex; align-items: center; gap: 14px; margin: 0; }
.st-btn { display: inline-flex; align-items: center; height: 30px; padding: 0 14px; border-radius: 999px; background: var(--fn-dark); color: #fff; font-size: 11px; font-weight: 600; }
.st-link { font-size: 11px; font-weight: 600; }
.st-link::after { content: ' \2192'; }
.st-room { position: relative; height: 230px; overflow: hidden; border-radius: 12px; background: #e9e2d6; }
.st-room > span { position: absolute; display: block; }
.st-floor { left: 0; right: 0; bottom: 0; height: 32%; background: #d9cdb9; }
.st-lamp { top: 12%; left: 58%; width: 22%; aspect-ratio: 1; border-radius: 50%; background: #f6f1e7; }
.st-sofa { left: 10%; bottom: 22%; width: 52%; height: 22%; border-radius: 12px 12px 5px 5px; background: #b9a68a; }
.st-table { right: 12%; bottom: 22%; width: 18%; height: 16%; border-radius: 6px 6px 0 0; background: #8c7a62; }
.st-rug { left: 6%; right: 6%; bottom: 8%; height: 10%; border-radius: 50%; background: rgb(255 255 255 / 0.45); }
/* Compact page: one centred column, the room as a strip below. */
.st-compact .st-page-top { height: 36px; padding: 0 16px; }
.st-compact .st-logo { font-size: 12px; }
.st-compact .st-nav { gap: 12px; font-size: 9.5px; }
.st-compact .st-nav > :nth-child(n + 3) { display: none; }
.st-compact .st-hero { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 20px 18px 0; text-align: center; }
.st-compact .st-eyebrow { margin-bottom: 8px; font-size: 7.5px; line-height: 10px; }
.st-compact .st-h1 { width: 168px; margin: 0 auto; font-size: 26px; line-height: 28px; }
.st-compact .st-lede { max-width: 250px; margin: 12px auto 12px; font-size: 9.5px; }
.st-compact .st-actions { justify-content: center; gap: 12px; }
.st-compact .st-btn { height: 24px; padding: 0 11px; font-size: 9.5px; }
.st-compact .st-link { font-size: 9.5px; }
.st-compact .st-room { height: 66px; border-radius: 10px; }
.st-compact .st-lamp { top: 10%; left: 64%; width: 9%; }
.st-compact .st-sofa { left: 18%; width: 34%; height: 30%; border-radius: 8px 8px 3px 3px; }
.st-compact .st-table { right: 22%; width: 9%; height: 22%; border-radius: 4px 4px 0 0; }

/* ---- The comment: one card, two faces (the widget's popup, then the comment card) ------------------------------ */
.st-card { width: var(--card-w); height: var(--card-h); border: 1px solid var(--ink-12); border-radius: 16px; background: var(--white); box-shadow: var(--story-shadow); font-size: 14px; }
.st-lift { position: absolute; inset: -1px; border-radius: inherit; box-shadow: var(--story-lift-shadow); opacity: 0; }
.st-face { position: absolute; inset: 0; padding: 16px; }
.st-card[data-face='popup'] .st-face-card, .st-card[data-face='card'] .st-face-popup { opacity: 0; }
/* Popup face: the element it is about, the comment being typed, Send. */
.st-target { margin: 0; overflow: hidden; color: var(--ink-64); font-size: 12px; line-height: 20px; white-space: nowrap; }
.st-target code { margin-right: 4px; padding: 3px 6px; border-radius: 6px; background: var(--ink-6); color: var(--ink); font: 600 11px/1 var(--mono); }
.st-close { position: absolute; top: 18px; right: 16px; width: 16px; height: 16px; }
.st-close::before, .st-close::after { content: ''; position: absolute; left: 7px; top: 1px; width: 1.5px; height: 14px; border-radius: 1px; background: var(--ink-64); transform: rotate(45deg); }
.st-close::after { transform: rotate(-45deg); }
.st-input { height: 86px; margin-top: 12px; padding: 10px 12px; border-radius: 8px; outline: 2px solid var(--signal); outline-offset: -1px; }
.st-typed-line { display: block; height: 22px; overflow: hidden; contain: strict; font-size: 15px; font-weight: 500; line-height: 22px; white-space: nowrap; }
.st-caret { display: inline-block; width: 1.5px; height: 18px; margin-left: 1px; vertical-align: -4px; background: var(--ink); opacity: 0; }
.st-popup-actions { position: absolute; right: 16px; bottom: 16px; margin: 0; }
.st-send { position: relative; display: inline-flex; align-items: center; height: 36px; padding: 0 18px; overflow: hidden; border-radius: 8px; background: var(--signal); color: var(--white); font-size: 14px; font-weight: 700; }
.st-send-press { position: absolute; inset: 0; background: rgb(15 17 21 / 0.2); opacity: 0; }
.st-send-label { position: relative; }
/* Card face (the live demo's comment card): screenshot crop with the element outlined, the comment, the page. */
.st-shot { position: relative; height: 106px; margin: 0; overflow: hidden; border: 1px solid var(--ink-12); border-radius: 8px; background: #faf8f4; }
.st-shot > .st-page { position: absolute; left: 11px; top: -72px; width: 520px; height: 352px; border: 0; border-radius: 0; box-shadow: none; }
.st-comment { margin: 12px 0 0; overflow: hidden; line-height: 20px; white-space: nowrap; text-overflow: ellipsis; }
.st-comment strong { font-weight: 600; }
.st-path { display: inline-block; margin-top: 8px; padding: 2px 8px; border-radius: 6px; background: var(--ink-6); color: var(--ink-64); font: 12px/1.5 var(--mono); }
.st-compact .st-card { font-size: 13.5px; }
.st-compact .st-face { padding: 14px; }
.st-compact .st-input { height: 80px; margin-top: 10px; }
.st-compact .st-typed-line { font-size: 14px; }
.st-compact .st-popup-actions { right: 14px; bottom: 14px; }
.st-compact .st-send { height: 34px; padding: 0 16px; font-size: 13px; }
.st-compact .st-close { top: 16px; right: 14px; }
.st-compact .st-shot { height: 96px; }
.st-compact .st-shot > .st-page { left: -40px; top: -46px; width: 330px; height: 272px; }

/* ---- Your agent: a neutral panel (no product UI) ------------------------------------------------------------------ */
.st-panel { overflow: hidden; border: 1px solid var(--ink-12); border-radius: 16px; background: var(--white); box-shadow: var(--story-shadow); }
.st-panel-head { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 16px; border-bottom: 1px solid var(--ink-6); }
.st-avatar { position: relative; flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); }
/* A terminal prompt, drawn: any agent, no product's mark. */
.st-avatar::before { content: ''; position: absolute; left: 7px; top: 9.5px; width: 5px; height: 5px; border: solid var(--white); border-width: 1.5px 1.5px 0 0; transform: rotate(45deg); }
.st-avatar::after { content: ''; position: absolute; left: 13px; top: 16px; width: 6px; height: 1.5px; border-radius: 1px; background: var(--white); }
.st-panel-name { font-size: 14px; font-weight: 600; }
.st-panel-body { padding: 16px; }
.st-tag { display: inline-flex; align-items: center; gap: 6px; height: 24px; margin: 0 0 10px; padding: 0 10px 0 8px; border: 1px solid var(--ink-12); border-radius: 999px; color: var(--ink-64); font-size: 12px; font-weight: 500; }
.st-tag-icon { position: relative; width: 12px; height: 12px; border-radius: 50%; background: var(--signal); }
.st-tag-icon::after { content: ''; position: absolute; left: 4px; top: 2.5px; width: 3px; height: 5.5px; border: solid var(--white); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
/* A slot is where the card lands; in the static frames the card sits in it, scaled to the slot's width. */
.st-slot { position: relative; aspect-ratio: var(--card-ratio); container-type: inline-size; }
.st-slot > .st-card { position: absolute; left: 0; top: 0; transform-origin: 0 0; scale: tan(atan2(100cqw, var(--card-w))); }
.st-panel .st-slot { width: 280px; }
.st-fields { display: grid; gap: 6px; margin: 14px 0 0; font: 12px/1.5 var(--mono); }
.st-field { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 8px; }
.st-field dt { color: var(--ink-64); }
.st-field dd { margin: 0; overflow-wrap: anywhere; }
.st-status { display: flex; align-items: center; gap: 8px; margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--ink-6); color: var(--ink-64); font-size: 13px; }
.st-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--signal); }

/* ---- The two GitHub screenshots (src/story/, see its README); a placeholder slot when a file is missing ---------- */
.st-shotslot { overflow: hidden; border: 1px solid var(--ink-12); border-radius: 12px; background: var(--white); box-shadow: var(--story-shadow); }
.st-shotslot > img { display: block; width: 100%; height: 100%; object-fit: contain; }
/* A crop for the compact canvas (the phone stage and the static frames), when the slot has one: one of the two shows. */
.st-canvas:not(.st-compact) .st-img-compact, .st-compact .st-img-wide { display: none; }
.st-ph { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 6px; }
.st-ph-label { color: var(--ink-64); font-size: 14px; font-weight: 500; }
.st-ph-file { padding: 0; background: none; color: var(--ink-64); font: 12px/1 var(--mono); opacity: 0.8; }
/* Where the card docks on the issue and where one soft pulse marks its Open badge, fractions
   of the slot matched to the crops in src/story/ (README): the card docks in the free space right of the issue's
   text, so the issue shows whole. Without the screenshot the placeholder's label is centred left of the card. */
.st-issue { --dock-x: 58%; --dock-y: 42%; --dock-w: 29.5%; --pulse-x: 2%; --pulse-y: 14.1%; --pulse-w: 13.3%; --pulse-h: 10.2%; }
.st-issue .st-slot { position: absolute; left: var(--dock-x); top: var(--dock-y); width: var(--dock-w); }
.st-issue .st-ph { padding-right: calc(100% - var(--dock-x)); }
.st-pulse { position: absolute; left: var(--pulse-x); top: var(--pulse-y); width: var(--pulse-w); height: var(--pulse-h); border: 1.5px solid var(--signal); border-radius: 8px; background: rgb(67 83 255 / 0.05); opacity: 0; }
.st-compact .st-issue { --dock-x: 54%; --dock-y: 44%; --dock-w: 43%; --pulse-x: 2.1%; --pulse-y: 32.8%; --pulse-w: 23.3%; --pulse-h: 17.5%; }

