/* === RESET & BASE === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --vault-black: #0a0f0a;
    --terminal-phosphor: #00ff88;
    --alert-amber: #ffaa00;
    --undergrowth: #1a2a1a;
    --phosphor-ghost: #00ff8833;
    --breach-red: #ff2244;
    --cleartext-gray: #e0e0e0;
    --boot-delay: 0ms;
}

html, body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: var(--vault-black);
    color: var(--terminal-phosphor);
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(12px, 1.4vw, 16px);
    letter-spacing: 0.05em;
    line-height: 1.7;
}

/* === SCAN LINES === */
#scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 255, 136, 0.03) 0px,
        rgba(0, 255, 136, 0.03) 1px,
        transparent 1px,
        transparent 2px
    );
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
}

#scanlines.active {
    animation: scanlineFadeIn 200ms ease forwards;
}

@keyframes scanlineFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* === GRID UNDERLAY === */
#grid-underlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(to right, rgba(0, 255, 136, 0.05) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 255, 136, 0.05) 1px, transparent 1px);
    background-size: 48px 48px;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
}

#grid-underlay.active {
    animation: gridFadeIn 400ms ease forwards;
}

@keyframes gridFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* === HUD FRAME === */
#hud-frame {
    position: fixed;
    top: 16px;
    left: 16px;
    right: 16px;
    bottom: 16px;
    z-index: 1;
    pointer-events: none;
}

.hud-border {
    position: absolute;
    background: var(--terminal-phosphor);
    opacity: 0;
}

.hud-border-top {
    top: 0;
    left: 0;
    height: 1px;
    width: 0;
}

.hud-border-top.animate {
    opacity: 1;
    animation: drawHorizontal 300ms ease-out forwards;
}

.hud-border-right {
    top: 0;
    right: 0;
    width: 1px;
    height: 0;
}

.hud-border-right.animate {
    opacity: 1;
    animation: drawVertical 200ms ease-out forwards;
}

.hud-border-bottom {
    bottom: 0;
    right: 0;
    height: 1px;
    width: 0;
}

.hud-border-bottom.animate {
    opacity: 1;
    animation: drawHorizontalReverse 300ms ease-out forwards;
}

.hud-border-left {
    bottom: 0;
    left: 0;
    width: 1px;
    height: 0;
}

.hud-border-left.animate {
    opacity: 1;
    animation: drawVerticalReverse 200ms ease-out forwards;
}

@keyframes drawHorizontal {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes drawVertical {
    from { height: 0; }
    to { height: 100%; }
}

@keyframes drawHorizontalReverse {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes drawVerticalReverse {
    from { height: 0; }
    to { height: 100%; }
}

/* === CORNER BRACKETS === */
.corner-bracket {
    position: fixed;
    width: 24px;
    height: 24px;
    z-index: 2;
    pointer-events: none;
    opacity: 0;
}

.corner-bracket.animate {
    opacity: 1;
    transition: all 600ms ease-out;
}

.corner-tl {
    top: 32px;
    left: 32px;
    border-top: 2px solid var(--terminal-phosphor);
    border-left: 2px solid var(--terminal-phosphor);
}

.corner-tl.animate {
    top: 8px;
    left: 8px;
}

.corner-tr {
    top: 32px;
    right: 32px;
    border-top: 2px solid var(--terminal-phosphor);
    border-right: 2px solid var(--terminal-phosphor);
}

.corner-tr.animate {
    top: 8px;
    right: 8px;
}

.corner-bl {
    bottom: 32px;
    left: 32px;
    border-bottom: 2px solid var(--terminal-phosphor);
    border-left: 2px solid var(--terminal-phosphor);
}

.corner-bl.animate {
    bottom: 8px;
    left: 8px;
}

.corner-br {
    bottom: 32px;
    right: 32px;
    border-bottom: 2px solid var(--terminal-phosphor);
    border-right: 2px solid var(--terminal-phosphor);
}

.corner-br.animate {
    bottom: 8px;
    right: 8px;
}

/* === SENSOR PANELS === */
.sensor-panel {
    position: fixed;
    background: var(--undergrowth);
    z-index: 5;
    padding: 10px;
    opacity: 0;
    cursor: pointer;
    border: 1px solid rgba(0, 255, 136, 0.4);
    transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1),
                border-color 200ms ease,
                opacity 300ms ease;
}

.sensor-panel.active {
    opacity: 1;
}

.sensor-panel:hover {
    transform: scale(1.02);
    border-color: var(--terminal-phosphor);
}

.sensor-panel.expanded {
    position: fixed;
    top: 10vh !important;
    left: 10vw !important;
    right: 10vw !important;
    bottom: 10vh !important;
    width: 80vw !important;
    height: 80vh !important;
    z-index: 100;
    transform: scale(1);
    padding: 24px;
    overflow-y: auto;
    border-color: var(--terminal-phosphor);
}

.sensor-panel .panel-expanded-content {
    display: none;
}

.sensor-panel.expanded .panel-expanded-content {
    display: block;
    margin-top: 16px;
}

.panel-label {
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--cleartext-gray);
    opacity: 0.5;
    margin-bottom: 6px;
}

/* Panel: Top-Left */
#panel-tl {
    top: 28px;
    left: 28px;
    width: 220px;
    height: 120px;
}

.velocity-chart {
    width: 100%;
    height: 60px;
}

.chart-line {
    stroke-dasharray: 320;
    stroke-dashoffset: 320;
}

.chart-line.animate {
    animation: drawChart 8s linear infinite;
}

@keyframes drawChart {
    0% { stroke-dashoffset: 320; }
    50% { stroke-dashoffset: 0; }
    50.01% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: -320; }
}

