/* ---------- Fonts (self-hosted, latin subset) ---------- */
@font-face {
  font-family: "Geist";
  src: url("fonts/geist-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("fonts/geist-mono-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("fonts/instrument-serif-italic-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --bg: #f4f3ee;
  --bg-elev: #fbfaf7;
  --ink: #141413;
  --ink-2: #45443f;
  --muted: #6f6e67;
  --line: #dddbd2;
  --line-strong: #c4c2b8;
  --accent: #d7261e;
  --chart-before: #a6a49b;
  --good: #1f9d55;
  --shadow: 0 1px 0 rgb(20 20 19 / 0.03), 0 20px 40px -24px rgb(20 20 19 / 0.25);

  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;

  --gutter: 16px;
  --radius: 20px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f0e;
    --bg-elev: #171715;
    --ink: #f2f0e9;
    --ink-2: #c4c2b9;
    --muted: #8f8d85;
    --line: #2a2926;
    --line-strong: #3d3c37;
    --accent: #ff4d40;
    --chart-before: #5f5e58;
    --good: #3ccf7a;
    --shadow: 0 1px 0 rgb(255 255 255 / 0.03), 0 20px 40px -24px rgb(0 0 0 / 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0f0e;
  --bg-elev: #171715;
  --ink: #f2f0e9;
  --ink-2: #c4c2b9;
  --muted: #8f8d85;
  --line: #2a2926;
  --line-strong: #3d3c37;
  --accent: #ff4d40;
  --chart-before: #5f5e58;
  --good: #3ccf7a;
  --shadow: 0 1px 0 rgb(255 255 255 / 0.03), 0 20px 40px -24px rgb(0 0 0 / 0.6);
  color-scheme: dark;
}

@media (min-width: 720px) {
  :root { --gutter: 40px; }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
}
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  transition: background-color 0.25s ease, color 0.25s ease;
}
img, svg { display: block; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; }
::selection { background: var(--ink); color: var(--bg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.mono { font-family: var(--mono); font-feature-settings: "zero" 0; }
.serif, em.serif {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.01em;
}
.accent { color: var(--accent); }

.container {
  width: min(1160px, 100% - 2 * var(--gutter));
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -100px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 10px;
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease, background-color 0.25s ease;
}
.site-header.scrolled { border-bottom-color: var(--line); }

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 15px;
  color: var(--muted);
  text-decoration: none;
}
.logo b { color: var(--ink); font-weight: 600; }
.logo-mark {
  width: 11px;
  height: 11px;
  background: var(--accent);
  border-radius: 2px;
  transition: transform 0.4s cubic-bezier(.2,.7,.2,1);
}
.logo:hover .logo-mark { transform: rotate(90deg); }

.nav-right { display: flex; align-items: center; gap: 8px; }
.nav-links { display: flex; gap: 4px; }
.nav-links a {
  display: block;
  padding: 8px 12px;
  font-size: 15px;
  color: var(--ink-2);
  text-decoration: none;
  border-radius: 999px;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.nav-links a:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-left: 4px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.3s ease;
}
.theme-toggle:hover { border-color: var(--ink); }
.theme-toggle:active { transform: rotate(20deg); }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

@media (max-width: 479px) {
  .nav-optional { display: none; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  font: 500 15px/1 var(--sans);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--bg)); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--ink); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: clamp(48px, 9vw, 112px) 0 0;
}
.hero::before {
  /* faint measurement grid */
  content: "";
  position: absolute;
  inset: 0 0 30% 0;
  z-index: -1;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: center top;
  opacity: 0.55;
  -webkit-mask-image: radial-gradient(ellipse 70% 80% at 50% 0%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse 70% 80% at 50% 0%, #000 20%, transparent 75%);
  pointer-events: none;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 48px;
}
@media (min-width: 960px) {
  .hero-grid {
    grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
    align-items: center;
    gap: 64px;
  }
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.pulse {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--accent);
  animation: ping 2.4s cubic-bezier(0, 0, 0.2, 1) infinite;
}
@keyframes ping {
  0% { transform: scale(1); opacity: 0.6; }
  80%, 100% { transform: scale(3); opacity: 0; }
}

h1 {
  margin: 22px 0 26px;
  font-size: clamp(3.4rem, 10vw, 6.75rem);
  font-weight: 600;
  line-height: 0.92;
  letter-spacing: -0.05em;
}
.lead {
  max-width: 34ch;
  font-size: clamp(1.15rem, 2.1vw, 1.45rem);
  line-height: 1.5;
  color: var(--ink-2);
  text-wrap: pretty;
}
.lead em.serif { color: var(--ink); font-size: 1.18em; line-height: 1; }

.cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 36px; }

/* ---------- Hero chart ---------- */
.chart-card {
  margin: 0;
  padding: 20px 20px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  font-size: 12px;
  color: var(--muted);
}
.tag {
  padding: 2px 9px;
  font-size: 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
}

.chart {
  position: relative;
  height: clamp(200px, 28vw, 250px);
  padding: 22px 6px 22px 0;
}
.plot {
  position: relative;
  height: 100%;
  border-bottom: 1px solid var(--line-strong);
  background-image: linear-gradient(var(--line) 1px, transparent 1px);
  background-size: 100% 25%;
}
.plot svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.line.before { stroke: var(--chart-before); }
.line.after { stroke: var(--ink); }
.area { fill: var(--ink); opacity: 0.06; }

.marker {
  position: absolute;
  top: -14px;
  bottom: 0;
  left: var(--change-x, 60%);
  border-left: 1.5px dashed var(--accent);
  opacity: 0;
}
.marker span {
  position: absolute;
  top: -8px;
  left: 8px;
  font-size: 11px;
  color: var(--ink-2);
  white-space: nowrap;
}
.chart-dot {
  position: absolute;
  left: 100%;
  top: var(--end-y, 75%);
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 2px var(--bg-elev);
  opacity: 0;
}
.chart-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--ink);
  animation: ping 2.4s cubic-bezier(0, 0, 0.2, 1) infinite;
}
.axis { position: absolute; font-size: 11px; color: var(--muted); }
.axis-y { top: 0; left: 0; }
.axis-x { bottom: 0; right: 6px; }

