/* ===================================
   bada.city - Cyberpunk Neon Descent
   =================================== */

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

:root {
    --void-black: #0A0A0F;
    --deep-indigo: #0B0B1A;
    --electric-cyan: #00F0FF;
    --hot-magenta: #FF00FF;
    --signal-green: #39FF14;
    --glitch-red: #FF0044;
    --screen-text: #C0F0FF;
    --warning-gold: #FFD700;
    --trace-line: #1A1A2E;
}

html, body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    background: #0A0A0F;
    color: #C0F0FF;
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(0.85rem, 1.8vw, 1.1rem);
    font-weight: 400;
    line-height: 1.7;
    letter-spacing: 0.05em;
    scroll-behavior: smooth;
}

/* --- Scanline Overlay --- */
#scanline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        transparent 0px,
        transparent 2px,
        #1A1A2E 2px,
        #1A1A2E 4px
    );
    opacity: 0.15;
}

/* --- Static Noise Overlay --- */
#noise-overlay {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    pointer-events: none;
    z-index: 9998;
    opacity: 0.04;
    background-image:
        radial-gradient(circle at 20% 30%, #C0F0FF 0.5px, transparent 0.5px),
        radial-gradient(circle at 80% 70%, #C0F0FF 0.5px, transparent 0.5px),
        radial-gradient(circle at 50% 10%, #C0F0FF 0.5px, transparent 0.5px),
        radial-gradient(circle at 10% 80%, #C0F0FF 0.5px, transparent 0.5px),
        radial-gradient(circle at 90% 40%, #C0F0FF 0.5px, transparent 0.5px),
        radial-gradient(circle at 40% 60%, #C0F0FF 0.5px, transparent 0.5px),
        radial-gradient(circle at 70% 20%, #C0F0FF 0.5px, transparent 0.5px),
        radial-gradient(circle at 30% 90%, #C0F0FF 0.5px, transparent 0.5px);
    background-size: 200px 200px, 180px 180px, 160px 160px, 220px 220px, 190px 190px, 170px 170px, 210px 210px, 150px 150px;
    animation: noiseShift 0.5s steps(5) infinite;
}

@keyframes noiseShift {
    0% { background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0; }
    20% { background-position: 10px -15px, -8px 12px, 5px 7px, -12px -3px, 15px 9px, -6px -11px, 8px 4px, -10px 13px; }
    40% { background-position: -5px 8px, 12px -6px, -9px 14px, 7px 10px, -3px -8px, 11px 5px, -7px -12px, 6px -9px; }
    60% { background-position: 13px 4px, -10px -9px, 8px -3px, -5px 15px, 11px -7px, -4px 12px, 9px -6px, -8px 10px; }
    80% { background-position: -7px -11px, 6px 8px, -12px 5px, 10px -10px, -8px 14px, 7px -4px, -11px 9px, 13px -5px; }
    100% { background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0; }
}

/* --- Layer Base --- */
.layer {
    min-height: 100vh;
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.layer-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    z-index: 2;
}

/* --- Fonts --- */
.glitch-text {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 700;
    position: relative;
}

.mono-text {
    font-family: 'Share Tech Mono', monospace;
}

.block-meta,
.status-tag {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

/* ===================================
   LAYER 0 - Signal Acquisition
   =================================== */
#layer-0 {
    background: #0A0A0F;
    z-index: 5;
}

/* Scanline sweep on Layer 0 */
#layer-0::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 4px,
        rgba(0, 240, 255, 0.03) 4px,
        rgba(0, 240, 255, 0.03) 5px
    );
    animation: scanSweep 4s linear infinite;
    pointer-events: none;
    z-index: 1;
}

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

#hero-title {
    font-size: clamp(2.5rem, 8vw, 8rem);
    color: #00F0FF;
    text-shadow:
        0 0 10px #00F0FF,
        0 0 40px #00F0FF,
        0 0 80px #00F0FF;
    text-align: center;
    margin-bottom: 1.5rem;
    opacity: 0;
    animation: heroReveal 0.4s ease-out 0.4s forwards;
}

#hero-title .char {
    display: inline-block;
    opacity: 0;
    animation: charAppear 0.2s ease-out forwards;
    animation-delay: calc(0.4s + var(--char-index) * 0.08s);
}

@keyframes charAppear {
    0% {
        opacity: 0;
        transform: translate(calc((var(--char-index) - 4) * 1px), calc((var(--char-index) - 4) * -1px));
        color: #FF0044;
    }
    50% {
        opacity: 1;
        color: #FF0044;
    }
    100% {
        opacity: 1;
        transform: translate(0, 0);
        color: #00F0FF;
    }
}

@keyframes heroReveal {
    to { opacity: 1; }
}

/* Chroma Split on glitch-text */
.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    font-family: inherit;
    font-weight: inherit;
    font-size: inherit;
    pointer-events: none;
    opacity: 0;
}

.glitch-text::before {
    color: #00F0FF;
    animation: chromaSplitLeft 5s ease-in-out infinite;
}

.glitch-text::after {
    color: #FF00FF;
    animation: chromaSplitRight 5s ease-in-out infinite;
}

@keyframes chromaSplitLeft {
    0%, 92%, 100% { opacity: 0; transform: translate(0, 0); }
    93% { opacity: 0.7; transform: translate(-2px, 1px); }
    95% { opacity: 0.5; transform: translate(-3px, -1px); }
    97% { opacity: 0; transform: translate(0, 0); }
}

@keyframes chromaSplitRight {
    0%, 92%, 100% { opacity: 0; transform: translate(0, 0); }
    93% { opacity: 0.7; transform: translate(2px, -1px); }
    95% { opacity: 0.5; transform: translate(3px, 1px); }
    97% { opacity: 0; transform: translate(0, 0); }
}

.terminal-prompt {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #39FF14;
    font-size: clamp(0.85rem, 1.8vw, 1.1rem);
    opacity: 0;
    animation: fadeIn 0.3s ease-out 1.8s forwards;
}

.prompt-symbol {
    color: #39FF14;
    font-weight: 700;
}

.blink-cursor {
    animation: blink 1s step-end infinite;
    color: #39FF14;
    font-size: 0.9em;
}

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

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

.system-status {
    margin-top: 2rem;
    opacity: 0;
    animation: fadeIn 0.3s ease-out 2.5s forwards;
}

.system-status .status-tag {
    color: #FFD700;
    font-size: 0.65rem;
}

/* Horizontal Tear */
.horizontal-tear {
    position: absolute;
    left: 0;
    width: 100%;
    height: 4px;
    background: #FF0044;
    z-index: 10;
    opacity: 0;
    top: 50%;
    transform: translateX(6px);
    animation: tearFlash 4s ease-in-out infinite;
}

@keyframes tearFlash {
    0%, 95%, 100% { opacity: 0; clip-path: inset(0 0 0 0); }
    96% { opacity: 1; clip-path: inset(0 0 0 0); transform: translateX(6px); }
    97% { opacity: 1; transform: translateX(-4px); }
    98% { opacity: 0; transform: translateX(6px); }
}

/* ===================================
   LAYER 1 - City Grid
   =================================== */
#layer-1 {
    background: #0A0A0F;
    padding: 2rem;
}

#layer-1 .layer-content {
    max-width: 1400px;
    width: 100%;
}

