:root {
  --bg: #faf9f6;
  --ink: #1a1a18;
  --muted: #85817a;
  --line: #e8e5df;
  --accent: #2f5d4f;
  --hl: rgba(196, 150, 60, .45);
  --sq-light: #ece8df;
  --sq-dark: #9aa58f;
  --piece-white: #fbf8f2;
  --piece-black: #1a1a18;

  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211;
    --ink: #e9e6e0;
    --muted: #8a867f;
    --line: #262523;
    --accent: #8fb59d;
    --sq-light: #a9a294;
    --sq-dark: #56614d;
  }
}
:root[data-theme="dark"] {
  --bg: #121211;
  --ink: #e9e6e0;
  --muted: #8a867f;
  --line: #262523;
  --accent: #8fb59d;
  --sq-light: #a9a294;
  --sq-dark: #56614d;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}
html { scroll-snap-type: y proximity; }
.mono { font-family: var(--mono); }
p { margin: 0 0 20px; }
a { color: inherit; }

.theme {
  position: fixed; top: 20px; right: 20px; z-index: 5;
  background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer;
}

/* ---------- layout: text scrolls, board stays ---------- */
/* the board is the hero: it takes all the room it can, text sits in a narrow column */
.layout {
  --text-w: clamp(280px, 30vw, 400px);
  display: grid; grid-template-columns: 1fr var(--text-w);
  gap: clamp(24px, 4vw, 64px);
  padding: 0 clamp(20px, 4vw, 56px);
}
.board-wrap {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 14px;
}
.board-wrap .board, .board-wrap .caption {
  width: min(100%, calc(100vh - 110px));
}
.board { box-shadow: 0 2px 6px rgba(0,0,0,.08), 0 24px 60px rgba(0,0,0,.12); }
.caption { font-size: 13px !important; }

.step { min-height: 100vh; display: flex; align-items: center; scroll-snap-align: center; }
.inner {
  width: 100%;
  opacity: 0; transform: translateY(24px);
  transition: opacity .6s ease, transform .6s ease;
}
.step.active .inner { opacity: 1; transform: none; }

/* ---------- type ---------- */
.eyebrow { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-bottom: 14px; }
h1 { font: 500 clamp(40px, 6vw, 56px)/1.05 var(--serif); letter-spacing: -.02em; margin: 0; }
h2 { font: 500 34px/1.1 var(--serif); letter-spacing: -.01em; margin: 0 0 24px; }
.sub { font-size: 13px; color: var(--muted); margin: 10px 0 28px; }
.links { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 13px; margin-bottom: 28px; }
.links a { color: var(--muted); text-decoration: none; transition: color .15s; }
.links a:hover { color: var(--accent); }
.hint { font-size: 12px; color: var(--muted); margin-top: 48px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.when { font-size: 12px; color: var(--muted); padding-top: 3px; }
.list strong { font-weight: 500; display: block; }
.list em { font-style: normal; font-size: 14px; color: var(--muted); }
.interests { font-size: 18px; line-height: 1.8; }
.picks { margin: 6px 0 0; padding-left: 20px; font-size: 14px; }
.list .picks li { display: list-item; padding: 1px 0; border: 0; }
.picks em { color: var(--muted); margin-left: 4px; }


.chart { display: block; width: 100%; max-width: 300px; height: auto; margin-top: 8px; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { font: 9px var(--mono); fill: var(--muted); }
.chart .val { font: 500 10px var(--mono); fill: var(--ink); }
.chart polyline { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart circle { fill: var(--bg); stroke: var(--accent); stroke-width: 2; }

/* clickable projects */
.list li.project { grid-template-columns: 64px 1fr 16px; cursor: pointer; transition: background .15s; }
.list li.project:hover, .list li.project:focus-visible { background: color-mix(in srgb, var(--accent) 7%, transparent); outline: none; }
.open { color: var(--muted); font-size: 16px; align-self: center; transition: color .15s, transform .15s; }
.project:hover .open { color: var(--accent); transform: rotate(90deg); }

.detail {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 64px);
  padding: 0; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink);
}
.detail-inner { padding: 32px; }
.detail::backdrop { background: rgba(0, 0, 0, .55); backdrop-filter: blur(3px); }
.detail[open] { animation: pop .25s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(12px); } }
.detail .close {
  position: absolute; top: 14px; right: 16px; background: none; border: 0;
  color: var(--muted); font-size: 22px; cursor: pointer;
}
.bullets { margin: 0 0 24px; padding-left: 18px; }
.bullets li { margin-bottom: 8px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; display: block; }
.gallery figure { margin: 0; }
.gallery figcaption { font: 11px var(--mono); color: var(--muted); margin-top: 4px; }
.gallery .empty {
  grid-column: 1 / -1; padding: 28px; text-align: center; border: 1px dashed var(--line);
  border-radius: 6px; font: 12px var(--mono); color: var(--muted);
}

a.plain { text-decoration: none; }
a.plain:hover { color: var(--accent); }

.more { font-size: 12px; margin-top: 16px; }
.more a { color: var(--muted); text-decoration: none; }
.more a:hover { color: var(--accent); }


.puzzle-msg { font-size: 13px; color: var(--muted); }
.puzzle-msg.win { color: var(--accent); }
.foot { font-size: 12px; color: var(--muted); margin-top: 64px; }

/* ---------- board ---------- */
.board {
  position: relative; width: 100%; aspect-ratio: 1;
  border-radius: 4px; overflow: hidden; user-select: none;
  container-type: inline-size;
}
.sq { position: absolute; width: 12.5%; height: 12.5%; }
.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.sq.hl { box-shadow: inset 0 0 0 100px var(--hl); }
.sq.sel { box-shadow: inset 0 0 0 3px var(--accent); }
.board.interactive .sq { cursor: pointer; }
.coord { position: absolute; font: 9px var(--mono); color: rgba(26, 26, 24, .45); pointer-events: none; }
.piece {
  position: absolute; width: 12.5%; height: 12.5%;
  display: grid; place-items: center;
  font-size: 9.6cqw; line-height: 1; pointer-events: none;
  transition: left .55s cubic-bezier(.5, 0, .2, 1), top .55s cubic-bezier(.5, 0, .2, 1), opacity .4s;
}
.piece.w { color: var(--piece-white); text-shadow: 0 0 1px #1a1a18, 0 0 1px #1a1a18, 0 1px 1px rgba(0,0,0,.3); }
.piece.b { color: var(--piece-black); }
.piece.gone { opacity: 0; }
.caption { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin: 0; }

/* ---------- mobile: board pinned on top, small ---------- */
@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; gap: 0; padding: 0 16px; }
  .board-col { position: sticky; top: 0; z-index: 2; background: var(--bg); }
  .board-wrap { position: static; height: auto; padding: 12px 0 10px; border-bottom: 1px solid var(--line); }
  .board-wrap .board, .board-wrap .caption { width: min(100%, 58vh); }
  .step { min-height: 70vh; padding: 32px 0; scroll-snap-align: none; }
  .theme { top: auto; bottom: 16px; right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .inner { transition: none; transform: none; }
  .piece { transition: none; }
}
