/* TRUE SCALE · real size map. Colours from the video engine (fit.py). */
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-style: normal; font-display: swap; src: url('../fonts/barlow-condensed-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 700; font-style: normal; font-display: swap; src: url('../fonts/barlow-condensed-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 800; font-style: normal; font-display: swap; src: url('../fonts/barlow-condensed-latin-800-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 400; font-style: normal; font-display: swap; src: url('../fonts/inter-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 500; font-style: normal; font-display: swap; src: url('../fonts/inter-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-style: normal; font-display: swap; src: url('../fonts/inter-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 700; font-style: normal; font-display: swap; src: url('../fonts/inter-latin-700-normal.woff2') format('woff2'); }

:root {
  --bg0: #080B1A;
  --bg1: #111836;
  --ink: #1E274E;
  --rim: #96A6DC;
  --yel: #FFD23F;
  --white: #F6F4EE;
  --red: #FF5C4E;
  --grn: #60E092;
  --panel: rgba(8, 11, 26, 0.84);
  --panel-solid: #0B1024;
  --line: rgba(150, 166, 220, 0.20);
  --muted: rgba(246, 244, 238, 0.62);
  --cond: 'Barlow Condensed', 'Avenir Next Condensed', 'Arial Narrow', sans-serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r: 16px;
  --gut: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg0); color: var(--white); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.app { position: fixed; inset: 0; }

/* ------------------------------------------------------------ map */
.stage { position: absolute; inset: 0; overflow: hidden; background: linear-gradient(180deg, var(--bg0), var(--bg1)); }
.map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; outline: none; }
.map.dragging { cursor: grabbing; }
.map:focus-visible { box-shadow: inset 0 0 0 2px var(--yel); }

.loading { position: absolute; left: 50%; top: 50%; width: 36px; height: 36px; margin: -18px 0 0 -18px; border-radius: 50%;
  border: 3px solid rgba(150, 166, 220, 0.25); border-top-color: var(--yel); animation: spin 0.9s linear infinite; }
.loading.done { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.hint { position: absolute; left: 0; top: 0; pointer-events: none; display: flex; align-items: center; gap: 8px;
  padding: 8px 14px 8px 10px; border-radius: 999px; background: var(--yel); color: var(--bg0);
  font: 800 17px/1 var(--cond); letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45); transform: translate(-50%, -100%); z-index: 3; }
.hint::after { content: ''; position: absolute; left: 50%; bottom: -6px; width: 12px; height: 12px; margin-left: -6px; background: var(--yel); transform: rotate(45deg); border-radius: 2px; }
.hint-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bg0); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(0.55); opacity: 0.6; } }

.zoom { position: absolute; right: var(--gut); display: flex; flex-direction: column; gap: 8px; z-index: 2; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); display: grid; place-items: center; cursor: pointer; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.icon-btn:hover { border-color: rgba(150, 166, 220, 0.5); }
.icon-btn:active { transform: scale(0.96); }

/* ------------------------------------------------------------ panels (mobile first: overlays) */
.top-ui, .bottom-ui { position: absolute; left: 0; right: 0; z-index: 4; padding: 0 var(--gut); pointer-events: none; }
.top-ui > *, .bottom-ui > * { pointer-events: auto; }
.top-ui { top: 0; padding-top: max(10px, env(safe-area-inset-top)); background: linear-gradient(180deg, rgba(8, 11, 26, 0.92) 55%, rgba(8, 11, 26, 0)); padding-bottom: 14px; }
.bottom-ui { bottom: 0; padding-bottom: max(8px, env(safe-area-inset-bottom)); background: linear-gradient(0deg, rgba(8, 11, 26, 0.9) 18%, rgba(8, 11, 26, 0) 60%); }
.explainer { display: none; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand-wrap { min-width: 0; }
.brand { margin: 0; font: 800 30px/0.9 var(--cond); letter-spacing: 0.02em; text-transform: uppercase; white-space: nowrap; }
.brand-y { color: var(--yel); }
.tagline { margin: 3px 0 0; font: 500 12.5px/1.2 var(--sans); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; gap: 6px; flex: none; }
.act-btn { display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); cursor: pointer; font: 600 14px/1 var(--sans); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.act-btn:hover { border-color: rgba(150, 166, 220, 0.5); }
.act-btn:active { transform: scale(0.97); }
.act-btn svg { width: 18px; height: 18px; }

.search { position: relative; margin-top: 10px; }
.search-ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
#search-input { width: 100%; height: 48px; padding: 0 14px 0 44px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel-solid);
  color: var(--white); font: 500 16px/1 var(--sans); outline: none; -webkit-appearance: none; appearance: none; }
#search-input::placeholder { color: rgba(246, 244, 238, 0.45); }
#search-input:focus { border-color: var(--yel); }
#search-input::-webkit-search-cancel-button { -webkit-appearance: none; }
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none; border-radius: 14px;
  background: var(--panel-solid); border: 1px solid var(--line); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55); max-height: 50vh; overflow-y: auto; z-index: 10; }