.velocity-chart-expanded {
    width: 100%;
    height: 200px;
    margin-top: 12px;
}

.chart-line-expanded {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
}

.sensor-panel.expanded .chart-line-expanded {
    animation: drawChartExpanded 10s linear infinite;
}

@keyframes drawChartExpanded {
    0% { stroke-dashoffset: 600; }
    50% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: -600; }
}

.expanded-title {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 600;
    font-size: clamp(14px, 2vw, 20px);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--terminal-phosphor);
    margin-bottom: 12px;
}

.expanded-stats {
    display: flex;
    gap: 24px;
    margin-top: 12px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    color: var(--terminal-phosphor);
    opacity: 0.7;
}

/* Panel: Top-Right */
#panel-tr {
    top: 28px;
    right: 28px;
    width: 220px;
    height: 120px;
    overflow: hidden;
}

.hash-ticker {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    color: var(--terminal-phosphor);
    opacity: 0.4;
    line-height: 1.6;
    overflow: hidden;
    height: 80px;
}

.hash-ticker-expanded {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--terminal-phosphor);
    opacity: 0.6;
    line-height: 1.8;
    max-height: calc(80vh - 120px);
    overflow-y: auto;
}

/* Panel: Bottom-Left */
#panel-bl {
    bottom: 28px;
    left: 28px;
    width: 160px;
    height: 140px;
}

.gauge-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.consensus-gauge {
    width: 100px;
    height: 100px;
}

.gauge-arc {
    stroke-dasharray: 251.2;
    stroke-dashoffset: 251.2;
}

.gauge-arc.animate {
    animation: fillGauge 2s ease-out forwards;
}

@keyframes fillGauge {
    from { stroke-dashoffset: 251.2; }
    to { stroke-dashoffset: 29.4; }
}

.consensus-details {
    margin-top: 12px;
}

.consensus-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0, 255, 136, 0.1);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    color: var(--terminal-phosphor);
    opacity: 0.8;
}

.consensus-row.total-row {
    border-bottom: none;
    opacity: 1;
    font-weight: 400;
}

.consensus-val {
    color: var(--terminal-phosphor);
}

/* Panel: Bottom-Right */
#panel-br {
    bottom: 28px;
    right: 28px;
    width: 180px;
    height: 140px;
}

.status-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    font-weight: 300;
    color: var(--terminal-phosphor);
    opacity: 0.8;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-green {
    background: var(--terminal-phosphor);
    animation: blink-green 1s step-end infinite;
}

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

.status-amber {
    background: var(--alert-amber);
    animation: pulse-amber 1s ease-in-out infinite;
}

@keyframes pulse-amber {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

.status-name {
    letter-spacing: 0.1em;
}

.status-diagnostics {
    margin-top: 12px;
}

.diag-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0, 255, 136, 0.1);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    color: var(--terminal-phosphor);
}

.diag-name {
    min-width: 60px;
    letter-spacing: 0.1em;
}

.diag-detail {
    color: var(--cleartext-gray);
    opacity: 0.6;
    font-size: 11px;
    margin-left: auto;
}

/* === CENTRAL DATA WELL === */
#central-well {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60vw;
    height: 60vh;
    z-index: 3;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 20px;
    opacity: 0;
}

#central-well::-webkit-scrollbar {
    width: 2px;
}

#central-well::-webkit-scrollbar-track {
    background: transparent;
}

#central-well::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 136, 0.2);
}

#central-well.active {
    opacity: 1;
    transition: opacity 300ms ease;
}

#terminal-output {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(12px, 1.4vw, 16px);
    letter-spacing: 0.05em;
    line-height: 1.7;
    color: var(--terminal-phosphor);
}

.terminal-line {
    margin-bottom: 4px;
    white-space: pre-wrap;
    word-break: break-all;
}

.timestamp-prefix {
    color: var(--cleartext-gray);
    opacity: 0.7;
}

.classification-stamp {
    display: inline-block;
    padding: 1px 8px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 6px 0;
}

.stamp-unrestricted {
    border: 1px solid var(--terminal-phosphor);
    color: var(--terminal-phosphor);
}

.stamp-eyes-only {
    border: 1px solid var(--alert-amber);
    color: var(--alert-amber);
}

.stamp-redacted {
    border: 1px solid var(--breach-red);
    color: var(--breach-red);
    position: relative;
    overflow: hidden;
}

.stamp-redacted::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        var(--breach-red) 0,
        var(--breach-red) 30%,
        transparent 30%,
        transparent 50%
    );
    background-size: 8px 8px;
    opacity: 0.3;
    pointer-events: none;
}

.section-header {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 600;
    font-size: clamp(14px, 2vw, 22px);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--terminal-phosphor);
    margin: 12px 0 4px 0;
}

.data-readout {
    font-weight: 300;
    opacity: 0.8;
    color: var(--terminal-phosphor);
}

/* === BLINKING CURSOR === */
#cursor {
    display: inline-block;
    width: 2px;
    height: 16px;
    background: var(--terminal-phosphor);
    vertical-align: middle;
    opacity: 0;
}

#cursor.active {
    animation: cursorBlink 1s step-end infinite;
}

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

/* === MODAL OVERLAY === */
#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 15, 10, 0.9);
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
}

#modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* === REDACT EASTER EGG FLASH === */
.redact-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--breach-red);
    opacity: 0.1;
    z-index: 10000;
    pointer-events: none;
    animation: redactFlash 100ms ease-out forwards;
}

@keyframes redactFlash {
    from { opacity: 0.1; }
    to { opacity: 0; }
}

/* === SELECTION HIGHLIGHT === */
::selection {
    background: var(--phosphor-ghost);
    color: var(--terminal-phosphor);
}
