/* ============================================
   supplychain.watch — Surveillance Grid Styles
   ============================================ */

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0D0A05;
    color: #C4B89A;
    font-family: 'Inter', sans-serif;
}

/* --- Typography Classes --- */
.panel-label {
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    font-size: clamp(0.75rem, 1.5vw, 1.1rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #FF8C00;
}

.panel-timestamp {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(0.65rem, 1.2vw, 0.9rem);
    letter-spacing: 0.04em;
    color: #E67300;
}

.mono-data {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(0.65rem, 1.2vw, 0.9rem);
    letter-spacing: 0.04em;
    color: #FFB347;
}

.narrative-text {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
    line-height: 1.7;
    color: #C4B89A;
}

/* --- Alert Banner --- */
#alert-banner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 48px;
    background: #1A0F05;
    border-bottom: 1px solid #5C4A1E;
    overflow: hidden;
    z-index: 100;
    display: flex;
    align-items: center;
}

#ticker-track {
    display: flex;
    white-space: nowrap;
    animation: tickerScroll 60s linear infinite;
}

.ticker-content {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(0.65rem, 1.2vw, 0.9rem);
    letter-spacing: 0.04em;
    color: #FF8C00;
    padding-right: 2rem;
}

@keyframes tickerScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* --- Grid Overlay --- */
#grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    background-image:
        linear-gradient(rgba(255,140,0,0.06) 0.5px, transparent 0.5px),
        linear-gradient(90deg, rgba(255,140,0,0.06) 0.5px, transparent 0.5px);
    background-size: 40px 40px;
}

/* --- Surveillance Grid Layout --- */
#surveillance-grid {
    position: fixed;
    top: 48px;
    left: 0;
    width: 100%;
    height: calc(100vh - 48px);
    display: grid;
    grid-template-columns: 60fr 40fr;
    grid-template-rows: 35fr 25fr 20fr 20fr;
    gap: 0;
}

/* --- Panel Base --- */
.panel {
    position: relative;
    background: #1A1408;
    overflow: hidden;
    cursor: pointer;
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.panel-border {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 1px solid #5C4A1E;
    pointer-events: none;
    z-index: 5;
}

.panel-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(92, 74, 30, 0.4);
    z-index: 3;
}

.panel-content {
    position: relative;
    padding: 16px;
    height: calc(100% - 44px);
    overflow: hidden;
    z-index: 3;
}

.panel-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: 1px solid #5C4A1E;
    color: #FF8C00;
    font-family: 'DM Sans', sans-serif;
    font-size: 1.4rem;
    width: 32px;
    height: 32px;
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.panel-close:hover {
    background: rgba(255, 140, 0, 0.15);
}

/* --- Scan Line --- */
.scanline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(255,140,0,0.15), transparent);
    z-index: 4;
    animation: scanlineMove 8s linear infinite;
    pointer-events: none;
}

@keyframes scanlineMove {
    0% { top: 0; }
    100% { top: 100%; }
}

/* --- CRT Scan-Line Texture Overlay --- */
.panel::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.03) 0px,
        rgba(0, 0, 0, 0.03) 2px,
        transparent 2px,
        transparent 4px
    );
    animation: crtDrift 4s linear infinite;
}

@keyframes crtDrift {
    0% { transform: translateY(0); }
    100% { transform: translateY(4px); }
}

/* --- CRT Boot Animation --- */
.crt-boot {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0D0A05;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.crt-boot.booted {
    opacity: 0;
    pointer-events: none;
}

.crt-line {
    width: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5), 0 0 20px rgba(255, 140, 0, 0.3);
    transition: width 0.4s ease-out;
}

.crt-boot.booting .crt-line {
    width: 100%;
}

/* --- Primary Panel --- */
.panel-primary {
    grid-row: 1 / -1;
    grid-column: 1;
}

.panel-primary .panel-content {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #5C4A1E #1A1408;
}

/* --- Crosshair --- */
.crosshair {
    position: relative;
    width: 28px;
    height: 28px;
    margin-right: 12px;
    flex-shrink: 0;
    animation: crosshairPulse 4s ease-in-out infinite;
}

@keyframes crosshairPulse {
    0%, 100% { transform: scale(0.98); }
    50% { transform: scale(1.02); }
}

.crosshair-h {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    background: #FF8C00;
    transform: translateY(-50%);
}

