/* General Body & Typography */
body { 
    background: #020617; 
    color: #94a3b8; 
    font-family: 'Fira Code', monospace; 
    overflow-x: hidden; 
}
h1, h2, h3 { 
    font-family: 'Cinzel', serif; 
}

/* Background Canvas - Forced to background layer */
#bg-canvas { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    z-index: -100 !important; 
    opacity: 0.3; 
    pointer-events: none !important;
}

/* Primary Content Layering */
main {
    position: relative;
    z-index: 20;
}

/* Navigation Base */
.dropdown { 
    position: relative; 
}

/* Add animated underline to nav links */
nav ul > li > a {
    position: relative;
}
nav ul > li > a::after {
    content: '';
    position: absolute;
    bottom: 1rem;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: #38bdf8;
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.3s ease-out;
}
nav ul > li > a:hover::after {
    transform: scaleX(1);
}

/* Dropdown Styles */
.dropdown-menu { 
    display: none; 
    position: absolute; 
    top: 100%; 
    left: 50%; 
    transform: translateX(-50%); 
    z-index: 100; 
    padding-top: 10px; 
}
.dropdown:hover .dropdown-menu { 
    display: block; 
    animation: navFade 0.2s ease-out; 
}
.dropdown.mobile-open .dropdown-menu { 
    display: block; 
}
@keyframes navFade { 
    from { opacity: 0; transform: translateX(-50%) translateY(5px); } 
    to { opacity: 1; transform: translateX(-50%) translateY(0); } 
}

/* Mobile Menu Control */
.mobile-menu { 
    display: none; 
}

@media (max-width: 768px) {
    nav ul { 
        display: none; 
    }
    
    nav ul.mobile-open { 
        display: flex !important; 
        flex-direction: column; 
        position: absolute; 
        top: 100%; 
        left: 0; 
        right: 0; 
        background: rgba(2,6,23,0.95); 
        backdrop-filter: blur(10px); 
        border-bottom: 1px solid rgba(56,189,248,0.2); 
        padding: 1rem; 
        gap: 0; 
    }
    
    nav ul.mobile-open li { 
        width: 100%; 
        border-bottom: 1px solid rgba(56,189,248,0.1); 
        padding: 0.5rem 0; 
    }
    
    nav ul.mobile-open li:last-child { 
        border-bottom: none; 
    }
    
    nav ul.mobile-open .dropdown-menu { 
        position: static; 
        display: none; 
        width: 100%;
    }
    
    nav ul.mobile-open .dropdown.mobile-open .dropdown-menu { 
        display: block; 
        padding-left: 1rem; 
        padding-top: 0.5rem; 
        margin-top: 0.5rem; 
    }
    
    .mobile-menu { 
        display: block; 
    }
    
    #bg-canvas { 
        opacity: 0.2; 
    }
}

/* Improved #nav-menu support (for ID-based JS) */
#nav-menu {
    display: none;           /* Hidden on mobile by default */
}

@media (min-width: 768px) {
    #nav-menu {
        display: flex !important;   /* Show on desktop */
    }
}

#nav-menu.mobile-open {
    display: flex !important;
    flex-direction: column;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    background: rgb(15 23 42);
    padding: 2rem 1.5rem;
    border-top: 1px solid rgb(51 65 85);
    z-index: 40;
    gap: 1rem;
}

#nav-menu.mobile-open .dropdown-menu {
    position: static;
    width: 100%;
    transform: none;
    margin-top: 1rem;
    display: none;
}

#nav-menu.mobile-open .dropdown.mobile-open .dropdown-menu {
    display: block;
}

.dropdown.mobile-open > a i {
    transform: rotate(180deg);
}

/* Desktop Dropdown Explicit View Activation */
.dropdown:hover .dropdown-menu {
    display: block;
}

