/* WARDOGS Companion — "field manual" theme.
   A printed-manual look, modernised: cream paper, black ink, one dark-red ink for actions,
   a book serif for reading and a typewriter face for numbers and labels. No dark mode. */
:root {
  --paper: #EFE8D6;
  --paper-2: #E7DFCA;     /* sidebar column */
  --plate: #F8F4EA;       /* panels, tiles, tables */
  --plate-2: #F1EBDC;
  --ink: #1A1814;
  --ink-2: #4A463D;
  --ink-3: #7A7566;
  --rule: #B9B098;
  --rule-2: #D7CFB8;
  --red: #8E2A22;
  --red-2: #A8362C;
  --olive: #5B6B3E;
  --good: #3A6B35;
  --bad: #9B2C24;
  --accent: var(--red);
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --mono: "Courier Prime", "Courier New", monospace;
  --ui: var(--serif);
  --head: var(--serif);
  --label: var(--mono);
  --body: var(--serif);
  --prose: var(--serif);
  /* legacy tokens used by page stylesheets written for the dark theme */
  --bg: var(--paper);
  --bg-2: var(--plate-2);
  --panel: var(--plate);
  --panel-solid: var(--plate);
  --panel-hi: var(--plate-2);
  --panel-bg: var(--plate);
  --panel-edge: var(--rule);
  --panel-bar: var(--plate-2);
  --line: var(--rule-2);
  --line-2: var(--rule);
  --text: var(--ink);
  --muted: var(--ink-2);
  --dim: var(--ink-3);
  --accent-dim: rgba(142, 42, 34, .12);
}
* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--serif); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .2 0 0 0 0 .18 0 0 0 0 .12 0 0 0 .06 0'/></filter><rect width='200' height='200' filter='url(%23p)'/></svg>");
}
a { color: inherit; text-decoration: none; }
p a, .prose a, .lede a { text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
img { max-width: 100%; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.good { color: var(--good); } .bad { color: var(--bad); }

/* ---------- type ---------- */
.h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.9rem, 3.4vw, 2.6rem); line-height: 1.1; margin: 0 0 .5rem; letter-spacing: .01em; }
.h2 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.35rem, 2.2vw, 1.7rem); line-height: 1.15; margin: 0 0 .9rem; }
.label { font-family: var(--mono); font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.lede { max-width: 62ch; color: var(--ink-2); margin: 0 0 1.6rem; font-size: 1.02rem; }
.fineprint { font-size: .82rem; color: var(--ink-3); margin: 1rem 0 0; font-family: var(--mono); }
.caps { font-variant: small-caps; letter-spacing: .06em; }

/* chapter heading block used by tool pages (replaces the old photo header strips) */
.chapter { border-bottom: 3px double var(--ink); padding-bottom: .6rem; margin-bottom: 1.4rem; }
.chapter .label { display: block; margin-bottom: .2rem; }

/* ---------- buttons: printed-manual plates ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font-family: var(--mono); font-weight: 700; font-size: .82rem; letter-spacing: .04em; text-transform: uppercase;
  padding: .6rem 1rem; line-height: 1; cursor: pointer; color: var(--ink);
  background: var(--plate); border: 1px solid var(--ink);
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn-primary { background: var(--red); border-color: var(--red); color: #FBF6EA; }
.btn-primary:hover { background: var(--red-2); border-color: var(--red-2); color: #fff; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------- layout ---------- */
.section { max-width: 1200px; margin: 0 auto; padding: 2.2rem 1.8rem 3rem; }
.panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.panel { background: var(--plate); border: 1px solid var(--ink); padding: .9rem 1rem 1rem; }
.panel h3 { margin: 0 0 .3rem; font-family: var(--serif); font-weight: 600; font-size: 1.15rem; }
.panel p { margin: 0; color: var(--ink-2); font-size: .95rem; }

.table-wrap { overflow-x: auto; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); margin-bottom: 1.4rem; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { padding: .55rem .8rem; text-align: left; border-bottom: 1px solid var(--rule-2); white-space: nowrap; }
.table th { font-family: var(--mono); font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); border-bottom: 1px solid var(--ink); }
.table th.num, .table td.num { text-align: right; }
.table td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.conf { font-family: var(--mono); font-size: .66rem; letter-spacing: .05em; text-transform: uppercase; padding: .1rem .35rem; border: 1px solid; }
/* Four provenance tiers. The legacy words are kept as aliases because the raw
   data files still carry them; see apps/core/provenance.py. */
