/* ---------- Tokens ---------- */
:root {
  --bg: #faf9f6;
  --bg-tint: #f1efe9;
  --surface: #ffffff;
  --ink: #15171c;
  --ink-2: #4a4f5a;
  --ink-3: #737885;
  --line: #e3e0d8;
  --accent: #0f766e;
  --accent-ink: #0b5f58;
  --accent-soft: #e2f1ef;
  --warn: #9a5b00;
  --warn-soft: #fbefd9;
  --shadow: 0 1px 2px rgba(20, 22, 28, .04), 0 8px 28px -12px rgba(20, 22, 28, .12);
  --radius: 18px;
  --maxw: 1160px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1014;
    --bg-tint: #12161c;
    --surface: #161b22;
    --ink: #ecebe7;
    --ink-2: #b4b8c0;
    --ink-3: #8a909b;
    --line: #262c35;
    --accent: #5fd4c4;
    --accent-ink: #7fe3d5;
    --accent-soft: #123a37;
    --warn: #f3c06b;
    --warn-soft: #3a2c12;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1014;
  --bg-tint: #12161c;
  --surface: #161b22;
  --ink: #ecebe7;
  --ink-2: #b4b8c0;
  --ink-3: #8a909b;
  --line: #262c35;
  --accent: #5fd4c4;
  --accent-ink: #7fe3d5;
  --accent-soft: #123a37;
  --warn: #f3c06b;
  --warn-soft: #3a2c12;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16.5px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .25s ease, color .25s ease;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent-ink); text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.15; margin: 0; letter-spacing: -.01em; }
p { margin: 0; }
em { font-style: italic; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 20px; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 650; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.brand-mark { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.nav { margin-left: auto; display: flex; gap: 4px; }
.nav a { color: var(--ink-2); text-decoration: none; font-size: 14.5px; padding: 6px 12px; border-radius: 999px; transition: background .15s, color .15s; }
.nav a:hover, .nav a.active { color: var(--ink); background: var(--bg-tint); }
.theme-toggle {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer;
  display: grid; place-items: center; flex: none;
  transition: border-color .15s, transform .15s;
}
.theme-toggle:hover { border-color: var(--ink-3); }
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.theme-toggle .icon-moon { fill: currentColor; stroke: none; }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[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-top: 88px; padding-bottom: 72px; }
.eyebrow, .kicker {
  font: 600 12.5px/1.2 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--accent-ink);
}
.hero-title { font: 700 clamp(44px, 7vw, 76px)/1.02 var(--sans); letter-spacing: -.035em; margin-top: 18px; }
.hero-theme {
  font-family: var(--serif); font-size: clamp(24px, 3.3vw, 36px); line-height: 1.28;
  max-width: 24ch; margin-top: 22px; color: var(--ink); letter-spacing: -.005em;
}
.hero-theme em { color: var(--accent-ink); }
.hero-sub { max-width: 60ch; margin-top: 22px; color: var(--ink-2); font-size: 17.5px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 18px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 550; font-size: 15px;
  transition: transform .15s ease, border-color .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-1px); border-color: var(--ink-3); box-shadow: var(--shadow); }
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary:hover { border-color: var(--ink); }
.btn .gh { width: 17px; height: 17px; fill: currentColor; }

.hero-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 56px 0 0;
  border-top: 1px solid var(--line);
}
.stat { padding: 22px 24px 0 0; }
.stat + .stat { padding-left: 24px; border-left: 1px solid var(--line); }
.stat dt { color: var(--ink-3); font-size: 13.5px; line-height: 1.4; }
.stat dd { margin: 8px 0 0; color: var(--ink-2); font-size: 14px; }
.stat .num { display: block; font: 650 26px/1.15 var(--sans); color: var(--ink); letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-bottom: 2px; }

