/* ---------- Tokens ---------- */
:root {
  --paper: #eef1ee;
  --paper-2: #e2e8e3;
  --ink: #1c2421;
  --ink-soft: #4b5751;
  --green: #18453b;       /* Spartan green */
  --green-lit: #2f7a62;
  --sq-light: #dfe6e0;
  --sq-dark: #b9c8bd;
  --bit-on: #18453b;
  --bit-on-text: #eef1ee;
  --rule: #c9d3cc;

  --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --measure: 66ch;
  --gutter: clamp(16px, 4vw, 48px);
  --radius-sm: 4px;
  --radius-lg: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121a17;
    --paper-2: #1a2420;
    --ink: #e3e9e5;
    --ink-soft: #a6b3ac;
    --green: #6fb293;
    --green-lit: #8fd0b0;
    --sq-light: #24302b;
    --sq-dark: #1b2521;
    --bit-on: #6fb293;
    --bit-on-text: #0f1613;
    --rule: #2c3934;
  }
}

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

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green); text-underline-offset: 3px; }
a:hover { color: var(--green-lit); }
:focus-visible { outline: 3px solid var(--green-lit); outline-offset: 3px; border-radius: 2px; }

h1, h2, h3 { line-height: 1.15; margin: 0; }

.skip {
  position: absolute; left: -9999px; top: 8px;
  background: var(--ink); color: var(--paper); padding: 8px 12px;
}
.skip:focus { left: 8px; }

/* ---------- Header / footer ---------- */
.site-header {
  display: flex; flex-wrap: wrap; gap: 12px 32px;
  align-items: baseline; justify-content: space-between;
  padding: 24px var(--gutter);
  max-width: 1200px; margin: 0 auto;
}
.wordmark { font-weight: 800; font-size: 1.125rem; color: var(--ink); text-decoration: none; }
.site-header nav { display: flex; flex-wrap: wrap; gap: 4px 22px; }
.site-header nav a { color: var(--ink-soft); text-decoration: none; font-weight: 500; }
.site-header nav a:hover { color: var(--green); }

.site-footer {
  max-width: 1200px; margin: 0 auto;
  padding: 32px var(--gutter) 48px;
  color: var(--ink-soft); font-size: 0.9rem;
  border-top: 1px solid var(--rule);
}

/* ---------- Hero ---------- */
.hero {
  max-width: 1200px; margin: 0 auto;
  padding: clamp(32px, 7vw, 96px) var(--gutter) clamp(48px, 8vw, 112px);
  display: grid; gap: clamp(32px, 6vw, 80px);
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  align-items: center;
}
.hero h1 {
  font-size: clamp(2.4rem, 6vw, 4.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  max-width: 14ch;
}
.lede { font-size: 1.2rem; color: var(--ink-soft); max-width: 44ch; margin: 24px 0 32px; }
.hero-links, .feature-links, .contact-links {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin: 0;
}

.button {
  display: inline-block;
  background: var(--green); color: var(--paper);
  padding: 12px 20px; border-radius: var(--radius-sm);
  font-weight: 700; text-decoration: none;
}
.button:hover { background: var(--green-lit); color: var(--paper); }
.text-link { font-weight: 600; }

/* ---------- Bitboard figure ---------- */
.bitboard { margin: 0; }
.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  aspect-ratio: 1;
  width: 100%; max-width: 440px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.cell {
  appearance: none; border: 0; margin: 0; padding: 0;
  font: 600 clamp(0.7rem, 1.6vw, 0.95rem) var(--font);
  color: var(--ink-soft);
  background: var(--sq-light);
  cursor: pointer;
  display: grid; place-items: center;
  transition: background-color 120ms ease, color 120ms ease;
}
.cell.dark { background: var(--sq-dark); }
.cell.on { background: var(--bit-on); color: var(--bit-on-text); }
.cell.knight { background: var(--ink); color: var(--paper); font-size: clamp(1rem, 2.6vw, 1.5rem); }

.bitboard figcaption {
  display: grid; gap: 6px;
  max-width: 440px; margin-top: 16px;
  font-size: 0.95rem; color: var(--ink-soft);
}
.bb-sq { color: var(--ink); }
.bitboard code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 1rem; color: var(--green); word-break: break-all;
}

/* ---------- Sections ---------- */
.section {
  max-width: 1200px; margin: 0 auto;
  padding: clamp(48px, 7vw, 88px) var(--gutter);
  border-top: 1px solid var(--rule);
}
.section h2 { font-size: clamp(1.8rem, 3.6vw, 2.6rem); font-weight: 800; letter-spacing: -0.02em; margin-bottom: 32px; }
.section p { max-width: var(--measure); }

/* Featured project gets the weight; the rest are a quiet list. */
.feature {
  background: var(--paper-2);
  border-radius: var(--radius-lg);
  padding: clamp(24px, 4vw, 48px);
  margin-bottom: 48px;
}
.feature h3 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 800; margin-bottom: 12px; }
.facts { padding-left: 1.2em; margin: 16px 0 28px; max-width: var(--measure); }
.facts li { margin: 4px 0; }

.project-list { list-style: none; padding: 0; margin: 0; }
.project-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 4px 32px;
  padding: 24px 0;
  border-top: 1px solid var(--rule);
}
.project-list h3 { font-size: 1.15rem; font-weight: 700; grid-row: span 2; }
.project-list p { margin: 0; }
.stack { color: var(--ink-soft); font-size: 0.95rem; }

.timeline { margin: 0 0 40px; }
.timeline > div {
  display: grid; grid-template-columns: 11rem minmax(0, 1fr);
  gap: 4px 32px; padding: 16px 0; border-top: 1px solid var(--rule);
}
.timeline dt { color: var(--ink-soft); font-weight: 500; }
.timeline dd { margin: 0; max-width: var(--measure); }
.subhead { font-size: 1.15rem; font-weight: 700; margin-bottom: 8px; }
.skills { margin: 0; }

.contact p:first-of-type { font-size: 1.2rem; margin: 0 0 24px; }

/* ---------- Simple inner pages (chess, 404) ---------- */
.page {
  max-width: 1200px; margin: 0 auto;
  padding: clamp(32px, 6vw, 80px) var(--gutter);
}
.page h1 { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 800; letter-spacing: -0.03em; margin-bottom: 16px; }
.page p { max-width: var(--measure); }
.placeholder {
  display: grid; place-items: center;
  aspect-ratio: 1; max-width: 520px; margin: 32px 0;
  border: 2px dashed var(--rule); border-radius: var(--radius-lg);
  color: var(--ink-soft); text-align: center; padding: 24px;
}

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; }
  .board, .bitboard figcaption { max-width: 100%; }
  .project-list li, .timeline > div { grid-template-columns: 1fr; }
  .project-list h3 { grid-row: auto; }
}
