/* Stealth Operator + Blueprint + Darkroom CSS */

:root {
    /* 1. Brand Concept & Colors */
    --bg-0: #0a0a0a;       /* Near-black (main background) */
    --bg-1: #141414;       /* Charcoal (secondary background) */
    --surface-0: #1a1a1a;  /* Deep slate (cards/panels) */
    --surface-1: #222222;  /* Lighter slate (active/hover panels) */
    --border-0: #333333;   /* Subtle gray border (thin) */
    --border-highlight: #444444;

    /* Accents */
    --accent-cyan: #00f0ff;        /* Bright but controlled cyan */
    --accent-cyan-muted: #007a82;  /* Softer cyan for secondary states */
    --accent-amber: #ffaa00;       /* Warm accent (only for darkroom/vision) */
    
    /* Semantic Status (Operator) */
    --status-success: #00ff41;
    --status-warning: #ffaa00;
    --status-error: #ff3333;

    /* Typography */
    --font-heading: 'Inter', system-ui, -apple-system, sans-serif; /* Confident sans */
    --font-body: 'Inter', system-ui, -apple-system, sans-serif;    /* Readable sans */
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;         /* Data ink only */

    /* Spacing & Layout */
    --grid-unit: 8px;
    --border-radius-lg: 12px;
    --border-radius-md: 8px;
    --border-radius-sm: 4px;
}

/* 3. Texture & Background Stack */
body {
    background-color: var(--bg-0);
    color: #e0e0e0;
    font-family: var(--font-body);
    margin: 0;
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

/* Film Grain Overlay */
body::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='1'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
    z-index: 9999;
}

/* Blueprint Grid Overlay (Faint) */
.blueprint-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: 40px 40px;
    background-image: linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
                      linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    pointer-events: none;
    z-index: -1;
}

/* 4. Typography System */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: -0.02em; /* Slightly tight tracking */
    color: white;
}

.font-mono {
    font-family: var(--font-mono);
}

.text-cyan {
    color: var(--accent-cyan);
}

.text-muted {
    color: #888;
}

/* 8. Core Components */

/* Project Panel Card */
.card-project {
    background-color: var(--surface-0);
    border: 1px solid var(--border-0);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.card-project:hover {
    transform: translateY(-4px);
    border-color: var(--accent-cyan-muted);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.1);
}

.card-project::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: var(--border-radius-lg);
    box-shadow: inset 0 0 0 1px transparent;
    transition: box-shadow 0.3s ease;
    pointer-events: none;
}

