/* =============================================================================
 * Recon landing page.
 * Tokens copied from frontend/src/styles/theme.css — keep the two in sync when
 * the product palette changes.
 * ========================================================================== */

:root {
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: light dark;

  /* Printed "paper" — the statement sheet stays white in both themes */
  --paper: #ffffff;
  --paper-ink: #1a1d24;
  --paper-ink-dim: #5b6472;
  --paper-line: #e2e6ec;
  --paper-line-strong: #98a1af;

  --l-bg: #f6f7f9;
  --l-surface: #ffffff;
  --l-surface-2: #f0f2f5;
  --l-text: #1b2230;
  --l-text-dim: #5b6472;
  --l-border: #e2e6ec;
  --l-border-strong: #cfd5de;
  --l-accent: #3b6cff;
  --l-accent-soft: rgba(59, 108, 255, 0.12);
  --l-accent-line: rgba(59, 108, 255, 0.55);
  --l-credit: #17915c;
  --l-debit: #c2413a;
  --l-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 12px rgba(16, 24, 40, 0.05);

  --d-bg: #0e1116;
  --d-surface: #171b22;
  --d-surface-2: #1e242d;
  --d-text: #e6e9ef;
  --d-text-dim: #97a1b0;
  --d-border: #262c36;
  --d-border-strong: #333b47;
  --d-accent: #6b8cff;
  --d-accent-soft: rgba(107, 140, 255, 0.16);
  --d-accent-line: rgba(107, 140, 255, 0.6);
  --d-credit: #3fbf82;
  --d-debit: #f0736b;
  --d-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.35);

  --bg: var(--l-bg);
  --surface: var(--l-surface);
  --surface-2: var(--l-surface-2);
  --text: var(--l-text);
  --text-dim: var(--l-text-dim);
  --border: var(--l-border);
  --border-strong: var(--l-border-strong);
  --accent: var(--l-accent);
  --accent-soft: var(--l-accent-soft);
  --accent-line: var(--l-accent-line);
  --credit: var(--l-credit);
  --debit: var(--l-debit);
  --shadow: var(--l-shadow);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--d-bg);
    --surface: var(--d-surface);
    --surface-2: var(--d-surface-2);
    --text: var(--d-text);
    --text-dim: var(--d-text-dim);
    --border: var(--d-border);
    --border-strong: var(--d-border-strong);
    --accent: var(--d-accent);
    --accent-soft: var(--d-accent-soft);
    --accent-line: var(--d-accent-line);
    --credit: var(--d-credit);
    --debit: var(--d-debit);
    --shadow: var(--d-shadow);
  }
}

/* ---- Base ---- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden; /* parallax orbs + stage travel bleed past the edges */
}

@supports (overflow: clip) {
  html,
  body {
    overflow-x: clip;
  }
}

.wrap {
  width: min(100%, 1080px);
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 28px);
}

a {
  color: var(--accent);
  text-decoration: none;
}

/* ---- Buttons ---- */

.btn {
  display: inline-block;
  padding: 12px 22px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.btn:hover {
  opacity: 0.88;
}
.btn--primary {
  background: var(--accent);
  color: #fff;
}
.btn--ghost {
  border-color: var(--border-strong);
  color: var(--text);
  background: transparent;
}

/* ---- Nav ---- */

.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav .wrap {
  display: flex;
  align-items: center;
  gap: 28px;
  height: 60px;
}
.logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  letter-spacing: 0;
}
.logo .dot {
  color: var(--accent);
}
.nav-links {
  display: flex;
  gap: 22px;
  margin-left: auto;
  align-items: center;
}
.nav-links a:not(.btn) {
  color: var(--text-dim);
  font-size: 0.92rem;
}
.nav-links a:not(.btn):hover {
  color: var(--text);
}

/* ---- Scroll reveal ---- */

.js .reveal {
  opacity: 0;
  transform: translateY(26px);
  transition:
    opacity 0.65s ease,
    transform 0.65s cubic-bezier(0.16, 1, 0.3, 1);
}
.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}
/* Stagger siblings inside a revealed group */
.reveal[data-delay='1'] { transition-delay: 0.08s; }
.reveal[data-delay='2'] { transition-delay: 0.16s; }
.reveal[data-delay='3'] { transition-delay: 0.24s; }
.reveal[data-delay='4'] { transition-delay: 0.32s; }