/* ---------- Sections ---------- */
.section { padding-top: 88px; padding-bottom: 88px; }
.section-tint { background: var(--bg-tint); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-head { margin-bottom: 40px; }
.section-head h2 { font: 700 clamp(30px, 4vw, 42px)/1.1 var(--sans); letter-spacing: -.025em; margin-top: 12px; }
.section-lede { color: var(--ink-2); max-width: 62ch; margin-top: 14px; }

/* ---------- Projects ---------- */
.projects { display: grid; gap: 24px; }
.project {
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 36px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px; box-shadow: var(--shadow);
}
.project-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.project-idx {
  font: 600 12px/1 var(--mono); color: var(--accent-ink); background: var(--accent-soft);
  padding: 5px 8px; border-radius: 6px;
}
.project-domain { font-size: 13px; color: var(--ink-3); }
.badge {
  font: 600 11.5px/1 var(--sans); letter-spacing: .06em; text-transform: uppercase;
  color: var(--warn); background: var(--warn-soft); padding: 6px 9px; border-radius: 999px;
}
.project h3 { font: 700 28px/1.1 var(--sans); letter-spacing: -.02em; margin-top: 14px; }
.hook { margin-top: 10px; color: var(--ink-2); font-size: 16.5px; }
.metric { margin-top: 20px; padding: 14px 0 14px 16px; border-left: 3px solid var(--accent); }
.metric-value { display: block; font: 700 36px/1.05 var(--sans); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.metric-label { display: block; margin-top: 6px; font-size: 13.5px; line-height: 1.5; color: var(--ink-3); }
.found { margin-top: 16px; font-size: 15px; color: var(--ink-2); }
.found strong { display: block; color: var(--ink); font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4px; }
.wip { color: var(--warn); font-weight: 600; }
.tags { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { font-size: 12.5px; color: var(--ink-2); border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; background: var(--bg); }
.repo { display: inline-flex; gap: 6px; margin-top: 20px; font-weight: 600; font-size: 15px; text-decoration: none; }
.repo:hover { text-decoration: underline; }
.repo-soon { color: var(--ink-3); font-weight: 500; }
.repo-soon::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); align-self: center; }

.figure {
  display: block; background: #fff; border-radius: 12px; padding: 10px;
  border: 1px solid var(--line); overflow: hidden; cursor: zoom-in;
  transition: transform .2s ease, box-shadow .2s ease;
}
.figure:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.figure img { width: 100%; border-radius: 6px; }
.figure-square { max-width: 420px; justify-self: center; width: 100%; }

/* ---------- Shortcuts ---------- */
.shortcuts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.shortcut {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow);
}
.shortcut-where { font: 600 12px/1.2 var(--mono); color: var(--accent-ink); }
.shortcut h3 { font: 700 21px/1.2 var(--sans); }
.shortcut p { color: var(--ink-2); font-size: 15px; }
.shortcut .caveat { margin-top: auto; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 13.5px; color: var(--ink-3); }
.drops { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 8px; }
.drops li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 12px; background: var(--bg); border-radius: 10px; font-size: 14.5px; color: var(--ink-2); }
.drops b { font: 650 18px/1 var(--sans); color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Methods ---------- */
.methods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.method { background: var(--bg); padding: 24px; }
.method h3 { font: 650 16.5px/1.25 var(--sans); }
.method h3::before { content: ""; display: block; width: 22px; height: 3px; border-radius: 2px; background: var(--accent); margin-bottom: 14px; }
.method p { margin-top: 8px; color: var(--ink-2); font-size: 14.5px; line-height: 1.55; }

/* ---------- Skills / About ---------- */
.about-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 64px; }
.skills { margin: 0; display: grid; gap: 0; }
.skills div { display: grid; grid-template-columns: 140px 1fr; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.skills div:last-child { border-bottom: 1px solid var(--line); }
.skills dt { font-weight: 600; font-size: 14.5px; }
.skills dd { margin: 0; color: var(--ink-2); font-size: 14.5px; }
.about p { color: var(--ink-2); }
.about p + p { margin-top: 14px; }
.ph { background: var(--warn-soft); color: var(--warn); border-radius: 4px; padding: 0 4px; font-size: .95em; }
.links { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 10px; }
.links a, .links span { font-size: 15px; font-weight: 550; }
.ph-link { color: var(--warn); }

/* ---------- Footer ---------- */
.footer { padding: 36px 0 48px; color: var(--ink-3); font-size: 13.5px; }
.footer-inner { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.footer a { color: var(--ink-2); text-decoration: none; }

/* ---------- Motion (subtle, opt-out) ---------- */
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s 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, .figure, body { transition: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .project { grid-template-columns: 1fr; gap: 24px; }
  .shortcuts { grid-template-columns: 1fr; }
  .methods { grid-template-columns: repeat(2, 1fr); }
  .about-grid { grid-template-columns: 1fr; gap: 48px; }
}
@media (max-width: 680px) {
  body { font-size: 16px; }
  .wrap { padding: 0 18px; }
  .nav { display: none; }
  .topbar-inner { justify-content: space-between; }
  .hero { padding-top: 48px; padding-bottom: 52px; }
  .hero-stats { grid-template-columns: 1fr; margin-top: 40px; }
  .stat, .stat + .stat { padding: 18px 0; border-left: 0; }
  .stat + .stat { border-top: 1px solid var(--line); }
  .section { padding-top: 60px; padding-bottom: 60px; }
  .project { padding: 22px; border-radius: 16px; }
  .project h3 { font-size: 25px; }
  .metric-value { font-size: 31px; }
  .figure { padding: 6px; }
  .methods { grid-template-columns: 1fr; }
  .skills div { grid-template-columns: 1fr; gap: 4px; }
}

/* ---------- Small polish ---------- */
.nw { white-space: nowrap; }
.hero-theme { max-width: 28ch; }
.figure { position: relative; }
.figure::after {
  content: "Open full size ↗"; position: absolute; right: 14px; bottom: 14px;
  font: 600 11.5px/1 var(--sans); color: #15171c; background: rgba(255, 255, 255, .92);
  border: 1px solid #e3e0d8; padding: 6px 9px; border-radius: 999px;
  opacity: 0; transition: opacity .2s ease;
}
.figure:hover::after, .figure:focus-visible::after { opacity: 1; }
@media (hover: none) { .figure::after { content: "Tap to enlarge"; opacity: 1; position: static; display: block; text-align: center; margin-top: 6px; border: 0; background: none; color: #737885; font-weight: 500; } }
.repo-links { display: flex; flex-wrap: wrap; gap: 6px 22px; }

/* "Try it live" links to the in-browser demos */
.repo-links .try-live, .try-live {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 20px; padding: 7px 14px; border-radius: 999px;
  background: var(--accent); color: #fff; font-weight: 650; font-size: 14.5px; text-decoration: none;
  transition: transform .15s, box-shadow .15s;
}
:root[data-theme="dark"] .try-live { color: #0d1014; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .try-live { color: #0d1014; } }
.try-live:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.try-live .try-note { font-weight: 500; opacity: .85; }
.repo-links { align-items: center; }
