/* ==========================================================================
   GHOSTS OF NEWPORT CITY — "Industrial Ghost" CRT terminal (ADR-0004)
   Palette: phosphor green #39ff6e on near-black #050805. Monospace, uppercase,
   brutalist hard angles. The ONLY colored elements are mission status tags:
   CLASSIFIED #ff2d95 · BRIEFED #ffd23f · DEBRIEFED #4dffb8.
   Rejected ADR-0004 effects (full-frame shake, cascading hex columns) are
   deliberately absent from this stylesheet.
   ========================================================================== */

:root {
  --phos: #39ff6e;
  --phos-dim: rgba(57, 255, 110, 0.55);
  --bg: #050805;
  --line: rgba(57, 255, 110, 0.3);
  --line-faint: rgba(57, 255, 110, 0.15);
  --grid: rgba(57, 255, 110, 0.07);
  --cls: #ff2d95;  /* CLASSIFIED */
  --brf: #ffd23f;  /* BRIEFED */
  --dbr: #4dffb8;  /* DEBRIEFED */
  --ink: #04160a;  /* inverse-video text on phosphor fills */
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Courier New", monospace;
}

* {
  box-sizing: border-box;
  border-radius: 0 !important; /* hard angles only — no rounded corners */
  margin: 0;
  padding: 0;
}

html { height: 100%; }

body {
  min-height: 100%;
  background: var(--bg);
  color: var(--phos);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  overflow-x: hidden;
}

a { color: var(--phos); text-decoration: none; }

::selection { background: var(--phos); color: var(--ink); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #143f22; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--phos); }

/* ---- CRT artifacts (ADR-0004 keep list) ---------------------------------- */

body::before { /* vignette */
  content: '';
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.5) 100%);
}

body::after { /* scanline overlay */
  content: '';
  position: fixed;
  inset: 0;
  z-index: 71;
  pointer-events: none;
  background: repeating-linear-gradient(0deg,
    rgba(0, 0, 0, 0.24) 0px, rgba(0, 0, 0, 0.24) 1px,
    transparent 1px, transparent 3px);
}

@keyframes crtFlicker {
  0%, 100% { opacity: 1; }
  4%  { opacity: 0.978; }
  8%  { opacity: 1; }
  46% { opacity: 0.988; }
  49% { opacity: 1; }
  74% { opacity: 0.982; }
  77% { opacity: 1; }
}

.sweep { /* slow bright sweep band */
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: 140px;
  z-index: 69;
  pointer-events: none;
  background: linear-gradient(180deg,
    rgba(57, 255, 110, 0) 0%,
    rgba(57, 255, 110, 0.05) 45%,
    rgba(57, 255, 110, 0.11) 50%,
    rgba(57, 255, 110, 0.05) 55%,
    rgba(57, 255, 110, 0) 100%);
  animation: sweep 9s linear infinite;
}

@keyframes sweep {
  from { transform: translateY(-160px); }
  to   { transform: translateY(110vh); }
}

/* ---- layout shell: sidebar · main · telemetry ----------------------------- */

.crt {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 300px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    'header header header'
    'nav    main   tele'
    'footer footer footer';
  min-height: 100vh;
  animation: crtFlicker 9s infinite;
}

.chrome {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 16, 9, 0.65);
  font-size: 12px;
  letter-spacing: 0.14em;
  white-space: nowrap;
}

.sys-tag { flex: 0 0 auto; }

.campaign-tag {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  color: var(--phos-dim);
}

.clock { flex: 0 0 auto; }

.sidebar {
  grid-area: nav;
  border-right: 1px solid var(--line);
  padding: 12px 0;
  font-size: 13px;
}

.nav-label {
  padding: 4px 16px 10px;
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--phos-dim);
}

.sidebar a {
  display: block;
  padding: 9px 16px;
  border-left: 3px solid transparent;
}

.sidebar a::before { content: '> '; opacity: 0.55; }

.sidebar a:hover {
  background: rgba(57, 255, 110, 0.08);
  border-left-color: var(--line);
}

.sidebar a.active {
  background: var(--phos);
  color: var(--ink);
  border-left-color: var(--ink);
}