@media (prefers-reduced-motion: reduce) {
  .js .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ---- Hero ---- */

.hero {
  position: relative;
  padding: clamp(52px, 8vw, 96px) 0 clamp(68px, 9vw, 112px);
  text-align: center;
  overflow-x: clip;
  overflow-y: visible;
}
.hero .wrap {
  position: relative; /* content above the orbs */
  z-index: 1;
}

/* Decorative parallax layers behind the hero */
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  pointer-events: none;
  z-index: 0;
  will-change: transform;
}
.orb--1 {
  width: 420px;
  height: 420px;
  top: -80px;
  left: -120px;
  background: var(--accent-soft);
}
.orb--2 {
  width: 340px;
  height: 340px;
  top: 220px;
  right: -140px;
  background: color-mix(in srgb, var(--credit) 14%, transparent);
}
.orb--3 {
  width: 260px;
  height: 260px;
  top: 560px;
  left: 12%;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.hero h1 {
  font-size: clamp(2.35rem, 5vw, 3.75rem);
  line-height: 1.12;
  letter-spacing: 0;
  margin: 0 auto 18px;
  max-width: 880px;
}
.hero h1 em {
  font-style: normal;
  color: var(--accent);
}
.hero .sub {
  font-size: clamp(1.18rem, 1.7vw, 1.34rem);
  line-height: 1.65;
  color: var(--text-dim);
  max-width: 760px;
  margin: 0 auto 36px;
}
.hero .cta-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 4px 14px;
  margin-bottom: 20px;
}

/* ---- Story ----
 * The page scrolls normally: five .story-chapter texts flow past on
 * alternating sides while .story-visual (the stage) stays sticky and the app
 * window travels left/right to meet each one. script.js sets
 * data-chapter="1..5" on .story from whichever chapter crosses mid-viewport:
 *   1 upload/OCR → 2 easy review (hover grounding) → 3 classification
 *   → 4 calculation/statement → 5 auto-review.
 */