.conf-official { color: var(--good); border-color: var(--good); font-weight: 700; }
.conf-verified { color: var(--ink); border-color: var(--ink); }
.conf-community { color: var(--ink-2); border-color: var(--rule); }
.conf-estimated { color: var(--bad); border-color: var(--bad); }
.conf-confirmed { color: var(--good); border-color: var(--good); }
.conf-reported { color: var(--ink-2); border-color: var(--rule); }
.conf-unconfirmed { color: var(--bad); border-color: var(--bad); }

/* Key that decodes the badges. Collapsed by default so it never competes with
   the data it explains. */
.prov-key { margin: .6rem 0 1.2rem; font-size: .85rem; }
.prov-key > summary {
  cursor: pointer; font-family: var(--mono); font-size: .72rem;
  letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2);
}
.prov-key > summary:hover { color: var(--red); }
.prov-key-list { margin: .6rem 0 0; }
.prov-key-row { display: flex; gap: .6rem; align-items: baseline; margin: .3rem 0; }
.prov-key-row dt { flex: 0 0 auto; min-width: 6.5rem; }
.prov-key-row dd { margin: 0; color: var(--ink-2); }
.prov-key-scope { margin: .6rem 0 0; color: var(--ink-3); font-size: .82rem; }

/* Dataset-level badge, for a page whose numbers all share one source. */
.prov-banner {
  display: flex; flex-wrap: wrap; gap: .5rem .8rem; align-items: baseline;
  border: 1px solid var(--rule); border-left: 3px solid var(--rule);
  padding: .5rem .7rem; margin: 0 0 1rem; font-size: .85rem;
}
.prov-banner.is-estimated { border-left-color: var(--bad); }
.prov-banner.is-community { border-left-color: var(--ink-2); }
.prov-banner.is-official { border-left-color: var(--good); }
.prov-banner-text { color: var(--ink-2); }
@media (max-width: 600px) {
  .prov-key-row { flex-direction: column; gap: .15rem; }
}
.foot { border-top: 1px solid var(--ink); padding: 1rem 1.8rem 1.4rem; display: flex; gap: 1.2rem; justify-content: space-between; flex-wrap: wrap; font-family: var(--mono); font-size: .74rem; color: var(--ink-3); }

