/* ============================================
   Formedium × RVS Media — Interactive Proposal
   Scientific editorial aesthetic
   ============================================ */

:root {
  /* Paper + ink */
  --paper: #f6f2ea;         /* warm off-white, agar cream */
  --paper-2: #ede7da;       /* deeper paper */
  --paper-3: #e4dcc9;       /* paper for dividers */
  --ink: #17140f;           /* deep warm ink */
  --ink-2: #2a2520;
  --ink-3: #4a4339;
  --ink-mute: #7a7163;

  /* Accent — agar amber */
  --accent: #c77b2c;
  --accent-2: #a75f18;
  --accent-soft: #e6a866;

  /* Data colors */
  --magenta: #7a1b1b;       /* warning / shopify */
  --forest: #2b4a2b;        /* positive */
  --slate: #3a4656;

  /* Type */
  --serif: "Fraunces", "Source Serif Pro", ui-serif, Georgia, serif;
  --sans: "Inter Tight", "Inter", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Layout */
  --gutter: clamp(20px, 4vw, 64px);
  --max: 1240px;
  --radius: 2px;
}

/* Note: Fraunces is an exception from "avoid overused fonts" — Inter is explicitly avoided; I'm using Inter Tight which has distinct metrics. Fraunces' optical sizing fits the editorial/scientific tone. */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.02em;
  margin: 0;
  text-wrap: balance;
  font-variation-settings: "SOFT" 30, "WONK" 0;
}

p { margin: 0; text-wrap: pretty; }

.mono {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-2);
  font-weight: 500;
}

.section-num {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--ink-mute);
}

/* Scaffolded sections */
section {
  position: relative;
  padding: clamp(80px, 12vw, 160px) var(--gutter);
}

.container {
  max-width: var(--max);
  margin: 0 auto;
  width: 100%;
}

.wide { max-width: 1400px; }

/* Rules */
.rule {
  height: 1px;
  background: var(--ink);
  opacity: 0.18;
  width: 100%;
}

/* Link base */
a {
  color: inherit;
  text-decoration: none;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 220ms cubic-bezier(.2,.8,.2,1), background 200ms, color 200ms;
}
.btn:hover { transform: translateY(-1px); background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--ink); color: var(--paper); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.btn.accent:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn .arrow { transition: transform 220ms; display: inline-block; }
.btn:hover .arrow { transform: translateX(3px); }

/* Chapter header */
.chapter-head {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: clamp(24px, 4vw, 80px);
  margin-bottom: clamp(40px, 6vw, 72px);
  align-items: start;
}
.chapter-head .meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 8px;
}
.chapter-head h2 {
  font-size: clamp(2.4rem, 5.4vw, 4.2rem);
  line-height: 0.96;
  letter-spacing: -0.03em;
}
.chapter-head .lede {
  font-family: var(--serif);
  font-size: clamp(1.1rem, 1.6vw, 1.35rem);
  line-height: 1.4;
  color: var(--ink-2);
  max-width: 62ch;
  margin-top: 24px;
  font-style: italic;
  font-weight: 300;
}
@media (max-width: 780px) {
  .chapter-head { grid-template-columns: 1fr; gap: 16px; }
}

/* Page chrome */
.top-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px var(--gutter);
  background: color-mix(in oklab, var(--paper) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid color-mix(in oklab, var(--ink) 10%, transparent);
  transition: transform 300ms, opacity 300ms;
}
.top-bar.hidden { transform: translateY(-100%); }

.brand-lock {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.brand-lock .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  display: inline-block;
}

.progress-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: transparent;
  z-index: 51;
  pointer-events: none;
}
.progress-bar .fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 120ms linear;
}

/* Chapter sidebar nav */
.chapter-nav {
  position: fixed;
  left: max(16px, calc((100vw - var(--max)) / 2 - 280px));
  top: 50%;
  transform: translateY(-50%);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 8px;
  background: color-mix(in oklab, var(--paper) 82%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid color-mix(in oklab, var(--ink) 10%, transparent);
  border-radius: 3px;
  max-height: 70vh;
  overflow-y: auto;
  opacity: 0;
  transform: translate(-12px, -50%);
  transition: opacity 400ms, transform 400ms;
  pointer-events: none;
}
.chapter-nav.visible {
  opacity: 1;
  transform: translate(0, -50%);
  pointer-events: auto;
}
.chapter-nav a {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-mute);
  padding: 4px 6px;
  border-radius: 2px;
  white-space: nowrap;
  transition: color 200ms, background 200ms;
}
.chapter-nav a .tick {
  width: 12px;
  height: 1px;
  background: currentColor;
  opacity: 0.4;
}
.chapter-nav a:hover { color: var(--ink); }
.chapter-nav a.active { color: var(--accent-2); }
.chapter-nav a.active .tick { width: 20px; opacity: 1; }
/* Hide by default, show conditionally */
.chapter-nav {
  display: none;
}

/* Show in background and subsequent sections */
body.show-nav .chapter-nav {
  display: flex;
}

@media (max-width: 1400px) {
  .chapter-nav { display: none !important; }
}

