/* Lair Flair design tokens and shared base styles, used by every page of the editor.
 * The look is the hcpoe.tools hub's "Field Manual" (picked by Ben on 2026-12-05): dark by default with a light
 * toggle, condensed uppercase headings, a plain technical body, square corners and one purple accent.
 * The colour values and fonts are the hub's (hub/public/static/hub.css); tools/test/hub-tokens.test.js fails
 * if they drift apart, so change the hub first and then copy here. No art from the game. Fonts are self-hosted
 * (CSP default-src 'self').
 * Every colour, size and radius is a token on :root, so the light theme is just another token set
 * (:root[data-theme="light"], set by hub-theme.js). The map keeps its dark colours in both themes.
 * The editor layout lives in theme.css; other pages add their own small layout styles.
 */

:root {
  /* Colour: surfaces, darkest to lightest (hub: band #0b0b0a, bg #121211, panel #191917) */
  --c-bg: #121211;
  --c-surface: #121211;
  --c-raised: #191917;
  --c-sunken: #0b0b0a;
  --c-hover: #22221f;
  --c-line: #34332f;
  --c-line-strong: #4d4b45;
  --c-float: rgba(18, 18, 17, .95);       /* panels that float over the map */
  --c-float-ring: rgba(11, 11, 10, .9);

  /* Colour: text */
  --c-text: #ece9df;
  --c-text-muted: #a9a59a;
  --c-text-faint: #8f8b81;  /* 4.5:1 or better on surfaces and hover */
  --c-heading: #ece9df;

  /* Colour: accent and states. One accent: purple. */
  --c-accent: #a78bfa;         /* accent fills and borders; text on it is --c-accent-ink */
  --c-accent-strong: #c4b5fd;  /* accent as text */
  --c-accent-ink: #121211;
  --c-accent-soft: #2a2340;
  --c-select: #c4b5fd;
  --c-select-soft: #2a2340;
  --c-owned: #7cb6ff;
  --c-danger: #ff7a6b;
  --c-danger-soft: #3a1814;
  --c-ok: #8fcf8a;
  --c-focus: #a78bfa;

  /* Colour: the map canvas (read once by editor.js and the map layers; 6-digit hex only).
     The map stays dark in the light theme too, so these are not overridden there. */
  --c-map-bg: #0e0e0d;
  --c-map-grid: #191917;
  --c-map-grid-major: #242420;
  --c-map-floor: #36352f;         /* walkable floor */
  --c-map-floor-unsure: #3b3448;  /* walkable, but a random tile variant */
  --c-map-void-unsure: #1b1820;   /* not walkable here, but may be in game */
  --c-map-edge: #77746a;
  --c-map-interactive: #7cb6ff;   /* stash, waypoint, NPCs */
  --c-map-label: #ece9df;
  --c-map-measure: #e6c84a;       /* the measure ruler (measure-tool.js) */
  --c-map-select: #c4b5fd;        /* selected pieces */
  --c-map-off: #ff7a6b;           /* pieces off the floor */
  --c-map-handle: #0b0b0a;        /* rotate handle fill */
  --c-map-added: #8fcf8a;         /* compare: added pieces */

  /* Type: the hub's fonts */
  --font-ui: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-caps: var(--font-display);
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, Menlo, monospace;
  --display-case: uppercase;      /* display and caps text is set in capitals */
  --tracking-display: .02em;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --lh: 1.45;
  --tracking-caps: .04em;

  /* Space (4px scale) */
  --sp-1: 2px;
  --sp-2: 4px;
  --sp-3: 6px;
  --sp-4: 8px;
  --sp-5: 12px;
  --sp-6: 16px;
  --sp-7: 24px;

  /* Shape and depth: square corners, plain rules */
  --r-sm: 0;
  --r-md: 0;
  --r-lg: 0;
  --rule-double: 1px solid var(--c-line-strong);
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, .6);
  --control-h: 30px;

  /* Layout */
  --side-left: 300px;
  --side-right: 290px;

  /* Old names, kept so feedback.js and editor.js styles keep working */
  --bg: var(--c-sunken);
  --panel: var(--c-surface);
  --panel2: var(--c-raised);
  --line: var(--c-line);
  --text: var(--c-text);
  --muted: var(--c-text-muted);
  --accent: var(--c-accent-strong);
  --sel: var(--c-select);
  --danger: var(--c-danger);

  color-scheme: dark;
  accent-color: var(--c-accent);
}

