/* ═══════════════════════════════════════════════════════
   SDR LISTENER — The Listening Post
   Radar-room aesthetic with CRT and instrument panel feel
   ═══════════════════════════════════════════════════════ */

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

:root {
    --bg: #070b12;
    --surface: #0e1420;
    --surface-raised: #131b28;
    --border: #1a2535;
    --border-light: #243040;
    --text: #c8d6e5;
    --text-dim: #56687a;
    --text-bright: #e8f0f8;

    --aviation: #e8a838;
    --aviation-dim: #b07820;
    --aviation-glow: rgba(232, 168, 56, 0.2);
    --marine: #20d6a0;
    --marine-dim: #18a078;
    --marine-glow: rgba(32, 214, 160, 0.2);
    --radio: #b888ff;
    --radio-dim: #8a60cc;
    --radio-glow: rgba(184, 136, 255, 0.2);
    --custom: #d29922;
    --custom-glow: rgba(210, 153, 34, 0.2);

    --green: #39ff85;
    --green-glow: rgba(57, 255, 133, 0.25);
    --red: #ff4050;
    --red-glow: rgba(255, 64, 80, 0.25);

    --accent: #58a6ff;

    --font-display: 'Chakra Petch', sans-serif;
    --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

    --radius: 4px;
    --panel-pad: 16px;
}

body {
    font-family: var(--font-mono);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Subtle grid overlay across the entire page */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(32, 214, 160, 0.03) 0%, transparent 55%),
        repeating-linear-gradient(
            0deg,
            transparent 0px, transparent 59px,
            rgba(26, 37, 53, 0.25) 59px, rgba(26, 37, 53, 0.25) 60px
        ),
        repeating-linear-gradient(
            90deg,
            transparent 0px, transparent 59px,
            rgba(26, 37, 53, 0.25) 59px, rgba(26, 37, 53, 0.25) 60px
        );
    pointer-events: none;
    z-index: 0;
}

/* ── Console Container ── */

.console {
    position: relative;
    z-index: 1;
    max-width: 920px;
    margin: 0 auto;
    padding: 0 20px 40px;
}

/* ── Shared Panel Style ── */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--panel-pad);
}

/* ── Station Header ── */

.station-header {
    position: relative;
    text-align: center;
    padding: 48px 0 32px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    overflow: hidden;
    animation: fadeSlideIn 0.7s ease-out;
}

.radar-sweep-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
}

.radar-ring {
    position: absolute;
    inset: 20px;
    border-radius: 50%;
    border: 1px solid rgba(32, 214, 160, 0.06);
}

.radar-ring.ring-2 {
    inset: 50px;
    border-color: rgba(32, 214, 160, 0.04);
}

.radar-sweep {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        transparent 0deg,
        rgba(32, 214, 160, 0.1) 18deg,
        transparent 45deg
    );
    animation: sweep 5s linear infinite;
}

.radar-center {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--marine);
    transform: translate(-50%, -50%);
    box-shadow: 0 0 6px var(--marine-glow);
}

@keyframes sweep {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.station-id {
    position: relative;
}

.station-id h1 {
    font-family: var(--font-display);
    font-size: 1.7em;
    font-weight: 700;
    letter-spacing: 5px;
    color: var(--text-bright);
    text-transform: uppercase;
}

.coordinates {
    font-family: var(--font-mono);
    font-size: 0.72em;
    color: var(--text-dim);
    letter-spacing: 2px;
    margin-top: 8px;
}

/* ── Module Labels ── */

.module-label {
    font-family: var(--font-display);
    font-size: 0.62em;
    font-weight: 600;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 10px;
}

/* ── Panel Headers ── */

.panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.panel-header h2,
.panel-header h3 {
    font-family: var(--font-display);
    font-size: 0.78em;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin: 0;
}

.panel-icon {
    font-size: 1em;
    opacity: 0.6;
}

.mod-badge {
    margin-left: auto;
    font-size: 0.62em;
    font-family: var(--font-mono);
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    color: var(--text-dim);
    letter-spacing: 1px;
}

/* ── Control Strip ── */

.control-strip {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    animation: fadeSlideIn 0.6s ease-out 0.05s both;
}

.status-module {
    flex: 1;
}

.transport-module {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 140px;
}

.status-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

/* ── Status Dot ── */

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--red);
    box-shadow: 0 0 6px var(--red-glow);
    flex-shrink: 0;
}

.status-dot.active {
    background: var(--green);
    box-shadow: 0 0 10px var(--green-glow);
    animation: led-pulse 2s ease-in-out infinite;
}

