/* ==========================================================================
   FONTS & VARIABLES
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Russo+One&family=VT323&display=swap');

:root {
    /* Terminal Neon Green Colors */
    --neon-green: #39ff14;
    --neon-dim: #115505;
    --neon-glow: rgba(57, 255, 20, 0.4);
    --bg-dark: #010a01;

    /* Text Colors */
    --text-primary: var(--neon-green);
    --text-highlight: #ffffff;
    --text-highlight-glow: #ffffff;
    --text-error: #ff2a2a;
    --text-muted: rgba(57, 255, 20, 0.6);

    /* UI Elements */
    --panel-bg: rgba(57, 255, 20, 0.03);
    --panel-border: var(--neon-dim);
    --scanline-color: rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   BASE STYLES & RESET
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    cursor: crosshair;
}

html { font-size: 20px; }

body {
    background-color: #000;
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    font-family: 'VT323', monospace;
    font-size: 1.15rem;
    line-height: 1.5;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    overflow: hidden; /* Full screen, no body scrolling */
}

h1, h2, h3, h4 {
    font-family: 'Russo One', sans-serif;
    text-transform: uppercase;
    font-weight: normal;
    letter-spacing: 1px;
}

/* ==========================================================================
   FULL SCREEN CRT EFFECT
   ========================================================================== */
.crt-screen {
    background-color: var(--bg-dark);
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 30px 40px;
    box-shadow: inset 0 0 100px rgba(0,20,0,0.9);
}

/* Scanlines & Vignette */
.crt-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 100;
    background:
        repeating-linear-gradient(0deg, transparent, transparent 2px, var(--scanline-color) 2px, var(--scanline-color) 4px),
        radial-gradient(circle at center, transparent 40%, rgba(0,5,0,0.8) 100%);
}

/* Screen flicker */
.flicker-fx {
    animation: crt-flicker 0.15s infinite alternate;
}
@keyframes crt-flicker {
    0% { opacity: 0.95; }
    100% { opacity: 1; }
}

/* ==========================================================================
   BOOT SEQUENCE
   ========================================================================== */
#boot-screen {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--bg-dark);
    z-index: 50;
    padding: 40px;
    font-size: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    color: var(--neon-green);
    text-shadow: 0 0 8px var(--neon-glow);
    transition: opacity 0.5s ease-out;
}

.cursor {
    display: inline-block;
    width: 15px;
    height: 1.8rem;
    background: var(--neon-green);
    animation: blink 1s infinite;
    vertical-align: bottom;
}
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

/* ==========================================================================
   MAIN UI CONTAINER
   ========================================================================== */
.ui-layer {
    position: relative;
    z-index: 10;
    color: var(--neon-green);
    text-shadow: 0 0 8px var(--neon-glow);
    display: flex;
    flex-direction: column;
    height: 100%;
    opacity: 0;
    transition: opacity 0.5s ease-in;
}

/* Header */
.sys-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--neon-dim);
    padding-bottom: 10px;
}

.sys-header h1 { font-size: 3rem; line-height: 1; }
.sys-header h1 span { color: var(--text-highlight); text-shadow: 0 0 10px var(--text-highlight-glow), 0 0 20px var(--text-highlight-glow); }

.sys-info { text-align: right; font-size: 1.5rem; }

/* ==========================================================================
   NAVIGATION TABS
   ========================================================================== */
.nav-tabs {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
}

.tab-btn {
    background: transparent;
    color: var(--neon-green);
    border: 2px solid var(--neon-dim);
    padding: 10px 25px;
    font-family: 'Russo One', sans-serif;
    font-size: 1.3rem;
    text-transform: uppercase;
    transition: all 0.2s;
    position: relative;
}

.tab-btn:hover, .tab-btn.active {
    background: var(--neon-green);
    color: #000;
    border-color: var(--neon-green);
    box-shadow: 0 0 15px var(--neon-glow);
    text-shadow: none;
}

/* ==========================================================================
   CONTENT SECTIONS & GRIDS
   ========================================================================== */
.page-content {
    display: none;
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 15px;
    padding-bottom: 30px;
}

.page-content.active {
    display: block;
    animation: scanline-reveal 0.3s ease-out;
}

@keyframes scanline-reveal {
    0% { opacity: 0; transform: translateY(10px); filter: contrast(200%); }
    100% { opacity: 1; transform: translateY(0); filter: contrast(100%); }
}

/* Custom Scrollbar */
.page-content::-webkit-scrollbar { width: 8px; }
.page-content::-webkit-scrollbar-track { background: var(--bg-dark); border: 1px solid var(--neon-dim); }
.page-content::-webkit-scrollbar-thumb { background: var(--neon-dim); }
.page-content::-webkit-scrollbar-thumb:hover { background: var(--neon-green); }