/* Light theme: the hub's light tokens. The map colours above stay as they are. */
:root[data-theme="light"] {
  --c-bg: #f3f1ea;
  --c-surface: #f3f1ea;
  --c-raised: #fbfaf6;
  --c-sunken: #e8e5db;
  --c-hover: #e3dfd3;
  --c-line: #cfcabd;
  --c-line-strong: #b9b5aa;
  --c-float: #fbfaf6;   /* solid in light: text under a see-through light panel shows through */
  --c-float-ring: rgba(232, 229, 219, .9);
  --c-text: #141414;
  --c-text-muted: #55524a;
  --c-text-faint: #615e56;
  --c-heading: #141414;
  --c-accent: #a78bfa;
  --c-accent-strong: #6d28d9;
  --c-accent-ink: #121211;
  --c-accent-soft: #e9e1fb;
  --c-select: #6d28d9;
  --c-select-soft: #e9e1fb;
  --c-owned: #1d5fae;
  --c-danger: #b3261e;
  --c-danger-soft: #f7dcd8;
  --c-ok: #276b2b;
  --c-focus: #6d28d9;
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, .18);
  color-scheme: light;
}

/* Barlow Condensed (Jeremy Tribby), IBM Plex Sans and IBM Plex Mono (IBM): the hub's self-hosted woff2 files,
 * latin subset, under the SIL Open Font License 1.1 (fonts/OFL-*.txt). */
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap; src: url("fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: swap; src: url("fonts/barlow-condensed-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600 700; font-display: swap; src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: var(--c-bg); color: var(--c-text);
  font: var(--fs-md)/var(--lh) var(--font-ui);
}
a { color: var(--c-accent-strong); }
a:hover { color: var(--c-focus); }
::selection { background: var(--c-accent-soft); color: var(--c-text); }
:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 1px; }
b, strong { color: var(--c-text); font-weight: 600; }

/* ---------- Controls ---------- */
/* Buttons are ruled labels; the primary one is a solid accent block with condensed capitals. */
button, label.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--control-h);
  background: transparent;
  color: var(--c-text);
  border: 1px solid var(--c-line-strong); border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-5);
  font: 500 var(--fs-md)/1.2 var(--font-ui); cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
}
button:hover, label.btn:hover { background: var(--c-raised); border-color: var(--c-accent); color: var(--c-heading); }
button:active, label.btn:active { background: var(--c-sunken); }
button:disabled, button:disabled:hover {
  cursor: default; color: var(--c-text-faint);
  border-color: var(--c-line); border-style: dashed; background: transparent;
}
label.btn:focus-within { outline: 2px solid var(--c-focus); outline-offset: 1px; }
button.primary {
  background: var(--c-accent); border-color: var(--c-accent); color: var(--c-accent-ink);
  font: 700 16px/1 var(--font-display); text-transform: var(--display-case); letter-spacing: .04em;
}
button.primary:hover { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-accent-ink); filter: brightness(1.08); }
button.primary:disabled { background: transparent; color: var(--c-text-faint); border-color: var(--c-line); box-shadow: none; }

input[type=number], input[type=text], input[type=search], input[type=email], select, textarea {
  background: var(--c-sunken); color: var(--c-text);
  border: 0; border-bottom: 1px solid var(--c-line-strong); border-radius: var(--r-sm);
  padding: var(--sp-2) var(--sp-3); font: inherit; width: 100%;
  min-height: calc(var(--control-h) - 2px);
}
textarea { border: 1px solid var(--c-line-strong); }
input:hover, select:hover, textarea:hover { border-color: var(--c-text-muted); }
input:focus, select:focus, textarea:focus { border-color: var(--c-select); outline: none; box-shadow: 0 1px 0 var(--c-select); }
input::placeholder, textarea::placeholder { color: var(--c-text-faint); }
input[type=checkbox], input[type=radio] { width: 15px; height: 15px; margin: 0; }
select:disabled, input:disabled { opacity: .5; }

