/* ---------- Design tokens ---------- */
:root {
  --bg: #f8f7f3;
  --surface: #ffffff;
  --surface-2: #f1f0ea;
  --text: #15171c;
  --muted: #5a606c;
  --border: #e3e1d9;
  --accent: #2448c4;
  --accent-soft: #e6ebfb;
  --accent-text: #ffffff;
  --live: #1f9d55;
  --highlight: #f5e14a;
  --highlight-text: #15171c;

  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: "Space Grotesk", var(--font-body);
  --font-serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --radius: 14px;
  --maxw: 1200px;
  --gutter: clamp(16px, 4vw, 40px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #161920;
    --surface-2: #1c2029;
    --text: #e9eaee;
    --muted: #9aa1ae;
    --border: #262b35;
    --accent: #7c9cff;
    --accent-soft: #1b2340;
    --accent-text: #0f1115;
    --live: #3ccf7e;
    --highlight: #e8d43a;
    --highlight-text: #0f1115;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #161920;
  --surface-2: #1c2029;
  --text: #e9eaee;
  --muted: #9aa1ae;
  --border: #262b35;
  --accent: #7c9cff;
  --accent-soft: #1b2340;
  --accent-text: #0f1115;
  --live: #3ccf7e;
  --highlight: #e8d43a;
  --highlight-text: #0f1115;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3 { font-family: var(--font-head); line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
strong { font-weight: 600; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.muted { color: var(--muted); }

.skip-link { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-text); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }

/* ---------- Header / nav ---------- */
.site-header {
  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;
}
.site-header.scrolled { border-bottom-color: var(--border); }
.nav { display: flex; align-items: center; gap: 20px; height: 64px; }
.brand { font-family: var(--font-head); font-weight: 700; font-size: 1.35rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-dot { color: var(--accent); }
.nav-links { display: none; gap: 4px; list-style: none; margin: 0; padding: 0; }
.nav-links a { display: block; padding: 6px 10px; border-radius: 8px; color: var(--muted); font-size: .92rem; font-weight: 500; }
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--surface-2); text-decoration: none; }
.clock { margin: 0 0 0 auto; font-family: var(--font-mono); font-size: .8rem; color: var(--muted); letter-spacing: .04em; }
.clock time { color: var(--text); }

.theme-toggle {
  display: grid; place-items: center; width: 38px; height: 38px; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer;
}
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
}

/* ---------- Hero ---------- */
.hero { padding-top: clamp(24px, 5vh, 48px); padding-bottom: clamp(48px, 8vh, 88px); }

/* Mono spec strip */
.spec {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 24px;
  margin: 0 0 clamp(40px, 9vh, 96px); padding-bottom: 20px; border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: .78rem; line-height: 1.6;
}
.spec dt { display: flex; align-items: center; gap: 8px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; }
.spec dt::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.spec dd { margin: 0; color: var(--text); }
.spec a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
.spec a:hover { color: var(--accent); text-decoration-color: currentColor; }

/* Oversized name: sans first name, italic serif last name */
.wordmark {
  display: flex; flex-wrap: wrap; align-items: baseline; column-gap: .18em;
  margin: 0 0 clamp(28px, 5vh, 48px);
  font-size: clamp(3.4rem, 15.5vw, 13rem); line-height: .95; letter-spacing: -0.045em; font-weight: 700;
}
.wm-last { font-family: var(--font-serif); font-style: italic; font-weight: 400; letter-spacing: -0.02em; color: var(--accent); }

.hero-foot { display: grid; grid-template-columns: 1.2fr 1fr; gap: 32px; align-items: end; }
.lead { font-size: clamp(1.15rem, 2.2vw, 1.45rem); line-height: 1.45; color: var(--text); max-width: 32ch; margin: 0; }
.hero-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 16px; }