.crosshair-v {
    position: absolute;
    top: 0;
    left: 50%;
    width: 1px;
    height: 100%;
    background: #FF8C00;
    transform: translateX(-50%);
}

.crosshair-bracket {
    position: absolute;
    width: 6px;
    height: 6px;
    border-color: #FF8C00;
    border-style: solid;
}

.crosshair-bracket.tl { top: 0; left: 0; border-width: 1px 0 0 1px; }
.crosshair-bracket.tr { top: 0; right: 0; border-width: 1px 1px 0 0; }
.crosshair-bracket.bl { bottom: 0; left: 0; border-width: 0 0 1px 1px; }
.crosshair-bracket.br { bottom: 0; right: 0; border-width: 0 1px 1px 0; }

/* --- Hero Content --- */
#hero-title {
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(2rem, 4vw, 4rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #FF8C00;
    margin-bottom: 12px;
}

.hero-subtitle {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(0.75rem, 1.5vw, 1rem);
    color: #E67300;
    letter-spacing: 0.04em;
    margin-bottom: 28px;
    min-height: 1.4em;
}

.narrative-block {
    margin-bottom: 28px;
}

.narrative-text {
    margin-bottom: 16px;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.narrative-text.visible {
    opacity: 1;
}

/* --- Status Row --- */
.status-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(92, 74, 30, 0.4);
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-label {
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #C4B89A;
}

.status-value {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    color: #FFB347;
}

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

.status-dot.normal {
    background: #4A7C3F;
    box-shadow: 0 0 6px rgba(74, 124, 63, 0.6);
    animation: dotPulseNormal 3s ease-in-out infinite;
}

.status-dot.alert {
    background: #FF4500;
    box-shadow: 0 0 8px rgba(255, 69, 0, 0.7);
    animation: dotPulseAlert 2s ease-in-out infinite;
}

.status-dot.warning {
    background: #E67300;
    box-shadow: 0 0 7px rgba(230, 115, 0, 0.6);
    animation: dotPulseWarning 2.5s ease-in-out infinite;
}

@keyframes dotPulseNormal {
    0%, 100% { box-shadow: 0 0 4px rgba(74, 124, 63, 0.4); }
    50% { box-shadow: 0 0 10px rgba(74, 124, 63, 0.8); }
}

@keyframes dotPulseAlert {
    0%, 100% { box-shadow: 0 0 4px rgba(255, 69, 0, 0.4); }
    50% { box-shadow: 0 0 12px rgba(255, 69, 0, 0.9); }
}

@keyframes dotPulseWarning {
    0%, 100% { box-shadow: 0 0 4px rgba(230, 115, 0, 0.4); }
    50% { box-shadow: 0 0 10px rgba(230, 115, 0, 0.8); }
}

/* --- Auxiliary Panels Grid Placement --- */
.panel-aux-1 { grid-row: 1; grid-column: 2; }
.panel-aux-2 { grid-row: 2; grid-column: 2; }
.panel-aux-3 { grid-row: 3; grid-column: 2; }
.panel-aux-4 { grid-row: 4; grid-column: 2; }

/* --- Radar Panel --- */
.radar-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: calc(100% - 44px);
}

.radar-container {
    position: relative;
    width: min(200px, 80%);
    height: 0;
    padding-bottom: min(200px, 80%);
    border-radius: 50%;
    overflow: hidden;
    background: radial-gradient(circle, rgba(26, 20, 8, 1) 0%, rgba(13, 10, 5, 1) 100%);
}

.radar-circle {
    position: absolute;
    border: 1px solid rgba(92, 74, 30, 0.4);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    height: 90%;
}

.radar-circle-2 {
    width: 60%;
    height: 60%;
}

.radar-circle-3 {
    width: 30%;
    height: 30%;
}

.radar-sweep-arm {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50%;
    height: 2px;
    transform-origin: 0 50%;
    background: linear-gradient(90deg, rgba(255,140,0,0.8), transparent);
    animation: radarSweep 12s linear infinite;
    z-index: 2;
}

.radar-sweep-arm::before {
    content: '';
    position: absolute;
    top: -60px;
    left: 0;
    width: 100%;
    height: 120px;
    transform-origin: 0 50%;
    background: conic-gradient(
        from -30deg,
        transparent 0deg,
        rgba(255,140,0,0.12) 30deg,
        transparent 60deg
    );
}

