/* Ninjaverse Docs — light documentation theme.
 *
 * Deliberately NOT the wiki's stylesheet. The wiki is a dark in-world browser; this
 * is a manual, and a manual is read on white. Everything here is self-contained, so
 * this module no longer reads anything out of wiki/.
 *
 * The only piece of the game's own look that carries over is the pixel wordmark and
 * the amber accent — enough to be recognisably Ninjaverse without asking anyone to
 * read tables of numbers off a dark background. */

:root {
  color-scheme: light;

  --bg: #ffffff;
  --bg-soft: #fafaf9;
  --bg-code: #f5f5f4;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;

  --text: #1c1917;
  --text-muted: #57534e;
  --text-faint: #78716c;

  --accent: #b45309;
  --accent-soft: #fef3c7;
  --accent-line: #f59e0b;

  --good: #15803d;
  --good-soft: #f0fdf4;
  --info-soft: #f0f9ff;
  --info-line: #38bdf8;

  --font-pixel: 'Press Start 2P', monospace;
  --font-body: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  --sidebar-w: 248px;
  --content-w: 780px;

  /* Icon sprite scale: the atlas is a 1024px logical sheet; --s scales it up. */
  --s: 2;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip {
  position: absolute; left: -9999px;
  background: var(--accent); color: #fff; padding: 10px 16px; z-index: 100;
}
.skip:focus { left: 12px; top: 12px; }

/* ---------------------------------------------------------------- top bar */

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  height: 60px; padding: 0 24px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex; align-items: baseline; gap: 10px;
  color: var(--text); font-family: var(--font-pixel); font-size: 0.8125rem;
}
.brand:hover { text-decoration: none; }
.brand-sub {
  font-family: var(--font-body); font-size: 0.6875rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: #fff; background: var(--accent);
  padding: 3px 7px; border-radius: 4px;
}
.topbar nav { display: flex; gap: 20px; font-size: 0.875rem; }
.topbar nav a { color: var(--text-muted); }
.topbar nav a:hover { color: var(--accent); }

/* --------------------------------------------------------------- the shell */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  max-width: 1180px; margin: 0 auto;
}

.sidebar { border-right: 1px solid var(--border); }
.side-inner { position: sticky; top: 60px; padding: 28px 16px 40px; }
.side-head {
  font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-faint);
  padding: 0 10px 8px;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  padding: 8px 10px; border-radius: 6px;
  color: var(--text-muted); font-size: 0.9375rem;
}
.sidebar nav a:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.sidebar nav a.active {
  background: var(--accent-soft); color: #92400e; font-weight: 600;
}

main {
  min-width: 0;
  max-width: var(--content-w);
  padding: 40px 40px 80px;
}
main > :first-child { margin-top: 0; }

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

h1, h2, h3 { line-height: 1.3; }

.page-title {
  font-family: var(--font-pixel);
  font-size: 1.375rem;
  margin: 0 0 12px;
  color: var(--text);
}
.page-intro {
  font-size: 1.0625rem; color: var(--text-muted);
  margin: 0 0 28px; padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.section-title {
  font-size: 1.3125rem; font-weight: 700;
  margin: 46px 0 10px; scroll-margin-top: 76px;
}
h3 { font-size: 1.0625rem; margin: 30px 0 8px; }

p { margin: 0 0 16px; }
ul, ol { margin: 0 0 16px; padding-left: 22px; }
li { margin-bottom: 7px; }

code {
  font-family: var(--font-mono); font-size: 0.875em;
  background: var(--bg-code); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px;
}

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

.tw { overflow-x: auto; overscroll-behavior-x: contain; margin: 18px 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.9375rem; }
th, td {
  text-align: left; padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
thead th {
  background: var(--bg-soft);
  border-bottom: 2px solid var(--border-strong);
  font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
}
tbody tr:hover { background: var(--bg-soft); }
tbody tr:last-child td { border-bottom: none; }
tr.tot td { border-top: 2px solid var(--border-strong); font-weight: 700; background: var(--bg-soft); }

.n { font-family: var(--font-mono); font-size: 0.9375em; white-space: nowrap; }
.n .tag { font-family: var(--font-body); }
.nw { white-space: nowrap; }
.tag { color: var(--text-faint); font-size: 0.8125rem; }
.up { color: var(--good); font-weight: 600; }

/* Provenance line under a table. Quiet, but always there. */
.src {
  margin: -10px 0 22px;
  font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-faint);
}
.src code { background: none; border: none; padding: 0; color: inherit; }

/* ------------------------------------------------------------------ icons */

.icon {
  display: inline-block; vertical-align: middle;
  image-rendering: pixelated;
  background-image: url("IconAtlas0.png");
  background-repeat: no-repeat;
  width: calc(var(--w) * var(--s) * 1px);
  height: calc(var(--h) * var(--s) * 1px);
  background-size: calc(1024px * var(--s)) calc(1024px * var(--s));
  background-position: calc(var(--x) * var(--s) * -1px) calc(var(--y) * var(--s) * -1px);
}
.icon--lg { --s: 3; }
.icon--empty {
  width: calc(16px * var(--s)); height: calc(16px * var(--s));
  border: 1px dashed var(--border-strong); border-radius: 3px;
}
/* An icon with its name beside it — the standard way an item appears in a table.
   flex-start, not center: the label can carry a second line under it, and the art
   should sit against the name rather than float halfway down the pair. */
.item { display: flex; align-items: flex-start; gap: 9px; }
.item + .item { margin-top: 8px; }
.item strong { font-weight: 600; }
.item .icon { flex: none; margin-top: 1px; }
/* The qualifier under an item name — "tradable ore", "up to 100,000 a pour". Its own
   line, so a long one cannot wrap itself around the sprite. */
.item .sub { display: block; color: var(--text-faint); font-size: 0.8125rem; line-height: 1.4; }

/* A currency with its coin in front of its name. Never breaks between the two. */
.money { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.money .icon { flex: none; }

/* ------------------------------------------------------------- components */

/* The headline figures at the top of a page. */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 12px; margin: 24px 0 28px;
}
.stats div {
  background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 16px;
}
.stats .k {
  display: block; font-size: 0.6875rem; font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 5px;
}
.stats .v { font-size: 1.25rem; font-weight: 700; font-family: var(--font-mono); }
.stats .v.up { color: var(--good); }
.stats .v.hi { color: var(--accent); }

/* Cards on the landing page. */
.grid { display: grid; gap: 18px; margin: 24px 0; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.card {
  display: block; padding: 22px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  color: inherit;
}
.card:hover { border-color: var(--accent-line); text-decoration: none; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05); }
.card h2 { margin: 0 0 6px; font-size: 1.125rem; }
.card .lede { color: var(--text-muted); font-size: 0.9375rem; margin: 0 0 14px; }
.card .cta { color: var(--accent); font-weight: 600; font-size: 0.875rem; }

/* Callouts. `note` is neutral, `tip` is the good news, `heads-up` is the caveat —
   which is a sentence in a box, not a warning banner. */
.note, .tip, .heads-up {
  border: 1px solid var(--border); border-left: 4px solid var(--border-strong);
  border-radius: 6px; padding: 14px 18px; margin: 20px 0;
  background: var(--bg-soft);
}
.note p:last-child, .tip p:last-child, .heads-up p:last-child { margin-bottom: 0; }
.tip { background: var(--good-soft); border-left-color: var(--good); }
.heads-up { background: var(--info-soft); border-left-color: var(--info-line); }
.note strong:first-child, .tip strong:first-child, .heads-up strong:first-child { color: var(--text); }

/* Worked arithmetic — a reader should be able to redo it by hand. */
.worked {
  background: var(--bg-code); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px 18px; margin: 20px 0;
  font-family: var(--font-mono); font-size: 0.875rem; line-height: 1.75;
  overflow-x: auto;
}
.worked .lbl { color: var(--text-faint); }
.worked .rule { display: block; border-top: 1px solid var(--border-strong); margin: 9px 0; }
.worked .out { color: var(--accent); font-weight: 700; }

/* Numbered stage list. */
.flow { counter-reset: stage; list-style: none; padding: 0; margin: 22px 0; }
.flow > li { position: relative; padding: 0 0 20px 46px; }
.flow > li::before {
  counter-increment: stage; content: counter(stage);
  position: absolute; left: 0; top: 1px;
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 50%; background: var(--accent-soft); color: #92400e;
  font-weight: 700; font-size: 0.875rem;
}
.flow h3 { margin: 3px 0 4px; font-size: 1rem; }
.flow p { margin: 0; color: var(--text-muted); }

/* In-page contents. */
.toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 24px; }
.toc a {
  font-size: 0.8125rem; padding: 5px 11px;
  border: 1px solid var(--border); border-radius: 999px;
  color: var(--text-muted); background: var(--bg-soft);
}
.toc a:hover { color: var(--accent); border-color: var(--accent-line); text-decoration: none; }

footer {
  border-top: 1px solid var(--border);
  padding: 28px 24px 40px; margin-top: 40px;
  text-align: center; color: var(--text-faint); font-size: 0.875rem;
}
footer a { color: var(--text-muted); margin: 0 10px; }

/* ------------------------------------------------------------ small screens */

@media (max-width: 940px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
  .side-inner { position: static; padding: 12px 16px; }
  .side-head { display: none; }
  .sidebar nav { flex-direction: row; overflow-x: auto; gap: 6px; }
  .sidebar nav a { white-space: nowrap; }
  main { padding: 28px 20px 60px; }
}
@media (max-width: 620px) {
  .topbar { padding: 0 16px; }
  .topbar nav { gap: 14px; font-size: 0.8125rem; }
  .page-title { font-size: 1.0625rem; }
}