.status {
  display: inline-flex; align-items: center; gap: 10px; margin: 0;
  font-family: var(--font-mono); font-size: .8rem; color: var(--muted);
}
.status-dot { flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; background: var(--live); animation: pulse 2.4s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 60%, transparent); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.cta { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 11px 20px; border-radius: 999px; font-weight: 500; font-size: .95rem;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: transform .15s, border-color .15s, background .15s;
  max-width: 100%; overflow-wrap: anywhere;
}
.btn:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.btn-primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* ---------- Body layout: sticky sidebar ---------- */
.layout { display: grid; grid-template-columns: 220px 1fr; gap: clamp(32px, 6vw, 96px); }
.sidebar { position: relative; }
.side-nav {
  position: sticky; top: 96px;
  list-style: none; margin: 0; padding: clamp(48px, 8vh, 80px) 0 0;
}
.side-nav a {
  display: flex; align-items: center; gap: 12px; padding: 7px 0;
  color: var(--muted); font-size: .92rem; font-weight: 500;
}
.side-nav a span { font-family: var(--font-mono); font-size: .72rem; }
.side-nav a::after {
  content: ""; order: -1; width: 16px; height: 1px; background: currentColor;
  transition: width .25s ease;
}
.side-nav a:hover, .side-nav a.active { color: var(--text); text-decoration: none; }
.side-nav a.active::after, .side-nav a:hover::after { width: 40px; }
.side-nav a.active span { color: var(--accent); }

.content { min-width: 0; }

/* ---------- Sections ---------- */
.section { padding-block: clamp(48px, 8vh, 80px); border-top: 1px solid var(--border); }
.section-title { display: flex; align-items: baseline; gap: 14px; font-size: clamp(1.6rem, 3.5vw, 2.2rem); margin-bottom: 32px; }
.section-title span { font-family: var(--font-mono); font-size: .85rem; font-weight: 400; color: var(--accent); }

.prose { max-width: 62ch; }
.prose p { font-size: 1.05rem; }

/* Stats row */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  list-style: none; margin: 36px 0 0; padding: 0;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.stats li { padding: 20px 16px 20px 0; }
.stats li + li { padding-left: 16px; border-left: 1px solid var(--border); }
.stats strong { display: block; font-family: var(--font-head); font-size: clamp(2rem, 4vw, 2.8rem); font-weight: 600; line-height: 1; letter-spacing: -0.03em; }
.stats small { font-size: .4em; font-family: var(--font-mono); font-weight: 400; margin-left: 3px; color: var(--muted); letter-spacing: 0; }
.stats span { display: block; margin-top: 8px; font-size: .85rem; color: var(--muted); line-height: 1.4; }

/* Manifesto card */
.manifesto {
  margin-top: 36px; max-width: 340px; padding: 22px 24px;
  background: var(--highlight); color: var(--highlight-text);
  transform: rotate(-1.2deg);
}
.manifesto-kicker { font-family: var(--font-mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; opacity: .7; }
.manifesto ul { list-style: none; margin: 0; padding: 0; font-family: var(--font-head); font-size: 1.15rem; font-weight: 500; line-height: 1.45; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline-item { display: grid; grid-template-columns: 170px 1fr; gap: 24px; }
.timeline-item + .timeline-item { margin-top: 40px; }
.timeline-meta { display: flex; flex-direction: column; font-family: var(--font-mono); font-size: .8rem; color: var(--muted); padding-top: 4px; }
.timeline-meta .date { color: var(--text); }
.timeline-body h3 { font-size: 1.25rem; margin-bottom: 8px; }
.at { color: var(--accent); font-weight: 500; }

.bullets { margin: 0 0 16px; padding-left: 1.1em; }
.bullets li { margin-bottom: 6px; }
.bullets li::marker { color: var(--accent); }

.tags { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.tags li {
  font-family: var(--font-mono); font-size: .75rem; line-height: 1.4;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted);
}

.metric {
  display: inline-block; align-self: flex-start; margin: 0 0 14px;
  font-family: var(--font-mono); font-size: .8rem; color: var(--accent);
  padding: 4px 10px; background: var(--accent-soft); border-radius: 6px;
}

/* ---------- Projects ---------- */
.card-kicker { font-family: var(--font-mono); font-size: .75rem; color: var(--muted); margin-bottom: 6px; }
.card-sub { color: var(--muted); margin: 4px 0 14px; }
.card-link { display: inline-block; margin-top: 16px; font-weight: 500; }

.projects { display: grid; gap: 0; }
.project { display: flex; flex-direction: column; padding: 28px 0; border-top: 1px solid var(--border); }
.project:first-child { border-top: 0; padding-top: 0; }
.project h3 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); letter-spacing: -0.03em; }
.project .tags { margin-top: 4px; }
.more { margin-top: 16px; font-family: var(--font-mono); font-size: .88rem; }

