/* bada.systems - Cyberpunk Data-Viz Dashboard */

:root {
    --cyan: #00e5ff;
    --green: #39ff85;
    --amber: #ffab00;
    --red: #ff1744;
    --void: #020a13;
    --panel: #0a1628;
    --grid: #0a3d5c;
    --text: #b0bec5;
    --bright: #eceff1;
}

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

html {
    scroll-behavior: smooth;
    scroll-snap-type: y proximity;
}

body {
    background-color: var(--void);
    color: var(--text);
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 400;
    font-size: 15px;
    line-height: 1.75;
    overflow-x: hidden;
    min-height: 100vh;
}

/* ========================================
   SCANLINE
   ======================================== */

#scanline {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: rgba(0, 229, 255, 0.08);
    z-index: 9999;
    pointer-events: none;
    animation: scanline-sweep 8s linear infinite;
    opacity: 0;
}

@keyframes scanline-sweep {
    0% { top: 0; }
    100% { top: 100vh; }
}

/* ========================================
   HUD FRAME
   ======================================== */

#hud-frame {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    opacity: 0;
}

#hud-border {
    position: absolute;
    top: 12px;
    left: 12px;
    width: calc(100% - 24px);
    height: calc(100% - 24px);
}

.corner-bracket {
    position: absolute;
    width: 40px;
    height: 40px;
    opacity: 0;
}

.corner-bracket path {
    stroke-dasharray: 60;
    stroke-dashoffset: 60;
}

.corner-tl { top: 6px; left: 6px; }
.corner-tr { top: 6px; right: 6px; }
.corner-bl { bottom: 6px; left: 6px; }
.corner-br { bottom: 6px; right: 6px; }

.corner-bracket.animate path {
    animation: draw-bracket 600ms ease-out forwards;
}

@keyframes draw-bracket {
    to { stroke-dashoffset: 0; }
}

.corner-data {
    position: absolute;
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text);
    opacity: 0;
}

.corner-data.visible {
    opacity: 0.6;
}

.corner-data-tl { top: 18px; left: 50px; }
.corner-data-tr { top: 18px; right: 50px; }
.corner-data-bl { bottom: 18px; left: 50px; }
.corner-data-br { bottom: 18px; right: 50px; display: flex; align-items: center; gap: 6px; }

/* ========================================
   HEXAGONAL NAVIGATION
   ======================================== */

#hex-nav {
    position: fixed;
    left: 2rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 4px;
    opacity: 0;
}

.hex-node {
    width: 48px;
    height: 55px;
    position: relative;
    cursor: pointer;
    transform: scale(0);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hex-node.visible {
    transform: scale(1);
}

.hex-node svg {
    width: 100%;
    height: 100%;
}

.hex-node polygon {
    transition: fill 0.3s ease, filter 0.3s ease;
}

.hex-node:hover polygon {
    fill: rgba(0, 229, 255, 0.3);
}

.hex-node.active polygon {
    fill: rgba(0, 229, 255, 0.2);
    animation: hex-pulse 2s ease-in-out infinite;
}

@keyframes hex-pulse {
    0%, 100% { filter: drop-shadow(0 0 4px rgba(0, 229, 255, 0.3)); }
    50% { filter: drop-shadow(0 0 12px rgba(0, 229, 255, 0.6)); }
}

.hex-label {
    position: absolute;
    left: 56px;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--cyan);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.hex-node:hover .hex-label {
    opacity: 1;
}

/* Hex ping ripple */
.hex-ping {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 48px;
    height: 48px;
    border: 1px solid var(--cyan);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    opacity: 1;
    animation: hex-ping-anim 600ms ease-out forwards;
    pointer-events: none;
}

@keyframes hex-ping-anim {
    to {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* ========================================
   DASHBOARD MAIN
   ======================================== */

#dashboard {
    position: relative;
    padding: 40px 100px 40px 100px;
    z-index: 10;
}

.dashboard-section {
    scroll-snap-align: start;
    margin-bottom: 8px;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.dashboard-section.booted {
    opacity: 1;
}

.dashboard-section.shutdown {
    opacity: 0.3;
    transition: opacity 0.8s ease;
}

/* ========================================
   PANELS
   ======================================== */

.panel-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 2px;
}

.panel {
    background: var(--panel);
    border: 1px solid rgba(10, 61, 92, 0.6);
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.4s ease, transform 0.4s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.panel.booted {
    opacity: 1;
    transform: translateY(0);
}

.panel:hover {
    border-color: var(--grid);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.1);
}

.panel:hover .panel-header {
    border-left: 4px solid var(--cyan);
}

.panel-header {
    height: 32px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    background: rgba(0, 229, 255, 0);
    border-bottom: 1px solid rgba(10, 61, 92, 0.4);
    border-left: 4px solid transparent;
    transition: background-color 0.3s ease, border-left-color 0.3s ease;
}

.panel.booted .panel-header {
    background: rgba(0, 229, 255, 0.08);
}

.panel-title {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text);
}

.panel-content {
    padding: 20px;
}

/* Panel sizes */
.panel-full { grid-column: 1 / -1; }
.panel-12col { grid-column: span 12; }
.panel-8col { grid-column: span 8; }
.panel-6col { grid-column: span 6; }
.panel-4col { grid-column: span 4; }
.panel-3col { grid-column: span 3; }

/* Full topology panel */
#topology .panel-full {
    min-height: 450px;
}

