/* Steven Ning · personal site
   One idea: the page is a marathon. Sections sit at real race markers,
   and a course line along the top fills as you scroll. Everything else stays calm. */

:root {
  --paper: #f5efe4;
  --paper-2: #ece4d5;
  --ink: #1d1a16;
  --ink-2: #4f483e;
  --muted: #7a7062;
  --line: #d9cfbd;
  --accent: #d9481f;      /* race bib orange */
  --accent-ink: #b23a17;  /* readable on paper */
  --on-accent: #fff8ee;
  --glow: rgba(217, 72, 31, 0.12);

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Figtree", "Helvetica Neue", Arial, system-ui, sans-serif;
  --nav: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --max: 1080px;
  --gutter: clamp(16px, 5vw, 56px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #16130f;
    --paper-2: #201c17;
    --ink: #f2eadc;
    --ink-2: #cfc4b2;
    --muted: #9b907f;
    --line: #3a332a;
    --accent: #f06a3f;
    --accent-ink: #ff8a62;
    --on-accent: #1a0d07;
    --glow: rgba(240, 106, 63, 0.14);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #16130f; --paper-2: #201c17; --ink: #f2eadc; --ink-2: #cfc4b2;
  --muted: #9b907f; --line: #3a332a; --accent: #f06a3f; --accent-ink: #ff8a62;
  --on-accent: #1a0d07; --glow: rgba(240, 106, 63, 0.14); color-scheme: dark;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.09375rem;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--accent-ink); }
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.1; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }

.skip {
  position: absolute; left: 12px; top: -100px; z-index: 100;
  background: var(--ink); color: var(--paper);
  padding: 10px 16px; border-radius: 8px; text-decoration: none; font-weight: 500;
}
.skip:focus { top: 12px; }

/* ---------- The course line ---------- */
.course {
  position: fixed; top: 0; left: 0; right: 0; height: 4px; z-index: 40;
  background: var(--line);
}
.course-fill {
  height: 100%; width: 0;
  background: var(--accent);
  transform-origin: left;
}
.course-ticks { position: absolute; inset: 0; }
.course-ticks span {
  position: absolute; top: 0; width: 2px; height: 9px; margin-left: -1px;
  background: var(--ink-2); opacity: 0.55; border-radius: 0 0 2px 2px;
}
.course-ticks span.passed { background: var(--accent); opacity: 1; }

.odometer {
  position: fixed; right: 16px; bottom: 16px; z-index: 40;
  font-family: var(--mono); font-size: 0.8125rem; font-variant-numeric: tabular-nums;
  background: var(--ink); color: var(--paper);
  padding: 7px 12px 7px 11px; border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  display: flex; align-items: baseline; gap: 0;
}
.odometer::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); align-self: center; margin-right: 7px;
}
.odo-of { opacity: 0.6; }
.odometer.done { background: var(--accent); color: var(--on-accent); }
.odometer.done::before { background: var(--on-accent); }

/* ---------- Header ---------- */
.top {
  position: sticky; top: 0; z-index: 30;
  background: var(--paper);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}
.top.stuck { border-bottom-color: var(--line); }
.top-inner {
  max-width: var(--max); margin: 0 auto;
  padding: 14px var(--gutter) 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.name {
  font-family: var(--serif); font-weight: 700; font-size: 1.1875rem;
  text-decoration: none; white-space: nowrap;
}
.top nav ul {
  list-style: none; margin: 0; padding: 0;
  display: flex; gap: 4px; position: relative;
}
.top nav a {
  display: block;
  font-family: var(--nav);
  font-weight: 600;
  font-size: 0.96875rem;
  letter-spacing: 0.015em;
  font-variation-settings: "opsz" 14;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
  padding: 7px 13px;
  border-radius: 999px;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.12s ease;
}
.top nav a:hover {
  background: var(--paper-2);
  color: var(--accent-ink);
}
.top nav a:active { transform: scale(0.96); }
.top nav a[aria-current="true"] {
  background: var(--ink);
  color: var(--paper);
}
.top nav a[aria-current="true"]:hover { background: var(--accent); color: var(--on-accent); }

/* ---------- Sections ---------- */
main { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }

section {
  padding: clamp(72px, 11vw, 128px) 0 0;
}
section + section { border-top: 0; }

.marker {
  font-family: var(--mono); font-size: 0.8125rem; letter-spacing: 0.02em;
  color: var(--muted);
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 18px;
}
.marker .m-num {
  color: var(--accent-ink); font-weight: 500; font-variant-numeric: tabular-nums;
}
.marker::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}
.marker .m-name { text-transform: uppercase; letter-spacing: 0.08em; }

