/*
 * BattleBytes — theatre map UI (HUD, layer chips, scrubber, intel panel,
 * tooltip, overview news column, MapLibre control skin).
 *
 * Why: all chrome around the paper map is our own DOM, built by
 * static/js/theatre/theatre.js. Every colour/font comes from tokens.css so the
 * light/dark switch on :root carries through. Mobile-first: under 720 px the
 * intel panel is a 55vh bottom sheet, chips wrap, the scrubber spans the
 * width. No blinking or looping animation anywhere — only short slides.
 */

.theatre {
  --panel-w: 360px;
  --chips-top: var(--theatre-chips-top, 12px);
  --attrib-h: 22px;
  position: relative;
  height: 100%;
  min-height: 320px;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font: 400 14px/1.45 var(--font-ui);
  -webkit-text-size-adjust: 100%;
}
.theatre *, .theatre *::before, .theatre *::after { box-sizing: border-box; }
.theatre .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.theatre-stage { position: absolute; inset: 0; }
.theatre .theatre-map.maplibregl-map, .theatre .theatre-map { position: absolute; inset: 0; background: var(--paper); }
.theatre :focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ---------- shared bits ---------- */
.theatre .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 0 12px;
  font: 600 12px/1 var(--font-display); letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink); background: var(--surface-2); text-decoration: none;
  border: 1px solid var(--line-strong); border-radius: 2px; cursor: pointer;
  transition: border-color 180ms var(--ease), color 180ms var(--ease);
}
.theatre .btn:hover { border-color: var(--amber); color: var(--amber); }
.theatre .btn:disabled { opacity: .55; cursor: default; }
.theatre .btn--amber { color: var(--amber); border-color: var(--amber-dim); background: color-mix(in srgb, var(--surface) 85%, transparent); }

.status-chip, .chip {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px;
  font: 600 11px/1 var(--font-display); letter-spacing: .1em; text-transform: uppercase;
  border: 1px solid var(--line-strong); border-radius: 2px; color: var(--ink-muted); white-space: nowrap;
}
.status-chip--active { color: var(--red); border-color: color-mix(in srgb, var(--red) 70%, transparent); }
.status-chip--watch { color: var(--amber); border-color: var(--amber-dim); }
.status-chip--frozen, .status-chip--ceasefire { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 70%, transparent); }

/* ---------- top overlay: HUD + layer chips ---------- */
.theatre-top {
  position: absolute; z-index: 3; top: 8px; left: 8px; right: 8px;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.theatre-top > * { pointer-events: auto; }
.theatre-hud {
  align-self: flex-start; max-width: 100%;
  padding: 9px 12px 10px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: 1px solid var(--line); border-radius: 4px;
}
.theatre-hud__row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.theatre-hud__title {
  margin: 0; font: 700 20px/1.1 var(--font-display); letter-spacing: .06em; text-transform: uppercase; color: var(--ink);
}
.theatre-hud__meta { display: flex; gap: 12px; margin-top: 4px; font-size: 11px; color: var(--ink-muted); letter-spacing: .04em; }
.theatre-hud__date { color: var(--amber); }
.mock-banner {
  margin: 8px 0 0; padding: 4px 8px; display: inline-block;
  font: 600 11px/1.3 var(--font-display); letter-spacing: .08em; text-transform: uppercase;
  color: var(--amber); border: 1px solid var(--amber); border-radius: 2px;
}

.layer-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.layer-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px 0 6px;
  font: 600 11px/1 var(--font-display); letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-faint); background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: 1px solid var(--line); border-radius: 2px; cursor: pointer;
  transition: color 180ms var(--ease), border-color 180ms var(--ease);
}
.layer-chip__sw { display: inline-flex; width: 22px; justify-content: center; opacity: .4; transition: opacity 180ms var(--ease); }
.layer-chip__sw svg { display: block; }
.layer-chip[aria-pressed="true"] { color: var(--ink); border-color: var(--line-strong); }
.layer-chip[aria-pressed="true"] .layer-chip__sw { opacity: 1; }
.layer-chip:hover { border-color: var(--amber-dim); }