.main-pane {
  grid-area: main;
  padding: 26px 30px 56px;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 26px 26px;  /* crosshair grid */
}

.telemetry {
  grid-area: tele;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border-left: 1px solid var(--line);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--phos-dim);
}

.tele-line { white-space: nowrap; }

.log-block {
  margin-top: auto;
  border: 1px dashed var(--line);
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.9;
  white-space: pre-wrap;
}

.footer {
  grid-area: footer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--phos-dim);
  white-space: nowrap;
}

/* ---- views, panels, typography -------------------------------------------- */

.view { max-width: 980px; }

.view-head {
  font-size: 18px;
  letter-spacing: 0.12em;
  margin: 6px 0 22px;
}

.view-head::before { content: '[[ '; color: var(--phos-dim); }
.view-head::after  { content: ' ]]'; color: var(--phos-dim); }

.block {
  position: relative;
  border: 1px solid var(--line);
  background: rgba(6, 12, 7, 0.55);
  padding: 16px 18px;
  margin-bottom: 18px;
}

.block::before, .block::after { /* corner crosshair marks */
  content: '+';
  position: absolute;
  color: var(--line);
  font-size: 12px;
  line-height: 1;
}
.block::before { top: -7px; left: -6px; }
.block::after  { bottom: -7px; right: -6px; }

.block-head {
  position: absolute;
  top: -9px;
  left: 12px;
  padding: 1px 9px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: 0.2em;
}

.block p { overflow-wrap: anywhere; }
.block p + p { margin-top: 8px; }

.dim { color: var(--phos-dim); font-size: 13px; }

.list { list-style: none; }
.list li { position: relative; padding: 4px 0 4px 20px; }
.list li::before { content: '»'; position: absolute; left: 2px; top: 4px; opacity: 0.6; }

/* list rows (mission board, agent roster) */
.row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line-faint);
  cursor: pointer;
}
.row:last-child { border-bottom: 0; }
.row:hover {
  background: rgba(57, 255, 110, 0.08);
  box-shadow: inset 0 0 0 1px var(--line);
}
.row-id    { color: var(--phos-dim); min-width: 48px; font-size: 12px; }
.row-title { flex: 1 1 auto; letter-spacing: 0.08em; }
.row-meta  { color: var(--phos-dim); font-size: 12px; white-space: nowrap; }

/* status tags — the only colored elements */
.tag {
  display: inline-block;
  flex: 0 0 auto;
  padding: 1px 8px;
  border: 1px solid currentColor;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  white-space: nowrap;
}
.tag-CLASSIFIED { color: var(--cls); }
.tag-BRIEFED    { color: var(--brf); }
.tag-DEBRIEFED  { color: var(--dbr); }

/* HOME latest intel */
.intel-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}
.intel-id    { color: var(--phos-dim); font-size: 13px; }
.intel-title { font-size: 16px; letter-spacing: 0.1em; }

/* typewriter target + blinking block cursor */
.typed-line { min-height: 1.5em; white-space: pre-wrap; }
.cursor {
  display: inline-block;
  width: 0.62em;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -0.16em;
  background: var(--phos);
  animation: blink 1.1s infinite;
}
@keyframes blink {
  0%, 54%  { opacity: 1; }
  55%, 100% { opacity: 0; }
}

/* links */
.file-link {
  display: inline-block;
  margin: 8px 18px 2px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.file-link:hover { background: rgba(57, 255, 110, 0.1); }

.rulebook-line { margin-top: 10px; }
.ext-link { text-decoration: underline; text-underline-offset: 3px; }
.ext-link:hover { background: rgba(57, 255, 110, 0.1); }

/* detail views */
.detail-head { margin-bottom: 16px; }
.back-link {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--phos-dim);
  font-size: 12px;
  letter-spacing: 0.14em;
}
.back-link:hover { color: var(--phos); text-decoration: underline; }

.title-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
}
.detail-id    { color: var(--phos-dim); font-size: 13px; }
.detail-title { font-size: 21px; letter-spacing: 0.1em; }
.role-chip {
  border: 1px solid var(--line);
  padding: 2px 9px;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--phos-dim);
}

