/* ============================================
   INTERNET TRAFFIC MAP — Command Center Theme
   ============================================ */

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

:root {
    /* Core palette */
    --bg: #030610;
    --bg-panel: rgba(4, 8, 20, 0.88);
    --land: #0a1628;
    --land-active: #0f2240;
    --border: #1a3060;
    --border-dim: #0d1a35;

    /* Accents */
    --cyan: #00c8ff;
    --cyan-dim: #0080aa;
    --cyan-glow: rgba(0, 200, 255, 0.15);
    --amber: #ffa500;
    --amber-dim: #996300;
    --green: #00ff7f;
    --green-dim: #009950;
    --red: #ff4455;

    /* Text */
    --text: #7a8eaa;
    --text-bright: #c0d4f0;
    --text-dim: #3a4e6a;

    /* Fonts */
    --font-display: 'Chakra Petch', sans-serif;
    --font-mono: 'IBM Plex Mono', 'SF Mono', monospace;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 400;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* ---- Scanline Overlay ---- */

.scanlines {
    position: fixed;
    inset: 0;
    z-index: 100;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.035) 2px,
        rgba(0, 0, 0, 0.035) 4px
    );
}

/* ---- App Layout ---- */

#app {
    position: relative;
    width: 100%;
    height: 100%;
    animation: boot 0.8s ease-out;
}

@keyframes boot {
    0% { opacity: 0; filter: brightness(3) saturate(0); }
    30% { opacity: 1; filter: brightness(1.5) saturate(0.5); }
    100% { opacity: 1; filter: brightness(1) saturate(1); }
}

/* ---- Header ---- */

header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: linear-gradient(to bottom, rgba(3, 6, 16, 0.95) 0%, rgba(3, 6, 16, 0.6) 70%, transparent 100%);
    border-bottom: 1px solid var(--border-dim);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-diamond {
    width: 10px;
    height: 10px;
    background: var(--cyan);
    transform: rotate(45deg);
    box-shadow: 0 0 8px var(--cyan), 0 0 20px rgba(0, 200, 255, 0.3);
    animation: diamond-pulse 3s ease-in-out infinite;
}

@keyframes diamond-pulse {
    0%, 100% { box-shadow: 0 0 8px var(--cyan), 0 0 20px rgba(0, 200, 255, 0.3); }
    50% { box-shadow: 0 0 12px var(--cyan), 0 0 30px rgba(0, 200, 255, 0.5); }
}

header h1 {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 4px;
    color: var(--text-dim);
    text-transform: uppercase;
}

.header-center {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 11px;
}

.utc-label {
    color: var(--text-dim);
    font-size: 9px;
    letter-spacing: 2px;
}

.utc-time {
    color: var(--cyan-dim);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

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

.live-badge {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 3px;
    color: var(--green);
}

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
    animation: live-pulse 2s ease-in-out infinite;
}

.live-ring {
    position: absolute;
    left: -3px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid var(--green);
    opacity: 0;
    animation: live-ring 2s ease-out infinite;
}

@keyframes live-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes live-ring {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(2.5); opacity: 0; }
}

/* ---- Map Container ---- */

#map-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

#map-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: grab;
}

#map-svg:active {
    cursor: grabbing;
}

#map-svg .country {
    fill: var(--land);
    stroke: #1a2a50;
    stroke-width: 0.5;
    transition: fill 0.6s ease;
}

#map-svg .country.active {
    fill: var(--land-active);
}

#map-svg .country:hover {
    fill: #132a4a;
}

#map-svg .graticule {
    fill: none;
    stroke: #060e1e;
    stroke-width: 0.3;
}

#map-svg .sphere {
    fill: var(--bg);
    stroke: #0a1830;
    stroke-width: 0.4;
}

#flow-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Vignette */
.vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse 80% 70% at 42% 50%,
        transparent 30%,
        rgba(3, 6, 16, 0.4) 65%,
        rgba(3, 6, 16, 0.85) 100%
    );
    pointer-events: none;
    z-index: 5;
}

/* HUD corner brackets */
.hud-corner {
    position: absolute;
    width: 24px;
    height: 24px;
    z-index: 6;
    pointer-events: none;
}

