/* ============================================
   JJUGGL.com — Cyberpunk AI Neural Architecture
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --bg-primary: #0A0A0F;
    --bg-secondary: #12101F;
    --neon-primary: #00FF88;
    --neon-secondary: #FF0066;
    --neon-tertiary: #00DDFF;
    --signal-yellow: #FFEE00;
    --text-primary: #E8E8F0;
    --text-muted: #6B6B8D;
    --glitch-red: #FF2244;
    --grid-line: #00FFAA;

    --font-primary: 'Jost', sans-serif;
    --font-mono: 'Space Mono', monospace;
    --font-accent: 'Orbitron', sans-serif;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 15px;
    line-height: 1.75;
    overflow-x: hidden;
    position: relative;
}

/* Scan-line overlay */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 2px,
        rgba(0, 255, 136, 0.03) 2px,
        rgba(0, 255, 136, 0.03) 4px
    );
}

/* --- Noise Texture Overlay --- */
.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9998;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* --- Grid Overlay --- */
.grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    background-image: repeating-linear-gradient(
        90deg,
        rgba(0, 255, 170, 0.06) 0px,
        rgba(0, 255, 170, 0.06) 1px,
        transparent 1px,
        transparent calc(100% / 12)
    );
}

/* --- Navigation --- */
.nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 44px;
    z-index: 1000;
    background: rgba(10, 10, 15, 0.85);
    border-bottom: 1px solid rgba(0, 255, 170, 0.15);
    backdrop-filter: blur(8px);
    opacity: 0;
    animation: navReveal 0.6s ease forwards 1.5s;
}

@keyframes navReveal {
    0% {
        opacity: 0;
        clip-path: inset(0 100% 0 0);
    }
    100% {
        opacity: 1;
        clip-path: inset(0 0 0 0);
    }
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 24px;
}

.nav-brand {
    font-family: var(--font-primary);
    font-weight: 900;
    font-size: 18px;
    letter-spacing: 0.15em;
    color: var(--neon-primary);
    text-transform: uppercase;
    text-shadow:
        -2px 0 var(--neon-secondary),
        2px 0 var(--neon-tertiary);
    animation: flicker 6s infinite;
}

.nav-coords {
    display: flex;
    gap: 16px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
}

.nav-label {
    color: var(--neon-tertiary);
    margin-right: 4px;
}

.nav-coord {
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.nav-links {
    display: flex;
    gap: 20px;
}

.nav-link {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    text-decoration: none;
    letter-spacing: 0.1em;
    transition: color 0.3s ease, text-shadow 0.3s ease;
    position: relative;
}

.nav-link:hover,
.nav-link.active {
    color: var(--neon-primary);
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--neon-primary);
    transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

.nav-status {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--neon-primary);
    animation: flicker 6s infinite;
}

/* Flicker animation */
@keyframes flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.97; }
    52% { opacity: 1; }
    83% { opacity: 0.97; }
    83.5% { opacity: 0.8; }
    84% { opacity: 0.97; }
    84.5% { opacity: 1; }
}

/* --- Viewport Base --- */
.viewport {
    min-height: 100vh;
    width: 100%;
    position: relative;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 40%, var(--bg-primary) 100%);
}

/* --- Circuit Traces --- */
.circuit-traces {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.circuit-path {
    fill: none;
    stroke: var(--neon-tertiary);
    stroke-width: 1;
    opacity: 0.12;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 0.05s linear;
}

.circuit-path.drawn {
    stroke-dashoffset: 0;
}

/* --- Data Rain --- */
.data-rain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    pointer-events: none;
    z-index: 3;
    overflow: hidden;
    opacity: 0.6;
}

.rain-column {
    position: absolute;
    top: -100%;
    width: 30px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 22px;
    color: var(--neon-primary);
    animation: rainFall linear infinite;
    white-space: nowrap;
}

@keyframes rainFall {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(200vh); }
}

/* =====================
   VIEWPORT 1: BOOT
   ===================== */
.viewport-boot {
    z-index: 5;
}

.boot-content {
    text-align: center;
    z-index: 10;
    position: relative;
}

