/* Sovereign Walkman — Phosphor/CRT HUD */

:root {
    --phosphor-amber:   #e8e8e8;
    --phosphor-red:     #ff3b30;
    --phosphor-dim:     #6a6a6a;
    --amber:            var(--wm-accent, #ffb347);
    --bg:               #080808;
    --scanline-opacity: 0.03;
    --glow-amber:       0 0 8px #ffffff55, 0 0 20px #ffffff22;
    --glow-red:         0 0 10px #ff3b30aa, 0 0 24px #ff3b3066;
    --font-mono:        'Courier New', 'Lucida Console', monospace;
}

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

body {
    background: var(--bg);
    color: var(--phosphor-amber);
    font-family: var(--font-mono);
    height: 100dvh;
    overflow: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(
        0deg, transparent, transparent 3px,
        rgba(0,0,0,var(--scanline-opacity)) 3px,
        rgba(0,0,0,var(--scanline-opacity)) 4px
    );
    pointer-events: none;
    z-index: 1000;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.5) 100%);
    pointer-events: none;
    z-index: 999;
}

/* ── HUD CONTAINER ─────────────────────────── */

#walkman-hud {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    padding: env(safe-area-inset-top, 16px) 12px env(safe-area-inset-bottom, 12px);
    gap: 6px;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

/* ── HEADER ─────────────────────────────────── */

#hud-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px solid #1e1e1e;
    padding-bottom: 6px;
    flex-shrink: 0;
}

#hud-title {
    font-size: 10px;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--phosphor-dim);
}

#hud-clock {
    font-size: 12px;
    color: var(--phosphor-amber);
    opacity: 0.6;
    letter-spacing: 0.1em;
}

/* ── SENSOR STATUS STRIP ─────────────────────── */

#sensor-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid #1e1e1e;
    background: rgba(255,255,255,0.02);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.status-pill {
    font-size: 9px;
    letter-spacing: 0.2em;
    font-weight: bold;
    padding: 3px 7px;
    border: 1px solid #333;
    color: #555;
    text-transform: uppercase;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.status-pill.live-hc {
    border-color: #4a9eff;
    color: #4a9eff;
    box-shadow: 0 0 6px rgba(74,158,255,0.3);
}

.status-pill.live-ble {
    border-color: var(--amber);
    color: var(--amber);
    box-shadow: 0 0 6px rgba(255,179,71,0.3);
}

.status-pill.mock {
    border-color: #333;
    color: #444;
}

.status-item {
    display: flex;
    align-items: baseline;
    gap: 3px;
}

.status-label {
    font-size: 8px;
    letter-spacing: 0.15em;
    color: #333;
    text-transform: uppercase;
}

.status-val {
    font-size: 13px;
    color: var(--phosphor-dim);
    letter-spacing: -0.01em;
    transition: color 0.3s;
}

.status-val.fresh { color: var(--phosphor-amber); }

.status-unit {
    font-size: 8px;
    color: #333;
}

.status-msg {
    font-size: 8px;
    color: #444;
    letter-spacing: 0.1em;
    flex: 1;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── HRV CHART ───────────────────────────────── */

#hrv-chart-wrap {
    position: relative;
    height: 72px;
    flex-shrink: 0;
    border: 1px solid #1a1a1a;
    background: rgba(0,0,0,0.3);
    padding: 4px 6px 2px;
}

#chart-label {
    position: absolute;
    top: 4px;
    left: 7px;
    font-size: 8px;
    letter-spacing: 0.2em;
    color: #2a2a2a;
    text-transform: uppercase;
    pointer-events: none;
}

#hrv-chart {
    width: 100% !important;
    height: 100% !important;
}

/* ── STAT GRID ───────────────────────────────── */

#stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    flex: 1;
    min-height: 0;
}

.stat-cell {
    border: 1px solid #1e1e1e;
    padding: 8px 8px 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    background: rgba(255, 179, 71, 0.015);
    transition: border-color 0.4s ease, background 0.4s ease;
    min-height: 0;
}