.hud-corner::before,
.hud-corner::after {
    content: '';
    position: absolute;
    background: var(--cyan-dim);
    opacity: 0.4;
}

.hud-corner.tl { top: 48px; left: 12px; }
.hud-corner.tl::before { top: 0; left: 0; width: 24px; height: 1px; }
.hud-corner.tl::after { top: 0; left: 0; width: 1px; height: 24px; }

.hud-corner.tr { top: 48px; right: 300px; }
.hud-corner.tr::before { top: 0; right: 0; width: 24px; height: 1px; }
.hud-corner.tr::after { top: 0; right: 0; width: 1px; height: 24px; }

.hud-corner.bl { bottom: 36px; left: 12px; }
.hud-corner.bl::before { bottom: 0; left: 0; width: 24px; height: 1px; }
.hud-corner.bl::after { bottom: 0; left: 0; width: 1px; height: 24px; }

.hud-corner.br { bottom: 36px; right: 300px; }
.hud-corner.br::before { bottom: 0; right: 0; width: 24px; height: 1px; }
.hud-corner.br::after { bottom: 0; right: 0; width: 1px; height: 24px; }

/* ---- Stats Panel ---- */

#stats-panel {
    position: absolute;
    top: 44px;
    right: 0;
    bottom: 28px;
    width: 280px;
    background: var(--bg-panel);
    border-left: 1px solid var(--border-dim);
    padding: 16px 14px;
    overflow-y: auto;
    z-index: 15;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

#stats-panel::-webkit-scrollbar {
    width: 3px;
}

#stats-panel::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

/* Panel sections */
.panel-section {
    margin-bottom: 18px;
    animation: section-in 0.5s ease-out both;
}

@keyframes section-in {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 2.5px;
    color: var(--cyan-dim);
    margin-bottom: 10px;
    padding-bottom: 6px;
}

.section-num {
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 300;
}

.section-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, var(--border-dim), transparent);
}

/* Stat rows */
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    font-size: 11px;
}

.stat-label {
    color: var(--text-dim);
    font-size: 10px;
    letter-spacing: 0.5px;
}

.stat-value {
    color: var(--text-bright);
    font-weight: 500;
}

.stat-value.mono {
    font-variant-numeric: tabular-nums;
}

#conn-status.connected {
    color: var(--green);
    text-shadow: 0 0 8px rgba(0, 255, 127, 0.3);
}

#conn-status.error {
    color: var(--red);
    text-shadow: 0 0 8px rgba(255, 68, 85, 0.3);
}

/* Legend */
.legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
}

.legend-swatch {
    width: 18px;
    height: 3px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-swatch.cyan {
    background: var(--cyan);
    box-shadow: 0 0 6px rgba(0, 200, 255, 0.4);
}

.legend-swatch.amber {
    background: var(--amber);
    box-shadow: 0 0 6px rgba(255, 165, 0, 0.4);
}

.legend-swatch.green {
    background: var(--green);
    box-shadow: 0 0 6px rgba(0, 255, 127, 0.4);
}

.legend-swatch.bright {
    background: linear-gradient(to right, var(--cyan-dim), #fff);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.3);
}

.legend-swatch.cable {
    background: none;
    border-top: 2px dashed #1a4a7a;
    height: 0;
    margin-top: 1px;
    margin-bottom: 1px;
}

.legend-swatch.ixp {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--cyan-dim);
    box-shadow: 0 0 6px rgba(0, 200, 255, 0.3);
    margin-left: 5px;
    margin-right: 5px;
}

.legend-text {
    color: var(--text);
    font-weight: 300;
}

/* Top flows */
.flow-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: 10px;
    border-bottom: 1px solid rgba(13, 26, 53, 0.6);
    animation: flow-in 0.3s ease-out both;
}

.flow-item .flow-rank {
    color: var(--text-dim);
    width: 14px;
    text-align: right;
    flex-shrink: 0;
    font-size: 9px;
    font-weight: 300;
}

