@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap');

/* Base Styles */
:root {
    --brand-50: #f0f9ff;
    --brand-100: #e0f2fe;
    --brand-500: #0ea5e9;
    --brand-600: #0284c7;
}

.glass-nav {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.hero-bg {
    background-image: radial-gradient(circle at 15% 50%, rgba(14, 165, 233, 0.1), transparent 25%),
                      radial-gradient(circle at 85% 30%, rgba(14, 165, 233, 0.1), transparent 25%);
}

.hero-orb {
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    filter: blur(80px);
    z-index: 0;
    opacity: 0.3;
    pointer-events: none;
    animation: orbFloat 20s infinite alternate ease-in-out;
}

@keyframes orbFloat {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 30px) scale(1.1); }
}

/* Terminal Typing Effect */
.terminal-line {
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid transparent;
    width: 0;
}

.type-line-1 { animation: typing 0.8s steps(20) forwards 0.5s; }
.type-line-2 { animation: typing 1.2s steps(30) forwards 1.3s; }
.type-line-3 { animation: typing 0.8s steps(20) forwards 2.5s; }
.type-line-4 { animation: typing 0.8s steps(20) forwards 3.3s; }
.type-line-5 { animation: typing 0.4s steps(15) forwards 4.1s; }
.type-line-6 { animation: typing 0.4s steps(15) forwards 4.5s; }
.type-line-7 { animation: typing 0.4s steps(15) forwards 4.9s; }

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

/* Modern Button Styles for "View All" */
.btn-secondary {
    display: inline-flex;
    align-items: center;
    padding: 0.75rem 2rem;
    background: white;
    color: #475569;
    font-weight: 700;
    border: 1px solid #e2e8f0;
    border-radius: 9999px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-secondary:hover {
    color: #0ea5e9;
    border-color: #0ea5e9;
    background: #f0f9ff;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(14, 165, 233, 0.1);
}

.glass-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Dropdown Menu - Robust Implementation */
.dropdown-content {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translate(-50%, 10px);
    width: max-content; /* Width based on longest item */
    min-width: 140px; /* Base minimum width */
    background: white;
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 1.25rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    padding: 0.5rem;
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    pointer-events: none; /* Prevent interaction when hidden */
}

/* Bridge to prevent closing when moving mouse down */
.dropdown-content::before {
    content: '';
    position: absolute;
    top: -30px; /* Increased bridge height for safety */
    left: 0;
    width: 100%;
    height: 30px;
    background: transparent;
}

/* Show dropdown on hover */
.group:hover .dropdown-content {
    visibility: visible;
    opacity: 1;
    transform: translate(-50%, 0);
    pointer-events: auto;
    transition-delay: 0s;
}

/* Add a slight delay when leaving to make it feel more stable */
.group .dropdown-content {
    transition-delay: 0.1s;
}

.dropdown-item {
    display: flex;
    align-items: center;
    justify-content: center; /* Center text horizontally */
    padding: 0.75rem 1.25rem; /* Reduced horizontal padding for a tighter fit */
    color: #475569;
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: 0.75rem;
    transition: all 0.2s;
    white-space: nowrap;
    text-align: center;
    width: 100%; /* Ensure full width for centering */
}

.dropdown-item:hover {
    background-color: #f0f9ff;
    color: #0ea5e9;
    transform: scale(1.02);
}

/* Navbar Links */
.nav-link {
    color: #475569;
    padding: 0.5rem 1.25rem;
    border-radius: 9999px;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}
.nav-link:hover {
    color: #0ea5e9;
    background-color: rgba(14, 165, 233, 0.05);
}
.nav-link.active {
    color: #0ea5e9;
    background-color: #f0f9ff;
}

.nav-link-dropdown {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: #475569;
    padding: 0.5rem 1.25rem;
    border-radius: 9999px;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    background: transparent;
    border: none;
}
.nav-link-dropdown:hover {
    color: #0ea5e9;
    background-color: rgba(14, 165, 233, 0.05);
}
.nav-link-dropdown.active {
    color: #0ea5e9;
    background-color: #f0f9ff;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #f8fafc;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 100px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Card & Interactive Effects */
.card-hover-3d {
    transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
    perspective: 1000px;
}
.card-hover-3d:hover {
    transform: translateY(-12px) rotateX(2deg) rotateY(1deg);
    box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.15);
}

/* Scroll Reveal Animations */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s cubic-bezier(0.23, 1, 0.32, 1);
}
.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* Background Patterns */
.bg-grid-slate-100 {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' width='32' height='32' fill='none' stroke='rgb(241 245 249)'%3e%3cpath d='M0 .5H31.5V32'/%3e%3c/svg%3e");
}