/* Glitch effect */
.glitch {
    position: relative;
    display: inline-block;
    font-family: var(--font-primary);
    font-weight: 900;
    font-size: clamp(3rem, 8vw, 12rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-primary);
    animation: glitchResolve 3s ease forwards;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.glitch::before {
    color: var(--neon-secondary);
    z-index: -1;
    animation: glitchBefore 3s ease forwards, glitchShift 0.1s infinite steps(2) alternate-reverse;
}

.glitch::after {
    color: var(--neon-tertiary);
    z-index: -1;
    animation: glitchAfter 3s ease forwards, glitchShift2 0.1s infinite steps(2) alternate-reverse;
}

@keyframes glitchResolve {
    0% {
        clip-path: inset(0 0 80% 0);
        transform: translateX(-20px);
        opacity: 0;
    }
    10% {
        clip-path: inset(20% 0 40% 0);
        transform: translateX(15px);
        opacity: 1;
    }
    20% {
        clip-path: inset(60% 0 0 0);
        transform: translateX(-10px);
    }
    30% {
        clip-path: inset(10% 0 30% 0);
        transform: translateX(8px);
    }
    50% {
        clip-path: inset(0 0 0 0);
        transform: translateX(-3px);
    }
    70% {
        transform: translateX(2px);
    }
    100% {
        clip-path: inset(0 0 0 0);
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes glitchBefore {
    0% { clip-path: inset(40% 0 20% 0); transform: translateX(-5px); opacity: 0.3; }
    50% { clip-path: inset(20% 0 40% 0); transform: translateX(3px); opacity: 0.3; }
    100% { clip-path: inset(0 0 0 0); transform: translateX(-2px); opacity: 0.3; }
}

@keyframes glitchAfter {
    0% { clip-path: inset(20% 0 60% 0); transform: translateX(5px); opacity: 0.3; }
    50% { clip-path: inset(50% 0 10% 0); transform: translateX(-3px); opacity: 0.3; }
    100% { clip-path: inset(0 0 0 0); transform: translateX(2px); opacity: 0.3; }
}

@keyframes glitchShift {
    0% { clip-path: inset(20% 0 60% 0); transform: translateX(-2px); }
    100% { clip-path: inset(60% 0 20% 0); transform: translateX(2px); }
}

@keyframes glitchShift2 {
    0% { clip-path: inset(50% 0 30% 0); transform: translateX(2px); }
    100% { clip-path: inset(10% 0 70% 0); transform: translateX(-2px); }
}

.glitch-text {
    text-shadow:
        -2px 0 rgba(255, 0, 102, 0.3),
        2px 0 rgba(0, 221, 255, 0.3);
}

.boot-subtitle {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 40px;
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--neon-primary);
    opacity: 0;
    animation: fadeInUp 1s ease forwards 2.5s;
}

.boot-line {
    opacity: 0;
    animation: typeLine 0.5s ease forwards;
}

.boot-line:nth-child(1) { animation-delay: 2.8s; }
.boot-line:nth-child(2) { animation-delay: 3.3s; }
.boot-line:nth-child(3) { animation-delay: 3.8s; }

@keyframes typeLine {
    0% { opacity: 0; transform: translateX(-10px); }
    100% { opacity: 1; transform: translateX(0); }
}

.boot-marker {
    margin-top: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    opacity: 0;
    animation: fadeInUp 1s ease forwards 4.2s;
}

.marker-icon {
    color: var(--neon-primary);
    font-size: 20px;
    animation: pulse 2s ease-in-out infinite;
}

.marker-label {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.2em;
    color: var(--text-muted);
}

@keyframes pulse {
    0%, 100% { transform: translateY(0); opacity: 0.6; }
    50% { transform: translateY(8px); opacity: 1; }
}

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

/* =====================
   VIEWPORT 2: SIGNAL
   ===================== */
.viewport-signal {
    display: block;
    padding: 0;
}

.signal-strips {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.signal-strip {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 30px;
    border-right: 1px solid rgba(0, 255, 170, 0.08);
}

.strip-left {
    width: 35%;
    background: linear-gradient(180deg, var(--bg-primary) 0%, rgba(18, 16, 31, 0.8) 50%, var(--bg-primary) 100%);
}

.strip-center {
    width: 40%;
    background: linear-gradient(180deg, var(--bg-secondary) 0%, rgba(10, 10, 15, 0.9) 50%, var(--bg-secondary) 100%);
}

.strip-right {
    width: 25%;
    background: linear-gradient(180deg, var(--bg-primary) 0%, rgba(18, 16, 31, 0.6) 50%, var(--bg-primary) 100%);
    border-right: none;
}

.strip-content {
    max-width: 400px;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.strip-content.visible {
    opacity: 1;
    transform: translateY(0);
}

.strip-label {
    font-family: var(--font-accent);
    font-size: 11px;
    font-weight: 500;
    color: var(--neon-tertiary);
    letter-spacing: 0.2em;
    display: block;
    margin-bottom: 20px;
}

.strip-title {
    font-family: var(--font-primary);
    font-weight: 800;
    font-size: clamp(1.5rem, 3vw, 3rem);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 20px;
    line-height: 1.1;
}

.strip-body {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.75;
    margin-bottom: 30px;
}

.strip-data {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.data-point {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid rgba(0, 255, 170, 0.06);
}

.data-key {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--neon-tertiary);
    letter-spacing: 0.1em;
}

.data-val {
    font-family: var(--font-accent);
    font-size: 12px;
    font-weight: 500;
    color: var(--neon-primary);
}

/* =====================
   VIEWPORT 3: CORE
   ===================== */
.viewport-core {
    background: var(--bg-primary);
}

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

.particle-dot {
    position: absolute;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: var(--grid-line);
    opacity: 0.08;
    transition: opacity 0.3s ease;
}

.particle-dot.bright {
    opacity: 0.6;
}

.core-block {
    position: relative;
    z-index: 10;
    max-width: 800px;
    width: 90%;
    padding: 60px;
    background: rgba(18, 16, 31, 0.7);
    border: 1px solid rgba(0, 255, 170, 0.1);
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.core-block.visible {
    opacity: 1;
    transform: translateY(0);
}

.core-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(0, 255, 170, 0.08);
}

.section-id {
    font-family: var(--font-accent);
    font-size: 11px;
    font-weight: 500;
    color: var(--neon-tertiary);
    letter-spacing: 0.15em;
}

.core-tag {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    color: var(--signal-yellow);
    padding: 4px 10px;
    border: 1px solid rgba(255, 238, 0, 0.3);
}

.core-title {
    font-family: var(--font-primary);
    font-weight: 900;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 30px;
}

.core-content {
    margin-bottom: 40px;
}

.core-text {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.75;
    margin-bottom: 20px;
}

.core-text:last-child {
    margin-bottom: 0;
}

.core-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    padding-top: 30px;
    border-top: 1px solid rgba(0, 255, 170, 0.08);
}

.stat-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: center;
}

.stat-value {
    font-family: var(--font-accent);
    font-size: clamp(1.2rem, 2vw, 1.8rem);
    font-weight: 700;
    color: var(--neon-primary);
    text-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
}

.stat-label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.15em;
    color: var(--text-muted);
}

.orbitron {
    font-family: var(--font-accent);
}

/* =====================
   VIEWPORT 4: PULSE
   ===================== */
.viewport-pulse {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 80px 0;
}

.pulse-header {
    text-align: center;
    padding: 0 40px;
    margin-bottom: 60px;
    z-index: 10;
}

.pulse-title {
    font-family: var(--font-primary);
    font-weight: 900;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin: 16px 0;
}

.pulse-subtitle {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-muted);
}

