/*
 * One stylesheet, no client JavaScript, no webfont.
 *
 * The corpus is long-form technical prose with wide tables and a lot of inline code, so the
 * measure is set for reading rather than for filling the window, and tables are allowed to
 * scroll inside their own box instead of forcing the page sideways. Colours come from the
 * game's own palette — Roman brick and bronze against a dark ground.
 */

:root {
  --bg: #16130f;
  --panel: #1d1a15;
  --panel-2: #241f19;
  --line: #332d24;
  --ink: #ded5c6;
  --ink-dim: #a2988a;
  --ink-faint: #7a7167;
  --brick: #b4512e;
  --bronze: #c99a4e;
  --link: #d8a35f;
  --link-hover: #f0c384;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #faf7f2;
    --panel: #f2ede4;
    --panel-2: #e9e2d6;
    --line: #d9d0c0;
    --ink: #23201b;
    --ink-dim: #59524a;
    --ink-faint: #857c70;
    --link: #9a4322;
    --link-hover: #7a3319;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 1.5rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.68 var(--sans);
  -webkit-font-smoothing: antialiased;
}

.skip {
  position: absolute; left: -9999px;
  background: var(--brick); color: #fff; padding: .6rem 1rem; z-index: 10;
}
.skip:focus { left: 1rem; top: 1rem; }

/* ------------------------------------------------------------------ layout */

.layout { display: flex; align-items: flex-start; gap: 0; }

.sidebar {
  position: sticky; top: 0;
  flex: 0 0 250px;
  height: 100vh; overflow-y: auto;
  padding: 1.6rem 1.1rem 3rem;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.brand {
  display: block; text-decoration: none;
  color: var(--ink); font-weight: 650; font-size: 1.05rem; letter-spacing: .01em;
  padding-bottom: 1.1rem; margin-bottom: .3rem;
  border-bottom: 1px solid var(--line);
}
.brand span {
  display: block; margin-top: .2rem;
  font-size: .72rem; font-weight: 400; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-faint);
}
.brand:hover { color: var(--link-hover); }

.navgroup { margin-top: 1.5rem; }
.navgroup h4 {
  margin: 0 0 .5rem; font-size: .68rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint);
}
.navgroup ul { list-style: none; margin: 0; padding: 0; }
.navgroup li { margin: 0; }
.navgroup a {
  display: block; padding: .3rem .55rem; margin-left: -.55rem;
  border-radius: 4px;
  color: var(--ink-dim); text-decoration: none; font-size: .92rem;
}
.navgroup a:hover { color: var(--ink); background: var(--panel-2); }
.navgroup a.here {
  color: var(--ink); background: var(--panel-2);
  box-shadow: inset 2px 0 0 var(--brick);
  font-weight: 550;
}

main {
  flex: 1 1 auto; min-width: 0;
  display: flex; gap: 2.5rem; align-items: flex-start;
  justify-content: center;
  padding: 2.6rem 2.2rem 6rem;
}

.prose { flex: 1 1 auto; min-width: 0; max-width: 46rem; }

/* --------------------------------------------------------------------- toc */

.toc {
  order: 2;
  position: sticky; top: 2.6rem;
  flex: 0 0 210px; max-height: calc(100vh - 5rem); overflow-y: auto;
  font-size: .85rem;
  border-left: 1px solid var(--line);
  padding-left: 1rem;
}
.toc h4 {
  margin: 0 0 .55rem; font-size: .68rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint);
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: .12rem 0; }
.toc li.d3 { padding-left: .85rem; font-size: .95em; }
.toc a { color: var(--ink-dim); text-decoration: none; display: block; line-height: 1.35; padding: .1rem 0; }
.toc a:hover { color: var(--link-hover); }

/* ------------------------------------------------------------------- prose */

.prose h1, .prose h2, .prose h3, .prose h4, .prose h5 {
  line-height: 1.25; font-weight: 650; letter-spacing: -.005em;
  position: relative;
}
.prose h1 { font-size: 2.1rem; margin: 0 0 1.1rem; letter-spacing: -.02em; }
.prose h2 {
  font-size: 1.42rem; margin: 2.9rem 0 .9rem;
  padding-bottom: .35rem; border-bottom: 1px solid var(--line);
}
.prose h3 { font-size: 1.13rem; margin: 2rem 0 .6rem; }
.prose h4 { font-size: 1rem; margin: 1.5rem 0 .5rem; color: var(--ink-dim); }

.anchor {
  position: absolute; left: -1.15rem; top: 0;
  color: var(--ink-faint); text-decoration: none; opacity: 0;
  font-weight: 400;
}
h1:hover .anchor, h2:hover .anchor, h3:hover .anchor, h4:hover .anchor { opacity: .55; }
.anchor:hover { opacity: 1 !important; color: var(--link-hover); }

