/* DEFAULT RESET */
* {
    margin: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* THEME VARIABLES */
:root {
    --primary-color: #4a90e2;
    /* Blue for buttons, highlights */
    --secondary-color: #50e3c2;
    /* Teal accents */
    --accent-color: #f5a623;
    /* Orange for CTA */
    --text-color: #333333;
    /* Dark grey for readability */
    --bg-color: #f0f2f5;
    /* Light neutral background */
    --card-bg: #ffffff;
    --card-shadow: rgba(0,0,0,0.15);
    --hero-gradient: linear-gradient(240deg, #4a90e2 0%, #50e3c2 50%, #ffffff 100%);
}

/* DARK THEME */
@media (prefers-color-scheme: dark) {
:root {
    --primary-color: #1e90ff;
    --secondary-color: #00b894;
    --accent-color: #ff7675;
    --text-color: #e0e0e0;
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --card-shadow: rgba(0,0,0,0.5);
    --hero-gradient: linear-gradient(240deg, #1e90ff 0%, #00b894 50%, #121212 100%);
}
}

/* HERO SECTION */
#hero {
    background: var(--hero-gradient);
    background-size: 800% 800%;
    animation: Waves 9s linear infinite alternate;
    padding: 3em 1.5em;
    text-align: center;
    color: var(--primary-color);
    box-shadow: 0px 2px 8px var(--card-shadow);
}

#hero h1 {
    margin-bottom: 0.5em;
    color: var(--accent-color);
}

#hero p {
    max-width: 700px;
    margin: 1em auto;
    line-height: 1.6;
    text-align: left;
    color: var(--text-color);
}

/* MAIN SECTION */
.main {
    flex: 1;
    padding: 2em;
}

#course-intro {
    text-align: center;
    margin-bottom: 1.5em;
    color: var(--primary-color);
}

#courses {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.course-box {
    background-color: var(--card-bg);
    box-shadow: 0 2px 8px var(--card-shadow);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 25% 0%;
    perspective: 1000px;
    padding: 1.5em;
    height: 10em;
    transition: all 0.4s ease;
    opacity: 0;
    animation: fadeUp 0.8s ease forwards;
}

.course-box:hover {
    border-radius: 0% 25%;
    transform: scale(1.05);
    background-color: #f8f8f8;
}

/* CARD FLIP */
.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.8s;
    transform-style: preserve-3d;
}

.course-box:hover .card-inner,
.course-box:active .card-inner {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 20px;
    box-shadow: 0 2px 8px var(--card-shadow);
    display: flex;
    flex-direction: column;
    text-align: center;
    justify-content: center;
    align-items: center;
}

/* Front side */
.card-front {
    background-color: var(--card-bg);
    color: var(--primary-color);
}

/* Back side */
.card-back {
    background-color: var(--secondary-color);
    color: var(--card-bg);
    transform: rotateY(180deg);
}

.card-back button {
    background: var(--primary-color);
    color: var(--card-bg);
    border: none;
    padding: 0.8em 1.2em;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
}

.card-back button:hover {
    background: var(--accent-color);
}

/* STATES */
.hidden {
    display: none !important;
}
.correct {
    background: #4caf50 !important;
    color: white;
}
.wrong {
    background: #f44336 !important;
    color: white;
}

/* QUIZ SECTION */
#quiz {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#questionContainer {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 10px;
    color: var(--text-color);
    width: 100%;
    max-width: 900px;
    box-shadow: 0 2px 8px var(--card-shadow);
    text-align: center;
}

#quiz h1 {
    background: var(--primary-color);
    color: var(--card-bg);
    border-radius: 10px;
    padding: 1em;
    width: 100%;
    max-width: 900px;
    text-align: center;
}

#questions {
    font-weight: bold;
    font-family: Times New Roman;
    margin-bottom: 1em;
}

#options {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 10px;
    background: var(--card-bg);
    border-radius: 10px;
}

#options button {
    display: block;
    width: 100%;
    padding: 10px;
    margin: 8px 0;
    border: none;
    background: #ddd;
    cursor: pointer;
    border-radius: 5px;
    transition: background 0.3s;
}

#options button:hover {
    background: #ccc;
}

#options button:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

#options button:disabled {
    cursor: not-allowed;
    opacity: 0.85;
}

#nextBtn {
    background: var(--primary-color);
    color: var(--card-bg);
    min-width: 8em;
    cursor: pointer;
    border-radius: 8px;
    border: solid 1px var(--accent-color);
    padding: 0.8em 1.4em;
    margin-top: 2em;
    font-size: 1rem;
    transition: background 0.25s, transform 0.15s;
}

#nextBtn:hover {
    background: var(--accent-color);
}

#nextBtn:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

#nextBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#result {
    color: var(--text-color);
    text-align: center;
    max-width: 900px;
    width: 100%;
    padding: 1em 0;
}

#result h2 {
    color: var(--accent-color);
    margin-bottom: 0.5em;
}

.result-score {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-top: 0.75em;
}

/* PRE-QUIZ SECTION */
#preQuiz {
    text-align: center;
    color: var(--primary-color);
    line-height: 2;
}

#preQuiz {
    text-align: center;
    color: var(--primary-color);
    line-height: 2;
}

#preQuiz button {
    background: var(--primary-color);
    color: var(--card-bg);
    cursor: pointer;
    border-radius: 8px;
    border: solid 2px var(--accent-color);
    padding: 0.8em 1.4em;
    margin-top: 1.2em;
    margin-right: 0.5em;
    font-size: 1rem;
    transition: background 0.25s;
}

#preQuiz button:hover:not(:disabled) {
    background: var(--accent-color);
}

#preQuiz button:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

#preQuiz button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* FOOTER */
footer {
    background-color: var(--secondary-color);
    color: var(--card-bg);
    box-shadow: 0px -4px 4px var(--card-shadow);
    text-align: center;
    padding: 1em;
    font-weight: bold;
}

/* KEYFRAMES */
@keyframes Waves {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    75% {
        background-position: 0% 50%;
    }
    100% {
        background-position: 100% 50%;
    }
}

@keyframes fadeUp {
    0% {
        opacity: 0;
        transform: translateY(-40px) scale(0);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* STAGGERED ANIMATION — driven by --stagger-index set inline by JS */
.course-box {
    animation-delay: calc((var(--stagger-index, 1) - 1) * 0.15s);
}


/* STATUS BANNER */
.status-banner {
    padding: 0.75em 1.25em;
    border-radius: 8px;
    margin: 0.5em 0 1em;
    font-size: 0.95rem;
    text-align: center;
}

.status-info {
    background: #e8f0fe;
    color: #1a56db;
    border: 1px solid #a3bffa;
}

.status-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.status-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

@media (prefers-color-scheme: dark) {
    .status-info    { background: #1e3a5f; color: #93c5fd; border-color: #1e40af; }
    .status-success { background: #14532d; color: #86efac; border-color: #166534; }
    .status-error   { background: #450a0a; color: #fca5a5; border-color: #991b1b; }
}

/* EMPTY STATE */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-color);
    opacity: 0.6;
    padding: 2em;
}

/* MOBILE OVERRIDES */
@media (max-width: 768px) {
    #hero {
        padding: 2em 1em;
    }
    #hero p {
        text-align: center;
    }
    #preQuiz button {
        display: block;
        width: 100%;
        margin-right: 0;
    }
}

@media (max-width: 480px) {
    .course-box {
        height: auto;
        padding: 2em 1em;
    }
    #questionContainer, #quiz h1 {
        width: 100%;
    }
}