/* Circuit atlas v2: set like the essay's own figures. A white page, the map as a flat picture on it (no frame, no
   pale-blue water), and one quiet bar under the map in the essay's figure type: in two modes, the tour and exploring.
   Nothing sits over the map but the hover card and the neuron card (flat, a hairline, a soft shadow). Colours are the
   essay's (style.css): ink, muted greys, 1px rules and one accent. */
:root {
  --ink: #222629; --muted: #677179; --faint: #8e989e; --line: #dce1e4; --panel: #ffffff; --panel2: #f5f7f8;
  --accent: #28627b; --chip: #eef2f4; --cap: #3d4b52; --dot: #cfd6da; --bg: #ffffff;
  --pop: 0 12px 40px rgba(25, 51, 67, .11);
  /* the canvas reads these (six-digit hex: atlas.js mixes them) */
  --water: #ffffff; --land: #f2eee6; --coast: #d4dadd; --pos: #28627b; --neg: #ac6538;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --gx: 20px;   /* the bar's side gutter (none inside the essay's frame, where the column's edge is the gutter) */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e7ebee; --muted: #a7b1b8; --faint: #7f8a91; --line: #33393e; --panel: #1b1f22; --panel2: #23282c;
    --accent: #7fb8d0; --chip: #2a3035; --cap: #cfd6db; --dot: #4d575d; --bg: #1b1f22; --pop: 0 12px 40px rgba(0, 0, 0, .5);
    --water: #1b1f22; --land: #262a2c; --coast: #3a4248; --pos: #7fb8d0; --neg: #e0955f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #e7ebee; --muted: #a7b1b8; --faint: #7f8a91; --line: #33393e; --panel: #1b1f22; --panel2: #23282c;
  --accent: #7fb8d0; --chip: #2a3035; --cap: #cfd6db; --dot: #4d575d; --bg: #1b1f22; --pop: 0 12px 40px rgba(0, 0, 0, .5);
  --water: #1b1f22; --land: #262a2c; --coast: #3a4248; --pos: #7fb8d0; --neg: #e0955f;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--sans); -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
/* inside the essay's frame: the page's own background shows around the map, and the page keeps its scrolling */
html.framed { --gx: 0px; }
html.framed, html.framed body { background: transparent; overscroll-behavior: auto; }
button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible { outline: 2px solid #3585ab; outline-offset: 2px; border-radius: 2px; }
#app { position: fixed; inset: 0; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; display: block; }
html.framed #map { touch-action: pan-y; }   /* (one finger scrolls the essay; two move the map) */
#map.drag { cursor: grabbing; }
#map.pointer { cursor: pointer; }

#loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; background: var(--bg); z-index: 9; }
html.framed #loading { background: transparent; }
#loading[hidden] { display: none; }

/* ---------- the bar under the map ---------- */
/* A hairline between the map and the bar (it fills with the tour's progress, in the accent); under it the caption, in
   the essay's figure type, and beside it the tour's arrows and dots or, while exploring, the way back and the zoom
   glyphs; under the caption two text links, "Take the tour" (or Pause / Play) and "Explore freely". */
#stepbar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; padding: 12px var(--gx) calc(10px + env(safe-area-inset-bottom, 0px));
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "cap side" "links side"; column-gap: 36px; row-gap: 5px; align-items: start; }
html.framed #stepbar { padding-bottom: 2px; }
.sb-prog { position: absolute; left: 0; right: 0; top: 0; height: 1px; background: var(--line); }
.sb-prog i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .1s linear; }
.sb-cap { grid-area: cap; margin: 0; font-size: 14px; line-height: 1.5; color: var(--cap); text-wrap: pretty; }
.sb-cap.ex { color: var(--muted); }
.sb-cap b { font-weight: 500; color: var(--ink); }

.sb-side { grid-area: side; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; margin-top: -2px; }
.sb-move { grid-area: side; display: flex; align-items: center; justify-content: flex-end; gap: 16px; min-width: 0; margin-top: -1px; }
#stepbar:not(.touring) .sb-side, #stepbar.touring .sb-move { display: none; }
.sb-nav { display: flex; align-items: center; gap: 2px; }
.sb-nav > button { width: 30px; height: 30px; display: inline-grid; place-items: center; flex: none; padding: 0; border: 1px solid var(--line); border-radius: 50%;
  background: transparent; color: var(--ink); cursor: pointer; transition: border-color .15s, opacity .15s; }
