/* Rejoice! The Complete Guide. The game's slate and gold, on parchment. */
:root {
  --bg: #fbf8f2;
  --surface: #ffffff;
  --surface-2: #f3eee4;
  --ink: #23272d;
  --muted: #5f6670;
  --rule: #e2dbcd;
  --gold: #9a7412;
  --gold-soft: #f4e7c2;
  --slate: #2d333b;
  --slate-ink: #ece6da;
  --pos: #2f7a3d;
  --pos-bg: #e3f1e4;
  --neg: #a8352b;
  --neg-bg: #f7e1de;
  --zero-bg: #eeebe4;
  --tip: #e9f1f8;
  --tip-rule: #4f7fa8;
  --warn: #fbefe0;
  --warn-rule: #c27a1a;
  --shadow: 0 1px 2px rgba(30, 30, 30, .06), 0 4px 16px rgba(30, 30, 30, .06);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15181c;
    --surface: #1d2126;
    --surface-2: #23282e;
    --ink: #e8e3d9;
    --muted: #a3a9b1;
    --rule: #333a42;
    --gold: #e2b94a;
    --gold-soft: #3a3220;
    --slate: #0f1215;
    --slate-ink: #e8e3d9;
    --pos: #7fd08c;
    --pos-bg: #1f3324;
    --neg: #f08a7e;
    --neg-bg: #3a2220;
    --zero-bg: #2a2f35;
    --tip: #1c2a36;
    --tip-rule: #6fa3cf;
    --warn: #33291a;
    --warn-rule: #e0a24a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #15181c; --surface: #1d2126; --surface-2: #23282e; --ink: #e8e3d9; --muted: #a3a9b1;
  --rule: #333a42; --gold: #e2b94a; --gold-soft: #3a3220; --slate: #0f1215; --slate-ink: #e8e3d9;
  --pos: #7fd08c; --pos-bg: #1f3324; --neg: #f08a7e; --neg-bg: #3a2220; --zero-bg: #2a2f35;
  --tip: #1c2a36; --tip-rule: #6fa3cf; --warn: #33291a; --warn-rule: #e0a24a; color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-padding-top: 16px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.65 var(--sans);
  -webkit-text-size-adjust: 100%;
}

/* --- Layout --- */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 280px;
  overflow-y: auto;
  background: var(--slate);
  color: var(--slate-ink);
  padding: 28px 18px 40px;
}

main {
  margin-left: 280px;
  max-width: 980px;
  padding: 40px 56px 64px;
}

.brand {
  display: block;
  color: #e8c35a;
  text-decoration: none;
  font: 700 28px/1.1 var(--serif);
  margin: 0 8px 24px;
}

.brand small {
  display: block;
  color: #b9b2a4;
  font: 500 13px/1.6 var(--sans);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-top: 6px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid #e8c35a;
  border-radius: 50%;
  font-size: 18px;
  vertical-align: 3px;
  margin-right: 4px;
}

.sidebar ol { list-style: none; margin: 0; padding: 0; }

.sidebar li a {
  display: flex;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  color: #d9d3c7;
  text-decoration: none;
  font-size: 15px;
  line-height: 1.35;
}

.sidebar li a:hover { background: rgba(255, 255, 255, .06); }

.sidebar li.current a { background: #c9a227; color: #1d1a12; font-weight: 600; }

.sidebar .num {
  flex: 0 0 22px;
  text-align: right;
  color: #8f877a;
  font-variant-numeric: tabular-nums;
}

.sidebar li.current .num { color: #3d3420; }

.nav-toggle, .nav-button { display: none; }

/* --- Type --- */

h1, h2, h3, h4 { font-family: var(--serif); line-height: 1.2; color: var(--ink); }

h1 { font-size: 44px; margin: 0 0 8px; }

h2 {
  font-size: 30px;
  margin: 56px 0 14px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
}

h3 { font-size: 22px; margin: 34px 0 10px; }

h4 { font-size: 18px; margin: 24px 0 8px; }

p, ul, ol, table, dl { margin: 0 0 16px; }

a { color: var(--gold); text-underline-offset: 2px; }

strong { font-weight: 650; }

code, kbd {
  font: 14px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1px 5px;
}

kbd { box-shadow: inset 0 -1px 0 var(--rule); white-space: nowrap; }

.chapter-head { margin-bottom: 28px; }

.kicker {
  color: var(--gold);
  font: 600 13px/1 var(--sans);
  letter-spacing: .12em;
  text-transform: uppercase;
  margin: 0 0 10px;
}

.lede { font-size: 20px; line-height: 1.6; color: var(--muted); }

.formula {
  font: 600 19px/1.5 var(--serif);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--gold);
  border-radius: 6px;
  padding: 12px 18px;
  box-shadow: var(--shadow);
}

/* --- Figures --- */

.figure { margin: 24px 0 30px; }

.figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--rule);
  box-shadow: var(--shadow);
  background: var(--surface-2);
}

.figure figcaption { font-size: 14.5px; color: var(--muted); margin-top: 8px; line-height: 1.5; }

.figure-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.figure-pair .figure { margin: 18px 0; }

/* --- Callouts --- */

