/* ============================================
   JJUGGL.com - Chrome Glitch Machine Aesthetic
   ============================================ */

/* --- CSS Variables --- */
:root {
    --chrome-base: #C0C0C0;
    --chrome-highlight: #E8E8E8;
    --chrome-shadow: #2C2C2E;
    --chrome-dark: #1A1A1D;
    --bg-primary: #0D0D0F;
    --bg-secondary: #161618;
    --glitch-red: #FF2D55;
    --glitch-cyan: #00E5FF;
    --glitch-magenta: #D400FF;
    --text-primary: #F0F0F2;
    --text-secondary: #8E8E93;
    --interactive-hover: #FFFFFF;
    --status-green: #00FF88;

    --font-display: 'Bebas Neue', sans-serif;
    --font-body: 'Space Grotesk', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --chrome-gradient: linear-gradient(135deg, #2C2C2E 0%, #C0C0C0 45%, #E8E8E8 50%, #C0C0C0 55%, #2C2C2E 100%);
}

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

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
}

/* --- Scanline Overlay --- */
#scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9998;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(255, 255, 255, 0.04) 2px,
        rgba(255, 255, 255, 0.04) 3px
    );
}

/* --- CRT Vignette --- */
#crt-vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9997;
    background: radial-gradient(
        ellipse at center,
        transparent 60%,
        rgba(0, 0, 0, 0.08) 100%
    );
}

/* ============================================
   Tier 0: Fixed Header
   ============================================ */
#site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#chrome-bar {
    width: 100%;
    height: 4px;
    background: var(--chrome-gradient);
}

#header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 24px;
    background: rgba(13, 13, 15, 0.85);
    border-bottom: 1px solid rgba(192, 192, 192, 0.1);
}

/* Data Ticker */
#data-ticker {
    flex: 1;
    overflow: hidden;
    margin-right: 32px;
    height: 20px;
    position: relative;
}

.ticker-content {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    display: inline-block;
    will-change: transform;
    letter-spacing: 0.02em;
}

#data-ticker:hover .ticker-content {
    color: var(--glitch-red);
}

/* Navigation */
#main-nav {
    display: flex;
    gap: 24px;
    flex-shrink: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    transition: color 0.15s ease;
    position: relative;
}

.nav-item:hover {
    color: var(--interactive-hover);
    text-shadow:
        -2px 0 var(--glitch-red),
        2px 0 var(--glitch-cyan);
}

.nav-item:hover .nav-label {
    animation: nav-glitch 0.15s steps(2) forwards;
}

@keyframes nav-glitch {
    0% {
        text-shadow: -2px 0 var(--glitch-red), 2px 0 var(--glitch-cyan);
    }
    50% {
        text-shadow: 2px 0 var(--glitch-red), -2px 0 var(--glitch-cyan);
    }
    100% {
        text-shadow: none;
    }
}

.nav-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--chrome-base);
    transition: background 0.3s ease;
}

.nav-item.active .nav-dot {
    background: var(--status-green);
    box-shadow: 0 0 6px var(--status-green);
    animation: dot-pulse 1s ease-in-out infinite;
}

@keyframes dot-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.nav-label {
    transition: text-shadow 0.15s ease;
}

/* ============================================
   Scroll Progress Indicator
   ============================================ */
#scroll-progress {
    position: fixed;
    left: 24px;
    top: 60px;
    bottom: 24px;
    width: 2px;
    z-index: 900;
    display: none;
}

@media (min-width: 1024px) {
    #scroll-progress {
        display: block;
    }
}

#scroll-track {
    position: relative;
    width: 100%;
    height: 100%;
    background: rgba(192, 192, 192, 0.1);
}

#scroll-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: var(--chrome-gradient);
    transition: height 0.1s linear;
}

#scroll-dot {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chrome-highlight);
    box-shadow: 0 0 8px rgba(232, 232, 232, 0.6);
    animation: dot-pulse 1s ease-in-out infinite;
    top: 0%;
    transition: top 0.1s linear;
}

/* ============================================
   Tier 1: Hero Section
   ============================================ */
#hero {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--bg-primary);
}

