/* ReliefMap — map-page layout (css/map.css)
 * Layout chrome for index.html only. Design tokens + card internals live in css/relief.css. */

html, body { height: 100%; margin: 0; }

.map-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--ops-deep);
  color: var(--ops-text);
  font-family: 'Public Sans', system-ui, sans-serif;
}
.map-page button { font-family: inherit; }
.map-page :focus-visible { outline: 2px solid var(--safety); outline-offset: 2px; }

/* ---------- header ---------- */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 54px;
  padding: 0 16px;
  background: var(--ops);
  border-bottom: 1px solid var(--ops-line);
}
.brand-block { line-height: 1.15; }
.brand {
  font-weight: 800;
  font-size: 19px;
  letter-spacing: 0.05em;
  color: #fff;
}
.brand-accent { color: var(--safety); }
.brand-sub {
  font-family: 'Courier Prime', monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ops-text-dim);
}
.program-tag {
  font-family: 'Courier Prime', monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ops-text-dim);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
}
.topbar-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}
.user-email { font-size: 12px; color: var(--ops-text-dim); }

/* ---------- persistent synthetic banner (never dismissable) ---------- */
.syn-banner {
  flex: none;
  position: relative;
  height: 28px;
  line-height: 28px;
  text-align: center;
  background: var(--ops-deep);
  border-bottom: 1px solid var(--ops-line);
  color: var(--hazard);
  font-family: 'Courier Prime', monospace;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  overflow: hidden;
}
.syn-banner::before,
.syn-banner::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 52px;
  background: repeating-linear-gradient(-45deg, var(--hazard) 0 9px, #191913 9px 18px);
  opacity: 0.85;
}
.syn-banner::before { left: 0; }
.syn-banner::after { right: 0; }

/* ---------- board ---------- */
.board { position: relative; flex: 1; min-height: 0; }
#map { position: absolute; inset: 0; }

/* shared floating-panel look */
.panel {
  background: var(--ops-panel);
  background: color-mix(in srgb, var(--ops-panel) 93%, transparent);
  border: 1px solid var(--ops-line);
  border-radius: var(--r);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(5px);
}

/* ---------- top-left overlays: control bar + stat strip ---------- */
.overlays-tl {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 396px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  pointer-events: none;
}
.overlays-tl > * { pointer-events: auto; }

.ctrlbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  max-width: 100%;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  background: var(--ops-deep);
  border: 1px solid var(--ops-line);
  color: var(--ops-text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}
.chips .chip:hover { border-color: var(--ops-text-dim); }
.chips .chip.off { opacity: 0.35; }
.chip-count {
  font-family: 'Courier Prime', monospace;
  font-weight: 700;
  font-size: 11px;
  color: var(--ops-text-dim);
  min-width: 2ch;
  text-align: right;
}
.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

.ctrl-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.tglbtn {
  font-family: 'Courier Prime', monospace;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ops-text);
  background: var(--ops-deep);
  border: 1px solid var(--ops-line);
  border-radius: var(--r);
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.tglbtn:hover { border-color: var(--ops-text-dim); }
.tglbtn.on {
  background: var(--safety);
  border-color: var(--safety);
  color: var(--ops-deep);
}

/* search */
.searchbox { position: relative; }
.searchbox input {
  width: 230px;
  background: var(--ops-deep);
  border: 1px solid var(--ops-line);
  border-radius: var(--r);
  color: var(--ops-text);
  font: inherit;
  font-size: 13px;
  padding: 6px 10px;
}
.searchbox input::placeholder { color: var(--ops-text-dim); }
.search-drop {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 320px;
  max-height: 330px;
  overflow-y: auto;
  background: var(--ops-panel);
  border: 1px solid var(--ops-line);
  border-radius: var(--r);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  z-index: 7;
}
.search-drop.open { display: block; }
.srow {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  background: none;
  border: 0;
  color: var(--ops-text);
  font-size: 12px;
  cursor: pointer;
}
.srow:hover, .srow.sel { background: var(--ops-deep); }
.srow-none { cursor: default; color: var(--ops-text-dim); }
.srow .s-code {
  font-family: 'Courier Prime', monospace;
  font-weight: 700;
  font-size: 11px;
  color: var(--safety);
  flex: none;
}
.srow .s-name {
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.srow .s-sub { margin-left: auto; color: var(--ops-text-dim); font-size: 11px; flex: none; }

/* stat strip */
.statstrip { display: flex; padding: 7px 4px; }
.stat {
  display: flex;
  flex-direction: column;
  padding: 2px 18px;
  border-right: 1px solid var(--ops-line);
}
.stat:last-child { border-right: 0; }
.stat-num {
  font-family: 'Courier Prime', monospace;
  font-weight: 700;
  font-size: 20px;
  line-height: 1.1;
  color: #fff;
}
.stat-num.num-unmet { color: var(--safety); }
.stat-num.num-problem { color: var(--st-problem); }
.stat-num.num-unclaimed { color: var(--st-unclaimed); }
.stat-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ops-text-dim);
}

