:root {
    --bg-dark: #050505;
    --accent: #ff3333;
    --glass-heavy: rgba(10, 10, 10, 0.85);
    --glass-border: rgba(255, 255, 255, 0.15);
    --neon-glow: 0 0 15px rgba(255, 51, 51, 0.3);
}

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

body {
    background-color: var(--bg-dark);
    color: white;
    font-family: 'Rajdhani', sans-serif;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* --- NAVBAR MODERNA --- */
.ui-layer {
    position: fixed; inset: 0; pointer-events: none; z-index: 1000;
    display: flex; flex-direction: column; justify-content: space-between;
}

.glass-nav {
    pointer-events: auto;
    width: 90%; margin: 20px auto;
    height: 70px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 2rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.nav-brand { font-family: 'Michroma'; font-size: 1.2rem; display: flex; align-items: center; gap: 5px; }
.nav-brand .dot { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 10px var(--accent); }

.nav-links { display: flex; list-style: none; gap: 2rem; }
.nav-links li { 
    opacity: 0.7; cursor: pointer; transition: 0.3s; font-size: 0.9rem; letter-spacing: 1px; display: flex; gap: 8px; align-items: center;
}
.nav-links li:hover, .nav-links li.active { opacity: 1; color: var(--accent); text-shadow: 0 0 10px rgba(255,51,51,0.4); }

.nav-status { font-size: 0.8rem; border: 1px solid var(--accent); padding: 5px 15px; border-radius: 20px; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.live-icon { animation: blink 2s infinite; }

/* --- CONTROLES INFERIORES --- */
.controls-wrapper {
    pointer-events: auto; align-self: center; margin-bottom: 3rem;
    display: flex; align-items: center; gap: 2rem;
}
.nav-btn {
    background: transparent; border: 1px solid rgba(255,255,255,0.3);
    color: white; width: 50px; height: 50px; border-radius: 50%;
    cursor: pointer; transition: 0.3s; display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.nav-btn:hover { background: white; color: black; border-color: white; transform: scale(1.1); }
.pagination { display: flex; gap: 8px; }
.page-dot { width: 8px; height: 8px; background: rgba(255,255,255,0.3); border-radius: 50%; transition: 0.3s; }
.page-dot.active { background: var(--accent); transform: scale(1.2); }

/* --- SWITCH DE CLIMA --- */
.weather-control {
    display: flex; align-items: center; gap: 10px; margin-right: 20px;
    font-family: 'Rajdhani'; font-weight: 700; color: white;
}
#weather-label { font-size: 0.9rem; letter-spacing: 1px; width: 60px; text-align: right; transition: color 0.3s; }
.switch { position: relative; display: inline-block; width: 50px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; inset: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s; border-radius: 34px; border: 1px solid rgba(255,255,255,0.3);
}
.slider:before {
    position: absolute; content: ""; height: 16px; width: 16px;
    left: 4px; bottom: 3px; background-color: white;
    transition: .4s; border-radius: 50%;
}
input:checked + .slider { background-color: #555; border-color: #777; }
input:checked + .slider:before { transform: translateX(26px); }


/* --- EFEITOS GLOBAIS --- */
#rain-drops-canvas { position: fixed; inset: 0; z-index: 60; pointer-events: none; mix-blend-mode: screen; transition: opacity 1.5s; }
.vignette { position: fixed; inset: 0; z-index: 55; background: radial-gradient(circle, transparent 60%, black 100%); pointer-events: none; }
.noise-overlay { position: fixed; inset: 0; z-index: 58; background: url('https://grainy-gradients.vercel.app/noise.svg'); opacity: 0.05; pointer-events: none; }
#global-flash { position: fixed; inset: 0; z-index: 90; background: white; opacity: 0; pointer-events: none; mix-blend-mode: overlay; transition: opacity 0.1s; }

/* --- 3D STAGE --- */
.stage-3d { perspective: 1200px; height: 100vh; width: 100vw; overflow: hidden; background: #080808; }
.parallax-group { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 0.1s ease-out; }
.layer { position: absolute; inset: -10%; background-size: cover; background-position: center bottom; background-repeat: no-repeat; transition: filter 1.5s; }

/* AJUSTES DE CENARIO */
.layer-bg { transform: translateZ(-600px) scale(1.4); background-image: url('imagens/city-cima-3.jpg'); z-index: 1; filter: brightness(0.7); }
.layer-clouds { transform: translateZ(-400px) scale(0.9); background-image: url('imagens/nuvens.png'); opacity: 0.2; z-index: 2; animation: moveClouds 50s linear infinite; }
.layer-street { 
    transform: translateZ(0px); 
    top: 55%; 
    background-image: url('imagens/city-baixo-2.png');
    z-index: 5; 
}

#rain-floor-canvas {
    position: absolute; bottom: 0; left: 0; width: 100%; height: 50%; 
    pointer-events: none; opacity: 0.8; mix-blend-mode: screen; transition: opacity 1.5s;
}

/* --- CORREÇÃO NEBLINA (FOG) --- */
.fog-layer {
    position: absolute; bottom: 0; left: 0; width: 100%; height: 100%; /* Ocupa toda a camada da rua */
    background: url('https://raw.githubusercontent.com/danielstuart14/CSS_FOG_ANIMATION/master/fog1.png') repeat-x;
    
    /* CORREÇÃO: Força a neblina a cobrir a altura total para não parecer um quadrado flutuante */
    background-size: 200% 100%; 
    background-position: 0 bottom;
    
    opacity: 0;
    transition: opacity 1.5s ease;
    z-index: 15;
    pointer-events: none;
    mix-blend-mode: screen;

    /* CORREÇÃO: Máscara para suavizar as bordas de cima e baixo, evitando corte seco */
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 20%, black 80%, transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, black 20%, black 80%, transparent 100%);
}

body.fog-mode .fog-layer {
    opacity: 0.7;
    animation: fogMove 60s linear infinite;
}
body.fog-mode #rain-drops-canvas,
body.fog-mode #rain-floor-canvas {
    opacity: 0; 
}
body.fog-mode .layer-bg {
    filter: brightness(0.4) blur(3px);
}

@keyframes fogMove { 0% { background-position: 0 bottom; } 100% { background-position: -200% bottom; } }


.layer-cars {
    position: absolute; inset: 0; z-index: 20; pointer-events: none;
    display: flex; justify-content: center; align-items: center;
    transform: translateZ(80px); 
}

/* CARROS */
.car-item {
    position: absolute; width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: flex-end;
    padding-bottom: 15vh; 
    opacity: 0; 
    transform: translateX(800px) scale(0.95); 
    pointer-events: none;
    transition: all 0.8s cubic-bezier(0.215, 0.610, 0.355, 1.000);
}

.car-item.active { 
    opacity: 1; 
    transform: translateX(0) scale(1); 
    pointer-events: auto; 
}

/* FUMAÇA */
.tire-smoke {
    position: absolute;
    bottom: 15%;
    width: 150px; height: 80px;
    background: radial-gradient(circle, rgba(220,220,220,0.8) 0%, rgba(255, 255, 255, 0.396) 60%);
    filter: blur(20px);
    opacity: 0;
    transform: scale(0.5);
    pointer-events: none;
    z-index: 5;
    mix-blend-mode: screen;
}
.smoke-left { left: 25%; }
.smoke-right { right: 25%; }
.car-item.active .trigger-smoke {
    animation: smokePuffAnimation 1s ease-out forwards;
}

@keyframes smokePuffAnimation {
    0% { opacity: 0; transform: scale(0.5) translateY(0) translateX(0); }
    10% { opacity: 0.7; transform: scale(1) translateY(-20px); }
    100% { opacity: 0; transform: scale(2.5) translateY(-50px) translateX(-30px); }
}

/* --- CORREÇÃO REFLEXO --- */
/* --- CORREÇÃO REFLEXO: Agora visível em superfícies escuras --- */
.reflection-wrapper {
    position: absolute; 
    top: 100%; 
    left: 30%; 
    width: 100%; 
    height: 60%; 
    
    /* Ajuste de Posição: 
       translateY(-20%): Puxa o reflexo para cima para colar nos pneus.
       scaleY(-1): Inverte a imagem de cabeça para baixo.
    */
    transform: translateY(-90%) scaleY(-1); 
    
    /* MUDANÇA PRINCIPAL: */
    opacity: 0.2; /* Transparência manual */
    mix-blend-mode: normal; /* Removido o 'screen' para que o preto apareça */
    z-index: 1;
    
    /* Máscara: O topo (pneus) é visível, o resto vai sumindo */
    -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 0%, transparent 70%);
    mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 0%, transparent 70%);
    
    /* Filtro para dar aspecto de chão molhado/desfocado */
    filter: url(#water-turbulence) blur(1px); 
    pointer-events: none;
}

/* INFO CARDS */
.info-card {
    position: absolute; top: 45%; transform: translateY(-40%);
    width: 350px; z-index: 200; 
    opacity: 0; transition: all 0.5s ease;
}
.info-card.right { right: 12%; text-align: right; }
.info-card.left { left: 12%; text-align: left; }

.car-item.active .info-card { opacity: 1; transform: translateY(-50%); transition-delay: 0.2s; }

.card-glass-bg {
    position: absolute; inset: 0; background: var(--glass-heavy);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    transform: skewX(-10deg); 
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.card-content { position: relative; z-index: 2; padding: 2rem; color: white; transform: skewX(0); }

.card-header h2 {
    font-family: 'Michroma'; font-size: 2.8rem; line-height: 1; margin: 5px 0;
    background: linear-gradient(to bottom, #fff, #aaa); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.card-header h3 { font-family: 'Rajdhani'; color: var(--accent); letter-spacing: 4px; font-weight: 700; margin-bottom: 20px; }
.brand-tag { font-size: 0.7rem; color: #888; letter-spacing: 2px; text-transform: uppercase; }

.stat-row { display: flex; justify-content: space-between; margin-top: 20px; border-top: 1px solid rgba(255,255,255,0.1); padding-top: 15px; }
.stat { display: flex; flex-direction: column; }
.stat .val { font-family: 'Michroma'; font-size: 1.1rem; }
.stat .lbl { font-size: 0.7rem; color: #888; margin-top: 3px; }

.action-btn {
    margin-top: 25px; width: 100%; padding: 12px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.2);
    color: white; font-family: 'Rajdhani'; font-weight: 700; cursor: pointer; display: flex; justify-content: center; align-items: center; gap: 10px; transition: 0.3s;
}
.action-btn:hover { background: var(--accent); border-color: var(--accent); box-shadow: var(--neon-glow); }

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes moveClouds { from { background-position: 0 bottom; } to { background-position: 1000px bottom; } }


/* --- CAMADA DE RUÍDO (TV CHIADA) --- */
.static-noise {
    position: fixed; inset: 0; z-index: 9998;
    background-image: url('https://raw.githubusercontent.com/s1mpson/CSS-Glitch-Effect/master/img/noise.png'); /* Textura de ruído */
    opacity: 0; pointer-events: none;
    mix-blend-mode: overlay;
}

/* --- CLASSE ATIVADA PELO JS --- */
body.system-failure {
    overflow: hidden; /* Trava rolagem */
    animation: shutdown-sequence 2.5s forwards ease-in-out;
}

body.system-failure .static-noise {
    animation: noise-buildup 2.5s forwards;
}

/* --- O EFEITO VAI NA DIV PRINCIPAL PARA NÃO TREMER O MENU --- */
body.system-failure .stage-3d {
    animation: glitch-skew 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both infinite;
    filter: contrast(1.5) brightness(1.2); /* Aumenta contraste antes de apagar */
}

body.system-failure .ui-layer {
    filter: blur(2px) grayscale(1); /* Interface perde foco */
    transition: filter 0.5s;
}

/* --- ANIMAÇÕES --- */

/* 1. Escurecimento Dramático (Luz falhando) */
@keyframes shutdown-sequence {
    0% { background: var(--bg-dark); filter: brightness(1); }
    10% { filter: brightness(1.5) sepia(1); } /* Clarão de curto */
    20% { filter: brightness(0.6); } /* Queda de energia */
    30% { filter: brightness(1.1); } /* Tenta voltar */
    40% { filter: brightness(0.2) grayscale(1); } /* Morrendo */
    50% { filter: brightness(0.4); } /* Último suspiro */
    100% { filter: brightness(0); background: black; } /* Breu total */
}

/* 2. Ruído aumentando */
@keyframes noise-buildup {
    0% { opacity: 0; }
    30% { opacity: 0.3; }
    80% { opacity: 0.8; }
    100% { opacity: 1; background-color: black; }
}

/* 3. Glitch Geométrico (Tremor lateral e corte) */
@keyframes glitch-skew {
    0% { transform: translate(0); }
    20% { transform: translate(-5px, 5px); }
    40% { transform: translate(-5px, -5px); }
    60% { transform: translate(5px, 5px); }
    80% { transform: translate(5px, -5px); }
    100% { transform: translate(0); }
}

/* Efeito extra: Separação de cores (RGB Split) nos carros durante o glitch */
body.system-failure .car-visual img {
    animation: chromatic-aberration 0.2s infinite;
}

@keyframes chromatic-aberration {
    0% { text-shadow: none; }
    50% { 
        filter: drop-shadow(4px 0 0 red) drop-shadow(-4px 0 0 cyan);
        opacity: 0.8;
    }
    100% { text-shadow: none; }
}