@media (max-width: 719.98px) {
  .theatre-hud { padding: 8px 10px 9px; }
  .theatre-hud__title { font-size: 18px; }
  .mock-banner { margin-top: 6px; font-size: 10.5px; padding: 3px 6px; }
  .layer-chip { height: 26px; gap: 4px; padding: 0 7px 0 4px; font-size: 10.5px; }
  .layer-chip__sw { width: 18px; }
  .layer-chip__sw svg { max-width: 18px; height: auto; }
}

/* ---------- scrubber ---------- */
.scrubber {
  position: absolute; z-index: 3; left: 8px; right: 8px; bottom: calc(var(--attrib-h) + 6px);
  display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px;
  padding: 8px 12px 6px 8px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line); border-radius: 4px;
  transition: left 280ms var(--ease), right 280ms var(--ease);
}
.scrubber__play {
  width: 36px; height: 36px; display: grid; place-items: center;
  color: var(--amber); background: transparent; border: 1px solid var(--amber-dim); border-radius: 2px; cursor: pointer;
}
.scrubber__play[aria-pressed="true"] { background: color-mix(in srgb, var(--amber) 14%, transparent); }
.scrubber__track { position: relative; padding-bottom: 16px; min-width: 0; }
.scrubber__date { font-size: 12px; color: var(--amber); white-space: nowrap; }
.scrubber__range {
  -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 22px; margin: 0;
  background: transparent; cursor: pointer; --pct: 100%;
}
.scrubber__range::-webkit-slider-runnable-track {
  height: 2px; border-radius: 0;
  background: linear-gradient(to right, var(--amber) 0 var(--pct), var(--line-strong) var(--pct) 100%);
}
.scrubber__range::-moz-range-track { height: 2px; background: var(--line-strong); }
.scrubber__range::-moz-range-progress { height: 2px; background: var(--amber); }
.scrubber__range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; margin-top: -6px;
  background: var(--surface); border: 2px solid var(--amber); border-radius: 2px; transform: rotate(45deg);
}
.scrubber__range::-moz-range-thumb { width: 12px; height: 12px; background: var(--surface); border: 2px solid var(--amber); border-radius: 2px; transform: rotate(45deg); }
.scrubber__ticks { position: absolute; left: 7px; right: 7px; top: 14px; height: 18px; }
.scrubber__tick {
  position: absolute; top: 0; left: calc(var(--i) / var(--n) * 100%); transform: translateX(-50%);
  padding: 6px 2px 0; border: 0; background: none; cursor: pointer;
  font: 400 10px/1 var(--font-mono); letter-spacing: .04em; color: var(--ink-faint); white-space: nowrap;
}
.scrubber__tick::before { content: ""; position: absolute; top: 0; left: 50%; width: 1px; height: 4px; background: var(--line-strong); }
.scrubber__tick:first-child { transform: translateX(-7px); }
.scrubber__tick:first-child::before { left: 7px; }
.scrubber__tick:last-child { transform: translateX(calc(-100% + 7px)); }
.scrubber__tick:last-child::before { left: auto; right: 7px; }
.scrubber__tick.is-current { color: var(--amber); }

/* ---------- tooltip ---------- */
.theatre-tip {
  position: absolute; z-index: 4; top: 0; left: 0; max-width: 260px; pointer-events: none;
  padding: 5px 8px; font: 500 13px/1.3 var(--font-ui); color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 2px;
}
.theatre-tip[hidden] { display: none; }