.card-project:hover::before {
    box-shadow: inset 0 0 0 1px rgba(0, 240, 255, 0.1);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.status-dot.stable { background-color: var(--status-success); box-shadow: 0 0 5px var(--status-success); }
.status-dot.prototype { background-color: var(--accent-amber); box-shadow: 0 0 5px var(--accent-amber); }
.status-dot.wip { background-color: var(--accent-cyan); box-shadow: 0 0 5px var(--accent-cyan); }

/* Architecture Strip */
.architecture-strip {
    height: 60px;
    background: rgba(10, 10, 10, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-0);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.arch-flow {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: #666;
}

.arch-node {
    padding: 2px 6px;
    border: 1px solid transparent;
    border-radius: 4px;
    transition: all 0.2s;
}

.arch-node:hover {
    color: var(--accent-cyan);
    border-color: var(--accent-cyan-muted);
    background: rgba(0, 240, 255, 0.05);
}

.arch-arrow { color: #444; }

/* Runbook Drawer */
.runbook-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background: var(--bg-1);
    border-left: 1px solid var(--border-0);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1001;
    display: flex;
    flex-direction: column;
}

.runbook-drawer.open {
    transform: translateX(0);
}

.runbook-toggle {
    background: transparent;
    border: 1px solid var(--accent-cyan-muted);
    color: var(--accent-cyan);
    font-family: var(--font-mono);
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.8rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.runbook-toggle:hover {
    background: rgba(0, 240, 255, 0.1);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

/* Blueprint Hero Map */
.hero-map-container {
    height: 80vh;
    width: 100%;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#blueprint-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.hero-overlay {
    position: relative;
    z-index: 10;
    text-align: center;
    pointer-events: none; /* Let clicks pass through to canvas */
}

.hero-title {
    font-size: 4rem;
    margin-bottom: 1rem;
    text-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
}

.hero-subtitle {
    font-family: var(--font-mono);
    color: var(--accent-cyan);
    font-size: 1.2rem;
    background: rgba(0, 0, 0, 0.6);
    padding: 0.5rem 1rem;
    border: 1px solid var(--accent-cyan-muted);
    display: inline-block;
}

/* Darkroom Module */
.darkroom-module {
    position: relative;
    overflow: hidden;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-0);
}

.histogram-mini {
    height: 40px;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    gap: 2px;
    padding: 4px;
}

.hist-bar {
    flex: 1;
    background: #333;
}
.hist-bar.highlight { background: var(--accent-amber); }

/* Metric Badges */
.metric-badge {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-0);
    color: #aaa;
}

.metric-badge.cyan {
    color: var(--accent-cyan);
    border-color: var(--accent-cyan-muted);
    background: rgba(0, 240, 255, 0.05);
}

/* Logbook Section */
.logbook-entry {
    border-bottom: 1px solid var(--border-0);
    padding: 1rem 0;
    display: flex;
    gap: 2rem;
    align-items: baseline;
}

.logbook-date {
    font-family: var(--font-mono);
    color: #666;
    font-size: 0.8rem;
    min-width: 100px;
}

/* Utilities */
.container-stealth {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.section-spacer {
    padding: 6rem 0;
}

.btn-stealth {
    background: transparent;
    border: 1px solid var(--accent-cyan);
    color: var(--accent-cyan);
    padding: 0.75rem 1.5rem;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-stealth:hover {
    background: var(--accent-cyan);
    color: black;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.4);
}

/* Animations */
@keyframes pulse-cyan {
    0%, 100% { border-color: rgba(0, 240, 255, 0.3); }
    50% { border-color: rgba(0, 240, 255, 0.8); }
}

.animate-pulse-cyan {
    animation: pulse-cyan 3s infinite;
}

/* Mobile */
@media (max-width: 768px) {
    .runbook-drawer {
        width: 85%;
    }
}

/* --- Added Phase 2 Styles --- */

/* Hover Cyan Glow Utils */
.hover-cyan-glow:hover {
    border-color: var(--accent-cyan) !important;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
    transform: translateY(-5px);
}
.transition-all {
    transition: all 0.3s ease;
}

/* Terminal Modal */
.terminal-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

/* --- Phase 3: Stealth Images & Nav --- */

/* Stealth Image Filter */
.img-stealth {
    filter: grayscale(100%) brightness(0.8) sepia(20%) hue-rotate(130deg) saturate(200%);
    transition: all 0.5s ease;
    border-radius: var(--border-radius-md);
}

.img-stealth:hover {
    filter: grayscale(0%) brightness(1.1);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.2);
}

/* Nav Link Styles */
.nav-link-stealth {
    color: #888;
    text-decoration: none;
    margin: 0 1rem;
    font-size: 0.9rem;
    position: relative;
    transition: color 0.3s;
}

.nav-link-stealth:hover,
.nav-link-stealth.active {
    color: var(--accent-cyan);
}

.nav-link-stealth.active::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--accent-cyan);
    box-shadow: 0 0 5px var(--accent-cyan);
}

.terminal-modal.open {
    display: flex;
}