/* Hero */
.hero {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 120px var(--gutter) 80px;
  position: relative;
  overflow: hidden;
}
.hero-stage {
  position: relative;
  width: 100%;
  max-width: 1100px;
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
}
@media (max-width: 780px) { .hero-stage { aspect-ratio: 4 / 5; } }

.hero-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hero-title {
  position: relative;
  text-align: center;
  z-index: 2;
}
.hero-title .eyebrow { display: block; margin-bottom: 28px; }
.hero-title h1 {
  font-size: clamp(2.4rem, 7vw, 6rem);
  line-height: 0.94;
  letter-spacing: -0.035em;
  font-weight: 300;
  font-style: italic;
}
.hero-title h1 .split { display: inline-block; overflow: hidden; }
.hero-title h1 .split span { display: inline-block; }
.hero-title .lockup {
  margin-top: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.hero-title .lockup .x { opacity: 0.5; }

.hero-meta {
  position: absolute;
  bottom: 36px;
  left: var(--gutter);
  right: var(--gutter);
  display: flex;
  justify-content: space-between;
  align-items: end;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  gap: 20px;
  flex-wrap: wrap;
}
.hero-meta .item { display: flex; flex-direction: column; gap: 4px; }
.hero-meta .item .k { opacity: 0.6; }
.hero-meta .item .v { color: var(--ink); }
.hero-scroll-cue {
  position: absolute;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-mute);
  animation: bob 3s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, 6px); }
}

/* Big number blocks */
.bignum {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  background: color-mix(in oklab, var(--ink) 12%, transparent);
  border: 1px solid color-mix(in oklab, var(--ink) 12%, transparent);
}
.bignum .cell {
  background: var(--paper);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 140px;
}
.bignum .cell .k { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-mute); }
.bignum .cell .v {
  font-family: var(--serif);
  font-size: clamp(2rem, 3.6vw, 3rem);
  line-height: 1;
  letter-spacing: -0.03em;
}
.bignum .cell .sub { font-size: 0.82rem; color: var(--ink-3); margin-top: auto; }
@media (max-width: 780px) {
  .bignum { grid-template-columns: repeat(2, 1fr); }
}

/* Two-col body */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(24px, 4vw, 64px);
  align-items: start;
}
@media (max-width: 780px) { .two-col { grid-template-columns: 1fr; } }

.body-copy {
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--ink-2);
  max-width: 62ch;
}
.body-copy p + p { margin-top: 1em; }

/* Background variants */
.bg-ink {
  background: var(--ink);
  color: var(--paper);
}
.bg-ink .eyebrow { color: var(--accent-soft); }
.bg-ink .body-copy { color: color-mix(in oklab, var(--paper) 82%, transparent); }
.bg-ink .section-num { color: color-mix(in oklab, var(--paper) 55%, transparent); }
.bg-ink .rule { background: var(--paper); opacity: 0.2; }
.bg-ink .btn { border-color: var(--paper); background: transparent; color: var(--paper); }
.bg-ink .btn:hover { background: var(--paper); color: var(--ink); }
.bg-ink .btn.accent { background: var(--accent); border-color: var(--accent); color: var(--paper); }

.bg-paper-2 { background: var(--paper-2); }

/* Dividers */
.div-lab {
  position: relative;
  height: 80px;
  background:
    repeating-linear-gradient(90deg,
      transparent 0 39px,
      color-mix(in oklab, var(--ink) 8%, transparent) 39px 40px);
}

/* Fade-in on reveal */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 700ms cubic-bezier(.2,.8,.2,1), transform 700ms cubic-bezier(.2,.8,.2,1);
}
.reveal.in {
  opacity: 1;
  transform: translateY(0);
}
.reveal.d1 { transition-delay: 80ms; }
.reveal.d2 { transition-delay: 160ms; }
.reveal.d3 { transition-delay: 240ms; }
.reveal.d4 { transition-delay: 320ms; }

/* Tweaks panel */
.tweaks {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: var(--paper);
  border: 1px solid color-mix(in oklab, var(--ink) 18%, transparent);
  padding: 16px 18px;
  z-index: 60;
  box-shadow: 0 20px 40px -20px rgba(0,0,0,0.3);
  min-width: 260px;
  display: none;
  font-family: var(--sans);
}
.tweaks.show { display: block; }
.tweaks h4 { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-mute); margin-bottom: 12px; font-weight: 500; }
.tweaks .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; font-size: 0.85rem; }
.tweaks .swatches { display: flex; gap: 6px; }
.tweaks .swatches button { width: 22px; height: 22px; border: 1px solid color-mix(in oklab, var(--ink) 18%, transparent); border-radius: 50%; cursor: pointer; padding: 0; }
.tweaks .swatches button.on { outline: 2px solid var(--ink); outline-offset: 2px; }
.tweaks select { font-family: var(--mono); font-size: 0.72rem; padding: 4px 8px; border: 1px solid color-mix(in oklab, var(--ink) 18%, transparent); background: var(--paper); color: var(--ink); }
