/* CarDOSgraphy: a pixel map of a city filling the window, the system's tile map under a camera (view.js), and round it a
   TUI in the large cells (the system's TUI part, .tui-lg: a 14 × 30 cell), Village's way at twice its size
   (CLAUDE.md, Deviations). Every ink is one of the theme's tokens, passed to the tile map by name (look.js INKS):
   nothing here is a hex. */
:root {
  --jakarta-mid: var(--500);            /* the sea by the shore and a river's body: DOS Age's sea blue */
  --jakarta-deep: var(--200);           /* open sea, a step off the ground, its waves thinning to specks */
  --jakarta-speck: var(--500);          /* a glint out at sea */
  --jakarta-sand: var(--map-sand);      /* the shore */
  --jakarta-town: var(--400);           /* the city's blocks, quiet */
  --jakarta-street: var(--600);         /* the lesser roads */
  --jakarta-road: var(--700);           /* the main roads */
  --jakarta-rail: var(--map-wood);      /* the railways' sleepers */
  --jakarta-stone: var(--1000);         /* Monas's lit stone */
  --jakarta-stone-dark: var(--700);     /* its shade */
  --jakarta-flame: var(--gilt);         /* its gilt flame */
  --jakarta-roof: var(--map-fruit);     /* Fatahillah's red clay tiles */
  --jakarta-sail: var(--1000);          /* a pinisi's sails */
  --jakarta-hull: var(--map-wood);      /* its wooden hull */
  --jakarta-sea: var(--500);            /* the harbour water round it */
  --jakarta-timber-dark: var(--map-wood);   /* a big tree's trunk and boughs: DOS-AGE's wood (#8f563b) */
  /* The one-tile signs, told apart by shape and by colour (red, orange, gold), from the theme's map tones: */
  --jakarta-house: var(--map-fruit);    /* DOS-AGE's house where people live: red, a terracotta roof */
  --jakarta-tower: color-mix(in srgb, var(--map-fruit), var(--map-ore));   /* its window block at each high-rise: orange,
     the map's red and yellow half and half (near DOS-AGE's #df7126, which is the theme's warning, so not borrowed) */
  --jakarta-church: var(--gilt);        /* its cross at a church: gilt */
  --jakarta-lit: var(--gilt);           /* a house's or tower's windows at night */
  --jakarta-train: var(--map-fruit);    /* a KRL train's carriages: DOS-AGE's red */
  --jakarta-people: var(--900);         /* people on the streets, in three shirts: light, */
  --jakarta-people-2: var(--map-sand);  /* sand, */
  --jakarta-people-3: var(--kin-2);     /* and DOS-AGE's pink */
  --jakarta-leaf: var(--map-grass);     /* a big tree's crown */
  --jakarta-canopy: color-mix(in srgb, var(--map-grass) 15%, color-mix(in srgb, var(--700) 30%, var(--bg)));   /* the grey-green under its leaves, as DOS-AGE's #323c39 is (tools/biomes/forest-1.png) */
  --jakarta-label: var(--bg);           /* a name's block: the ground */
  --jakarta-name-ink: var(--text-strong);
  --jakarta-city-label: var(--motif-2); /* a city's block: DOS-AGE's blue2 (#3f3f74), DOS Age's --motif-2 */
  --jakarta-earth: var(--map-earth);      /* a landmark's dark wood (DOS-AGE's #663931) */
  --jakarta-roof-dark: color-mix(in srgb, var(--map-fruit) 55%, var(--bg));   /* a red house's dark red (#661c31) */
  --jakarta-rock: var(--600);             /* the cave's dark rock (#4c4147) */
  --jakarta-dark: var(--100);             /* behind a landmark's walls: the theme's darkest (DOS-AGE's #071324) */
  --jakarta-park: var(--tilemap-ground);   /* a park's ground: the plain ground (a theme may tint it) */
  --jakarta-gutter: max(var(--space-4), env(safe-area-inset-left), env(safe-area-inset-right));
}

/* Old map (MEK's ask; the art library's palette): the system's Light theme read as an old map, iron-gall ink on
   parchment, in its own tokens only. The ground is parchment (--bg, and --surface a step darker: the tile map, the
   boxes, the labels and the fog follow it); the town and streets drawn in sepia (--map-earth) and sand; the sea a
   faded tint of the map's water; houses rubric, towers rubric and gilt, churches and lit windows gilt; the names in
   sepia, a city's a rubricated title (rubric, its letters the ground). The accent is rubric too, so the picked name
   and the houses are one red, and the keys and the wordmark gilt. */