#topology .panel-content {
    height: 400px;
    padding: 10px;
}

/* ========================================
   STATUS DOTS
   ======================================== */

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-connected {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
    animation: status-pulse 2s ease-in-out infinite;
}

.status-warning {
    background: var(--amber);
    box-shadow: 0 0 6px var(--amber);
    animation: status-pulse-amber 2s ease-in-out infinite;
}

.status-critical {
    background: var(--red);
    box-shadow: 0 0 6px var(--red);
    animation: status-pulse-red 1s ease-in-out infinite;
}

@keyframes status-pulse {
    0%, 100% { box-shadow: 0 0 4px var(--green); }
    50% { box-shadow: 0 0 10px var(--green); }
}

@keyframes status-pulse-amber {
    0%, 100% { box-shadow: 0 0 4px var(--amber); }
    50% { box-shadow: 0 0 10px var(--amber); }
}

@keyframes status-pulse-red {
    0%, 100% { box-shadow: 0 0 4px var(--red); }
    50% { box-shadow: 0 0 10px var(--red); }
}

/* ========================================
   TYPOGRAPHY
   ======================================== */

.section-heading {
    font-family: 'Exo 2', sans-serif;
    font-weight: 300;
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    letter-spacing: 0.06em;
    color: var(--bright);
    margin-bottom: 16px;
    line-height: 1.2;
}

.body-text {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 400;
    font-size: 15px;
    line-height: 1.75;
    color: var(--text);
    margin-bottom: 12px;
}

.cursor-blink {
    animation: blink-cursor 1060ms step-end infinite;
    color: var(--cyan);
}

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

/* ========================================
   METRICS
   ======================================== */

.metric-panel {
    text-align: center;
    padding-top: 24px;
}

.metric-value {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: 48px;
    color: var(--cyan);
    cursor: default;
    transition: color 0.2s ease;
    font-variant-numeric: tabular-nums;
}

.metric-unit {
    font-family: 'Share Tech Mono', monospace;
    font-size: 14px;
    color: var(--text);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-left: 4px;
}

.metric-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text);
    margin-top: 8px;
    opacity: 0.7;
}

.metric-subtext {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--text);
    opacity: 0.5;
    margin-top: 4px;
}

.metric-value-sm {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: 28px;
    color: var(--cyan);
    font-variant-numeric: tabular-nums;
    cursor: default;
}

.metric-label-sm {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text);
    opacity: 0.7;
    display: block;
    margin-top: 2px;
}

.metric-inline {
    margin-top: 16px;
    text-align: center;
}

.metric-value-inline {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    color: var(--cyan);
    font-variant-numeric: tabular-nums;
}

/* Metric bar */
.metric-bar {
    width: 100%;
    height: 4px;
    background: rgba(10, 61, 92, 0.6);
    border-radius: 2px;
    margin-top: 12px;
    overflow: hidden;
}

.metric-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--cyan), var(--green));
    border-radius: 2px;
    transition: width 1s ease;
}

