/* ============================================================
   bable.pro — Broadcast Station Dashboard
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    --bg-primary: #0a0a0a;
    --bg-panel: #111110;
    --bg-accent: #1a120c;
    --burnt-copper: #d4621a;
    --forge-orange: #e8872d;
    --signal-gold: #f0b95a;
    --warm-parchment: #e8d5c4;
    --aged-steel: #8a7d72;
    --dark-rust: #3d2a1a;
    --signal-cyan: #1ac4d4;
    --warning-red: #d41a2e;
    --gap-bezel: #0d0d0d;

    --font-headline: 'Barlow Condensed', sans-serif;
    --font-body: 'Barlow', sans-serif;
    --font-mono: 'Share Tech Mono', monospace;

    --header-height: 8vh;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: auto;
}

body {
    background-color: var(--bg-primary);
    color: var(--warm-parchment);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 1.05rem;
    line-height: 1.65;
    overflow-x: hidden;
    min-height: 100vh;
}

/* --- Scanlines Overlay (CRT) --- */
.scanlines-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 2px,
        rgba(0, 0, 0, 0.03) 2px,
        rgba(0, 0, 0, 0.03) 4px
    );
}

/* --- Power-On Overlay --- */
.power-on-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 10000;
    pointer-events: none;
}

.power-on-overlay.phase-scan {
    background: #000;
}

.power-on-overlay.phase-done {
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.power-on-overlay.phase-hidden {
    display: none;
}

.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(to right, transparent, var(--burnt-copper), transparent);
    opacity: 0;
    box-shadow: 0 0 12px var(--burnt-copper), 0 0 30px rgba(212, 98, 26, 0.4);
}

.scan-line.animate {
    opacity: 1;
    animation: scanSweep 0.6s linear forwards;
}

@keyframes scanSweep {
    from { top: 0; }
    to { top: 100vh; }
}

/* --- Dashboard Grid --- */
.dashboard {
    display: grid;
    grid-template-columns: 1fr 0.62fr;
    grid-template-rows: var(--header-height) 1fr;
    min-height: 100vh;
    gap: 2px;
    background-color: var(--gap-bezel);
    opacity: 0;
    transition: opacity 0.5s ease;
}

.dashboard.visible {
    opacity: 1;
}

/* --- Panel Base --- */
.panel {
    background-color: var(--bg-panel);
    border: 1px solid var(--dark-rust);
    border-radius: 0;
    box-shadow: inset 0 0 20px rgba(212, 98, 26, 0.05);
    opacity: 0;
    transform: scale(0.98);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.panel.panel-active {
    opacity: 1;
    transform: scale(1);
}

/* --- Command Header --- */
.command-header {
    grid-column: 1 / -1;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    border-bottom: 1px solid var(--burnt-copper);
    background-color: var(--bg-primary);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.wordmark {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--warm-parchment);
}

.wordmark-dot {
    color: var(--burnt-copper);
}

.header-status {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    color: var(--burnt-copper);
    animation: statusBlink 3s ease-in-out infinite;
}

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

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.header-timestamp {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    color: var(--aged-steel);
}

.signal-strength svg {
    display: block;
}

.sig-bar {
    fill: var(--burnt-copper);
    animation: sigPulse 2s ease-in-out infinite;
}

.sig-bar-1 { animation-delay: 0s; }
.sig-bar-2 { animation-delay: 0.15s; }
.sig-bar-3 { animation-delay: 0.3s; }
.sig-bar-4 { animation-delay: 0.45s; }

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

/* --- Primary Viewport --- */
.primary-viewport {
    grid-column: 1;
    grid-row: 2;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4rem 8vw;
    background-color: var(--bg-primary);
    position: relative;
}

.circuit-traces {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.6;
}

.circuit-pulse {
    animation: circuitPulse 3s ease-in-out infinite;
}

@keyframes circuitPulse {
    0%, 100% { fill: transparent; stroke: var(--burnt-copper); opacity: 0.3; }
    50% { fill: var(--burnt-copper); stroke: var(--burnt-copper); opacity: 1; }
}

/* --- Lens Flare Effects --- */
.lens-flare {
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
    mix-blend-mode: screen;
    opacity: 0.15;
}

.flare-1 {
    width: 400px;
    height: 400px;
    top: 5%;
    right: -10%;
    background: radial-gradient(circle, rgba(212, 98, 26, 0.6) 0%, rgba(240, 185, 90, 0.2) 40%, transparent 70%);
    animation: flareDrift1 30s ease-in-out infinite alternate;
}

.flare-2 {
    width: 300px;
    height: 300px;
    top: 40%;
    left: -5%;
    background: radial-gradient(circle, rgba(232, 135, 45, 0.5) 0%, rgba(212, 98, 26, 0.15) 50%, transparent 75%);
    animation: flareDrift2 25s ease-in-out infinite alternate;
}

.flare-3 {
    width: 250px;
    height: 250px;
    bottom: 15%;
    right: 5%;
    background: radial-gradient(circle, rgba(240, 185, 90, 0.5) 0%, rgba(212, 98, 26, 0.1) 60%, transparent 80%);
    animation: flareDrift3 35s ease-in-out infinite alternate;
}

@keyframes flareDrift1 {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(-60px, 80px) scale(1.15); }
}