.tip, .warn, .key {
  border-radius: 8px;
  padding: 14px 18px;
  margin: 22px 0;
  border-left: 4px solid;
}

.tip { background: var(--tip); border-color: var(--tip-rule); }

.warn { background: var(--warn); border-color: var(--warn-rule); }

.key { background: var(--gold-soft); border-color: var(--gold); }

.tip > :last-child, .warn > :last-child, .key > :last-child { margin-bottom: 0; }

.tip::before, .warn::before, .key::before {
  display: block;
  font: 700 12px/1 var(--sans);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.tip::before { content: "Tip"; color: var(--tip-rule); }

.warn::before { content: "Watch out"; color: var(--warn-rule); }

.key::before { content: "Key idea"; color: var(--gold); }

/* --- Tables --- */

.table-wrap { overflow-x: auto; margin: 0 0 20px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15.5px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
}

th, td { text-align: left; vertical-align: top; padding: 9px 12px; border-bottom: 1px solid var(--rule); }

th { background: var(--surface-2); font-weight: 650; font-size: 14px; }

tr:last-child td { border-bottom: 0; }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --- Contents page --- */

.cover {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 32px;
  align-items: center;
  margin-bottom: 36px;
}

.cover h1 { font-size: 56px; }

.cover img { width: 100%; border-radius: 10px; box-shadow: var(--shadow); border: 1px solid var(--rule); }

.chapter-grid {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.chapter-grid a {
  display: block;
  height: 100%;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.chapter-grid a:hover { border-color: var(--gold); }

.chapter-grid b { display: block; font: 700 19px/1.25 var(--serif); margin-bottom: 4px; }

.chapter-grid .n { color: var(--gold); font: 600 12px/1 var(--sans); letter-spacing: .1em; text-transform: uppercase; }

.chapter-grid span.d { display: block; color: var(--muted); font-size: 14.5px; line-height: 1.45; margin-top: 6px; }

/* --- Item catalogue --- */

.item-toc ul { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; }

.item-toc li a {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--rule);
  border-radius: 99px;
  background: var(--surface);
  text-decoration: none;
}

.item-toc .count { color: var(--muted); font-size: 13px; margin-left: 2px; }

.chips { font-size: 14px; line-height: 2; }

.chips a { white-space: nowrap; margin-right: 10px; }

.item-card {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 22px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 18px;
  margin: 18px 0;
  box-shadow: var(--shadow);
}

.item-card:target { outline: 3px solid var(--gold); outline-offset: 2px; }

.item-pic { display: block; text-decoration: none; }

.item-pic img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  background: #f1ece2;
  border: 1px solid var(--rule);
}

.illustration { display: block; font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.4; }

.item-body h3 { margin: 2px 0 6px; display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }

.price { font: 650 17px/1 var(--sans); color: var(--gold); white-space: nowrap; }

.desc { color: var(--muted); font-style: italic; }

.stats {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 3px 14px;
  font-size: 14.5px;
  margin-bottom: 12px;
}

.stats dt { color: var(--muted); }

.stats dd { margin: 0; }

.tip-line {
  font-size: 15px;
  background: var(--gold-soft);
  border-radius: 6px;
  padding: 8px 12px;
}

.fit-label { font: 600 12px/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 12px 0 8px; }

.fit {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.fit li {
  border-radius: 6px;
  padding: 6px 4px 7px;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.25;
  background: var(--zero-bg);
}

.fit li span { display: block; color: var(--muted); font-size: 11.5px; }

.fit li b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }

.fit li.pos { background: var(--pos-bg); }

.fit li.pos b { color: var(--pos); }

.fit li.neg { background: var(--neg-bg); }

.fit li.neg b { color: var(--neg); }

.need {
  display: inline-block;
  margin-top: 3px;
  font: 700 9.5px/1 var(--sans);
  font-style: normal;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 5px;
  border-radius: 3px;
  color: #fff;
}

.need.required { background: #8a5a0c; }

.need.expected { background: #3d6b8f; }

.need.discouraged { background: #9b3b31; }

/* --- Pager --- */

.pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
}

.pager a {
  flex: 1;
  max-width: 48%;
  padding: 14px 18px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  text-decoration: none;
  font: 600 17px/1.3 var(--serif);
}

.pager a span { display: block; font: 600 12px/1.6 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.pager .next { margin-left: auto; text-align: right; }

/* --- Narrow screens --- */

@media (max-width: 960px) {
  .sidebar {
    position: static;
    width: auto;
    display: none;
    padding: 16px;
  }

  .nav-button {
    display: block;
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--slate);
    color: #e8c35a;
    font: 600 15px/1 var(--sans);
    padding: 14px 16px;
    cursor: pointer;
  }

  .nav-button::before { content: "\2630  "; }

  .nav-toggle:checked ~ .sidebar { display: block; }

  main { margin-left: 0; padding: 24px 16px 48px; }

  h1 { font-size: 34px; }

  .cover { grid-template-columns: 1fr; }

  .cover h1 { font-size: 42px; }

  .item-card { grid-template-columns: 1fr; }

  .fit { grid-template-columns: repeat(3, 1fr); }

  .figure-pair { grid-template-columns: 1fr; }
}
