/* =========================================================
   COMPONENTS — modal, quiz, formula, animations
   ========================================================= */

/* ============= REVEAL ON SCROLL ============= */
[data-reveal] {
    opacity: 0;
    transform: translateY(28px);
    transition: opacity .8s cubic-bezier(.25,.8,.25,1), transform .8s cubic-bezier(.25,.8,.25,1);
}
[data-reveal].reveal-in { opacity: 1; transform: translateY(0); }
[data-reveal-delay="100"] { transition-delay: .1s; }
[data-reveal-delay="200"] { transition-delay: .2s; }
[data-reveal-delay="300"] { transition-delay: .3s; }
[data-reveal-delay="400"] { transition-delay: .4s; }
[data-reveal-delay="500"] { transition-delay: .5s; }

/* ============= WHATSAPP MODAL ============= */
.wa-alert-modal {
    position: fixed; inset: 0; z-index: 80;
    display: grid; place-items: center;
    animation: waFadeIn .3s ease;
}
.wa-modal-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(4px);
}
.wa-modal-card {
    position: relative;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-radius: 24px;
    padding: 2.5rem 2rem;
    max-width: 460px;
    width: calc(100% - 2rem);
    box-shadow: 0 40px 80px -20px rgba(0,0,0,.5);
    text-align: center;
    animation: waPop .35s cubic-bezier(.34,1.56,.64,1);
}
.wa-icon {
    width: 80px; height: 80px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: #25D36622;
    color: #25D366;
    display: grid; place-items: center;
}
.wa-modal-card h3 {
    font-size: 1.5rem;
    margin-bottom: .75rem;
    color: var(--text-primary);
}
.wa-modal-card p {
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 1.5rem;
}
.wa-actions {
    display: flex; gap: .75rem; justify-content: center;
    flex-wrap: wrap;
}
@keyframes waFadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes waPop { from { opacity: 0; transform: scale(.85) translateY(20px) } to { opacity: 1; transform: scale(1) translateY(0) } }

/* ============= QUIZ ============= */
.question-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
}
.question-card .q-num {
    color: var(--color-accent);
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: .5rem;
}
.question-card .q-text {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 1.5rem;
}
.question-card img.q-image {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 1rem auto;
    display: block;
    border: 1px solid var(--border-color);
}

.quiz-options {
    display: grid; gap: .75rem;
}
.quiz-option {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1.5px solid var(--border-color);
    border-radius: 14px;
    padding: 1rem 1.25rem;
    cursor: pointer;
    text-align: left;
    transition: border-color .2s ease, background .2s ease, transform .15s ease;
    display: flex; gap: .75rem; align-items: center;
    line-height: 1.4;
}
.quiz-option:hover {
    border-color: var(--color-accent);
    transform: translateX(2px);
}
.quiz-option.selected {
    background: rgba(255,102,0,0.12);
    border-color: var(--color-accent);
    color: var(--color-accent);
    font-weight: 600;
}
.quiz-option.correct {
    background: rgba(143,209,79,0.18);
    border-color: var(--color-success);
    color: #2f6f1f;
}
.quiz-option.wrong {
    background: rgba(239,68,68,0.12);
    border-color: var(--color-danger);
    color: #b32424;
}
.quiz-option .opt-letter {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: grid; place-items: center;
    background: rgba(0,0,0,0.06);
    font-weight: 700; font-size: .9rem;
    flex-shrink: 0;
}
.quiz-option.selected .opt-letter,
.quiz-option.correct .opt-letter,
.quiz-option.wrong .opt-letter { background: rgba(255,255,255,0.5); }

.quiz-option img.opt-image {
    max-width: 120px; max-height: 90px;
    border-radius: 8px;
    margin-left: auto;
}

/* Quiz progress bar */
.quiz-progress {
    height: 8px;
    background: rgba(0,0,0,0.08);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 2rem;
}
.quiz-progress-bar {
    height: 100%;
    background: var(--gradient-accent);
    transition: width .35s ease;
    border-radius: 999px;
}

/* Result circle */
.result-circle {
    width: 180px; height: 180px;
    border-radius: 50%;
    background: conic-gradient(var(--color-accent) calc(var(--score) * 1%), rgba(0,0,0,0.08) 0);
    display: grid; place-items: center;
    margin: 0 auto 1.5rem;
    position: relative;
}
.result-circle::before {
    content: '';
    position: absolute; inset: 14px;
    background: var(--bg-elevated);
    border-radius: 50%;
}
.result-circle .score-text {
    position: relative;
    z-index: 1;
    font-size: 2.5rem; font-weight: 800;
    color: var(--color-accent);
}

/* Leaderboard table */
.lb-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 .5rem;
}
.lb-table th {
    text-align: left;
    padding: .75rem 1rem;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.lb-table td {
    background: var(--bg-elevated);
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}
.lb-table tr td:first-child { border-left: 1px solid var(--border-color); border-radius: 12px 0 0 12px; }
.lb-table tr td:last-child  { border-right: 1px solid var(--border-color); border-radius: 0 12px 12px 0; }
.lb-rank {
    display: inline-grid; place-items: center;
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--gradient-accent);
    color: var(--text-inverse);
    font-weight: 800;
}
.lb-rank.gold   { background: linear-gradient(135deg, #FFD700, #FFA500); }
.lb-rank.silver { background: linear-gradient(135deg, #C0C0C0, #999); }
.lb-rank.bronze { background: linear-gradient(135deg, #CD7F32, #8B4513); }

/* Code/formula MathJax block */
.formula-block {
    padding: .75rem 1rem;
    background: rgba(96,76,195,0.08);
    border-radius: 10px;
    border-left: 3px solid var(--color-accent-2);
    overflow-x: auto;
    margin: .5rem 0;
}

/* Brand block in header */
.brand {
    display: inline-flex; align-items: center; gap: .65rem;
}
.brand-logo {
    width: 40px; height: 40px;
    border-radius: 12px;
    background: var(--gradient-accent);
    color: #fff;
    display: grid; place-items: center;
    font-weight: 800; font-size: 1.1rem;
    box-shadow: 0 8px 18px -8px rgba(255,102,0,0.55);
}
.brand-text {
    font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--text-primary);
    letter-spacing: -.02em;
}
.brand-text span { color: var(--color-accent); }

/* Loading spinner */
.spinner {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 3px solid var(--border-color);
    border-top-color: var(--color-accent);
    animation: spin 1s linear infinite;
    margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Floating WhatsApp button */
.fab-whatsapp {
    position: fixed; right: 1.5rem; bottom: 5.5rem;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: #25D366;
    color: #fff;
    display: grid; place-items: center;
    box-shadow: 0 10px 30px -8px rgba(37,211,102,.55);
    z-index: 40;
    transition: transform .3s ease;
    animation: float 3s ease-in-out infinite;
}
.fab-whatsapp:hover { transform: scale(1.1); color: #fff; }
@keyframes float { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-6px) } }

/* Tag/badge */
.badge {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .25rem .65rem;
    border-radius: 999px;
    font-size: .78rem; font-weight: 600;
    line-height: 1;
}
.badge-accent  { background: rgba(255,102,0,0.12); color: var(--color-accent); }
.badge-success { background: rgba(143,209,79,0.18); color: #498b1f; }
.badge-purple  { background: rgba(96,76,195,0.12); color: var(--color-accent-2); }