/* ---------- intel panel: bottom sheet (mobile first) ---------- */
.intel-panel {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; height: 55vh; height: 55dvh;
  display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink);
  border-top: 1px solid var(--line-strong); border-radius: 4px 4px 0 0; box-shadow: var(--shadow);
  transform: translateY(105%); visibility: hidden;
  transition: transform 280ms var(--ease), visibility 0s linear 280ms;
  overscroll-behavior: contain;
}
.intel-panel.open { transform: translateY(0); visibility: visible; transition: transform 280ms var(--ease), visibility 0s; }
.intel-panel.dragging { transition: none; }
.intel-panel__handle { flex: 0 0 auto; display: grid; place-items: center; height: 22px; cursor: grab; touch-action: none; }
.intel-panel__handle span { width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); }
.intel-panel__close {
  position: absolute; top: 10px; right: 10px; z-index: 1; width: 32px; height: 32px; display: grid; place-items: center;
  color: var(--ink-muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 2px; cursor: pointer;
}
.intel-panel__close:hover { color: var(--ink); border-color: var(--line-strong); }
.intel-panel__body { flex: 1 1 auto; overflow-y: auto; padding: 4px 16px 20px; }

.intel-head { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: center; padding-right: 40px; }
.intel-head__sym svg { display: block; }
.intel-head__title { margin: 0; font: 700 22px/1.12 var(--font-display); letter-spacing: .02em; color: var(--ink); }
.intel-head__time { display: block; margin-top: 4px; font-size: 12px; color: var(--amber); }
.intel-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 10px; }
.chip--hostile { color: var(--red); border-color: color-mix(in srgb, var(--red) 60%, transparent); }
.chip--friendly { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 60%, transparent); }
.chip--neutral { color: var(--green); border-color: color-mix(in srgb, var(--green) 60%, transparent); }
.chip--unknown { color: var(--amber); border-color: var(--amber-dim); }
.chip--type { color: var(--ink); }
.chip--mock { color: var(--amber); border-style: dashed; border-color: var(--amber-dim); }
.chip--report { color: var(--amber); border-color: var(--amber-dim); }
.intel-conf { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-muted); }
.intel-conf strong { font-weight: 600; color: var(--ink); }
.intel-conf__ring { color: var(--paper-ink); display: inline-flex; }
.intel-summary { margin: 12px 0 4px; font-size: 15px; line-height: 1.5; color: var(--ink); }
.intel-sec { margin-top: 18px; display: grid; gap: 8px; }
.intel-sec h3 {
  margin: 0; padding-bottom: 6px; border-bottom: 1px solid var(--line);
  font: 600 12px/1 var(--font-display); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-muted);
}
.intel-foot { margin: 18px 0 0; font-size: 11px; color: var(--ink-faint); }