/* Widget Grid System */
.grid-layout {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 20px;
}

.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }

/* Panel Styling */
.panel {
    border: 1px solid var(--panel-border);
    padding: 20px;
    background: var(--panel-bg);
    position: relative;
}

/* Decorative panel corner */
.panel::before {
    content: '';
    position: absolute;
    top: -1px; left: -1px;
    width: 15px; height: 15px;
    border-top: 3px solid var(--neon-green);
    border-left: 3px solid var(--neon-green);
}

.panel-title {
    font-family: 'Russo One', sans-serif;
    font-size: 1.45rem;
    color: var(--text-highlight);
    text-shadow: 0 0 5px var(--text-highlight-glow);
    border-bottom: 1px dashed var(--neon-dim);
    padding-bottom: 5px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ==========================================================================
   SPECIFIC WIDGET STYLES
   ========================================================================== */

/* Connect Button */
.btn-connect {
    display: block;
    background: var(--neon-green);
    color: #000;
    padding: 12px;
    text-align: center;
    font-family: 'Russo One', sans-serif;
    font-size: 1.5rem;
    text-decoration: none;
    border: 2px solid var(--neon-green);
    margin-top: 15px;
    transition: 0.2s;
    text-shadow: none;
    box-shadow: 0 0 15px var(--neon-glow);
}
.btn-connect:hover {
    background: #000;
    color: var(--neon-green);
    box-shadow: inset 0 0 20px var(--neon-green);
}

.btn-discord {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: transparent;
    color: var(--neon-green);
    padding: 9px;
    text-align: center;
    font-family: 'Russo One', sans-serif;
    font-size: 1.1rem;
    letter-spacing: 1px;
    text-decoration: none;
    border: 2px solid var(--neon-dim);
    margin-top: 10px;
    transition: 0.2s;
}
.btn-discord:hover {
    border-color: var(--neon-green);
    box-shadow: 0 0 10px var(--neon-glow);
    color: var(--text-highlight);
}

/* Interactive Radar Map */
.radar-container {
    width: 100%;
    height: 250px;
    background-color: #010501;
    border: 1px solid var(--neon-green);
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 0 30px rgba(57, 255, 20, 0.1);
}

/* Larger variant used on the dedicated SATELLITE tab, where the map has the whole page to itself */
.radar-container-lg {
    height: 60vh;
    min-height: 400px;
    cursor: grab;
    touch-action: none; /* we handle pan/pinch-zoom ourselves via pointer events */
}
.radar-container-lg.grabbing { cursor: grabbing; }

/* Real map render, drawn at full resolution (no downsampling/blockiness) and tinted to the
   terminal's green phosphor palette via CSS filter so it reads as part of the same CRT world.
   transform (not width/height) drives pan/zoom, so it stays GPU-composited and stutter-free. */
.map-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: contain; /* show the whole map, letterboxed, never cropped */
    image-rendering: auto;
    filter: grayscale(0.25) sepia(0.5) hue-rotate(60deg) saturate(3.2) contrast(1.25) brightness(0.85);
    opacity: 0;
    transform-origin: 0 0;
    transition: opacity 0.6s ease;
    pointer-events: none; /* the container handles input, so a zoomed-out canvas edge can't dead-zone drags */
}
.map-canvas.loaded { opacity: 0.85; }

.map-zoom-hint {
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-size: 0.95rem;
    letter-spacing: 1px;
    color: var(--text-muted);
    pointer-events: none;
    opacity: 0.8;
    z-index: 5;
}
.map-canvas-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 1.2rem;
    letter-spacing: 2px;
}
.map-canvas-placeholder.hidden { display: none; }

.radar-grid {
    position: absolute;
    width: 100%; height: 100%;
    background-image:
        linear-gradient(var(--neon-dim) 1px, transparent 1px),
        linear-gradient(90deg, var(--neon-dim) 1px, transparent 1px);
    background-size: 30px 30px;
    opacity: 0.4;
    pointer-events: none;
}