@keyframes flareDrift2 {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(40px, -50px) scale(0.9); }
}

@keyframes flareDrift3 {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(-30px, -40px) scale(1.1); }
}

/* --- Transmission Articles --- */
.transmission {
    position: relative;
    z-index: 1;
    margin-bottom: 5rem;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.transmission-header {
    margin-bottom: 1.5rem;
}

.transmission-id {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.15em;
    color: var(--burnt-copper);
    display: block;
    margin-bottom: 0.5rem;
}

.transmission-rule {
    border: none;
    height: 1px;
    background-color: var(--dark-rust);
}

/* --- Typography --- */
.headline {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--warm-parchment);
    line-height: 1.15;
    margin-bottom: 1.5rem;
}

.body-text {
    color: var(--warm-parchment);
    margin-bottom: 1.2rem;
    max-width: 65ch;
}

.accent-quote {
    font-family: var(--font-headline);
    font-weight: 500;
    font-style: italic;
    font-size: 1.4rem;
    color: var(--signal-gold);
    border-left: 3px solid var(--burnt-copper);
    padding-left: 1.5rem;
    margin: 2rem 0;
    line-height: 1.5;
}

/* --- Content Cards --- */
.content-card {
    background-color: var(--bg-panel);
    border: 1px solid var(--dark-rust);
    padding: 1.5rem 2rem;
    margin-bottom: 1rem;
    position: relative;
    transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1), box-shadow 0.4s ease;
}

.content-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background-color: var(--burnt-copper);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.content-card:hover::before,
.content-card.focused::before {
    opacity: 1;
}

.card-title {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--forge-orange);
    margin-bottom: 0.75rem;
}

/* --- Zoom-Focus Interaction --- */
.content-card:hover,
.content-card.focused {
    transform: scale(1.02);
    box-shadow: 0 0 30px rgba(212, 98, 26, 0.1);
}

.transmission.dimmed .content-card:not(:hover):not(.focused) {
    opacity: 0.4;
    filter: blur(1px);
    transition: opacity 0.4s cubic-bezier(0.23, 1, 0.32, 1), filter 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

/* --- Log Entries --- */
.log-entries {
    margin-top: 1.5rem;
}

.log-entry {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(61, 42, 26, 0.5);
    transition: background-color 0.3s ease, transform 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.log-entry:hover {
    background-color: rgba(26, 18, 12, 0.8);
    transform: scale(1.02);
}

.log-time {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.15em;
    color: var(--aged-steel);
    min-width: 5ch;
}

.log-label {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--warm-parchment);
    flex: 1;
}

.log-status {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    padding: 0.2rem 0.5rem;
}

.status-active {
    color: var(--burnt-copper);
    border: 1px solid var(--burnt-copper);
}

.status-warning {
    color: var(--warning-red);
    border: 1px solid var(--warning-red);
}

/* --- End Signal Marker --- */
.end-signal-marker {
    margin-top: 3rem;
    text-align: center;
}

.end-marker-text {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.15em;
    color: var(--aged-steel);
}

.end-marker-line {
    width: 200px;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--dark-rust), transparent);
    margin: 1rem auto 0;
}

/* --- Signal Panel (Right Sidebar) --- */
.signal-panel {
    grid-column: 2;
    grid-row: 2;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    display: flex;
    flex-direction: column;
    gap: 2px;
    background-color: var(--gap-bezel);
}

.instrument-panel {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    overflow: hidden;
}

.panel-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    color: var(--aged-steel);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--dark-rust);
}

/* --- Oscilloscope Panel --- */
.oscilloscope-panel {
    flex: 0 0 40%;
}

#oscilloscope-canvas {
    width: 100%;
    flex: 1;
    background-color: var(--bg-primary);
    display: block;
}