:root[data-theme="light"] {
  --bg: color-mix(in srgb, var(--map-sand) 25%, var(--100));
  --surface: color-mix(in srgb, var(--map-earth) 8%, var(--bg));
  --text-muted: color-mix(in srgb, var(--map-earth) 60%, var(--700));
  --accent: var(--rubric); --key: var(--gilt);
  --jakarta-park: var(--bg); --jakarta-town: color-mix(in srgb, var(--map-sand) 50%, var(--bg));
  --jakarta-street: color-mix(in srgb, var(--map-earth) 45%, var(--bg)); --jakarta-road: var(--map-earth); --jakarta-rail: var(--900);
  --jakarta-mid: color-mix(in srgb, var(--map-water) 35%, var(--bg)); --jakarta-sea: color-mix(in srgb, var(--map-water) 35%, var(--bg));
  --jakarta-deep: color-mix(in srgb, var(--map-water) 20%, var(--bg)); --jakarta-speck: color-mix(in srgb, var(--map-earth) 30%, var(--bg));
  --jakarta-dark: var(--1000); --jakarta-sand: var(--map-sand); --jakarta-stone: var(--100); --jakarta-stone-dark: var(--map-earth);
  --jakarta-house: var(--rubric); --jakarta-tower: color-mix(in srgb, var(--rubric), var(--gilt)); --jakarta-church: var(--gilt);
  --jakarta-lit: var(--gilt); --jakarta-train: var(--rubric); --jakarta-roof: var(--rubric); --jakarta-hull: var(--map-wood);
  --jakarta-leaf: color-mix(in srgb, var(--map-grass) 50%, var(--bg)); --jakarta-canopy: color-mix(in srgb, var(--map-grass) 18%, var(--bg));
  --jakarta-label: var(--bg); --jakarta-name-ink: var(--map-earth); --jakarta-city-label: var(--rubric);
  --jakarta-people-3: var(--map-wood);   /* the third shirt in the map's brown, not a modern pink */
}
:root[data-theme="light"] .jakarta-name.city { color: var(--bg); }
:root[data-theme="light"] .jakarta-stage { --tilemap-mark: color-mix(in srgb, var(--map-earth) 45%, var(--bg)); }
:root[data-theme="light"] .jakarta-mini { --hud-map-water: color-mix(in srgb, var(--map-water) 35%, var(--bg)); --hud-map-grass: color-mix(in srgb, var(--map-grass) 50%, var(--bg));
  --hud-map-floor: color-mix(in srgb, var(--map-sand) 50%, var(--bg)); --hud-map-wall: color-mix(in srgb, var(--map-earth) 45%, var(--bg)); }

html, body.jakarta { height: 100%; overflow: hidden; overscroll-behavior: none; }
body.jakarta { background: var(--tilemap-ground); }

/* The map: the whole window, dragged by hand (pan.js), so the browser's own scroll and zoom stay out of it. */
.jakarta-stage { position: fixed; inset: 0; overflow: hidden; touch-action: none; cursor: grab; --tilemap-mark: var(--text-muted); }
.jakarta-stage:active { cursor: grabbing; }
.jakarta-stage:focus-visible { outline: var(--stroke) dashed var(--focus-ring); outline-offset: -4px; }
.jakarta-map, .jakarta-air { position: absolute; top: 0; left: 0; }
.jakarta-air { pointer-events: none; image-rendering: pixelated; }
.jakarta-air[hidden], .jakarta-mini-box[hidden] { display: none; }   /* rain, glints, fireflies: weather.js, over the map */

/* Touch screens (no hover): the TUI controls' dissolve is a 2px conic-gradient tile whose stops sit at zero width at
   rest, and WebKit (every iPhone browser) leaves seams there, a grey dot grid over every button on a 3× screen; and a
   tap leaves :hover stuck. So with no hover, nothing is painted at rest and a press or focus is the solid inverse cell
   (the system's focus look, at once). Deviation until the system's TUI part fixes it (HQ t119). */