@keyframes radarSweep {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.radar-blip {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #FF8C00;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(255, 140, 0, 0.8);
    animation: blipFade 4s ease-in-out infinite;
    z-index: 1;
}

.radar-blip:nth-child(5) { animation-delay: 1s; }
.radar-blip:nth-child(6) { animation-delay: 2s; }
.radar-blip:nth-child(7) { animation-delay: 0.5s; }
.radar-blip:nth-child(8) { animation-delay: 3s; }

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

.radar-crosshair-h,
.radar-crosshair-v {
    position: absolute;
    background: rgba(92, 74, 30, 0.3);
}

.radar-crosshair-h {
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    transform: translateY(-50%);
}

.radar-crosshair-v {
    left: 50%;
    top: 0;
    width: 1px;
    height: 100%;
    transform: translateX(-50%);
}

.radar-readout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-top: 12px;
}

/* --- Route Map Panel --- */
.routes-content {
    display: flex;
    align-items: center;
    justify-content: center;
}

#route-map {
    width: 100%;
    height: 100%;
}

.continent {
    fill: none;
    stroke: #3D3520;
    stroke-width: 1;
}

.trade-route {
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
}

.route-active {
    stroke: #FF8C00;
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    animation: drawRoute 6s ease-in-out infinite;
}

.route-dormant {
    stroke: #3D3520;
    stroke-dasharray: 4 4;
}

#route-2 { animation-delay: 1.5s; }
#route-3 { animation-delay: 3s; }
#route-5 { animation-delay: 4.5s; }

@keyframes drawRoute {
    0% { stroke-dashoffset: 500; }
    50% { stroke-dashoffset: 0; }
    60% { stroke-dashoffset: 0; stroke: #FFB347; }
    70% { stroke-dashoffset: 0; stroke: #FF8C00; }
    100% { stroke-dashoffset: 500; }
}

.route-node {
    fill: #FF8C00;
    animation: nodePulse 3s ease-in-out infinite;
}

.route-node:nth-child(7) { animation-delay: 0.5s; }
.route-node:nth-child(8) { animation-delay: 1s; }
.route-node:nth-child(9) { animation-delay: 1.5s; }
.route-node:nth-child(10) { animation-delay: 2s; }

@keyframes nodePulse {
    0%, 100% { r: 3; opacity: 0.6; }
    50% { r: 5; opacity: 1; }
}

.cargo-icon {
    fill: none;
    stroke: #5C4A1E;
    stroke-width: 1;
}

/* --- Node Status Panel --- */
.status-grid-content {
    overflow-y: auto;
}

.node-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.node-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: rgba(13, 10, 5, 0.6);
    border: 1px solid rgba(92, 74, 30, 0.2);
}

.node-name {
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #C4B89A;
    flex-shrink: 0;
}

.node-val {
    font-size: 0.6rem;
    margin-left: auto;
}

/* --- Data Cascade Panel --- */
.data-cascade-content {
    position: relative;
    overflow: hidden;
}

#data-cascade {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    color: #3D3520;
    line-height: 1.6;
    animation: cascadeScroll 30s linear infinite;
    white-space: pre-wrap;
    word-break: break-all;
}

@keyframes cascadeScroll {
    0% { transform: translateY(0); }
    100% { transform: translateY(-50%); }
}

/* --- Panel Expansion --- */
.panel.expanded {
    position: fixed;
    top: 48px;
    left: 0;
    width: 100vw;
    height: calc(100vh - 48px);
    z-index: 80;
    transform: none;
    cursor: default;
}

.panel.expanded .panel-close {
    display: flex !important;
}

.panel.expanded .panel-content {
    height: calc(100% - 60px);
    overflow-y: auto;
}

.panel.dimmed {
    opacity: 0.2;
    pointer-events: none;
}

#panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 10, 5, 0.85);
    z-index: 70;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

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

/* --- Mobile Layout --- */
@media (max-width: 768px) {
    #surveillance-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        overflow-y: auto;
    }

    .panel-primary {
        grid-row: auto;
        grid-column: 1;
        min-height: 60vh;
    }

    .panel-aux-1,
    .panel-aux-2,
    .panel-aux-3,
    .panel-aux-4 {
        grid-row: auto;
        grid-column: 1;
        min-height: 40vh;
    }

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

    .status-row {
        flex-direction: column;
        gap: 12px;
    }
}
