/* Light theme (default) */
:root {
  --bg: #FAFAF9;
  --surface: #FFFFFF;
  --fg: #0A0A0A;
  --muted: #5C5C5C;
  --faint: #8A8A8A;
  --border: #E7E5E4;
  --border-strong: #CFCCCA;
  --grid: rgba(10, 10, 10, 0.055);
  --nav: rgba(250, 250, 249, 0.8);
  --live: #16A34A;
  --gold: #E2B12C;

  --sans: "Geist", "Inter", "Helvetica Neue", Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --pad: 3rem;
  color-scheme: light;
}

/* Dark theme: follows the device unless the visitor picked light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A0A0A;
    --surface: #111111;
    --fg: #EDEDED;
    --muted: #A1A1A1;
    --faint: #6E6E6E;
    --border: #232323;
    --border-strong: #3A3A3A;
    --grid: rgba(255, 255, 255, 0.05);
    --nav: rgba(10, 10, 10, 0.75);
    --live: #22C55E;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0A0A0A;
  --surface: #111111;
  --fg: #EDEDED;
  --muted: #A1A1A1;
  --faint: #6E6E6E;
  --border: #232323;
  --border-strong: #3A3A3A;
  --grid: rgba(255, 255, 255, 0.05);
  --nav: rgba(10, 10, 10, 0.75);
  --live: #22C55E;
  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0 1.5rem;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

::selection { background: var(--gold); color: #0A0A0A; }

a { color: inherit; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  z-index: 20;
  background: var(--surface);
  padding: 0.5rem 0.75rem;
}
.skip:focus { left: 0.5rem; }

.mono {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
}

/* The frame: a centred column with hairline sides, and full-width hairlines between blocks */
.frame {
  position: relative;
  max-width: 72rem;
  margin: 0 auto;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
main > .frame::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 100vw;
  transform: translateX(-50%);
  border-bottom: 1px solid var(--border);
}

/* Nav */
.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: 0 -1.5rem;
  padding: 0 1.5rem;
  background: var(--nav);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  height: 3.5rem;
  padding: 0 var(--pad);
}
.wordmark {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.sections {
  display: flex;
  gap: 1.5rem;
  margin-left: auto;
  font-size: 0.875rem;
}
.sections a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s ease;
}
.sections a:hover,
.sections a[aria-current] { color: var(--fg); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover { color: var(--fg); border-color: var(--border-strong); }
.icon-btn svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.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; }
}

/* Hero */
.hero {
  padding: clamp(4rem, 10vw, 7rem) var(--pad) 3.5rem;
  scroll-margin-top: 3.5rem;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 2.5rem 2.5rem;
  -webkit-mask-image: radial-gradient(ellipse 70% 80% at 0% 0%, #000 30%, transparent 75%);
  mask-image: radial-gradient(ellipse 70% 80% at 0% 0%, #000 30%, transparent 75%);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 1.75rem;
  padding: 0.3rem 0.8rem 0.3rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}
.dot {
  position: relative;
  flex: none;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--live);
}
.dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--live);
  animation: ping 2.2s cubic-bezier(0, 0, 0.2, 1) infinite;
}
@keyframes ping {
  0% { transform: scale(1); opacity: 0.6; }
  75%, 100% { transform: scale(2.6); opacity: 0; }
}

h1 {
  margin: 0;
  font-size: clamp(2.6rem, 7vw, 4.75rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.045em;
}

.lede {
  max-width: 38rem;
  margin: 1.25rem 0 0;
  font-size: clamp(1.05rem, 1.8vw, 1.2rem);
  line-height: 1.55;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 2rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  height: 2.5rem;
  padding: 0 1.1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg);
  font: 500 0.875rem/1 var(--sans);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, opacity 0.15s ease;
}
.btn:hover { border-color: var(--border-strong); }
.btn-primary {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
}
.btn-primary:hover { opacity: 0.86; border-color: var(--fg); }

.now {
  margin: 2.5rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.label {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--fg);
  margin-right: 0.75rem;
  padding-right: 0.75rem;
  border-right: 1px solid var(--border-strong);
}

