/* ═══════════════════════════════════════════════════════════════
   Ezra Reichel: ink and machine
   The page is a sheet of paper. Ink moves underneath everything
   (js/ink.js). Type sits on top like a set book: a wide left
   margin for the chapter numeral, a right margin for sidenotes.
   ═══════════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Fraunces';
  src: url('assets/fonts/Fraunces-latin.woff2') format('woff2');
  font-weight: 300 900;
  font-display: swap;
}
@font-face { font-family:'Switzer'; src:url('assets/fonts/Switzer-300.woff2') format('woff2'); font-weight:300; font-display:swap; }
@font-face { font-family:'Switzer'; src:url('assets/fonts/Switzer-400.woff2') format('woff2'); font-weight:400; font-display:swap; }
@font-face { font-family:'Switzer'; src:url('assets/fonts/Switzer-500.woff2') format('woff2'); font-weight:500; font-display:swap; }
@font-face { font-family:'Switzer'; src:url('assets/fonts/Switzer-600.woff2') format('woff2'); font-weight:600; font-display:swap; }
@font-face { font-family:'Switzer'; src:url('assets/fonts/Switzer-700.woff2') format('woff2'); font-weight:700; font-display:swap; }
/* Only the numerals 一 to 八 are in this file. Everything else falls through to the system Songti. */
@font-face {
  font-family: 'Numerals SC';
  src: url('assets/fonts/NotoSerifSC-numerals.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
  unicode-range: U+4E00, U+4E8C, U+4E09, U+56DB, U+4E94, U+516D, U+4E03, U+516B;
}

:root {
  --paper:      #ECEDE9;
  --paper-deep: #E1E3DE;
  --ink:        #121418;
  --ink-2:      #2A2E36;
  --wash:       #6B717D;
  --wash-light: #9CA2AD;
  --indigo:     #24306E;
  --hair:       rgba(18, 20, 24, 0.14);
  --hair-soft:  rgba(18, 20, 24, 0.07);

  --display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --sans: 'Switzer', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --cjk: 'Numerals SC', 'Songti SC', 'Noto Serif CJK SC', 'SimSun', serif;

  --margin-l: 132px;      /* numeral column */
  --col: 660px;           /* measure */
  --margin-r: 272px;      /* sidenote column */
  --gut: clamp(20px, 5vw, 56px);
  --band: clamp(88px, 12vh, 160px);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  letter-spacing: -0.004em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Paper fibre and a faint static wash for when the simulation is off. */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: -2;
  background:
    radial-gradient(60% 30% at 30% 28%, rgba(18,20,24,0.07), transparent 70%),
    radial-gradient(40% 24% at 68% 62%, rgba(18,20,24,0.045), transparent 70%),
    var(--paper);
  opacity: 0;
  transition: opacity 600ms var(--ease);
}
body.no-ink::before { opacity: 1; }

#ink {
  position: fixed; inset: 0; z-index: -1;
  width: 100vw; height: 100vh;
  display: block;
  pointer-events: none;
}
body.no-ink #ink { display: none; }

::selection { background: rgba(36, 48, 110, 0.18); }

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--indigo); }
:focus-visible { outline: 2px solid var(--indigo); outline-offset: 3px; border-radius: 2px; }

.skip {
  position: absolute; left: 16px; top: -60px;
  padding: 10px 14px; background: var(--ink); color: var(--paper);
  z-index: 100; transition: top 150ms;
}
.skip:focus { top: 16px; }

/* ── Top bar: mark, nav ─────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px var(--gut);
  font-size: 13px;
  mix-blend-mode: multiply;
}
.mark {
  font-family: var(--display); font-weight: 560; font-size: 22px;
  letter-spacing: -0.02em;
  font-variation-settings: 'opsz' 20;
}
.nav { display: flex; gap: 22px; }
.nav a { color: var(--wash); font-weight: 500; }
.nav a:hover, .nav a[aria-current="true"] { color: var(--ink); }

/* ── Chapters ───────────────────────────────────────────────── */
main { display: block; }

.chap {
  position: relative;
  display: grid;
  grid-template-columns: var(--margin-l) minmax(0, var(--col)) var(--margin-r);
  justify-content: center;
  column-gap: 0;
  padding: var(--band) var(--gut);
}
.chap + .chap { border-top: 1px solid var(--hair-soft); }

.num {
  grid-column: 1;
  font-family: var(--cjk);
  font-size: 64px; line-height: 1;
  color: var(--ink);
  opacity: 0.9;
  padding-top: 6px;
  user-select: none;
  letter-spacing: 0;
  align-self: start;
  position: sticky; top: 96px;
}
.body { grid-column: 2; min-width: 0; }

h1, h2, h3 { font-family: var(--display); margin: 0; color: var(--ink); font-weight: 500; }
h1 {
  font-size: clamp(64px, 10.5vw, 136px);
  line-height: 0.92;
  letter-spacing: -0.035em;
  font-variation-settings: 'opsz' 144, 'SOFT' 30;
  margin: 10px 0 34px;
}
h2 {
  font-size: clamp(34px, 4.6vw, 54px);
  line-height: 1.02;
  letter-spacing: -0.025em;
  font-variation-settings: 'opsz' 60;
  margin-bottom: 14px;
}
h3 { font-size: 27px; letter-spacing: -0.015em; font-variation-settings: 'opsz' 28; }

