/**
 * NCERT Solutions - Professional Styles
 * Responsive, Modern, SEO-Optimized
 * 
 * Color Palette:
 * - Primary: #1e3a5f (Deep Blue)
 * - Secondary: #2c5282 (Medium Blue)
 * - Accent: #ed8936 (Orange)
 * - Success: #38a169 (Green)
 * - Background: #f8fafc (Light Gray)
 */

/* ========================================
   CSS Variables - NCERTBooks.net Brand Colors
   ======================================== */
:root {
    /* Primary - Purple gradient matching site header */
    --ncert-primary: #813588;
    --ncert-primary-light: #9b4f9f;
    --ncert-primary-dark: #2f1686;
    --ncert-secondary: #4a5568;
    /* Accent - Orange for CTAs */
    --ncert-accent: #ed8936;
    --ncert-accent-hover: #dd6b20;
    /* Status colors */
    --ncert-success: #48a87c;
    --ncert-warning: #e8a54b;
    --ncert-danger: #e85a5a;
    /* Backgrounds */
    --ncert-bg: #f5f5f5;
    --ncert-bg-alt: #eef2f6;
    /* Text */
    --ncert-text: #1f2937;
    --ncert-text-muted: #6b7280;
    --ncert-border: #e5e7eb;
    --ncert-white: #ffffff;
    /* Shadows */
    --ncert-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --ncert-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --ncert-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --ncert-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --ncert-radius: 12px;
    --ncert-radius-lg: 16px;
    --ncert-transition: all 0.3s ease;
    --font-display: 'Nunito', 'Segoe UI', system-ui, sans-serif;
    --font-body: 'Source Sans Pro', 'Segoe UI', system-ui, sans-serif;
}

/* ========================================
   Base Styles - Integrate with Theme Grid
   ======================================== */

/* 
 * The theme uses 3-column grid:
 * Left sidebar: 260px | Main content: 1fr | Right sidebar: 320px
 * NCERT templates use #primary.ncert-page to fit within this grid
 */

/* CRITICAL: Override theme's restrictive article styling for NCERT pages */
#primary.ncert-page,
.ncert-page,
.ncert-page article,
.ncert-page .site-main,
#primary.ncert-page article {
    max-width: 100% !important;
    width: 100% !important;
    flex: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: var(--ncert-bg) !important;
}

/* Main container - sits in middle column of grid */
#primary.ncert-page {
    background: var(--ncert-bg);
    margin: 0;
    padding: 0;
}

#primary.ncert-page .site-main {
    margin: 0;
    padding: 0;
}

/* Container for content sections - use full width of main column */
.ncert-container {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0;
    padding: 0 0.5rem;
    box-sizing: border-box;
}

/* Adjust section padding to fit within available space */
.ncert-section {
    padding: 2rem 0.5rem;
    width: 100% !important;
    box-sizing: border-box;
}

/* Cards grid - responsive within main column width */
.ncert-cards-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important;
    gap: 1rem !important;
    width: 100%;
}

.ncert-cards-grid--2cols {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)) !important;
}

.ncert-cards-grid--4cols {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)) !important;
}

/* 2-column grid on tablet and desktop (768px+) */
@media (min-width: 768px) {
    .ncert-cards-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .ncert-cards-grid--2cols {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .ncert-cards-grid--4cols {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ========================================
   Hero Section
   ======================================== */
.ncert-hero {
    /* Purple gradient matching NCERTBooks.net header */
    background: linear-gradient(45deg, #813588 0%, #2f1686 100%);
    padding: 2rem 1.5rem;
    position: relative;
    overflow: hidden;
    margin: 0;
    border-radius: 0;
    margin-bottom: 1.5rem;
}

.ncert-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.6;
}

.ncert-hero-content {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
}

.ncert-hero h1 {
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 5vw, 2.75rem);
    font-weight: 800;
    color: var(--ncert-white);
    margin: 0 0 1rem 0;
    line-height: 1.2;
}

.ncert-hero-subtitle {
    font-family: var(--font-body);
    font-size: 1.125rem;
    color: rgba(255, 255, 255, 0.9);
    margin: 0 0 1.5rem 0;
    line-height: 1.6;
}

.ncert-hero-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

.ncert-hero-stat {
    text-align: center;
}

.ncert-hero-stat-number {
    display: block;
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 800;
    color: var(--ncert-accent);
}

.ncert-hero-stat-label {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Trust Badges (E-E-A-T) */
.trust-badges {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.trust-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.15);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
}

.trust-badge svg {
    width: 18px;
    height: 18px;
    fill: var(--ncert-accent);
}

/* ========================================
   Feature Row (Above Cards)
   ======================================== */
.feature-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.feature-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    background: var(--ncert-white);
    padding: 1.25rem;
    border-radius: var(--ncert-radius);
    box-shadow: var(--ncert-shadow);
    border-left: 4px solid var(--ncert-accent);
}

.feature-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.feature-text h4 {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--ncert-text);
    margin: 0 0 0.25rem 0;
}