@media (hover: none) {
  .jakarta-box :is(.tui-btn, .tui-menu > button, .tui-check, .pick-btn, .pick-menu button) { background: none; transition: none; }
  .jakarta-box :is(.tui-btn, .tui-menu > button, .tui-check, .pick-btn, .pick-menu button):hover { --dz: 0; }
  .jakarta-box :is(.tui-btn, .tui-menu > button, .pick-btn, .pick-menu button):is(:focus-visible, :active),
  .jakarta-box .tui-menu > button:focus, .jakarta-box .pick-menu button:focus,
  .jakarta-box .tui-check:has(input:focus-visible) { --dz: 1; background: var(--text-strong); }
}

/* ---------- The TUI boxes ----------
   Every box over the map is a .tui.tui-lg .jakarta-box: the ground, a single-line edge drawn in cells (frame.js, the
   system's mekTui.canvas) in the muted ink, one row and one or two cells of padding inside it, its title notched in
   the top edge (.jakarta-title), Esc or the OSM line in the foot (.jakarta-foot). Every size is whole cells, so the
   edge closes. Words wrap inside (the TUI keeps white space only in its drawings). Deviation: the system has no TUI
   window yet (HQ t118); this goes when it does. */
.jakarta-box { --cw: 1ch; --lh: 30px;   /* the 14 × 30 cell of .tui-lg (tui.css) */
  position: fixed; z-index: var(--z-sticky); margin: 0; padding: var(--lh) calc(2 * var(--cw)); box-sizing: border-box; border: 0;
  background: var(--bg); color: var(--text); --tui-edge: var(--text-muted); white-space: normal; }
.jakarta-box[hidden] { display: none; }
dialog.jakarta-box { position: fixed; inset: 0; margin: auto; }
.jakarta-box > .frame { position: absolute; inset: 0; margin: 0; pointer-events: none; color: var(--tui-edge); font: inherit; line-height: inherit; white-space: pre; }
.jakarta-box :is(h1, h2, h3, p, fieldset, form) { margin: 0; padding: 0; border: 0; font: inherit; line-height: inherit; }
.jakarta-title { position: absolute; top: 0; left: calc(2 * var(--cw)); padding: 0 var(--cw); background: var(--bg); white-space: pre; }
.jakarta-foot { position: absolute; bottom: 0; right: calc(2 * var(--cw)); padding: 0 var(--cw); background: var(--bg); }

/* The minimap: the HUD's, wide, in a box round it top right (top left on a phone, where the OSM line has the right). */
.jakarta-mini-box { top: max(var(--space-4), env(safe-area-inset-top)); right: var(--jakarta-gutter); padding: var(--lh) var(--cw);
  display: grid; place-items: center; }   /* never narrower than its name, notched in the middle (frame.js) */
/* The HUD's picture fills the box: its own pixel rim taken off (the box's edge is the frame), the ring it leaves taken
   back with a margin, so what's laid out is the tiles alone: 46 × 30 of them, at 4px (184 × 120, four rows of cells),
   3px on a phone (three rows). The landmarks are gilt, as Monas's flame and the churches' crosses: never the
   strong ink of the arrow where the view is (they'd run together), nor the accent, the picked name's alone. */
.jakarta-mini { --hud-px: 4px; margin: calc(-1 * var(--p)); --hud-map-water: var(--500); --hud-map-landmark: var(--gilt);
  --hud-map-me: transparent; --hud-map-view: var(--text-strong); }   /* the city held still, the view a mark (minimap.js) */
.jakarta-mini > :is([data-l="rim"], [data-l="rim-shade"], [data-l="rim-glint"]) { display: none; }

/* Zoom out and in (MEK's ask): the system's minus and plus at 2× in their brackets, a box of whole cells top left, as
   tall as the minimap's title row is from the top; a pinch, the wheel, the keys and a double tap zoom too. */
.jakarta-zoom { top: max(var(--space-4), env(safe-area-inset-top)); left: var(--jakarta-gutter); padding: var(--lh) var(--cw);
  display: flex; gap: 0 1ch; }
.jakarta-zoom .jakarta-icon { width: 2ch; height: 30px; vertical-align: top; overflow: visible; }
/* Its brackets tight round the icon, [-] [+] (MEK's ask): the TUI's "[ " and " ]" hidden, a bare bracket drawn in each. */
.jakarta-zoom .tui-btn > [data-tui-mark] { font-size: 0; }
.jakarta-zoom .tui-btn > [data-tui-mark]:first-child::before { content: "["; font-size: var(--tui-size, 24px); }
.jakarta-zoom .tui-btn > [data-tui-mark]:last-child::before { content: "]"; font-size: var(--tui-size, 24px); }

/* The landmarks: a button over each one's cells (the tile map draws them), to tap or reach with Tab. */
.jakarta-marks { position: absolute; inset: 0; pointer-events: none; }
.jakarta-mark { position: absolute; left: 0; top: 0; padding: 0; border: 0; background: none; cursor: pointer; pointer-events: auto; }

/* The names written on the map (names.js): a row of cells each, Dosage Mono 24 (the TUI's large cells) on a block a
   cell wider each side, so it reads over any tile: districts in the strong ink on the ground, places to see the other
   way round (the ground on the muted ink). Cities in MEKZANTINE
   capitals (MEK's ask) on DOS-AGE's blue2. labels.js keeps them apart by these blocks (names.js measures them). */
.jakarta-names { position: absolute; inset: 0; pointer-events: none; }
.jakarta-names[hidden] { display: none; }
.jakarta-name {
  position: absolute; left: 0; top: 0; white-space: pre; color: var(--jakarta-name-ink); background: var(--jakarta-label);
  font: 24px/30px var(--font-dosage-mono); padding: 0 14px;
}
.jakarta-name.city {
  font: 36px/60px var(--font-blackletter); text-transform: uppercase; letter-spacing: 2px; padding: 0 14px;
  background: var(--jakarta-city-label);
}
.jakarta-name.poi { background: var(--text-muted); color: var(--bg); }

/* What else sits over the map, 16px in from the window's edges and past the safe area. */
.jakarta-failed, .jakarta-loading { position: fixed; z-index: var(--z-sticky); }
.jakarta-loading { top: 50%; left: 50%; transform: translate(-50%, -50%); margin: 0; padding: var(--space-2) var(--space-3); background: var(--bg); }
.jakarta-loading[hidden] { display: none; }
.jakarta-failed { top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(360px, calc(100vw - 2 * var(--space-4))); background: var(--bg); }

/* The toolbar: at the bottom middle, as wide as its tools (whole cells, never past the window's), wrapping to more rows
   where it must. Its name in MEKZANTINE notched in the middle of the top edge, a size over the cells (its own grid's 36),
   centred on the edge's row; the OSM credit in its foot, on the right. */
.jakarta-dock { bottom: max(var(--space-4), env(safe-area-inset-bottom)); left: 0; right: 0; margin-inline: auto;
  width: fit-content; max-width: calc(100vw - 2 * var(--jakarta-gutter));   /* (for a browser without round()) */
  max-width: round(down, 100vw - 2 * var(--jakarta-gutter), 1ch); }
.jakarta-dock .jakarta-word { position: absolute; top: 0; left: 0; padding: 0; text-align: center; background: var(--bg);
  font: 18px/30px var(--font-blackletter); color: var(--key); white-space: pre; overflow: visible; }   /* the keys' quiet accent (MEK's ask) */
.jakarta-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 1ch; }
.jakarta-tools .jakarta-icon { display: none; width: 3ch; height: 30px; padding: 0 6px; box-sizing: border-box; vertical-align: top; }
/* The OSM credit, small: Dosage Humanist 12 (on its 12 grid; under the system's 14, MEK's ask), notched in the foot. */
.jakarta-dock .jakarta-osm { position: absolute; bottom: 0; right: calc(2 * var(--cw)); padding: 0 7px; background: var(--bg); white-space: pre;
  font: 12px/30px var(--font-dosage); }
.jakarta-osm .link { font: inherit; line-height: inherit; }
/* Layers: what's drawn, each a check in cells, in a box standing on the toolbar's right (opened by its Layers
   button); two columns where there's room. */
