/* www.friedelprivat.de – Hagrid & Snitch
   Two colour worlds: "black" (night game, default) and "white" (paper). */

:root, :root[data-theme="black"] {
  --bg: #0e0e0f;
  --surface: #161618;
  --surface-2: #1d1d20;
  --line: #2a2a2e;
  --text: #e9e5dc;
  --muted: #9b968c;
  --accent: #c9a45c;          /* brass */
  --accent-soft: rgba(201,164,92,.14);
  --silver: #c3c7cc;
  --glow: rgba(201,164,92,.10);
  /* read by the 3D board */
  --sq-light: #3a3834;
  --sq-dark: #22211f;
  --frame: #1c1a17;
  color-scheme: dark;
}
:root[data-theme="white"] {
  --bg: #f3efe7;
  --surface: #faf7f1;
  --surface-2: #efe9dd;
  --line: #dcd3c2;
  --text: #1d1b17;
  --muted: #6d665a;
  --accent: #94701f;
  --accent-soft: rgba(148,112,31,.12);
  --silver: #6f757c;
  --glow: rgba(255,240,205,.9);
  --sq-light: #e9e0cc;
  --sq-dark: #b9aa88;
  --frame: #8a7550;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  transition: background-color .6s, color .6s;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; }
.serif { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif; }
.mono  { font-family: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 24px; }
@media (max-width: 600px) { .wrap { padding: 0 16px; } }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}

/* ---------- Header ---------- */
header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
header .wrap { display: flex; align-items: center; gap: 32px; height: 64px; }
.logo { font-size: 20px; color: var(--text); letter-spacing: .02em; white-space: nowrap; }
.logo:hover { text-decoration: none; }
.logo b { color: var(--accent); font-weight: 400; }
nav { display: flex; gap: 24px; margin-left: auto; font-size: 14px; }
nav a { color: var(--muted); }
nav a:hover { color: var(--text); text-decoration: none; }
@media (max-width: 760px) { nav { display: none; } .toggle { margin-left: auto; } }

.toggle {
  display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px;
  background: var(--surface);
}
.toggle button {
  border: 0; background: none; color: var(--muted); cursor: pointer;
  font-size: 13px; line-height: 1; padding: 7px 12px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px;
}
.toggle button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.toggle .g { font-size: 15px; line-height: 1; }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  padding: 64px 0 80px;
  background: radial-gradient(ellipse 55% 60% at 72% 42%, var(--glow), transparent 70%);
}
.hero .wrap { display: grid; grid-template-columns: 1fr 1.1fr; gap: 48px; align-items: center; }
.hero .wrap > * { min-width: 0; }
@media (max-width: 900px) {
  .hero .wrap { grid-template-columns: minmax(0, 1fr); }
  .hero { padding-top: 40px; }
}
.eyebrow { font-size: 12px; letter-spacing: .22em; text-transform: uppercase; color: var(--accent); }
h1 { font-size: clamp(38px, 5.4vw, 64px); line-height: 1.05; margin: 14px 0 20px; font-weight: 400; }
h1 em { color: var(--accent); font-style: italic; }
.lead { color: var(--muted); font-size: 18px; max-width: 30em; }
.cta { display: flex; gap: 12px; margin-top: 32px; flex-wrap: wrap; }
.btn {
  display: inline-block; padding: 12px 22px; border-radius: 6px; font-size: 15px;
  border: 1px solid var(--accent); color: var(--accent);
}
.btn.primary { background: var(--accent); color: var(--bg); }
.btn:hover { text-decoration: none; filter: brightness(1.1); }

/* 3D board (three.js). The canvas overhangs the stage on all sides (transparent),
   so the board can grow beyond its column when the camera zooms in on hover. */
.stage { position: relative; width: 100%; aspect-ratio: 1 / .9; }
.stage canvas {
  position: absolute; left: -25%; top: -20%;
  width: 150% !important; height: 140% !important;
  pointer-events: none;
  opacity: 0; transition: opacity .8s;
}
.hero .wrap > :first-child, .readout, .replay-bar { position: relative; z-index: 1; }
.stage.ready canvas { opacity: 1; }
.stage .fallback {
  display: none; position: absolute; inset: 0; place-items: center; text-align: center;
  color: var(--muted); font-size: 14px; padding: 24px;
}
.stage.no-webgl .fallback { display: grid; }

/* Engine output under the board */
.readout {
  margin: 4px auto 0; width: min(100%, 540px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 14px 16px 12px; font-size: 12.5px; line-height: 1.75; color: var(--muted);
}
.readout .hd { display: flex; justify-content: space-between; gap: 12px; color: var(--text); font-size: 12px; }
.readout .hd span:last-child { color: var(--accent); }
.evalbar { height: 3px; margin: 8px 0 8px; border-radius: 2px; background: var(--accent); overflow: hidden; }
.evalbar i { display: block; height: 100%; width: 50%; background: var(--silver); transition: width .8s ease; }
.readout ol { list-style: none; margin: 0; padding: 0; min-height: calc(4 * 1.75em); }
.readout li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readout li b { font-weight: 400; display: inline-block; min-width: 7.5em; }
.readout li.w b { color: var(--silver); }
.readout li.b b { color: var(--accent); }
.readout li:last-child { color: var(--text); }
.replay-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  width: min(100%, 540px); margin: 10px auto 0; font-size: 12.5px; color: var(--muted);
}
.replay-bar button {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 4px 12px; font-size: 12px; cursor: pointer;
}
.replay-bar button:hover { border-color: var(--accent); color: var(--accent); }
.replay-bar .controls { display: flex; align-items: center; gap: 10px; }