/* Periodic Table Styles */
.periodic-table {
    display: grid;
    grid-template-columns: repeat(18, 1fr);
    gap: 6px;
    padding: 24px;
}

.element {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-size: 14px;
    border: 1px solid transparent;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.element:hover {
    transform: scale(1.25);
    z-index: 50;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border-color: rgba(255,255,255,0.5);
}

.alkali-metal { background: #fee2e2; color: #991b1b; }
.alkaline-earth { background: #ffedd5; color: #9a3412; }
.transition { background: #e0f2fe; color: #075985; }
.boron-group { background: #dcfce7; color: #166534; }
.carbon-group { background: #f0fdf4; color: #15803d; }
.nitrogen-group { background: #fef9c3; color: #854d0e; }
.oxygen-group { background: #fae8ff; color: #86198f; }
.halogen { background: #f3e8ff; color: #6b21a8; }
.noble-gas { background: #f1f5f9; color: #475569; }
.lanthanide-actinide { background: #ffe4e6; color: #be123c; }

.element.empty {
    pointer-events: none;
    background: transparent;
    box-shadow: none;
}

/* =========================================
   Mobile Optimization & Dark Mode Supplements
   ========================================= */

/* Mobile Bottom Drawer Menu (Overrides default dropdown) */
@media (max-width: 1024px) {
    #mobile-menu {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        max-height: 85vh !important;
        border-radius: 1.5rem 1.5rem 0 0;
        box-shadow: 0 -10px 40px -10px rgba(0, 0, 0, 0.2);
        z-index: 2000 !important;
        border-top: 1px solid rgba(226, 232, 240, 0.8);
        padding-bottom: env(safe-area-inset-bottom, 20px);
        transform-origin: bottom;
        
        /* Transition State */
        transform: translateY(100%);
        opacity: 0;
        visibility: hidden;
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
    }

    #mobile-menu.open {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }
    
    /* Ensure content is scrollable if needed */
    #mobile-menu > div {
        max-height: 80vh;
        overflow-y: auto;
    }
}

/* System Dark Mode Support (Brute Force Overrides) */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #0f172a !important; /* slate-900 */
        color: #f1f5f9 !important; /* slate-100 */
    }

    /* Override white backgrounds */
    .bg-white, .bg-slate-50 {
        background-color: #1e293b !important; /* slate-800 */
        border-color: #334155 !important; /* slate-700 */
    }
    
    .glass-nav {
        background: rgba(15, 23, 42, 0.85) !important;
        border-color: #334155 !important;
    }
    
    /* Text Colors */
    .text-slate-900, .text-slate-800, .text-gray-900 {
        color: #f8fafc !important; /* slate-50 */
    }
    
    .text-slate-600, .text-slate-500, .text-gray-600 {
        color: #cbd5e1 !important; /* slate-300 */
    }
    
    .text-slate-400 {
        color: #94a3b8 !important;
    }

    /* Cards and Borders */
    .border-slate-100, .border-slate-200 {
        border-color: #334155 !important;
    }
    
    .shadow-sm, .shadow-lg, .shadow-xl {
        box-shadow: none !important; /* Simplify shadows in dark mode */
    }
    
    /* Mobile Menu in Dark Mode */
    #mobile-menu {
        background-color: #1e293b !important;
        border-color: #334155 !important;
    }
    
    /* Inputs */
    input, textarea {
        background-color: #0f172a !important;
        color: white !important;
        border-color: #475569 !important;
    }
}
