/* Reset, typography, layout primitives, reveal system. */
*, *::before, *::after { box-sizing: border-box; }
html {
  background: var(--ink-1);
  scrollbar-gutter: stable; /* dialogs lock the scroll without the page shifting sideways */
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header) + 8px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  background: var(--ink-1);
  color: var(--text-1);
  font: 400 var(--fs-body)/1.8 var(--sans);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden; /* iOS 15 has no clip; hidden on body propagates to the viewport, so sticky still works */
  overflow-x: clip;
}
h1, h2, h3, h4, p, ol, ul, figure, blockquote { margin: 0; }
ol, ul { padding: 0; list-style: none; }
h1, h2, h3 { text-wrap: balance; font-weight: 400; }
p { text-wrap: pretty; }
img, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; opacity: 0.45; }
a { color: inherit; text-decoration: none; }
button, a, input, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blue-soft); outline-offset: 4px; border-radius: 4px; }
::selection { background: var(--blue); color: #fff; }
mark { background: none; color: inherit; }
sup { font-size: 0.62em; line-height: 0; vertical-align: super; }
sup a { color: var(--blue-soft); padding: 0 2px; font-family: var(--mono); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg:has(> use) { width: 1em; height: 1em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* Scrollbar */
html { scrollbar-color: var(--ink-5) var(--ink-1); scrollbar-width: thin; }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--ink-1); }
::-webkit-scrollbar-thumb { background: var(--ink-4); border-radius: 8px; border: 2px solid var(--ink-1); }

/* Layout */
.shell { width: min(1280px, calc(100% - var(--gutter) * 2)); margin-inline: auto; }
.skip-link {
  position: fixed; z-index: 100; top: 10px; left: 12px; padding: 10px 18px; border-radius: 999px;
  background: var(--paper); color: var(--paper-ink); font-weight: 600; transform: translateY(-160%);
  transition: transform var(--t-base) var(--ease-out);
}
.skip-link:focus { transform: none; }

/* Film grain: a static, compositor-only texture that gives the ink a printed tooth. */
.grain {
  position: fixed; inset: 0; z-index: 90; pointer-events: none; opacity: 0.05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Type */
.display-xl, .display-l, .display-m, .closure-title {
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: -0.035em;
  font-feature-settings: "palt" 1;
}
.display-xl { font-size: var(--fs-display-xl); line-height: 1.08; }
.display-l { font-size: var(--fs-display-l); line-height: 1.14; }
.display-m { font-size: var(--fs-display-m); line-height: 1.3; }
.lead { font-size: var(--fs-lead); line-height: 1.85; color: var(--text-2); max-width: 34em; }
.body-copy { color: var(--text-2); max-width: 36em; }
.line { display: block; }
/* Chinese phrase wrapping: break at punctuation, not inside words; overflow still wraps. */
h1, h2, h3, h4, .lead, .hero-lead, .ink-text, .chapter-coda, .closure-title, .dock-note p, .origin-card p,
.draft-receipt p, .paper-review p, .footer-tag, .faq-list summary span, .growth-note h3, .clauses h3,
.agent-placeholder p, .wb-side-foot small, .mode-note, .stage-caption, .reception-note p {
  word-break: keep-all; overflow-wrap: anywhere;
}
.line-accent > span {
  background: linear-gradient(100deg, var(--blue-mist) 0%, var(--blue-soft) 38%, #6aa2ff 70%, var(--blue-soft) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  padding-right: 0.04em;
}

/* Folio: the section mark of a legal document. */
.folio {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 14px;
  font: 500 var(--fs-micro)/1.6 var(--mono); letter-spacing: 0.14em; color: var(--text-3);
  margin-bottom: clamp(18px, 2.2vw, 30px);
}
.folio b { font-weight: 500; color: var(--blue-soft); letter-spacing: 0.08em; }
.folio span { font-family: var(--sans); letter-spacing: 0.22em; }
.folio em { font-style: normal; text-transform: uppercase; letter-spacing: 0.22em; color: var(--text-4); }
.folio.is-center { justify-content: center; }

.text-link {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px;
  font-size: 15px; color: var(--blue-soft);
  background: linear-gradient(currentColor, currentColor) 0 calc(100% - 9px) / 0 1px no-repeat;
  transition: background-size var(--t-slow) var(--ease-out), color var(--t-base);
}
.text-link:hover { background-size: calc(100% - 26px) 1px; color: var(--blue-mist); }
.text-link svg { transition: transform var(--t-base) var(--ease-out); }
.text-link:hover svg { transform: translate(2px, -2px); }

/* ---------------------------------------------------------------- reveals
   Before JS everything is visible. With JS, items wait for .is-in; a failsafe
   shows them after 3.5s even if the observer never runs. */
.js [data-reveal]:not(.is-in):not([data-reveal="lines"]) {
  opacity: 0; transform: translate3d(0, 26px, 0);
  animation: reveal-failsafe 0s linear 3.5s forwards;
}
[data-reveal]:not([data-reveal="lines"]) {
  transition: opacity 0.9s var(--ease-out), transform var(--t-reveal) var(--ease-out);
  transition-delay: var(--d, 0ms);
}
[data-reveal="lines"] .line { overflow: hidden; padding-block: 0.06em 0.12em; margin-block: -0.06em -0.12em; }
[data-reveal="lines"] .line > span { display: inline-block; transition: transform 1.15s var(--ease-out); }
.js [data-reveal="lines"]:not(.is-in) .line > span { transform: translate3d(0, 108%, 0); animation: reveal-failsafe 0s linear 3.5s forwards; }
[data-reveal="lines"] .line:nth-child(2) > span { transition-delay: 90ms; }
[data-reveal="lines"] .line:nth-child(3) > span { transition-delay: 180ms; }
.actions[data-reveal], .lead[data-reveal] { --d: 140ms; }
.hero-lead[data-reveal] { --d: 260ms; }
.hero-copy .actions[data-reveal] { --d: 360ms; }
.origin-card[data-reveal] { --d: 480ms; }
@keyframes reveal-failsafe { to { opacity: 1; transform: none; } }

.motion-reduced [data-reveal], .motion-reduced [data-reveal] .line > span { opacity: 1 !important; transform: none !important; transition: none !important; animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  [data-reveal], [data-reveal] .line > span { opacity: 1 !important; transform: none !important; transition: none !important; animation: none !important; }
}

/* Reduced motion (system setting or the header toggle): no decorative animation at all.
   End states are shown directly, e.g. the hero wires fully drawn. */
.motion-reduced *, .motion-reduced *::before, .motion-reduced *::after { animation: none !important; transition-duration: 0.01ms !important; transition-delay: 0s !important; }
.motion-reduced .hero-rings .wire { stroke-dashoffset: 0; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; transition-delay: 0s !important; }
  .hero-rings .wire { stroke-dashoffset: 0; }
}
