/*
  The stylesheet for the written pages -- everything under /learn, plus the
  changelog.

  It is a plain file rather than a string inside the generator because it is
  ordinary CSS and deserves ordinary tooling. The build copies it to
  /learn/learn.css and every page links it, so one edit reaches all of them.

  The palette is lifted from the app (apps/web/src/styles.css) and from the
  renderer (apps/web/src/render/palette.ts) rather than re-picked, so a diagram
  of the house on a written page is the same blue and the same red as the house
  a player is looking at while they read it.
*/

:root {
  --bg: #10161f;
  --panel: #18202b;
  --panel-2: #1f2937;
  --line: #2b3644;
  --text: #e7edf5;
  --muted: #93a3b8;
  --accent: #4a9d6b;
  --accent-bright: #6ab98a;
  --red: #d94141;
  --yellow: #e8b62c;

  /* The sheet, exactly as the game draws it. */
  --ice: #eef4fb;
  --ice-edge: #d6e2f0;
  --ice-line: #8fa6bd;
  --hog: #c0392b;
  --ring12: #2f5fbf;
  --ring8: #ffffff;
  --ring4: #c0392b;
  --granite: #6f7378;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* ---- chrome ---- */

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 20px;
  background: rgba(16, 22, 31, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.top .brand {
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
  text-decoration: none;
  font-size: 17px;
}

.top nav {
  display: flex;
  gap: 14px;
  margin-left: auto;
  font-size: 14px;
  flex-wrap: wrap;
}

.top nav a { color: var(--muted); text-decoration: none; }
.top nav a:hover { color: var(--text); }
.top nav a.play { color: var(--accent-bright); font-weight: 600; }

main {
  max-width: 48rem;
  margin: 0 auto;
  padding: 0 20px 4rem;
}

/* ---- headings and prose ---- */

.crumbs {
  margin: 1.75rem 0 0;
  font-size: 13px;
  color: var(--muted);
}
.crumbs a { color: var(--muted); }
.crumbs span { opacity: 0.6; padding: 0 0.35rem; }

h1 {
  font-size: clamp(1.9rem, 1.3rem + 2.2vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0.6rem 0 0.5rem;
}

.standfirst {
  font-size: 1.12rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
  max-width: 40rem;
}

.updated {
  font-size: 12.5px;
  color: var(--muted);
  opacity: 0.75;
  margin: 0 0 2.25rem;
  letter-spacing: 0.02em;
}

h2 {
  font-size: 1.4rem;
  letter-spacing: -0.01em;
  margin: 3rem 0 0.75rem;
  padding-top: 0.4rem;
  scroll-margin-top: 4.5rem;
}

h3 {
  font-size: 1.08rem;
  margin: 2rem 0 0.5rem;
  scroll-margin-top: 4.5rem;
}

h2 .anchor, h3 .anchor {
  color: var(--line);
  text-decoration: none;
  margin-left: 0.4rem;
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.12s;
}
h2:hover .anchor, h3:hover .anchor { opacity: 1; }
h2 .anchor:hover, h3 .anchor:hover { color: var(--accent-bright); }

p { margin: 0 0 1.1rem; }

a { color: var(--accent-bright); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: #8ed3ac; }

strong { color: #f4f8fc; font-weight: 650; }

ul, ol { padding-left: 1.35rem; margin: 0 0 1.2rem; }
li { margin: 0.4rem 0; }

code {
  background: var(--panel-2);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

pre {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.55;
}
pre code { background: none; padding: 0; font-size: inherit; }

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

blockquote {
  margin: 0 0 1.2rem;
  padding-left: 1rem;
  border-left: 2px solid var(--line);
  color: var(--muted);
}

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

.scroll-x { overflow-x: auto; margin: 0 0 1.4rem; }

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14.5px;
  font-variant-numeric: tabular-nums;
}

th, td {
  border: 1px solid var(--line);
  padding: 0.42rem 0.7rem;
  text-align: left;
  vertical-align: top;
}

thead th {
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.018); }
td.num, th.num { text-align: right; white-space: nowrap; }

/* ---- callouts ---- */

.note, .key {
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  background: var(--panel);
  border-radius: 0 8px 8px 0;
  padding: 0.9rem 1.1rem;
  margin: 0 0 1.4rem;
}
.note > :last-child, .key > :last-child { margin-bottom: 0; }
.key { border-left-color: var(--accent); }
.note .label, .key .label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.key .label { color: var(--accent-bright); }

/* ---- figures ---- */

figure {
  margin: 1.8rem 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  overflow: hidden;
}

figure .art {
  display: block;
  padding: 1rem;
  background: radial-gradient(120% 100% at 50% 0%, #1a2431 0%, var(--panel) 70%);
}

figure svg { display: block; width: 100%; height: auto; }

figcaption {
  border-top: 1px solid var(--line);
  padding: 0.7rem 1rem;
  font-size: 13.5px;
  color: var(--muted);
  background: var(--panel-2);
}

/* ---- the card grids on the hub ---- */

.cards {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
}

.cards li { margin: 0; }

.cards a {
  display: block;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 0.9rem 1rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.14s, background 0.14s, transform 0.14s;
}
.cards a:hover {
  border-color: #3d5063;
  background: #1c2531;
  transform: translateY(-1px);
}
.cards .t { display: block; font-weight: 650; margin-bottom: 0.25rem; }
.cards .d { display: block; font-size: 13.5px; color: var(--muted); line-height: 1.5; }

/* ---- prev / next ---- */

.pager {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 3rem 0 0;
  border-top: 1px solid var(--line);
  padding-top: 1.5rem;
}
.pager a {
  flex: 1 1 14rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: var(--text);
}
.pager a:hover { border-color: #3d5063; }
.pager .dir { display: block; font-size: 12px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.pager .next { text-align: right; }

/* ---- footer ---- */

footer.site {
  border-top: 1px solid var(--line);
  margin-top: 3rem;
  padding: 1.5rem 20px 3rem;
  color: var(--muted);
  font-size: 13.5px;
}
footer.site .inner { max-width: 48rem; margin: 0 auto; }
footer.site a { color: var(--muted); }
footer.site a:hover { color: var(--text); }
footer.site .links { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 0.6rem; }

/* ---- interactive diagram controls ---- */

.diagram { margin: 1.8rem 0; }

.diagram .tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.diagram .tabs button {
  font: inherit;
  font-size: 13.5px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  cursor: pointer;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.diagram .tabs button:hover { color: var(--text); border-color: #3d5063; }
.diagram .tabs button[aria-pressed='true'] {
  color: #0d1218;
  background: var(--accent-bright);
  border-color: var(--accent-bright);
  font-weight: 650;
}

.diagram .stage {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}
@media (min-width: 46rem) {
  .diagram .stage { grid-template-columns: minmax(0, 1fr) 15rem; }
}

.diagram figure { margin: 0; }

.diagram .readout {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 0.9rem 1rem;
  min-height: 7rem;
}
.diagram .readout h4 { margin: 0 0 0.35rem; font-size: 1rem; }
.diagram .readout p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.55; }
.diagram .readout .hint { font-style: italic; opacity: 0.8; }

/*
  Hit targets on the sheet, and the legend beside them.

  The two are the same control seen twice: pointing at either one lights up
  both. That is deliberate rather than clever -- the legend is ordinary text
  that a crawler reads and a screen reader announces, so nothing on these pages
  is only available to a mouse. The highlight is a saturated green at partial
  opacity because it lands on white ice, not on the dark page.
*/

.hot { cursor: pointer; }
.hot .fill { fill: transparent; transition: fill 0.12s; }
.hot .band { fill: none; stroke: transparent; transition: stroke 0.12s; }
.hot .halo { fill: none; stroke: transparent; stroke-width: 0.18; transition: stroke 0.12s; }
.hot .edge { fill: none; stroke: transparent; stroke-width: 0.13; transition: stroke 0.12s; }
.hot:hover .fill, .hot.on .fill { fill: rgba(47, 143, 91, 0.45); }
.hot:hover .band, .hot.on .band { stroke: rgba(47, 143, 91, 0.45); }
.hot:hover .halo, .hot.on .halo { stroke: #2f8f5b; }
.hot:hover .edge, .hot.on .edge { stroke: #2f8f5b; }
.hot:focus { outline: none; }
.hot:focus-visible .halo, .hot:focus-visible .edge { stroke: #1b6b40; stroke-dasharray: 0.3 0.2; }

.legend {
  list-style: none;
  padding: 0;
  margin: 0 0 1.4rem;
  display: grid;
  gap: 2px;
}
.legend li {
  margin: 0;
  padding: 0.42rem 0.7rem;
  border: 1px solid transparent;
  border-radius: 7px;
  transition: background 0.12s, border-color 0.12s;
  font-size: 15px;
}
.legend li.on {
  background: rgba(74, 157, 107, 0.14);
  border-color: rgba(106, 185, 138, 0.45);
}
.legend b { color: #f4f8fc; }
.legend .said { color: var(--muted); }
.legend .n {
  display: inline-block;
  min-width: 1.6em;
  font-variant-numeric: tabular-nums;
  color: var(--accent-bright);
  font-weight: 650;
}

.hint-line {
  font-size: 13px;
  color: var(--muted);
  margin: -0.6rem 0 1.2rem;
  font-style: italic;
}

/* ---- the changelog ---- */

.release { margin: 0 0 2.5rem; }
.release h2 { margin-top: 2.5rem; display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
.release .date {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.release ul { margin-bottom: 0; }

/* ---- small print ---- */

.pill {
  display: inline-block;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  vertical-align: 0.1em;
}

.lede-links { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 2rem; }
.lede-links a {
  border: 1px solid var(--accent);
  color: var(--accent-bright);
  border-radius: 8px;
  padding: 0.45rem 0.95rem;
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 600;
}
.lede-links a:hover { background: rgba(74, 157, 107, 0.12); }
.lede-links a.plain { border-color: var(--line); color: var(--muted); font-weight: 500; }
.lede-links a.plain:hover { background: var(--panel); color: var(--text); }