.radar-sweep {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 250%;
    aspect-ratio: 1 / 1;
    transform: translate(-50%, -50%);
    transform-origin: center center;
    background: conic-gradient(from 0deg, transparent 70%, rgba(57, 255, 20, 0.8) 100%);
    border-radius: 50%;
    animation: spin-radar 3s linear infinite;
    pointer-events: none;
}
@keyframes spin-radar {
    0%   { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.crosshair-h { position: absolute; width: 100%; height: 1px; background: var(--neon-green); opacity: 0.3; pointer-events: none; }
.crosshair-v { position: absolute; height: 100%; width: 1px; background: var(--neon-green); opacity: 0.3; pointer-events: none; }

/* Wipe Countdown Timer */
.timer-display {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    text-align: center;
    margin-top: 15px;
}
.time-box {
    background: rgba(0,0,0,0.6);
    border: 1px solid var(--neon-dim);
    flex: 1;
    padding: 10px 5px;
}
.t-val { font-size: 3rem; font-weight: bold; line-height: 1; }
.t-lbl { font-size: 1.25rem; color: var(--text-muted); margin-top: 5px; }

/* Hardware Bars */
.hw-bar-bg {
    background: #002200;
    width: 100%;
    height: 15px;
    border: 1px solid var(--neon-dim);
    margin-top: 5px;
    margin-bottom: 10px;
}
.hw-bar-fill {
    background: var(--neon-green);
    height: 100%;
    box-shadow: 0 0 10px var(--neon-glow);
}

/* Activity Feed */
#activity-feed {
    height: 250px;
    overflow-y: hidden;
    font-size: 1.35rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}
.log-entry { margin-bottom: 5px; }
.log-time { color: var(--text-muted); }
.log-highlight { color: var(--text-highlight); }

/* Tables & Lists */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; min-width: 500px; border-collapse: collapse; font-size: 1.4rem; margin-top: 15px; }
th { text-align: left; border-bottom: 2px solid var(--neon-green); padding: 10px; color: var(--text-highlight); font-family: 'Russo One', sans-serif; font-size: 1.25rem; }
td { padding: 10px; border-bottom: 1px dashed var(--neon-dim); }
tr:hover td { background: rgba(57, 255, 20, 0.1); color: var(--text-highlight); }

ul.directive-list { list-style: none; font-size: 1.4rem; margin-bottom: 25px; }
ul.directive-list li { margin-bottom: 12px; padding-left: 25px; position: relative; }
ul.directive-list li::before { content: '>>'; position: absolute; left: 0; color: var(--text-highlight); }

/* Click-to-copy IP */
.ip-copy { transition: color 0.2s, text-shadow 0.2s; }
.ip-copy:hover { color: var(--neon-green); text-shadow: 0 0 8px var(--neon-glow); }

/* Utility Classes */
.text-white { color: var(--text-highlight); }
.text-error { color: var(--text-error); text-shadow: 0 0 5px var(--text-error); }
.text-muted { color: var(--text-muted); text-shadow: none; }
.flicker-text { animation: text-flick 2s infinite; }
@keyframes text-flick {
    0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% { opacity: 1; }
    20%, 22%, 24%, 55% { opacity: 0.2; }
}

/* ==========================================================================
   RESPONSIVE / MOBILE (tested against iPhone 15 Safari/Chrome, ~393px CSS width)
   ========================================================================== */
@media (max-width: 900px) {
    html { font-size: 15px; }

    * { cursor: auto; }

    .crt-screen {
        padding: 14px 12px;
        height: 100dvh;
        overflow: hidden;
    }

    .sys-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        margin-bottom: 14px;
    }
    .sys-header h1 { font-size: 1.9rem; }
    .sys-info { text-align: left; font-size: 1.15rem; }

    .nav-tabs {
        gap: 8px;
        margin-bottom: 15px;
        flex-wrap: wrap;
    }
    .tab-btn {
        padding: 8px 14px;
        font-size: 1rem;
        flex: 1 1 auto;
        text-align: center;
    }

    .grid-layout {
        display: flex;
        flex-direction: column;
        gap: 14px;
    }
    .span-12, .span-8, .span-6, .span-5, .span-4, .span-3 {
        grid-column: unset;
    }

    .panel { padding: 14px; }
    .panel-title { font-size: 1.2rem; }

    .timer-display { gap: 6px; }
    .t-val { font-size: 1.9rem; }
    .t-lbl { font-size: 0.85rem; }

    .radar-container { height: 180px; }
    .radar-container-lg { height: 45vh; min-height: 260px; }

    table { min-width: 460px; font-size: 1.1rem; }
    th, td { padding: 8px 6px; }

    ul.directive-list, ul.directive-list li { font-size: 1.15rem; }

    #boot-screen { padding: 20px; font-size: 1.3rem; }
}

@media (max-width: 480px) {
    html { font-size: 13px; }
    .sys-header h1 { font-size: 1.5rem; }
    .t-val { font-size: 1.5rem; }
    .radar-container { height: 150px; }
}