.story {
  position: relative;
  overflow-x: clip;
  --story-vh: 100vh;
  --stage-w: 520px;
  --stage-h: 540px;
  --stage-left: 50%;
  --stage-top: 50%;
  --hover-row-step: 46px;
  --hover-doc-step: 21px;
}
@supports (height: 100svh) {
  .story {
    --story-vh: 100svh;
  }
}
.story-visual {
  position: sticky;
  top: 0;
  height: var(--story-vh);
  pointer-events: none;
  z-index: 1;
}
.story-chapters {
  margin-top: calc(0px - var(--story-vh)); /* chapters scroll over the sticky stage's runway */
  position: relative;
  z-index: 2;
}
.story-chapter {
  min-height: var(--story-vh);
  display: flex;
  align-items: center;
}
.chapter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
}
.chapter-text {
  max-width: 440px;
}
.story-chapter:nth-child(even) .chapter-text {
  grid-column: 2;
  justify-self: end;
}
.chapter-text h3 {
  margin: 8px 0 12px;
  font-size: clamp(1.55rem, 2.4vw, 2rem);
  line-height: 1.18;
  letter-spacing: 0;
}
.chapter-text p {
  margin: 0;
  font-size: clamp(1.06rem, 1.4vw, 1.16rem);
  line-height: 1.72;
  color: var(--text-dim);
}
.ch-label {
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

/* Stage: centered in the sticky viewport; .stage-shift travels per chapter */
.story-stage {
  position: absolute;
  left: var(--stage-left);
  top: var(--stage-top);
  width: min(var(--stage-w), calc(100vw - 48px));
  height: min(var(--stage-h), calc(var(--story-vh) - 88px));
  transform: translate(-50%, -50%);
}
.stage-shift {
  position: absolute;
  inset: 0;
  transform: translateX(clamp(160px, 17vw, 220px));
  transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.story[data-chapter='2'] .stage-shift,
.story[data-chapter='4'] .stage-shift {
  transform: translateX(clamp(-220px, -17vw, -160px));
}

/* Scattered source documents (chapter 1); pulled into the app afterwards */
.s-doc {
  position: absolute;
  width: 178px;
  z-index: 1;
  transition:
    transform 0.7s cubic-bezier(0.5, 0, 0.6, 1),
    opacity 0.5s ease;
}
.s-doc--1 { top: -5%; left: -22%; rotate: -6deg; --tx: 160px; --ty: 180px; }
.s-doc--2 { top: -9%; right: -16%; rotate: 5deg; --tx: -150px; --ty: 190px; transition-delay: 0.06s; }
.s-doc--3 { top: 38%; left: -30%; rotate: 3deg; --tx: 190px; --ty: 20px; transition-delay: 0.12s; }
.s-doc--4 { bottom: -4%; left: -12%; rotate: -4deg; --tx: 130px; --ty: -160px; transition-delay: 0.18s; }
.s-doc--5 { bottom: -8%; right: -14%; rotate: 6deg; --tx: -150px; --ty: -170px; transition-delay: 0.24s; }
.story:not([data-chapter='1']) .s-doc {
  transform: translate(var(--tx), var(--ty)) scale(0.2);
  opacity: 0;
}

.float-doc {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  animation: float 5.5s ease-in-out infinite;
}
.s-doc--2 .float-doc { animation-delay: -1.2s; }
.s-doc--3 .float-doc { animation-delay: -2.3s; }
.s-doc--4 .float-doc { animation-delay: -3.4s; }
.s-doc--5 .float-doc { animation-delay: -4.5s; }
.float-doc--rct {
  border-bottom: 2px dashed var(--border-strong);
}
@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}
.doc-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 10px;
  background: var(--debit);
  color: #fff;
}
.doc-tag--inv {
  background: var(--accent);
}
.doc-tag--rct {
  background: var(--credit);
}
.doc-tag--xls {
  background: color-mix(in srgb, var(--credit) 60%, var(--accent) 40%);
}
.doc-tag--img {
  background: var(--text-dim);
}
.doc-name {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-lines i {
  display: block;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
  margin-bottom: 6px;
}
.doc-lines i:nth-child(1) {
  width: 92%;
}
.doc-lines i:nth-child(2) {
  width: 70%;
}
.doc-lines i:nth-child(3) {
  width: 52%;
  margin-bottom: 0;
}

/* App window, centered inside the traveling stage */
.s-app {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(500px, 100%);
  z-index: 2;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.app-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.app-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-strong);
}
.app-title {
  font-size: 0.8rem;
  font-weight: 700;
  margin-left: 8px;
}
.status {
  position: absolute;
  right: 12px;
  top: 50%;
  translate: 0 -50%;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.35s ease;
}
.status--5 {
  background: color-mix(in srgb, var(--credit) 15%, transparent);
  color: var(--credit);
}
.story[data-chapter='1'] .status--1,
.story[data-chapter='2'] .status--2,
.story[data-chapter='3'] .status--3,
.story[data-chapter='4'] .status--4,
.story[data-chapter='5'] .status--5 {
  opacity: 1;
}

/* Tabs mirror the product's right panel; the story switches them at ch4 */
.app-tabs {
  display: flex;
  gap: 4px;
  padding: 6px 10px 0;
  border-bottom: 1px solid var(--border);
}
.tab {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-dim);
  padding: 5px 10px;
  border-bottom: 2px solid transparent;
  transition:
    color 0.3s ease,
    border-color 0.3s ease;
}
.story[data-chapter='1'] .tab--txn,
.story[data-chapter='2'] .tab--txn,
.story[data-chapter='3'] .tab--txn,
.story[data-chapter='4'] .tab--stmt,
.story[data-chapter='5'] .tab--stmt {
  color: var(--accent);
  border-color: var(--accent);
}

/* Two views crossfade inside a fixed-height body */
.app-body {
  position: relative;
  height: 244px;
}
.app-view {
  position: absolute;
  inset: 0;
  padding: 12px 14px 14px;
  transition:
    opacity 0.45s ease,
    transform 0.45s ease;
}
.app-view--stmt {
  opacity: 0;
  transform: translateX(16px);
}
.story[data-chapter='4'] .app-view--txn,
.story[data-chapter='5'] .app-view--txn {
  opacity: 0;
  transform: translateX(-16px);
}
.story[data-chapter='4'] .app-view--stmt,
.story[data-chapter='5'] .app-view--stmt {
  opacity: 1;
  transform: none;
}