/* ---------- right side panel: viewport list + legend + roadmap ---------- */
.side {
  position: absolute;
  top: 12px;
  right: 12px;
  bottom: 12px;
  width: 372px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.side-head {
  flex: none;
  padding: 10px 14px;
  border-bottom: 1px solid var(--ops-line);
  font-family: 'Courier Prime', monospace;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ops-text);
}
.claim-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--ops-line) transparent;
}
.list-empty {
  padding: 26px 18px;
  text-align: center;
  font-family: 'Courier Prime', monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ops-text-dim);
}
.list-sentinel { height: 2px; }

.crow {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--ops-line);
  color: var(--ops-text);
  cursor: pointer;
}
.crow:hover { background: var(--ops-deep); }
.crow.sel { background: var(--ops-deep); box-shadow: inset 3px 0 0 var(--safety); }
.crow-glyph {
  flex: none;
  width: 22px;
  text-align: center;
  font-size: 15px;
  color: var(--sage);
}
.crow-main { flex: 1; min-width: 0; }
.crow-top { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.crow-code {
  font-family: 'Courier Prime', monospace;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--safety);
  flex: none;
}
.crow-name {
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.crow-sub {
  display: block;
  font-size: 11px;
  color: var(--ops-text-dim);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.crow-side {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}
.crow-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
}
.crow-status .dot { width: 8px; height: 8px; }
.crow-meta {
  font-family: 'Courier Prime', monospace;
  font-size: 11px;
  color: var(--ops-text-dim);
}

/* legend */
.legend { flex: none; border-top: 1px solid var(--ops-line); padding: 8px 14px 10px; }
.legend-title {
  font-family: 'Courier Prime', monospace;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ops-text-dim);
  margin-bottom: 6px;
}
.legend-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px 10px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--ops-text);
}
.legend-item .dot { width: 8px; height: 8px; }

/* roadmap */
.roadmap { flex: none; border-top: 1px solid var(--ops-line); }
.roadmap-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: 0;
  text-align: left;
  cursor: pointer;
  color: var(--ops-text);
  font-family: 'Courier Prime', monospace;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.roadmap-caret { color: var(--ops-text-dim); }
.roadmap-list { display: none; margin: 0; padding: 0 14px 12px; list-style: none; }
.roadmap.open .roadmap-list { display: block; }
.roadmap-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 3px 0;
  font-size: 12px;
  color: var(--ops-text);
}
.tag-planned {
  flex: none;
  font-family: 'Courier Prime', monospace;
  font-weight: 700;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--hazard);
  border: 1px solid var(--hazard);
  border-radius: 3px;
  padding: 1px 5px;
}

/* ---------- claim detail panel (slide-in) ---------- */
.detail {
  position: absolute;
  top: 12px;
  right: 12px;
  bottom: 12px;
  width: 398px;
  max-width: calc(100% - 24px);
  z-index: 8;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--ops);
  border: 1px solid var(--ops-line);
  border-radius: var(--r);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
  transform: translateX(calc(100% + 26px));
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.detail.open { transform: translateX(0); }
.detail-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px 8px 16px;
  border-bottom: 1px solid var(--ops-line);
}
.detail-code {
  font-family: 'Courier Prime', monospace;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--safety);
}
.detail-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--ops-line);
  background: var(--ops-deep);
  color: var(--ops-text);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.detail-close:hover { border-color: var(--safety); color: var(--safety); }
.detail-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 18px 22px;
  scrollbar-width: thin;
  scrollbar-color: var(--ops-line) transparent;
}
#detailCard { display: flex; justify-content: center; padding: 16px 0 4px; }