.panel-readout {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    padding-top: 0.25rem;
    border-top: 1px solid var(--dark-rust);
}

.readout-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    color: var(--aged-steel);
}

.readout-value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.15em;
    color: var(--burnt-copper);
}

/* --- Telemetry Panel --- */
.telemetry-panel {
    flex: 0 0 35%;
}

.telemetry-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    flex: 1;
    align-content: start;
}

.telemetry-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.telemetry-key {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    letter-spacing: 0.15em;
    color: var(--aged-steel);
    text-transform: uppercase;
}

.telemetry-val {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.15em;
    color: var(--burnt-copper);
}

.tel-active {
    color: var(--forge-orange);
    animation: statusBlink 3s ease-in-out infinite;
}

/* --- Spectrum Panel --- */
.spectrum-panel {
    flex: 0 0 25%;
}

.spectrum-bars {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    flex: 1;
    padding: 0.5rem 0;
}

.spectrum-bar {
    flex: 1;
    background: linear-gradient(to top, var(--burnt-copper), var(--forge-orange));
    border-radius: 0;
    min-height: 4px;
    height: var(--bar-height, 30%);
    transition: height 0.3s ease;
    animation: spectrumIdle 2s ease-in-out infinite;
    animation-delay: calc(var(--bar-index) * 0.12s);
}

@keyframes spectrumIdle {
    0%, 100% { height: var(--bar-height, 30%); opacity: 0.7; }
    50% { height: calc(var(--bar-height, 30%) + 15%); opacity: 1; }
}

.spectrum-labels {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 0.5rem;
    letter-spacing: 0.1em;
    color: var(--aged-steel);
    padding-top: 0.25rem;
    border-top: 1px solid var(--dark-rust);
}

/* --- Glitch Animation --- */
@keyframes glitchDisplace {
    0% { transform: translateX(0); filter: hue-rotate(0deg); }
    10% { transform: translateX(-4px); }
    20% { transform: translateX(6px); filter: hue-rotate(180deg); }
    30% { transform: translateX(-2px); }
    40% { transform: translateX(4px); filter: hue-rotate(0deg); }
    50% { transform: translateX(-6px); filter: hue-rotate(180deg); }
    60% { transform: translateX(3px); }
    70% { transform: translateX(-4px); filter: hue-rotate(90deg); }
    80% { transform: translateX(2px); }
    90% { transform: translateX(-1px); filter: hue-rotate(0deg); }
    100% { transform: translateX(0); filter: hue-rotate(0deg); }
}

.glitch-active {
    animation: glitchDisplace 0.3s linear;
}

.glitch-hover:hover {
    animation: glitchDisplace 0.3s linear;
}

/* Glitch cyan flash */
.glitch-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: rgba(26, 196, 212, 0.05);
    opacity: 0;
    z-index: 2;
}

.glitch-flash.active {
    animation: glitchFlash 0.3s linear;
}

@keyframes glitchFlash {
    0% { opacity: 0; }
    20% { opacity: 1; }
    40% { opacity: 0; }
    60% { opacity: 0.5; }
    80% { opacity: 0; }
    100% { opacity: 0; }
}

/* --- Mobile Responsive (< 768px) --- */
@media (max-width: 768px) {
    .dashboard {
        grid-template-columns: 1fr;
        grid-template-rows: var(--header-height) auto;
    }

    .command-header {
        padding: 0 1rem;
    }

    .wordmark {
        font-size: 1.1rem;
    }

    .primary-viewport {
        padding: 2rem 5vw;
        grid-column: 1;
    }

    .signal-panel {
        grid-column: 1;
        grid-row: auto;
        position: relative;
        top: 0;
        height: auto;
        flex-direction: column;
    }

    .instrument-panel {
        flex: none;
        min-height: 150px;
    }

    .oscilloscope-panel {
        flex: none;
        height: 200px;
    }

    .telemetry-panel {
        flex: none;
    }

    .spectrum-panel {
        flex: none;
        height: 120px;
    }

    .headline {
        font-size: clamp(1.4rem, 5vw, 2.5rem);
    }

    .log-entry {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .content-card {
        padding: 1rem 1.25rem;
    }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .scan-line,
    .circuit-pulse,
    .lens-flare,
    .spectrum-bar,
    .sig-bar,
    .header-status,
    .tel-active {
        animation: none;
    }

    .glitch-active,
    .glitch-hover:hover {
        animation: none;
    }

    .panel {
        opacity: 1;
        transform: none;
    }

    .dashboard {
        opacity: 1;
    }

    .power-on-overlay {
        display: none;
    }
}