.city-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    width: 100%;
    margin-bottom: 2rem;
}

.grid-block {
    border: 1px solid var(--neon);
    background: rgba(10, 10, 15, 0.85);
    box-shadow: inset 0 0 20px rgba(0, 240, 255, 0.05);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    min-height: 80px;
    cursor: default;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    opacity: 0;
    transform: translateY(40px) scale(0.9);
}

.grid-block.span-2 {
    grid-column: span 2;
}

.grid-block.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: opacity 0.5s ease, transform 0.5s ease;
    transition-delay: var(--delay);
}

.grid-block:hover {
    transform: skewX(2deg);
    box-shadow:
        inset 0 0 30px rgba(0, 240, 255, 0.1),
        0 0 20px var(--neon);
    animation: borderCycle 0.3s steps(3) infinite;
}

@keyframes borderCycle {
    0% { border-color: #00F0FF; }
    33% { border-color: #FF00FF; }
    66% { border-color: #39FF14; }
    100% { border-color: #FF0044; }
}

.block-label {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 700;
    font-size: clamp(0.7rem, 1.5vw, 1rem);
    color: var(--neon);
    text-shadow: 0 0 8px var(--neon);
    text-align: center;
}

.block-meta {
    color: #FF00FF;
    text-align: center;
}

.grid-status {
    justify-content: center;
}

/* ===================================
   LAYER 2 - Data Stream
   =================================== */
#layer-2 {
    background: #0A0A0F;
    min-height: 100vh;
}

.data-columns {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-around;
    overflow: hidden;
    z-index: 1;
}

.data-column {
    width: 18%;
    overflow: hidden;
    position: relative;
}

.data-stream-text {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.75rem;
    line-height: 2;
    color: #39FF14;
    opacity: 0.35;
    white-space: nowrap;
    animation: dataScroll var(--speed) linear infinite;
    transform: translateY(var(--offset));
}

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

/* CRT Window */
.crt-window {
    position: relative;
    z-index: 3;
    width: min(80%, 700px);
    margin: 0 auto;
}

.crt-screen {
    border: 2px solid #00F0FF;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    background: rgba(10, 10, 15, 0.95);
    box-shadow:
        0 0 15px rgba(0, 240, 255, 0.3),
        0 0 40px rgba(0, 240, 255, 0.1),
        inset 0 0 30px rgba(0, 240, 255, 0.05);
}

.crt-curvature {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.4) 100%);
    pointer-events: none;
    z-index: 2;
}

.crt-content {
    padding: 2rem 2.5rem;
    position: relative;
    z-index: 1;
}

.transmission-header {
    color: #FFD700;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
}

.transmission-body {
    color: #C0F0FF;
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(0.85rem, 1.6vw, 1rem);
    line-height: 1.8;
    margin-bottom: 1.5rem;
}

.transmission-footer {
    color: #39FF14;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.crt-content .blink-cursor {
    display: inline-block;
    margin-top: 0.5rem;
    color: #00F0FF;
}

/* ===================================
   LAYER 3 - Interference
   =================================== */
#layer-3 {
    background: #0A0A0F;
}

