/* =========================================================
   aiice.io - Generative Intelligence Observatory
   ========================================================= */

/* --- Custom Properties --- */
:root {
    --bg-void: #0a0a12;
    --bg-midnight: #0d1b2a;
    --accent-cyan: #00f0ff;
    --accent-magenta: #ff00e5;
    --accent-green: #39ff14;
    --accent-amber: #ffb800;
    --text-silver: #c8d6e5;
    --text-ghost: #e8f0fe;
    --bg-violet: #1a0033;
    --panel-bg: rgba(10, 10, 18, 0.85);

    --font-display: 'Orbitron', sans-serif;
    --font-body: 'IBM Plex Mono', monospace;
    --font-accent: 'Share Tech Mono', monospace;

    --top-bar-h: 64px;
    --left-gutter-w: 48px;
    --right-strip-w: 200px;
    --bottom-bar-h: 32px;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    background: var(--bg-void);
    color: var(--text-silver);
    font-family: var(--font-body);
    font-size: clamp(0.8rem, 1.2vw, 0.95rem);
    line-height: 1.7;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    display: none;
}

/* --- Grid Overlay --- */
#gridOverlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
    pointer-events: none;
    background:
        repeating-linear-gradient(0deg, transparent, transparent 39.5px, rgba(0, 240, 255, 0.03) 39.5px, rgba(0, 240, 255, 0.03) 40px),
        repeating-linear-gradient(90deg, transparent, transparent 39.5px, rgba(0, 240, 255, 0.03) 39.5px, rgba(0, 240, 255, 0.03) 40px);
}

/* --- Generative Canvas --- */
#generativeCanvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    background: var(--bg-void);
}

/* --- Scan Line --- */
#scanLine {
    position: fixed;
    top: -2px;
    left: 0;
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    z-index: 50;
    pointer-events: none;
    animation: scan 8s linear infinite;
}

@keyframes scan {
    from { top: -2px; }
    to { top: 100%; }
}

/* =========================================================
   HUD Frame (Layer 1)
   ========================================================= */

/* --- Top Bar --- */
#hudTopBar {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    height: var(--top-bar-h);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid rgba(0, 240, 255, 0.3);
    background: rgba(10, 10, 18, 0.9);
}

.top-bar-left {
    display: flex;
    align-items: center;
}

.logotype {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 700;
    color: var(--accent-cyan);
    text-shadow: 0 0 8px var(--accent-cyan), 0 0 24px rgba(0, 240, 255, 0.15);
    display: inline-flex;
}

.logotype .logo-char {
    display: inline-block;
    animation: breathe 3s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% { opacity: 0.6; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-2px); }
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.system-clock {
    font-family: var(--font-accent);
    font-size: 14px;
    color: var(--text-ghost);
    letter-spacing: 0.08em;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-green {
    background: var(--accent-green);
    box-shadow: 0 0 6px var(--accent-green), 0 0 12px rgba(57, 255, 20, 0.3);
    animation: pulse-green 2s ease-in-out infinite;
}

@keyframes pulse-green {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.status-amber {
    background: var(--accent-amber);
    box-shadow: 0 0 6px var(--accent-amber), 0 0 12px rgba(255, 184, 0, 0.3);
}

.status-cyan {
    background: var(--accent-cyan);
    box-shadow: 0 0 6px var(--accent-cyan), 0 0 12px rgba(0, 240, 255, 0.3);
    animation: blink-cyan 1.5s step-end infinite;
}

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

/* --- Left Gutter --- */
#hudLeftGutter {
    position: fixed;
    top: var(--top-bar-h);
    left: 0;
    width: var(--left-gutter-w);
    height: calc(100vh - var(--top-bar-h) - var(--bottom-bar-h));
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    border-right: 1px solid rgba(0, 240, 255, 0.2);
    background: rgba(10, 10, 18, 0.7);
}

.gutter-label {
    font-family: var(--font-accent);
    font-size: 11px;
    color: var(--text-silver);
    letter-spacing: 0.15em;
    writing-mode: vertical-lr;
    transform: rotate(180deg);
    cursor: pointer;
    border: none;
    background: none;
    padding: 8px 4px;
    transition: color 0.3s, text-shadow 0.3s;
    opacity: 0.5;
}

.gutter-label:hover {
    color: var(--accent-cyan);
    opacity: 0.8;
}

.gutter-label.active {
    color: var(--accent-cyan);
    text-shadow: 0 0 8px var(--accent-cyan);
    opacity: 1;
}

/* --- Right Telemetry Strip --- */
#hudRightTelemetry {
    position: fixed;
    top: var(--top-bar-h);
    right: 0;
    width: var(--right-strip-w);
    height: calc(100vh - var(--top-bar-h) - var(--bottom-bar-h));
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 32px;
    padding: 20px 16px;
    border-left: 1px solid rgba(255, 0, 229, 0.15);
    background: rgba(10, 10, 18, 0.7);
}