@keyframes led-pulse {
    0%, 100% { box-shadow: 0 0 10px var(--green-glow); opacity: 1; }
    50% { box-shadow: 0 0 18px var(--green-glow); opacity: 0.7; }
}

.current-freq {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.9em;
    color: var(--green);
}

.listener-count {
    font-size: 0.72em;
    color: var(--text-dim);
}

/* ── Play Button ── */

.play-btn {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.82em;
    letter-spacing: 2px;
    text-transform: uppercase;
    background: transparent;
    color: var(--green);
    border: 2px solid var(--green);
    border-radius: var(--radius);
    padding: 10px 24px;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s, color 0.2s, border-color 0.2s;
}

.play-btn::before {
    content: '\25B6\00a0';
}

.play-btn:hover {
    background: rgba(57, 255, 133, 0.08);
    box-shadow: 0 0 16px var(--green-glow);
}

.play-btn.playing {
    color: var(--red);
    border-color: var(--red);
}

.play-btn.playing::before {
    content: '\25A0\00a0';
}

.play-btn.playing:hover {
    background: rgba(255, 64, 80, 0.08);
    box-shadow: 0 0 16px var(--red-glow);
}

.audio-status {
    font-size: 0.68em;
    color: var(--text-dim);
    letter-spacing: 1px;
}

/* ── Cooldown ── */

.cooldown-notice {
    font-family: var(--font-display);
    font-size: 0.78em;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--custom);
    text-align: center;
    min-height: 1.4em;
    margin-bottom: 16px;
}

/* ── Spectrum Analyzer ── */

.spectrum-module {
    margin-bottom: 20px;
    animation: fadeSlideIn 0.6s ease-out 0.1s both;
}

.spectrum-viewport {
    position: relative;
    border-radius: 3px;
    overflow: hidden;
}

#spectrum {
    width: 100%;
    height: 150px;
    display: block;
    background: #060a10;
    border-radius: 3px;
}

.crt-scanlines {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px, transparent 2px,
        rgba(0, 0, 0, 0.07) 2px, rgba(0, 0, 0, 0.07) 4px
    );
    pointer-events: none;
    border-radius: 3px;
}

.spectrum-hint {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 0.72em;
    font-weight: 600;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--text-dim);
    pointer-events: none;
}

.spectrum-hint.hidden {
    display: none;
}

/* ── Frequency Panels Grid ── */

.freq-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
    animation: fadeSlideIn 0.6s ease-out 0.15s both;
}

/* Category top accent border */
.freq-group.aviation { border-top: 2px solid var(--aviation); }
.freq-group.marine   { border-top: 2px solid var(--marine); }
.freq-group.radio    { border-top: 2px solid var(--radio); }

/* Category header colors */
.freq-group.aviation .panel-header h2,
.freq-group.aviation .panel-icon { color: var(--aviation); }
.freq-group.marine .panel-header h2,
.freq-group.marine .panel-icon   { color: var(--marine); }
.freq-group.radio .panel-header h2,
.freq-group.radio .panel-icon    { color: var(--radio); }

/* ── Frequency Buttons ── */

.freq-btn {
    display: flex;
    align-items: center;
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 10px 12px;
    margin-bottom: 6px;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.78em;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    text-align: left;
}

.freq-btn:last-of-type {
    margin-bottom: 0;
}

.freq-btn:hover {
    border-color: var(--border-light);
    background: var(--surface-raised);
}

.freq-btn .freq-num {
    font-weight: 600;
    min-width: 62px;
    flex-shrink: 0;
    color: var(--text-bright);
}

.freq-btn .freq-label {
    color: var(--text-dim);
    margin-left: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.freq-btn .freq-active-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: auto;
    flex-shrink: 0;
    background: transparent;
    transition: background 0.3s, box-shadow 0.3s;
}

/* Active — Aviation */
.freq-btn.active {
    border-color: var(--aviation-dim);
    box-shadow: 0 0 10px var(--aviation-glow), inset 0 0 10px rgba(232, 168, 56, 0.04);
}
.freq-btn.active .freq-active-dot {
    background: var(--aviation);
    box-shadow: 0 0 8px var(--aviation-glow);
    animation: dot-pulse 2s ease-in-out infinite;
}

/* Active — Marine */
.freq-group.marine .freq-btn.active {
    border-color: var(--marine-dim);
    box-shadow: 0 0 10px var(--marine-glow), inset 0 0 10px rgba(32, 214, 160, 0.04);
}
.freq-group.marine .freq-btn.active .freq-active-dot {
    background: var(--marine);
    box-shadow: 0 0 8px var(--marine-glow);
}