.sb-nav > button svg { display: block; width: 12px; height: 12px; }
.sb-nav > button:hover:not(:disabled) { border-color: var(--ink); }
.sb-nav > button:disabled { opacity: .35; cursor: default; }
.sb-rail { display: flex; align-items: center; margin: 0 3px; }
.sb-rail button { width: 16px; height: 22px; display: grid; place-items: center; flex: none; padding: 0; border: 0; background: none; cursor: pointer; }
.sb-rail button::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--dot); transition: background .2s, transform .2s; }
.sb-rail button:hover::before { background: var(--faint); }
.sb-rail button.on::before { background: var(--accent); transform: scale(1.15); }
.sb-rail button:focus-visible { outline-offset: -2px; border-radius: 4px; }
.sb-name { min-height: 19px; padding-right: 36px; font-size: 12.5px; line-height: 19px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.sb-name b { font-weight: 400; color: var(--faint); margin-right: 6px; font-variant-numeric: tabular-nums; }
.sb-name.peek { color: var(--ink); }

/* exploring: one level back up (named for where it goes) and small zoom glyphs */
.sb-back { flex: 0 1 auto; min-width: 0; max-width: 280px; padding: 0; border: 0; background: none; cursor: pointer; font-size: 13px; line-height: 20px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-back[hidden] { display: none; }
.sb-back:hover { color: var(--accent); }
.sb-back .bk-s { display: none; }
#zoomctl { display: inline-flex; align-items: center; flex: none; }
#zoomctl button { width: 24px; height: 24px; padding: 0; border: 0; background: none; cursor: pointer; font-size: 16px; line-height: 24px; color: var(--muted); }
#zoomctl #zhome { display: inline-grid; place-items: center; }
#zoomctl #zhome svg { display: block; width: 12px; height: 12px; }
#zoomctl button:hover { color: var(--ink); }

.sb-links { grid-area: links; display: flex; align-items: baseline; gap: 18px; min-width: 0; }
.sb-links button { display: inline-flex; align-items: center; gap: 5px; flex: none; padding: 0; border: 0; background: none; cursor: pointer;
  font-size: 13px; line-height: 20px; color: var(--muted); white-space: nowrap; }
.sb-links button svg { width: 9px; height: 9px; flex: none; }
.sb-links button:hover:not(:disabled) { color: var(--accent); }
#stepbar:not(.touring) .sb-play { color: var(--accent); }   /* "Take the tour": the way in */
.sb-free.cur, .sb-free.cur:hover { color: var(--ink); cursor: default; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
#stepbar.last .sb-free { color: var(--accent); }             /* the tour's last step: the way on is to explore */
/* inside the essay: how to use the map, shown when the pointer arrives or the page scrolls over it, then gone */
#ehint { flex: 0 1 auto; min-width: 0; margin-left: auto; font-size: 12px; line-height: 20px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transition: opacity .25s; }
#ehint:empty { display: none; }
#ehint.show { opacity: 1; }
#ehint.strong { opacity: 1; color: var(--muted); }

/* ---------- the hover card and the neuron card: flat, a hairline and a soft shadow ---------- */
#tip { position: absolute; z-index: 7; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 3px; box-shadow: var(--pop);
  padding: 7px 10px 8px; font-size: 12.5px; line-height: 1.45; max-width: 320px; color: var(--ink); }
#tip[hidden] { display: none; }
#tip .t { font-weight: 500; font-size: 13px; }
#tip .s { color: var(--muted); }
#tip .n { font-variant-numeric: tabular-nums; }
#tourCard { position: absolute; z-index: 5; background: var(--panel); border: 1px solid var(--line); border-radius: 3px; box-shadow: var(--pop);
  padding: 9px 11px 8px; width: max-content; max-width: min(340px, calc(100vw - 24px)); transition: opacity .25s ease; }
#tourCard[hidden] { display: none; }
#tourCard.settling { opacity: 0; pointer-events: none; }   /* (it fades in once the camera has landed) */
#tourCard .tc-h b { display: block; font-size: 13.5px; font-weight: 500; }
#tourCard .tc-h small { display: block; color: var(--muted); font-size: 11.5px; contain: inline-size; }   /* (wraps to the pictures' width, never widens the card) */
#tourCard .tc-row { display: flex; gap: 8px; margin: 8px 0 6px; align-items: flex-start; }
#tourCard .tc-g { display: grid; column-gap: 8px; row-gap: 3px; align-items: end; margin: 8px 0 6px; }
#tourCard .tc-l { font-size: 10.5px; line-height: 1.2; color: var(--muted); contain: inline-size; }
#tourCard .tc-fv { flex: none; border-radius: 2px; background-repeat: no-repeat; background-color: var(--chip); }
#tourCard .tc-grid { display: grid; grid-template-columns: repeat(3, 56px); gap: 3px; }
#tourCard .tc-im { display: block; border-radius: 1px; background-repeat: no-repeat; background-color: var(--chip); }
#tourCard .tc-f { display: flex; justify-content: flex-end; align-items: baseline; gap: 8px; font-size: 12px; }
#tourCard .tc-id { color: var(--muted); font-size: 11px; margin-right: auto; }
#tourCard .tc-f a { color: var(--accent); white-space: nowrap; text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
#tourCard .tc-f a:hover { border-bottom-color: currentColor; }

/* ---------- narrower than the essay column: the caption takes the width; under it the tour's arrows and dots (with the
   step's name), then the links, with the way back and the whole-map glyph at the end of that line ---------- */
@media (max-width: 600px) {
  :root { --gx: 16px; }
  #stepbar { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "cap cap" "side side" "links move"; column-gap: 12px; row-gap: 6px; padding-top: 10px; }
  .sb-cap { font-size: 13.5px; line-height: 1.45; }
  .sb-side { flex-direction: row; align-items: center; gap: 8px; margin: 0 0 0 -1px; }
  .sb-name { padding-right: 0; flex: 1 1 auto; min-width: 0; }
  .sb-move { grid-area: move; gap: 10px; margin: 0; }
  .sb-back .bk-n { display: none; }
  .sb-back .bk-s { display: inline; }
  #zoomctl #zin, #zoomctl #zout { display: none; }   /* (pinch zooms) */
  .sb-links { gap: 16px; min-height: 30px; align-items: center; }
  /* (the touch hint wraps to two short lines beside the links) */
  #ehint { flex: 1 1 0; white-space: normal; text-align: right; font-size: 11.5px; line-height: 14px; max-height: 28px;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; text-overflow: clip; }
  #ehint:empty { display: none; }
  #tourCard { padding: 8px; }
  #tourCard .tc-row { gap: 6px; }
}
@media (max-width: 370px) { .sb-cap { font-size: 13px; } .sb-rail button { width: 15px; } .sb-links { gap: 14px; } }
@media (prefers-reduced-motion: reduce) { #tourCard, .sb-prog i { transition: none; } }
