/* ===========================================================================
   MEGALITH MEDIA — v02
   One stylesheet for the five tabs. v01's CSS grew a class per view; this one
   has a class per IDEA (card, pill, badge, empty, missing) and the views compose
   those. The test of this file: a reader should be able to tell a "we have this"
   from a "we do not have this" without reading a word.
   =========================================================================== */

:root {
  --bg: #0d0f13;
  --panel: #151920;
  --panel-2: #1b2029;
  --line: #262c37;
  --line-2: #333b49;
  --ink: #e8ecf2;
  --ink-2: #a8b2c1;
  --ink-3: #6f7a8a;
  --accent: #6ea8fe;
  --ok: #3fb950;
  --warn: #d29922;
  --err: #f85149;
  --hist: #8b949e;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

/* ── Login ──────────────────────────────────────────────────────────────── */
.login { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login__card {
  width: 100%; max-width: 380px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; padding: 28px;
}
.login__mark { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.login__title { margin: 6px 0 4px; font-size: 26px; }
.login__sub { margin: 0 0 20px; color: var(--ink-2); font-size: 14px; }
.login__err { color: var(--err); font-size: 13px; margin: 12px 0 0; }
.vtag {
  font-size: 12px; font-family: var(--mono); background: var(--panel-2);
  border: 1px solid var(--line-2); border-radius: 5px; padding: 2px 6px;
  color: var(--accent); vertical-align: middle;
}

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; color: var(--ink-3); margin-bottom: 5px; }
.field input {
  width: 100%; padding: 9px 11px; background: var(--bg); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 8px; font-size: 14px;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.btn {
  font: inherit; cursor: pointer; border-radius: 8px; padding: 8px 14px;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--ink);
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #06101f; font-weight: 600; }
.btn--wide { width: 100%; }
.btn--sm { padding: 5px 10px; font-size: 13px; }
.btn--ghost { background: transparent; }

/* ── Header ─────────────────────────────────────────────────────────────── */
.top {
  display: flex; align-items: center; gap: 16px; padding: 0 18px;
  height: 54px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.top__left { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.top__mark { font-weight: 700; letter-spacing: .02em; }
.top__sep { color: var(--ink-3); }
.top__page { color: var(--ink-2); }
.top__nav { display: flex; gap: 2px; margin-left: 8px; }
.navbtn {
  font: inherit; cursor: pointer; background: transparent; color: var(--ink-2);
  border: 0; border-radius: 7px; padding: 7px 12px;
}
.navbtn:hover { background: var(--panel-2); color: var(--ink); }
.navbtn--on { background: var(--panel-2); color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.top__right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.top__user { color: var(--ink-2); font-size: 13px; }

/* The site version toggle. Deliberately looks like a switch, because it IS one:
   it navigates between two whole builds. */
.vswitch {
  display: inline-flex; align-items: center; text-decoration: none;
  border: 1px solid var(--line-2); border-radius: 999px; overflow: hidden;
  font-family: var(--mono); font-size: 12px;
}
.vswitch__on { background: var(--accent); color: #06101f; padding: 3px 9px; font-weight: 700; }
.vswitch__off { color: var(--ink-3); padding: 3px 9px; }
.vswitch:hover .vswitch__off { color: var(--ink); }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.main { padding: 22px 18px 80px; max-width: 1500px; margin: 0 auto; }

.shead { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.shead h2 { margin: 0; font-size: 22px; }
.shead__sub { margin: 4px 0 0; color: var(--ink-2); font-size: 14px; max-width: 78ch; }
.shead__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.sec { margin: 26px 0; }
.sec__head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.sec__title { margin: 0; font-size: 15px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.sec__note { margin: 0; color: var(--ink-3); font-size: 13px; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid--wide { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.grid--media { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}
.card__media { background: #0a0c10; aspect-ratio: 16/9; display: grid; place-items: center; overflow: hidden; }
.card__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card__body { padding: 12px 13px; flex: 1; }
.card__head { display: flex; align-items: flex-start; gap: 8px; }
.card__title { margin: 0; font-size: 15px; flex: 1; }
.card__badges { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.card__sub { margin: 6px 0 0; color: var(--ink-2); font-size: 13px; }
.card__foot {
  padding: 10px 13px; border-top: 1px solid var(--line);
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}

/* ── Pills and badges ───────────────────────────────────────────────────── */
.pill {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--ink-2); white-space: nowrap;
}
.pill--approved, .pill--ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.pill--rejected, .pill--err { color: var(--err); border-color: color-mix(in srgb, var(--err) 45%, transparent); }
.pill--draft, .pill--pending, .pill--warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.pill--historical, .pill--superseded { color: var(--hist); }
.pill--current { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

.vbadge {
  font-family: var(--mono); font-size: 11px; padding: 2px 6px; border-radius: 5px;
  background: var(--panel-2); border: 1px solid var(--line-2); color: var(--ink-2);
}

/* ── Field rows ─────────────────────────────────────────────────────────── */
.field-row { display: flex; gap: 10px; padding: 4px 0; font-size: 13px; border-bottom: 1px solid var(--line); }
.field-row:last-child { border-bottom: 0; }
.field-row__k { color: var(--ink-3); min-width: 132px; flex-shrink: 0; }
.field-row__v { color: var(--ink); }
.field-row__v--mono { font-family: var(--mono); font-size: 12px; }
/* "not recorded" must never look like a value. */
.field-row__v--none { color: var(--ink-3); font-style: italic; }

/* ── Empty vs missing. THE DISTINCTION THIS FILE EXISTS FOR. ────────────── */
.empty, .missing {
  border: 1px dashed var(--line-2); border-radius: var(--radius);
  padding: 18px; text-align: center; color: var(--ink-3);
}
.empty__title, .missing__title { margin: 0; font-size: 14px; }
.empty__why, .missing__why { margin: 6px 0 0; font-size: 13px; }
.missing { border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.missing__title { color: var(--warn); }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--ink-3); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.tbl tr:hover td { background: var(--panel); }

/* ── Tabs inside a detail panel ─────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  font: inherit; cursor: pointer; background: transparent; color: var(--ink-2);
  border: 0; border-bottom: 2px solid transparent; padding: 9px 13px;
}
.tab:hover { color: var(--ink); }
.tab--on { color: var(--ink); border-bottom-color: var(--accent); }

/* ── Modal ──────────────────────────────────────────────────────────────── */
/*
 * `[hidden]` IS NOT ENOUGH ON ITS OWN.
 *
 * The `hidden` attribute works by way of the UA stylesheet's `display: none`,
 * which any author `display` declaration outranks. `.modal` sets `display: grid`
 * and `.login` sets `display: grid`, so a "hidden" modal stayed laid out, its
 * full-viewport backdrop sat over the page, and it swallowed every click —
 * including the Sign in button. Found by driving the deployed build in a browser:
 * the click timed out with "<div class="modal__backdrop"> intercepts pointer
 * events".
 *
 * This is written as a blanket rule rather than a list of the three selectors
 * that happen to be broken today, because the next component to set `display` on
 * a hidden host would reintroduce exactly this bug and it would be invisible
 * until someone tried to click through it.
 */
[hidden] { display: none !important; }
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.66); }
.modal__box {
  position: relative; background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 14px; max-width: 760px; width: 100%; max-height: 86vh; overflow: auto;
}
.modal__x {
  position: absolute; top: 10px; right: 12px; background: transparent; border: 0;
  color: var(--ink-3); font-size: 22px; cursor: pointer; line-height: 1;
}
.modal__body { padding: 24px; }

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 9px;
  padding: 11px 18px; z-index: 200; font-size: 14px; max-width: 80vw;
}
.toast--err { border-color: var(--err); color: var(--err); }
.toast--ok { border-color: var(--ok); }

/* ── Media viewer ───────────────────────────────────────────────────────── */
#uav, #scene { position: fixed; inset: 0; z-index: 90; }
#scene { z-index: 80; }
.uav__backdrop, .scene__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.7); }
.uav__box, .scene__box {
  position: relative; margin: 3vh auto; background: var(--panel);
  border: 1px solid var(--line-2); border-radius: 14px; width: min(1200px, 94vw);
  max-height: 94vh; overflow: auto;
}
.uav__img { width: 100%; display: block; background: #0a0c10; }
.uav__bar, .scene__bar {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 2;
}
.uav__title, .scene__title { font-weight: 600; flex: 1; }

/* ── Utility ────────────────────────────────────────────────────────────── */
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--ink-3); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.hidden { display: none !important; }