.telemetry-metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric-label {
    font-family: var(--font-accent);
    font-size: 10px;
    color: var(--accent-magenta);
    letter-spacing: 0.15em;
    opacity: 0.7;
}

.metric-value {
    font-family: var(--font-accent);
    font-size: 11px;
    color: var(--text-ghost);
    letter-spacing: 0.05em;
    position: relative;
    overflow: hidden;
    height: 1.4em;
}

.metric-value .digit-old,
.metric-value .digit-new {
    display: block;
    transition: transform 0.3s ease-out;
}

.metric-value .digit-old {
    transform: translateY(-100%);
}

/* --- Bottom Status Bar --- */
#hudBottomBar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--bottom-bar-h);
    z-index: 10;
    display: flex;
    align-items: center;
    overflow: hidden;
    border-top: 1px solid rgba(57, 255, 20, 0.25);
    background: rgba(10, 10, 18, 0.9);
    padding: 0 16px;
}

.log-stream {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    overflow: hidden;
    position: relative;
}

.log-message {
    font-family: var(--font-accent);
    font-size: 11px;
    color: var(--accent-green);
    white-space: nowrap;
    position: absolute;
    animation: slideLog 8s linear forwards;
    opacity: 0.8;
}

@keyframes slideLog {
    0% { transform: translateX(100vw); opacity: 0.8; }
    80% { opacity: 0.8; }
    100% { transform: translateX(-100%); opacity: 0; }
}

/* --- Mobile Nav Dots --- */
#mobileNavDots {
    display: none;
    position: fixed;
    bottom: 44px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    gap: 12px;
}

.nav-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-silver);
    opacity: 0.3;
    cursor: pointer;
    transition: opacity 0.3s, box-shadow 0.3s;
}

.nav-dot.active {
    opacity: 1;
    background: var(--accent-cyan);
    box-shadow: 0 0 8px var(--accent-cyan);
}

/* =========================================================
   Content Area (Layer 2)
   ========================================================= */

#contentArea {
    position: fixed;
    top: var(--top-bar-h);
    left: var(--left-gutter-w);
    right: var(--right-strip-w);
    bottom: var(--bottom-bar-h);
    z-index: 20;
    overflow: hidden;
}

.screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    display: none;
    padding: 24px;
    gap: 16px;
}

.screen--active {
    display: grid;
}

/* Screen 0: Single centered panel */
.screen[data-screen="0"] {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    place-items: center;
}

.screen[data-screen="0"] .panel-primary {
    width: 70%;
    max-height: 65%;
    overflow-y: auto;
    scrollbar-width: none;
}

.screen[data-screen="0"] .panel-primary::-webkit-scrollbar {
    display: none;
}

/* Screen 1: Two panel layout */
.screen[data-screen="1"] {
    grid-template-columns: 55% 1fr;
    grid-template-rows: 1fr;
    align-items: center;
}

/* Screen 2: Three panel layout */
.screen[data-screen="2"] {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 38% 1fr;
}

.screen[data-screen="2"] .panel-wide {
    grid-column: 1 / -1;
}

/* Screen 3: Single terminal panel */
.screen[data-screen="3"] {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    place-items: center;
}

.screen[data-screen="3"] .panel-terminal {
    width: 65%;
    max-height: 85%;
    overflow-y: auto;
    scrollbar-width: none;
}

.screen[data-screen="3"] .panel-terminal::-webkit-scrollbar {
    display: none;
}

/* =========================================================
   Panel Styling
   ========================================================= */