.interference-content {
    gap: 2rem;
    max-width: 900px;
}

.corrupt-title {
    font-size: clamp(2rem, 6vw, 5rem);
    color: #FF0044;
    text-shadow:
        0 0 10px #FF0044,
        0 0 40px #FF0044,
        0 0 80px #FF0044;
    text-align: center;
}

.corrupt-title .char {
    display: inline-block;
    opacity: 0;
}

.layer.active .corrupt-title .char {
    animation: corruptCharAppear 0.2s ease-out forwards;
    animation-delay: calc(var(--char-index) * 0.05s);
}

@keyframes corruptCharAppear {
    0% {
        opacity: 0;
        transform: translate(calc((var(--char-index) - 6) * 2px), calc((var(--char-index) - 6) * -2px));
        color: #00F0FF;
    }
    50% {
        opacity: 1;
        color: #FFD700;
    }
    100% {
        opacity: 1;
        transform: translate(0, 0);
        color: #FF0044;
    }
}

.corrupt-fragment {
    width: 100%;
    padding: 1rem 1.5rem;
    border-left: 3px solid #FF0044;
    background: rgba(255, 0, 68, 0.05);
    opacity: 0;
    transform: translateX(-20px);
}

.layer.active .corrupt-fragment {
    animation: fragmentSlide 0.4s ease-out forwards;
}

.layer.active .fragment-1 { animation-delay: 0.3s; }
.layer.active .fragment-2 { animation-delay: 0.5s; }
.layer.active .fragment-3 { animation-delay: 0.7s; }
.layer.active .fragment-4 { animation-delay: 0.9s; }
.layer.active .fragment-5 { animation-delay: 1.1s; }