/* Chapter 1: scanline sweeps and skeleton rows OCR into text (looping) */
.scanline {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 8px;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 12px var(--accent-line);
  opacity: 0;
  z-index: 2;
  pointer-events: none;
}
.story[data-chapter='1'] .scanline {
  animation: scan 9s ease-in-out infinite;
}
@keyframes scan {
  0% { top: 8px; opacity: 0; }
  4% { opacity: 1; }
  38% { top: calc(100% - 12px); opacity: 1; }
  43%, 100% { top: calc(100% - 12px); opacity: 0; }
}

.ocr-row {
  position: relative;
  height: 46px;
  border-bottom: 1px solid var(--border);
}
.ocr-row:last-child {
  border-bottom: none;
}
.row-skeleton,
.row-content {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 48px 1fr auto 88px;
  gap: 12px;
  align-items: center;
  font-family: var(--mono);
  font-size: 0.76rem;
  white-space: nowrap;
  transition: opacity 0.4s ease;
}
.row-skeleton i {
  height: 8px;
  border-radius: 4px;
  background: var(--surface-2);
}
.row-skeleton i:nth-child(2) {
  width: 72%;
}
.row-skeleton i:nth-child(3) {
  width: 46px;
}
.row-skeleton i:nth-child(4) {
  width: 64%;
  justify-self: end;
}
.row-content {
  opacity: 0;
}
.story[data-chapter='1'] .row-skeleton {
  animation: skel-out 9s linear infinite;
  animation-delay: var(--d, 0s);
}
.story[data-chapter='1'] .row-content {
  animation: ocr-in 9s linear infinite;
  animation-delay: var(--d, 0s);
}
.story:not([data-chapter='1']) .row-skeleton {
  opacity: 0;
}
.story:not([data-chapter='1']) .row-content {
  opacity: 1;
}
.row-content .c-desc {
  overflow: hidden;
  text-overflow: ellipsis;
}
.c-amt {
  text-align: right;
}
.amt-credit {
  color: var(--credit);
}
.amt-debit {
  color: var(--debit);
}
@keyframes ocr-in {
  0%, 8% { opacity: 0; filter: blur(6px); }
  13% { opacity: 1; filter: blur(0); }
  92% { opacity: 1; filter: blur(0); }
  97%, 100% { opacity: 0; filter: blur(6px); }
}
@keyframes skel-out {
  0%, 8% { opacity: 1; }
  13%, 92% { opacity: 0; }
  97%, 100% { opacity: 1; }
}

/* Chapter 2 (easy review): a cursor walks the rows; the hovered row and its
 * source region on the document highlight together — the grounding link. */
.ground-doc {
  position: absolute;
  left: -210px;
  top: 50%;
  width: 184px;
  padding: 16px 14px;
  background: var(--paper);
  border-radius: 8px;
  box-shadow: var(--shadow);
  transform: translateY(-50%) translateX(-16px);
  opacity: 0;
  transition:
    opacity 0.5s ease 0.15s,
    transform 0.6s ease 0.15s;
}
.story[data-chapter='2'] .ground-doc {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}
.g-title {
  height: 9px;
  width: 60%;
  border-radius: 4px;
  background: var(--paper-line-strong);
  margin-bottom: 16px;
}
.g-line {
  height: 8px;
  border-radius: 4px;
  background: var(--paper-line);
  margin-bottom: 13px;
}
.g-line:last-of-type {
  margin-bottom: 0;
}
/* the product-style bbox highlight over the doc line */
.doc-hl {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 39px;
  height: 19px;
  border: 1.5px solid var(--accent-line);
  background: var(--accent-soft);
  border-radius: 4px;
  opacity: 0;
}
/* hovered-row highlight inside the app table */
.row-hl {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 10px;
  height: 46px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  opacity: 0;
  z-index: 1;
  pointer-events: none;
}
.hover-cursor {
  position: absolute;
  left: 55%;
  top: 24px;
  width: 16px;
  height: 16px;
  z-index: 4;
  color: var(--text);
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45));
  opacity: 0;
}
.story[data-chapter='2'] .doc-hl {
  opacity: 1;
  animation: hover-walk-doc 8s ease-in-out infinite;
}
.story[data-chapter='2'] .row-hl {
  opacity: 1;
  animation: hover-walk 8s ease-in-out infinite;
}
.story[data-chapter='2'] .hover-cursor {
  opacity: 1;
  animation: hover-walk 8s ease-in-out infinite;
}
/* one shared timeline: 4 stops through the visible rows and source lines */
@keyframes hover-walk {
  0%, 20% { transform: translateY(0); }
  27%, 45% { transform: translateY(var(--hover-row-step)); }
  52%, 70% { transform: translateY(calc(var(--hover-row-step) * 2)); }
  77%, 95% { transform: translateY(calc(var(--hover-row-step) * 3)); }
  100% { transform: translateY(0); }
}
@keyframes hover-walk-doc {
  0%, 20% { transform: translateY(0); }
  27%, 45% { transform: translateY(var(--hover-doc-step)); }
  52%, 70% { transform: translateY(calc(var(--hover-doc-step) * 2)); }
  77%, 95% { transform: translateY(calc(var(--hover-doc-step) * 3)); }
  100% { transform: translateY(0); }
}

