/* ============================================
   diplomatic.boo v2 — Situation Room Interface
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --abyss-black: #0A0E14;
    --cipher-green: #00E676;
    --alert-amber: #FFB300;
    --terminal-cream: #C8D6C0;
    --dossier-red: #E53935;
    --slate-charcoal: #1A2332;
    --muted-olive: #4A6741;

    --cipher-green-30: rgba(0, 230, 118, 0.30);
    --cipher-green-08: rgba(0, 230, 118, 0.08);
    --cipher-green-03: rgba(0, 230, 118, 0.03);

    --font-mono: 'Share Tech Mono', monospace;
    --font-body: 'IBM Plex Sans', sans-serif;
    --font-data: 'Orbitron', sans-serif;

    --gauge-circumference: 157;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--abyss-black);
    color: var(--terminal-cream);
    font-family: var(--font-body);
    font-size: clamp(14px, 1vw, 16px);
    line-height: 1.65;
    cursor: crosshair;
}

/* --- CRT Scanline Overlay (persistent) --- */
#crt-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 1px,
        rgba(0, 230, 118, 0.03) 1px,
        rgba(0, 230, 118, 0.03) 2px
    );
}

/* --- Boot Sequence Overlay --- */
#boot-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--abyss-black);
    z-index: 9999;
    animation: bootFadeOut 0.5s ease-out 3.5s forwards;
}

#scanline {
    position: absolute;
    top: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--alert-amber);
    opacity: 0.6;
    box-shadow: 0 0 12px rgba(255, 179, 0, 0.5), 0 0 30px rgba(255, 179, 0, 0.2);
    animation: scanSweep 2s ease-out 0.5s forwards;
}

@keyframes scanSweep {
    0% { top: -2px; opacity: 0.6; }
    100% { top: 100vh; opacity: 0.1; }
}

@keyframes bootFadeOut {
    0% { opacity: 1; pointer-events: all; }
    100% { opacity: 0; pointer-events: none; }
}

/* --- Grid Skeleton (breathing lines) --- */
#grid-skeleton {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    animation: gridAppear 0.8s ease-out 2.5s forwards, gridBreathe 6s ease-in-out 3.3s infinite;
}

/* Vertical divider at 60% mark */
#grid-skeleton::before {
    content: '';
    position: absolute;
    top: 0;
    left: 60%;
    width: 1px;
    height: 100%;
    background: var(--cipher-green-30);
}

/* Horizontal divider splitting the right column at 50% */
#grid-skeleton::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 60%;
    width: 40%;
    height: 1px;
    background: var(--cipher-green-30);
}

@keyframes gridAppear {
    0% { opacity: 0; }
    100% { opacity: 0.30; }
}

@keyframes gridBreathe {
    0%, 100% { opacity: 0.25; }
    50% { opacity: 0.35; }
}

/* --- Main Grid Layout --- */
#situation-room {
    position: relative;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: 1fr 0.67fr;
    grid-template-rows: 1fr 1fr;
    gap: 1px;
    background: var(--abyss-black);
    opacity: 0;
    animation: contentAppear 0.8s ease-out 2.8s forwards;
}

@keyframes contentAppear {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* --- Pane Base Styles --- */
.pane {
    position: relative;
    background: var(--abyss-black);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#pane-briefing {
    grid-row: 1 / -1;
    grid-column: 1;
}

#pane-status {
    grid-row: 1;
    grid-column: 2;
}

#pane-dispatch {
    grid-row: 2;
    grid-column: 2;
}

/* --- Pane Headers --- */
.pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--slate-charcoal);
    border-bottom: 1px solid var(--cipher-green-30);
    flex-shrink: 0;
}

.header-text {
    font-family: var(--font-mono);
    font-size: clamp(14px, 1.8vw, 22px);
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--cipher-green);
    min-height: 1.2em;
}

.header-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--cipher-green);
    animation: indicatorPulse 2s ease-in-out infinite;
    flex-shrink: 0;
}

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

