/* ═══════════════════════════════════════════════════════
   MU/TH/UR 6000 — INTERFACE 2037
   WEYLAND-YUTANI SYSTEMS MONITORING TERMINAL
   USCSS NOSTROMO — COMMERCIAL TOWING VEHICLE
   ═══════════════════════════════════════════════════════ */

@font-face {
  font-family: "VT323";
  font-display: swap;
}

*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
}

:root {
  /* P1 Phosphor Green - Authentic 1979 CRT look */
  --p: #41ff00;
  --p-bright: #66ff22;
  --p-mid: #2dbb00;
  --p-dim: #1a8800;
  --p-faint: #0f4d00;
  --p-ghost: #082b00;
  --p-glow: rgba(65,255,0,0.12);
  --p-glow-s: rgba(65,255,0,0.25);
  --p-glow-x: rgba(65,255,0,0.5);
  --amber: #ff8800;
  --amber-dim: #aa5500;
  --red: #ff2200;
  --red-dim: #881100;
  --red-glow: rgba(255,34,0,0.3);
  --void: #000;
  --void-up: #060606;
  /* Font: IBM Plex Mono for 70s sci-fi accuracy, VT323 fallback */
  --font: "IBM Plex Mono", "VT323", "Courier New", monospace;
}

/* ═══════════ BASE ═══════════ */
html { height: 100%; }

body {
  font-family: var(--font);
  background: var(--void);
  color: var(--p);
  min-height: 100%;
  font-size: 16px;
  line-height: 1.35;
  overflow-x: hidden;
  text-shadow: 0 0 6px var(--p-glow);
}

body.booting .terminal { opacity: 0; }
body.booting .login-overlay { display: none; }
body.logged-in .login-overlay { display: none; }
body.logged-in .boot-overlay { display: flex; }

@keyframes terminal-on {
  0% { opacity: 0; filter: brightness(3) blur(2px); }
  40% { opacity: 1; filter: brightness(1.5) blur(0); }
  100% { filter: brightness(1); }
}

/* ═══════════ CRT FLICKER ═══════════ */
@keyframes crt-flicker {
  0%, 100% { opacity: 1; }
  3% { opacity: 0.97; }
  6% { opacity: 1; }
  8% { opacity: 0.98; }
  9% { opacity: 1; }
  12% { opacity: 0.96; }
  15% { opacity: 1; }
  18% { opacity: 0.98; }
  20% { opacity: 1; }
  50% { opacity: 0.99; }
  55% { opacity: 1; }
  80% { opacity: 0.97; }
  85% { opacity: 1; }
}

body.booted .terminal {
  animation: terminal-on 0.8s ease-out, crt-flicker 8s infinite, h-sync 12s infinite;
}

/* ═══════════ HORIZONTAL SYNC DRIFT ═══════════ */
@keyframes h-sync {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-1px); }
}

::selection { background: var(--p); color: var(--void); }

/* ═══════════ CRT SCANLINES ═══════════ */
.crt-scanlines {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 1000;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.12) 0px, rgba(0,0,0,0.12) 1px,
    transparent 1px, transparent 2px
  );
  mix-blend-mode: multiply;
}

/* ═══════════ CRT VIGNETTE ═══════════ */
.crt-vignette {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 999;
  background: radial-gradient(
    ellipse at center,
    transparent 40%,
    rgba(0,0,0,0.35) 70%,
    rgba(0,0,0,0.85) 100%
  );
}

/* ═══════════ CRT PHOSPHOR GLOW ═══════════ */
.crt-glow {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 997;
  background: radial-gradient(
    ellipse at center,
    rgba(51,255,0,0.02) 0%,
    transparent 70%
  );
  animation: glow-breathe 8s ease-in-out infinite;
}

@keyframes glow-breathe {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ═══════════ DATA RAIN CANVAS ═══════════ */
.data-rain {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  opacity: 0.07;
}

/* ═══════════ SCREEN GLITCH ═══════════ */
@keyframes glitch {
  0%    { clip-path: inset(40% 0 61% 0); transform: translate(-2px, 0); }
  20%   { clip-path: inset(92% 0 1% 0); transform: translate(2px, 0); }
  40%   { clip-path: inset(43% 0 1% 0); transform: translate(-1px, 0); }
  60%   { clip-path: inset(25% 0 58% 0); transform: translate(0); }
  80%   { clip-path: inset(54% 0 7% 0); transform: translate(3px, 0); }
  100%  { clip-path: inset(58% 0 43% 0); transform: translate(0); }
}

body.glitch-active .terminal {
  animation: glitch 0.15s steps(2) 1;
}

body.glitch-active .crt-scanlines {
  animation: scanline-shift 0.15s steps(2) 1;
}

@keyframes scanline-shift {
  0%   { transform: translateY(0); }
  50%  { transform: translateY(4px); }
  100% { transform: translateY(0); }
}

/* ═══════════ CHROMATIC ABERRATION — on hover ═══════════ */
body.glitch-active .terminal {
  text-shadow:
    -1px 0 rgba(255,0,0,0.4),
    1px 0 rgba(0,255,255,0.4),
    0 0 6px var(--p-glow);
}

/* ═══════════ LOGIN TERMINAL ═══════════ */
.login-overlay {
  position: fixed; inset: 0;
  z-index: 2100;
  background: var(--void);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-overlay.hidden {
  display: none;
}

.login-terminal {
  width: 100%;
  max-width: 640px;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

.login-header {
  display: flex;
  justify-content: space-between;
  color: var(--p);
  text-shadow: 0 0 10px var(--p-glow-s);
  letter-spacing: 0.1em;
  font-weight: 600;
}

.login-subheader {
  display: flex;
  justify-content: space-between;
  color: var(--p-dim);
  text-shadow: none;
  letter-spacing: 0.08em;
  font-size: 14px;
  margin-top: 2px;
}

.login-divider {
  color: var(--p-faint);
  text-shadow: none;
  margin: 12px 0;
  letter-spacing: 0.04em;
  font-size: 12px;
}

.login-content {
  color: var(--p-dim);
  text-shadow: none;
  min-height: 200px;
  white-space: pre-wrap;
  word-break: break-all;
}

.login-content .login-line {
  display: block;
  margin: 8px 0;
}

.login-content .login-label {
  color: var(--p-mid);
}

.login-content .login-value {
  color: var(--p);
  text-shadow: 0 0 8px var(--p-glow-s);
}

.login-content .login-value.typing {
  border-right: 2px solid var(--p);
  animation: blink 1s step-end infinite;
}

.login-content .access-granted {
  color: var(--p-bright);
  text-shadow: 0 0 15px var(--p-glow-x), 0 0 30px var(--p-glow);
  text-align: center;
  margin-top: 30px;
  font-weight: 600;
  letter-spacing: 0.15em;
  animation: pulse-glow 1.5s ease-in-out infinite;
}

.login-content .system-online {
  color: var(--p);
  text-align: center;
  margin-top: 8px;
  letter-spacing: 0.1em;
}

.login-content .login-ascii {
  color: var(--p);
  text-shadow: 0 0 15px var(--p-glow-x), 0 0 30px var(--p-glow);
  font-size: 11px;
  line-height: 1.15;
  white-space: pre;
  overflow-x: hidden;
  margin-bottom: 20px;
}

@keyframes pulse-glow {
  0%, 100% { text-shadow: 0 0 15px var(--p-glow-x), 0 0 30px var(--p-glow); }
  50% { text-shadow: 0 0 25px var(--p-glow-x), 0 0 50px var(--p-glow-s); }
}

.login-cursor {
  display: inline-block;
  animation: blink 1s step-end infinite;
}
.boot-overlay {
  position: fixed; inset: 0;
  z-index: 2000;
  background: var(--void);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px;
}

.boot-overlay.active {
  display: flex;
}

.boot-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.boot-screen {
  width: 100%;
  max-width: 800px;
  padding-top: 60px;
}

.boot-log {
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: 0.04em;
  white-space: pre-wrap;
  word-break: break-all;
}

.boot-log .line { display: block; }
.boot-log .ok { color: var(--p-bright); }
.boot-log .warn { color: var(--amber); }
.boot-log .fail { color: var(--red); text-shadow: 0 0 8px var(--red-glow); }
.boot-log .dim { color: var(--p-dim); text-shadow: none; }
.boot-log .header {
  color: var(--p-bright);
  text-shadow: 0 0 12px var(--p-glow-s);
  font-size: 18px;
}
.boot-log .ascii-art {
  color: var(--p);
  text-shadow: 0 0 20px var(--p-glow-x), 0 0 40px var(--p-glow);
  line-height: 1.1;
  font-size: 10px;
}

.boot-cursor {
  display: inline-block;
  animation: blink 1s step-end infinite;
  font-size: 16px;
}

/* ═══════════ ALERT BANNER ═══════════ */
.alert-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1500;
  background: var(--red);
  color: var(--void);
  text-align: center;
  font-size: 15px;
  letter-spacing: 0.15em;
  padding: 4px 16px;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
  text-shadow: none;
  font-family: var(--font);
}

.alert-banner.visible {
  transform: translateY(0);
  animation: alert-flash 0.5s step-end 3;
}

@keyframes alert-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ═══════════ TERMINAL ═══════════ */
.terminal {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 28px;
  position: relative;
  z-index: 1;
  opacity: 0;
}

/* ═══════════ HEADER ═══════════ */
.header-grid {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 32px;
  margin-bottom: 12px;
}

.mother-logo {
  font-family: var(--font);
  font-size: 10px;
  line-height: 1.05;
  color: var(--p);
  text-shadow: 0 0 20px var(--p-glow-x), 0 0 60px var(--p-glow-s);
  margin-bottom: 10px;
  white-space: pre;
  overflow: hidden;
}

.system-id {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 15px;
  letter-spacing: 0.08em;
}

.wy-corp {
  font-size: 18px;
  letter-spacing: 0.15em;
  text-shadow: 0 0 15px var(--p-glow-s);
}

.dim { color: var(--p-dim); text-shadow: none; }

.classified {
  color: var(--amber);
  text-shadow: 0 0 8px rgba(255,136,0,0.4);
  animation: classified-blink 4s step-end infinite;
}

@keyframes classified-blink {
  0%, 85%, 100% { opacity: 1; }
  90% { opacity: 0; }
}

.dots { color: var(--p-faint); text-shadow: none; }

/* ═══ Stats ═══ */
.header-right { flex-shrink: 0; }

.stat-block { margin-bottom: 8px; }

.stat-block-title {
  color: var(--p-dim);
  font-size: 15px;
  text-shadow: none;
  letter-spacing: 0.04em;
}

.stat-row {
  display: flex;
  align-items: center;
  font-size: 17px;
  letter-spacing: 0.05em;
  padding: 1px 0;
}

.stat-key { color: var(--p-dim); text-shadow: none; white-space: nowrap; }
.stat-dots {
  flex: 1;
  border-bottom: 1px dotted var(--p-ghost);
  margin: 0 8px;
  min-width: 20px;
}
.stat-val { white-space: nowrap; text-shadow: 0 0 8px var(--p-glow-s); }
.stat-val.active { color: var(--p-bright); }
.stat-val.terminated { color: var(--amber); text-shadow: 0 0 8px rgba(255,136,0,0.3); }

.threat-display {
  font-size: 15px;
  margin-bottom: 4px;
  letter-spacing: 0.06em;
}

.threat-value {
  font-weight: bold;
  margin-left: 4px;
}

.threat-value.green { color: var(--p-bright); text-shadow: 0 0 8px var(--p-glow-s); }
.threat-value.yellow { color: var(--amber); text-shadow: 0 0 8px rgba(255,136,0,0.4); animation: threat-pulse 2s ease infinite; }
.threat-value.red { color: var(--red); text-shadow: 0 0 12px var(--red-glow); animation: threat-pulse 0.8s ease infinite; }

@keyframes threat-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.crew-status {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 14px;
}

/* ═══ Dividers ═══ */
.divider-double {
  height: 6px;
  border-top: 1px solid var(--p-faint);
  border-bottom: 1px solid var(--p-faint);
  margin: 4px 0;
}

/* ═══════════ FILTERS ═══════════ */
.filters {
  display: flex;
  gap: 3px;
  padding: 10px 0 6px;
  overflow-x: auto;
  flex-wrap: wrap;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }

.filter-btn {
  background: transparent;
  border: 1px solid var(--p-faint);
  color: var(--p-dim);
  padding: 3px 12px;
  font-family: var(--font);
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.08s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-shadow: none;
}

.filter-btn:hover {
  border-color: var(--p-mid);
  color: var(--p);
  text-shadow: 0 0 6px var(--p-glow);
}

.filter-btn.active {
  background: var(--p);
  border-color: var(--p);
  color: var(--void);
  text-shadow: none;
  box-shadow: 0 0 12px var(--p-glow-s), 0 0 30px var(--p-glow);
}

.filter-count { font-size: 13px; margin-left: 3px; opacity: 0.6; }
.filter-btn.active .filter-count { opacity: 1; }

/* ═══════════ QUERY LINE ═══════════ */
.query-line {
  padding: 6px 0 10px;
  font-size: 16px;
  letter-spacing: 0.04em;
}

.prompt-prefix {
  color: var(--p-mid);
  margin-right: 6px;
}

.cursor {
  animation: blink 1s step-end infinite;
  margin-left: 1px;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ═══════════ LOADING DOTS ═══════════ */
.loading-dots::after {
  content: "";
  animation: loading-dots 2s step-end infinite;
}

@keyframes loading-dots {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
}

/* ═══════════ GRID ═══════════ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1px;
  background: var(--p-ghost);
  border: 1px solid var(--p-faint);
}

/* ═══════════ CARDS ═══════════ */
.card {
  background: var(--void);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  transition: background 0.1s;
  /* staggered reveal */
  opacity: 0;
  animation: card-in 0.3s ease forwards;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.card:hover {
  background: rgba(51,255,0,0.015);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-name {
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 0 8px var(--p-glow-s);
}

.card-name a { color: inherit; text-decoration: none; }
.card-name a:hover { text-decoration: underline; }

.status-indicator {
  font-size: 15px;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}

.status-indicator.running {
  color: var(--p-bright);
  text-shadow: 0 0 8px var(--p-glow-s);
}
.status-indicator.exited, .status-indicator.dead {
  color: var(--red);
  text-shadow: 0 0 6px var(--red-glow);
}
.status-indicator.paused, .status-indicator.restarting, .status-indicator.created {
  color: var(--amber);
}

.card-image {
  font-size: 13px;
  color: var(--p-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: none;
}

.card-description {
  font-size: 15px;
  color: var(--p-dim);
  text-shadow: none;
}

.no-description { color: var(--p-faint); }

/* ═══ Resource Bars ═══ */
.resource-bars { display: flex; gap: 14px; }
.resource-bar { flex: 1; }

.resource-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--p-dim);
  text-shadow: none;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.bar-track {
  height: 10px;
  border: 1px solid var(--p-faint);
  background: var(--void);
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  background-color: var(--p-dim);
  transition: width 0.6s linear;
  min-width: 0;
  box-shadow: 0 0 4px var(--p-glow);
  background-image: repeating-linear-gradient(
    90deg, transparent, transparent 5px, var(--void) 5px, var(--void) 7px
  );
}
.bar-fill.high {
  background-color: var(--amber-dim);
  box-shadow: 0 0 4px rgba(255,136,0,0.3);
  background-image: repeating-linear-gradient(
    90deg, transparent, transparent 5px, var(--void) 5px, var(--void) 7px
  );
}
.bar-fill.critical {
  background-color: var(--red);
  box-shadow: 0 0 6px var(--red-glow);
  animation: bar-critical 0.8s step-end infinite;
  background-image: repeating-linear-gradient(
    90deg, transparent, transparent 5px, var(--void) 5px, var(--void) 7px
  );
}

@keyframes bar-critical {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 4px;
  border-top: 1px solid var(--p-ghost);
}

.category-badge {
  font-size: 13px;
  padding: 1px 7px;
  border: 1px solid var(--p-faint);
  color: var(--p-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-shadow: none;
}

.status-text {
  font-size: 13px;
  color: var(--p-faint);
  text-shadow: none;
}

/* ═══ Dead containers ═══ */
.card[data-state="exited"], .card[data-state="dead"] {
  background: rgba(255,34,0,0.02);
}
.card[data-state="exited"] .card-name, .card[data-state="dead"] .card-name {
  color: var(--red);
  text-shadow: 0 0 6px var(--red-glow);
}
.card[data-state="exited"] .category-badge, .card[data-state="dead"] .category-badge {
  border-color: var(--red-dim);
  color: var(--red);
}

/* ═══ Xenomorph ═══ */
.card[data-xeno="true"] { overflow: hidden; }
.card[data-xeno="true"]::after {
  content: "⚠ UNIDENTIFIED LIFEFORM — QUARANTINE PROTOCOL";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--red);
  color: var(--void);
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.12em;
  padding: 2px;
  animation: xeno-flash 1.5s step-end infinite;
  text-shadow: none;
  font-family: var(--font);
}

@keyframes xeno-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ═══════════ COMMAND PROMPT ═══════════ */
.command-section { margin-top: 12px; }

.command-output {
  min-height: 0;
  max-height: 200px;
  overflow-y: auto;
  font-size: 15px;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--p-faint) var(--void);
}

.command-output .cmd-line {
  padding: 1px 0;
  letter-spacing: 0.03em;
}

.command-output .cmd-response {
  color: var(--p-mid);
  text-shadow: none;
  padding: 1px 0 1px 16px;
}

.command-output .cmd-error {
  color: var(--red);
  text-shadow: 0 0 6px var(--red-glow);
}

.command-output .cmd-ascii {
  color: var(--p);
  text-shadow: 0 0 8px var(--p-glow);
  white-space: pre;
  line-height: 1.1;
}

.command-line {
  display: flex;
  align-items: center;
  gap: 6px;
}

.command-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--p);
  font-family: var(--font);
  font-size: 16px;
  flex: 1;
  caret-color: var(--p);
  letter-spacing: 0.04em;
  text-shadow: 0 0 6px var(--p-glow);
  text-transform: uppercase;
}

.command-input::placeholder {
  color: var(--p-faint);
  text-shadow: none;
  text-transform: uppercase;
}

/* ═══════════ LOADING ═══════════ */
.loading {
  grid-column: 1 / -1;
  padding: 60px 0;
  text-align: center;
  background: var(--void);
}

.boot-text {
  font-size: 17px;
  letter-spacing: 0.06em;
}

.error-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 0;
  font-size: 17px;
  background: var(--void);
}

.error-state .error-title {
  font-size: 22px;
  color: var(--red);
  text-shadow: 0 0 12px var(--red-glow);
  margin-bottom: 12px;
  animation: blink 1.5s step-end infinite;
}

.error-state p { color: var(--p-dim); margin: 3px 0; }

/* ═══════════ FOOTER ═══════════ */
footer { margin-top: 12px; }

.footer-content {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0;
  font-size: 13px;
  color: var(--p-dim);
  text-shadow: none;
}

.wy-motto {
  color: var(--p-faint);
  letter-spacing: 0.1em;
}

/* ═══════════ JONES ═══════════ */
#jones-status {
  cursor: pointer;
  transition: color 0.15s;
}
#jones-status:hover {
  color: var(--p);
  text-shadow: 0 0 8px var(--p-glow);
}

/* ═══════════ RESPONSIVE ═══════════ */
@media (max-width: 900px) {
  .terminal { padding: 12px 14px; }
  .header-grid { flex-direction: column; gap: 12px; }
  .mother-logo { font-size: 7px; }
  .grid { grid-template-columns: 1fr; }
}

@media (max-width: 500px) {
  .mother-logo { display: none; }
  .terminal { padding: 8px; }
  .footer-content { flex-direction: column; align-items: center; }
  .boot-screen { padding-top: 20px; }
  .boot-overlay { padding: 16px; }
}