.prose p { margin: 0 0 1.05rem; }
.prose strong { color: #fff; font-weight: 620; }
@media (prefers-color-scheme: light) { .prose strong { color: #000; } }

.prose a { color: var(--link); text-decoration: none; border-bottom: 1px solid rgba(216,163,95,.28); }
.prose a:hover { color: var(--link-hover); border-bottom-color: currentColor; }

.prose ul, .prose ol { margin: 0 0 1.05rem; padding-left: 1.35rem; }
.prose li { margin: .3rem 0; }
.prose li > ul, .prose li > ol { margin: .3rem 0; }

.prose blockquote {
  margin: 1.2rem 0; padding: .1rem 0 .1rem 1.1rem;
  border-left: 3px solid var(--brick);
  color: var(--ink-dim);
}

.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.4rem 0; }

.prose img { max-width: 100%; height: auto; border-radius: 5px; border: 1px solid var(--line); display: block; margin: 1.3rem 0; }

/* -------------------------------------------------------------------- code */

.prose code {
  font-family: var(--mono); font-size: .875em;
  background: var(--panel-2); border: 1px solid var(--line);
  padding: .08em .34em; border-radius: 3px;
  color: var(--bronze);
  word-break: break-word;
}
@media (prefers-color-scheme: light) { .prose code { color: #8a4a1c; } }

.code { position: relative; margin: 1.3rem 0; }
.code .lang {
  position: absolute; top: 0; right: 0;
  font: 600 .62rem/1 var(--mono); letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-faint); background: var(--panel-2);
  padding: .38rem .55rem; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line);
  border-radius: 0 5px 0 4px;
}
.code pre {
  margin: 0; padding: .95rem 1.05rem; overflow-x: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 5px;
}
.code pre code {
  background: none; border: 0; padding: 0; color: var(--ink);
  font-size: .855rem; line-height: 1.6;
}

/* highlight.js, hand-cut to the palette rather than vendored wholesale */
.hljs-comment, .hljs-quote { color: var(--ink-faint); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-type { color: #d0797f; }
.hljs-string, .hljs-meta .hljs-string { color: #9dbd7a; }
.hljs-number, .hljs-symbol { color: #d9a05b; }
.hljs-title, .hljs-title.function_, .hljs-section { color: var(--bronze); }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable { color: #8fb8c9; }
.hljs-built_in, .hljs-class .hljs-title { color: #c9915e; }
.hljs-meta, .hljs-doctag { color: var(--ink-faint); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* ------------------------------------------------------------------ tables */

.tablewrap { overflow-x: auto; margin: 1.4rem 0; border: 1px solid var(--line); border-radius: 5px; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th {
  background: var(--panel-2); color: var(--ink-dim);
  font-size: .7rem; letter-spacing: .07em; text-transform: uppercase; font-weight: 700;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.018); }
td code { white-space: nowrap; }

/* ------------------------------------------------------------------- index */

.lede { font-size: 1.1rem; color: var(--ink-dim); margin-bottom: 1.6rem; }
.group { margin-top: 2.8rem; }
.group h2 { margin-bottom: .4rem; }
.blurb { color: var(--ink-dim); margin-bottom: 1.1rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .8rem; }
.card {
  display: block; padding: 1rem 1.1rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  text-decoration: none; color: inherit;
  transition: border-color .12s, transform .12s;
}
.card:hover { border-color: var(--brick); transform: translateY(-1px); }
.card h3 { margin: 0 0 .35rem; font-size: 1.02rem; color: var(--ink); }
.card p { margin: 0; font-size: .87rem; color: var(--ink-dim); line-height: 1.5; }

.pending { color: var(--ink-dim); }
.foot { color: var(--ink-faint); font-size: .87rem; }

/* ----------------------------------------------------------------- narrow */

@media (max-width: 1180px) {
  .toc { display: none; }
  main { padding: 2.2rem 1.8rem 5rem; }
}
@media (max-width: 820px) {
  .layout { display: block; }
  .sidebar {
    position: static; height: auto; width: auto;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .navgroup { margin-top: 1rem; }
  .navgroup ul { display: flex; flex-wrap: wrap; gap: .1rem .35rem; }
  main { padding: 1.6rem 1.15rem 4rem; }
  .prose h1 { font-size: 1.7rem; }
}

/* The index hero. Full-bleed against the measure, and our own render — see build.mjs. */
.hero {
  display: block; width: 100%; height: auto;
  border-radius: 6px; border: 1px solid var(--line);
  margin: 0 0 1.6rem;
}
