/* Docs pages: rules, getting-started, api, cli, downloads. Loaded after site.css.
   Layout and a few page parts only; colours and type come from site.css variables. */

/* ---------------------------------------------------------------- layout, contents */
.docs-layout { grid-template-columns: minmax(0, 1fr) 220px; gap: var(--s-7); }
/* the site sidebar takes ~250px, so the page contents fold up below 1200px */
@media (max-width: 1200px) { .docs-layout { grid-template-columns: minmax(0, 1fr); } .docs-aside { display: none; } }
.docs-aside .toc { max-height: calc(100vh - var(--header-h, 64px) - 96px); overflow-y: auto; scrollbar-width: thin; }
.docs-aside .kicker { margin-bottom: var(--s-3); }
.toc .toc-sub a { padding-left: 1.75em; font-size: var(--fs-xs); }

/* the same list as a fold-out where the sidebar hides */
.docs-toc-mobile { display: none; margin-bottom: var(--s-5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.docs-toc-mobile > summary { cursor: pointer; padding: var(--s-3) var(--s-4); color: var(--text-dim); }
.docs-toc-mobile .toc { margin: 0 var(--s-4) var(--s-3); columns: 2 11em; column-gap: var(--s-5); }
.docs-toc-mobile .toc li { break-inside: avoid; }
@media (max-width: 1200px) { .docs-toc-mobile { display: block; } }

.docs-section { padding-block: var(--s-6); border-bottom: 1px solid var(--line); }
.docs-section:first-of-type { padding-top: 0; }
.docs-section:last-child { border-bottom: 0; }
.docs-section > h2 { margin-top: 0; }
.docs-section .prose { max-width: 76ch; }
.docs-section h3 { margin-top: var(--s-5); }
.section-num { color: var(--muted); font-variant-numeric: lining-nums tabular-nums; margin-right: 0.6em; }

/* ---------------------------------------------------------------- rules page parts */
.facts { margin-bottom: var(--s-6); }

.spec-list { display: grid; grid-template-columns: max-content 1fr; gap: var(--s-2) var(--s-5); margin: 0 0 var(--s-4); }
.spec-list dt { color: var(--muted); }
.spec-list dd { margin: 0; }
@media (max-width: 520px) {
  .spec-list { grid-template-columns: 1fr; gap: 0; }
  .spec-list dd { margin-bottom: var(--s-3); }
}

.phase-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3); margin: 0 0 var(--s-5); padding: 0; list-style: none; counter-reset: phase; }
.phase-grid > li { margin: 0; counter-increment: phase; }
.phase-grid .card { height: 100%; }
.phase-grid .card-meta::before { content: "0" counter(phase) "  "; color: var(--muted); }
@media (max-width: 960px) { .phase-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .phase-grid { grid-template-columns: minmax(0, 1fr); } }

/* the order of one raid round: attacker steps gold, defender steps silver */
.round-order { counter-reset: ro; list-style: none; padding: 0; margin: 0 0 var(--s-4); }
.round-order > li { counter-increment: ro; position: relative; margin: 0; padding: var(--s-2) var(--s-3) var(--s-2) 44px; border-top: 1px solid var(--line); }
.round-order > li:first-child { border-top: 0; }
.round-order > li::before { content: counter(ro); position: absolute; left: var(--s-2); top: var(--s-2); width: 24px; text-align: center; color: var(--muted); font-variant-numeric: lining-nums tabular-nums; }
.round-order > li.ro-att::before { color: var(--team-a-text, var(--team-a)); }
.round-order > li.ro-def::before { color: var(--team-b-text, var(--team-b)); }

