:root {
    --bg-pure-black: #000000;
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --surface: #131315;
    --border-dim: #27272A;
    --border-bright: #3F3F46;
    --glow-primary: rgba(255, 255, 255, 0.1);
    --glass-blur: 16px;
    
    /* Fluid Spacing & Typography */
    --space-section: clamp(8rem, 15vw, 12rem);
    --space-xl: clamp(3rem, 6vw, 5rem);
    --font-h1: clamp(2.5rem, 8vw, 4rem);
    --font-h2: clamp(1.5rem, 5vw, 2.5rem);
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 6rem;
}

section {
    scroll-margin-top: 6rem;
    margin-bottom: var(--space-section);
}

body {
    background-color: var(--bg-pure-black);
    color: var(--text-primary);
    overflow-x: hidden;
    font-family: 'Inter', sans-serif;
    font-display: swap;
}

/* --- Cinematic System Utilities --- */

.glass-panel {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid rgba(39, 39, 42, 0.5); /* zinc-800 */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.glass-panel:hover {
    border-color: rgba(63, 63, 70, 0.8); /* zinc-700 */
}

.inner-glow {
    box-shadow: inset 0 0 20px var(--glow-primary);
}

.protocol-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.25em;
    color: var(--text-secondary);
}

/* --- Scanline & Texture --- */

.scanline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.02), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.02));
    background-size: 100% 3px, 3px 100%;
    z-index: 999;
    pointer-events: none;
    opacity: 0.03;
}

.grain-overlay {
    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)'/%3E%3C/svg%3E");
    opacity: 0.04;
    z-index: 998;
    pointer-events: none;
}

/* --- Animated SVG Blob Accent for Hero --- */
#hero-accent-blob {
    position: absolute;
    top: 4vw;
    left: max(0vw, 5vw);
    width: min(430px, 32vw);
    height: auto;
    z-index: 6; /* over particles but below terminal */
    filter: blur(2.5px) brightness(1.07) grayscale(1) opacity(0.64);
    pointer-events: none;
    transition: filter 0.3s, opacity 0.5s;
}
@media (max-width: 900px) {
  #hero-accent-blob {
    left: max(-2vw, 0vw);
    top: 6vw;
    width: min(340px, 44vw);
    filter: blur(1.7px) brightness(1.04) grayscale(1) opacity(0.58);
  }
}
@media (max-width: 600px) {
  #hero-accent-blob {
    left: max(-8vw, 0vw);
    top: 12vw;
    width: min(240px, 80vw);
    filter: blur(1px) brightness(1.02) grayscale(1) opacity(0.53);
  }
}
/* Background Particles */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    opacity: 0.15;
}

/* 3D Terminal & Cinematic Sequence */
#main-terminal {
    transform-style: preserve-3d;
    backface-visibility: hidden;
    z-index: 10;
    will-change: transform, opacity;
}

#terminal-3d-wrap {
    transform-style: preserve-3d;
    position: relative;
    will-change: transform, opacity;
}

#hero-text-container {
    will-change: opacity, transform;
}

#content-reveal-zone {
    will-change: opacity, transform;
}

/* Shards for disassembly */
.terminal-shard {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    pointer-events: none;
    opacity: 0;
    z-index: 5;
    backdrop-filter: blur(4px);
    transition: all 0.3s ease-out;
}

#shard-1 { clip-path: polygon(0 0, 50% 0, 50% 50%, 0 50%); }
#shard-2 { clip-path: polygon(50% 0, 100% 0, 100% 50%, 50% 50%); }
#shard-3 { clip-path: polygon(0 50%, 50% 50%, 50% 100%, 0 100%); }
#shard-4 { clip-path: polygon(50% 50%, 100% 50%, 100% 100%, 50% 100%); }

/* Coding Stream Highlight */
.code-line {
    border-left: 2px solid rgba(255,255,255,0.2);
    padding-left: 10px;
    margin-bottom: 4px;
    animation: fadeInUp 0.3s ease forwards;
}

/* Active Nav Link */
.nav-link.active {
    color: #ffffff !important;
    font-weight: 700;
}
.nav-link.active::after {
    content: '';
    display: block;
    width: 100%;
    height: 1px;
    background: #ffffff;
    margin-top: 2px;
    animation: fadeInUp 0.3s ease;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-dim); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }

/* Accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 8px;
    z-index: 1000;
    transition: top 0.3s;
}
.skip-link:focus { top: 0; }

.glass-panel {
    background-color: rgba(24, 24, 27, 0.6);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-dim);
    box-shadow: inset 1px 1px 0px 0px rgba(255, 255, 255, 0.1);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s ease;
}
.glass-panel:hover {
    border-color: var(--border-bright);
    transform: translateY(-4px);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.reveal-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.reveal-on-scroll.visible {
    opacity: 1;
    transform: translateY(0);
}

.terminal-cursor {
    display: inline-block;
    width: 8px;
    height: 15px;
    background: #ffffff;
    margin-left: 4px;
    vertical-align: middle;
    animation: blink 1s step-end infinite;
}

.tech-chip {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    color: #a1a1aa;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}
.tech-chip:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
    color: #ffffff;

}

.blueprint-bg {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    background-image: radial-gradient(circle at 2px 2px, rgba(255, 255, 255, 0.05) 1px, transparent 0);
    background-size: 24px 24px;
    mask-image: linear-gradient(to bottom, black 50%, transparent);
    pointer-events: none;
}

/* Ambient Grain Overlay */
.grain-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' 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)'/%3E%3C/svg%3E");
    opacity: 0.04;
    pointer-events: none;
    z-index: 9999;
}

.tech-grid-bg {
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
}

.magnetic-btn {
    transition: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1), box-shadow 0.3s ease;
    display: inline-block;
    will-change: transform;
}

.magnetic-btn:hover {
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.magnetic-btn:active, .dock-link:active {
    transform: scale(0.95) !important;
}

/* Command Dock Enhancements */
#command-dock {
    transition: transform 0.5s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.5s ease, background 0.3s ease;
}

.dock-link {
    position: relative;
    z-index: 1;
}
.dock-link.active .material-symbols-outlined {
    color: #ffffff;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5));
}

#dock-indicator {
    background: #ffffff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 0 5px rgba(255, 255, 255, 0.4);
    height: 2px;
    width: 32px;
    border-radius: 2px;
    top: -1px;
}

/* CRT Effects for Terminal */
.terminal-screen::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.2) 50%), 
                linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
    background-size: 100% 3px, 3px 100%;
    pointer-events: none;
    z-index: 20;
    opacity: 0.6;
}

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

.terminal-screen::before {
    content: " ";
    display: block;
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
    background: linear-gradient(to bottom, transparent 0%, rgba(255, 255, 255, 0.03) 50%, transparent 100%);
    width: 100%;
    height: 100px;
    z-index: 21;
    animation: scanline 8s linear infinite;
    pointer-events: none;
}

@keyframes crt-flicker {
    0% { opacity: 0.98; }
    5% { opacity: 0.95; }
    10% { opacity: 0.99; }
    15% { opacity: 0.96; }
    20% { opacity: 0.98; }
    25% { opacity: 0.99; }
    30% { opacity: 1; }
    100% { opacity: 1; }
}

.terminal-screen {
    animation: crt-flicker 0.15s infinite;
}

.terminal-screen p {
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    #navbar {
        display: none !important;
    }
    
    #command-dock {
        padding-bottom: env(safe-area-inset-bottom);
        box-sizing: content-box;
        display: flex !important;
    }
    
    #command-dock.visible {
        transform: translate3d(-50%, 0, 0);
        opacity: 1;
        pointer-events: auto;
    }

    #main-terminal {
        height: 260px !important;
        width: 95vw !important;
        max-width: 400px !important;
    }
    #terminal-3d-wrap {
        width: 100% !important;
        display: flex;
        justify-content: center;
    }
}

#mobile-menu.open {
    transform: translateX(0);
}

.mobile-nav-link {
    transition: all 0.3s ease;
}

.mobile-nav-link:hover {
    letter-spacing: 0.1em;
    transform: scale(1.1);
}

@media (prefers-reduced-motion: reduce) {
    .scanline-overlay, .grain-overlay, .animate-glow, .animate-pulse {
        animation: none !important;
        opacity: 0.02 !important;
    }
    html {
        scroll-behavior: auto !important;
    }
}

.reveal-delay-1 { animation-delay: 0.1s; }
.reveal-delay-2 { animation-delay: 0.2s; }
.reveal-delay-3 { animation-delay: 0.3s; }
.reveal-delay-4 { animation-delay: 0.4s; }

@keyframes revealIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* UI Glitch & Glow Effects */
.inner-glow {
    box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.05);
}

.animate-glow {
    animation: textGlow 4s ease-in-out infinite alternate;
}

@keyframes textGlow {
    from { text-shadow: 0 0 10px rgba(255, 255, 255, 0); }
    to { text-shadow: 0 0 20px rgba(255, 255, 255, 0.2); }
}

/* Protocol Selector Styles */
.protocol-btn.active, .ai-btn.active {
    background-color: #ffffff;
    color: #000000 !important;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.protocol-btn:not(.active):hover, .ai-btn:not(.active):hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Core UI Architecture Styles */
.panel-scroll {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}
.panel-scroll::-webkit-scrollbar { width: 4px; }
.panel-scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 4px; }

.queue-item {
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
}
.queue-item.active {
    background: rgba(200, 255, 0, 0.05);
    border-left-color: #C8FF00;
}
.queue-item:hover:not(.active) {
    background: rgba(255, 255, 255, 0.02);
}