.eyebrow {
  margin: 0; color: var(--wash); font-size: 13px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.sub { margin: 0 0 42px; color: var(--wash); font-size: 18px; }
.meta { margin: 6px 0 0; color: var(--wash); font-size: 14px; }
.meta a { color: var(--ink); border-bottom: 1px solid var(--hair); }

/* Book prose: a measure, old-style figures, a first paragraph that opens. */
.prose, .prose p { font-size: 18px; line-height: 1.64; }
.prose p { margin: 0 0 1.25em; color: var(--ink-2); }
.prose p:last-child { margin-bottom: 0; }
.prose .first, p.first { font-size: 21px; line-height: 1.5; color: var(--ink); }
.prose .first::first-letter, p.first::first-letter {
  font-family: var(--display); font-weight: 500;
  font-size: 3.2em; line-height: 0.8;
  float: left; margin: 0.08em 0.1em 0 0;
  font-variation-settings: 'opsz' 72;
}
.lead { text-wrap: pretty; font-size: clamp(19px, 2vw, 23px); line-height: 1.48; color: var(--ink); margin: 0 0 22px; max-width: 34ch; }
.hero-line { color: var(--wash); font-size: 16px; margin: 0; max-width: 46ch; }

/* Sidenotes, in the right margin. The span sits in the sentence it belongs to. */
.sn {
  float: right; clear: right;
  width: calc(var(--margin-r) - 40px);
  margin-right: calc(-1 * var(--margin-r) + 8px);
  margin-top: 4px; margin-bottom: 10px;
  font-size: 13.5px; line-height: 1.5;
  color: var(--wash);
  font-family: var(--sans);
  letter-spacing: 0;
  counter-increment: sn;
  position: relative;
  padding-left: 16px;
}
.sn::before {
  content: counter(sn);
  position: absolute; left: 0; top: 0.1em;
  font-family: var(--display); font-size: 12px; color: var(--ink);
}
.body { counter-reset: sn; }

/* ── Hero ───────────────────────────────────────────────────── */
.hero { min-height: calc(100vh - 60px); align-content: center; padding-top: 6vh; }
.hero .body { grid-column: 2; }
.portrait {
  grid-column: 3; grid-row: 1;
  margin: 0; align-self: center; justify-self: end;
  width: 236px;
  position: relative;
}
.portrait-ink {
  width: 100%; aspect-ratio: 1;
  /* The bled edge lives in the mask, so the photo itself is never distorted. */
  -webkit-mask: url('assets/img/portrait-mask.svg') center / 100% 100% no-repeat;
  mask: url('assets/img/portrait-mask.svg') center / 100% 100% no-repeat;
}
.portrait img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  filter: grayscale(1) contrast(1.04) brightness(1.08);
  transition: filter 700ms var(--ease);
}
.portrait:hover img { filter: grayscale(0); }
.portrait figcaption {
  margin-top: 14px; font-size: 12.5px; color: var(--wash); text-align: right;
  letter-spacing: 0.01em;
}

/* ── Built ──────────────────────────────────────────────────── */
.venture-head { margin-bottom: 20px; }
/* ── Pipeline ─────────────────────────────────────────────── */
.pipe { margin: 40px 0 0; color: var(--ink); }
.pipe-steps {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(7, 1fr);
  counter-reset: step;
}
.pipe-steps li {
  position: relative; padding: 30px 8px 0 0;
  font-size: 12.5px; line-height: 1.35; color: var(--wash);
  counter-increment: step;
}
/* the station dot and the line through it */
.pipe-steps li::before {
  content: ''; position: absolute; left: 0; top: 8px;
  width: 9px; height: 9px; border-radius: 50%; background: var(--ink);
}
.pipe-steps li::after {
  content: ''; position: absolute; left: 9px; right: 0; top: 12px;
  height: 1.2px; background: var(--ink);
}
.pipe-steps li:last-child::after { display: none; }
.pipe-steps b {
  display: block; color: var(--ink); font-family: var(--display); font-weight: 500;
  font-size: 17px; letter-spacing: -0.01em; margin-bottom: 4px;
  font-variation-settings: 'opsz' 20;
}
.pipe-loop { display: block; width: 100%; height: 34px; margin-top: 10px; color: var(--wash-light); }
.pipe figcaption { margin-top: 8px; font-size: 13.5px; color: var(--wash); }