#orbit-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#particles-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 1px;
    height: 1px;
    background: var(--chrome-highlight);
    opacity: 0.6;
    will-change: transform;
}

/* Hero Text */
#hero-text {
    position: relative;
    z-index: 3;
    text-align: center;
    overflow: hidden;
}

.hero-strip {
    font-family: var(--font-display);
    font-size: clamp(80px, 18vw, 280px);
    line-height: 0.9;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: transparent;
    background: var(--chrome-gradient);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    background-clip: text;
    will-change: transform, background-position;
    animation: chrome-sweep 20s linear infinite;
    position: relative;
}

#strip-1 {
    transform: translateX(-60px);
    opacity: 0;
}

#strip-2 {
    transform: translateX(40px);
    opacity: 0;
}

#strip-3 {
    transform: translateX(-30px);
    opacity: 0;
}

.hero-strip.assembled {
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.6s ease-out;
}

#strip-1.assembled {
    transform: translateX(-2px);
    opacity: 1;
}

#strip-2.assembled {
    transform: translateX(2px);
    opacity: 1;
}

#strip-3.assembled {
    transform: translateX(-1px);
    opacity: 1;
}

@keyframes chrome-sweep {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Hero Subtitle */
#hero-subtitle {
    position: relative;
    z-index: 3;
    margin-top: 32px;
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
    opacity: 0;
    transition: opacity 0.6s ease 1s;
}

#hero-subtitle.visible {
    opacity: 1;
}

.subtitle-cursor {
    animation: cursor-blink 1s step-end infinite;
}

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

/* ============================================
   Glitch Tear Dividers
   ============================================ */
.glitch-tear {
    width: 100%;
    height: 2px;
    position: relative;
    overflow: hidden;
    background: var(--chrome-shadow);
}

.glitch-tear::before,
.glitch-tear::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch-tear::before {
    background: var(--glitch-red);
    transform: translateY(-3px);
    mix-blend-mode: screen;
    opacity: 0;
}

.glitch-tear::after {
    background: var(--glitch-cyan);
    transform: translateY(3px);
    mix-blend-mode: screen;
    opacity: 0;
}

.glitch-tear.active {
    height: 40px;
    transition: height 0.2s ease-out;
    background: repeating-linear-gradient(
        90deg,
        var(--glitch-red) 0px,
        transparent 2px,
        var(--glitch-cyan) 4px,
        transparent 6px,
        var(--glitch-magenta) 8px,
        transparent 10px
    );
    opacity: 0.7;
}

.glitch-tear.active::before {
    opacity: 0.6;
    animation: tear-shift 0.1s steps(3) infinite;
}

.glitch-tear.active::after {
    opacity: 0.6;
    animation: tear-shift 0.1s steps(3) infinite reverse;
}

@keyframes tear-shift {
    0% { transform: translateX(0) translateY(-3px); }
    33% { transform: translateX(4px) translateY(1px); }
    66% { transform: translateX(-2px) translateY(-1px); }
    100% { transform: translateX(0) translateY(3px); }
}

.glitch-tear.collapse {
    height: 2px;
    transition: height 0.2s ease-in;
}

.inline-tear {
    margin: 48px 0;
}

/* ============================================
   Tier 2: Data Card Modules
   ============================================ */
#modules {
    padding: 120px 24px;
    position: relative;
    background: var(--bg-secondary);
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
    max-width: 1200px;
    margin: 0 auto;
}

@media (max-width: 900px) {
    .module-grid {
        grid-template-columns: 1fr;
        max-width: 500px;
    }
}