/* ---------- Skills grid ---------- */
.skill-grid { border-top: 1px solid var(--border); }
.skill-row { display: grid; grid-template-columns: 170px 1fr; gap: 24px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.skill-row h3 { font-family: var(--font-mono); font-size: .75rem; font-weight: 500; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding-top: 3px; }
.skill-row ul { display: flex; flex-wrap: wrap; gap: 6px 22px; list-style: none; margin: 0; padding: 0; font-weight: 500; }

/* ---------- Beyond code ---------- */
.beyond { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; list-style: none; margin: 0; padding: 0; }
.beyond-num { font-family: var(--font-serif); font-style: italic; font-size: 2.6rem; line-height: 1; color: var(--accent); margin-bottom: 12px; }
.beyond h3 { font-size: 1.05rem; margin-bottom: 8px; }
.beyond p:not(.beyond-num) { color: var(--muted); margin: 0; font-size: .93rem; }

/* ---------- Contact ---------- */
.contact { border-top: 1px solid var(--border); padding-block: clamp(72px, 14vh, 160px) clamp(48px, 8vh, 80px); }
.contact-kicker { display: flex; gap: 12px; font-family: var(--font-mono); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.contact-kicker span { color: var(--accent); }
.contact-title { font-size: clamp(2.8rem, 9vw, 7.5rem); line-height: .95; letter-spacing: -0.045em; margin: 8px 0 28px; }
.contact-lead { font-size: 1.1rem; color: var(--muted); max-width: 48ch; margin-bottom: 28px; }
.contact-mail {
  display: inline-block; font-family: var(--font-serif); font-style: italic;
  font-size: clamp(1.6rem, 5vw, 3.2rem); line-height: 1.1; color: var(--text);
  border-bottom: 2px solid var(--accent); overflow-wrap: anywhere;
}
.contact-mail:hover { color: var(--accent); text-decoration: none; }
.contact-links { display: flex; gap: 24px; list-style: none; margin: 28px 0 0; padding: 0; font-family: var(--font-mono); font-size: .88rem; }
.contact-links a { color: var(--muted); }
.contact-links a:hover { color: var(--accent); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); overflow: hidden; }
.footer-row {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  padding-block: 24px; font-size: .85rem; color: var(--muted);
}
.footer-row p { margin: 0; }
.footer-wordmark {
  margin: 0; padding-inline: var(--gutter); white-space: nowrap; text-align: center;
  font-family: var(--font-head); font-weight: 700; font-size: 16.5vw; line-height: .78; letter-spacing: -0.05em;
  color: var(--surface-2); user-select: none;
  transform: translateY(12%);
}
.footer-wordmark em { font-family: var(--font-serif); font-weight: 400; letter-spacing: -0.02em; }

/* ---------- Reveal on scroll ---------- */
.js .reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
.js .reveal.visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .status-dot { animation: none; }
  .btn, .side-nav a::after { transition: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .nav-links { display: flex; margin-left: auto; }
  .clock { margin-left: 0; }
  .spec { grid-template-columns: repeat(3, 1fr); row-gap: 20px; }
}
@media (max-width: 760px) {
  .nav-links { display: none; }
  .clock { margin-left: auto; }
  .spec { grid-template-columns: repeat(2, 1fr); }
  .hero-foot { grid-template-columns: 1fr; }
  .hero-actions { align-items: flex-start; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats li:nth-child(3) { padding-left: 0; border-left: 0; }
  .stats li:nth-child(n+3) { border-top: 1px solid var(--border); }
  .beyond { grid-template-columns: 1fr; }
  .timeline-item, .skill-row { grid-template-columns: 1fr; gap: 8px; }
  .timeline-meta { flex-direction: row; gap: 12px; }
}
@media (max-width: 480px) {
  .btn { flex: 1 1 auto; }
  .cta { width: 100%; }
}