.feature-text p {
    font-size: 0.875rem;
    color: var(--ncert-text-muted);
    margin: 0;
    line-height: 1.5;
}

/* ========================================
   Section Styles
   ======================================== */
.ncert-section {
    padding: 3rem 1rem;
}

.ncert-section-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.ncert-section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 0.25rem 0;
    position: relative;
    display: inline-block;
}

.ncert-section-title::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 3px;
    background: #f59e0b;
    border-radius: 2px;
}

.ncert-section-subtitle {
    color: #6b7280;
    font-size: 0.875rem;
    margin: 0.5rem 0 0 0;
}

/* ========================================
   Cards Grid - Clean & Lightweight
   ======================================== */
.ncert-cards-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
}

.ncert-cards-grid--2cols {
    grid-template-columns: repeat(2, 1fr) !important;
}

.ncert-cards-grid--3cols {
    grid-template-columns: repeat(3, 1fr) !important;
}

.ncert-cards-grid--4cols {
    grid-template-columns: repeat(4, 1fr) !important;
}

/* Responsive grid */
@media (max-width: 600px) {
    .ncert-cards-grid,
    .ncert-cards-grid--2cols,
    .ncert-cards-grid--3cols,
    .ncert-cards-grid--4cols {
        grid-template-columns: 1fr !important;
        gap: 0.875rem !important;
    }
}

/* ========================================
   Card Component - Professional & Minimal
   ======================================== */
.ncert-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex !important;
    flex-direction: column !important;
    border: 1px solid #eaeef3;
    position: relative;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
}

.ncert-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

/* Card Header - Compact gradient header */
.ncert-card-header {
    position: relative;
    padding: 1rem 1rem 0.875rem;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

/* Subject Colors - Soft, professional gradients */
.ncert-card-header--maths { 
    background: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%); 
}
.ncert-card-header--science { 
    background: linear-gradient(135deg, #10b981 0%, #34d399 100%); 
}
.ncert-card-header--english { 
    background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%); 
}
.ncert-card-header--hindi { 
    background: linear-gradient(135deg, #ef4444 0%, #f87171 100%); 
}
.ncert-card-header--sanskrit { 
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%); 
}
.ncert-card-header--social { 
    background: linear-gradient(135deg, #06b6d4 0%, #22d3ee 100%); 
}
.ncert-card-header--physics { 
    background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%); 
}
.ncert-card-header--chemistry { 
    background: linear-gradient(135deg, #ec4899 0%, #f472b6 100%); 
}
.ncert-card-header--biology { 
    background: linear-gradient(135deg, #22c55e 0%, #4ade80 100%); 
}
.ncert-card-header--geography { 
    background: linear-gradient(135deg, #14b8a6 0%, #2dd4bf 100%); 
}
.ncert-card-header--history { 
    background: linear-gradient(135deg, #a16207 0%, #ca8a04 100%); 
}
.ncert-card-header--civics { 
    background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%); 
}

/* Card Icon - Clean circle */
.ncert-card-icon {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* Badge - Pill style */
.ncert-card-badge {
    background: rgba(255,255,255,0.95);
    color: #374151;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.3rem 0.6rem;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* Card Body - Clean spacing */
.ncert-card-body {
    padding: 1rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
}

/* Card Title - Bold, compact */
.ncert-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 0.375rem 0;
    line-height: 1.3;
}

.ncert-card-title a {
    color: inherit;
    text-decoration: none;
}

.ncert-card-title a:hover {
    color: #3b82f6;
}

/* Card Description - Subtle */
.ncert-card-description {
    font-size: 0.8125rem;
    color: #6b7280;
    line-height: 1.5;
    margin: 0 0 0.875rem 0;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Card Meta */
.ncert-card-meta {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.625rem;
    font-size: 0.75rem;
    color: #9ca3af;
}

.ncert-card-meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.ncert-card-meta-item svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
}

.ncert-card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--ncert-border);
    background: var(--ncert-bg);
}

/* ========================================
   Button Styles
   ======================================== */
/* ========================================
   Buttons - Clean & Professional
   ======================================== */
.ncert-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.625rem 1rem;
    border-radius: 8px;
    text-decoration: none !important;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    white-space: nowrap;
}

.ncert-btn-primary {
    background: #f59e0b;
    color: #fff !important;
}

.ncert-btn-primary:hover {
    background: #d97706;
    color: #fff !important;
    text-decoration: none !important;
}

.ncert-btn-accent {
    background: #3b82f6;
    color: #fff !important;
}

.ncert-btn-accent:hover {
    background: #2563eb;
}

.ncert-btn-outline {
    background: transparent;
    color: #3b82f6;
    border: 1.5px solid #3b82f6;
}

.ncert-btn-outline:hover {
    background: #3b82f6;
    color: #fff;
}

.ncert-btn-block {
    width: 100%;
}

.ncert-btn svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.ncert-btn:hover svg {
    transform: translateX(2px);
}

/* ========================================
   Class Card (Special styling for class cards)
   ======================================== */
.ncert-class-card {
    text-align: center;
}

.ncert-class-card .ncert-card-header {
    padding: 2rem 1.5rem;
}

.ncert-class-number {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 800;
    color: var(--ncert-white);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.ncert-class-label {
    font-size: 1.125rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
}

/* ========================================
   Exercise List
   ======================================== */
.ncert-exercise-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ncert-exercise-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--ncert-white);
    border: 1px solid var(--ncert-border);
    border-radius: var(--ncert-radius);
    margin-bottom: 0.75rem;
    transition: var(--ncert-transition);
}