/* --- Pane Content --- */
.pane-content {
    flex: 1;
    overflow: hidden;
    padding: 16px;
    opacity: 0;
    animation: paneContentFadeIn 0.8s ease-out 3.5s forwards;
}

#pane-briefing .pane-content {
    overflow-y: auto;
    animation-delay: 3.5s;
}

#pane-status .pane-content {
    animation-delay: 3.7s;
}

#pane-dispatch .pane-content {
    padding: 0;
    animation-delay: 3.9s;
}

@keyframes paneContentFadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* Scrollbar styling for Briefing pane */
#briefing-content::-webkit-scrollbar {
    width: 4px;
}

#briefing-content::-webkit-scrollbar-track {
    background: var(--abyss-black);
}

#briefing-content::-webkit-scrollbar-thumb {
    background: var(--cipher-green-30);
    border-radius: 2px;
}

/* --- Briefing Content --- */
.briefing-block {
    margin-bottom: 20px;
}

.briefing-title {
    font-family: var(--font-mono);
    font-size: clamp(13px, 1.5vw, 18px);
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cipher-green);
    margin: 12px 0 8px;
}

.briefing-block p {
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--terminal-cream);
    margin-bottom: 10px;
}

/* --- Classification Badges --- */
.classification-badge {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 4px 8px;
    cursor: crosshair;
    transition: box-shadow 0.2s ease, background-color 0.2s ease;
}

.badge-unclassified {
    color: var(--cipher-green);
    border: 1px solid var(--cipher-green);
}

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

.badge-flash {
    color: var(--dossier-red);
    border: 1px solid var(--dossier-red);
}

.classification-badge:hover {
    box-shadow: 0 0 8px rgba(0, 230, 118, 0.4);
    background-color: var(--cipher-green-08);
}

.badge-eyes-only:hover {
    box-shadow: 0 0 8px rgba(255, 179, 0, 0.4);
    background-color: rgba(255, 179, 0, 0.08);
}

.badge-flash:hover {
    box-shadow: 0 0 8px rgba(229, 57, 53, 0.4);
    background-color: rgba(229, 57, 53, 0.08);
}

/* --- Briefing Dividers --- */
.briefing-divider {
    display: flex;
    align-items: center;
    margin: 16px 0;
}

.divider-line {
    flex: 1;
    height: 1px;
    background: var(--cipher-green-30);
}

/* --- Redacted Text --- */
.redacted {
    background: var(--terminal-cream);
    color: var(--terminal-cream);
    padding: 0 2px;
    cursor: crosshair;
    transition: background-color 0.3s ease, color 0.3s ease;
    font-family: var(--font-body);
    user-select: none;
}

.redacted:hover {
    background: rgba(0, 230, 118, 0.15);
    color: var(--cipher-green);
}

.redacted.revealed {
    background: transparent;
    color: var(--cipher-green);
    user-select: auto;
}

/* --- SVG Gauges --- */
.gauges-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: center;
    height: 100%;
    gap: 8px;
    padding: 4px;
}

.gauge-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 100px;
    max-width: 140px;
}

.gauge-svg {
    width: 100%;
    max-width: 120px;
    height: auto;
}

.gauge-track {
    fill: none;
    stroke: var(--slate-charcoal);
    stroke-width: 3;
    stroke-linecap: round;
}

.gauge-fill {
    fill: none;
    stroke: var(--cipher-green);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: var(--gauge-circumference);
    stroke-dashoffset: var(--gauge-circumference);
    transition: stroke 0.5s ease;
}

/* Gauge 1 animation (tension ~47%, oscillates 38-62%) */
.gauge-fill-1 {
    animation: gaugeDraw1 1.5s cubic-bezier(0.4, 0, 0.2, 1) 4s forwards,
               gaugeOscillate1 10s ease-in-out 5.5s infinite;
}

