/* ===== Self-hosted font — no external requests (Inter variable, latin subset) ===== */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/inter.woff2") format("woff2");
}

/* ===== Tokens ===== */
:root {
  --bg: #FCFCFA;
  --bg-elev: rgba(252, 252, 250, 0.82);
  --text: #1C1C1A;
  --muted: #6E6E66;
  --line: rgba(28, 28, 26, 0.12);
  --accent: #FFD000;            /* duck yellow */
  --accent-ink: #8A6D00;
  --accent-soft: rgba(255, 208, 0, 0.16);
  --mark: #FFD000;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #111113;
  --bg-elev: rgba(17, 17, 19, 0.80);
  --text: #ECECE6;
  --muted: #98988E;
  --line: rgba(236, 236, 230, 0.14);
  --accent: #FFD45E;
  --accent-ink: #FFD45E;
  --accent-soft: rgba(255, 212, 94, 0.12);
  --mark: rgba(255, 212, 94, 0.38);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111113;
    --bg-elev: rgba(17, 17, 19, 0.80);
    --text: #ECECE6;
    --muted: #98988E;
    --line: rgba(236, 236, 230, 0.14);
    --accent: #FFD45E;
    --accent-ink: #FFD45E;
    --accent-soft: rgba(255, 212, 94, 0.12);
    --mark: rgba(255, 212, 94, 0.38);
    color-scheme: dark;
  }
}

/* ===== Base ===== */
* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1.03rem;
  line-height: 1.68;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.25s ease, color 0.25s ease;
}

::selection { background: var(--accent-soft); }

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  transition: background-color 0.15s ease;
}
a:hover { background: var(--accent-soft); }

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 3px;
  border-radius: 2px;
}

h1, h2, h3 { margin: 0 0 0.75rem; line-height: 1.2; letter-spacing: -0.015em; }
p { margin: 0 0 1rem; }

main > section, .hero, .footer-inner {
  width: min(100% - 2.75rem, 44rem);
  margin-inline: auto;
}

.mono {
  font-family: var(--mono);
  font-size: 0.8em;
  letter-spacing: 0.02em;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin: 0 0 1.1rem;
}

/* ===== Nav ===== */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: var(--bg-elev);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s ease;
}
.site-nav.scrolled { border-bottom-color: var(--line); }

.nav-inner {
  width: min(100% - 2.75rem, 44rem);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.4rem;
}

.brand {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
}
.brand:hover { background: none; }
.brand .dot { color: var(--accent-ink); }

.site-nav nav {
  display: flex;
  align-items: center;
  gap: 1.15rem;
}

.site-nav nav a {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-decoration: none;
}
.site-nav nav a:hover { color: var(--text); background: none; }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover { color: var(--text); border-color: var(--muted); }

.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

/* ===== Hero ===== */
.hero { padding: clamp(4rem, 12vh, 7rem) 0 clamp(2.5rem, 6vh, 4rem); }

.hero h1 {
  font-size: clamp(2rem, 6vw, 3.15rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 1.4rem;
  text-wrap: balance;
}

.hero h1 em {
  font-style: normal;
  background: linear-gradient(transparent 72%, var(--mark) 72%, var(--mark) 94%, transparent 94%);
}

.lead { color: var(--muted); max-width: 38rem; }
.lead a { color: var(--text); }
.lead strong, .cards strong { color: var(--text); font-weight: 600; }

.stats {
  color: var(--muted);
  font-size: 0.78rem;
  margin: 1.6rem 0 1.9rem;
}

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.btn {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  text-decoration: none;
  padding: 0.55rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}
.btn:hover { border-color: var(--muted); background: none; transform: translateY(-1px); }

.btn.primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.btn.primary:hover { background: var(--text); opacity: 0.88; }

/* ===== Sections ===== */
main > section {
  padding: clamp(2.8rem, 7vh, 4.5rem) 0;
  border-top: 1px solid var(--line);
}

section h2 {
  font-size: 1.45rem;
  font-weight: 650;
  margin-bottom: 1.6rem;
}

.section-intro { color: var(--muted); max-width: 38rem; }

/* Cards (Lab) */
.cards {
  list-style: none;
  margin: 1.7rem 0 0;
  padding: 0;
  display: grid;
  gap: 1.9rem;
}

.cards h3 { font-size: 1.02rem; font-weight: 600; margin-bottom: 0.35rem; }
.cards p { color: var(--muted); margin: 0; max-width: 38rem; }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.card-head h3 { margin: 0 0 0.35rem; }

.bench {
  margin-top: 2.2rem;
  padding-top: 1.4rem;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 40rem;
}
.bench .mono {
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
}

/* Work list */
.work-list {
  list-style: none;
  margin: 1.7rem 0 0;
  padding: 0;
}

.work-list li {
  padding: 1.15rem 0;
  border-bottom: 1px solid var(--line);
}
.work-list li:last-child { border-bottom: none; }

.work-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.work-head h3 { font-size: 1.02rem; font-weight: 600; margin: 0; }

.meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}