@keyframes fragmentSlide {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.corrupt-text {
    font-family: 'Share Tech Mono', monospace;
    color: #C0F0FF;
    font-size: clamp(0.8rem, 1.5vw, 1rem);
}

.corrupt-text.hue-shift {
    animation: hueRotate 2s linear infinite;
}

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

.corrupt-text.letter-morph {
    animation: letterSpacing 1.5s ease-in-out infinite alternate;
}

@keyframes letterSpacing {
    0% { letter-spacing: 0.05em; }
    50% { letter-spacing: 0.3em; }
    100% { letter-spacing: 0.05em; }
}

.system-warning {
    text-align: center;
    margin-top: 2rem;
}

.warning-flash {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #FF0044;
    animation: warningPulse 0.8s ease-in-out infinite alternate;
}

@keyframes warningPulse {
    0% {
        opacity: 0.4;
        text-shadow: none;
    }
    100% {
        opacity: 1;
        text-shadow:
            0 0 10px #FF0044,
            0 0 30px #FF0044;
    }
}

/* Strobe Overlay for Layer 3 */
.strobe-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
}

.layer.active .strobe-overlay {
    animation: strobeEffect 6s ease-in-out infinite;
}

@keyframes strobeEffect {
    0%, 85%, 100% { opacity: 0; background: transparent; }
    86% { opacity: 0.06; background: #FF0044; }
    87% { opacity: 0; background: transparent; }
    88% { opacity: 0.04; background: #00F0FF; }
    89% { opacity: 0; background: transparent; }
    90% { opacity: 0.05; background: #FF00FF; }
    91% { opacity: 0; background: transparent; }
}

/* ===================================
   LAYER 4 - Resolution
   =================================== */
#layer-4 {
    background: #0B0B1A;
}

.resolution-content {
    align-items: center;
    gap: 2rem;
}

.resolution-title {
    font-size: clamp(4rem, 12vw, 10rem);
    color: #00F0FF;
    text-align: center;
    opacity: 0;
    animation: none;
}

.resolution-title .char {
    display: inline-block;
    opacity: 0;
}

.layer.active .resolution-title {
    opacity: 1;
    text-shadow:
        0 0 10px #00F0FF,
        0 0 40px #00F0FF,
        0 0 80px #00F0FF;
    animation: neonBreathe 4s ease-in-out infinite;
}

.layer.active .resolution-title .char {
    animation: resolutionCharAppear 0.3s ease-out forwards;
    animation-delay: calc(var(--char-index) * 0.06s);
}

@keyframes resolutionCharAppear {
    0% {
        opacity: 0;
        transform: translateY(10px);
        color: #FF0044;
    }
    60% {
        opacity: 1;
        color: #FF0044;
    }
    100% {
        opacity: 1;
        transform: translateY(0);
        color: #00F0FF;
    }
}

@keyframes neonBreathe {
    0%, 100% {
        text-shadow:
            0 0 10px #00F0FF,
            0 0 40px #00F0FF,
            0 0 80px #00F0FF;
    }
    50% {
        text-shadow:
            0 0 5px #00F0FF,
            0 0 20px #00F0FF,
            0 0 40px #00F0FF;
    }
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    opacity: 0;
}

.layer.active .connection-status {
    animation: fadeIn 0.5s ease-out 0.8s forwards;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #39FF14;
    box-shadow: 0 0 8px #39FF14, 0 0 16px #39FF14;
}

.status-text {
    color: #39FF14;
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    letter-spacing: 0.15em;
}

.resolution-meta {
    opacity: 0;
}

.layer.active .resolution-meta {
    animation: fadeIn 0.5s ease-out 1.2s forwards;
}

.resolution-meta .mono-text {
    font-size: 0.75rem;
    color: #FFD700;
    letter-spacing: 0.1em;
}

/* ===================================
   Responsive
   =================================== */
@media (max-width: 768px) {
    .city-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }

    .grid-block {
        min-height: 60px;
        padding: 0.5rem;
    }

    .grid-block.span-2 {
        grid-column: span 1;
    }

    .block-meta {
        font-size: 0.55rem;
    }

    .crt-content {
        padding: 1.2rem 1.5rem;
    }

    .data-column {
        width: 20%;
    }
}

@media (max-width: 480px) {
    .city-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .crt-window {
        width: 95%;
    }

    .crt-content {
        padding: 1rem;
    }
}
