/**
 * ============================================================================
 * NCERT Solutions - Professional Template CSS
 * Clean, Modern, Student-Friendly Design
 * Version: 1.0.0
 * Created: 2026-01-18
 * ============================================================================
 *
 * Design Philosophy:
 * - Clean and distraction-free reading experience
 * - Clear visual hierarchy for questions, solutions, and answers
 * - Professional yet approachable for students
 * - Optimized for both study and print
 * - Mobile-first responsive design
 * ============================================================================
 */

/* ========================================
   PAGE STRUCTURE & LAYOUT
   ======================================== */

.ncert-solutions-wrapper {
    background-color: #f8f9fa;
    min-height: 100vh;
    padding: 2rem 0;
}

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

/* ========================================
   CHAPTER HEADER
   ======================================== */

.ncert-chapter-header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2.5rem 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 0.75rem;
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
}

.ncert-chapter-header h1 {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.ncert-chapter-header h3 {
    font-size: 1.25rem;
    font-weight: 400;
    opacity: 0.95;
    margin-bottom: 0;
}

.ncert-chapter-header hr {
    width: 100px;
    height: 3px;
    background: white;
    opacity: 0.5;
    margin: 1.5rem auto;
    border: none;
}

/* ========================================
   QUESTION CARD
   ======================================== */

.ncert-card {
    background: white;
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: 2.5rem;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

/* ========================================
   QUESTION HEADER
   ======================================== */

.ncert-question-header {
    background: white;
    border-bottom: 1px solid #f0f0f0;
    padding: 1.75rem 1.75rem 1.25rem;
}

.ncert-badge {
    display: inline-block;
    background: #0d6efd;
    color: white;
    padding: 0.4rem 0.85rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 1rem;
}

.ncert-question-header h5 {
    font-size: 1.15rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.ncert-question-header p {
    color: #6c757d;
    font-size: 1rem;
    margin-bottom: 0;
    line-height: 1.7;
}

/* ========================================
   SOLUTION BODY
   ======================================== */

.ncert-body {
    padding: 1.75rem;
}

.ncert-body h6 {
    color: #0d6efd;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1.25rem;
    display: inline-block;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #0d6efd;
}

.ncert-body p {
    color: #495057;
    font-size: 1rem;
    line-height: 1.8;
    margin-bottom: 1rem;
}

.ncert-body strong {
    color: #2c3e50;
    font-weight: 600;
}

.ncert-body ul,
.ncert-body ol {
    color: #495057;
    font-size: 1rem;
    line-height: 1.8;
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.ncert-body li {
    margin-bottom: 0.5rem;
}

/* ========================================
   SOLUTION STEPS (Blue Bar Design)
   ======================================== */

.ncert-step {
    border-left: 4px solid #0d6efd;
    background: #f8f9fa;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    border-radius: 0 0.375rem 0.375rem 0;
    transition: background 0.2s ease;
}

.ncert-step:hover {
    background: #e9ecef;
}

.ncert-step strong {
    display: block;
    color: #0d6efd;
    font-weight: 700;
    margin-bottom: 0.75rem;
    font-size: 1.05rem;
}

.ncert-step p {
    margin-bottom: 0.5rem;
    line-height: 1.8;
}

.ncert-step p:last-child {
    margin-bottom: 0;
}

/* Two Column Layout for Steps */
.ncert-step-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

/* ========================================
   DIAGRAM/IMAGE CONTAINER
   ======================================== */

.ncert-diagram {
    text-align: center;
    margin: 2rem 0;
    padding: 1.5rem;
    background: white;
    border: 2px dashed #dee2e6;
    border-radius: 0.5rem;
}

.ncert-diagram img {
    max-width: 100%;
    height: auto;
    border-radius: 0.375rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.ncert-diagram small {
    display: block;
    color: #6c757d;
    font-style: italic;
    margin-top: 1rem;
}

/* ========================================
   FINAL ANSWER BOX
   ======================================== */

.ncert-answer {
    background: linear-gradient(135deg, #d1e7dd 0%, #c1dccf 100%);
    color: #0f5132;
    padding: 1.25rem 1.5rem;
    border-radius: 0.5rem;
    border: 2px solid #a3cfbb;
    margin-top: 2rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(15, 81, 50, 0.1);
}

.ncert-answer::before {
    content: "✓";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #198754;
    color: white;
    border-radius: 50%;
    margin-right: 1rem;
    flex-shrink: 0;
    font-weight: 700;
    font-size: 1.1rem;
}

.ncert-answer .fw-bold {
    color: #0a3622;
}

/* ========================================
   MATH EXPRESSIONS (MathJax Enhancement)
   ======================================== */

.ncert-step mjx-container,
.ncert-body mjx-container {
    margin: 0.5rem 0;
}

/* Display math (centered equations) */
mjx-container[display="true"],
.MathJax_Display {
    margin: 1.5rem auto !important;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 0.375rem;
    text-align: center;
    overflow-x: auto;
}

/* Inline math */
mjx-container[display="false"],
.MathJax {
    margin: 0 0.2rem;
    display: inline-block;
    vertical-align: middle;
}

/* Math scrollbar for long equations */
mjx-container[display="true"]::-webkit-scrollbar {
    height: 6px;
}

mjx-container[display="true"]::-webkit-scrollbar-track {
    background: #e9ecef;
    border-radius: 3px;
}

mjx-container[display="true"]::-webkit-scrollbar-thumb {
    background: #adb5bd;
    border-radius: 3px;
}

mjx-container[display="true"]::-webkit-scrollbar-thumb:hover {
    background: #6c757d;
}

/* ========================================
   ALERT BOXES (Tips, Warnings, Notes)
   ======================================== */

.ncert-alert {
    padding: 1rem 1.25rem;
    border-radius: 0.5rem;
    margin: 1.5rem 0;
    border-left: 4px solid;
}

.ncert-alert-info {
    background: #e7f3ff;
    border-left-color: #0dcaf0;
    color: #055160;
}

.ncert-alert-warning {
    background: #fff3cd;
    border-left-color: #ffc107;
    color: #664d03;
}

.ncert-alert-success {
    background: #d1f2eb;
    border-left-color: #198754;
    color: #0f5132;
}

.ncert-alert strong {
    display: block;
    font-weight: 700;
    margin-bottom: 0.5rem;
    font-size: 1.05rem;
}

/* ========================================
   NUMBERED LIST STYLING
   ======================================== */

.ncert-body ol.ncert-list {
    counter-reset: item;
    list-style: none;
    padding-left: 0;
}

.ncert-body ol.ncert-list > li {
    counter-increment: item;
    margin-bottom: 1rem;
    padding-left: 2.5rem;
    position: relative;
}

.ncert-body ol.ncert-list > li::before {
    content: counter(item);
    position: absolute;
    left: 0;
    top: 0;
    width: 28px;
    height: 28px;
    background: #0d6efd;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

/* ========================================
   NAVIGATION BUTTONS
   ======================================== */

.ncert-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 3rem;
    padding: 1.5rem;
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.ncert-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: #0d6efd;
    color: white;
    border-radius: 0.5rem;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.ncert-nav-btn:hover {
    background: #0b5ed7;
    color: white;
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
}

.ncert-nav-btn.prev::before {
    content: "←";
    font-size: 1.2rem;
}

.ncert-nav-btn.next::after {
    content: "→";
    font-size: 1.2rem;
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .ncert-solutions-wrapper {
        background: white;
    }

    .ncert-chapter-header {
        background: none;
        color: black;
        border: 2px solid black;
        page-break-after: avoid;
    }

    .ncert-card {
        box-shadow: none;
        border: 1px solid #dee2e6;
        page-break-inside: avoid;
        margin-bottom: 2rem;
    }

    .ncert-navigation,
    .ncert-nav-btn {
        display: none;
    }

    .ncert-answer {
        background: none;
        border: 2px solid #198754;
    }

    .ncert-step {
        background: white;
        border: 1px solid #dee2e6;
    }
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
    .ncert-chapter-header h1 {
        font-size: 1.75rem;
    }

    .ncert-chapter-header h3 {
        font-size: 1.1rem;
    }

    .ncert-question-header,
    .ncert-body {
        padding: 1.25rem;
    }

    .ncert-step-grid {
        grid-template-columns: 1fr;
    }

    .ncert-navigation {
        flex-direction: column;
        gap: 1rem;
    }

    .ncert-nav-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .ncert-container {
        padding: 0 10px;
    }

    .ncert-chapter-header {
        padding: 1.75rem 1rem;
        border-radius: 0.5rem;
    }

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

    .ncert-question-header h5 {
        font-size: 1.05rem;
    }

    .ncert-step {
        padding: 1rem;
    }

    .ncert-diagram {
        padding: 1rem;
    }
}

/* ========================================
   ACCESSIBILITY ENHANCEMENTS
   ======================================== */

.ncert-card:focus-within {
    outline: 2px solid #0d6efd;
    outline-offset: 4px;
}

.ncert-nav-btn:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .ncert-card {
        border: 2px solid #000;
    }

    .ncert-step {
        border-left-width: 6px;
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.ncert-highlight {
    background: #fff3cd;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
}

.ncert-formula {
    background: #f8f9fa;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    border-left: 3px solid #6c757d;
    margin: 1rem 0;
    font-family: 'Courier New', monospace;
}

.ncert-note {
    background: #e7f3ff;
    padding: 1rem;
    border-radius: 0.375rem;
    border-left: 4px solid #0dcaf0;
    margin: 1rem 0;
    font-size: 0.95rem;
}

.ncert-important {
    background: #fff3cd;
    padding: 1rem;
    border-radius: 0.375rem;
    border-left: 4px solid #ffc107;
    margin: 1rem 0;
    font-weight: 500;
}

/* ========================================
   LOADING STATES
   ======================================== */

.ncert-card.loading {
    opacity: 0.6;
    pointer-events: none;
}

.ncert-card.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0d6efd;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   END OF NCERT SOLUTIONS TEMPLATE CSS
   ======================================== */