.panel {
    position: relative;
    background: var(--panel-bg);
    clip-path: polygon(12px 0, calc(100% - 12px) 0, 100% 12px, 100% calc(100% - 12px), calc(100% - 12px) 100%, 12px 100%, 0 calc(100% - 12px), 0 12px);
    padding: 24px;
    border: 1px solid rgba(0, 240, 255, 0.0);
    overflow: hidden;
}

.panel::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    clip-path: polygon(12px 0, calc(100% - 12px) 0, 100% 12px, 100% calc(100% - 12px), calc(100% - 12px) 100%, 12px 100%, 0 calc(100% - 12px), 0 12px);
    border: 1px solid var(--panel-accent, var(--accent-cyan));
    opacity: 0.4;
    pointer-events: none;
    z-index: 1;
}

.panel-top-accent {
    position: absolute;
    top: 0;
    left: 12px;
    right: 12px;
    height: 4px;
    background: var(--panel-accent, var(--accent-cyan));
    box-shadow: 0 0 12px var(--panel-accent, var(--accent-cyan));
    opacity: 0.8;
    z-index: 2;
}

/* Corner Brackets */
.panel-corner {
    position: absolute;
    width: 16px;
    height: 16px;
    z-index: 2;
    pointer-events: none;
}

.panel-corner--tl {
    top: 4px;
    left: 4px;
    border-top: 2px solid var(--panel-accent, var(--accent-cyan));
    border-left: 2px solid var(--panel-accent, var(--accent-cyan));
}

.panel-corner--br {
    bottom: 4px;
    right: 4px;
    border-bottom: 2px solid var(--panel-accent, var(--accent-cyan));
    border-right: 2px solid var(--panel-accent, var(--accent-cyan));
}

/* Hex Coordinates */
.hex-coord {
    position: absolute;
    font-family: var(--font-accent);
    font-size: 9px;
    opacity: 0.25;
    color: var(--text-silver);
    z-index: 2;
    pointer-events: none;
}

.hex-coord--tl {
    top: 8px;
    left: 24px;
}

.hex-coord--br {
    bottom: 8px;
    right: 24px;
}

/* =========================================================
   Panel Content
   ========================================================= */

.panel-heading {
    font-family: var(--font-display);
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    font-weight: 400;
    color: var(--text-ghost);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    text-shadow: 0 0 8px currentColor;
    margin-bottom: 16px;
    position: relative;
    z-index: 3;
}

.panel-heading .heading-char {
    display: inline-block;
    opacity: 0;
    transform: translateY(6px);
}

.panel-heading .heading-char.revealed {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}

.panel-body {
    color: var(--text-silver);
    margin-bottom: 12px;
    position: relative;
    z-index: 3;
}

.panel-body.mono-accent {
    color: var(--accent-green);
    font-family: var(--font-accent);
    font-size: 12px;
    text-shadow: 0 0 8px rgba(57, 255, 20, 0.3);
}

/* ASCII Divider */
.ascii-divider {
    font-family: var(--font-accent);
    font-size: 12px;
    color: var(--panel-accent, var(--accent-cyan));
    opacity: 0.4;
    margin: 14px 0;
    text-align: center;
    position: relative;
    z-index: 3;
}

/* Signal Bars */
.signal-bars {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 60px;
    margin: 12px 0;
    position: relative;
    z-index: 3;
}

.signal-bars .bar {
    width: 4px;
    background: var(--panel-accent, var(--accent-cyan));
    border-radius: 1px;
    box-shadow: 0 0 6px var(--panel-accent, var(--accent-cyan));
    animation: barPulse 1.5s ease-in-out infinite alternate;
}

.signal-bars .bar:nth-child(1) { height: 25px; animation-delay: 0s; }
.signal-bars .bar:nth-child(2) { height: 40px; animation-delay: 0.2s; }
.signal-bars .bar:nth-child(3) { height: 55px; animation-delay: 0.4s; }
.signal-bars .bar:nth-child(4) { height: 35px; animation-delay: 0.6s; }
.signal-bars .bar:nth-child(5) { height: 50px; animation-delay: 0.8s; }
.signal-bars .bar:nth-child(6) { height: 30px; animation-delay: 1.0s; }
.signal-bars .bar:nth-child(7) { height: 45px; animation-delay: 1.2s; }
.signal-bars .bar:nth-child(8) { height: 20px; animation-delay: 1.4s; }