/* ---------- builder ---------- */
.builder-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.builder-actions { display: flex; gap: .5rem; }
#build-name { outline: none; min-width: 6ch; border-bottom: 1px dashed var(--rule); }
#build-name:focus { border-bottom-color: var(--red); }
.builder-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr) 270px; gap: 1rem; align-items: start; }
@media (max-width: 1000px) { .builder-grid { grid-template-columns: 1fr; } }
.slots { display: flex; flex-direction: column; gap: 0; border-top: 1px solid var(--ink); }
.slot { display: grid; grid-template-columns: 64px 1fr auto; gap: .05rem .7rem; padding: .5rem .5rem .5rem .3rem; background: transparent; border: 0; border-bottom: 1px solid var(--rule-2); cursor: pointer; text-align: left; color: inherit; font: inherit; }
.slot:hover { background: var(--plate); }
.slot.active { background: var(--plate); box-shadow: inset 3px 0 0 var(--red); }
.slot .k { grid-column: 2; font-family: var(--mono); font-size: .68rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.slot .n { grid-column: 2; font-weight: 500; font-size: .98rem; }
.slot .n.empty { color: var(--ink-3); font-style: italic; }
.slot .p { grid-column: 3; grid-row: 1 / span 2; align-self: center; font-family: var(--mono); font-weight: 700; font-size: .95rem; font-variant-numeric: tabular-nums; }
.slot-img { grid-column: 1; grid-row: 1 / span 2; width: 64px; height: 42px; object-fit: contain; background: #fff; border: 1px solid var(--rule); align-self: center; display: block; padding: 2px; }
.stage { background: var(--plate); border: 1px solid var(--ink); min-height: 420px; padding: 1rem; }
.stage-empty { color: var(--ink-3); text-align: center; padding: 6rem 1rem; font-style: italic; }
.stage-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .7rem; border-bottom: 1px solid var(--ink); padding-bottom: .4rem; }
.stage-head h2 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 1.3rem; }
.search { width: 100%; padding: .55rem .7rem; background: #fff; color: var(--ink); border: 1px solid var(--ink); font: inherit; margin-bottom: .5rem; }
.picklist { display: flex; flex-direction: column; border-top: 1px solid var(--ink); max-height: 60vh; overflow: auto; }
.pick { display: grid; grid-template-columns: 1fr auto auto; gap: .8rem; align-items: center; padding: .5rem .6rem; background: transparent; border: 0; border-bottom: 1px solid var(--rule-2); cursor: pointer; text-align: left; color: inherit; font: inherit; }
.pick:hover { background: #fff; }
.pick.selected { background: #fff; box-shadow: inset 3px 0 0 var(--red); }
.pick .cat { font-family: var(--mono); font-size: .68rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.pick .price { font-family: var(--mono); font-weight: 700; font-size: .95rem; font-variant-numeric: tabular-nums; min-width: 4.5rem; text-align: right; }
.weapon-card { display: grid; grid-template-columns: 1fr; gap: .8rem; }
.weapon-hero { background: #fff; border: 1px solid var(--ink); min-height: 160px; display: grid; place-items: center; text-align: center; padding: 1rem; }
.weapon-hero.has-img { grid-template-rows: auto auto; gap: .4rem; padding: .6rem 1rem .9rem; }
.weapon-hero img { max-height: 220px; width: auto; max-width: 100%; }
.weapon-hero .name { font-family: var(--serif); font-weight: 600; font-size: 1.6rem; line-height: 1; }
.weapon-hero .cat { font-family: var(--mono); font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); margin-top: .3rem; }
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 0; margin: 0; border: 1px solid var(--ink); }
.stat-strip div { background: #fff; padding: .45rem .7rem; border-right: 1px solid var(--rule-2); }
.stat-strip div:last-child { border-right: 0; }
.stat-strip dt { font-family: var(--mono); font-size: .64rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.stat-strip dd { margin: 0; font-family: var(--mono); font-weight: 700; font-size: 1rem; font-variant-numeric: tabular-nums; }
.attach-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .5rem; }
.attach { background: #fff; border: 1px solid var(--rule); padding: .55rem .65rem; }
.attach label { display: block; font-family: var(--mono); font-size: .66rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); margin-bottom: .3rem; }
.attach select { width: 100%; background: #fff; color: var(--ink); border: 1px solid var(--ink); padding: .4rem .45rem; font: inherit; font-size: .95rem; }
.attach .none { color: var(--ink-3); font-size: .85rem; font-style: italic; }
.summary { background: var(--plate); border: 1px solid var(--ink); padding: 0; position: sticky; top: 1rem; }
.panel-title { font-family: var(--mono); font-size: .74rem; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); margin: 0 0 .6rem; }
.big-num { display: flex; justify-content: space-between; align-items: baseline; }
.big-num .k { font-family: var(--mono); font-size: .68rem; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); }
.big-num .v { font-family: var(--mono); font-weight: 700; font-size: 1.8rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.big-num .v.ok { color: var(--good); }
.big-num .v.over { color: var(--bad); }
.bar { height: 6px; background: var(--rule-2); margin: .5rem 0 .8rem; border: 1px solid var(--rule); }
.bar i { display: block; height: 100%; background: var(--ink); transition: width .2s; }
.bar i.over { background: var(--bad); }
.kv { display: flex; justify-content: space-between; font-size: .9rem; color: var(--ink-2); padding: .4rem 0; border-top: 1px solid var(--rule-2); }
.kv span:last-child { color: var(--ink); font-family: var(--mono); font-weight: 700; }
.chips { display: flex; gap: 0; margin: .8rem 0 .2rem; border: 1px solid var(--ink); }
.chip { flex: 1; display: grid; gap: .1rem; text-align: center; font-family: var(--mono); font-size: .68rem; letter-spacing: .03em; text-transform: uppercase; padding: .38rem .2rem; border-right: 1px solid var(--ink); color: var(--ink-2); line-height: 1.1; background: #fff; }
/* only the segmented bar doubles its border against the strip edge; standalone .chip plates
   on economy/progression/skills keep all four sides (:where keeps this at .chip:last-child weight) */
.chip:where(.chips > *):last-child { border-right: 0; }
.chip small { font-size: .62rem; letter-spacing: 0; text-transform: none; font-variant-numeric: tabular-nums; opacity: .85; }
.chip.on { background: var(--ink); color: var(--paper); }
.chip.over { color: var(--bad); }
.toast { position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: .55rem .9rem; font-family: var(--mono); font-size: .85rem; z-index: 50; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* guides keep the reading face */
.guide p, .guide li, .guide td, .guide dd, .lede { font-family: var(--serif); }