/* Draw-in: wipe the series left to right, then bring in annotations. */
.js .chart .plot svg { clip-path: inset(0 100% 0 0); }
.js .chart.ready .plot svg { animation: wipe 1.8s cubic-bezier(.45,.05,.25,1) 0.2s forwards; }
.js .chart.ready .marker { animation: fade 0.5s ease 1.3s forwards; }
.js .chart.ready .chart-dot { animation: fade 0.4s ease 1.95s forwards; }
html:not(.js) .marker, html:not(.js) .chart-dot { opacity: 1; }
@keyframes wipe { to { clip-path: inset(0 0 0 0); } }
@keyframes fade { to { opacity: 1; } }

.chart-card figcaption {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-top: clamp(56px, 8vw, 96px);
  background: var(--line);
  border-block: 1px solid var(--line);
}
@media (min-width: 820px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.stat {
  padding: 28px 20px 28px 0;
  background: var(--bg);
  transition: background-color 0.25s ease;
}
.stat:nth-child(2n) { padding-left: 20px; }
@media (min-width: 820px) {
  .stat, .stat:nth-child(2n) { padding: 32px 24px; }
  .stat:first-child { padding-left: 0; }
}
.stat-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: clamp(2.2rem, 4.6vw, 3.1rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.04em;
}
.stat-value small {
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--muted);
}
.stat-label {
  margin-top: 12px;
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--muted);
  max-width: 24ch;
}

/* ---------- Sections ---------- */
.section {
  padding: clamp(80px, 11vw, 136px) 0;
}
.section + .section { border-top: 1px solid var(--line); }