/* Chapter 3: category chips pop onto the recognized rows */
.chip {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
}
.chip--accent {
  background: var(--accent-soft);
  color: var(--accent);
}
.row-content .chip {
  justify-self: start;
  opacity: 0;
  transform: scale(0.4);
  transition:
    opacity 0.3s ease,
    transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  /* stagger derived from the row's OCR delay (--d: -0.4s..1.85s → 0s..0.45s) */
  transition-delay: calc((var(--d, 0s) + 0.4s) / 5);
}
.story[data-chapter='3'] .row-content .chip,
.story[data-chapter='4'] .row-content .chip,
.story[data-chapter='5'] .row-content .chip {
  opacity: 1;
  transform: scale(1);
}

/* Chapter 4: the statement builds itself on product-style white "paper" */
.app-view--stmt {
  background: var(--paper);
  color: var(--paper-ink);
  font-family: var(--mono);
}
.stmt-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding-bottom: 6px;
  border-bottom: 1.5px solid var(--paper-line-strong);
}
.stmt-head span {
  font-weight: 400;
  color: var(--paper-ink-dim);
  letter-spacing: 0;
}
.stmt-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  font-size: 0.78rem;
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.4s ease,
    transform 0.5s ease;
}
.stmt-line span {
  flex: 1;
}
.stmt-line b {
  font-weight: 600;
}
.stmt-total {
  border-top: 1.5px solid var(--paper-line-strong);
  margin-top: 8px;
  padding-top: 9px;
}
.stmt-total b {
  font-weight: 700;
  color: var(--credit);
}
.story[data-chapter='4'] .stmt-line,
.story[data-chapter='5'] .stmt-line {
  opacity: 1;
  transform: none;
}
.stmt-line:nth-child(2) { transition-delay: 0.05s; }
.stmt-line:nth-child(3) { transition-delay: 0.15s; }
.stmt-line:nth-child(4) { transition-delay: 0.25s; }
.stmt-line:nth-child(5) { transition-delay: 0.35s; }
.stmt-line:nth-child(6) { transition-delay: 0.5s; }

/* Chapter 5: review checkmarks tick down the statement, then the stamp lands */
.ck {
  font-style: normal;
  width: 14px;
  text-align: center;
  color: var(--credit);
  opacity: 0;
  transform: scale(0.3);
  transition:
    opacity 0.3s ease,
    transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.story[data-chapter='5'] .ck {
  opacity: 1;
  transform: scale(1);
}
.story[data-chapter='5'] .stmt-line:nth-child(2) .ck { transition-delay: 0.05s; }
.story[data-chapter='5'] .stmt-line:nth-child(3) .ck { transition-delay: 0.15s; }
.story[data-chapter='5'] .stmt-line:nth-child(4) .ck { transition-delay: 0.25s; }
.story[data-chapter='5'] .stmt-line:nth-child(5) .ck { transition-delay: 0.35s; }
.story[data-chapter='5'] .stmt-line:nth-child(6) .ck { transition-delay: 0.5s; }

.stamp {
  position: absolute;
  right: 14px;
  bottom: 12px;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--credit);
  border: 2px solid var(--credit);
  border-radius: 6px;
  padding: 4px 8px;
  rotate: -8deg;
  opacity: 0;
  transform: scale(1.6);
  transition:
    opacity 0.35s ease 0.75s,
    transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 0.75s;
}
.story[data-chapter='5'] .stamp {
  opacity: 1;
  transform: scale(1);
}