.data-card {
    position: relative;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.data-card.revealed {
    opacity: 1;
    transform: translateY(0);
}

.card-border {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 1px solid transparent;
    background: var(--chrome-gradient) border-box;
    background-size: 200% 200%;
    -webkit-mask:
        linear-gradient(#fff 0 0) padding-box,
        linear-gradient(#fff 0 0);
    mask:
        linear-gradient(#fff 0 0) padding-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    transition: background-position 0.3s ease-out;
    pointer-events: none;
}

.data-card:hover .card-border {
    background-position: 100% 100%;
}

.card-inner {
    padding: 32px 28px;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.data-card:hover .card-inner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(255, 255, 255, 0.02) 2px,
        rgba(255, 255, 255, 0.02) 3px
    );
    pointer-events: none;
}

.data-card:hover .card-inner {
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.4);
}

.card-icon {
    width: 80px;
    height: 80px;
    margin-bottom: 24px;
}

.line-illustration {
    width: 100%;
    height: 100%;
}

.card-title {
    font-family: var(--font-display);
    font-size: 28px;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.card-text {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
    letter-spacing: 0.02em;
    margin-bottom: 20px;
}

.card-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--chrome-base);
}

.status-dot.active {
    background: var(--status-green);
    box-shadow: 0 0 6px var(--status-green);
    animation: dot-pulse 1s ease-in-out infinite;
}

.status-label {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
}

/* ============================================
   Tier 3: Narrative Descent
   ============================================ */
#narrative {
    padding: 120px 24px 120px 80px;
    position: relative;
    min-height: 100vh;
}

@media (min-width: 1024px) {
    #narrative {
        padding-left: 260px;
    }
}

.narrative-content {
    max-width: 800px;
}

.narrative-block {
    margin-bottom: 80px;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.narrative-block.revealed {
    opacity: 1;
    transform: translateY(0);
}

.block-marker {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.marker-line {
    display: block;
    width: 40px;
    height: 1px;
    background: var(--chrome-base);
}

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

.narrative-heading {
    font-family: var(--font-display);
    font-size: clamp(36px, 5vw, 64px);
    letter-spacing: 0.08em;
    color: var(--text-primary);
    margin-bottom: 24px;
    background: var(--chrome-gradient);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: chrome-sweep 20s linear infinite;
}

.narrative-text {
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.8;
    letter-spacing: 0.02em;
    margin-bottom: 16px;
    max-width: 640px;
}

/* ============================================
   Tier 4: Signal Loss Footer
   ============================================ */
#signal-loss {
    min-height: 80vh;
    padding: 80px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    position: relative;
}

.degradation-zone {
    width: 100%;
    max-width: 700px;
    text-align: center;
}

.degrading-block {
    margin-bottom: 48px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.degrading-block.revealed {
    opacity: 1;
    transform: translateY(0);
}

.degrade-text {
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--text-primary);
    letter-spacing: 0.04em;
    line-height: 1.6;
}

.degrade-text.mono {
    font-family: var(--font-mono);
    font-size: 14px;
}

.degrade-text.desaturate {
    color: var(--chrome-base);
}

.degrade-text.corrupt {
    color: var(--chrome-shadow);
    letter-spacing: 0.2em;
    text-shadow:
        -3px 0 var(--glitch-red),
        3px 0 var(--glitch-cyan);
    animation: corrupt-flicker 0.3s steps(2) infinite;
}

@keyframes corrupt-flicker {
    0% { opacity: 1; }
    25% { opacity: 0.7; }
    50% { opacity: 1; }
    75% { opacity: 0.5; }
    100% { opacity: 1; }
}

#terminal-end {
    margin-top: 80px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000000;
    border: 1px solid rgba(44, 44, 46, 0.3);
    padding: 0 24px;
}

#final-cursor {
    font-family: var(--font-mono);
    font-size: 20px;
    color: var(--chrome-highlight);
    animation: cursor-blink 1s step-end infinite;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    #header-inner {
        flex-direction: column;
        gap: 8px;
        padding: 6px 16px;
    }

    #data-ticker {
        margin-right: 0;
        width: 100%;
    }

    #main-nav {
        gap: 16px;
    }

    .nav-item {
        font-size: 10px;
    }

    #hero-text {
        padding: 0 16px;
    }

    #narrative {
        padding: 80px 24px;
    }

    .narrative-heading {
        font-size: 32px;
    }

    #modules {
        padding: 80px 16px;
    }
}

/* ============================================
   Selection Styles
   ============================================ */
::selection {
    background: var(--glitch-red);
    color: var(--interactive-hover);
}

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--chrome-shadow);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--chrome-base);
}