.terminal-content {
    background: var(--bg-0);
    border: 1px solid var(--accent-cyan-muted);
    width: 90%;
    max-width: 700px;
    height: 500px;
    border-radius: var(--border-radius-md);
    box-shadow: 0 0 30px rgba(0, 240, 255, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.terminal-header {
    background: #1a1a1a;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border-0);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.terminal-close {
    background: none;
    border: none;
    color: var(--status-error);
    font-weight: bold;
    cursor: pointer;
    font-family: var(--font-mono);
}

.terminal-body {
    padding: 1rem;
    color: var(--accent-cyan);
    font-family: var(--font-mono);
    overflow-y: auto;
    flex-grow: 1;
    font-size: 0.9rem;
    line-height: 1.5;
}

.terminal-cursor {
    display: inline-block;
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

/* Matrix Text Color variation */
.text-success { color: var(--status-success) !important; }
.text-warning { color: var(--status-warning) !important; }
.text-danger { color: var(--status-error) !important; }
.text-info { color: #0dcaf0 !important; }

/* --- Phase 4 Expansion Styles --- */

/* Operational Metrics HUD */
.hud-metrics-container {
    border: 1px solid var(--border-0);
    background: rgba(10, 10, 10, 0.5);
    border-radius: var(--border-radius-md);
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    position: relative;
    overflow: hidden;
}

.hud-metrics-container::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-cyan), transparent);
    opacity: 0.5;
}

.hud-metric-item {
    text-align: center;
    padding: 1.5rem;
    min-width: 150px;
}

.metric-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
    font-family: var(--font-mono);
}

.metric-label {
    font-size: 0.8rem;
    color: var(--accent-cyan);
    font-family: var(--font-mono);
    letter-spacing: 1px;
    margin-top: 0.5rem;
}

/* System Architecture Diagram (CSS Art) */
.arch-diagram {
    position: relative;
    height: 400px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    perspective: 1000px;
}

.arch-layer {
    background: rgba(10, 10, 10, 0.8);
    border: 1px solid var(--accent-cyan-muted);
    padding: 15px 40px;
    width: 300px;
    text-align: center;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.05);
    transform: rotateX(10deg);
    transition: all 0.4s ease;
    position: relative;
}

.arch-layer:hover {
    transform: rotateX(0deg) scale(1.05);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 25px rgba(0, 240, 255, 0.2);
    z-index: 10;
    background: rgba(0, 20, 20, 0.9);
}

.arch-layer::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -22px;
    width: 2px;
    height: 20px;
    background: var(--border-0);
    transform: translateX(-50%);
}

.arch-layer:last-child::before {
    display: none;
}

.arch-layer-icon {
    font-size: 1.5rem;
    color: var(--accent-cyan);
    margin-bottom: 5px;
}

.arch-layer-title {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: white;
}

.arch-layer-desc {
    font-size: 0.75rem;
    color: #888;
}

/* Trace Route Timeline (Background Page) */
.timeline-container {
    position: relative;
    padding: 4rem 0;
    max-width: 800px;
    margin: 0 auto;
}

.timeline-line {
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    background: linear-gradient(180deg, transparent, var(--accent-cyan), transparent);
    transform: translateX(-50%);
    z-index: 0;
}

.timeline-node {
    position: relative;
    z-index: 1;
    margin-bottom: 150px; /* Space for scrolling */
    opacity: 0.3;
    transform: scale(0.9);
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    justify-content: center;
}

.timeline-node.active {
    opacity: 1;
    transform: scale(1.1);
}

.node-content {
    background: var(--surface-0);
    border: 1px solid var(--accent-cyan-muted);
    padding: 2rem;
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 600px;
    text-align: center;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    position: relative;
}

.node-content::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    background: var(--bg-0);
    border: 2px solid var(--accent-cyan);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-cyan);
}

.node-year {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    color: var(--accent-cyan);
    margin-bottom: 1rem;
    display: block;
}

/* ==============================================
   ANIMATION SYSTEM — Phase 5
   ============================================== */

