/* ============================================
   UNIFIED EDUCATIONAL RESOURCES THEME
   ============================================ */

:root {
    /* Mode transition */
    --mode-transition: background-color 0.4s ease, color 0.4s ease;

    /* Light Mode (Default) */
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #334155;
    --secondary-light: #475569;
    --accent-color: #f43f5e;
    --accent-light: #fb7185;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --nav-bg: #334155;
    --header-gradient: linear-gradient(135deg, #6366f1, #4f46e5);
    --border-color: rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --border-radius: 1rem;
    --container-padding: 1rem;
}

[data-theme="dark"] {
    --primary-color: #818cf8;
    --primary-dark: #6366f1;
    --secondary-color: #f8fafc; /* Changed to light color for text consistency */
    --secondary-light: #e2e8f0;
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --nav-bg: #0f172a;
    --header-gradient: linear-gradient(135deg, #1e293b, #0f172a);
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* ============================================
   GLOBAL STYLES
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    transition: var(--mode-transition);
}

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--container-padding);
}

.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

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

.hide {
    display: none !important;
}

.text-center {
    text-align: center;
}

/* ============================================
   HEADER & NAVIGATION
   ============================================ */

header {
    background: var(--header-gradient);
    color: white;
    text-align: center;
    padding: 3rem var(--container-padding);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--mode-transition);
}

header h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    font-weight: 700;
    letter-spacing: -0.025em;
    word-break: break-word;
}

header p {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    max-width: 800px;
    margin: 0 auto;
    opacity: 0.9;
    padding: 0 1rem;
}

nav {
    background-color: var(--nav-bg);
    padding: 0.75rem var(--container-padding);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
    transition: var(--mode-transition);
}

.section-title {
    text-align: center;
    margin-bottom: 3rem;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 700;
    color: var(--secondary-color);
    position: relative;
    padding-bottom: 1rem;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background: var(--primary-color);
    border-radius: 2px;
}

nav .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

nav ul {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    list-style: none;
    gap: 0.5rem;
}

.search-container {
    position: relative;
    flex-grow: 0;
    max-width: 300px;
}

.search-input {
    width: 100%;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    border-radius: 2rem;
    border: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.9rem;
    transition: var(--transition);
}

.search-input:focus {
    background-color: rgba(255, 255, 255, 0.2);
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-light);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.7;
    pointer-events: none;
}

.theme-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

nav a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    white-space: nowrap;
}

nav a:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

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

.btn, button {
    font-size: 1rem;
    padding: 0.75rem 1.5rem;
    margin: 0.5rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn:hover, button:hover:not(:disabled) {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:active, button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: var(--shadow);
}

.btn:disabled, button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    transform: none;
    opacity: 0.6;
}

.btn-secondary {
    background-color: var(--secondary-color);
}

.btn-secondary:hover {
    background-color: var(--secondary-light);
}

.btn-success {
    background-color: var(--success-color);
}

.btn-success:hover {
    background-color: #059669;
}

.btn-error {
    background-color: var(--error-color);
}

.btn-error:hover {
    background-color: #dc2626;
}

/* ============================================
   CARDS & CONTAINERS
   ============================================ */

.card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition), var(--mode-transition);
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 1.5rem;
}

.card-content {
    padding: 1.25rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card h3 {
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    font-weight: 600;
    line-height: 1.3;
}

.card p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    flex-grow: 1;
    font-size: 0.9rem;
    line-height: 1.5;
}

.about-section {
    background-color: var(--card-bg);
    padding: 3rem 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 3rem;
    border: 1px solid var(--border-color);
    transition: var(--mode-transition);
}

.about-section h2 {
    color: var(--text-primary);
    margin-bottom: 2rem;
    text-align: center;
    font-weight: 700;
}

.about-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    align-items: center;
}

.about-image {
    width: 100%;
    max-width: 250px;
    background-color: var(--bg-color);
    height: 250px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--mode-transition);
}

.about-image svg {
    width: 100%;
    height: 100%;
    max-width: 200px;
    max-height: 200px;
}

.about-text {
    width: 100%;
    text-align: center;
}

.about-text h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: clamp(1.3rem, 3vw, 1.75rem);
    font-weight: 600;
}

.about-text p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.6;
}