/* map diagram */
.map-figure { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: var(--s-5); align-items: center; margin: 0 0 var(--s-5); }
.map-box { aspect-ratio: 1; padding: var(--s-2); display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.map-svg { display: block; width: 100%; height: auto; max-height: 100%; }
.mz-base { fill: var(--surface); }
.mz-deploy { fill: color-mix(in srgb, var(--accent) 30%, var(--surface)); }
.mz-scout { fill: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.mz-rock { fill: var(--map-rock); }
.map-legend { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s-2); }
.map-legend li { margin: 0; display: grid; grid-template-columns: 16px 1fr; gap: var(--s-3); align-items: start; font-size: var(--fs-sm); }
.map-legend i { display: block; width: 16px; height: 16px; margin-top: 3px; border: 1px solid var(--line-2); }
.map-legend .mz-base { background: var(--surface); }
.map-legend .mz-deploy { background: color-mix(in srgb, var(--accent) 30%, var(--surface)); }
.map-legend .mz-scout { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.map-legend .mz-rock { background: var(--map-rock); }
.map-caption { margin-top: var(--s-3); color: var(--muted); font-size: var(--fs-xs); }
@media (max-width: 640px) { .map-figure { grid-template-columns: minmax(0, 1fr); } .map-box { max-width: 300px; } }

/* base inventory chips, linking into the codex */
.inventory { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: 0 0 var(--s-4); }
.inv-chip { display: inline-flex; align-items: center; gap: var(--s-2); padding: 2px var(--s-2) 2px 4px; font-size: var(--fs-xs); color: var(--text-dim); text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.inv-chip b { color: var(--text); font-weight: 600; }
.inv-chip:hover { color: var(--accent); border-color: var(--accent-line); }
.px-icon { display: block; flex: none; image-rendering: pixelated; }

/* ---------------------------------------------------------------- codex */
.codex-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-3) var(--s-4); margin-bottom: var(--s-4); border-bottom: 1px solid var(--line); }
.codex-toolbar .tabs { margin-bottom: 0; border-bottom: 0; min-width: 0; }
.codex-toolbar .segmented { margin-bottom: var(--s-2); }
.codex .tab-panel > p { margin-bottom: var(--s-4); }
.codex[data-view="cards"] .tab-panel > .table-wrap { display: none; }
.codex[data-view="table"] .codex-cards { display: none; }
.codex-cards { --min: 250px; --grid-gap: var(--s-3); }
.codex-card { gap: var(--s-2); }
.codex-card:target { outline: 1px solid var(--line-3, var(--line-2)); outline-offset: 2px; }
.codex-head { display: flex; align-items: center; gap: var(--s-3); }
/* the pixel icons use the game's bright sprite colours (js/docs.js), so they sit on a dark ink tile */
.codex-icon { flex: none; display: grid; place-items: center; width: 44px; height: 44px; background: var(--surface-3); border: 1px solid var(--line-2); border-radius: var(--radius); }
.codex-name { min-width: 0; flex: 1; }
.codex-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-2); }
.codex-name .card-title { margin: 0; }
.codex-rust { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); background: none; border: 0; box-shadow: none; padding: 0; white-space: nowrap; }
.codex-meta { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; font-variant-numeric: lining-nums tabular-nums; }
.codex-note { margin: 0; font-size: var(--fs-sm); color: var(--text-dim); }
.codex-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.codex-tags:empty { display: none; }
.codex-kv { grid-template-columns: max-content 1fr; gap: 2px var(--s-3); align-items: baseline; padding-top: var(--s-2); border-top: 1px solid var(--line); }
.codex-kv dd { font-size: var(--fs-sm); }
.codex-kv dd { text-align: right; font-variant-numeric: lining-nums tabular-nums; }
.codex-table th[scope="row"] { font-family: var(--font-body); font-size: var(--fs-sm); font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--text); background: transparent; white-space: nowrap; }
.codex-table thead th { white-space: normal; vertical-align: bottom; }
.codex-table thead th[title] { cursor: help; }
.codex-row-name { display: inline-flex; align-items: center; gap: var(--s-2); }
.codex-loading { display: grid; gap: var(--s-3); padding: var(--s-5) 0; }
.const-table td:first-child code { white-space: nowrap; }
@media (max-width: 640px) {
  .codex-kv { grid-template-columns: max-content 1fr max-content 1fr; column-gap: var(--s-3); }
  .codex-kv dd { font-size: var(--fs-xs); }
}

/* ---------------------------------------------------------------- api and cli references */
.sig-table td { vertical-align: top; }
.sig-table td:first-child { width: 50%; }
.sig-table code { white-space: pre-wrap; overflow-wrap: anywhere; }
.sig-table .cost { white-space: nowrap; text-align: right; color: var(--muted); font-variant-numeric: lining-nums tabular-nums; }
.sig-table .cost b { color: var(--text); font-weight: 600; }
@media (max-width: 640px) {
  .sig-table, .sig-table tbody, .sig-table tr, .sig-table td { display: block; width: auto !important; }
  .sig-table thead { display: none; }
  .sig-table tr { padding: var(--s-2) 0; border-bottom: 1px solid var(--line); }
  .sig-table td { padding: 2px 0; border: 0; text-align: left; }
  .sig-table td.cost:not(:empty)::before { content: "Bytecode "; }
}
.code-note { margin: calc(-1 * var(--s-2)) 0 var(--s-4); font-size: var(--fs-xs); color: var(--muted); }
.filetree .dir { color: var(--text); }
.filetree .note { color: var(--muted); }
details.code-full { margin-top: var(--s-4); }
details.code-full > summary { cursor: pointer; color: var(--text-dim); margin-bottom: var(--s-3); }
.out-pre { color: var(--text-dim); }
.cmd-name { font-weight: 600; }

/* getting started: room for code under each step */
.gs-steps > li > .code, .gs-steps > li > .callout, .gs-steps > li > .table-wrap, .gs-steps > li > .grid { margin-top: var(--s-3); }
.gs-steps > li > p { max-width: 74ch; }

/* ---------------------------------------------------------------- downloads */
.dl-grid { --min: 300px; }
.dl-card .icon-tile .px-icon { width: 28px; height: 28px; }
.dl-card ul { margin: 0; padding-left: 1.1em; font-size: var(--fs-sm); color: var(--text-dim); }
.dl-size { font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: lining-nums tabular-nums; }
.dl-size b { color: var(--text); font-weight: 600; }
.version-kv dd code { overflow-wrap: anywhere; }
.changes { margin: 0; }
.map-svg .mz-gridline { stroke: var(--bg); stroke-opacity: 0.5; }
.map-svg .mz-edge { stroke: var(--line-2); }
/* inline code in tables breaks at spaces, not inside names */
.docs-section .table code { overflow-wrap: normal; word-break: normal; }
.docs-section .table:not(.sig-table) td > code:only-child { white-space: nowrap; }