.ncert-exercise-item:hover {
    border-color: var(--ncert-primary-light);
    box-shadow: var(--ncert-shadow);
}

.ncert-exercise-item a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--ncert-text);
    text-decoration: none;
    font-weight: 600;
    flex-grow: 1;
}

.ncert-exercise-item a:hover {
    color: var(--ncert-primary-light);
}

.ncert-exercise-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--ncert-primary);
    color: var(--ncert-white);
    border-radius: 50%;
    font-size: 0.875rem;
    font-weight: 700;
}

.ncert-exercise-questions {
    font-size: 0.85rem;
    color: var(--ncert-text-muted);
    white-space: nowrap;
}

/* ========================================
   Q&A Accordion
   ======================================== */
.ncert-qa-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ncert-qa-item {
    background: var(--ncert-white);
    border: 1px solid var(--ncert-border);
    border-radius: var(--ncert-radius);
    overflow: hidden;
    transition: var(--ncert-transition);
}

.ncert-qa-item:hover {
    border-color: var(--ncert-primary-light);
}

.ncert-qa-item.active {
    box-shadow: var(--ncert-shadow);
    border-color: var(--ncert-primary);
}

.ncert-qa-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem;
    cursor: pointer;
    background: var(--ncert-bg);
    transition: var(--ncert-transition);
}

.ncert-qa-header:hover {
    background: var(--ncert-bg-alt);
}

.ncert-qa-number {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    background: var(--ncert-primary);
    color: var(--ncert-white);
    border-radius: 50%;
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 700;
}

.ncert-qa-question {
    flex-grow: 1;
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--ncert-text);
    line-height: 1.6;
    margin: 0;
}

.ncert-qa-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--ncert-white);
    border: 1px solid var(--ncert-border);
    border-radius: 50%;
    transition: var(--ncert-transition);
    flex-shrink: 0;
}

.ncert-qa-toggle svg {
    width: 16px;
    height: 16px;
    fill: var(--ncert-text-muted);
    transition: transform 0.3s ease;
}

.ncert-qa-item.active .ncert-qa-toggle {
    background: var(--ncert-primary);
    border-color: var(--ncert-primary);
}

.ncert-qa-item.active .ncert-qa-toggle svg {
    fill: var(--ncert-white);
    transform: rotate(180deg);
}

.ncert-qa-body {
    display: none;
    padding: 0 1.25rem 1.25rem 4.5rem;
}

.ncert-qa-item.active .ncert-qa-body {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.ncert-qa-answer {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border-left: 4px solid var(--ncert-success);
    padding: 1.25rem;
    border-radius: 0 8px 8px 0;
    margin-bottom: 1rem;
}

.ncert-qa-answer-label {
    display: inline-block;
    background: var(--ncert-success);
    color: var(--ncert-white);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

.ncert-qa-answer-text {
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--ncert-text);
    line-height: 1.8;
    margin: 0;
}

.ncert-qa-answer-text p {
    margin: 0 0 1rem 0;
}

.ncert-qa-answer-text p:last-child {
    margin-bottom: 0;
}

/* ========================================
   Navigation (Prev/Next)
   ======================================== */
.ncert-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--ncert-border);
}

.ncert-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: var(--ncert-white);
    border: 1px solid var(--ncert-border);
    border-radius: var(--ncert-radius);
    text-decoration: none;
    transition: var(--ncert-transition);
    max-width: 45%;
}

.ncert-nav-link:hover {
    border-color: var(--ncert-primary);
    box-shadow: var(--ncert-shadow);
}

.ncert-nav-link--prev {
    flex-direction: row;
}

.ncert-nav-link--next {
    flex-direction: row-reverse;
    margin-left: auto;
    text-align: right;
}