.media-facade {
  position: relative; aspect-ratio: 16 / 9; width: 100%; overflow: hidden;
  background: var(--paper) center / cover no-repeat; border: 1px solid var(--line); border-radius: 2px; color: var(--paper-ink);
}
.media-facade__ph { position: absolute; inset: 0; }
.media-facade__ph svg { display: block; }
.media-facade iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.media-facade__cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 10px;
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 10px; align-items: center;
  background: linear-gradient(to top, color-mix(in srgb, var(--paper) 96%, transparent), color-mix(in srgb, var(--paper) 70%, transparent));
}
.media-facade__title { font: 600 13px/1.25 var(--font-ui); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-facade__note { grid-row: 2; font: 400 11px/1.3 var(--font-mono); color: var(--ink-muted); }
.media-facade__load { grid-row: 1 / span 2; grid-column: 2; }

.xcard { padding: 10px 12px; border: 1px solid var(--line); border-radius: 2px; background: var(--surface-2); }
.xcard__head { display: flex; align-items: center; gap: 8px; }
.xcard__mark {
  width: 22px; height: 22px; display: grid; place-items: center;
  font: 700 12px/1 var(--font-display); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 2px;
}
.xcard__author { font: 500 13px/1 var(--font-mono); color: var(--ink); }
.xcard__text { margin: 8px 0 0; font-size: 14px; }
.xcard__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.xcard__embed:not(:empty) { margin-top: 10px; }

.intel-news { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.intel-news li { display: grid; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.intel-news li:last-child { border-bottom: 0; }
.intel-news__outlet { font: 600 11px/1 var(--font-display); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-muted); }
.intel-news a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.intel-news a:hover { color: var(--amber); text-decoration-color: var(--amber); }

/* ---------- overview: news column ---------- */
.theatre[data-mode="overview"] { display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; }
.theatre[data-mode="overview"] .theatre-stage { position: relative; inset: auto; flex: 0 0 auto; height: 64vh; min-height: 300px; }
.theatre[data-mode="overview"] .theatre-map { position: absolute; inset: 0; }
.theatre-side { flex: 1 0 auto; padding: 16px; background: var(--surface); border-top: 1px solid var(--line); }
.theatre-side__title {
  margin: 0 0 10px; font: 600 14px/1 var(--font-display); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-muted);
}
.theatre-side__empty { margin: 0; color: var(--ink-faint); font-size: 13px; }

/* ---------- MapLibre control skin ---------- */
.theatre .maplibregl-ctrl-bottom-right, .theatre .maplibregl-ctrl-bottom-left { z-index: 2; }
.theatre .maplibregl-ctrl.maplibregl-ctrl-attrib {
  margin: 0; padding: 3px 8px; max-width: 100%;
  font: 400 10px/16px var(--font-ui); color: var(--ink-muted);
  background: color-mix(in srgb, var(--paper) 85%, transparent);
}
.theatre .maplibregl-ctrl-attrib a { color: var(--ink-muted); }
.theatre .maplibregl-ctrl-attrib a:hover { color: var(--ink); }
.theatre .maplibregl-canvas:focus-visible { outline: 2px solid var(--amber-dim); outline-offset: -2px; }

/* ---------- desktop / tablet ---------- */
@media (min-width: 720px) {
  .theatre-top { top: 12px; left: 12px; right: 12px; flex-direction: row; justify-content: space-between; align-items: flex-start; gap: 12px;
    transition: right 280ms var(--ease); }
  .theatre-hud { max-width: min(460px, 60%); padding: 10px 14px 12px; }
  .theatre-hud__title { font-size: 24px; }
  .layer-chips { flex-direction: column; align-items: stretch; flex-wrap: nowrap; margin-top: calc(var(--chips-top) - 12px); }
  .layer-chip { height: 30px; }
  .scrubber { left: 50%; right: auto; width: min(640px, calc(100% - 24px)); transform: translateX(-50%); bottom: calc(var(--attrib-h) + 10px);
    transition: left 280ms var(--ease); }

  .intel-panel {
    position: absolute; top: 0; bottom: 0; left: auto; right: 0; width: var(--panel-w); height: auto;
    border-top: 0; border-left: 1px solid var(--line-strong); border-radius: 0;
    transform: translateX(100%);
  }
  .intel-panel.open { transform: translateX(0); }
  .intel-panel__handle { display: none; }
  .intel-panel__body { padding: 16px 18px 24px; }
  .theatre.panel-open .theatre-top { right: calc(var(--panel-w) + 12px); }
  .theatre.panel-open .scrubber { left: calc((100% - var(--panel-w)) / 2); width: min(640px, calc(100% - var(--panel-w) - 24px)); }
  .theatre.panel-open .maplibregl-ctrl-bottom-right { right: var(--panel-w); }

  .theatre[data-mode="overview"] { display: grid; grid-template-columns: 1fr 340px; overflow: hidden; }
  .theatre[data-mode="overview"] .theatre-stage { height: auto; min-height: 0; }
  .theatre-side { overflow-y: auto; border-top: 0; border-left: 1px solid var(--line); padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .theatre *, .theatre *::before, .theatre *::after { transition-duration: 0s !important; }
}

/* real-data banner: informational, not a warning */
.theatre .mock-banner.data-banner { color: var(--ink-muted); border-color: var(--line-strong); background: transparent; }