/* --- Keyframes --- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(32px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInLeft {
    from { opacity: 0; transform: translateX(-32px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes fadeInRight {
    from { opacity: 0; transform: translateX(32px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes scanlineSweep {
    0%   { top: -4px; opacity: 0.7; }
    85%  { opacity: 0.5; }
    100% { top: 100%; opacity: 0; }
}

@keyframes shimmer {
    0%   { background-position: -200% center; }
    100% { background-position: 200% center; }
}

@keyframes borderGlow {
    0%, 100% { box-shadow: 0 0 8px rgba(0,240,255,0.12), inset 0 0 8px rgba(0,240,255,0.05); }
    50%       { box-shadow: 0 0 24px rgba(0,240,255,0.3),  inset 0 0 16px rgba(0,240,255,0.08); }
}

@keyframes glitchFlicker {
    0%, 88%, 100% { text-shadow: none; clip-path: none; opacity: 0.5; }
    90%  { text-shadow: 2px 0 var(--accent-cyan), -2px 0 rgba(255,0,80,0.5);
           clip-path: inset(20% 0 55% 0); opacity: 0.8; }
    92%  { clip-path: inset(55% 0 10% 0); opacity: 0.6; }
    94%  { text-shadow: none; clip-path: none; opacity: 0.5; }
}

@keyframes btnShimmer {
    from { transform: translateX(-120%); }
    to   { transform: translateX(120%); }
}

/* --- Scroll Reveal Base States --- */
.fade-up {
    opacity: 0;
    transform: translateY(32px);
    transition: opacity 0.75s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.75s cubic-bezier(0.16, 1, 0.3, 1);
}

.fade-left {
    opacity: 0;
    transform: translateX(-32px);
    transition: opacity 0.75s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.75s cubic-bezier(0.16, 1, 0.3, 1);
}

.fade-right {
    opacity: 0;
    transform: translateX(32px);
    transition: opacity 0.75s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.75s cubic-bezier(0.16, 1, 0.3, 1);
}

.fade-up.visible,
.fade-left.visible,
.fade-right.visible {
    opacity: 1;
    transform: none;
}

/* --- Stagger Delays --- */
.stagger-1 { transition-delay: 0.08s; }
.stagger-2 { transition-delay: 0.18s; }
.stagger-3 { transition-delay: 0.28s; }
.stagger-4 { transition-delay: 0.38s; }
.stagger-5 { transition-delay: 0.48s; }
.stagger-6 { transition-delay: 0.58s; }

/* --- Hero Entrance (first-load, staggered children) --- */
.hero-entrance > * {
    opacity: 0;
    animation: fadeInUp 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.hero-entrance > *:nth-child(1) { animation-delay: 0.25s; }
.hero-entrance > *:nth-child(2) { animation-delay: 0.50s; }
.hero-entrance > *:nth-child(3) { animation-delay: 0.70s; }
.hero-entrance > *:nth-child(4) { animation-delay: 0.90s; }

/* --- Masthead Scanline --- */
.masthead-scanline {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(0,240,255,0.5), transparent);
    pointer-events: none;
    z-index: 3;
    animation: scanlineSweep 9s linear infinite;
}

/* --- HUD bar: animated shimmer (overrides Phase 4 declaration) --- */
.hud-metrics-container::before {
    background: linear-gradient(90deg, transparent 0%, var(--accent-cyan) 50%, transparent 100%);
    background-size: 200% auto;
    animation: shimmer 5s linear infinite;
    opacity: 0.6;
}

/* --- CTA section glow pulse --- */
.cta-glow {
    animation: borderGlow 3.5s ease-in-out infinite;
    border-color: var(--accent-cyan-muted) !important;
}

/* --- System-logs label glitch --- */
.section-label-glitch {
    animation: glitchFlicker 10s ease-in-out infinite;
}

/* --- btn-stealth: shimmer sweep on hover --- */
.btn-stealth {
    position: relative;
    overflow: hidden;
}
.btn-stealth::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 60%;
    height: 100%;
    background: linear-gradient(120deg, transparent, rgba(0,240,255,0.18), transparent);
    transform: translateX(-120%);
    transition: none;
    pointer-events: none;
}
.btn-stealth:hover::after {
    animation: btnShimmer 0.55s ease-out forwards;
}