.ncert-nav-label {
    font-size: 0.75rem;
    color: var(--ncert-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ncert-nav-title {
    font-weight: 600;
    color: var(--ncert-text);
    font-size: 0.95rem;
}

.ncert-nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--ncert-bg);
    border-radius: 50%;
    flex-shrink: 0;
}

.ncert-nav-icon svg {
    width: 20px;
    height: 20px;
    fill: var(--ncert-primary);
}

/* ========================================
   Responsive Design
   ======================================== */

/* Desktop adjustments for main column width (~600-800px) */
@media (min-width: 992px) {
    .ncert-hero h1 {
        font-size: 1.75rem;
    }
    
    .ncert-hero-subtitle {
        font-size: 1rem;
    }
    
    .ncert-hero-stats {
        gap: 1.5rem;
    }
    
    .ncert-hero-stat-number {
        font-size: 1.5rem;
    }
    
    .feature-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .ncert-section-title {
        font-size: 1.5rem;
    }
}

/* Mobile only - single column layout */
@media (max-width: 767px) {
    .ncert-hero {
        padding: 1.5rem 1rem;
        margin: 0;
        border-radius: 0;
    }

    .ncert-hero h1 {
        font-size: 1.5rem;
    }

    .ncert-hero-stats {
        gap: 1rem;
    }

    .trust-badges {
        flex-direction: column;
        align-items: center;
    }

    .feature-row {
        grid-template-columns: 1fr !important;
        margin-bottom: 1.5rem;
    }

    .ncert-section {
        padding: 1.5rem 0.5rem;
    }

    /* Single column on mobile only */
    .ncert-cards-grid,
    .ncert-cards-grid--2cols,
    .ncert-cards-grid--4cols {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    .ncert-qa-body {
        padding: 0 1rem 1rem 1rem;
    }

    .ncert-qa-header {
        padding: 1rem;
    }

    .ncert-nav {
        flex-direction: column;
    }

    .ncert-nav-link {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .ncert-card-body {
        padding: 1rem;
    }

    .ncert-class-number {
        font-size: 2.5rem;
    }

    .ncert-qa-number {
        min-width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .ncert-hero,
    .ncert-nav,
    .ncert-qa-toggle {
        display: none !important;
    }

    .ncert-qa-body {
        display: block !important;
    }

    .ncert-qa-item {
        break-inside: avoid;
        border: 1px solid #000;
        margin-bottom: 1rem;
    }

    .ncert-qa-answer {
        background: #f5f5f5 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ========================================
   WORDPRESS THEME OVERRIDE - CRITICAL
   These rules ensure NCERT cards display correctly
   within the WordPress theme's layout
   ======================================== */

/* Fix WordPress editor adding unwanted <p> tags inside grid */
.ncert-cards-grid > p {
    display: none !important;
}

/* Handle WordPress using <article> instead of <div> for cards */
.ncert-cards-grid > article.ncert-card,
article.ncert-card {
    max-width: 100% !important;
    width: 100% !important;
    flex: none !important;
    display: flex !important;
    flex-direction: column !important;
    margin: 0 !important;
}

/* Hide empty paragraphs and comment paragraphs */
.ncert-cards-grid > p:empty,
.ncert-cards-grid > p:has(br:only-child) {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Fix line breaks inside cards from WordPress */
.ncert-card-body p > br:first-child,
.ncert-card-header p > br:first-child {
    display: none;
}

/* Handle WordPress wrapping spans/badges in <p> */
.ncert-card-header > p,
.ncert-card-body > p:has(.ncert-btn) {
    margin: 0 !important;
    padding: 0 !important;
}

/* Override article max-width restrictions */
body.page-template-template-ncert-hub article,
body.page-template-template-ncert-class article,
body.page-template-template-ncert-subject article,
body.page-template-template-ncert-chapter article,
body.page-template-template-ncert-exercise article,
.ncert-page article,
article.ncert-page {
    max-width: 100% !important;
    width: 100% !important;
    flex: none !important;
    padding: 0 !important;
}

/* Force grid layout on cards container */
.ncert-cards-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Individual card styling - handle both div and article */
.ncert-cards-grid > .ncert-card,
.ncert-cards-grid > a,
.ncert-cards-grid > div,
.ncert-cards-grid > article {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

/* Tablet: 2 columns */
@media (min-width: 601px) {
    .ncert-cards-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Mobile: Single column */
@media (max-width: 600px) {
    .ncert-cards-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Ensure sections take full width */
.ncert-page .ncert-section,
.ncert-page .ncert-container {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    box-sizing: border-box !important;
}

/* Reset any flex restrictions on main layout */
#main .ncert-page,
.site-main .ncert-page {
    display: block !important;
    width: 100% !important;
}