@keyframes barPulse {
    0% { transform: scaleY(0.6); opacity: 0.5; }
    100% { transform: scaleY(1); opacity: 1; }
}

/* =========================================================
   Neural Network (Screen 1)
   ========================================================= */

.neural-network {
    position: relative;
    width: 100%;
    height: 200px;
    margin-top: 16px;
}

.nn-connections {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
}

.nn-connections line {
    stroke: var(--accent-cyan);
    stroke-width: 1;
    stroke-dasharray: 4 4;
    opacity: 0.4;
    animation: dashMove 2s linear infinite;
}

@keyframes dashMove {
    to { stroke-dashoffset: -16; }
}

.nn-node {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--accent-cyan);
    background: transparent;
    box-shadow: 0 0 6px var(--accent-cyan), 0 0 12px rgba(0, 240, 255, 0.2);
    z-index: 2;
    animation: nodePulse 3s ease-in-out infinite alternate;
}

.nn-node-1 { top: 10%; left: 15%; animation-delay: 0s; }
.nn-node-2 { top: 30%; left: 45%; animation-delay: 0.3s; }
.nn-node-3 { top: 60%; left: 25%; animation-delay: 0.6s; }
.nn-node-4 { top: 15%; left: 75%; animation-delay: 0.9s; }
.nn-node-5 { top: 50%; left: 65%; animation-delay: 1.2s; }
.nn-node-6 { top: 80%; left: 50%; animation-delay: 1.5s; }
.nn-node-7 { top: 40%; left: 10%; animation-delay: 1.8s; }
.nn-node-8 { top: 70%; left: 80%; animation-delay: 2.1s; }
.nn-node-9 { top: 20%; left: 55%; animation-delay: 2.4s; }

@keyframes nodePulse {
    0% { box-shadow: 0 0 4px var(--accent-cyan), 0 0 8px rgba(0, 240, 255, 0.15); }
    100% { box-shadow: 0 0 8px var(--accent-cyan), 0 0 20px rgba(0, 240, 255, 0.35); }
}

/* =========================================================
   Waveform (Screen 2)
   ========================================================= */

.waveform-container {
    width: 100%;
    height: 80px;
    margin-top: 8px;
    position: relative;
}

#waveformCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* =========================================================
   Terminal (Screen 3)
   ========================================================= */

.terminal-window {
    font-family: var(--font-body);
    font-size: clamp(0.75rem, 1.1vw, 0.9rem);
    line-height: 1.8;
    position: relative;
    z-index: 3;
}

.terminal-line {
    margin-bottom: 2px;
}

.terminal-prompt {
    color: var(--accent-green);
    text-shadow: 0 0 8px rgba(57, 255, 20, 0.3);
}

.terminal-cmd {
    color: var(--text-ghost);
}

.terminal-response {
    color: var(--accent-green);
    opacity: 0.8;
    padding-left: 1.5em;
}

.terminal-cursor {
    color: var(--accent-green);
    animation: cursorBlink 1s step-end infinite;
}

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

/* =========================================================
   Panel Transitions
   ========================================================= */

.panel--entering {
    opacity: 0;
    transform: translateY(12px);
}

.panel--active {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.panel--exiting {
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.3s ease-in, transform 0.3s ease-in;
}

/* =========================================================
   Mobile (< 768px)
   ========================================================= */

@media (max-width: 768px) {
    :root {
        --left-gutter-w: 0px;
        --right-strip-w: 0px;
        --bottom-bar-h: 48px;
    }

    #hudLeftGutter {
        display: none;
    }

    #hudRightTelemetry {
        display: none;
    }

    #mobileNavDots {
        display: flex;
    }

    #contentArea {
        left: 0;
        right: 0;
        padding: 8px;
    }

    .screen {
        padding: 12px;
    }

    .screen[data-screen="0"] .panel-primary {
        width: 95%;
        max-height: 80%;
    }

    .screen[data-screen="1"] {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
    }

    .screen[data-screen="2"] {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }

    .screen[data-screen="2"] .panel-wide {
        grid-column: 1;
    }

    .screen[data-screen="3"] .panel-terminal {
        width: 95%;
        max-height: 80%;
    }

    .panel-heading {
        font-size: clamp(1rem, 4vw, 1.4rem);
    }

    #hudBottomBar {
        height: var(--bottom-bar-h);
    }
}