/* --- Index Page Specific --- */
/* Hero Game Canvas */
#gameCanvas { 
    background: #000; 
    border: 2px solid #0ea5e9; 
}
.animate-glow { 
    animation: glow 1.5s ease-in-out infinite alternate; 
}
@keyframes glow { 
    from { text-shadow: 0 0 5px #0ea5e9; } 
    to { text-shadow: 0 0 20px #0ea5e9; } 
}

/* Skill Card */
.skill { 
    background: rgba(15,23,42,0.6); 
    backdrop-filter: blur(10px); 
    border: 1px solid rgba(56,189,248,0.2); 
    padding: 1.5rem; 
    border-radius: 0.75rem; 
    text-align: center; 
    transition: transform 0.3s, box-shadow 0.3s;
}
.skill:hover { 
    transform: translateY(-5px); 
    box-shadow: 0 0 20px rgba(14,165,233,0.5); 
}

/* Hero Section */
.hero-header {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: 5rem;
    padding-bottom: 5rem;
    text-align: center;
    z-index: 10;
}
.hero-title {
    font-size: 3rem;
    line-height: 1;
    color: #38bdf8;
    margin-bottom: 1rem;
}
@media (min-width: 768px) { 
    .hero-title { font-size: 4.5rem; } 
}
.hero-subtitle {
    font-size: 1.25rem;
    color: #94a3b8;
    margin-bottom: 3rem;
}

/* Skills Section */
.skills-section {
    width: 100%;
    padding: 4rem 1.5rem;
    background-color: rgba(15, 23, 42, 0.8);
    position: relative;
    z-index: 10;
}
.skills-grid {
    max-width: 64rem;
    margin-left: auto;
    margin-right: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2rem;
}
@media (min-width: 768px) { 
    .skills-grid { 
        grid-template-columns: repeat(4, minmax(0, 1fr)); 
    } 
}

/* --- About Page Specific --- */
/* CRT Scanline */
.scanline {
    width: 100%; 
    height: 100px; 
    z-index: 5;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0) 0%, rgba(14, 165, 233, 0.05) 50%, rgba(0, 0, 0, 0) 100%);
    opacity: 0.1; 
    position: fixed; 
    bottom: 100%;
    pointer-events: none; 
    animation: scanline 8s linear infinite;
}
@keyframes scanline { 
    0% { bottom: 100%; } 
    100% { bottom: -100%; } 
}

/* Typewriter Cursor */
.cursor { 
    display: inline-block; 
    width: 10px; 
    height: 1.2em; 
    background: #0ea5e9; 
    margin-left: 5px; 
    animation: blink 0.8s infinite; 
    vertical-align: middle; 
}
@keyframes blink { 
    50% { opacity: 0; } 
}

/* Reveal Animation */
.reveal { 
    opacity: 0; 
    transform: translateY(30px); 
    transition: all 1s ease-out; 
}
.reveal.active { 
    opacity: 1; 
    transform: translateY(0); 
}
.glass-panel {
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(56, 189, 248, 0.1);
    transition: all 0.4s ease;
}
.glass-panel:hover { 
    border-color: rgba(56, 189, 248, 0.4); 
    box-shadow: 0 0 30px rgba(14, 165, 233, 0.1); 
}
.glow-text { 
    color: #fff; 
    text-shadow: 0 0 10px rgba(14, 165, 233, 0.8); 
}

/* --- Contact Page Specific --- */
/* Text Glitch Animation */
.glitch { 
    position: relative; 
    color: #fff; 
    animation: glitch-skew 1s infinite alternate-reverse; 
}
.glitch::before { 
    content: attr(data-text); 
    position: absolute; 
    left: 2px; 
    text-shadow: -2px 0 #0ea5e9; 
    clip: rect(44px, 450px, 56px, 0); 
    animation: glitch-anim 5s infinite linear alternate-reverse; 
}
@keyframes glitch-anim { 
    0% { clip: rect(31px, 9999px, 94px, 0); } 
    100% { clip: rect(2px, 9999px, 86px, 0); } 
}

/* Advanced Map HUD Effects */
.map-wrapper { 
    position: relative; 
    overflow: hidden; 
    border-radius: 1rem; 
    border: 1px solid #1e293b; 
}
.map-container {
    filter: grayscale(1) invert(0.9) brightness(0.8) contrast(1.2);
    transition: all 0.7s cubic-bezier(0.4, 0, 0.2, 1);
    height: 450px;
}
.map-wrapper:hover .map-container {
    filter: grayscale(0) invert(0) brightness(1) contrast(1);
}

/* HUD Scanner Line */
.scanner-line {
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 2px;
    background: rgba(14, 165, 233, 0.6);
    box-shadow: 0 0 15px #0ea5e9;
    z-index: 20; 
    pointer-events: none;
    animation: scan 4s linear infinite;
}
@keyframes scan { 
    0% { top: 0%; } 
    100% { top: 100%; } 
}

/* Targeting Reticles */
.reticle { 
    position: absolute; 
    width: 30px; 
    height: 30px; 
    border-color: #0ea5e9; 
    border-width: 2px; 
    z-index: 30; 
    pointer-events: none; 
    opacity: 0.5; 
}
.tl { top: 20px; left: 20px; border-right: 0; border-bottom: 0; }
.tr { top: 20px; right: 20px; border-left: 0; border-bottom: 0; }
.bl { bottom: 20px; left: 20px; border-right: 0; border-top: 0; }
.br { bottom: 20px; right: 20px; border-left: 0; border-top: 0; }

.contact-card { 
    background: rgba(15, 23, 42, 0.7); 
    backdrop-filter: blur(10px); 
    border: 1px solid rgba(56, 189, 248, 0.1); 
}

/* Elevated Interaction Targets */
nav a {
    position: relative;
    z-index: 60 !important;
    pointer-events: auto !important;
}

nav ul {
    position: relative;
    z-index: 50 !important;
}