/* ──────────────── Finwise — shared styles ──────────────── */

/* Tokens */
:root {
  --ink-50:  #eef0ff;
  --ink-100: #e0e3ff;
  --ink-200: #c4cafd;
  --ink-300: #a5acf9;
  --ink-400: #8189f3;
  --ink-500: #6366f1;
  --ink-600: #4f46e5;
  --ink-700: #4338ca;
  --ink-800: #3730a3;
  --ink-900: #312e81;
  --ink-950: #1e1b4b;

  --paper:    #fbfaf7;
  --paper-2:  #f4f2ec;
  --rule:     rgba(30, 27, 75, 0.10);
  --rule-2:   rgba(30, 27, 75, 0.06);
  --body:     #2a2740;
  --body-soft:#5b5780;
  --muted:    #8b87a8;

  --accent:      var(--ink-600);
  --accent-2:    var(--ink-500);
  --accent-deep: var(--ink-900);
  --bg:          var(--paper);
  --bg-2:        var(--paper-2);
  --fg:          var(--body);
  --fg-soft:     var(--body-soft);
  --fg-mute:     var(--muted);
  --line:        var(--rule);
  --line-2:      var(--rule-2);

  --display: "Instrument Serif", Georgia, "Times New Roman", serif;
  --sans:    "Geist", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono:    "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;

  --maxw: 1240px;
  --col:  760px;
}

/* Base */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  font-family: var(--sans);
  color: var(--fg);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
::selection { background: var(--accent); color: var(--bg); }

.shell {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 40px;
}
@media (max-width: 640px) { .shell { padding: 0 22px; } }

/* ──────────────── Top bar (chapter pages) ──────────────── */
.topbar {
  padding: 28px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 0.5px solid var(--line);
  background: var(--bg);
}
.mark {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--display);
  font-size: 20px;
  letter-spacing: -0.01em;
  color: var(--accent-deep);
}
.mark-glyph {
  width: 20px; height: 20px; border-radius: 5px;
  background: var(--accent);
  position: relative;
}
.mark-glyph::after {
  content: "";
  position: absolute; inset: 4px;
  border-left: 1.4px solid rgba(255,255,255,.9);
  border-bottom: 1.4px solid rgba(255,255,255,.9);
  border-bottom-left-radius: 2px;
}
.chapter-indicator {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-mute);
}
.chapter-indicator b {
  color: var(--accent);
  font-weight: 400;
}

/* ──────────────── Hero ──────────────── */
.hero {
  padding: 64px 0 40px;
  position: relative;
  overflow: hidden;
}
.hero .shell { position: relative; z-index: 2; }

h1.lede {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(48px, 7.2vw, 104px);
  line-height: 0.98;
  letter-spacing: -0.02em;
  color: var(--accent-deep);
  margin: 0 0 28px;
  max-width: 14ch;
  text-wrap: balance;
}
h1.lede em { font-style: italic; color: var(--accent); }

.standfirst {
  max-width: 48ch;
  font-family: var(--display);
  font-size: clamp(20px, 2.4vw, 26px);
  line-height: 1.4;
  color: var(--fg-soft);
  margin: 28px 0 0;
  text-wrap: pretty;
}

/* Ambient decor */
.orb {
  position: absolute;
  width: min(720px, 95vw); height: min(720px, 95vw);
  right: clamp(-240px, -20vw, -120px); top: -200px;
  border-radius: 50%;
  background: radial-gradient(closest-side,
    color-mix(in oklab, var(--accent) 22%, transparent),
    transparent 70%);
  filter: blur(20px);
  pointer-events: none;
  z-index: 1;
}
.orb-echo {
  position: absolute;
  width: min(620px, 80vw); height: min(620px, 80vw);
  left: clamp(-260px, -18vw, -160px);
  bottom: -240px;
  right: auto; top: auto;
  border-radius: 50%;
  background: radial-gradient(closest-side,
    color-mix(in oklab, var(--accent) 14%, transparent),
    transparent 70%);
  filter: blur(28px);
  pointer-events: none;
  z-index: 0;
}
.grid-bg {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right,  var(--line-2) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line-2) 1px, transparent 1px);
  background-size: 80px 80px;
  mask-image: radial-gradient(ellipse at 75% 30%, black, transparent 65%);
  -webkit-mask-image: radial-gradient(ellipse at 75% 30%, black, transparent 65%);
  pointer-events: none;
  z-index: 0;
}

/* ──────────────── Story ──────────────── */
.story {
  padding: 56px 0 40px;
  border-top: 0.5px solid var(--line);
  position: relative;
  overflow: hidden;
}
.story-body { max-width: var(--col); margin: 0 auto; }

.section-tag {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 18px;
}

h2.section {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(30px, 6vw, 52px);
  line-height: 1.05;
  letter-spacing: -0.015em;
  color: var(--accent-deep);
  margin: 0 0 28px;
  text-wrap: balance;
}