/* ---------- Sections ---------- */
section { padding: 96px 0; border-top: 1px solid var(--line); }
@media (max-width: 600px) { section { padding: 64px 0; } }
h2 { font-size: clamp(30px, 3.6vw, 42px); font-weight: 400; margin: 10px 0 16px; }
.intro { color: var(--muted); max-width: 40em; margin: 0 0 48px; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 760px) { .cards { grid-template-columns: 1fr; } }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 32px;
  position: relative; overflow: hidden;
}
@media (max-width: 600px) { .card { padding: 24px; } }
.card .glyph {
  position: absolute; right: -6px; top: -26px; font-size: 150px; line-height: 1;
  color: var(--accent); opacity: .08; font-family: "DejaVu Sans", "Segoe UI Symbol", serif;
  pointer-events: none;
}
.card h3 { font-size: 30px; font-weight: 400; margin: 0 0 4px; }
.card .ver { color: var(--accent); font-size: 13px; }
.card p { color: var(--muted); }
.card .links { font-size: 14px; display: flex; gap: 20px; flex-wrap: wrap; }
.stats { display: flex; gap: 28px; margin: 24px 0 20px; padding-top: 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.stats div { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.stats b { display: block; font-size: 22px; color: var(--text); font-weight: 400; letter-spacing: 0; text-transform: none; }

/* Expand / collapse helpers */
.more-btn {
  margin-top: 8px; border: 1px solid var(--line); background: none; color: var(--accent);
  border-radius: 999px; padding: 8px 18px; font-size: 14px; cursor: pointer;
}
.more-btn:hover { border-color: var(--accent); }

/* Timeline */
.timeline { position: relative; margin-left: 8px; }
.timeline::before { content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.ev { position: relative; padding: 0 0 36px 36px; display: grid; grid-template-columns: 130px 1fr; gap: 24px; }
@media (max-width: 600px) { .ev { grid-template-columns: 1fr; gap: 4px; padding-left: 28px; } }
.ev::before {
  content: ""; position: absolute; left: -5px; top: 7px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--bg); border: 1px solid var(--accent);
}
.ev.major::before { background: var(--accent); }
.ev time { color: var(--accent); font-size: 13px; padding-top: 2px; }
.ev h3 { margin: 0; font-size: 20px; font-weight: 400; }
.ev p, .ev ul { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.ev ul { padding-left: 1.1em; }
.timeline:not(.expanded) .ev.extra { display: none; }

/* Internals table */
.tbl-wrap {
  position: relative; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface);
}
.tbl-wrap:not(.expanded) { max-height: 620px; overflow-y: hidden; }
.tbl-wrap:not(.expanded)::after {
  content: ""; position: sticky; display: block; left: 0; bottom: 0; height: 120px; margin-top: -120px;
  background: linear-gradient(transparent, var(--surface)); pointer-events: none;
}
.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tbl th, .tbl td { text-align: left; padding: 11px 18px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl thead th {
  font-weight: 400; color: var(--accent); font-size: 12px; text-transform: uppercase; letter-spacing: .12em;
  background: var(--surface-2); position: sticky; top: 0;
}
.tbl tbody th {
  font-weight: 400; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .14em;
  padding-top: 22px; background: var(--surface);
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl td { color: var(--muted); }
.tbl td:first-child { color: var(--text); }
.imp { display: inline-flex; gap: 3px; vertical-align: middle; }
.imp i { width: 14px; height: 6px; border-radius: 1px; background: var(--line); }
.imp i.on { background: var(--accent); }
.imp-neg { color: var(--muted); font-size: 13px; }
.legend { margin-top: 16px; font-size: 13px; color: var(--muted); }

/* Downloads */
.dl { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
@media (max-width: 900px) { .dl { grid-template-columns: 1fr; } }
.dl a.card { color: var(--text); display: block; transition: border-color .2s, transform .2s; }
.dl a.card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.dl .tag { font-size: 12px; color: var(--accent); text-transform: uppercase; letter-spacing: .12em; }
.dl h3 { font-size: 24px; margin-top: 8px; }
.dl .arrow { margin-top: 18px; color: var(--accent); font-size: 14px; }
.older { margin-top: 32px; }
.older summary { cursor: pointer; color: var(--accent); font-size: 15px; }
.older ul {
  list-style: none; padding: 0; margin: 16px 0 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 4px 24px;
}
.older li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.older li span { color: var(--muted); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; margin-top: 56px; }
@media (max-width: 760px) { .cols { grid-template-columns: 1fr; gap: 32px; } }
.cols h3 { font-size: 22px; font-weight: 400; margin: 0 0 12px; }
.cols p { color: var(--muted); margin: 0 0 12px; }
.linklist { list-style: none; padding: 0; margin: 0; }
.linklist li { padding: 9px 0; border-bottom: 1px solid var(--line); }
.linklist li span { color: var(--muted); font-size: 14px; }

footer { border-top: 1px solid var(--line); padding: 40px 0; color: var(--muted); font-size: 14px; }
footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
