:root {
    --bg-color: #050505;
    --term-green: #4af626; /* Color Hacker Principal */
    --term-amber: #ffb000;
    --text-dim: rgba(255, 255, 255, 0.7);
    --font-ui: 'Share Tech Mono', monospace;
    --font-header: 'VT323', monospace;
    --sidebar-bg: rgba(0, 0, 0, 0.85); /* Semitransparente para ver el 3D */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: var(--bg-color);
    color: var(--text-dim);
    font-family: 'IBM Plex Mono', monospace;
    height: 100vh; overflow: hidden;
}

/* --- 3D BACKGROUND --- */
#canvas-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1; /* Detrás de todo */
    opacity: 0.4; /* Sutil */
}

/* --- CRT EFFECTS --- */
.crt-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 900; }
.scanlines { background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06)); background-size: 100% 3px, 3px 100%; }
.vignette { background: radial-gradient(circle, rgba(0,0,0,0) 50%, rgba(0,0,0,0.9) 100%); }

/* --- UI ELEMENTS --- */
.hidden { display: none !important; }
#main-interface { height: 100vh; display: flex; flex-direction: column; opacity: 0; transition: opacity 1.5s; }

.top-bar {
    padding: 1rem; border-bottom: 1px solid rgba(74, 246, 38, 0.3);
    display: flex; justify-content: space-between;
    font-family: var(--font-ui); font-size: 0.8rem;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(5px);
}
.blink { animation: blink 2s infinite; color: var(--term-green); }

/* --- SIDEBAR & NAVIGATION --- */
.layout-grid { display: grid; grid-template-columns: 320px 1fr; height: 100%; overflow: hidden; }

#sidebar {
    border-right: 1px solid rgba(74, 246, 38, 0.2);
    padding: 2rem; overflow-y: auto;
    background: var(--sidebar-bg);
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease;
}

.nav-header { 
    font-family: var(--font-ui); color: var(--term-green); margin-bottom: 1.5rem; 
    display: flex; justify-content: space-between; align-items: center;
}
#close-sidebar { display: none; background: none; border: none; color: var(--term-green); font-size: 1.5rem; cursor: pointer; }

#chapter-list { list-style: none; padding-bottom: 3rem; }
#chapter-list li a {
    display: block; padding: 0.6rem 0;
    text-decoration: none; color: #888;
    font-family: var(--font-ui); font-size: 0.95rem;
    transition: 0.2s; border-left: 1px solid transparent; padding-left: 10px;
}
#chapter-list li a:hover, #chapter-list li a.active {
    color: #fff; text-shadow: 0 0 8px var(--term-green);
    border-left: 3px solid var(--term-green); padding-left: 15px; background: rgba(74, 246, 38, 0.05);
}

/* --- READER --- */
#reader {
    padding: 3rem 10% 8rem; 
    overflow-y: auto; scroll-behavior: smooth;
    position: relative;
}
#chapter-title {
    font-family: var(--font-header); font-size: 3.5rem; color: var(--term-green);
    margin-bottom: 2rem; line-height: 0.9;
    text-shadow: 4px 4px 0px rgba(0,0,0,0.5);
}
#chapter-body {
    font-size: 1.1rem; line-height: 1.8; max-width: 800px;
}
#chapter-body p { margin-bottom: 1.5rem; text-shadow: 0 1px 2px #000; }

/* --- ANIMACIONES SCROLL REVEAL --- */
.reveal-text {
    opacity: 0; transform: translateY(30px); filter: blur(5px);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal-text.visible { opacity: 1; transform: translateY(0); filter: blur(0); }

/* --- MOBILE MENU --- */
#mobile-menu-toggle {
    display: none; position: fixed; top: 10px; right: 10px; z-index: 950;
    background: #000; border: 1px solid var(--term-green); color: var(--term-green);
    padding: 0.5rem 1rem; font-family: var(--font-ui); cursor: pointer;
}

@media (max-width: 768px) {
    .layout-grid { grid-template-columns: 1fr; }
    
    #sidebar {
        position: fixed; top: 0; left: 0; width: 85%; height: 100%;
        z-index: 1000; transform: translateX(-100%); /* Oculto a la izquierda */
        box-shadow: 5px 0 20px rgba(0,0,0,0.8);
    }
    #sidebar.active { transform: translateX(0); /* Mostrar */ }
    
    #mobile-menu-toggle { display: block; }
    #close-sidebar { display: block; }
    #reader { padding: 2rem 1.5rem 6rem; }
    #chapter-title { font-size: 2.5rem; }
}

/* --- BOOT SCREEN --- */
#boot-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #000; z-index: 2000;
    display: flex; align-items: center; justify-content: center;
}
#init-btn {
    background: transparent; border: 1px solid var(--term-green); color: var(--term-green);
    padding: 1rem 2rem; font-family: var(--font-header); font-size: 1.5rem; cursor: pointer;
    transition: 0.3s; margin-top: 1rem;
}
#init-btn:hover { background: var(--term-green); color: #000; box-shadow: 0 0 20px var(--term-green); }

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }