/* ═══════════════════════════════════════════════════════════
   Cockpit HUD — Full-screen immersive cockpit display
   Theme: Dark background, neon cyan/green/amber, monospace
   Effects: scanline, glow, corner brackets, blinking
   ═══════════════════════════════════════════════════════════ */

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

html, body {
  width: 100vw; height: 100vh;
  overflow: hidden;
  background: #05080f;
  color: #c8e6e0;
  font-family: 'Share Tech Mono', 'JetBrains Mono', monospace;
}

/* ═══════ SCANLINE OVERLAY ═══════ */
.scanline-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 9000;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 255, 200, 0.015) 2px,
    rgba(0, 255, 200, 0.015) 4px
  );
}

/* ═══ SCANLINE MOVING BAR ═══ */
.scanline-overlay::after {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 100%; height: 4px;
  background: linear-gradient(180deg, transparent, rgba(46,224,192,0.08), transparent);
  animation: scanlineMove 6s linear infinite;
}

@keyframes scanlineMove {
  0% { top: -4px; }
  100% { top: 100vh; }
}

/* ═══════ COLOR VARIABLES ═══════ */
:root {
  --cyan: #00e5ff;
  --cyan-dim: #008899;
  --green: #00ff88;
  --green-dim: #00aa55;
  --amber: #ffaa00;
  --amber-dim: #996600;
  --red: #ff3344;
  --red-dim: #991122;
  --blue: #4488ff;
  --white: #e0f0ee;
}