.about-text h4 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    margin-top: 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
}

/* ============================================
   FORMS & INPUTS
   ============================================ */

.topic-selection, .difficulty-selection {
    margin-bottom: 1.5rem;
    width: 100%;
}

.topics, .difficulties {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.8rem;
    margin-top: 1rem;
}

.topic-btn, .difficulty-btn {
    padding: 0.6rem 1rem;
    background-color: var(--bg-color);
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.topic-btn:hover, .difficulty-btn:hover {
    background-color: var(--primary-color);
    color: white;
}

.topic-btn.active, .difficulty-btn.active {
    background-color: var(--primary-color);
    color: white;
    font-weight: bold;
    box-shadow: var(--shadow);
}

.choice-container {
    display: flex;
    width: 100%;
    margin-bottom: 1rem;
    border-radius: var(--border-radius);
    background-color: var(--card-bg);
    box-shadow: var(--shadow);
    transition: var(--transition);
    overflow: hidden;
    border: 2px solid var(--border-color);
}

.choice-container:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.choice-prefix {
    padding: 1rem 1.5rem;
    background-color: var(--primary-color);
    color: white;
    font-weight: bold;
    min-width: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.choice-text {
    padding: 1rem;
    width: 100%;
    cursor: pointer;
    color: var(--text-primary);
}

.correct {
    background-color: var(--success-color);
    color: white;
}

.correct .choice-text {
    color: white;
}

.incorrect {
    background-color: var(--error-color);
    color: white;
}

.incorrect .choice-text {
    color: white;
}

/* ============================================
   QUIZ STYLES
   ============================================ */

#quiz {
    width: 100%;
}

#hud {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.hud-prefix {
    font-size: 0.9rem;
    color: var(--primary-color);
    font-weight: bold;
}

.hud-main-text {
    font-size: 1.5rem;
    font-weight: 600;
}

#topic-indicator {
    text-align: center;
    font-weight: bold;
    color: var(--accent-color);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

#question {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: var(--text-primary);
    text-align: left;
    font-weight: 600;
}

#explanation-container {
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-color);
    color: var(--text-primary);
}

.quiz-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 2rem;
    width: 100%;
}

#next-btn {
    padding: 0.8rem 2.5rem;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

/* ============================================
   RESULTS & REVIEW
   ============================================ */

#end {
    text-align: center;
}

#final-score {
    font-size: 2.5rem;
    margin: 1.5rem 0;
    color: var(--primary-color);
    font-weight: 700;
}

.thanks-section {
    background-color: var(--card-bg);
    padding: 3rem 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 3rem;
    border: 1px solid var(--border-color);
    transition: var(--mode-transition);
    text-align: center;
}

.thanks-content h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

.thanks-content p {
    color: var(--text-secondary);
    max-width: 800px;
    margin: 0 auto;
}

.skills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.skill-tag {
    background-color: var(--bg-color);
    color: var(--primary-color);
    padding: 0.4rem 1rem;
    border-radius: 2rem;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.skill-tag:hover {
    background-color: var(--primary-color);
    color: white;
}

.featured-card {
    border: 2px solid var(--primary-color) !important;
}

.featured-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background-color: var(--accent-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: bold;
    z-index: 2;
}

#result-details {
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    color: var(--text-secondary);
}

#topic-performance {
    margin: 1.5rem 0;
    text-align: left;
    width: 100%;
}

.topic-stat {
    margin-bottom: 0.5rem;
    padding: 0.75rem;
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    border-left: 4px solid var(--primary-color);
    font-weight: 500;
    color: var(--text-primary);
}

.end-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

.review-item {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-color);
}

.review-question {
    font-weight: bold;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.review-choice {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 0.5rem;
    background-color: var(--light-bg);
    border-left: 3px solid transparent;
}

.review-choice.selected {
    font-weight: bold;
}

.review-choice.correct {
    background-color: var(--success-light);
    border-left-color: var(--success-color);
    color: #065f46;
}

.review-choice.incorrect {
    background-color: var(--error-light);
    border-left-color: var(--error-color);
    color: #991b1b;
}

.review-explanation {
    padding: 1rem;
    background-color: var(--light-bg);
    border-radius: var(--border-radius);
    font-style: italic;
    color: var(--text-secondary);
    border-left: 4px solid var(--primary-color);
    margin-top: 1rem;
}

/* ============================================
   MODAL
   ============================================ */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.8);
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(5px);
}