/* ── Accounts, clips ────────────────────────────────── */
.minor {
  margin: 52px 0 16px; font-family: var(--sans); font-weight: 500;
  font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--wash);
}
.accounts { list-style: none; margin: 0; padding: 0; }
.accounts li { padding: 18px 0; border-top: 1px solid var(--hair-soft); }
.accounts li:first-child { border-top: 0; padding-top: 0; }
.acct { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.acct-name { font-family: var(--display); font-size: 22px; color: var(--ink); letter-spacing: -0.01em; font-variation-settings: 'opsz' 24; }
.acct-handle { font-size: 14px; color: var(--wash); }
.acct:hover .acct-handle, .acct:hover .acct-name { color: var(--indigo); }
.accounts p { margin: 6px 0 0; color: var(--ink-2); font-size: 16px; }
.accounts b { color: var(--ink); font-weight: 600; }

.clips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.clip { margin: 0; }
.clip video {
  display: block; width: 100%; height: auto; aspect-ratio: 9 / 16;
  background: var(--ink); border-radius: 3px;
}
.clip figcaption { margin-top: 8px; font-size: 13px; color: var(--wash); }

/* ── Work ───────────────────────────────────────────────────── */
.roles { list-style: none; margin: 0; padding: 0; }
.role {
  display: grid; grid-template-columns: 140px 1fr; gap: 24px;
  padding: 28px 0; border-top: 1px solid var(--hair-soft);
}
.role:first-child { border-top: 0; padding-top: 0; }
.role-when { color: var(--wash); font-size: 14px; padding-top: 8px; font-variant-numeric: tabular-nums; }
.role h3 { font-size: 24px; }
.role h3 a { border-bottom: 1px solid var(--hair); }
.role-title { font-family: var(--sans); font-weight: 400; font-size: 15px; color: var(--wash); margin-left: 8px; }
.role-where { margin: 4px 0 12px; color: var(--wash-light); font-size: 13.5px; }
.role p:last-child { margin: 0; }

/* ── Projects ───────────────────────────────────────────────── */
.projects { display: grid; gap: 44px; }
.project h3 a { border-bottom: 1px solid var(--hair); }
.project .prose { margin-top: 16px; }

/* ── On paper ───────────────────────────────────────────────── */
.facts { margin: 0; display: grid; gap: 0; }
.facts > div {
  display: grid; grid-template-columns: 140px 1fr; gap: 24px;
  padding: 14px 0; border-top: 1px solid var(--hair-soft);
}
.facts > div:first-child { border-top: 0; padding-top: 0; }
.facts dt { color: var(--wash); font-size: 14px; }
.facts dd { margin: 0; color: var(--ink-2); }

/* ── Contact ────────────────────────────────────────────────── */
.links { list-style: none; margin: 28px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px 26px; font-size: 17px; }
.links a { border-bottom: 1px solid var(--hair); padding-bottom: 2px; }

.foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 28px var(--gut) 40px;
  font-size: 13px; color: var(--wash);
  border-top: 1px solid var(--hair-soft);
}
.motion {
  font: inherit; color: var(--wash); background: none; border: 0; padding: 0;
  cursor: pointer; border-bottom: 1px solid var(--hair);
}
.motion:hover { color: var(--ink); }

/* ── Reveal ─────────────────────────────────────────────────── */
.chap .body > *, .portrait { opacity: 0; transform: translateY(14px); transition: opacity 800ms var(--ease), transform 800ms var(--ease); }
.chap.in .body > *, .chap.in .portrait { opacity: 1; transform: none; }
.chap.in .body > :nth-child(2) { transition-delay: 60ms; }
.chap.in .body > :nth-child(3) { transition-delay: 120ms; }
.chap.in .body > :nth-child(4) { transition-delay: 180ms; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1140px) {
  :root { --margin-r: 0px; --margin-l: 96px; }
  .chap { grid-template-columns: var(--margin-l) minmax(0, var(--col)); }
  .sn {
    float: none; clear: none; display: block; width: auto; margin: 10px 0 14px;
    padding-left: 16px; border-left: 1px solid var(--hair);
  }
  .sn::before { left: -4px; display: none; }
  .hero { grid-template-columns: var(--margin-l) minmax(0, 1fr); }
  .portrait { grid-column: 2; grid-row: 2; justify-self: start; margin-top: 36px; width: 200px; }
  .portrait figcaption { text-align: left; }
}
@media (max-width: 760px) {
  :root { --margin-l: 0px; --band: 72px; }
  .top { padding: 14px var(--gut); }
  .nav { display: none; }
  .chap { grid-template-columns: minmax(0, 1fr); }
  .num { position: static; grid-column: 1; font-size: 40px; margin-bottom: 18px; }
  .body { grid-column: 1; }
  .hero { min-height: 0; padding-top: 40px; }
  .hero .body { grid-column: 1; }
  .portrait { grid-column: 1; grid-row: 3; width: 160px; }
  h1 { font-size: clamp(60px, 18vw, 96px); }
  .pipe-steps { grid-template-columns: 1fr; }
  .pipe-steps li { padding: 0 0 18px 26px; }
  .pipe-steps li::before { top: 4px; }
  .pipe-steps li::after { left: 4px; right: auto; top: 13px; bottom: 0; width: 1.2px; height: auto; }
  .pipe-loop { display: none; }
  .clips { grid-template-columns: 1fr; }
  .role, .facts > div { grid-template-columns: 1fr; gap: 6px; }
  .role-when { padding-top: 0; }
}

/* ── Motion preferences ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .chap .body > *, .portrait { opacity: 1; transform: none; transition: none; }
}
