/* The Metis user guide. Colours are the app's Orbit tokens (docs/design-brief.md). */
:root {
  --frame: #efe9db;
  --sheet: #fbf8f1;
  --raised: #fffdf8;
  --text: #414042;
  --muted: #5c5b5e;
  --line: #e7e0d0;
  --line-strong: #dcd3c0;
  --accent: #16774a;
  --accent-soft: #e0f2e8;
  --gold: #8a5a12;
  --gold-fill: #efc88b;
  --marker: #c8553d;
}
@media (prefers-color-scheme: dark) {
  :root {
    --frame: #2b2a2c;
    --sheet: #333234;
    --raised: #3c3b3d;
    --text: #ece7dc;
    --muted: #c4c0b8;
    --line: #403f42;
    --line-strong: #4b4a4d;
    --accent: #34c07d;
    --accent-soft: #2c4a3a;
    --gold: #e0ad5a;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
body {
  margin: 0;
  background: var(--frame);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Display", "Segoe UI", Helvetica, Arial, sans-serif;
  line-height: 1.65;
}
a { color: var(--accent); }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid var(--gold-fill); outline-offset: 2px; }

.layout { display: grid; grid-template-columns: 288px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 20px 14px 32px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px; font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; }
.brand img { width: 26px; height: 26px; }
.brand .brand-logo { width: auto; height: 40px; }
.brand span { color: var(--muted); font-weight: 400; }
.side h2 { margin: 22px 10px 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.side ul { list-style: none; margin: 0; padding: 0; }
.side li a { display: block; padding: 4px 10px; border-radius: 7px; font-size: 14px; line-height: 1.4; color: var(--text); text-decoration: none; }
.side li a:hover { background: var(--line); }
.side li a[aria-current] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-toggle { display: none; }
/* The list's scrollbar stays out of sight until the pointer is over the list, and takes the same
   room either way, so the links never shift. */
.side { scrollbar-width: thin; scrollbar-color: transparent transparent; scrollbar-gutter: stable; transition: scrollbar-color .2s; }
.side:hover, .side:focus-within { scrollbar-color: var(--line-strong) transparent; }
html { scrollbar-color: var(--line-strong) var(--frame); }

/* Search and the map button, kept in reach at the top of the list. */
.find { position: sticky; top: -20px; z-index: 1; display: flex; gap: 6px; margin: 16px 0 6px; padding: 8px 0 6px; background: var(--frame); }
.find-box { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; height: 36px; padding: 0 8px 0 10px; background: var(--raised); border: 1px solid var(--line-strong); border-radius: 8px; color: var(--muted); cursor: text; }
.find-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.find-box svg, .map-open svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.find-box input { flex: 1; min-width: 0; padding: 0; border: 0; outline: 0; background: none; color: var(--text); font: inherit; font-size: 14px; }
.find-box input::-webkit-search-cancel-button { display: none; }
.find-box kbd { font-size: 11px; color: var(--muted); }
.find-box:focus-within kbd { visibility: hidden; }
.map-open { flex: none; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; background: var(--raised); border: 1px solid var(--line-strong); border-radius: 8px; color: var(--muted); cursor: pointer; }
.map-open:hover { border-color: var(--accent); color: var(--accent); }
.side.searching nav, .side.searching .side-toggle { display: none; }
.results a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; line-height: 1.4; }
.results a:hover, .results a:focus-visible { background: var(--line); outline: 0; }
.results strong { display: block; font-size: 14px; }
.results span { display: block; font-size: 13px; color: var(--accent); }
.results small { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }
.results mark { background: var(--accent-soft); color: var(--text); border-radius: 3px; padding: 0 1px; }
.results-note { margin: 8px 10px; font-size: 14px; color: var(--muted); }

/* The map of the guide. */
dialog.map { width: min(1100px, calc(100vw - 32px)); height: min(780px, calc(100vh - 32px)); max-width: none; max-height: none; padding: 0; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--sheet); color: var(--text); box-shadow: 0 24px 80px rgba(0, 0, 0, .25); }
dialog.map[open] { display: flex; flex-direction: column; animation: map-in .22s cubic-bezier(.2, .7, .3, 1); }
dialog.map::backdrop { background: rgba(20, 18, 14, .4); animation: map-fade .22s ease; }
@keyframes map-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
@keyframes map-fade { from { opacity: 0; } }
dialog.map header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 20px 0; }
dialog.map h2 { margin: 0; font-size: 18px; }
dialog.map header p { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
.map-close { flex: none; width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--line); color: var(--text); font-size: 22px; line-height: 1; cursor: pointer; }
.map-close:hover { background: var(--line-strong); }
dialog.map svg { flex: 1; min-height: 0; width: 100%; }
.map-edges line { stroke: var(--line-strong); stroke-width: 1.2; transition: stroke .15s, opacity .15s; }
.map-node circle { fill: var(--c); stroke: var(--sheet); stroke-width: 2; transition: r .15s; }
.map-node text { font-size: 11px; fill: var(--muted); paint-order: stroke; stroke: var(--sheet); stroke-width: 3px; stroke-linejoin: round; pointer-events: none; }
.map-node { transition: opacity .15s; outline: 0; }
.map-node.here circle { stroke: var(--text); stroke-width: 2.5; }
.map-node.here text { fill: var(--text); font-weight: 650; }
svg.focus .map-node:not(.lit) { opacity: .25; }
svg.focus .map-edges line:not(.lit) { opacity: .2; }
.map-edges line.lit { stroke: var(--accent); stroke-width: 2; }
.map-node.lit text { fill: var(--text); }
.map-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; margin: 0; padding: 4px 20px 16px; list-style: none; font-size: 13px; color: var(--muted); }
.map-legend li { margin: 0; display: flex; align-items: center; gap: 6px; }
.map-legend li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.g0 { --c: #16774a; } .g1 { --c: #c8553d; } .g2 { --c: #3b6ea8; } .g3 { --c: #b07a1c; }
.g4 { --c: #7a4fa0; } .g5 { --c: #2a8a8a; } .g6 { --c: #a0527a; } .g7 { --c: #6b7a3a; }
@media (prefers-reduced-motion: reduce) { dialog.map[open], dialog.map::backdrop { animation: none; } }

.sheet { margin-block: 12px; margin-inline: 0 12px; padding: 48px 32px 40px; background: var(--sheet); border: 1px solid var(--line); border-radius: 12px; }
main, .pager, .foot { max-width: 760px; margin: 0 auto; }
h1 { font-size: clamp(30px, 5vw, 38px); line-height: 1.2; letter-spacing: -.02em; font-weight: 650; margin: 0 0 10px; }
.lede { font-size: 18px; color: var(--muted); margin: 0 0 32px; }
h2 { font-size: 23px; line-height: 1.35; letter-spacing: -.01em; font-weight: 650; margin: 44px 0 8px; }
h3 { font-size: 18px; font-weight: 650; margin: 28px 0 4px; }
p { margin: 10px 0; }
ul, ol { padding-inline-start: 24px; margin: 10px 0; }
li { margin: 5px 0; }
strong { font-weight: 650; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .9em; background: var(--raised); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; overflow-wrap: anywhere; }
kbd { font: 600 .82em ui-monospace, "Cascadia Code", Consolas, monospace; background: var(--raised); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; white-space: nowrap; }

figure { margin: 22px 0 26px; }
figure a { display: block; }
figure img { display: block; width: 100%; height: auto; background: var(--raised); border: 1px solid var(--line-strong); border-radius: 10px; }
figure.small img { width: auto; max-width: min(100%, 460px); }
figure.video iframe { display: block; width: 100%; aspect-ratio: 16 / 9; background: var(--raised); border: 1px solid var(--line-strong); border-radius: 10px; }
figcaption { margin-top: 8px; font-size: 14px; color: var(--muted); }
.n { display: inline-block; width: 21px; height: 21px; margin: 0 2px; border-radius: 50%; background: var(--marker); color: #fff; font: 700 12px/21px system-ui, sans-serif; text-align: center; vertical-align: 1px; }
.tip { margin: 20px 0; padding: 12px 16px; background: var(--accent-soft); border-radius: 10px; }
.tip.warn { background: color-mix(in srgb, var(--gold-fill) 28%, var(--sheet)); }
.tip p { margin: 0; }
.tip strong:first-child { color: var(--accent); }
.tip.warn strong:first-child { color: var(--gold); }

.table { overflow-x: auto; margin: 16px 0 24px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
th { font-weight: 650; border-bottom-color: var(--line-strong); }

.cards h2 { margin-top: 36px; }
.cards ul { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.cards li { margin: 0; }
.cards a { display: block; height: 100%; padding: 12px 14px; background: var(--raised); border: 1px solid var(--line); border-radius: 10px; color: var(--text); text-decoration: none; }
.cards a:hover { border-color: var(--accent); }
.cards strong { display: block; }
.cards small { color: var(--muted); font-size: 14px; line-height: 1.4; display: block; margin-top: 2px; }

.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--line); }
.pager a { max-width: 48%; text-decoration: none; }
.pager small { display: block; color: var(--muted); }
.pager .next { margin-inline-start: auto; text-align: end; }
.foot { margin-top: 32px; font-size: 14px; color: var(--muted); }
.foot a { color: inherit; margin-inline-end: 14px; }
.lang { max-width: 760px; margin: -24px auto 12px; text-align: end; }
.lang a { display: inline-block; padding: 3px 12px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 14px; color: var(--text); text-decoration: none; }
.lang a:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 860px) {
  .layout { display: block; }
  .side { position: static; height: auto; padding: 14px 16px 6px; overflow: visible; }
  .side-toggle { display: block; margin: 10px 0 0; padding: 8px 12px; width: 100%; background: var(--raised); border: 1px solid var(--line-strong); border-radius: 8px; color: var(--text); font: inherit; text-align: start; }
  .side nav { display: none; }
  .side.open nav { display: block; }
  .sheet { margin: 8px; padding: 28px 16px 28px; }
  .lang { margin-top: -12px; }
}
@media print {
  body { background: #fff; }
  .side, .pager, .foot, .lang, dialog.map { display: none; }
  .layout { display: block; }
  .sheet { border: 0; margin: 0; padding: 0; }
}
dialog.viewer { max-width: none; max-height: none; width: 100vw; height: 100vh; margin: 0; padding: 24px; border: 0; background: rgba(0, 0, 0, .85); display: none; place-items: center; cursor: zoom-out; box-sizing: border-box; }
dialog.viewer[open] { display: grid; }
dialog.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.viewer-close { position: fixed; top: 14px; inset-inline-end: 18px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .15); color: #fff; font-size: 26px; line-height: 1; cursor: pointer; }