kbd, .help kbd {
  display: inline-block; min-width: 1.6em; text-align: center;
  background: var(--c-raised); color: var(--c-heading);
  border: 1px solid var(--c-line-strong); border-radius: var(--r-sm);
  padding: 0 var(--sp-2); font: var(--fs-xs)/1.5 var(--font-mono);
}

/* ---------- Text helpers ---------- */
.muted { color: var(--c-text-muted); }
.help { color: var(--c-text-muted); font-size: var(--fs-sm); }
.err { color: var(--c-danger); white-space: pre-wrap; min-height: 1em; margin-top: var(--sp-3); }
.grid2 { display: grid; grid-template-columns: 74px 1fr; gap: var(--sp-3) var(--sp-4); align-items: center; }
.grid2 > span:nth-child(odd) { color: var(--c-text-muted); font-size: var(--fs-sm); }
.row { display: flex; gap: var(--sp-3); flex-wrap: wrap; margin: var(--sp-4) 0; align-items: center; }
.chk { display: flex; gap: var(--sp-4); align-items: center; margin: var(--sp-2) 0; padding: var(--sp-1) 0; cursor: pointer; }
.chk:hover { color: var(--c-heading); }
.chk select { flex: none; width: auto; min-height: 24px; padding: 0 var(--sp-2); }

/* ---------- The hcpoe.tools wordmark: a link home to the hub (data-link="hub", filled in by apply.js) ---------- */
.hub-mark {
  flex: none; display: inline-flex; align-items: stretch; text-decoration: none;
  font: 700 18px/1 var(--font-display); letter-spacing: var(--tracking-display); border: 2px solid var(--c-text);
}
.hub-mark .hm-a { background: var(--c-text); color: var(--c-sunken); padding: 4px 6px 3px; }
.hub-mark .hm-b { color: var(--c-text); padding: 4px 6px 3px; font-weight: 600; }
.hub-mark:hover { border-color: var(--c-accent); }
.hub-mark:hover .hm-a { background: var(--c-accent); color: var(--c-accent-ink); }

/* ---------- The text pages' top strip: wordmark, the editor's pages, the theme switch (UX review E24) ----------
   Used by the converter, check-owned, privacy and 404 pages, and the Worker's gallery pages. */
.site-nav {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; font-size: 14px;
  padding-bottom: var(--sp-4); margin-bottom: var(--sp-5); border-bottom: 1px solid var(--c-line);
}
.site-nav a:not(.hub-mark) { color: var(--c-text-muted); text-decoration: none; }
.site-nav a:not(.hub-mark):hover, .site-nav a[aria-current="page"] { color: var(--c-heading); text-decoration: underline; text-underline-offset: 4px; }
/* quiet, like the editor footer's Light/Dark link, not a filled button */
.site-nav .nav-theme {
  margin-left: auto; min-height: 0; height: auto; padding: 0; font: inherit; font-size: 13px;
  background: none; border: 0; box-shadow: none; color: var(--c-text-muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.site-nav .nav-theme:hover { background: none; color: var(--c-heading); }
.site-nav .nav-theme[hidden] { display: none; }
@media (any-pointer: coarse) {
  /* one row that scrolls sideways if it must, rather than two rows of 44 px links */
  .site-nav { gap: 0 14px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; white-space: nowrap; }
  .site-nav::-webkit-scrollbar { display: none; }
  @media (max-width: 600px) { .site-nav { mask-image: linear-gradient(to right, #000 85%, transparent); padding-right: 24px; } }
  .site-nav .nav-theme { margin-left: 0; }
  .site-nav a:not(.hub-mark), .site-nav .nav-theme { display: inline-flex; align-items: center; min-height: 44px; }   /* finger-sized */
}

/* ---------- Scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--c-line-strong) transparent; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
/* the line between headed groups in an open dropdown list (select-groups.js); phone pickers don't show it */
select hr.sel-divider { border: 0; border-top: 1px solid var(--c-line-strong); margin: 4px 0; }