/* Gauge 2 animation (compliance ~82%, oscillates 72-90%) */
.gauge-fill-2 {
    animation: gaugeDraw2 1.5s cubic-bezier(0.4, 0, 0.2, 1) 4.2s forwards,
               gaugeOscillate2 12s ease-in-out 5.7s infinite;
}

/* Gauge 3 animation (negotiations ~31%, oscillates 20-45%) */
.gauge-fill-3 {
    animation: gaugeDraw3 1.5s cubic-bezier(0.4, 0, 0.2, 1) 4.4s forwards,
               gaugeOscillate3 8s ease-in-out 5.9s infinite;
}

/* Gauge 1: tension ~47% -- dashoffset = 157 * (1 - 0.47) = 83 */
@keyframes gaugeDraw1 {
    0% { stroke-dashoffset: 157; }
    100% { stroke-dashoffset: 83; }
}
@keyframes gaugeOscillate1 {
    0%   { stroke-dashoffset: 83; stroke: var(--cipher-green); }
    25%  { stroke-dashoffset: 60; stroke: var(--alert-amber); }
    50%  { stroke-dashoffset: 97; stroke: var(--cipher-green); }
    75%  { stroke-dashoffset: 70; stroke: var(--alert-amber); }
    100% { stroke-dashoffset: 83; stroke: var(--cipher-green); }
}

/* Gauge 2: compliance ~82% -- dashoffset = 157 * (1 - 0.82) = 28 */
@keyframes gaugeDraw2 {
    0% { stroke-dashoffset: 157; }
    100% { stroke-dashoffset: 28; }
}
@keyframes gaugeOscillate2 {
    0%   { stroke-dashoffset: 28; stroke: var(--cipher-green); }
    25%  { stroke-dashoffset: 44; stroke: var(--cipher-green); }
    50%  { stroke-dashoffset: 16; stroke: var(--cipher-green); }
    75%  { stroke-dashoffset: 35; stroke: var(--cipher-green); }
    100% { stroke-dashoffset: 28; stroke: var(--cipher-green); }
}

/* Gauge 3: negotiations ~31% -- dashoffset = 157 * (1 - 0.31) = 108 */
@keyframes gaugeDraw3 {
    0% { stroke-dashoffset: 157; }
    100% { stroke-dashoffset: 108; }
}
@keyframes gaugeOscillate3 {
    0%   { stroke-dashoffset: 108; stroke: var(--cipher-green); }
    35%  { stroke-dashoffset: 86; stroke: var(--cipher-green); }
    65%  { stroke-dashoffset: 126; stroke: var(--cipher-green); }
    100% { stroke-dashoffset: 108; stroke: var(--cipher-green); }
}

.gauge-value {
    font-family: var(--font-data);
    font-weight: 700;
    font-size: clamp(20px, 3vw, 36px);
    letter-spacing: 0.08em;
    color: var(--cipher-green);
    margin-top: 4px;
    text-align: center;
    transition: color 0.5s ease;
}

.gauge-label {
    font-family: var(--font-mono);
    font-size: 8px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted-olive);
    text-align: center;
    margin-top: 2px;
}

/* --- Dispatch Log --- */
.dispatch-scroll-wrapper {
    height: 100%;
    overflow: hidden;
    position: relative;
}

.dispatch-scroll-track {
    display: flex;
    flex-direction: column;
    animation: dispatchScroll 64s linear infinite;
}

.dispatch-feed {
    padding: 12px 16px;
    flex-shrink: 0;
}

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

.dispatch-line {
    font-family: var(--font-body);
    font-size: clamp(11px, 0.9vw, 13px);
    line-height: 1.8;
    color: var(--terminal-cream);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 2px 0;
}

.dispatch-time {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted-olive);
    margin-right: 8px;
    letter-spacing: 0.05em;
}

/* --- Deep Dive Panels --- */
.deep-dive-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 50%;
    height: 100%;
    background: rgba(10, 14, 20, 0.95);
    z-index: 5000;
    transform: translateX(100%);
    transition: transform 0.4s ease-out;
    overflow-y: auto;
    border-left: 1px solid var(--cipher-green-30);
}