/* Load-in: the hero rises once, quietly */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  .hero > * { animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  .hero > :nth-child(2) { animation-delay: 0.06s; }
  .hero > :nth-child(3) { animation-delay: 0.12s; }
  .hero > :nth-child(4) { animation-delay: 0.18s; }
  .hero > :nth-child(5) { animation-delay: 0.24s; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* Stats strip */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: 0;
  margin-bottom: 0;
  border-top: 1px solid var(--border);
}
.stats div { padding: 1.75rem var(--pad) 1.75rem 1.5rem; }
.stats div:first-child { padding-left: var(--pad); }
.stats div + div { border-left: 1px solid var(--border); }
.stats dt {
  font-size: 1.85rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}
.stats dd {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--muted);
}

/* Content blocks */
.block {
  display: grid;
  grid-template-columns: 13rem 1fr;
  gap: 2rem;
  padding: 4.5rem var(--pad);
}
.block-head {
  align-self: start;
  position: sticky;
  top: 5.5rem;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}
.index {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--faint);
}
h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  scroll-margin-top: 5.5rem;
}
.block-body { max-width: 46rem; }

h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.35;
}

/* Projects */
.project {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  padding: 1.75rem;
  transition: border-color 0.2s ease;
}
.project + .project { margin-top: 1rem; }
.project:hover { border-color: var(--border-strong); }
.project-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  padding-bottom: 1.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.project-head h3 { font-size: 1.35rem; letter-spacing: -0.03em; }
.project-head p { margin: 0; }

.facts {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 0.9rem 1.5rem;
  margin: 0;
  font-size: 0.95rem;
}
.facts dt {
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.6rem;
  color: var(--faint);
}
.facts dd { margin: 0; }

.project-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-top: 1.5rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.chips li {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
  background: var(--bg);
}

.text-link {
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 4px;
  transition: text-decoration-color 0.15s ease;
}
.text-link:hover { text-decoration-color: var(--fg); }

/* Experience-style rows */
.row { padding: 1.5rem 0; border-top: 1px solid var(--border); }
.row:first-child { padding-top: 0; border-top: 0; }
.row:last-child { padding-bottom: 0; }
.row header {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 1.5rem;
}
.row .org {
  grid-column: 1;
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.925rem;
}
.row .when {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  white-space: nowrap;
  line-height: 1.6rem;
}
.row ul {
  margin: 0.75rem 0 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.95rem;
}
.row li { margin-bottom: 0.3rem; }
.row li::marker { color: var(--faint); }

.skills { align-items: center; }
.skills dd { color: var(--muted); }

/* Contact */
.contact { padding: 5rem var(--pad); }
.contact h2 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1.05;
}
.copy { font-family: var(--mono); font-size: 0.8rem; }

/* Footer */
.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding: 1.5rem var(--pad) 2.5rem;
}
.footer p { margin: 0; }
.footer a {
  text-decoration: none;
  margin-left: 1.25rem;
  transition: color 0.15s ease;
}
.footer a:first-child { margin-left: 0; }
.footer a:hover { color: var(--fg); }

@media (max-width: 800px) {
  :root { --pad: 1.25rem; }
  body { padding: 0 1rem; }
  .nav { margin: 0 -1rem; padding: 0 1rem; }
  .nav-inner { gap: 1rem; }
  .sections a[href^="#"] { display: none; }

  .stats { grid-template-columns: 1fr 1fr; }
  .stats div,
  .stats div:first-child { padding: 1.25rem var(--pad); }
  .stats div:nth-child(3) { border-left: 0; }
  .stats div:nth-child(n+3) { border-top: 1px solid var(--border); }

  .block {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: 3rem var(--pad);
  }
  .block-head { position: static; }

  .project { padding: 1.25rem; }
  .facts { grid-template-columns: 1fr; gap: 0.15rem; }
  .facts dd + dt { margin-top: 0.75rem; }

  .row header { grid-template-columns: 1fr; }
  .row .when { grid-column: 1; grid-row: auto; margin-top: 0.15rem; }

  .contact { padding: 3.5rem var(--pad); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