/* satellite maps (ADR-0003) */
.map-block {
  border: 1px solid var(--line-faint);
  padding: 12px 14px;
  margin: 14px 0 4px;
}
.map-name {
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--phos-dim);
  margin-bottom: 10px;
}
.map-stage { overflow-x: auto; }
.mermaid-figure svg { max-width: 100%; height: auto; }
.map-fallback {
  border: 1px dashed var(--line);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--phos-dim);
}

/* campaign chronicle */
.chronicle-entry { padding: 12px 0 4px; }
.chronicle-entry + .chronicle-entry { border-top: 1px dashed var(--line); }
.chronicle-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--phos-dim);
  margin-bottom: 6px;
}
.chronicle-title { font-size: 15px; letter-spacing: 0.1em; margin-bottom: 8px; }
.chronicle-text { white-space: pre-wrap; }

/* staggered HUD pop-ins */
@keyframes popIn {
  from { opacity: 0; transform: translateY(9px); }
  to   { opacity: 1; transform: translateY(0); }
}
.pop-in { animation: popIn 0.3s ease-out both; }

/* cold boot overlay */
.boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background-color: var(--bg);
  background-image: repeating-linear-gradient(0deg,
    rgba(0, 0, 0, 0.25) 0px, rgba(0, 0, 0, 0.25) 1px,
    transparent 1px, transparent 3px);
  display: flex;
  align-items: center;
  padding: 8vh 8vw;
  overflow: hidden;
  transition: opacity 0.65s ease-in-out;
}
.boot-overlay.fade-out { opacity: 0; pointer-events: none; }
.boot-lines {
  width: min(680px, 90vw);
  font-size: 13px;
  line-height: 2.2;
  letter-spacing: 0.1em;
}
.boot-row { white-space: pre-wrap; }
.boot-pre { opacity: 0.45; margin-right: 0.5em; }

/* ---- responsive tiers (§10) ------------------------------------------------ */

/* tablet ≤1024px: telemetry collapses to a bottom row */
@media (max-width: 1024px) {
  .crt {
    grid-template-columns: 200px minmax(0, 1fr);
    grid-template-areas:
      'header header'
      'nav    main'
      'tele   tele';
  }
  .telemetry {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 24px;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .log-block { margin-top: 0; flex: 1 1 260px; }
  .main-pane { padding: 22px 20px 44px; }
}

/* mobile ≤768px: everything stacks, nav becomes a horizontal strip */
@media (max-width: 768px) {
  .crt {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'header'
      'nav'
      'main'
      'tele'
      'footer';
  }
  .sidebar {
    display: flex;
    flex-wrap: wrap;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0;
    font-size: 12px;
  }
  .nav-label { display: none; }
  .sidebar a {
    padding: 9px 12px;
    border-left: 0;
    border-bottom: 2px solid transparent;
  }
  .sidebar a:hover {
    border-left: 0;
    border-bottom-color: var(--line);
  }
  .sidebar a.active { border-bottom-color: var(--ink); }
  .log-block { display: none; }
  .chrome { flex-wrap: wrap; padding: 8px 10px; font-size: 11px; row-gap: 2px; }
  .campaign-tag { order: 3; flex-basis: 100%; white-space: normal; text-align: left; }
  .telemetry { flex-direction: column; gap: 8px; }
  .main-pane { padding: 16px 14px 40px; }
  .block { padding: 14px 13px; }
  .detail-title { font-size: 19px; }
}

/* ≤480px: tighter padding and type */
@media (max-width: 480px) {
  body { font-size: 12.5px; }
  .main-pane { padding: 12px 10px 34px; }
  .view-head { font-size: 15px; }
  .detail-title { font-size: 16px; }
  .block { padding: 12px 10px; margin-bottom: 14px; }
  .row { gap: 8px; padding: 9px 5px; }
  .row-id { min-width: 40px; }
  .telemetry { padding: 10px 12px; font-size: 11px; gap: 6px; }
  .footer { font-size: 10px; padding: 6px 10px; }
  .boot-lines { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .pop-in { animation: none; }
  .crt { animation: none; }
  .sweep { display: none; }
}