h2 {
  font-size: clamp(2rem, 4.6vw, 3.25rem);
  margin-bottom: clamp(28px, 4vw, 48px);
}

.prose p + p { margin-top: 1em; }
.prose { color: var(--ink-2); max-width: 62ch; }
.prose strong { color: var(--ink); font-weight: 600; }

.links { display: flex; flex-wrap: wrap; gap: 10px 24px; margin-top: 22px; font-weight: 500; }
.links a {
  text-decoration: none;
  border-bottom: 1.5px solid var(--accent);
  padding-bottom: 2px;
}
.links a::after { content: " →"; color: var(--accent-ink); }
.links a[download]::after { content: " ↓"; }

/* ---------- Hero ---------- */
.hero { padding-top: clamp(64px, 14vh, 160px); min-height: min(88vh, 860px); }
.hero h1 {
  font-size: clamp(3.4rem, 13vw, 9.5rem);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 0.95;
  margin: 8px 0 clamp(28px, 4vw, 44px);
  font-variation-settings: "opsz" 144;
}
.hero h1 .wave { font-style: italic; font-weight: 400; color: var(--accent-ink); }
.lede {
  font-size: clamp(1.125rem, 2vw, 1.375rem);
  line-height: 1.55;
  max-width: 40ch;
  color: var(--ink-2);
}
.hero .lede { max-width: 46ch; }
.status {
  margin-top: 28px;
  display: inline-flex; align-items: flex-start; gap: 10px;
  font-size: 0.9375rem; color: var(--ink);
  background: var(--paper-2); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 14px;
}
.status .dot {
  flex: none; width: 8px; height: 8px; margin-top: 0.55em; border-radius: 50%;
  background: #3a9a5b; box-shadow: 0 0 0 4px rgba(58,154,91,0.18);
}
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 26px; margin-top: 34px; }
.btn {
  display: inline-block;
  background: var(--ink); color: var(--paper);
  padding: 13px 22px; border-radius: 999px;
  text-decoration: none; font-weight: 500;
  transition: background 0.2s ease, transform 0.2s ease;
}
.btn:hover { background: var(--accent); color: var(--on-accent); transform: translateY(-1px); }
.quiet { font-weight: 500; color: var(--ink-2); }

/* ---------- About ---------- */
.split {
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(28px, 6vw, 80px); align-items: start;
}
.pull { margin: 0; padding: 0; position: relative; }
.pull p {
  font-family: var(--serif); font-style: italic; font-weight: 400;
  font-size: clamp(1.5rem, 2.8vw, 2.125rem); line-height: 1.25;
  color: var(--ink);
}
.pull p::before {
  content: "“"; display: block; font-style: normal; color: var(--accent);
  font-size: 4rem; line-height: 0.6; margin-bottom: 12px;
}

/* ---------- Work rows ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid; grid-template-columns: 200px minmax(0, 1fr);
  gap: 8px 40px;
  padding: 32px 0;
  border-top: 1px solid var(--line);
}
.row:last-child { border-bottom: 1px solid var(--line); }
.row-meta { font-family: var(--mono); font-size: 0.8125rem; color: var(--muted); padding-top: 6px; }
.row-meta p:first-child { color: var(--ink); }
.row h3 { font-size: clamp(1.5rem, 2.6vw, 1.875rem); }
.role { color: var(--accent-ink); font-weight: 500; margin: 6px 0 14px; }
.points { margin: 0; padding: 0; list-style: none; color: var(--ink-2); max-width: 66ch; }
.points li { position: relative; padding-left: 22px; }
.points li + li { margin-top: 12px; }
.points li::before {
  content: ""; position: absolute; left: 3px; top: 0.62em;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}

/* ---------- Projects ---------- */
.project {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 20px clamp(28px, 6vw, 80px);
  padding: clamp(36px, 5vw, 56px) 0;
  border-top: 1px solid var(--line);
}
.project:last-child { border-bottom: 1px solid var(--line); }
.project-head { grid-row: span 2; }
.project-kicker {
  font-family: var(--mono); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin-bottom: 12px;
}
.project h3 { font-size: clamp(2.25rem, 5vw, 3.5rem); letter-spacing: -0.025em; }
.project h3 a { text-decoration: none; }
.project h3 .arrow {
  display: inline-block; font-family: var(--sans); font-weight: 400;
  font-size: 0.5em; margin-left: 0.25em; vertical-align: 0.6em;
  color: var(--accent-ink); transition: transform 0.2s ease;
}
.project h3 a:hover .arrow { transform: translate(3px, -3px); }
.project-tag {
  margin-top: 14px; font-family: var(--serif); font-size: 1.1875rem; line-height: 1.4;
  color: var(--ink); max-width: 30ch;
}
.honest {
  border-left: 3px solid var(--accent);
  background: var(--glow);
  padding: 14px 18px; border-radius: 0 10px 10px 0;
}
.project-foot { grid-column: 2; }
.tools { font-family: var(--mono); font-size: 0.8125rem; color: var(--muted); }
.project-foot .links { margin-top: 14px; }