.stat-cell.nominal .stat-value { color: #777; }
.stat-cell.nominal .stat-label { color: var(--phosphor-dim); }
.stat-cell.nominal .stat-sub   { color: #2a2a2a; }
.stat-cell.nominal .stat-bar-fill { background: #2a2a2a; }

.stat-cell.warming {
    border-color: #4a3a1a;
    background: rgba(255, 179, 71, 0.03);
}
.stat-cell.warming .stat-value { color: var(--amber); }
.stat-cell.warming .stat-bar-fill { background: var(--amber); box-shadow: var(--glow-amber); }

.stat-cell.elevated {
    border-color: var(--amber);
    background: rgba(255, 179, 71, 0.06);
}
.stat-cell.elevated .stat-value { color: var(--amber); text-shadow: var(--glow-amber); }
.stat-cell.elevated .stat-bar-fill { background: var(--amber); box-shadow: var(--glow-amber); }

.stat-cell.critical {
    border-color: var(--phosphor-red);
    background: rgba(255, 59, 48, 0.07);
    animation: breach-pulse 1s ease-in-out infinite;
}
.stat-cell.critical .stat-value,
.stat-cell.critical .stat-label { color: var(--phosphor-red); text-shadow: var(--glow-red); }
.stat-cell.critical .stat-bar-fill { background: var(--phosphor-red); box-shadow: var(--glow-red); }

@keyframes breach-pulse {
    0%, 100% { box-shadow: none; }
    50%       { box-shadow: 0 0 14px rgba(255,59,48,0.4), inset 0 0 8px rgba(255,59,48,0.08); }
}

.stat-label {
    font-size: 9px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--phosphor-dim);
    flex-shrink: 0;
}

.stat-sub {
    font-size: 8px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #2a2a2a;
    font-weight: normal;
}

.stat-unit {
    font-size: 10px;
    opacity: 0.4;
    margin-left: 1px;
    font-weight: normal;
}

/* ── GAUGE ───────────────────────────────────── */

.gauge-wrap {
    position: relative;
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gauge-wrap canvas {
    max-width: 80px;
    max-height: 80px;
}

.gauge-val {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.gauge-val span:first-child {
    font-size: 26px;
    font-weight: bold;
    color: #666;
    letter-spacing: -0.03em;
    line-height: 1;
    display: block;
    transition: color 0.4s;
}

.stat-cell.warming   .gauge-val span:first-child,
.stat-cell.elevated  .gauge-val span:first-child { color: var(--amber); }
.stat-cell.critical  .gauge-val span:first-child { color: var(--phosphor-red); }

/* Focus Lock — horizontal arc */

#stat-focusLock {
    flex-direction: row !important;
    align-items: center;
    gap: 12px;
}

#stat-focusLock .stat-label { flex: 0 0 auto; }

.focus-wrap {
    flex: 1;
    position: relative;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.focus-wrap canvas {
    max-width: 52px;
    max-height: 52px;
}

.focus-val {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.focus-val span:first-child {
    font-size: 22px;
    font-weight: bold;
    color: #555;
    letter-spacing: -0.02em;
    transition: color 0.4s;
}

/* ── SHORT FUSE ───────────────────────────────── */

#stat-shortfuse {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    flex-shrink: 0;
}

#stat-shortfuse .stat-info { flex: 0 0 auto; }
#stat-shortfuse .stat-value { font-size: 44px; }

.fuse-bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fuse-segments {
    display: flex;
    gap: 2px;
    height: 12px;
}

.fuse-seg {
    flex: 1;
    background: #111;
    transition: background 0.4s ease;
    border-radius: 1px;
}

.fuse-seg.active-nominal  { background: #3a3a3a; }
.fuse-seg.active-warming  { background: var(--amber); }
.fuse-seg.active-elevated { background: #ff8c00; box-shadow: 0 0 4px #ff8c0066; }
.fuse-seg.active-critical { background: var(--phosphor-red); box-shadow: var(--glow-red); }

/* ── THERMAL STRIP ───────────────────────────── */

#thermal-strip {
    border-top: 1px solid #1a1a1a;
    padding-top: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    letter-spacing: 0.2em;
    color: var(--phosphor-dim);
    text-transform: uppercase;
    flex-shrink: 0;
}

#thermal-t120 {
    color: var(--phosphor-red);
    display: none;
    font-weight: bold;
    font-size: 10px;
}
#thermal-t120.visible {
    display: inline;
    animation: breach-pulse 0.7s ease-in-out infinite;
}

/* ── CONTROLS ROW ─────────────────────────────── */

#controls-row {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

/* ── DEV PANEL ────────────────────────────────── */

#dev-panel {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

#dev-panel.hidden { display: none; }

.dev-row {
    display: flex;
    gap: 5px;
}

#debug-log {
    font-size: 9px;
    color: #333;
    letter-spacing: 0.05em;
    padding: 4px 6px;
    border: 1px solid #151515;
    background: rgba(0,0,0,0.3);
    max-height: 52px;
    overflow-y: auto;
    font-family: var(--font-mono);
    line-height: 1.6;
}

#debug-log .log-entry { color: #3a3a3a; }
#debug-log .log-entry.warn { color: #5a4a2a; }
#debug-log .log-entry.ok   { color: #2a4a2a; }
#debug-log .log-entry.err  { color: #4a2a2a; }

/* ── BUTTONS ─────────────────────────────────── */

.dev-btn {
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: transparent;
    border: 1px solid #1e1e1e;
    color: #444;
    padding: 7px 5px;
    cursor: pointer;
    flex: 1;
    transition: all 0.2s ease;
    min-height: 32px;
    white-space: nowrap;
}

.dev-btn:hover,
.dev-btn.active {
    border-color: #3a3a3a;
    color: var(--phosphor-dim);
    background: rgba(255,255,255,0.03);
}

.dev-btn.active-critical {
    border-color: var(--phosphor-red);
    color: var(--phosphor-red);
}

/* ── SILENCE BANNER ──────────────────────────── */

#silence-banner {
    position: fixed;
    top: 0; left: 0; right: 0;
    background: rgba(255,59,48,0.12);
    border-bottom: 1px solid var(--phosphor-red);
    padding: 7px 16px;
    font-size: 10px;
    letter-spacing: 0.3em;
    color: var(--phosphor-red);
    text-align: center;
    display: none;
    z-index: 998;
    text-transform: uppercase;
}
#silence-banner.visible { display: block; }