.deep-dive-panel.active {
    transform: translateX(0);
}

.panel-inner {
    padding: 32px 28px;
    position: relative;
}

.panel-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    background: none;
    border: 1px solid var(--cipher-green-30);
    color: var(--cipher-green);
    font-size: 20px;
    cursor: crosshair;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: var(--font-mono);
}

.panel-close:hover {
    border-color: var(--cipher-green);
    box-shadow: 0 0 8px rgba(0, 230, 118, 0.3);
}

.panel-header {
    font-family: var(--font-mono);
    font-size: clamp(14px, 1.8vw, 22px);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--cipher-green);
    margin-bottom: 12px;
}

.panel-classification {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    color: var(--muted-olive);
    margin-bottom: 20px;
}

.panel-title {
    font-family: var(--font-mono);
    font-size: clamp(13px, 1.5vw, 18px);
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cipher-green);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--cipher-green-30);
}

.panel-body p {
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--terminal-cream);
    line-height: 1.65;
    margin-bottom: 16px;
}

/* Panel scrollbar */
.deep-dive-panel::-webkit-scrollbar {
    width: 4px;
}

.deep-dive-panel::-webkit-scrollbar-track {
    background: var(--abyss-black);
}

.deep-dive-panel::-webkit-scrollbar-thumb {
    background: var(--cipher-green-30);
    border-radius: 2px;
}

/* --- Desktop Navigation (top-right corner) --- */
#desktop-nav {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 4000;
    display: flex;
    gap: 4px;
    opacity: 0;
    animation: paneContentFadeIn 0.5s ease-out 4s forwards;
}

.nav-btn-desktop {
    width: 24px;
    height: 24px;
    background: var(--slate-charcoal);
    border: 1px solid var(--cipher-green-30);
    color: var(--cipher-green);
    font-family: var(--font-mono);
    font-size: 8px;
    letter-spacing: 0.05em;
    cursor: crosshair;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.nav-btn-desktop:hover {
    border-color: var(--cipher-green);
    box-shadow: 0 0 8px rgba(0, 230, 118, 0.3);
}

.nav-btn-desktop.active {
    background: rgba(0, 230, 118, 0.15);
    border-color: var(--cipher-green);
}

/* --- Mobile Navigation --- */
#mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 4000;
    background: var(--slate-charcoal);
    border-top: 1px solid var(--cipher-green-30);
    padding: 8px 0;
    justify-content: space-around;
}

.nav-btn {
    background: none;
    border: 1px solid var(--cipher-green-30);
    color: var(--cipher-green);
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    padding: 6px 14px;
    cursor: crosshair;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.nav-btn.active {
    background: rgba(0, 230, 118, 0.15);
    border-color: var(--cipher-green);
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    #situation-room {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
        height: calc(100% - 50px);
    }

    #mobile-nav {
        display: flex;
    }

    #desktop-nav {
        display: none;
    }

    #grid-skeleton::before,
    #grid-skeleton::after {
        display: none;
    }

    .pane {
        grid-row: 1;
        grid-column: 1;
        display: none;
    }

    .pane.mobile-active {
        display: flex;
    }

    /* Show all panes by default (ALL mode) */
    #situation-room.show-all {
        grid-template-rows: 1fr 1fr 1fr;
    }

    #situation-room.show-all .pane {
        display: flex;
    }

    #situation-room.show-all #pane-briefing {
        grid-row: 1;
    }

    #situation-room.show-all #pane-status {
        grid-row: 2;
    }

    #situation-room.show-all #pane-dispatch {
        grid-row: 3;
    }

    .deep-dive-panel {
        width: 100%;
    }

    .gauges-container {
        flex-direction: row;
        gap: 4px;
    }

    .gauge-wrapper {
        min-width: 80px;
    }
}

/* --- Selection color --- */
::selection {
    background: rgba(0, 230, 118, 0.3);
    color: var(--terminal-cream);
}
