/* Supply-chain brain: page chrome shared by both pages (index.html, map.html).
 *
 * The header, the settings card on the right and the floating pill, copied
 * from the source viz named in COPIED_FROM.md so the two pages look like one
 * product. Both pages link this file; neither restyles these parts.
 *
 * This is presenter chrome, not content for the room, so it keeps the source
 * viz's small sizes. The projector minimum (18px) applies to the content:
 * nav.css and map.html (tests/test_viz_nav_ui.py), and the rings page's
 * drawer, results, tooltip and canvas labels (tests/test_viz_rings_ui.py).
 * The chrome's own colours
 * live here, prefixed --c-, so they cannot clash with the map's tokens
 * (nav.css). They are also the ONLY colours of the rings graph: index.html
 * defines no token and no literal colour, and its canvas reads these values
 * (tests/test_viz_nav_ui.py and tests/test_viz_rings_ui.py check both).
 * Text pairs pass 4.5:1 in both themes; --c-pink is for fills and borders,
 * --c-pink-ink for pink text.
 * Dark mode: [data-theme="dark"] on <html>, set by nav.js or the rings page.
 */
:root {
  --c-page: #FAF7F2; --c-card: #FFFFFF; --c-ink: #16130F; --c-label: #52493E;
  --c-sec: #6E6558; --c-muted: #746A5C; --c-pink: #EC3D8F; --c-pink-ink: #B81F66;
  --c-accent: #B81F66; --c-accent-ink: #FFFFFF; --c-on-pink: #FFFFFF;
  --c-line: #E9E2D8; --c-card-line: #ECE6DC; --c-field-line: #E5DED3; --c-btn-line: #E3DCD1;
  --c-divider: #DFD7CB; --c-input: #F6F2EB; --c-chip: #F6F2EB; --c-placeholder: #746A5C;
  --c-seg-on-bg: #16130F; --c-seg-on-fg: #FFFFFF;
  --c-rail: #E7E0D6; --c-plate: #E2DBD0; --c-edge: #9280BA; --c-ring-guide: #EEE9E2;
  --c-selection: #F9CFE2; --c-toast-bg: #16130F; --c-toast-fg: #FFFFFF;
  --c-card-shadow: 0 6px 24px rgba(60, 45, 25, 0.06);
  --c-pill-shadow: 0 4px 14px rgba(70, 55, 35, 0.07);
  --c-float-shadow: 0 8px 24px rgba(70, 55, 35, 0.12);
  --c-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --c-sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
[data-theme="dark"] {
  --c-page: #0F0D11; --c-card: #17151C; --c-ink: #F2EDE5; --c-label: #D5CDBF;
  --c-sec: #A49C8E; --c-muted: #968E81; --c-pink: #EC3D8F; --c-pink-ink: #F45FA2;
  --c-accent: #F45FA2; --c-accent-ink: #0F0D11; --c-on-pink: #FFFFFF;
  --c-line: #262230; --c-card-line: #2A2634; --c-field-line: #332E3D; --c-btn-line: #3A3546;
  --c-divider: #332E3D; --c-input: #1E1B24; --c-chip: #1E1B24; --c-placeholder: #968E81;
  --c-seg-on-bg: #F2EDE5; --c-seg-on-fg: #17151C;
  --c-rail: #332E3D; --c-plate: #332E3D; --c-edge: #B29EDC; --c-ring-guide: #1C1A1F;
  --c-selection: #5A2A44; --c-toast-bg: #F2EDE5; --c-toast-fg: #17151C;
  --c-card-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  --c-pill-shadow: 0 8px 24px rgba(0, 0, 0, 0.40);
  --c-float-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
}

/* Keyboard focus is always visible, on both pages (a mouse click shows none). */
:focus-visible { outline: 3px solid var(--c-pink); outline-offset: 2px; }

/* ---- header: wordmark | BRAIN | tag · page links · theme, menu, offline ---- */
#hd { flex: none; height: 62px; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 0 26px; border-bottom: 1px solid var(--c-line); background: var(--c-page);
  position: relative; z-index: 30; font-family: var(--c-sans); line-height: normal; }