.story-body p {
  font-size: clamp(17px, 2.2vw, 20px);
  line-height: 1.6;
  color: var(--fg);
  margin: 0 0 24px;
  text-wrap: pretty;
}
.story-body p.intro {
  font-family: var(--display);
  font-size: clamp(20px, 3.6vw, 26px);
  line-height: 1.4;
  color: var(--accent-deep);
  margin-bottom: 36px;
}

/* "Missing" — big serif nouns */
.missing {
  margin: 8px 0 28px;
  padding: 0;
  list-style: none;
  counter-reset: m;
}
.missing li {
  display: grid;
  grid-template-columns: 36px 1fr;
  column-gap: 20px;
  align-items: baseline;
  padding: 18px 0;
  border-bottom: 0.5px solid var(--line);
  counter-increment: m;
}
.missing li:first-child { border-top: 0.5px solid var(--line); }
.missing li::before {
  content: counter(m, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.04em;
  align-self: start;
  padding-top: 14px;
}
.missing li span {
  font-family: var(--display);
  font-size: clamp(28px, 4.2vw, 44px);
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--accent-deep);
}
.story-body p.missing-coda {
  margin: 22px 0 0;
  padding-left: 56px;
  font-size: clamp(16px, 1.8vw, 18px);
  line-height: 1.55;
  color: var(--fg-soft);
  text-wrap: pretty;
  position: relative;
}
.story-body p.missing-coda::before {
  content: "+";
  position: absolute;
  left: 0; top: 0;
  width: 36px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.04em;
}

/* Principles list (Chapter 02) */
.creed {
  margin: 8px 0 36px;
  padding: 0;
  list-style: none;
  counter-reset: c;
  border-top: 0.5px solid var(--line);
}
.creed li {
  display: grid;
  grid-template-columns: 56px 1fr;
  column-gap: 24px;
  padding: 32px 0;
  border-bottom: 0.5px solid var(--line);
  counter-increment: c;
}
.creed li::before {
  content: counter(c, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.04em;
  padding-top: 10px;
}
.creed h3 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(22px, 3.4vw, 32px);
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--accent-deep);
  margin: 0 0 12px;
  text-wrap: balance;
}
.creed p {
  font-size: clamp(16px, 1.9vw, 18px);
  line-height: 1.6;
  color: var(--fg-soft);
  margin: 0;
  text-wrap: pretty;
}

/* Pre-thesis lead-in */
.story-body p.lead-in {
  margin: 48px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  text-align: center;
}

/* Thesis line */
.story-body p.thesis {
  margin: 24px auto 64px;
  padding: 0 20px;
  max-width: 36ch;
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(28px, 4vw, 38px);
  line-height: 1.22;
  letter-spacing: -0.01em;
  color: var(--accent-deep);
  text-align: center;
  text-wrap: balance;
}
.story-body p.thesis.first { margin-top: 72px; }

/* Pull quote */
.pullquote {
  margin: 44px auto 24px;
  padding: 38px 32px 40px;
  border-top: 0.5px solid var(--accent);
  border-bottom: 0.5px solid var(--accent);
  background: color-mix(in oklab, var(--bg) 92%, var(--accent) 6%);
  position: relative;
  max-width: var(--col);
}
.pullquote-tag {
  position: absolute; top: -8px; left: 24px;
  background: var(--bg);
  padding: 0 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.pullquote q {
  quotes: none;
  display: block;
  font-family: "Times New Roman", Georgia, "Instrument Serif", serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(22px, 2.8vw, 32px);
  line-height: 1.25;
  letter-spacing: -0.005em;
  color: var(--accent-deep);
  text-wrap: balance;
}
.pullquote q::before { content: "\201C"; color: var(--accent); margin-right: 4px; }
.pullquote q::after  { content: "\201D"; color: var(--accent); margin-left: 4px; }
.pullquote .hl { color: var(--accent); font-style: italic; }

.story-body p.closing {
  font-family: var(--display);
  font-size: clamp(28px, 4.6vw, 44px);
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--accent-deep);
  margin: 56px 0 0;
  text-wrap: balance;
}
.story-body p.closing em { font-style: italic; color: var(--accent); }

/* Pivot pair */
.pivot {
  margin: 36px 0 28px;
  padding: 24px 0 28px;
  border-top: 0.5px solid var(--line);
  border-bottom: 0.5px solid var(--line);
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.pivot .a, .pivot .b {
  font-family: var(--display);
  font-size: clamp(22px, 3.2vw, 30px);
  line-height: 1.25;
  margin: 0;
  letter-spacing: -0.005em;
}
.pivot .a { color: var(--fg-soft); }
.pivot .b { color: var(--accent-deep); }
.pivot .b em { font-style: italic; color: var(--accent); }

.story-body p.closing-sig {
  margin: 28px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-mute);
  line-height: 1.4;
}