.detail-loading, .detail-error, .d-none-note {
  font-family: 'Courier Prime', monospace;
  font-size: 12px;
  color: var(--ops-text-dim);
  padding: 12px 0;
}
.detail-error { color: var(--st-problem); }
.detail-error .tglbtn { margin-top: 8px; }

.dsection { margin-top: 20px; }
.dsection-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: 'Courier Prime', monospace;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ops-text-dim);
  border-bottom: 1px solid var(--ops-line);
  padding-bottom: 5px;
  margin-bottom: 9px;
}
.dsection-title .syn { color: var(--hazard); }

.narrative {
  margin: 0;
  font-family: 'Newsreader', Georgia, serif;
  font-style: italic;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ops-text);
}

.fl { margin-bottom: 10px; }
.fl-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-family: 'Courier Prime', monospace;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.07em;
}
.fl-name { color: var(--st-problem); }
.fl-days { color: var(--st-problem); flex: none; }
.fl.resolved .fl-name { color: var(--ops-text-dim); }
.fl.resolved .fl-days { color: var(--st-disbursed); }
.fl-detail { margin-top: 2px; font-size: 12px; line-height: 1.45; color: var(--ops-text); }

.ev-ledger { font-family: 'Courier Prime', monospace; }
.ev {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 0 10px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--ops-line);
}
.ev-date { font-size: 11px; color: var(--ops-text-dim); white-space: nowrap; }
.ev-type { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; color: var(--sage); }
.ev-title { font-size: 12px; color: var(--ops-text); }
.ev-actor { font-size: 11px; color: var(--ops-text-dim); }
.ev.warn .ev-type { color: var(--hazard); }
.ev.critical .ev-type { color: var(--st-problem); }
.ev.critical .ev-title { color: var(--st-problem); }

/* fallback card (only when js/card.js failed to load) */
.card-fallback {
  width: 290px;
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--r);
  border: 1px solid var(--paper-edge);
  padding: 18px;
}
.card-fallback .cf-code {
  font-family: 'Courier Prime', monospace;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.card-fallback .cf-name { font-weight: 700; font-size: 16px; margin-top: 8px; }
.card-fallback .cf-damage {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 19px;
  margin: 6px 0 10px;
}
.card-fallback .cf-status { font-weight: 700; text-transform: uppercase; font-size: 12px; }
.card-fallback .cf-money {
  font-family: 'Courier Prime', monospace;
  font-size: 11px;
  margin-top: 10px;
  color: var(--ink-soft);
}
.card-fallback .cf-syn {
  margin-top: 12px;
  font-family: 'Courier Prime', monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--hazard);
}

/* ---------- map tooltip ---------- */
.map-tooltip {
  position: absolute;
  z-index: 9;
  pointer-events: none;
  max-width: 260px;
  background: var(--ops-deep);
  border: 1px solid var(--ops-line);
  border-radius: 6px;
  padding: 6px 9px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  font-size: 12px;
  color: var(--ops-text);
}
.map-tooltip .tt-title { font-weight: 700; }
.map-tooltip .tt-sub { font-size: 11px; color: var(--ops-text-dim); }

/* ---------- fatal / empty overlay ---------- */
.empty-overlay[hidden] { display: none; }
.empty-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--ops-deep) 55%, transparent);
}
.empty {
  max-width: 460px;
  margin: 0 16px;
  padding: 24px 32px;
  text-align: center;
  background: var(--ops-panel);
  border: 1px solid var(--ops-line);
  border-radius: var(--r);
  color: var(--ops-text);
  font-family: 'Courier Prime', monospace;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.03em;
  line-height: 1.5;
}

/* ---------- motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .detail, .tglbtn, .chips .chip { transition: none; }
}

/* ---------- responsive: side panel becomes a bottom sheet ---------- */
@media (max-width: 900px) {
  .overlays-tl { right: 12px; }
  .statstrip { flex-wrap: wrap; }
  .searchbox input { width: 170px; }
  .side {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: 44vh;
    border-radius: var(--r) var(--r) 0 0;
  }
  .legend { display: none; }
  .detail {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    height: 80vh;
    border-radius: var(--r) var(--r) 0 0;
    transform: translateY(106%);
  }
  .detail.open { transform: translateY(0); }
}