.modal.show {
    opacity: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--card-bg);
    margin: auto;
    padding: 2.5rem;
    border-radius: var(--border-radius);
    max-width: 95%;
    width: 600px;
    position: relative;
    transform: scale(0.8);
    transition: transform 0.3s ease, var(--mode-transition);
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.modal.show .modal-content {
    transform: scale(1);
}

.close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    color: #94a3b8;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close:hover {
    color: var(--accent-color);
    background-color: var(--light-bg);
}

.modal-header {
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--light-bg);
    padding-bottom: 1rem;
    padding-right: 2rem;
}

.modal-header h2 {
    color: var(--primary-color);
    font-size: clamp(1.3rem, 3vw, 1.8rem);
}

.modal-body {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

.modal-body p {
    margin-bottom: 1rem;
    font-size: 0.95rem;
    line-height: 1.6;
}

.modal-footer {
    text-align: right;
    border-top: 1px solid var(--light-bg);
    padding-top: 1rem;
}

.modal-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.9rem;
}

.modal-btn:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
}

/* ============================================
   FOOTER
   ============================================ */

footer {
    background-color: #1e293b; /* Persistent dark background for footer */
    color: white !important;
    text-align: center;
    padding: 2.5rem var(--container-padding);
    position: relative;
}

footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
}

footer p {
    margin-bottom: 1rem;
    opacity: 0.9;
    font-size: 0.9rem;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.social-link {
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: var(--transition);
    font-size: 1.1rem;
    cursor: pointer;
}

.social-link:hover {
    background-color: var(--primary-color);
    transform: translateY(-3px);
}

/* ============================================
   BACK TO TOP BUTTON
   ============================================ */

.back-to-top {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    background-color: var(--primary-color);
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: var(--transition);
    pointer-events: none;
    z-index: 99;
    font-size: 1.2rem;
}

.back-to-top.active {
    opacity: 1;
    pointer-events: auto;
}

.back-to-top:hover {
    background-color: var(--primary-dark);
    transform: translateY(-3px);
}

/* ============================================
   ACCESSIBILITY & ANIMATIONS
   ============================================ */

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

.animate {
    opacity: 0;
    animation: fadeIn 0.8s ease forwards;
}

.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }
.delay-5 { animation-delay: 0.5s; }

a:focus,
button:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

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

/* Tablets */
@media (max-width: 768px) {
    :root {
        --container-padding: 0.75rem;
    }

    header {
        padding: 1.5rem var(--container-padding);
        min-height: 250px;
    }

    nav ul {
        gap: 0.25rem;
    }

    nav a {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }

    .grid-container {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 1rem;
    }

    #hud {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }

    .choice-container {
        flex-direction: column;
    }

    .choice-prefix {
        width: 100%;
        text-align: center;
        padding: 0.5rem;
    }

    .modal-content {
        width: 90%;
    }
}

/* Mobile phones */
@media (max-width: 480px) {
    :root {
        --container-padding: 0.5rem;
    }

    header {
        padding: 1rem var(--container-padding);
        min-height: 200px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    nav ul {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }

    nav a {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        width: 100%;
        max-width: 200px;
        justify-content: center;
    }

    main {
        padding: 1rem var(--container-padding);
    }

    .grid-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .card {
        max-width: 100%;
    }

    .btn {
        width: 100%;
        margin: 0.5rem 0;
    }

    .section-title {
        font-size: 1.5rem;
    }

    .end-buttons {
        flex-direction: column;
    }

    .modal-content {
        width: 95%;
        padding: 1rem;
    }

    .close {
        width: 30px;
        height: 30px;
        font-size: 20px;
    }
}

/* Extra small devices */
@media (max-width: 320px) {
    .grid-container {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .card-content {
        padding: 0.75rem;
    }

    .modal-content {
        padding: 0.75rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
}
/* Card Button Styling */
.card-btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    background-color: var(--primary-color);
    color: white !important;
    text-decoration: none;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: var(--transition);
    margin-top: auto;
    text-align: center;
}

.card-btn:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