/* ========================================
   PULSE DIVIDERS
   ======================================== */

.pulse-divider {
    height: 40px;
    margin: 4px 0;
    overflow: hidden;
}

.pulse-line {
    width: 100%;
    height: 40px;
}

/* ========================================
   REGION LIST
   ======================================== */

.region-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.region-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(10, 61, 92, 0.3);
}

.region-name {
    font-family: 'Share Tech Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.12em;
    color: var(--text);
    flex: 1;
}

.region-metric {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: 14px;
    color: var(--green);
    font-variant-numeric: tabular-nums;
}

.region-warn {
    color: var(--amber);
}

/* ========================================
   PROTOCOL LIST
   ======================================== */

.protocol-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(10, 61, 92, 0.3);
}

.protocol-name {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: 14px;
    color: var(--bright);
}

.protocol-status {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.18em;
    color: var(--green);
}

.protocol-degraded {
    color: var(--amber);
}

/* ========================================
   PACKET STATS
   ======================================== */

.packet-stats {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.packet-stat {
    text-align: center;
}

/* ========================================
   THROUGHPUT CHART
   ======================================== */

#throughput-chart {
    display: block;
    margin-bottom: 8px;
}

.chart-labels {
    display: flex;
    justify-content: space-between;
    font-family: 'Share Tech Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.18em;
    color: var(--text);
    opacity: 0.5;
}

/* ========================================
   STATUS GRID
   ======================================== */

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 8px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(10, 22, 40, 0.5);
    border: 1px solid rgba(10, 61, 92, 0.3);
}

.status-name {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 14px;
    color: var(--text);
    flex: 1;
}

.status-value {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.status-ok {
    color: var(--green);
}

.status-warn {
    color: var(--amber);
}

.status-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(10, 61, 92, 0.3);
}

.status-timestamp,
.status-uptime {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--text);
    opacity: 0.6;
}

/* ========================================
   GLITCH EFFECT
   ======================================== */

.glitch-active {
    animation: glitch 80ms linear;
}

@keyframes glitch {
    0% { transform: translate(2px, 0); filter: hue-rotate(0deg); }
    25% { transform: translate(-2px, 0); filter: hue-rotate(90deg); }
    50% { transform: translate(1px, 0); filter: hue-rotate(180deg); }
    75% { transform: translate(-1px, 0); filter: hue-rotate(270deg); }
    100% { transform: translate(0, 0); filter: hue-rotate(0deg); }
}

/* ========================================
   HEXAGONAL BACKGROUND PATTERN
   ======================================== */

.hex-bg-pattern {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='55.4'%3E%3Cpolygon points='24,1 47,14.2 47,41.2 24,54.4 1,41.2 1,14.2' fill='none' stroke='rgba(10,61,92,0.15)' stroke-width='1'/%3E%3C/svg%3E");
    background-size: 48px 55.4px;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 1024px) {
    #dashboard {
        padding: 40px 20px 40px 80px;
    }

    .panel-8col,
    .panel-6col,
    .panel-4col,
    .panel-3col {
        grid-column: span 12;
    }

    #hex-nav {
        left: 0.5rem;
    }

    .hex-node {
        width: 36px;
        height: 42px;
    }

    .metric-value {
        font-size: 36px;
    }
}

@media (max-width: 600px) {
    #dashboard {
        padding: 30px 12px 30px 12px;
    }

    #hex-nav {
        display: none;
    }

    .corner-data {
        display: none;
    }

    .section-heading {
        font-size: 1.5rem;
    }

    .metric-value {
        font-size: 28px;
    }

    .status-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   REDUCED MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    #scanline { display: none; }

    .status-connected,
    .status-warning,
    .status-critical {
        animation: none;
    }

    .hex-node.active polygon {
        animation: none;
    }

    .cursor-blink {
        animation: none;
        opacity: 1;
    }

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

    .dashboard-section {
        opacity: 1;
    }

    #hud-frame {
        opacity: 1;
    }

    .corner-bracket {
        opacity: 1;
    }

    .corner-bracket path {
        stroke-dashoffset: 0;
    }

    .corner-data {
        opacity: 0.6;
    }

    #hex-nav {
        opacity: 1;
    }

    .hex-node {
        transform: scale(1);
    }
}