#hd .left { display: flex; align-items: center; gap: 14px; min-width: 0; }
#hd #logo { font-family: "Quicksand", "Helvetica Neue", sans-serif; font-weight: 700; font-size: 23px;
  letter-spacing: -0.4px; color: var(--c-pink); line-height: 1; user-select: none; white-space: nowrap; }
#hd .div { width: 1px; height: 20px; background: var(--c-divider); flex: none; }
#hd .word { font-family: var(--c-mono); font-weight: 600; font-size: 12px; letter-spacing: 5px; color: var(--c-ink); }
#hd .tag { font-family: var(--c-mono); font-size: 11px; color: var(--c-muted); margin-left: 4px; white-space: nowrap; }
#hd .right { display: flex; align-items: center; gap: 8px; }
#hd #themeBtn, #hd #menuBtn { background: transparent; border: 1.5px solid var(--c-ink); color: var(--c-ink);
  border-radius: 999px; cursor: pointer; }
#hd #themeBtn { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  font-size: 14px; padding: 0; line-height: 1; }
#hd #menuBtn { padding: 8px 18px; font-family: var(--c-mono); font-size: 11px; font-weight: 600;
  letter-spacing: 2.5px; white-space: nowrap; }
#hd #themeBtn:hover, #hd #menuBtn:hover { background: var(--c-ink); color: var(--c-page); }
#hd #menuBtn[aria-expanded="false"] { opacity: 0.8; }
#navlinks { display: flex; align-items: center; gap: 4px; }
.navlink { font-family: var(--c-mono); font-size: 11px; font-weight: 600; letter-spacing: 2.2px;
  text-transform: uppercase; text-decoration: none; color: var(--c-sec); padding: 8px 14px;
  border-radius: 999px; border: 1.5px solid transparent; white-space: nowrap; }
.navlink:hover { color: var(--c-ink); background: var(--c-chip); }
.navlink[aria-current="page"] { color: var(--c-pink-ink); border-color: var(--c-pink); }
.navchip { font-family: var(--c-mono); font-size: 10px; font-weight: 600; letter-spacing: 1.8px;
  color: var(--c-muted); background: var(--c-chip); border-radius: 999px; padding: 5px 12px; margin-left: 4px; }