.flow-item .flow-countries {
    flex: 1;
    color: var(--text);
    white-space: nowrap;
    font-weight: 300;
    font-size: 9px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flow-item .flow-countries .flow-cc {
    color: var(--text-bright);
    font-weight: 500;
    font-size: 10px;
}

.flow-item .flow-countries .arrow {
    color: var(--cyan-dim);
    margin: 0 2px;
    font-size: 9px;
}

.flow-item .flow-bar-container {
    width: 50px;
    height: 3px;
    background: rgba(13, 26, 53, 0.5);
    border-radius: 1px;
    overflow: hidden;
    flex-shrink: 0;
}

.flow-item .flow-bar {
    height: 100%;
    background: linear-gradient(to right, var(--cyan-dim), var(--cyan));
    border-radius: 1px;
    transition: width 0.6s ease;
    box-shadow: 0 0 4px rgba(0, 200, 255, 0.2);
}

.flow-item .flow-count {
    color: var(--text-dim);
    min-width: 32px;
    text-align: right;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    font-size: 9px;
    white-space: nowrap;
}

/* Event log */
.event-entry {
    font-size: 9px;
    padding: 3px 0;
    color: var(--text-dim);
    border-bottom: 1px solid rgba(13, 26, 53, 0.3);
    line-height: 1.5;
    font-weight: 300;
}

.event-entry .event-time {
    color: var(--text-dim);
    margin-right: 6px;
    opacity: 0.6;
}

.event-entry .event-text {
    color: var(--text);
}

.event-entry .as-num {
    color: var(--cyan-dim);
}

/* Panel footer */
.panel-footer {
    border-top: 1px solid var(--border-dim);
    padding-top: 12px;
}

.panel-footer p {
    font-size: 9px;
    color: var(--text-dim);
    line-height: 1.6;
    margin-bottom: 3px;
    font-weight: 300;
}

.panel-footer a {
    color: var(--cyan-dim);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.panel-footer a:hover {
    border-color: var(--cyan-dim);
}

/* ---- Bottom Status Bar ---- */

#status-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 28px;
    z-index: 20;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 0;
    background: rgba(3, 6, 16, 0.92);
    border-top: 1px solid var(--border-dim);
    font-size: 9px;
    letter-spacing: 1px;
    animation: bar-in 0.6s ease-out 1s both;
}

@keyframes bar-in {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
}

.bar-group {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
}

.bar-label {
    color: var(--text-dim);
    font-size: 8px;
    letter-spacing: 1.5px;
    font-weight: 400;
}

.bar-value {
    color: var(--text);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    font-size: 10px;
}

.bar-sep {
    width: 1px;
    height: 12px;
    background: var(--border-dim);
}

/* Country labels */
.country-label {
    font-family: var(--font-display);
    font-size: 4px;
    font-weight: 600;
    fill: var(--text-dim);
    opacity: 0.4;
    pointer-events: none;
    letter-spacing: 0.5px;
}

/* Submarine cables */
.submarine-cable {
    fill: none;
    stroke: #0d2a4a;
    stroke-width: 0.8;
    stroke-dasharray: 3, 2;
    opacity: 0.6;
    pointer-events: none;
}

/* IXP nodes */
.ixp-glow {
    fill: rgba(0, 200, 255, 0.06);
    pointer-events: none;
}

.ixp-dot {
    fill: var(--cyan-dim);
    stroke: var(--cyan);
    stroke-width: 0.3;
    opacity: 0.7;
    pointer-events: none;
}

.ixp-label {
    font-family: var(--font-mono);
    font-size: 2.5px;
    font-weight: 400;
    fill: var(--cyan-dim);
    opacity: 0.6;
    pointer-events: none;
    letter-spacing: 0.2px;
}

/* ---- Tooltip ---- */

.country-tooltip {
    position: absolute;
    background: rgba(4, 8, 20, 0.92);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 8px 12px;
    font-size: 10px;
    pointer-events: none;
    z-index: 30;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.15s;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.country-tooltip.visible {
    opacity: 1;
}

.country-tooltip .tt-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 12px;
    color: var(--text-bright);
    margin-bottom: 4px;
    letter-spacing: 1px;
}

.country-tooltip .tt-stat {
    color: var(--text-dim);
    font-size: 9px;
}

/* ---- Responsive ---- */

@media (max-width: 768px) {
    #stats-panel {
        display: none;
    }

    .hud-corner.tr,
    .hud-corner.br {
        right: 12px;
    }
}