/* ──────────────── Chapter navigation ──────────────── */
.chapter-nav {
  border-top: 0.5px solid var(--line);
  padding: 56px 0 64px;
}
.chapter-nav .shell {
  max-width: var(--col);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.chapter-nav a,
.chapter-nav .ghost {
  display: block;
  padding: 22px 0;
}
.chapter-nav .tag {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin-bottom: 10px;
}
.chapter-nav .title {
  font-family: var(--display);
  font-size: clamp(22px, 3vw, 28px);
  line-height: 1.2;
  color: var(--accent-deep);
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  transition: color .15s ease, transform .15s ease;
}
.chapter-nav .title em {
  font-style: italic;
  color: var(--accent);
}
.chapter-nav .arrow {
  font-family: var(--sans);
  font-size: 0.85em;
  color: var(--accent);
  transition: transform .15s ease;
}
.chapter-nav .prev { text-align: left; }
.chapter-nav .next { text-align: right; }
.chapter-nav .next .title { justify-content: flex-end; }
.chapter-nav a:hover .title { color: var(--accent); }
.chapter-nav .prev a:hover .arrow { transform: translateX(-3px); }
.chapter-nav .next a:hover .arrow { transform: translateX(3px); }

.chapter-nav .ghost .title {
  color: var(--fg-mute);
  font-style: italic;
}
.chapter-nav .ghost .arrow { color: var(--fg-mute); }

/* ──────────────── Sign-off ──────────────── */
.signoff {
  padding: 56px 0 72px;
  border-top: 0.5px solid var(--line);
  text-align: center;
  background:
    linear-gradient(to bottom,
      color-mix(in oklab, var(--bg) 100%, transparent),
      color-mix(in oklab, var(--bg) 92%, var(--accent) 5%));
}
.signoff p {
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(22px, 2.6vw, 30px);
  line-height: 1.4;
  color: var(--accent-deep);
  margin: 0;
  text-wrap: balance;
}
.signoff .next-up {
  margin-top: 20px;
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-mute);
}
.signoff .next-up::before {
  content: ""; width: 22px; height: 1px;
  background: var(--accent);
}

/* ──────────────── Footer ──────────────── */
footer {
  padding: 28px 0 36px;
  border-top: 0.5px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-mute);
  letter-spacing: 0.04em;
}
footer .shell {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

/* ──────────────── Mobile ──────────────── */
@media (max-width: 640px) {
  :root { --maxw: 100%; }
  body { font-size: 17px; }
  .topbar { padding: 20px 0; }
  .mark { font-size: 18px; }
  .chapter-indicator { font-size: 10px; letter-spacing: 0.1em; }
  .hero { padding: 56px 0 28px; }
  .story { padding: 32px 0 56px; }
  .signoff { padding: 48px 0 64px; }
  h1.lede { text-align: left; max-width: 100%; font-size: clamp(44px, 11vw, 64px); }
  h1.lede em { display: inline; }
  .standfirst { font-size: 18px; margin-top: 22px; }
  h2.section { font-size: clamp(28px, 7.5vw, 40px); margin: 0 0 22px; }
  .story-body p { font-size: 17px; margin-bottom: 18px; }
  .story-body p.intro { font-size: 19px; }
  .pivot { margin: 28px 0 22px; padding: 20px 0 22px; }
  .pivot .a, .pivot .b { font-size: clamp(20px, 5.8vw, 26px); }
  .missing li { padding: 14px 0; grid-template-columns: 24px 1fr; column-gap: 14px; }
  .missing li span { font-size: clamp(26px, 7vw, 36px); }
  .missing li::before { padding-top: 10px; }
  .missing-coda { padding-left: 38px; font-size: 16px; }
  .creed li { grid-template-columns: 32px 1fr; column-gap: 14px; padding: 24px 0; }
  .creed li::before { padding-top: 6px; }
  .creed h3 { font-size: clamp(22px, 6.4vw, 28px); margin-bottom: 8px; }
  .creed p { font-size: 16px; }
  .story-body p.thesis { font-size: clamp(24px, 6.4vw, 32px); margin: 32px auto 40px; padding: 0 8px; }
  .story-body p.thesis.first { margin-top: 48px; }
  .pullquote { margin: 28px auto 20px; padding: 30px 20px 28px; }
  .pullquote-tag { left: 16px; padding: 0 10px; }
  .pullquote q { line-height: 1.25; font-size: clamp(20px, 5.4vw, 26px); }
  .story-body p.closing { font-size: clamp(26px, 7vw, 36px); margin-top: 40px; }
  .closing-sig { margin-top: 22px; }
  .chapter-nav { padding: 40px 0 48px; }
  .chapter-nav .shell { grid-template-columns: 1fr; gap: 4px; }
  .chapter-nav .next { text-align: left; }
  .chapter-nav .next .title { justify-content: flex-start; }
  .chapter-nav .title { font-size: 22px; }
  .signoff p { font-size: clamp(22px, 5.6vw, 28px); padding: 0 8px; }
  footer .shell { flex-direction: column; align-items: flex-start; gap: 8px; }
  .orb { opacity: 0.6; }
  .orb-echo { display: none; }
  .grid-bg { background-size: 56px 56px; }
}
