/* NCERT eBook & Exemplar Performance Optimized CSS */
/* Critical CSS for above-the-fold content */

/* Base Performance Optimizations */
* {
    box-sizing: border-box;
}

.ncert-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* Critical Above-the-fold Styles */
.ncert-hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 60px 0;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.ncert-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="50" cy="50" r="1" fill="rgba(255,255,255,0.1)"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    opacity: 0.3;
}

.ncert-hero h1 {
    font-size: clamp(1.8rem, 4vw, 3rem);
    font-weight: 700;
    margin: 0 0 20px 0;
    line-height: 1.2;
    position: relative;
    z-index: 1;
}

.ncert-hero p {
    font-size: clamp(1rem, 2vw, 1.2rem);
    margin: 0 0 30px 0;
    opacity: 0.9;
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

/* Performance-optimized Grid */
.ncert-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin: 40px 0;
}

.ncert-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    padding: 30px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid #e1e5e9;
    position: relative;
    overflow: hidden;
}

.ncert-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.ncert-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

.ncert-card h3 {
    color: #2c3e50;
    font-size: 1.4rem;
    font-weight: 600;
    margin: 0 0 15px 0;
    line-height: 1.3;
}

.ncert-card p {
    color: #666;
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 0 0 20px 0;
}

/* Optimized Button Styles */
.ncert-btn {
    display: inline-flex;
    align-items: center;
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.ncert-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.ncert-btn:hover::before {
    left: 100%;
}

.ncert-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.ncert-btn-outline {
    background: transparent;
    border: 2px solid #667eea;
    color: #667eea;
}

.ncert-btn-outline:hover {
    background: #667eea;
    color: white;
}

/* Class Navigation */
.class-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    margin: 40px 0;
    padding: 30px;
    background: #f8f9fa;
    border-radius: 12px;
}

.class-nav-item {
    padding: 10px 20px;
    background: white;
    border: 2px solid #e1e5e9;
    border-radius: 25px;
    text-decoration: none;
    color: #495057;
    font-weight: 500;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.class-nav-item:hover,
.class-nav-item.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-2px);
}

/* Subject Grid */
.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.subject-item {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.subject-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.subject-item:hover::before {
    transform: scaleX(1);
}

.subject-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(0,0,0,0.1);
}

.subject-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
}

/* Chapter List Optimization */
.chapter-list {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin: 20px 0;
}

.chapter-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #f1f3f4;
    text-decoration: none;
    color: #333;
    transition: background-color 0.3s ease;
    position: relative;
}

.chapter-item:last-child {
    border-bottom: none;
}

.chapter-item:hover {
    background-color: #f8f9fa;
}

.chapter-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #667eea;
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.chapter-item:hover::before {
    transform: scaleY(1);
}

.chapter-number {
    background: #667eea;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    margin-right: 15px;
    flex-shrink: 0;
}

.chapter-title {
    flex: 1;
    font-weight: 500;
    line-height: 1.4;
}

/* Download Stats */
.download-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 40px 0;
    padding: 30px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
}

.stat-item {
    text-align: center;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: #667eea;
    display: block;
    margin-bottom: 5px;
}

.stat-label {
    color: #666;
    font-size: 0.9rem;
    font-weight: 500;
}

/* FAQ Section */
.faq-section {
    margin: 50px 0;
}

.faq-item {
    /* background: white; */
    /* border: 1px solid #e1e5e9; */
    border-radius: 8px;
    margin-bottom: 0;
    /* overflow: hidden; */
}

.faq-question {
    padding: 20px;
    background: #f8f9fa;
    cursor: pointer;
    font-weight: 600;
    color: #333;
    border: none;
    width: 100%;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.3s ease;
}

.faq-question:hover {
    background: #e9ecef;
}

.faq-answer {
    padding: 0 20px;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.faq-answer.active {
    padding: 20px;
    max-height: 200px;
}

.faq-icon {
    transition: transform 0.3s ease;
}

.faq-question.active .faq-icon {
    transform: rotate(180deg);
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .ncert-hero {
        padding: 40px 0;
    }
    
    .ncert-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        margin: 20px 0;
    }
    
    .ncert-card {
        padding: 20px;
    }
    
    .class-nav {
        gap: 10px;
        padding: 20px;
    }
    
    .class-nav-item {
        padding: 8px 16px;
        font-size: 0.8rem;
    }
    
    .subject-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 15px;
    }
    
    .download-stats {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 15px;
        padding: 20px;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
}

/* Performance Critical Styles */
.lazy-load {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lazy-load.loaded {
    opacity: 1;
}

/* Preload Critical Resources */
.preload-bg {
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1"><rect width="1" height="1" fill="%23f8f9fa"/></svg>');
}

/* Critical CSS for Core Web Vitals */
.ncert-content {
    contain: layout style paint;
}

.ncert-sidebar {
    contain: layout style;
}

/* Accessibility Improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus Styles for Accessibility */
.ncert-btn:focus,
.class-nav-item:focus,
.chapter-item:focus,
.faq-question:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .ncert-hero,
    .class-nav,
    .ncert-btn {
        display: none;
    }
    
    .ncert-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