.suggest li { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 46px; padding: 0 12px; border-radius: 10px; cursor: pointer; font: 500 15px/1.2 var(--sans); }
.suggest li[aria-selected="true"], .suggest li:hover { background: rgba(150, 166, 220, 0.14); }
.suggest .s-meta { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.suggest .s-empty { color: var(--muted); cursor: default; }

.examples { touch-action: pan-x; display: flex; gap: 6px; margin: 10px calc(-1 * var(--gut)) 0; padding: 0 var(--gut) 2px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.examples::-webkit-scrollbar { display: none; }
.ex-btn { flex: none; height: 36px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer;
  font: 700 15px/1 var(--cond); letter-spacing: 0.03em; text-transform: uppercase; white-space: nowrap; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.ex-btn:hover { border-color: var(--yel); }
.ex-btn[aria-pressed="true"] { background: var(--yel); color: var(--bg0); border-color: var(--yel); }

.readout { padding: 12px 14px 12px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.ro-head { display: flex; align-items: center; gap: 10px; min-height: 32px; }
.ro-dot { width: 12px; height: 12px; border-radius: 4px; flex: none; background: var(--yel); }
.ro-id { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.ro-name { font: 800 19px/1 var(--cond); letter-spacing: 0.03em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ro-area { font: 500 12.5px/1.2 var(--sans); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ro-area:empty { display: none; }
.mini-btn { display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--line); background: transparent; cursor: pointer; font: 600 12.5px/1 var(--sans); color: var(--muted); flex: none; }
.mini-btn svg { width: 15px; height: 15px; }
.mini-btn:hover { color: var(--white); border-color: rgba(150, 166, 220, 0.5); }
.ro-main { margin: 8px 0 0; font: 700 25px/1.08 var(--cond); letter-spacing: 0.005em; text-wrap: balance; }
.ro-main .hl, .ro-sub .hl { color: var(--yel); }
.ro-sub { margin: 5px 0 0; font: 500 14px/1.3 var(--sans); color: var(--muted); }
.ro-sub:empty { display: none; }

.chips { touch-action: pan-x; display: flex; gap: 6px; margin: 8px calc(-1 * var(--gut)) 0; padding: 0 var(--gut); list-style: none; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips:empty { display: none; }
.chip { flex: none; display: flex; align-items: center; height: 40px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.chip.active { border-color: var(--white); }
.chip-sel { display: flex; align-items: center; gap: 7px; height: 100%; padding: 0 4px 0 12px; border: 0; background: transparent; cursor: pointer; font: 700 15px/1 var(--cond); letter-spacing: 0.03em; text-transform: uppercase; white-space: nowrap; }
.chip-dot { width: 10px; height: 10px; border-radius: 3px; }
.chip-x { width: 40px; height: 40px; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--muted); border-radius: 999px; }
.chip-x:hover { color: var(--white); }
.chip-x svg { width: 16px; height: 16px; }

.sources { margin-top: 6px; font: 400 11px/1.4 var(--sans); color: rgba(246, 244, 238, 0.5); }
.sources summary { cursor: pointer; list-style: none; padding: 2px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sources summary::-webkit-details-marker { display: none; }
.sources summary::before { content: '\24D8'; margin-right: 5px; }
.sources details[open] { padding: 8px 10px; border-radius: 12px; background: var(--panel-solid); border: 1px solid var(--line); }
.sources p { margin: 6px 0 0; }

.toast { position: absolute; left: 50%; bottom: var(--bottom-inset, 40%); transform: translateX(-50%); z-index: 20; pointer-events: none; white-space: normal; width: max-content; max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 12px;
  background: var(--white); color: var(--bg0); font: 600 14px/1.35 var(--sans); box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5); word-break: break-word; text-align: center; }
.toast.sticky { pointer-events: auto; }

@media (max-width: 599px) { .tagline { display: none; } }

/* phones up to 430 px: the wordmark keeps its room, Save image goes icon-only */
@media (max-width: 599px) { .brand-wrap { flex: none; } }
@media (max-width: 430px) {
  #btn-save span { display: none; }
  #btn-save { padding: 0; width: 44px; justify-content: center; }
}

/* small phones */
@media (max-width: 370px) {
  .act-btn span { display: none; }
  .act-btn { padding: 0; width: 44px; justify-content: center; }
  .brand { font-size: 27px; }
}

/* ------------------------------------------------------------ desktop: side panel */
@media (min-width: 900px) {
  :root { --gut: 20px; }
  .app { display: grid; grid-template-columns: 400px 1fr; grid-template-rows: auto 1fr; }
  .stage { position: relative; grid-column: 2; grid-row: 1 / span 2; }
  .top-ui, .bottom-ui { position: relative; grid-column: 1; background: var(--bg0); pointer-events: auto; left: auto; right: auto; top: auto; bottom: auto; }
  .top-ui { grid-row: 1; padding: 22px var(--gut) 0; background: var(--bg0); }
  .bottom-ui { grid-row: 2; padding: 16px var(--gut) 18px; display: flex; flex-direction: column; overflow-y: auto; border-right: 1px solid var(--line); }
  .top-ui { border-right: 1px solid var(--line); }
  .brand { font-size: 38px; }
  .tagline { font-size: 13.5px; margin-top: 6px; }
  .topbar { align-items: flex-start; }
  .actions { flex-direction: column; }
  .act-btn { height: 38px; font-size: 13.5px; }
  .examples { flex-wrap: wrap; overflow: visible; margin: 14px 0 0; padding: 0; }
  .readout { background: rgba(150, 166, 220, 0.06); backdrop-filter: none; }
  .ro-main { font-size: 32px; }
  .ro-name { font-size: 22px; }
  .chips { flex-wrap: wrap; overflow: visible; margin: 12px 0 0; padding: 0; }
  .chip { background: rgba(150, 166, 220, 0.06); }
  .explainer { display: block; margin: 18px 2px 0; font: 400 13.5px/1.55 var(--sans); color: var(--muted); max-width: 36em; }
  .sources { margin-top: auto; padding-top: 16px; font-size: 12px; }
  .sources details { }
  .sources summary { white-space: normal; }
  .zoom { bottom: 24px; right: 24px; }
  .toast { top: auto; bottom: 32px; transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  .hint-dot, .loading { animation: none; }
}