.work-list p { color: var(--muted); margin: 0.4rem 0 0; max-width: 38rem; }

/* Timeline */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1.6rem;
}

.timeline li {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 1rem;
}

.timeline .when {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding-top: 0.2rem;
  white-space: nowrap;
}

.timeline h3 { font-size: 0.98rem; font-weight: 600; margin-bottom: 0.25rem; }
.timeline p { color: var(--muted); margin: 0; font-size: 0.95rem; }

.edu {
  margin-top: 2.2rem;
  padding-top: 1.4rem;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 0.95rem;
}
.edu .mono {
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
}

/* Toolbox */
.toolbox-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.7rem 2.5rem;
}

.toolbox-grid h3 {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.toolbox-grid p { margin: 0; font-size: 0.95rem; }

/* ===== Footer ===== */
footer {
  border-top: 1px solid var(--line);
  background: linear-gradient(var(--accent-soft), transparent 65%);
}

.footer-inner { padding: clamp(2.8rem, 7vh, 4.5rem) 0 2rem; }

footer h2 { font-size: clamp(1.6rem, 4.5vw, 2.2rem); font-weight: 700; }

.email {
  font-size: clamp(1.05rem, 3.4vw, 1.45rem);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.footer-links { display: flex; gap: 1.4rem; margin: 1.6rem 0 3rem; font-size: 0.78rem; }

.small {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  border-top: 1px solid var(--line);
  padding-top: 1.3rem;
  margin: 0;
}

/* ===== Article ===== */
.article {
  width: min(100% - 2.75rem, 42rem);
  margin-inline: auto;
  padding: clamp(3rem, 9vh, 5rem) 0 clamp(2.5rem, 6vh, 4rem);
}

.article h1 {
  font-size: clamp(1.7rem, 4.6vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.022em;
  margin: 0.6rem 0 1.1rem;
  text-wrap: balance;
}

.article .lede {
  font-size: 1.12rem;
  line-height: 1.55;
  color: var(--muted);
  margin-bottom: 1.2rem;
  text-wrap: pretty;
}

.article .art-meta {
  color: var(--muted);
  font-size: 0.74rem;
  margin-bottom: 2.5rem;
  padding-bottom: 1.6rem;
  border-bottom: 1px solid var(--line);
}

.article h2 {
  font-size: 1.28rem;
  font-weight: 650;
  margin: 2.6rem 0 0.9rem;
}

.article h3 { font-size: 1.02rem; font-weight: 600; margin: 1.8rem 0 0.6rem; }

.article p, .article li { text-wrap: pretty; }

.article .wip {
  font-size: 0.88rem;
  color: var(--muted);
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 0.7rem 0.95rem;
  margin: -1.2rem 0 2.4rem;
}

.article .art-note {
  border-left: 2px solid var(--accent);
  padding-left: 1rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
  margin: 0 0 2.4rem;
}

.article .ref {
  font-family: var(--mono);
  font-size: 0.72em;
  vertical-align: super;
  line-height: 0;
  text-decoration: none;
  color: var(--accent-ink);
}
.article .ref:hover { background: var(--accent-soft); }

.table-wrap { overflow-x: auto; margin: 1.4rem 0; }

.article table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
}
.article th, .article td {
  text-align: left;
  padding: 0.55rem 0.9rem 0.55rem 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.article th {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.article td:nth-child(2), .article td:nth-child(3),
.article th:nth-child(2), .article th:nth-child(3) { text-align: right; padding-right: 0; }
.article td:nth-child(2), .article td:nth-child(3) { font-family: var(--mono); font-size: 0.84rem; }

.article .sources {
  font-size: 0.84rem;
  color: var(--muted);
  padding-left: 1.2rem;
  display: grid;
  gap: 0.55rem;
}
.article .sources a { overflow-wrap: anywhere; }

.article .notes { color: var(--muted); font-size: 0.93rem; }
.article .notes li { margin-bottom: 0.5rem; }

.back-home {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.78rem;
  margin-top: 3rem;
}

/* ===== Reveal ===== */
.js .reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.js .reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .btn:hover { transform: none; }
}

/* ===== Small screens ===== */
@media (max-width: 540px) {
  .hide-s { display: none; }
  .timeline li { grid-template-columns: 1fr; gap: 0.15rem; }
  .toolbox-grid { grid-template-columns: 1fr; }
  .work-head { flex-direction: column; gap: 0.1rem; }
  .site-nav nav { gap: 0.9rem; }
}