.pulse-track-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
    z-index: 10;
    scrollbar-width: thin;
    scrollbar-color: var(--neon-primary) var(--bg-secondary);
    cursor: grab;
}

.pulse-track-wrapper:active {
    cursor: grabbing;
}

.pulse-track {
    display: flex;
    gap: 30px;
    padding: 40px 60px;
    width: max-content;
}

.pulse-card {
    position: relative;
    width: 320px;
    min-height: 300px;
    padding: 36px;
    background: var(--bg-secondary);
    border: 1px solid rgba(0, 255, 170, 0.1);
    flex-shrink: 0;
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.pulse-card:hover {
    border-color: var(--neon-primary);
    transform: rotate(0deg) !important;
}

.pulse-card:hover .glitch-text {
    text-shadow:
        -3px 0 rgba(255, 0, 102, 0.5),
        3px 0 rgba(0, 221, 255, 0.5);
}

.card-glitch-border {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.pulse-card:hover .card-glitch-border {
    opacity: 1;
    border: 1px solid var(--glitch-red);
    animation: borderGlitch 0.5s steps(3) infinite;
}

@keyframes borderGlitch {
    0% { clip-path: inset(0 0 90% 0); transform: translateX(2px); }
    33% { clip-path: inset(30% 0 40% 0); transform: translateX(-3px); }
    66% { clip-path: inset(70% 0 0 0); transform: translateX(1px); }
    100% { clip-path: inset(0 0 90% 0); transform: translateX(2px); }
}

.card-id {
    font-family: var(--font-accent);
    font-size: 11px;
    font-weight: 500;
    color: var(--neon-tertiary);
    letter-spacing: 0.15em;
    display: block;
    margin-bottom: 16px;
}

.card-title {
    font-family: var(--font-primary);
    font-weight: 800;
    font-size: 20px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 16px;
    text-shadow:
        -2px 0 rgba(255, 0, 102, 0.3),
        2px 0 rgba(0, 221, 255, 0.3);
}

.card-body {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.75;
    margin-bottom: 24px;
}

.card-status {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.1em;
    padding: 4px 12px;
    display: inline-block;
}

.status-active {
    color: var(--neon-primary);
    border: 1px solid rgba(0, 255, 136, 0.3);
}

.status-warning {
    color: var(--signal-yellow);
    border: 1px solid rgba(255, 238, 0, 0.3);
}

.status-error {
    color: var(--glitch-red);
    border: 1px solid rgba(255, 34, 68, 0.3);
    animation: flicker 2s infinite;
}

/* =====================
   VIEWPORT 5: EXIT
   ===================== */
.viewport-exit {
    background: linear-gradient(180deg, var(--bg-primary), var(--bg-secondary));
    animation: hueShift 30s linear infinite;
}

@keyframes hueShift {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

.exit-content {
    text-align: center;
    z-index: 10;
    position: relative;
}

.exit-title {
    font-family: var(--font-primary);
    font-weight: 900;
    font-size: clamp(2rem, 6vw, 6rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 24px;
}

.exit-message {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 60px;
}

.exit-loop-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 80px;
}

.loop-symbol {
    font-size: 48px;
    color: var(--neon-primary);
    text-shadow: 0 0 30px rgba(0, 255, 136, 0.4);
    animation: pulse 3s ease-in-out infinite;
}

.loop-label {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 0.15em;
}

.exit-signature {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sig-line {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    opacity: 0.5;
}

/* =====================
   Chromatic Aberration for interactive elements
   ===================== */
.nav-link:hover,
.pulse-card:hover .card-title,
.strip-title:hover {
    text-shadow:
        -3px 0 rgba(255, 0, 102, 0.4),
        3px 0 rgba(0, 221, 255, 0.4);
}

/* =====================
   Scroll Reveal Base
   ===================== */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* =====================
   Responsive
   ===================== */
@media (max-width: 900px) {
    .signal-strips {
        flex-direction: column;
    }

    .strip-left,
    .strip-center,
    .strip-right {
        width: 100%;
        min-height: auto;
        padding: 60px 30px;
        border-right: none;
        border-bottom: 1px solid rgba(0, 255, 170, 0.08);
    }

    .core-block {
        padding: 30px;
    }

    .core-stats {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .nav-coords {
        display: none;
    }

    .nav-links {
        gap: 10px;
    }

    .pulse-card {
        width: 280px;
        min-height: auto;
    }
}

@media (max-width: 600px) {
    .nav-links {
        display: none;
    }

    .core-block {
        width: 95%;
        padding: 24px;
    }

    .pulse-track {
        padding: 20px 20px;
    }
}

/* =====================
   Reduced Motion
   ===================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .rain-column {
        display: none;
    }

    .glitch::before,
    .glitch::after {
        display: none;
    }

    .viewport-exit {
        animation: none;
    }
}
