/* Hex atlas (spec §11.6-11.7, HEXMAP v2 §C), drawn as a printed map in the Field Kit (docs/DESIGN.md). Owner: ATLAS.
   Used with app/static/atlas.js on /map, the Today end card, the landing demo and the admin coverage view.
   The map is printed: flat, hairline, no shadows; only the controls and the tooltip are objects (ink edge, hard
   shadow). By day the five domain "continents" are muted printed-map inks on the sheet; at night they are
   luminous but calm on the night sheet. Domain inks keep CVD dE >= 10 (deutan, protan, tritan) between every pair
   at the half tint and >= 20 at full ink (design/build/foundation/cvd.py).
   Explored = domain tint engraved with 45 deg hatching that tightens with depth; said-only (from me.md, not
   watched) = hatching the other way on bare paper; visited = plain tint + ink footprint; fog = stipple;
   mist (next door) = a faint wash; start here = dotted accent; you are here = accent dot in a ring;
   selection = solid accent (survey red by day, survey-flag pink at night).
   Dark values follow app.css: plain values on :root, dark under prefers-color-scheme and [data-theme="dark"]
   (no light-dark(): Chromium freezes colour transitions between its values). */
:root {
  --dom-life: #3E7238;      /* D1 Life Sciences: forest green */
  --dom-social: #A84E76;    /* D2 Social Sciences: madder rose */
  --dom-physical: #3A8BB5;  /* D3 Physical Sciences: lake blue */
  --dom-health: #4B3F93;    /* D4 Health Sciences: indigo */
  --dom-x: #C49A22;         /* X Life, Craft & Culture: ochre */
  --atlas-paper: var(--sheet, #F5F0E2);
  --atlas-surface: var(--card, #FFFCF3);
  --atlas-ink: var(--ink, #1A1915);
  --atlas-muted: var(--muted, #5F584A);
  --atlas-accent: var(--accent, #BF3518);
  --atlas-grid: var(--grid-dot, rgb(26 25 21 / .14));
  --fog: #E9E2CF;
  --fog-dot: rgb(26 25 21 / .22);
  --fog-line: rgb(26 25 21 / .10);
  --hatch-ink: var(--atlas-ink);   /* mixed into the domain hue for the engraved lines */
  --hatch-mix: 22%;
  --coast-mix: 55%;
  --ex1: 18%; --ex2: 30%; --ex3: 44%; --ex4: 60%; --mi: 0%;
  --d0: 16%; --d1: 32%; --d2: 50%; --d3: 70%; --d4: 100%;   /* revealed base layer, by catalogue density */
  --atlas-focus: var(--focus, #BF3518);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --dom-life: #4DAE63; --dom-social: #CC7BA0; --dom-physical: #5CB4E0; --dom-health: #8C7CEB; --dom-x: #D8A93A;
    --fog: #151E2A; --fog-dot: rgb(232 237 243 / .13); --fog-line: rgb(232 237 243 / .07);
    --hatch-mix: 34%; --coast-mix: 38%;
    --ex1: 26%; --ex2: 38%; --ex3: 52%; --ex4: 66%; --mi: 4%;
    --d0: 26%; --d1: 40%; --d2: 54%; --d3: 68%; --d4: 82%;
  }
}
:root[data-theme="dark"] {
  --dom-life: #4DAE63; --dom-social: #CC7BA0; --dom-physical: #5CB4E0; --dom-health: #8C7CEB; --dom-x: #D8A93A;
  --fog: #151E2A; --fog-dot: rgb(232 237 243 / .13); --fog-line: rgb(232 237 243 / .07);
  --hatch-mix: 34%; --coast-mix: 38%;
  --ex1: 26%; --ex2: 38%; --ex3: 52%; --ex4: 66%; --mi: 4%;
  --d0: 26%; --d1: 40%; --d2: 54%; --d3: 68%; --d4: 82%;
}

/* ---- the sheet: paper + a 24 px dotted grid that pans with the map ---- */
/* size: fills its host unless the host sets one (zero specificity, so .mini-atlas { height } wins) */
:where(.slash-atlas) { width: 100%; height: 100%; min-height: 200px; }
.slash-atlas {
  position: relative; overflow: hidden;
  background-color: var(--atlas-paper);
  background-image: radial-gradient(circle at 1px 1px, var(--atlas-grid) 1px, transparent 1.5px);
  background-size: 24px 24px;
  border-radius: var(--r-xs, 3px); touch-action: none; user-select: none;
  -webkit-user-select: none; outline: none; cursor: grab; font-family: var(--sans, system-ui, sans-serif);
}
.slash-atlas:focus-visible { box-shadow: inset 0 0 0 2.5px var(--atlas-focus); }
.slash-atlas.sa-dragging { cursor: grabbing; }
.slash-atlas > svg { display: block; width: 100%; height: 100%; max-width: none; opacity: 0; transition: opacity .5s var(--ease, ease); }
.slash-atlas.sa-ready > svg { opacity: 1; }
.sa-msg { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 1;
  font: italic 400 16px/1.4 var(--serif, Georgia, serif); color: var(--atlas-muted); }
.sa-msg[hidden] { display: none; }
/* a static fog silhouette while the sheet loads: three dotted hex outlines, no spinner */
.sa-loading .sa-msg { padding-top: 150px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 120'%3E%3Cg fill='none' stroke='rgb(128 118 98 / .45)' stroke-width='1.2' stroke-dasharray='1 3' stroke-linecap='round'%3E%3Cpath d='M30 60l15-26h30l15 26-15 26H45z'/%3E%3Cpath d='M75 34l15-26h30l15 26-15 26H90z'/%3E%3Cpath d='M75 86l15-26h30l15 26-15 26H90z'/%3E%3Cpath d='M120 60l15-26h30l15 26-15 26h-30z'/%3E%3C/g%3E%3C/svg%3E") center calc(50% - 20px) / 180px auto no-repeat; }
.sa-failed .sa-msg { font-style: normal; font-family: var(--sans, sans-serif); font-size: 15px; }

/* ---- cells: one <path> per cell; class gives the fallback tint, inline style the engraved pattern ---- */
.sa-cell { stroke: none; vector-effect: non-scaling-stroke; }
.dom-life { --hue: var(--dom-life); }
.dom-social { --hue: var(--dom-social); }
.dom-physical { --hue: var(--dom-physical); }
.dom-health { --hue: var(--dom-health); }
.dom-x { --hue: var(--dom-x); }
/* revealed base layer (admin, signed out): hue x catalogue density toward the surface */
.sa-cell.d0 { fill: color-mix(in srgb, var(--hue) var(--d0), var(--atlas-surface)); }
.sa-cell.d1 { fill: color-mix(in srgb, var(--hue) var(--d1), var(--atlas-surface)); }
.sa-cell.d2 { fill: color-mix(in srgb, var(--hue) var(--d2), var(--atlas-surface)); }
.sa-cell.d3 { fill: color-mix(in srgb, var(--hue) var(--d3), var(--atlas-surface)); }
.sa-cell.d4 { fill: color-mix(in srgb, var(--hue) var(--d4), var(--atlas-surface)); }
.sa-cell.sa-empty { fill: color-mix(in srgb, var(--hue) 8%, var(--atlas-surface)); stroke: none !important; }
.sa-user .sa-cell.sa-empty { fill: var(--fog); }
/* explored, by depth (fallback tint; the pattern below adds the engraving) */
.sa-cell.ex1 { fill: color-mix(in srgb, var(--hue) 30%, var(--atlas-paper)); }
.sa-cell.ex2 { fill: color-mix(in srgb, var(--hue) 45%, var(--atlas-paper)); }
.sa-cell.ex3 { fill: color-mix(in srgb, var(--hue) 62%, var(--atlas-paper)); }
.sa-cell.ex4 { fill: color-mix(in srgb, var(--hue) 80%, var(--atlas-paper)); }
.sa-cell.inf { fill: color-mix(in srgb, var(--hue) 14%, var(--atlas-paper)); }
.sa-cell.ex1, .sa-cell.ex2, .sa-cell.ex3, .sa-cell.ex4, .sa-cell.inf { stroke: var(--atlas-paper); stroke-width: 1px; }
/* next door (mist): a faint wash of the hue over fog */
.sa-cell.mi0 { fill: color-mix(in srgb, var(--hue) calc(10% + var(--mi)), var(--fog)); }
.sa-cell.mi1 { fill: color-mix(in srgb, var(--hue) calc(14% + var(--mi)), var(--fog)); }
.sa-cell.mi2 { fill: color-mix(in srgb, var(--hue) calc(18% + var(--mi)), var(--fog)); }
.sa-cell.mi3 { fill: color-mix(in srgb, var(--hue) calc(22% + var(--mi)), var(--fog)); }
.sa-cell.mi4 { fill: color-mix(in srgb, var(--hue) calc(26% + var(--mi)), var(--fog)); }
.sa-cell.fog { fill: var(--fog); }
.sa-z2 .sa-cell.mi0, .sa-z2 .sa-cell.mi1, .sa-z2 .sa-cell.mi2, .sa-z2 .sa-cell.mi3, .sa-z2 .sa-cell.mi4,
.sa-z2 .sa-cell.fog, .sa-z2.sa-user .sa-cell.sa-empty { stroke: var(--fog-line); stroke-width: .75px; }
.sa-z2 .sa-cell.d0, .sa-z2 .sa-cell.d1, .sa-z2 .sa-cell.d2, .sa-z2 .sa-cell.d3,
.sa-z2 .sa-cell.d4 { stroke: var(--atlas-surface); stroke-width: .5px; }

/* ---- engraving patterns (defined per map in <defs>) ---- */
.sa-pat .sa-pbg { fill: var(--atlas-paper); }
.sa-pat .sa-pln { fill: color-mix(in srgb, var(--hatch-ink) var(--hatch-mix), var(--hue)); }
.sa-pat.ex1 .sa-pbg { fill: color-mix(in srgb, var(--hue) var(--ex1), var(--atlas-paper)); }
.sa-pat.ex2 .sa-pbg { fill: color-mix(in srgb, var(--hue) var(--ex2), var(--atlas-paper)); }
.sa-pat.ex3 .sa-pbg { fill: color-mix(in srgb, var(--hue) var(--ex3), var(--atlas-paper)); }
.sa-pat.ex4 .sa-pbg { fill: color-mix(in srgb, var(--hue) var(--ex4), var(--atlas-paper)); }
.sa-pat.inf .sa-pbg { fill: color-mix(in srgb, var(--hue) 6%, var(--atlas-paper)); }
.sa-pat.inf .sa-pln { fill: color-mix(in srgb, var(--hue) 70%, var(--atlas-paper)); }
.sa-stip .sa-pbg { fill: var(--fog); }
.sa-stip .sa-pdot { fill: var(--fog-dot); }

/* ---- borders ---- */
.sa-coast, .sa-prov, .sa-subreg { fill: none; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.sa-coast { stroke: color-mix(in srgb, var(--atlas-ink) var(--coast-mix), transparent); stroke-width: 1px; }
.sa-z0 .sa-coast { stroke-width: 1.25px; }
.sa-prov { stroke: color-mix(in srgb, var(--atlas-ink) 32%, transparent); stroke-width: 1px; }
.sa-z0 .sa-prov { display: none; }
.sa-user .sa-prov { stroke: color-mix(in srgb, var(--atlas-ink) 26%, transparent); stroke-dasharray: 3 2; }

/* ---- markers ---- */
.sa-marks { pointer-events: none; }
.sa-frontier { fill: none; stroke: var(--atlas-accent); stroke-width: 2px; stroke-linecap: round; stroke-dasharray: 0 4;
  vector-effect: non-scaling-stroke; }
.sa-recent { fill: none; stroke: var(--atlas-ink); stroke-width: 1px; opacity: .6; vector-effect: non-scaling-stroke; }
.sa-new { fill: var(--atlas-ink); }
.sa-dot { fill: var(--fog-dot); opacity: .8; }
.sa-z1 .sa-dot { display: none; }
.sa-z0 .sa-recent, .sa-z0 .sa-new, .sa-z0 .sa-dot { display: none; }
.sa-z0 .sa-frontier { stroke-width: 1.5px; stroke-dasharray: 0 3; }

/* ---- interaction: hover ink, keyboard focus ink, selection survey red ---- */
.sa-hover, .sa-focus, .sa-sel { fill: none; vector-effect: non-scaling-stroke; pointer-events: none; stroke-linejoin: round; }
.sa-hover { stroke: var(--atlas-ink); stroke-width: 1.5px; }
.sa-focus { stroke: var(--atlas-ink); stroke-width: 2px; stroke-dasharray: 4 2; }
.sa-sel { stroke: var(--atlas-accent); stroke-width: 3px; paint-order: stroke; }
.sa-ping { pointer-events: none; }
.sa-ping-ring { fill: none; stroke: var(--atlas-accent); stroke-width: 2px; vector-effect: non-scaling-stroke;
  transform-box: fill-box; transform-origin: center; animation: sa-ping 1.4s var(--ease, ease-out) 2 both; }
.sa-ping-ring.two { animation-delay: .35s; }
@keyframes sa-ping { from { transform: scale(.6); opacity: 1; } to { transform: scale(2.2); opacity: 0; } }

/* ---- labels: ink with a paper halo, never coloured text; region names in wide caps ---- */
.sa-labels { pointer-events: none; }
.sa-labels text {
  fill: var(--atlas-ink); paint-order: stroke; stroke: var(--atlas-paper); stroke-width: 3px;
  stroke-linejoin: round; text-anchor: middle; dominant-baseline: central; font-size: 11px; font-family: var(--sans, sans-serif);
  font-weight: 500;
}
.sa-labels .lv-domain { font-size: 12.5px; font-family: var(--display, sans-serif); font-weight: 800; letter-spacing: .26em;
  fill: color-mix(in srgb, var(--atlas-ink) 78%, var(--atlas-paper)); stroke-width: 4px; }
.sa-labels .lv-field { font-size: 10px; font-weight: 700; letter-spacing: .14em;
  fill: color-mix(in srgb, var(--atlas-ink) 82%, var(--atlas-paper)); }
.sa-labels .lv-sub { fill: color-mix(in srgb, var(--atlas-ink) 80%, var(--atlas-paper)); }
.sa-labels .lv-explored { font-weight: 700; }
.sa-labels .lv-topic { font: italic 450 11.5px var(--serif, Georgia, serif); }

/* ---- zoom 3: topic lattice over its province ---- */
.sa-topics { opacity: 0; transition: opacity 200ms ease; }
.sa-topics.sa-in { opacity: 1; }
.sa-cells { transition: opacity 200ms ease; }
.sa-z3 .sa-cells, .sa-z3 .sa-marks { opacity: .35; }
.sa-topic { vector-effect: non-scaling-stroke; stroke: var(--atlas-paper); stroke-width: .5px; }
.sa-topic.tp0 { fill: color-mix(in srgb, var(--hue) 30%, var(--atlas-surface)); }
.sa-topic.tp1 { fill: color-mix(in srgb, var(--hue) 48%, var(--atlas-surface)); }
.sa-topic.tp2 { fill: color-mix(in srgb, var(--hue) 64%, var(--atlas-surface)); }
.sa-topic.tp3 { fill: color-mix(in srgb, var(--hue) 80%, var(--atlas-surface)); }
.sa-subreg { stroke: color-mix(in srgb, var(--atlas-ink) 45%, transparent); stroke-width: 1px; }

/* ---- chrome: tooltip slip, zoom controls ---- */
.sa-tip {
  position: absolute; z-index: 3; max-width: 260px; padding: 7px 10px 8px; pointer-events: none;
  background: var(--atlas-surface); color: var(--atlas-ink); border: 2px solid var(--edge, #1A1915);
  border-radius: var(--r-s, 8px); box-shadow: var(--lift-s, 2px 2px 0 #1A1915); line-height: 1.3;
}
.sa-tip[hidden] { display: none; }
.sa-tip b { display: block; font: 700 15.5px/1.2 var(--display, sans-serif); font-stretch: 94%; letter-spacing: -.01em; }
.sa-tip span { display: block; margin-top: 3px; font: 400 10.5px/1.4 var(--mono, monospace); letter-spacing: .04em;
  text-transform: uppercase; color: var(--atlas-muted); }
.sa-ctrl { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; z-index: 2;
  background: var(--atlas-surface); border: 2px solid var(--edge, #1A1915); border-radius: var(--r-s, 8px);
  box-shadow: var(--lift-s, 2px 2px 0 #1A1915); overflow: hidden; }
.sa-ctrl button {
  display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; cursor: pointer;
  background: transparent; color: var(--atlas-ink); border-radius: 0;
}
.sa-ctrl button + button { border-top: 1.5px solid var(--line-2, rgb(26 25 21 / .32)); }
.sa-ctrl button[hidden] { display: none; }
.sa-ctrl button:hover { background: var(--sunk, #E2DAC5); }
.sa-ctrl button:focus-visible { outline: 2.5px solid var(--atlas-focus); outline-offset: -3px; }
.sa-ctrl svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.sa-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (pointer: coarse) { .sa-ctrl button { width: 44px; height: 44px; } }

@media (prefers-reduced-motion: reduce) {
  .sa-topics, .sa-cells, .slash-atlas > svg { transition: none; }
  .sa-ping-ring { animation: none; opacity: 1; }
  .sa-ping-ring.two { display: none; }
}

/* ---- what the user has really walked (map review, 12 Nov) ---- */
/* visited: watched here, not explored yet: a plain tint and an ink footprint, no engraving */
.sa-cell.vi { fill: color-mix(in srgb, var(--hue) 24%, var(--atlas-paper)); stroke: var(--atlas-paper); stroke-width: 1px; }
.sa-foot { fill: var(--atlas-ink); opacity: .75; }
.sa-z0 .sa-foot { display: none; }
/* said-only explored cells get a hairline in the domain ink so the bare-paper hatching reads as a place */
.sa-user .sa-cell.inf { stroke: color-mix(in srgb, var(--hue) 55%, var(--atlas-paper)); stroke-width: 1px; }
/* you are here: the latest walk, survey red, constant screen size (drawn in the label layer) */
.sa-labels .sa-here-ring { fill: none; stroke: var(--atlas-accent); stroke-width: 1.75px; }
.sa-labels .sa-here-dot { fill: var(--atlas-accent); stroke: var(--atlas-paper); stroke-width: 1.5px; }
.sa-labels .lv-here { font-size: 10px; font-family: var(--mono, monospace); font-weight: 500; letter-spacing: .14em; fill: var(--atlas-accent); }