.section-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}
@media (min-width: 960px) {
  .section-grid { grid-template-columns: 200px minmax(0, 1fr); gap: 56px; }
  .section-label { position: sticky; top: 104px; align-self: start; }
}
.section-label {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.section-label .idx {
  color: var(--ink);
  padding: 3px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  letter-spacing: 0;
}

h2 {
  max-width: 20ch;
  margin-bottom: 28px;
  font-size: clamp(2.1rem, 5vw, 3.5rem);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.04em;
  text-wrap: balance;
}
h2 em.serif { font-size: 1.08em; }

.prose { max-width: 62ch; }
.prose p {
  font-size: 1.12rem;
  line-height: 1.65;
  color: var(--ink-2);
  text-wrap: pretty;
}
.prose p + p { margin-top: 1.1em; }

/* About chips */
.chips-block { margin-top: 44px; }
.chips-title {
  margin-bottom: 14px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 14px;
  font-size: 13px;
  color: var(--ink-2);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
}

/* Approach steps */
.steps {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1px;
  margin-top: 44px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
@media (min-width: 640px) {
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.step {
  position: relative;
  padding: 28px 26px 30px;
  background: var(--bg-elev);
  transition: background-color 0.25s ease;
}
.step::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width 0.5s cubic-bezier(.2,.7,.2,1);
}
.step:hover::before { width: 100%; }
.step-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
  color: var(--ink);
}
.step-idx { font-size: 12px; color: var(--muted); }
.step h3 {
  margin-bottom: 8px;
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.step p { font-size: 15.5px; line-height: 1.55; color: var(--muted); }
.loop-note { margin-top: 20px; font-size: 13px; color: var(--muted); }

/* ---------- Work ---------- */
.projects { display: grid; gap: 16px; margin-top: 44px; }

.project {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.35s cubic-bezier(.2,.7,.2,1), border-color 0.2s ease;
}
.project:hover { transform: translateY(-3px); border-color: var(--line-strong); }
@media (min-width: 760px) {
  .project { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
}

.project-visual {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 260px;
  padding: 24px 26px;
  overflow: hidden;
  color: #f3efe6;
  background-color: #0b0a09;
  isolation: isolate;
}
.project-visual::before {
  /* a field of individuals */
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(circle, rgb(243 239 230 / 0.32) 1.1px, transparent 1.6px);
  background-size: 11px 11px;
  -webkit-mask-image: linear-gradient(160deg, #000 10%, transparent 85%);
  mask-image: linear-gradient(160deg, #000 10%, transparent 85%);
  transition: transform 6s linear;
}
.project:hover .project-visual::before { transform: translate3d(-11px, -11px, 0); }
.one-dot {
  position: absolute;
  top: 38%;
  left: 58%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f7b267;
  box-shadow: 0 0 0 4px rgb(247 178 103 / 0.18), 0 0 24px 4px rgb(247 178 103 / 0.35);
}
.one-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #f7b267;
  animation: ping 2.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}
.project-url { font-size: 12px; color: rgb(243 239 230 / 0.65); }
.project-wordmark {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(3.4rem, 7vw, 4.6rem);
  line-height: 1;
  letter-spacing: -0.01em;
}

.project-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 26px 26px 28px;
}
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.project-body h3 { font-size: 1.6rem; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; }
.project-tagline { font-family: var(--serif); font-style: italic; font-size: 1.3rem; line-height: 1.3; color: var(--ink); }
.project-desc { font-size: 15.5px; line-height: 1.6; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags li {
  padding: 3px 10px;
  font-size: 12px;
  color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.project-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
  font-weight: 500;
  font-size: 15px;
}
.project-link svg { transition: transform 0.25s ease; }
.project:hover .project-link svg { transform: translate(3px, -3px); }

.project-soon {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 24px 26px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}
.soon-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.soon-text { font-size: 1.05rem; color: var(--ink-2); }
.cursor { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.caret {
  width: 8px;
  height: 16px;
  background: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Contact ---------- */
.contact-title { max-width: 18ch; font-size: clamp(2.3rem, 6vw, 4.25rem); }
.contact-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 36px; }
.contact-row .btn-primary { font-family: var(--mono); font-weight: 500; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); }
.footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  padding: 28px 0 36px;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- 404 ---------- */
.nf { min-height: 100svh; display: grid; place-items: center; padding: 48px 0; }
.nf-req { margin-bottom: 20px; font-size: 13px; color: var(--muted); word-break: break-all; }
.nf-req b { color: var(--accent); font-weight: 500; }
.nf h1 { margin: 0 0 20px; }
.nf .lead { margin-bottom: 32px; }

/* ---------- Reveal ---------- */
.js .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.8s cubic-bezier(.2,.7,.2,1), transform 0.8s cubic-bezier(.2,.7,.2,1);
}
.js .reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
  .js .reveal { transform: none; }
}
