/* ==========================================================================
   1. MASTER CONFIGURATION (THEME & VARIABLES)
   ========================================================================== */
:root {
    /* --- Deep Space Chemistry Background --- */
    --bg-dark: #02040a;
    --bg-gradient: radial-gradient(circle at 50% 0%, #0b111a 0%, #02040a 100%);
    
    /* --- Glass Surface (The "Premium" Look) --- */
    --glass-bg: rgba(20, 25, 40, 0.65);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.12);
    --glass-blur: blur(24px) saturate(180%);
    --glass-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
    
    /* --- Card Specifics (Dark Neumorphism) --- */
    --bg-card-outer: #0b0f19;
    --bg-card-inner: #111827;
    
    /* --- Energy Colors (Emerald/Cyan for Chemistry) --- */
    --accent-primary: #10b981; /* Emerald */
    --accent-glow: #34d399;
    --accent-cyan: #06b6d4;
    
    /* --- Typography --- */
    --font-main: 'Poppins', sans-serif;
    --text-heading: #ffffff;
    --text-body: #cbd5e1;
    --text-muted: #94a3b8;
}

/* ==========================================================================
   2. GLOBAL RESET & SMOOTHNESS
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Removes blue tap highlight on mobile */
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-dark);
    background-image: var(--bg-gradient);
    color: var(--text-body);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.7;
    overscroll-behavior-y: none; /* Disables pull-to-refresh bounce on Android */
}

/* Custom Text Selection */
::selection {
    background-color: rgba(16, 185, 129, 0.3); /* Emerald tint */
    color: #ffffff;
    text-shadow: 0 0 5px rgba(0,0,0,0.5);
}

/* --- Premium Scrollbar --- */
::-webkit-scrollbar { 
    width: 6px; 
    height: 6px;
}
::-webkit-scrollbar-track { 
    background: var(--bg-dark); 
}
::-webkit-scrollbar-thumb { 
    background: #1e293b; 
    border-radius: 10px; 
    border: 1px solid var(--bg-dark);
}
::-webkit-scrollbar-thumb:hover { 
    background: var(--accent-primary); 
}

/* ==========================================================================
   3. BACKGROUND AMBIENCE (Alive Blobs)
   ========================================================================== */
.background-blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    animation: floatBlob 20s infinite alternate ease-in-out;
    will-change: transform;
}

/* Blobs positioned strategically */
.blob-1 { top: -10%; left: -10%; width: 50vw; height: 50vw; }
.blob-2 { bottom: -10%; right: -10%; width: 45vw; height: 45vw; animation-delay: -5s; }
.blob-3 { top: 40%; left: 30%; width: 30vw; height: 30vw; animation-delay: -10s; }

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

/* ==========================================================================
   4. GLASS COMPONENTS & HERO SHINE
   ========================================================================== */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-top: 1px solid var(--glass-highlight);
    box-shadow: var(--glass-shadow);
    position: relative;
}

/* Premium Shine effect on hover for the Hero Card */
.hero-card::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 50%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.03), transparent);
    transition: 0.7s ease-in-out;
    pointer-events: none;
    transform: skewX(-20deg);
}
.hero-card:hover::before { 
    left: 150%; 
}

/* ==========================================================================
   5. DYNAMIC SYLLABUS CARDS (Injected by app.js)
   ========================================================================== */
/* Main Category Accordion Container */
.section-card {
    background-color: var(--bg-card-outer);
    border: 1px solid var(--glass-border);
    transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}

.section-card.open {
    border-color: rgba(16, 185, 129, 0.2); /* Emerald glow border */
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.6);
}

/* Individual Formula/Topic Cards */
.formula-card {
    background-color: var(--bg-card-inner);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    /* Hardware acceleration for smooth mobile scrolling */
    will-change: transform, border-color, box-shadow; 
}

.formula-card:hover {
    border-color: rgba(16, 185, 129, 0.3);
    background-color: #162032;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(16, 185, 129, 0.1);
    transform: translateY(-2px);
}

/* ==========================================================================
   6. CATEGORY BADGES (Matching screenshot design)
   ========================================================================== */
.badge-red {
    color: #F87171;
    background-color: rgba(248, 113, 113, 0.08);
    border: 1px solid rgba(248, 113, 113, 0.2);
    box-shadow: 0 0 10px rgba(248, 113, 113, 0.05);
}

.badge-yellow {
    color: #FBBF24;
    background-color: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.2);
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.05);
}

.badge-blue {
    color: #60A5FA;
    background-color: rgba(96, 165, 250, 0.08);
    border: 1px solid rgba(96, 165, 250, 0.2);
    box-shadow: 0 0 10px rgba(96, 165, 250, 0.05);
}

/* ==========================================================================
   7. ADVANCED ACCORDION PHYSICS (CSS GRID TRICK)
   ========================================================================== */