/* The tag goes first, whole, rather than being cut to an ellipsis. */
@media (max-width: 1320px) { #hd .tag { display: none; } }
@media (max-width: 760px) { #hd { padding: 0 14px; } }

/* ---- settings card (top right of the stage) ------------------------------ */
.menu { position: absolute; top: 18px; right: 18px; z-index: 10; width: 292px; background: var(--c-card);
  border: 1px solid var(--c-card-line); border-radius: 12px; box-shadow: var(--c-card-shadow);
  padding: 18px 16px; max-height: calc(100% - 36px); overflow-y: auto; font-family: var(--c-sans);
  font-size: 13px; color: var(--c-ink); line-height: normal; }
.menu.hidden { display: none; }
.menu .search { width: 100%; background: var(--c-input); border: 1px solid var(--c-field-line); border-radius: 8px;
  padding: 9px 12px; font-family: var(--c-mono); font-size: 12px; color: var(--c-ink); outline: none; }
.menu .search::placeholder { color: var(--c-placeholder); }
.menu .search:focus { border-color: var(--c-pink); background: var(--c-card); }
.menu .matches { margin-top: 7px; font-family: var(--c-mono); font-size: 10.5px; color: var(--c-pink-ink); }
.menu .matches:empty { display: none; }
.menu .stats { margin-top: 10px; font-family: var(--c-mono); font-size: 10.5px; line-height: 1.7; color: var(--c-muted); }
.menu .sec { display: block; font-family: var(--c-mono); font-weight: 600; font-size: 10px; letter-spacing: 2.5px;
  text-transform: uppercase; color: var(--c-muted); margin: 18px 0 8px; }
.btnrow { display: flex; flex-wrap: wrap; gap: 6px; }
.btnrow button { flex: 1; padding: 8px 0; border-radius: 8px; border: 1px solid var(--c-btn-line);
  background: transparent; color: var(--c-sec); font-family: var(--c-sans); font-size: 12.5px;
  font-weight: 600; cursor: pointer; white-space: nowrap; }
.btnrow button.on { background: var(--c-seg-on-bg); border-color: var(--c-seg-on-bg); color: var(--c-seg-on-fg); }
.btnrow button:not(.on):hover { border-color: var(--c-ink); color: var(--c-ink); }
.btnrow.wrap button { flex: 1 0 auto; padding: 8px 12px; }
.btnrow.actions { margin-top: 16px; }
/* List rows in the card: a swatch, a name, a count on the right. */
.menu .rowbtn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 8px;
  border: 1px solid transparent; border-radius: 8px; background: none; font-family: var(--c-sans);
  font-size: 13px; color: var(--c-label); text-align: left; cursor: pointer; }
.menu .rowbtn:hover { background: var(--c-input); }
.menu .rowbtn.sel { border-color: var(--c-pink); background: var(--c-input); }
.menu .rowbtn[aria-pressed="false"] { opacity: 0.45; }
.menu .rowbtn[aria-pressed="false"] > span:not(.n) { text-decoration: line-through; }
.menu .rowbtn .n { margin-left: auto; font-family: var(--c-mono); font-size: 11px; color: var(--c-muted);
  font-variant-numeric: tabular-nums; white-space: nowrap; }
.checkrow { display: flex; align-items: center; gap: 9px; margin-top: 12px; font-size: 13px;
  color: var(--c-label); user-select: none; }
.checkrow label { cursor: pointer; }
.checkrow input[type=checkbox] { appearance: none; -webkit-appearance: none; width: 16px; height: 16px;
  border-radius: 5px; border: 1px solid var(--c-btn-line); background: transparent; cursor: pointer; flex: none;
  margin: 0; display: flex; align-items: center; justify-content: center; }
.checkrow input[type=checkbox]:checked { background: var(--c-pink); border-color: var(--c-pink); }
.checkrow input[type=checkbox]:checked::after { content: "✓"; color: var(--c-on-pink); font-size: 10px; font-weight: 700; line-height: 1; }

/* Sliders in the card (Text size on both pages; the graph adds spin, springs, size). */
.sliderrow { display: grid; grid-template-columns: 56px 1fr 34px; gap: 10px; align-items: center;
  margin-top: 13px; font-size: 12px; line-height: 1.35; color: var(--c-label); }
.sliderrow .val { font-family: var(--c-mono); font-size: 11px; color: var(--c-pink-ink); text-align: right; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 4px;
  border-radius: 99px; background: var(--c-rail); cursor: pointer; margin: 6px 0;
  padding: 0; border: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 15px;
  height: 15px; border-radius: 50%; background: var(--c-pink); border: 2.5px solid var(--c-card);
  box-shadow: var(--c-pill-shadow); }
input[type=range]::-moz-range-thumb { width: 11px; height: 11px; border-radius: 50%;
  background: var(--c-pink); border: 2.5px solid var(--c-card); box-shadow: var(--c-pill-shadow); }

/* ---- floating pill (bottom centre of the stage) -------------------------- */
.floatpill { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 5;
  background: var(--c-card); border: 1px solid var(--c-line); border-radius: 999px; padding: 8px 16px;
  font-family: var(--c-mono); font-size: 11px; color: var(--c-label); box-shadow: var(--c-pill-shadow);
  white-space: nowrap; }