/* Reduced motion: no loops, no transitions; chapter states switch instantly */
@media (prefers-reduced-motion: reduce) {
  .story *,
  .story {
    transition-duration: 0s !important;
    transition-delay: 0s !important;
    animation: none !important;
  }
  .scanline,
  .hover-cursor {
    display: none;
  }
  .story .row-skeleton {
    display: none;
  }
  .story .row-content {
    opacity: 1;
    filter: none;
  }
}

/* ---- Sections ---- */

section {
  padding: 72px 0;
}
.section-head {
  text-align: center;
  max-width: 740px;
  margin: 0 auto 52px;
}
.section-head h2 {
  font-size: clamp(1.75rem, 3vw, 2.35rem);
  letter-spacing: 0;
  margin: 0 0 10px;
}
.section-head p {
  color: var(--text-dim);
  margin: 0;
  font-size: clamp(1.08rem, 1.5vw, 1.2rem);
  line-height: 1.7;
}

/* ---- Feature cards ---- */

.features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 30px;
  box-shadow: var(--shadow);
}
.card .icon {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.card .icon svg {
  width: 25px;
  height: 25px;
}
.card h3 {
  margin: 0 0 12px;
  font-size: 1.25rem;
  line-height: 1.25;
}
.card p {
  margin: 0;
  color: var(--text-dim);
  font-size: 1.06rem;
  line-height: 1.72;
}

/* ---- Final CTA ---- */

.cta-final {
  text-align: center;
}
.cta-final .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 56px 32px;
}
.cta-final h2 {
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  margin: 0 0 10px;
}
.cta-final p {
  color: var(--text-dim);
  margin: 0 0 26px;
  font-size: 1.12rem;
  line-height: 1.7;
}

/* ---- Footer ---- */

footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
}
footer .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* ---- Responsive ---- */

@media (min-width: 1280px) {
  .wrap {
    width: min(100%, 1160px);
  }
  .story {
    --stage-w: 560px;
    --stage-h: 560px;
  }
  .chapter-text {
    max-width: 470px;
  }
  .features {
    gap: 22px;
  }
}

@media (max-width: 1100px) {
  .story {
    --stage-w: 480px;
    --stage-h: 500px;
  }
  .ground-doc {
    left: -90px;
    width: 156px;
  }
  .chapter-text {
    max-width: 410px;
  }
  .s-doc {
    width: 160px;
  }
  .s-app {
    width: min(470px, 100%);
  }
}

@media (max-width: 960px) {
  /* The story becomes a stacked viewport: animation above, text below. */
  .story {
    --stage-w: 420px;
    --stage-h: 430px;
    --stage-top: 34%;
    --hover-row-step: 42px;
    --hover-doc-step: 14px;
  }
  .stage-shift,
  .story[data-chapter='2'] .stage-shift,
  .story[data-chapter='4'] .stage-shift {
    transform: none;
  }
  .ground-doc {
    left: 12px;
    top: 6%;
    z-index: 3;
    width: 126px;
    padding: 10px 9px;
    transform: translateX(-10px) scale(0.94);
    transform-origin: left top;
  }
  .story[data-chapter='2'] .ground-doc {
    transform: translateX(0) scale(0.94);
  }
  .g-title {
    height: 7px;
    margin-bottom: 10px;
  }
  .g-line {
    height: 6px;
    margin-bottom: 8px;
  }
  .doc-hl {
    top: 28px;
    height: 14px;
  }
  .s-doc {
    width: 112px;
  }
  .s-doc--1 { left: -6%; }
  .s-doc--2 { right: -4%; }
  .s-doc--3 { left: -8%; }
  .s-doc--4 { left: -2%; }
  .s-doc--5 { right: -4%; }
  .s-app {
    width: min(400px, 96vw);
  }
  .app-body {
    height: 220px;
  }
  .ocr-row {
    height: 42px;
  }
  .row-skeleton,
  .row-content {
    grid-template-columns: 42px minmax(0, 1fr) auto 78px;
    gap: 9px;
    font-size: 0.7rem;
  }
  .row-hl {
    height: 42px;
  }
  .story-chapter {
    align-items: flex-end;
    padding-bottom: clamp(24px, 5vh, 48px);
  }
  .chapter-grid {
    grid-template-columns: 1fr;
  }
  .story-chapter:nth-child(even) .chapter-text {
    grid-column: 1;
    justify-self: center;
  }
  .chapter-text {
    justify-self: center;
    width: min(100%, 540px);
    max-width: none;
    padding: 22px 24px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: color-mix(in srgb, var(--bg) 84%, transparent);
    backdrop-filter: blur(8px);
  }
  .chapter-text p {
    font-size: 1.08rem;
  }
}

@media (max-width: 820px) {
  .nav-links a:not(.btn) {
    display: none;
  }
  section {
    padding: 60px 0;
  }
  .features {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .card {
    padding: 28px;
  }
  footer .wrap {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .story {
    --stage-w: 380px;
    --stage-h: 390px;
    --stage-top: 30%;
    --hover-row-step: 39px;
    --hover-doc-step: 12px;
  }
  .nav .wrap {
    height: 56px;
  }
  .nav-links {
    gap: 12px;
  }
  .nav-links .btn {
    padding: 9px 14px;
    font-size: 0.92rem;
  }
  .hero h1 {
    font-size: clamp(2.1rem, 11vw, 3.1rem);
  }
  .hero .sub {
    font-size: 1.12rem;
  }
  .cta-row .btn {
    min-width: min(100%, 220px);
  }
  .ground-doc {
    left: 8px;
    top: 4%;
    width: 112px;
    padding: 9px 8px;
    transform: translateX(-8px) scale(0.9);
  }
  .story[data-chapter='2'] .ground-doc {
    transform: translateX(0) scale(0.9);
  }
  .g-title {
    height: 6px;
    margin-bottom: 9px;
  }
  .g-line {
    height: 5px;
    margin-bottom: 7px;
  }
  .doc-hl {
    left: 6px;
    right: 6px;
    top: 24px;
    height: 12px;
  }
  .s-doc {
    width: 102px;
  }
  .float-doc {
    padding: 10px 11px;
  }
  .doc-tag {
    font-size: 0.56rem;
  }
  .doc-name {
    font-size: 0.58rem;
  }
  .s-app {
    width: min(360px, 96vw);
  }
  .app-bar {
    padding: 10px 12px;
  }
  .status {
    right: 10px;
    max-width: 52%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .tab {
    font-size: 0.68rem;
    padding: 5px 8px;
  }
  .app-body {
    height: 204px;
  }
  .app-view {
    padding: 10px;
  }
  .ocr-row {
    height: 39px;
  }
  .row-skeleton,
  .row-content {
    grid-template-columns: 38px minmax(0, 1fr) auto 68px;
    gap: 7px;
    font-size: 0.63rem;
  }
  .chip {
    font-size: 0.62rem;
    padding: 1px 6px;
  }
  .row-hl {
    top: 10px;
    height: 39px;
  }
  .stmt-head {
    font-size: 0.64rem;
  }
  .stmt-line {
    font-size: 0.66rem;
  }
  .stamp {
    font-size: 0.58rem;
  }
  .story-chapter {
    min-height: max(620px, var(--story-vh));
    padding-bottom: clamp(18px, 3vh, 28px);
  }
  .chapter-text {
    padding: 20px;
  }
  .chapter-text h3 {
    font-size: 1.48rem;
  }
  .chapter-text p {
    font-size: 1.02rem;
    line-height: 1.65;
  }
  .section-head {
    margin-bottom: 34px;
  }
  .card {
    padding: 24px;
  }
  .card .icon {
    width: 46px;
    height: 46px;
  }
  .card p {
    font-size: 1.02rem;
  }
  .cta-final .panel {
    padding: 42px 22px;
  }
}

@media (max-width: 430px) {
  .nav-links .btn {
    padding: 8px 12px;
  }
  .hero {
    padding-top: 52px;
  }
  .badge {
    font-size: 0.74rem;
  }
  .cta-row {
    flex-direction: column;
    align-items: stretch;
  }
  .cta-row .btn {
    width: 100%;
  }
  .story {
    --stage-w: 340px;
    --stage-h: 350px;
    --stage-top: 27%;
    --hover-doc-step: 11px;
  }
  .ground-doc {
    left: 8px;
    top: 3%;
    width: 94px;
    padding: 8px 7px;
    border-radius: 7px;
    transform: translateX(-6px) scale(0.88);
  }
  .story[data-chapter='2'] .ground-doc {
    transform: translateX(0) scale(0.88);
  }
  .s-doc {
    width: 88px;
  }
  .s-doc--1 { left: -2%; top: 1%; }
  .s-doc--2 { right: -1%; top: 0; }
  .s-doc--3 { left: -3%; top: 40%; }
  .s-doc--4 { left: 3%; bottom: 3%; }
  .s-doc--5 { right: 0; bottom: 2%; }
  .doc-lines i {
    height: 4px;
    margin-bottom: 4px;
  }
  .s-app {
    width: min(330px, 96vw);
    border-radius: 12px;
  }
  .app-dot {
    width: 8px;
    height: 8px;
  }
  .app-title {
    font-size: 0.7rem;
    margin-left: 5px;
  }
  .status {
    font-size: 0.58rem;
    padding: 2px 6px;
  }
  .app-body {
    height: 194px;
  }
  .row-skeleton,
  .row-content {
    grid-template-columns: 35px minmax(0, 1fr) auto 60px;
    gap: 6px;
    font-size: 0.58rem;
  }
  .chip {
    font-size: 0.56rem;
    padding-inline: 5px;
  }
  .story-chapter {
    min-height: max(600px, var(--story-vh));
  }
  .chapter-text {
    padding: 18px;
  }
  .chapter-text h3 {
    font-size: 1.34rem;
  }
  .chapter-text p,
  .card p {
    font-size: 1rem;
  }
}

@media (max-width: 360px) {
  .logo {
    font-size: 1rem;
  }
  .nav-links .btn {
    padding: 8px 10px;
    font-size: 0.86rem;
  }
  .hero h1 {
    font-size: 2rem;
  }
  .hero .sub {
    font-size: 1.04rem;
  }
  .story {
    --stage-w: 310px;
    --stage-h: 330px;
    --stage-top: 34%;
    --hover-row-step: 34px;
    --hover-doc-step: 10px;
  }
  .ground-doc {
    top: 10%;
    width: 86px;
  }
  .s-app {
    width: min(300px, 96vw);
  }
  .app-body {
    height: 172px;
  }
  .ocr-row {
    height: 34px;
  }
  .row-skeleton,
  .row-content {
    grid-template-columns: 32px minmax(0, 1fr) auto 54px;
    gap: 5px;
    font-size: 0.54rem;
  }
  .row-hl {
    height: 34px;
  }
  .chapter-text h3 {
    font-size: 1.24rem;
  }
  .chapter-text p,
  .card p {
    font-size: 0.96rem;
  }
}

@media (max-height: 640px) and (max-width: 960px) and (orientation: landscape) {
  .hero {
    padding: 44px 0 54px;
  }
  .story {
    --stage-w: min(340px, 52vw);
    --stage-h: 310px;
    --stage-left: 31%;
    --stage-top: 54%;
    --hover-row-step: 32px;
    --hover-doc-step: 10px;
  }
  .ground-doc {
    left: 8px;
    top: 8%;
    width: 82px;
    padding: 7px 6px;
  }
  .s-app {
    width: min(330px, 58vw);
  }
  .app-body {
    height: 166px;
  }
  .ocr-row {
    height: 32px;
  }
  .row-skeleton,
  .row-content {
    grid-template-columns: 30px minmax(0, 1fr) auto 52px;
    gap: 5px;
    font-size: 0.52rem;
  }
  .row-hl {
    height: 32px;
  }
  .stmt-head {
    font-size: 0.56rem;
  }
  .stmt-line {
    font-size: 0.58rem;
    padding-top: 6px;
  }
  .stamp {
    font-size: 0.5rem;
  }
  .story-chapter {
    min-height: var(--story-vh);
    align-items: center;
    padding-bottom: 0;
  }
  .chapter-grid {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
    align-items: center;
  }
  .story-chapter:nth-child(even) .chapter-text,
  .chapter-text {
    grid-column: 2;
    justify-self: end;
    text-align: left;
  }
  .chapter-text {
    width: min(100%, 440px);
    padding: 14px 16px;
  }
  .chapter-text h3 {
    margin-bottom: 6px;
    font-size: 1.08rem;
  }
  .chapter-text p {
    font-size: 0.86rem;
    line-height: 1.45;
  }
  .ch-label {
    font-size: 0.58rem;
  }
}