/* Using CSS Grid avoids the jankiness of max-height transitions */
.accordion-wrapper {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.section-card.open .accordion-wrapper {
    grid-template-rows: 1fr;
}

.accordion-inner {
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Delay opacity fade-in until the accordion has started opening */
.section-card.open .accordion-inner {
    opacity: 1;
    transition-delay: 0.15s; 
}

/* Spring-loaded Caret Dropdown Icon */
.caret {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); /* Bouncy spring effect */
    transform-origin: center;
}

.section-card.open .caret {
    transform: rotate(180deg);
}

/* ==========================================================================
   8. TOAST NOTIFICATION SYSTEM
   ========================================================================== */
.toast {
    background: var(--bg-card-inner);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    animation: toastEnter 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    will-change: transform, opacity;
    pointer-events: auto;
}

.toast-exit {
    animation: toastExit 0.35s cubic-bezier(0.4, 0, 1, 1) forwards !important;
}

@keyframes toastEnter {
    0% { transform: translateY(150%) scale(0.85); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes toastExit {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(150%) scale(0.85); opacity: 0; }
}

/* ==========================================================================
   9. PRINT MEDIA OPTIMIZATION (THE "INK SAVER")
   ========================================================================== */
@media print {
    /* 1. Force white background and black text everywhere */
    html, body { 
        background-color: white !important; 
        background-image: none !important;
        color: black !important; 
        font-size: 11pt !important;
    }
    
    /* 2. Hide all non-essential UI elements */
    nav, 
    header, 
    #mobile-drawer, 
    #drawer-overlay, 
    footer, 
    .dev-card, 
    #toast-container,
    .background-blob { 
        display: none !important; 
    }
    
    /* 3. Strip dark backgrounds and shadows from cards */
    .bg-app-dark, .bg-card-dark, .bg-card-inner, .section-card, .formula-card, .glass-card { 
        background-color: white !important; 
        background: none !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    
    /* 4. Format Containers for A4 Paper */
    .section-card {
        border: none !important;
        margin-bottom: 2rem !important;
        page-break-inside: avoid;
    }

    .formula-card {
        border: 1px solid #d1d5db !important; /* Light gray border */
        border-radius: 6px !important;
        break-inside: avoid; /* Prevent formulas from splitting across pages */
        margin-bottom: 0.75rem !important;
        padding: 0.75rem !important;
        transform: none !important; /* Disable hover translates */
    }
    
    /* 5. Override Text Colors for max contrast */
    .text-emerald-400, .text-emerald-100, .text-white, .text-gray-200, .text-gray-400, h1, h2, h3, span { 
        color: black !important; 
        text-shadow: none !important;
        background: none !important;
        -webkit-text-fill-color: black !important;
    }

    .text-emerald-100 {
        font-weight: 700 !important; /* Make formulas bold on paper */
    }

    /* 6. Force Accordions to be completely open */
    .accordion-wrapper { 
        grid-template-rows: 1fr !important; 
        transition: none !important; /* Remove animations during print prep */
    }
    
    .accordion-inner { 
        opacity: 1 !important; 
        overflow: visible !important; 
        transition: none !important;
    }
    
    /* 7. Hide interactivity icons */
    .caret, ion-icon, svg, .group-hover\:opacity-100 { 
        display: none !important; 
    }

    /* 8. Standardize Margins */
    @page {
        margin: 1.5cm;
        size: auto;
    }
}
/* ==========================================================================
   10. PREMIUM FOOTER & STATUS DOT
   ========================================================================== */
.app-footer {
    margin-top: auto;
    border-top: 1px solid var(--glass-border);
    background: rgba(2, 4, 10, 0.6);
    backdrop-filter: blur(12px);
    padding: 3rem 1.5rem 1rem 1.5rem;
    position: relative;
    z-index: 10;
}

/* Glowing Pulsing Dot for Status */
.status-pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent-primary);
    border-radius: 50%;
    position: relative;
}

.status-pulse-dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    background-color: var(--accent-primary);
    border-radius: 50%;
    animation: statusPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes statusPulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(3);
        opacity: 0;
    }
}

/* Print Optimization for Footer */
@media print {
    .app-footer {
        display: none !important;
    }
}

/* ==========================================================================
   11. FLASHCARD MODE (ACTIVE RECALL)
   ========================================================================== */
/* Jab Flashcard Mode ON ho, tab formulas blur ho jayenge */
/* ==========================================================================
   11. FLASHCARD MODE (ACTIVE RECALL) - FIXED
   ========================================================================== */
/* Jab Flashcard Mode ON ho, tab formulas blur ho jayenge */
body.flashcard-mode .formula-text {
    filter: blur(6px) !important;
    opacity: 0.5 !important;
    cursor: pointer;
    user-select: none;
    transition: filter 0.3s ease, opacity 0.3s ease, text-shadow 0.3s ease;
}

/* Hover ya Touch (Tap) karne par formula reveal hoga */
body.flashcard-mode .formula-text:hover,
body.flashcard-mode .formula-text:active {
    filter: blur(0px) !important;
    opacity: 1 !important;
    text-shadow: 0 0 15px rgba(52, 211, 153, 0.5) !important;
}

/* Hint Watermark */
body.flashcard-mode .formula-card::after {
    content: 'Tap formula to reveal';
    position: absolute;
    top: 12px;
    right: 45px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-primary);
    opacity: 0.4;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

body.flashcard-mode .formula-card:hover::after,
body.flashcard-mode .formula-card:active::after {
    opacity: 0;
}