/* Active — Radio */
.freq-group.radio .freq-btn.active {
    border-color: var(--radio-dim);
    box-shadow: 0 0 10px var(--radio-glow), inset 0 0 10px rgba(184, 136, 255, 0.04);
}
.freq-group.radio .freq-btn.active .freq-active-dot {
    background: var(--radio);
    box-shadow: 0 0 8px var(--radio-glow);
}

@keyframes dot-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.freq-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ── Bottom Panels (Radio + Custom Tune) ── */

.bottom-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
    animation: fadeSlideIn 0.6s ease-out 0.2s both;
}

/* ── Custom Tune ── */

.custom-tune {
    border-top: 2px solid var(--custom);
}

.custom-tune .panel-header h2,
.custom-tune .panel-icon { color: var(--custom); }

.custom-tune-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.custom-freq-input {
    flex: 1;
    min-width: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 9px 10px;
    color: var(--text-bright);
    font-family: var(--font-mono);
    font-size: 0.82em;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.custom-freq-input::placeholder {
    color: var(--text-dim);
}

.custom-freq-input:focus {
    outline: none;
    border-color: var(--custom);
    box-shadow: 0 0 8px var(--custom-glow);
}

/* Hide number input spinners */
.custom-freq-input::-webkit-outer-spin-button,
.custom-freq-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.custom-freq-input[type=number] {
    -moz-appearance: textfield;
}

.custom-mod-select {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 9px 8px;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.82em;
    transition: border-color 0.2s;
}

.custom-mod-select:focus {
    outline: none;
    border-color: var(--custom);
}

.custom-tune-btn {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.78em;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    background: transparent;
    color: var(--custom);
    border: 1px solid var(--custom);
    border-radius: 3px;
    padding: 9px 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, box-shadow 0.2s;
}

.custom-tune-btn:hover {
    background: rgba(210, 153, 34, 0.08);
    box-shadow: 0 0 10px var(--custom-glow);
}

.custom-tune-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ── Activity / Comms Log ── */

.comms-log {
    margin-bottom: 24px;
    animation: fadeSlideIn 0.6s ease-out 0.25s both;
}

.comms-log .panel-header h3,
.comms-log .panel-icon {
    color: var(--text-dim);
}

.log-entries {
    max-height: 180px;
    overflow-y: auto;
    font-size: 0.72em;
}

.log-entry {
    padding: 4px 0;
    color: var(--text-dim);
    border-bottom: 1px solid rgba(26, 37, 53, 0.5);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-time {
    color: var(--text-dim);
    opacity: 0.45;
    margin-right: 10px;
}

/* Scrollbar */
.log-entries::-webkit-scrollbar {
    width: 4px;
}
.log-entries::-webkit-scrollbar-track {
    background: var(--bg);
}
.log-entries::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 2px;
}

/* ── Footer ── */

.console-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 18px 0 0;
    font-family: var(--font-display);
    font-size: 0.58em;
    letter-spacing: 3px;
    color: var(--text-dim);
    opacity: 0.35;
    text-transform: uppercase;
    border-top: 1px solid var(--border);
}

.footer-sep {
    display: inline-block;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-dim);
    opacity: 0.5;
}

/* ── Connection Lost Banner ── */

.connection-lost {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--red);
    color: white;
    text-align: center;
    padding: 8px;
    font-family: var(--font-display);
    font-size: 0.72em;
    font-weight: 600;
    letter-spacing: 2px;
    z-index: 100;
    display: none;
}

.connection-lost.visible {
    display: block;
}

/* ── Toast ── */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-raised);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 12px 24px;
    font-family: var(--font-mono);
    font-size: 0.78em;
    color: var(--text);
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.toast.visible {
    opacity: 1;
}

/* ── Entry Animation ── */

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Responsive ── */

@media (max-width: 640px) {
    .console {
        padding: 0 12px 30px;
    }

    .station-header {
        padding: 32px 0 24px;
    }

    .station-id h1 {
        font-size: 1.25em;
        letter-spacing: 3px;
    }

    .coordinates {
        font-size: 0.62em;
        letter-spacing: 1.5px;
    }

    .control-strip {
        flex-direction: column;
    }

    .transport-module {
        flex-direction: row;
        min-width: unset;
    }

    .freq-panels,
    .bottom-panels {
        grid-template-columns: 1fr;
    }

    #spectrum {
        height: 120px;
    }

    .custom-tune-row {
        flex-wrap: wrap;
    }

    .custom-freq-input {
        flex: 1 1 100%;
    }
}