.temp-color { color: #ff8844; }
.hum-color { color: #44ccff; }
.pres-color { color: #2ee0c0; }
.wind-color { color: #ffaa55; }
.rain-color { color: #4488ff; }
.uv-color { color: #ffcc00; }
.rad-color { color: #ff8866; }
.pm-color { color: #aa88cc; }
.aqi-color { color: #2ee080; }

/* ═══════ TOP STATUS BAR ═══════ */
.hud-topbar {
  position: relative; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 24px;
  background: linear-gradient(90deg, rgba(0,229,255,0.08) 0%, transparent 50%, rgba(0,255,136,0.08) 100%);
  border-bottom: 1px solid rgba(0,229,255,0.15);
  height: 44px; flex-shrink: 0;
}
.hud-station-label {
  font-family: 'Orbitron', monospace;
  font-size: 13px; font-weight: 600;
  color: var(--cyan); letter-spacing: 0.15em;
  text-shadow: 0 0 8px rgba(0,229,255,0.5);
}
.hud-clock {
  font-family: 'Orbitron', monospace;
  font-size: 20px; font-weight: 700;
  color: var(--green); margin-right: 16px;
  text-shadow: 0 0 10px rgba(0,255,136,0.6);
  min-width: 140px; text-align: center;
}
.hud-date {
  font-size: 12px; color: #5a7a72;
}
.hud-status-right { display: flex; align-items: center; gap: 16px; }

/* Link status indicator */
.hud-link-indicator {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.1em; padding: 3px 10px;
  border: 1px solid rgba(255,68,68,0.4);
  border-radius: 3px; background: rgba(255,68,68,0.08);
  color: var(--red);
}
.hud-link-indicator.online {
  border-color: rgba(0,255,136,0.4);
  background: rgba(0,255,136,0.08);
  color: var(--green);
}
.link-dot {
  width: 7px; height: 7px; border-radius: 50%;
  display: inline-block;
  transition: background 0.3s;
}
.link-dot.offline {
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
  animation: blinkDot 1s infinite;
}
.link-dot.online {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: none;
}
@keyframes blinkDot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

/* ═══════ MAIN HUD GRID ═══════ */
.hud-main {
  display: grid;
  width: 100vw; height: calc(100vh - 44px - 120px);
  grid-template-columns: 1.6fr 2.2fr 1.4fr;
  gap: 10px;
  padding: 10px 16px;
}

/* ═══════ PANEL FRAME (shared corner bracket style) ═══════ */
.panel-frame {
  width: 100%; height: 100%;
  background: rgba(8, 14, 28, 0.95);
  border: 1px solid rgba(0,229,255,0.18);
  border-radius: 4px;
  display: flex; flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(0,229,255,0.03), 0 0 20px rgba(0,0,0,0.5);
}

/* Corner brackets */
.corner-br {
  position: absolute; width: 18px; height: 18px; z-index: 10;
}
.corner-br::before, .corner-br::after {
  content: ''; position: absolute; background: var(--cyan);
  box-shadow: 0 0 4px rgba(0,229,255,0.6);
}
.corner-br.tl { top: 4px; left: 4px; }
.corner-br.tl::before { width: 18px; height: 2px; top: 0; left: 0; }
.corner-br.tl::after { width: 2px; height: 18px; top: 0; left: 0; }

.corner-br.tr { top: 4px; right: 4px; }
.corner-br.tr::before { width: 18px; height: 2px; top: 0; right: 0; }
.corner-br.tr::after { width: 2px; height: 18px; top: 0; right: 0; }

.corner-br.bl { bottom: 4px; left: 4px; }
.corner-br.bl::before { width: 18px; height: 2px; bottom: 0; left: 0; }
.corner-br.bl::after { width: 2px; height: 18px; bottom: 0; left: 0; }

.corner-br.br { bottom: 4px; right: 4px; }
.corner-br.br::before { width: 18px; height: 2px; bottom: 0; right: 0; }
.corner-br.br::after { width: 2px; height: 18px; bottom: 0; right: 0; }

/* Panel header */
.panel-header {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; flex-shrink: 0;
  background: rgba(0,229,255,0.04);
  border-bottom: 1px solid rgba(0,229,255,0.1);
}
.panel-header.compact { padding: 4px 10px; }
.panel-header-line {
  flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0,229,255,0.3), transparent);
}
.panel-header-text {
  font-family: 'Orbitron', monospace;
  font-size: 10px; font-weight: 600;
  color: var(--cyan); letter-spacing: 0.2em;
  text-shadow: 0 0 6px rgba(0,229,255,0.4);
  white-space: nowrap;
}
.cam-live-badge {
  display: flex; align-items: center; gap: 4px;
  font-size: 9px; color: var(--red); font-weight: 700;
}
.cam-live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--red);
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--red); }
  50% { opacity: 0.3; box-shadow: none; }
}

/* ═══════ LEFT PANEL: Readouts ═══════ */
.hud-left-panel {
  display: flex; flex-direction: column; gap: 10px;
}

.readout-grid {
  flex: 1; display: flex; flex-direction: column; gap: 0;
  padding: 8px 14px; overflow: hidden;
}
.readout-row {
  display: flex; align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px solid rgba(0,229,255,0.06);
}
.readout-row:last-child { border-bottom: none; }
.readout-label {
  width: 80px; flex-shrink: 0;
  font-size: 11px; font-weight: 600;
  color: #4a6a62; letter-spacing: 0.12em;
}
.readout-value {
  font-family: 'Orbitron', monospace;
  font-size: 22px; font-weight: 700;
  letter-spacing: 0.03em;
  text-shadow: 0 0 8px currentColor;
  min-width: 70px;
}
.readout-unit {
  font-size: 11px; color: #5a7a72;
  margin-left: 4px;
}
.readout-divider {
  height: 1px; margin: 4px 0;
  background: linear-gradient(90deg, transparent, rgba(0,229,255,0.15), transparent);
}

/* ═══════ CENTER PANEL: Gauges ═══════ */
.hud-center-panel {
  display: flex; flex-direction: column;
}
.hud-center-grid {
  flex: 1; display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 10px;
}
.hud-gauge-wrap {
  display: flex; flex-direction: column;
  min-height: 0;
}
.hud-gauge-wrap .panel-frame {
  align-items: center; justify-content: center;
  padding: 8px;
}
.gauge-digital-readout {
  display: flex; align-items: baseline; justify-content: center;
  padding: 4px 0 2px;
}
.gauge-readout-value {
  font-family: 'Orbitron', monospace;
  font-size: 26px; font-weight: 800;
  text-shadow: 0 0 12px currentColor;
}
.gauge-readout-unit {
  font-size: 13px; color: #5a7a72; margin-left: 4px;
}

/* ═══════ RIGHT PANEL ═══════ */
.hud-right-panel {
  display: flex; flex-direction: column; gap: 10px;
}
.hud-pip-wrap {
  flex-shrink: 0;
}
.hud-pip-cam { flex: 0 0 auto; }
.hud-pip-map { flex: 0 0 auto; }
.hud-panel-frame.wind-details-frame { flex: 1; min-height: 0; }

.pip-cam-frame {
  flex: 1; min-height: 0;
  overflow: hidden; border-radius: 3px;
  background: #000;
}
.pip-cam-frame img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.pip-map-frame {
  flex: 1; min-height: 0;
  overflow: hidden; border-radius: 3px;
}
.pip-map-frame iframe {
  width: 100%; height: 100%;
  border: none; border-radius: 3px;
}

.wind-dtl { padding: 6px 14px; }
.wind-dtl .readout-value { font-size: 18px; min-width: 55px; }

/* ═══════ BOTTOM BAR: Sparkline ═══════ */
.hud-bottom-bar {
  padding: 0 16px 8px; flex-shrink: 0;
  height: 100px;
}
.hud-bottom-bar .panel-frame {
  padding: 4px;
}
#sparklineCanvas {
  width: calc(100% - 28px); height: 60px;
  margin: 0 auto; display: block;
}

/* ═══════ BOTTOM RIGHT: Rainfall ═══════ */
.hud-bottom-rain {
  position: fixed; bottom: 8px; right: 16px; z-index: 50;
  width: 220px; height: 90px;
}
.hud-bottom-rain .panel-frame {
  padding: 6px;
}
.rain-mini { padding: 4px 8px; }
.rain-mini .readout-value { font-size: 16px; min-width: 50px; }
.rain-mini .readout-label { width: 55px; font-size: 10px; }
.rain-mini .readout-unit { font-size: 9px; }

/* ═══════ WARNING STATE ═══════ */
.warning-row .readout-value.null-value {
  color: var(--amber) !important;
  animation: blinkWarn 1.5s infinite;
}
@keyframes blinkWarn {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ═══════ GLITCH TRANSITION (shared) ═══════ */
.glitch-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: 99999; pointer-events: none;
  background: #05080f;
  animation: glitchFade 0.4s ease-out forwards;
}
@keyframes glitchFade {
  0% { opacity: 0; }
  15% { opacity: 1; background: rgba(0,229,255,0.15); }
  30% { opacity: 1; background: rgba(255,136,68,0.1); }
  50% { opacity: 1; background: rgba(0,255,136,0.08); }
  70% { opacity: 0.6; }
  100% { opacity: 0; }
}

/* ═══════ RESPONSIVE ═══════ */
@media (max-width: 1400px) {
  .readout-value { font-size: 18px; }
  .gauge-readout-value { font-size: 22px; }
  .hud-clock { font-size: 17px; }
}
@media (max-width: 1100px) {
  .hud-main {
    grid-template-columns: 1.2fr 1.6fr 1fr;
    gap: 6px;
    padding: 6px 10px;
  }
  .readout-value { font-size: 15px; min-width: 50px; }
  .gauge-readout-value { font-size: 18px; }
  .hud-clock { font-size: 14px; min-width: 110px; }
  .hud-bottom-rain { width: 170px; height: 75px; }
  .rain-mini .readout-value { font-size: 13px; }
}