.jakarta-layers { position: absolute; bottom: 100%; right: 0; }
.jakarta-layers fieldset { display: grid; grid-template-columns: repeat(2, 20ch); gap: 0 2ch; }
.jakarta-layers .tui-check { display: block; white-space: pre; }
/* While Layers is open the dock lifts over everything else on the page (the system's rule for an open popup). */
.jakarta-dock:has([aria-expanded="true"]) { z-index: var(--z-menu); }
@media (max-width: 640px) {
  .jakarta-dock { padding-inline: var(--cw); }
  /* The toolbar on one row (MEK's ask): Layers, the city, the theme. Layers and the theme as the system's menu and fill
     icons at 2× (30px, a row tall) in two cells, without their brackets, their names kept for a screen reader; the city
     pick without its brackets either, a cell before its caret. 21 cells in all, so a 360px phone holds it. */
  .jakarta-tools { flex-wrap: nowrap; }
  .jakarta-tools .jakarta-long, .jakarta-theme [data-pick-value] { display: none; }
  .jakarta-tools .jakarta-icon { display: inline-block; width: 2ch; padding: 0; overflow: visible; }
  .jakarta-tools :is([data-layers-open], .pick-btn) > [data-tui-mark] { font-size: 0; }   /* (the brackets' text, gone) */
  .jakarta-city .pick-btn .tui-caret { font-size: var(--tui-size, 24px); margin-left: 1ch; }
  /* The minimap's box without its picture or the city's name (MEK's ask; the toolbar names the city): only Stats, in
     its foot, at the top left. */
  .jakarta-mini-box { right: auto; left: var(--jakarta-gutter); }
  /* Zoom at the top right (Stats has the left), its minus and plus without their brackets, as the toolbar's icons. */
  .jakarta-zoom { left: auto; right: var(--jakarta-gutter); gap: 0 2ch; }
  .jakarta-zoom .tui-btn > [data-tui-mark]:is(:first-child, :last-child)::before { content: none; }
  .jakarta-mini, .jakarta-mini-box .jakarta-title { display: none; }
  .jakarta-mini-box .jakarta-foot { position: static; padding: 0; background: none; }   /* (Stats in the box, one row, as Zoom) */
  /* The OSM line leaves the foot (the toolbar is narrower than it) for just over the toolbar, on its right: hung from
     the toolbar itself, so no browser's idea of the window's bottom (an in-app browser's, under its own bar) can put it
     anywhere else. */
  .jakarta-dock .jakarta-osm { bottom: calc(100% + var(--space-2)); right: 0; line-height: 18px; }
  .jakarta-layers fieldset { grid-template-columns: 20ch; }
}

/* The cards: someone met in the street and a landmark, as Village's card in the large cells: the picture in a slot of
   whole cells on the left (cards.js), standing on its foot, the words beside it; a blank row between the words and a
   landmark's facts. */
.jakarta-card[open] { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; column-gap: 2ch;
  width: min(46ch, round(down, 100vw - 2 * var(--jakarta-gutter), 1ch)); max-width: none; max-height: round(down, 100dvh - 2 * var(--space-4), 30px); overflow: hidden; }
.jakarta-card-slot { position: relative; display: grid; place-items: end center; }
.jakarta-card-slot canvas { display: block; image-rendering: pixelated; }
.jakarta-card-words { display: grid; }
.jakarta-card-words > p:first-child { margin-bottom: 0; }
.jakarta-facts { padding-top: var(--lh); }
.jakarta-facts p { white-space: pre; overflow: hidden; }
/* City stats: the card without a picture, one column of rows (cards.js statsCard): a group's title in the strong ink,
   its facts on leaders, its source in the dim, a blank row between; a value with no room for dots on its own row, at
   the far side. */
.jakarta-stats[open] { grid-template-columns: minmax(0, 1fr); width: min(36ch, calc(100vw - 2 * var(--jakarta-gutter)));   /* (for a browser without round()) */
  width: min(36ch, round(down, 100vw - 2 * var(--jakarta-gutter), 1ch)); }
.jakarta-stats-rows { display: grid; align-content: start; min-height: 0; max-height: 100%; overflow-y: auto; overscroll-behavior: contain; }   /* a short window scrolls the rows, the edge stays */
.jakarta-stats-rows p { margin: 0; white-space: pre; overflow: hidden; }
.jakarta-far { text-align: end; }
.jakarta-stats-rows .link { font: inherit; line-height: inherit; }
/* On a phone the picture stands over the words, and the words scroll inside the edge where the window is short. */
@media (max-width: 640px) { .jakarta-card[open] { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); padding-inline: var(--cw); }
  .jakarta-card-slot { justify-self: start; } .jakarta-card-words { overflow-y: auto; overscroll-behavior: contain; max-height: 100%; } }