/* ---------- Research ---------- */
.paper {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: clamp(24px, 5vw, 56px);
}
.paper-venue { font-family: var(--mono); font-size: 0.8125rem; color: var(--accent-ink); margin-bottom: 14px; }
.paper h3 {
  font-size: clamp(1.5rem, 3.2vw, 2.25rem); font-weight: 600; line-height: 1.18;
  max-width: 28ch;
}
.paper-authors { margin: 14px 0 28px; color: var(--muted); }
.paper-authors strong { color: var(--ink); font-weight: 600; }
.facts {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px; margin: 36px 0;
}
.facts div {
  border-top: 2px solid var(--accent);
  padding-top: 14px;
}
.facts dt {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(1.75rem, 3.4vw, 2.5rem); line-height: 1.05; letter-spacing: -0.02em;
}
.facts dd { margin: 8px 0 0; color: var(--ink-2); font-size: 1rem; line-height: 1.55; }
.takeaway { color: var(--ink-2); }

/* ---------- Off the clock ---------- */
.life {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 0 clamp(28px, 4vw, 56px);
}
.life li { padding: 24px 0; border-top: 1px solid var(--line); }
.life h3 {
  font-size: 1.375rem; margin-bottom: 8px;
  display: flex; align-items: center; gap: 10px;
}
.life h3::before {
  content: ""; width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--accent);
}
.life p { color: var(--ink-2); }

/* ---------- Finish ---------- */
.finish { padding-bottom: clamp(80px, 12vw, 140px); }
.finish h2 { max-width: 16ch; }
.finish .marker .m-name { color: var(--accent-ink); }
.mail {
  margin-top: 30px;
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(1.5rem, 5.4vw, 3.25rem); letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.mail a {
  text-decoration: none;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 100% 3px; background-repeat: no-repeat; background-position: 0 100%;
  padding-bottom: 4px;
  transition: background-size 0.25s ease, color 0.2s ease;
}
.mail a:hover { color: var(--accent-ink); background-size: 100% 6px; }

.foot {
  max-width: var(--max); margin: 0 auto;
  padding: 28px var(--gutter) 88px;
  border-top: 1px solid var(--line);
  font-size: 0.875rem; color: var(--muted);
}

/* ---------- Gentle reveal (skipped for reduced motion) ---------- */
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.6s ease, transform 0.6s ease; }
.js .reveal.in { opacity: 1; transform: none; }

/* ---------- Small screens ---------- */
@media (max-width: 820px) {
  .top-inner { padding: 10px 0 10px var(--gutter); gap: 14px; }
  .top nav { flex: 1; min-width: 0; }
  .top nav ul {
    overflow-x: auto; scrollbar-width: none;
    padding-right: 64px;
    -webkit-mask-image: linear-gradient(to right, #000 85%, transparent);
            mask-image: linear-gradient(to right, #000 85%, transparent);
  }
  .top nav ul::-webkit-scrollbar { display: none; }
  .split, .project, .row { grid-template-columns: minmax(0, 1fr); }
  .project-head { grid-row: auto; }
  .project-foot { grid-column: auto; }
  .row { gap: 4px; padding: 26px 0; }
  .row-meta { display: flex; gap: 14px; padding-top: 0; margin-bottom: 4px; }
  .facts { grid-template-columns: minmax(0, 1fr); gap: 20px; margin: 28px 0; }
  .hero { min-height: auto; padding-top: 56px; }
}
@media (max-width: 480px) {
  .odometer { right: 10px; bottom: 10px; font-size: 0.6875rem; padding: 5px 9px; opacity: 0.92; }
  .odo-of { display: none; }
  .name { display: none; }
  .top-inner { padding-left: 10px; }
  .top nav a { font-size: 0.9375rem; padding: 7px 12px; }
  body { font-size: 1.03125rem; line-height: 1.7; }
  .status { border-radius: 12px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}

@media print {
  .course, .odometer, .skip, .top nav { display: none; }
  body { background: #fff; color: #000; }
}
