/* ==========================================================================
   WikiFakeFact — quiz app theme (Bootstrap 5.3 + light/dark color modes)
   ========================================================================== */

:root,
[data-bs-theme="light"] {
    --wf-brand: #6d28d9;
    --wf-brand-rgb: 109, 40, 217;
    --wf-brand-hover: #5b21b6;
    --wf-brand-soft: #f1ebff;
    --wf-accent: #f59e0b;

    --wf-bg: #f5f3ff;
    --wf-bg-pattern: rgba(109, 40, 217, 0.06);
    --wf-surface: #ffffff;
    --wf-surface-2: #faf8ff;
    --wf-border: #e7e2f5;
    --wf-text: #1f1636;
    --wf-muted: #6b6485;
    --wf-shadow: 0 10px 30px -12px rgba(46, 16, 101, 0.18);
    --wf-shadow-lg: 0 24px 50px -20px rgba(46, 16, 101, 0.35);

    --wf-hero-from: #7c3aed;
    --wf-hero-to: #db2777;

    /* Answer tile colors (A/B/C/D) */
    --wf-opt-1: #e5484d;
    --wf-opt-2: #3b82f6;
    --wf-opt-3: #f59e0b;
    --wf-opt-4: #10b981;

    /* Chart line (validated against each theme's surface) */
    --wf-chart-line: #6d28d9;

    --bs-primary: var(--wf-brand);
    --bs-primary-rgb: var(--wf-brand-rgb);
    --bs-link-color-rgb: var(--wf-brand-rgb);
    --bs-link-hover-color-rgb: 91, 33, 182;
    --bs-body-font-family: 'Nunito', 'Cairo', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --bs-body-bg: var(--wf-bg);
    --bs-body-color: var(--wf-text);
    --bs-secondary-color: var(--wf-muted);
    --bs-border-color: var(--wf-border);
    --bs-border-radius: .75rem;
    --bs-border-radius-lg: 1rem;
}

[data-bs-theme="dark"] {
    --wf-brand: #a78bfa;
    --wf-chart-line: #9a7af5;
    --wf-brand-rgb: 167, 139, 250;
    --wf-brand-hover: #c4b5fd;
    --wf-brand-soft: rgba(167, 139, 250, 0.14);

    --wf-bg: #0f0b1a;
    --wf-bg-pattern: rgba(167, 139, 250, 0.07);
    --wf-surface: #1a1429;
    --wf-surface-2: #221a35;
    --wf-border: #2f2645;
    --wf-text: #ece8f7;
    --wf-muted: #a49cbc;
    --wf-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
    --wf-shadow-lg: 0 24px 50px -20px rgba(0, 0, 0, 0.8);

    --wf-hero-from: #5b21b6;
    --wf-hero-to: #9d174d;

    --wf-opt-1: #f87171;
    --wf-opt-2: #60a5fa;
    --wf-opt-3: #fbbf24;
    --wf-opt-4: #34d399;

    --bs-link-hover-color-rgb: 196, 181, 253;
    --bs-body-bg: var(--wf-bg);
    --bs-body-color: var(--wf-text);
    --bs-secondary-color: var(--wf-muted);
    --bs-border-color: var(--wf-border);
    --bs-tertiary-bg: var(--wf-surface-2);
}

/* ---------- Base ---------------------------------------------------------- */

html { scroll-behavior: smooth; }

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--wf-bg);
    background-image: radial-gradient(var(--wf-bg-pattern) 1.5px, transparent 1.5px);
    background-size: 22px 22px;
    color: var(--wf-text);
    transition: background-color .25s ease, color .25s ease;
}

main { flex: 1 0 auto; }

h1, h2, h3, h4, .fw-black { font-weight: 800; letter-spacing: -0.01em; }
.fw-black { font-weight: 900; }
.text-muted { color: var(--wf-muted) !important; }
.text-brand { color: var(--wf-brand) !important; }
.bg-brand-soft { background: var(--wf-brand-soft) !important; }

.btn-primary {
    --bs-btn-bg: var(--wf-brand);
    --bs-btn-border-color: var(--wf-brand);
    --bs-btn-hover-bg: var(--wf-brand-hover);
    --bs-btn-hover-border-color: var(--wf-brand-hover);
    --bs-btn-active-bg: var(--wf-brand-hover);
    --bs-btn-active-border-color: var(--wf-brand-hover);
    --bs-btn-disabled-bg: var(--wf-brand);
    --bs-btn-disabled-border-color: var(--wf-brand);
    --bs-btn-color: #fff;
    --bs-btn-hover-color: #fff;
    --bs-btn-active-color: #fff;
    box-shadow: 0 4px 0 0 rgba(0, 0, 0, .18);
}
[data-bs-theme="dark"] .btn-primary {
    --bs-btn-color: #1a1029;
    --bs-btn-hover-color: #1a1029;
    --bs-btn-active-color: #1a1029;
    --bs-btn-disabled-color: #1a1029;
}
.btn-outline-primary {
    --bs-btn-color: var(--wf-brand);
    --bs-btn-border-color: var(--wf-brand);
    --bs-btn-hover-bg: var(--wf-brand);
    --bs-btn-hover-border-color: var(--wf-brand);
    --bs-btn-active-bg: var(--wf-brand);
    --bs-btn-active-border-color: var(--wf-brand);
    --bs-btn-hover-color: #fff;
    --bs-btn-active-color: #fff;
}
[data-bs-theme="dark"] .btn-outline-primary {
    --bs-btn-hover-color: #1a1029;
    --bs-btn-active-color: #1a1029;
}
.btn { font-weight: 700; border-radius: .9rem; }
.btn-lg { padding: .8rem 2rem; }
.btn-primary:active { transform: translateY(2px); box-shadow: 0 2px 0 0 rgba(0, 0, 0, .18); }

.form-control, .form-select {
    border-radius: .9rem;
    border-width: 2px;
    background-color: var(--wf-surface);
}
.form-control:focus, .form-select:focus {
    border-color: var(--wf-brand);
    box-shadow: 0 0 0 .25rem rgba(var(--wf-brand-rgb), .2);
}

.badge.bg-primary { color: #fff; }
[data-bs-theme="dark"] .badge.bg-primary { color: #1a1029; }

/* ---------- Navbar -------------------------------------------------------- */

.wf-navbar {
    background: color-mix(in srgb, var(--wf-surface) 85%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--wf-border);
}
.wf-brand {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    font-weight: 900;
    font-size: 1.3rem;
    color: var(--wf-text) !important;
}
.wf-brand-mark {
    display: grid;
    place-items: center;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: .7rem;
    background: linear-gradient(135deg, var(--wf-hero-from), var(--wf-hero-to));
    color: #fff;
    font-size: 1.1rem;
    transform: rotate(-6deg);
}
.wf-brand .accent { color: var(--wf-brand); }
.wf-navbar .nav-link {
    font-weight: 700;
    color: var(--wf-muted);
    border-radius: .7rem;
    padding: .45rem .8rem !important;
    display: flex;
    align-items: center;
    gap: .4rem;
    white-space: nowrap;
}
/* Translated labels are longer; tighten the horizontal nav on mid-size screens */
@media (min-width: 1200px) and (max-width: 1399.98px) {
    .wf-navbar .nav-link { padding: .45rem .55rem !important; font-size: .95rem; }
}
.wf-navbar .nav-link:hover { color: var(--wf-text); background: var(--wf-brand-soft); }
.wf-navbar .nav-link.active { color: var(--wf-brand); background: var(--wf-brand-soft); }

.theme-toggle {
    width: 2.5rem;
    height: 2.5rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 2px solid var(--wf-border);
    background: var(--wf-surface);
    color: var(--wf-text);
    transition: transform .3s ease, border-color .2s;
}
.theme-toggle:hover { border-color: var(--wf-brand); transform: rotate(20deg); }
.theme-toggle .bi-sun-fill { display: none; }
[data-bs-theme="dark"] .theme-toggle .bi-sun-fill { display: inline; }
[data-bs-theme="dark"] .theme-toggle .bi-moon-stars-fill { display: none; }
.theme-toggle.lang-toggle { width: auto; min-width: 2.5rem; padding: 0 .65rem; border-radius: 999px; display: inline-flex; gap: .3rem; font-weight: 800; font-size: .8rem; }
.theme-toggle.lang-toggle:hover { transform: none; }
.lang-toggle .lang-code { letter-spacing: .03em; }

/* ---------- Surfaces ------------------------------------------------------ */

.card {
    --bs-card-bg: var(--wf-surface);
    --bs-card-border-color: var(--wf-border);
    border-radius: 1.25rem;
}
.wf-card {
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    border-radius: 1.5rem;
    box-shadow: var(--wf-shadow);
}
.wf-card-pad { padding: 2.5rem; }
@media (max-width: 576px) { .wf-card-pad { padding: 1.5rem; } }

.page-head { text-align: center; margin-bottom: 2rem; }
.page-head .eyebrow {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--wf-brand);
    background: var(--wf-brand-soft);
    padding: .35rem .8rem;
    border-radius: 999px;
    margin-bottom: .8rem;
}
.page-head h1 { font-size: clamp(2rem, 4vw, 2.75rem); margin-bottom: .4rem; }
.page-head p { color: var(--wf-muted); font-size: 1.1rem; margin: 0; }

.section-label {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-weight: 800;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}
.section-label .step {
    display: grid;
    place-items: center;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    background: var(--wf-brand);
    color: #fff;
    font-size: .9rem;
}
[data-bs-theme="dark"] .section-label .step { color: #1a1029; }

/* ---------- Hero (home) --------------------------------------------------- */

.wf-hero {
    position: relative;
    overflow: hidden;
    border-radius: 2rem;
    padding: 3.5rem 2rem;
    color: #fff;
    background: linear-gradient(135deg, var(--wf-hero-from), var(--wf-hero-to));
    box-shadow: var(--wf-shadow-lg);
}
.wf-hero::before, .wf-hero::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, .1);
}
.wf-hero::before { width: 320px; height: 320px; top: -120px; right: -80px; }
.wf-hero::after { width: 200px; height: 200px; bottom: -90px; left: -60px; }
.wf-hero > * { position: relative; z-index: 1; }
.wf-hero h1 { font-size: clamp(2.2rem, 5vw, 3.5rem); font-weight: 900; }
.wf-hero .lead { opacity: .92; max-width: 560px; margin-inline: auto; }

.hero-form {
    max-width: 480px;
    margin: 2rem auto 0;
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 1.25rem;
    padding: .5rem;
    display: flex;
    gap: .5rem;
}
.hero-form .form-control {
    border: none;
    background: #fff;
    color: #1f1636;
    font-weight: 700;
}
.hero-form .form-control::placeholder { color: #8b84a3; }
.hero-form .hero-pin { flex: 0 0 7rem; text-align: center; letter-spacing: .3em; }
.hero-form .btn {
    background: #fff;
    color: #6d28d9;
    border: none;
    white-space: nowrap;
    box-shadow: 0 4px 0 0 rgba(0, 0, 0, .2);
}
.hero-form .btn:hover { background: #fef3c7; color: #5b21b6; }
@media (max-width: 576px) { .hero-form { flex-direction: column; } .hero-form .hero-pin { flex-basis: auto; } }

.floating-chip {
    position: absolute;
    font-size: 2rem;
    animation: float 6s ease-in-out infinite;
    opacity: .9;
}
@keyframes float {
    0%, 100% { transform: translateY(0) rotate(-6deg); }
    50% { transform: translateY(-14px) rotate(6deg); }
}

.feature-tile {
    height: 100%;
    padding: 1.5rem;
    border-radius: 1.25rem;
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    box-shadow: var(--wf-shadow);
}
.feature-icon {
    width: 3rem;
    height: 3rem;
    display: grid;
    place-items: center;
    border-radius: .9rem;
    font-size: 1.4rem;
    margin-bottom: 1rem;
}

/* ---------- Selectable tiles (setup / custom quiz) ------------------------ */

.tile-input { position: absolute; opacity: 0; pointer-events: none; }
.tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    height: 100%;
    min-height: 110px;
    padding: 1.1rem .75rem;
    text-align: center;
    cursor: pointer;
    user-select: none;
    border-radius: 1.1rem;
    border: 2px solid var(--wf-border);
    background: var(--wf-surface);
    box-shadow: 0 4px 0 0 var(--wf-border);
    transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.tile:hover { transform: translateY(-3px); border-color: rgba(var(--wf-brand-rgb), .5); }
.tile .tile-emoji { font-size: 2.1rem; line-height: 1; }
.tile .tile-icon { font-size: 1.6rem; color: var(--wf-brand); }
.tile .tile-title { font-weight: 800; }
.tile .tile-sub { font-size: .85rem; color: var(--wf-muted); font-weight: 600; }
.tile .tile-check {
    position: absolute;
    top: .55rem;
    inset-inline-end: .6rem;
    color: var(--wf-brand);
    opacity: 0;
    transform: scale(.5);
    transition: all .15s ease;
}
.tile-input:checked + .tile {
    border-color: var(--wf-brand);
    background: var(--wf-brand-soft);
    box-shadow: 0 4px 0 0 var(--wf-brand);
}
.tile-input:checked + .tile .tile-check { opacity: 1; transform: scale(1); }
.tile-input:focus-visible + .tile { outline: 3px solid rgba(var(--wf-brand-rgb), .4); outline-offset: 2px; }
.tile.tile-link { text-decoration: none; color: inherit; border-style: dashed; }
.tile.tile-compact { min-height: 0; flex-direction: row; justify-content: flex-start; text-align: start; gap: .8rem; }

/* ---------- Quiz ---------------------------------------------------------- */

.quiz-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: 1rem;
}
.quiz-counter { font-weight: 900; font-size: 1.05rem; }
.quiz-counter .total { color: var(--wf-muted); }
.chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem .8rem;
    border-radius: 999px;
    font-size: .85rem;
    font-weight: 700;
    background: var(--wf-surface-2);
    border: 1px solid var(--wf-border);
    color: var(--wf-text);
}
.chip-brand { background: var(--wf-brand-soft); border-color: transparent; color: var(--wf-brand); }

.quiz-progress {
    height: .9rem;
    border-radius: 999px;
    background: var(--wf-surface-2);
    border: 1px solid var(--wf-border);
    overflow: hidden;
}
.quiz-progress .bar {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--wf-hero-from), var(--wf-hero-to));
    transition: width .6s cubic-bezier(.22, 1, .36, 1);
}

.quiz-question {
    text-align: center;
    padding: 2rem 1rem 1.5rem;
}
.quiz-question .q-icon {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1rem;
    display: grid;
    place-items: center;
    border-radius: 1.2rem;
    font-size: 2rem;
    background: linear-gradient(135deg, var(--wf-hero-from), var(--wf-hero-to));
    color: #fff;
    transform: rotate(-6deg);
}
.quiz-question h2 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); font-weight: 900; }

.answer {
    --opt: var(--wf-opt-1);
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 100%;
    padding: 1.1rem 1.2rem;
    cursor: pointer;
    user-select: none;
    border-radius: 1.1rem;
    border: 2px solid var(--wf-border);
    background: var(--wf-surface);
    box-shadow: 0 5px 0 0 var(--wf-border);
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, background-color .15s ease;
    animation: pop-in .4s cubic-bezier(.22, 1, .36, 1) both;
}
.answer-2 { --opt: var(--wf-opt-2); animation-delay: .05s; }
.answer-3 { --opt: var(--wf-opt-3); animation-delay: .1s; }
.answer-4 { --opt: var(--wf-opt-4); animation-delay: .15s; }
.answer:hover { transform: translateY(-3px); border-color: var(--opt); }
.answer .letter {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: .8rem;
    font-weight: 900;
    font-size: 1.15rem;
    color: #fff;
    background: var(--opt);
}
.answer .text { font-weight: 700; font-size: 1.05rem; line-height: 1.35; }
.answer .pick {
    margin-inline-start: auto;
    flex-shrink: 0;
    font-size: 1.4rem;
    color: var(--opt);
    opacity: 0;
    transform: scale(.4);
    transition: all .15s ease;
}
.answer-input:checked + .answer {
    border-color: var(--opt);
    background: color-mix(in srgb, var(--opt) 12%, var(--wf-surface));
    box-shadow: 0 5px 0 0 var(--opt);
}
.answer-input:checked + .answer .pick { opacity: 1; transform: scale(1); }
.answer-input:focus-visible + .answer { outline: 3px solid var(--opt); outline-offset: 2px; }
.kbd-hint { font-size: .85rem; color: var(--wf-muted); }
.kbd-hint kbd {
    background: var(--wf-surface-2);
    color: var(--wf-text);
    border: 1px solid var(--wf-border);
    border-bottom-width: 3px;
    border-radius: .4rem;
    font-family: inherit;
    font-weight: 800;
    padding: .05rem .4rem;
}

@keyframes pop-in {
    from { opacity: 0; transform: translateY(12px) scale(.97); }
    to { opacity: 1; transform: none; }
}

/* ---------- Flash / feedback --------------------------------------------- */

.wf-alert {
    display: flex;
    align-items: center;
    gap: .8rem;
    border: none;
    border-radius: 1rem;
    font-weight: 700;
    box-shadow: var(--wf-shadow);
    animation: pop-in .35s ease both;
}
.wf-alert .alert-icon { font-size: 1.4rem; flex-shrink: 0; }
.wf-alert.alert-success .alert-icon { animation: bounce .6s ease; }
@keyframes bounce {
    0%, 100% { transform: scale(1); }
    40% { transform: scale(1.35); }
    70% { transform: scale(.9); }
}

/* ---------- Results ------------------------------------------------------- */

.score-ring {
    --p: 0;
    --ring: var(--wf-brand);
    width: 210px;
    height: 210px;
    margin: 0 auto;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: conic-gradient(var(--ring) calc(var(--p) * 1%), var(--wf-surface-2) 0);
    box-shadow: var(--wf-shadow);
}
.score-ring .inner {
    width: 170px;
    height: 170px;
    border-radius: 50%;
    background: var(--wf-surface);
    display: grid;
    place-items: center;
    align-content: center;
}
.score-ring .pct { font-size: 3rem; font-weight: 900; line-height: 1; }
.score-ring .frac { color: var(--wf-muted); font-weight: 700; }

.stat-tile {
    padding: 1.1rem;
    border-radius: 1.1rem;
    background: var(--wf-surface-2);
    border: 1px solid var(--wf-border);
    text-align: center;
    height: 100%;
}
.stat-tile .value { font-size: 1.6rem; font-weight: 900; line-height: 1.2; }
.stat-tile .label { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--wf-muted); font-weight: 800; }

/* ---------- Leaderboard --------------------------------------------------- */

.podium {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-items: end;
    gap: 1rem;
    max-width: 640px;
    margin: 0 auto 2rem;
}
.podium-spot { text-align: center; text-decoration: none; color: inherit; }
.podium-spot .medal { font-size: 2.2rem; }
.podium-spot .name { font-weight: 900; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-spot .pct { font-weight: 800; color: var(--wf-brand); }
.podium-spot .block {
    margin-top: .6rem;
    border-radius: 1rem 1rem .4rem .4rem;
    display: grid;
    place-items: center;
    font-weight: 900;
    font-size: 2rem;
    color: #fff;
}
.podium-1 { order: 2; }
.podium-2 { order: 1; }
.podium-3 { order: 3; }
.podium-1 .block { height: 140px; background: linear-gradient(180deg, #fbbf24, #d97706); }
.podium-2 .block { height: 105px; background: linear-gradient(180deg, #cbd5e1, #64748b); }
.podium-3 .block { height: 80px; background: linear-gradient(180deg, #fdba74, #c2410c); }

.rank-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .9rem 1.1rem;
    border-radius: 1rem;
    background: var(--wf-surface-2);
    border: 1px solid var(--wf-border);
    transition: transform .15s ease, border-color .15s ease;
}
.rank-row:hover { transform: translateX(4px); border-color: rgba(var(--wf-brand-rgb), .5); }
.rank-row .rank {
    width: 2.2rem;
    flex-shrink: 0;
    text-align: center;
    font-weight: 900;
    font-size: 1.1rem;
    color: var(--wf-muted);
}
.rank-row .who { min-width: 0; flex: 1; }
.rank-row .who a { font-weight: 800; color: var(--wf-text); text-decoration: none; }
.rank-row .who a:hover { color: var(--wf-brand); }
.rank-row .meta { font-size: .85rem; color: var(--wf-muted); }
.rank-row .score { text-align: end; flex-shrink: 0; }
.rank-row .score .pct { font-weight: 900; font-size: 1.15rem; color: var(--wf-brand); }

/* ---------- Avatars / players -------------------------------------------- */

.avatar {
    --size: 3rem;
    width: var(--size);
    height: var(--size);
    flex-shrink: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 900;
    font-size: calc(var(--size) * .42);
    color: #fff;
    text-transform: uppercase;
    background: linear-gradient(135deg, var(--wf-hero-from), var(--wf-hero-to));
}
.avatar-xl { --size: 7rem; }
.avatar-lg { --size: 5rem; }
.avatar-sm { --size: 2.4rem; }
.avatar-photo { object-fit: cover; background: var(--wf-surface-2); border: 1px solid var(--wf-border); }
.avatar-c1 { background: linear-gradient(135deg, #f43f5e, #f97316); }
.avatar-c2 { background: linear-gradient(135deg, #3b82f6, #06b6d4); }
.avatar-c3 { background: linear-gradient(135deg, #10b981, #84cc16); }
.avatar-c4 { background: linear-gradient(135deg, #8b5cf6, #ec4899); }
.avatar-c5 { background: linear-gradient(135deg, #f59e0b, #ef4444); }

.player-card {
    display: block;
    height: 100%;
    padding: 1.5rem;
    text-align: center;
    text-decoration: none;
    color: inherit;
    border-radius: 1.25rem;
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    box-shadow: var(--wf-shadow);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.player-card:hover { transform: translateY(-5px); box-shadow: var(--wf-shadow-lg); border-color: rgba(var(--wf-brand-rgb), .5); color: inherit; }

.meter {
    height: .6rem;
    border-radius: 999px;
    background: var(--wf-surface-2);
    border: 1px solid var(--wf-border);
    overflow: hidden;
}
.meter > span { display: block; height: 100%; border-radius: 999px; }
.meter-good { background: #10b981; }
.meter-mid { background: #f59e0b; }
.meter-low { background: #ef4444; }

/* ---------- Analysis ------------------------------------------------------ */

.insight-box {
    padding: 1.1rem 1.2rem;
    border-radius: 1rem;
    height: 100%;
    background: var(--wf-surface-2);
    border: 1px solid var(--wf-border);
    border-inline-start-width: 5px;
}
.insight-good { border-inline-start-color: #10b981; }
.insight-warn { border-inline-start-color: #f59e0b; }
.path-step {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 0;
}
.path-step + .path-step { border-top: 1px dashed var(--wf-border); }
.path-step .num {
    flex-shrink: 0;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 900;
    background: var(--wf-brand-soft);
    color: var(--wf-brand);
}
.tip {
    border-radius: .8rem;
    padding: .7rem .9rem;
    background: var(--wf-brand-soft);
    color: var(--wf-text);
    font-size: .9rem;
}

/* ---------- Custom quiz -------------------------------------------------- */

.seg {
    display: inline-flex;
    padding: .3rem;
    gap: .3rem;
    border-radius: 1rem;
    background: var(--wf-surface-2);
    border: 1px solid var(--wf-border);
}
.seg .nav-link {
    border: none;
    border-radius: .75rem;
    font-weight: 800;
    color: var(--wf-muted);
    padding: .55rem 1.2rem;
}
.seg .nav-link.active { background: var(--wf-surface); color: var(--wf-brand); box-shadow: var(--wf-shadow); }

.dropzone {
    position: relative;
    display: block;
    padding: 2.5rem 1rem;
    text-align: center;
    cursor: pointer;
    border-radius: 1.25rem;
    border: 2px dashed var(--wf-border);
    background: var(--wf-surface-2);
    transition: border-color .15s ease, background-color .15s ease;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--wf-brand); background: var(--wf-brand-soft); }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone .dz-icon { font-size: 2.6rem; color: var(--wf-brand); }
.dropzone .dz-file { font-weight: 800; color: var(--wf-brand); }

/* ---------- Chatbot ------------------------------------------------------- */

.chat-shell {
    display: flex;
    flex-direction: column;
    height: min(620px, 70vh);
    border-radius: 1.5rem;
    overflow: hidden;
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    box-shadow: var(--wf-shadow);
}
.chat-header {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--wf-border);
}
.chat-header .status { font-size: .8rem; color: #10b981; font-weight: 700; }
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    background: var(--wf-surface-2);
    scroll-behavior: smooth;
}
.chat-message {
    display: flex;
    align-items: flex-end;
    gap: .6rem;
    margin-bottom: 1rem;
    animation: pop-in .3s ease both;
}
.chat-message.user { flex-direction: row-reverse; }
.chat-message .bot-avatar {
    flex-shrink: 0;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--wf-hero-from), var(--wf-hero-to));
    color: #fff;
}
.message-content {
    max-width: 75%;
    padding: .75rem 1rem;
    border-radius: 1.1rem;
    word-wrap: break-word;
    line-height: 1.45;
}
.message-content.assistant {
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    border-bottom-left-radius: .3rem;
}
.message-content.user {
    background: var(--wf-brand);
    color: #fff;
    border-bottom-right-radius: .3rem;
}
[data-bs-theme="dark"] .message-content.user { color: #1a1029; }
.suggested-action { margin-top: .5rem; }
.suggested-action a {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .85rem;
    font-weight: 800;
    text-decoration: none;
    padding: .3rem .7rem;
    border-radius: 999px;
    background: var(--wf-brand-soft);
    color: var(--wf-brand);
}
.suggested-action a:hover { background: var(--wf-brand); color: #fff; }
.chat-input {
    display: flex;
    gap: .5rem;
    padding: .9rem;
    border-top: 1px solid var(--wf-border);
}
.chat-input .btn { flex-shrink: 0; width: 3rem; padding: 0; }
.typing span {
    display: inline-block;
    width: .45rem;
    height: .45rem;
    margin: 0 .1rem;
    border-radius: 50%;
    background: var(--wf-muted);
    animation: typing 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30% { transform: translateY(-5px); opacity: 1; }
}
.suggestion-chip {
    display: flex;
    align-items: center;
    gap: .6rem;
    width: 100%;
    text-align: start;
    padding: .8rem 1rem;
    border-radius: 1rem;
    font-weight: 700;
    font-size: .92rem;
    color: var(--wf-text);
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    transition: all .15s ease;
}
.suggestion-chip i { color: var(--wf-brand); }
.suggestion-chip:hover { border-color: var(--wf-brand); background: var(--wf-brand-soft); transform: translateX(3px); }

/* ---------- Floating help button & footer -------------------------------- */

.chatbot-fab {
    position: fixed;
    inset-inline-end: 1.5rem;
    bottom: 1.5rem;
    z-index: 1030;
    width: 3.6rem;
    height: 3.6rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 1.5rem;
    color: #fff;
    text-decoration: none;
    background: linear-gradient(135deg, var(--wf-hero-from), var(--wf-hero-to));
    box-shadow: var(--wf-shadow-lg);
    transition: transform .2s ease;
}
.chatbot-fab:hover { color: #fff; transform: scale(1.08) rotate(-6deg); }

.wf-footer { color: var(--wf-muted); font-size: .9rem; }
.wf-donate { color: var(--wf-muted); text-decoration: none; }
.wf-donate:hover, .wf-donate:focus { color: var(--wf-brand); text-decoration: underline; }
.wf-donate .bi-heart-fill { color: #e0457b; }

/* ---------- Loading overlay ---------------------------------------------- */

.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    place-items: center;
    padding: 1rem;
    background: color-mix(in srgb, var(--wf-bg) 88%, transparent);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.loading-overlay.show { display: grid; animation: pop-in .25s ease both; }
.loading-card { text-align: center; max-width: 380px; }
.loading-dice {
    width: 5rem;
    height: 5rem;
    margin: 0 auto 1.5rem;
    display: grid;
    place-items: center;
    border-radius: 1.4rem;
    font-size: 2.4rem;
    color: #fff;
    background: linear-gradient(135deg, var(--wf-hero-from), var(--wf-hero-to));
    animation: wobble 1.4s ease-in-out infinite;
}
@keyframes wobble {
    0%, 100% { transform: rotate(-10deg) scale(1); }
    50% { transform: rotate(10deg) scale(1.08); }
}
.loading-tip { min-height: 3em; color: var(--wf-muted); transition: opacity .3s ease; }

/* ---------- Practice card / answer review --------------------------------- */
.practice-card { display: flex; align-items: center; gap: 1.25rem; border-inline-start: 5px solid #f59e0b; }
.practice-card .min-w-0, .daily-card .min-w-0 { min-width: 0; }
.practice-icon {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 1rem;
    font-size: 1.6rem;
    color: #f59e0b;
    background: rgba(245, 158, 11, .15);
}
@media (max-width: 576px) {
    .practice-card, .daily-card { flex-wrap: wrap; }
    .practice-card .btn, .daily-action, .daily-action .btn:not(.btn-sm) { width: 100%; }
}

.review-round + .review-round { border-top: 1px solid var(--wf-border); padding-top: 1.5rem; }
.review-chip-good { background: rgba(16, 185, 129, .14); border-color: transparent; color: #10b981; }
.review-chip-bad { background: rgba(239, 68, 68, .14); border-color: transparent; color: #ef4444; }
.review-facts { display: flex; flex-direction: column; gap: .5rem; }
.review-fact {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .65rem .85rem;
    border-radius: .8rem;
    background: var(--wf-surface-2);
    border: 1px solid var(--wf-border);
}
.review-fact > .bi { color: #10b981; padding-top: .1rem; }
.review-fact.is-fake { border-color: rgba(239, 68, 68, .55); background: rgba(239, 68, 68, .08); }
.review-fact.is-fake > .bi { color: #ef4444; }
.review-fact.is-wrong-pick { border-style: dashed; border-color: var(--wf-muted); }
.review-tags { display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; flex-shrink: 0; }
.review-tag { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; padding: .1rem .5rem; border-radius: 999px; }
.tag-fake { background: #ef4444; color: #fff; }
.tag-pick { background: var(--wf-brand-soft); color: var(--wf-brand); }
.source-quote blockquote {
    margin: 0;
    padding: .5rem .85rem;
    border-inline-start: 4px solid var(--wf-brand);
    border-radius: .4rem;
    background: var(--wf-surface-2);
    font-style: italic;
}
.source-quote blockquote::before { content: "“"; }
.source-quote blockquote::after { content: "”"; }
.source-quote figcaption { padding-inline-start: .85rem; }
.tag-their-pick { background: rgba(245, 158, 11, .16); color: #d97706; }
.review-chip-who { font-weight: 900; max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Challenges: navbar bell with the number of new challengers, and the list of them */
.challenge-bell { position: relative; text-decoration: none; }
.challenge-bell:hover { transform: none; }
.challenge-bell .count {
    position: absolute;
    top: -.3rem;
    inset-inline-end: -.3rem;
    min-width: 1.15rem;
    height: 1.15rem;
    padding: 0 .3rem;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: .7rem;
    font-weight: 900;
    line-height: 1.15rem;
    text-align: center;
}
.rank-row-new { border-color: rgba(245, 158, 11, .7); background: rgba(245, 158, 11, .07); }
.chip-new { background: #f59e0b; border-color: transparent; color: #fff; font-size: .7rem; padding: .1rem .5rem; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Quiz history ------------------------------------------------------ */
.history-chart { position: relative; height: 220px; outline: none; touch-action: pan-y; }
.history-chart:focus-visible { box-shadow: 0 0 0 3px rgba(var(--wf-brand-rgb), .35); border-radius: .75rem; }
.chart-grid { stroke: var(--wf-border); stroke-width: 1; }
.chart-tick { fill: var(--wf-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart-line { fill: none; stroke: var(--wf-chart-line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: var(--wf-chart-line); opacity: .1; }
.chart-dot { fill: var(--wf-chart-line); stroke: var(--wf-surface); stroke-width: 2; }
.chart-dot-active { stroke-width: 3; }
.chart-crosshair { stroke: var(--wf-muted); stroke-width: 1; }
.chart-end-label { fill: var(--wf-text); font-size: 13px; font-weight: 800; }
.chart-tooltip {
    position: absolute;
    z-index: 2;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    min-width: 9rem;
    max-width: 16rem;
    padding: .5rem .7rem;
    border-radius: .7rem;
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    box-shadow: var(--wf-shadow);
    font-size: .8rem;
    color: var(--wf-muted);
}
.chart-tooltip .tt-value { color: var(--wf-text); font-size: .95rem; }
.chart-tooltip .tt-topic { color: var(--wf-text); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-row { gap: 1rem; }
.history-meter { width: 7rem; flex-shrink: 0; }
.history-row .score { min-width: 3.5rem; }
.history-action { width: 2.5rem; flex-shrink: 0; text-align: end; }
@media (min-width: 768px) { .history-action { width: 6rem; } }

/* ---------- Daily challenge --------------------------------------------------- */
.daily-card { display: flex; align-items: center; gap: 1.25rem; border-inline-start: 5px solid var(--wf-brand); }
.daily-icon {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 3.75rem;
    height: 3.75rem;
    border-radius: 1rem;
    font-size: 1.8rem;
    color: #fff;
    background: linear-gradient(135deg, var(--wf-hero-from), var(--wf-hero-to));
}
.rank-row-me { border-color: rgba(var(--wf-brand-rgb), .55); }
.daily-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .9rem 1.2rem;
    text-decoration: none;
    color: inherit;
    transition: transform .2s ease, border-color .2s ease;
}
.daily-banner:hover { transform: translateY(-2px); border-color: rgba(var(--wf-brand-rgb), .5); color: inherit; }
.daily-banner .min-w-0, .event-champion .min-w-0 { min-width: 0; }
.daily-banner-icon {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: .8rem;
    color: #fff;
    background: linear-gradient(135deg, var(--wf-hero-from), var(--wf-hero-to));
}

/* ---------- Saved uploads ----------------------------------------------------- */
.upload-option { display: flex; align-items: center; gap: .5rem; }
.upload-label {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: .8rem;
    margin: 0;
    padding: .75rem 1rem;
    border-radius: 1rem;
    border: 2px solid var(--wf-border);
    background: var(--wf-surface-2);
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}
.upload-label:hover { border-color: rgba(var(--wf-brand-rgb), .5); }
.upload-label .min-w-0 { min-width: 0; }
.upload-icon { font-size: 1.4rem; color: var(--wf-brand); flex-shrink: 0; }
.upload-check { font-size: 1.2rem; color: var(--wf-brand); opacity: 0; flex-shrink: 0; transition: opacity .15s ease; }
.upload-input:checked + .upload-label { border-color: var(--wf-brand); background: var(--wf-brand-soft); }
.upload-input:checked + .upload-label .upload-check { opacity: 1; }
.upload-input:focus-visible + .upload-label { box-shadow: 0 0 0 3px rgba(var(--wf-brand-rgb), .35); }
.upload-delete { flex-shrink: 0; }

/* ---------- Leaderboard filters ----------------------------------------------- */
.leaderboard-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem 1rem; padding: 1rem 1.25rem; }
.filter-field { flex: 1 1 10rem; min-width: 0; }
.filter-label { display: block; font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--wf-muted); margin-bottom: .3rem; }
.filter-actions { display: flex; align-items: center; gap: .5rem; min-height: calc(1.5em + .75rem + 4px); }

/* ---------- Badges & streaks -------------------------------------------------- */
.streak-chip.is-active { background: rgba(245, 158, 11, .15); border-color: transparent; color: #b45309; }
[data-bs-theme="dark"] .streak-chip.is-active { color: #fbbf24; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .75rem; }
.badge-tile {
    text-align: center;
    padding: 1rem .75rem;
    border-radius: 1rem;
    background: var(--wf-surface-2);
    border: 1px solid var(--wf-border);
}
.badge-icon { font-size: 2rem; line-height: 1; margin-bottom: .4rem; }
.badge-desc { font-size: .78rem; color: var(--wf-muted); margin-top: .2rem; }
.badge-date { font-size: .72rem; font-weight: 800; color: var(--wf-brand); margin-top: .4rem; }
.badge-tile.is-locked { background: transparent; border-style: dashed; }
.badge-tile.is-locked .badge-icon { filter: grayscale(1); opacity: .5; }

/* ---------- Account ----------------------------------------------------------- */
.danger-zone { border-inline-start: 5px solid #ef4444; }

/* ---------- Timed mode -------------------------------------------------------- */
.timed-switch { display: flex; align-items: flex-start; gap: .75rem; padding-inline-start: 0; }
.timed-switch .form-check-input { float: none; margin: .2rem 0 0; width: 2.75rem; height: 1.4rem; flex-shrink: 0; }
.quiz-timer { display: flex; align-items: center; gap: .75rem; margin: 1rem 0 0; font-weight: 900; color: var(--wf-brand); }
.timer-track { flex: 1; height: .5rem; border-radius: 999px; background: var(--wf-surface-2); border: 1px solid var(--wf-border); overflow: hidden; }
.timer-bar { height: 100%; background: var(--wf-brand); border-radius: 999px; transition: width .2s linear; }
.timer-count { min-width: 2ch; text-align: end; font-variant-numeric: tabular-nums; }
.quiz-timer.is-low { color: #ef4444; }
.quiz-timer.is-low .timer-bar { background: #ef4444; }

/* ---------- Challenges -------------------------------------------------------- */
.challenge-result { border-top: 5px solid var(--wf-brand); }
.challenge-result.is-win { border-top-color: #10b981; }
.challenge-result.is-loss { border-top-color: #ef4444; }

/* ---------- Recommended difficulty -------------------------------------------- */
.tile { position: relative; }
.tile-badge {
    position: absolute;
    top: .5rem;
    inset-inline-start: .5rem;
    font-size: .68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: .1rem .45rem;
    border-radius: 999px;
    background: rgba(245, 158, 11, .18);
    color: #b45309;
}
[data-bs-theme="dark"] .tile-badge { color: #fbbf24; }

/* ---------- Right-to-left (Arabic) --------------------------------------------- */
/* Arrows point the way the page reads, and hover nudges move toward the reading end */
[dir="rtl"] .bi-arrow-right::before,
[dir="rtl"] .bi-arrow-left::before,
[dir="rtl"] .bi-chevron-right::before,
[dir="rtl"] .bi-arrow-right-circle-fill::before { transform: scaleX(-1); }
[dir="rtl"] .rank-row:hover { transform: translateX(-4px); }
[dir="rtl"] .suggestion-chip:hover { transform: translateX(-3px); }
/* Arabic letters don't take extra spacing or capitals */
[dir="rtl"] .tile-badge, [dir="rtl"] .stat-tile .label, [dir="rtl"] .page-head .eyebrow { letter-spacing: 0; }
/* The PIN field's wide letter spacing is for digits; it breaks up the Arabic placeholder */
[dir="rtl"] .hero-form .hero-pin::placeholder { letter-spacing: 0; }

/* ---------- Navbar profile link ------------------------------------------------------- */
.nav-avatar { border-radius: 50%; text-decoration: none; }
.nav-avatar .avatar { --size: 2.5rem; transition: box-shadow .2s ease; }
.nav-avatar:hover .avatar, .nav-avatar:focus-visible .avatar { box-shadow: 0 0 0 3px var(--wf-brand-soft), 0 0 0 4px var(--wf-brand); }
/* Small phones: a slightly smaller brand keeps it on one row with the language, theme and menu buttons */
@media (max-width: 420px) {
    .wf-brand { font-size: 1.1rem; gap: .4rem; }
    .wf-brand-mark { width: 2rem; height: 2rem; }
    .wf-navbar .theme-toggle { width: 2.25rem; height: 2.25rem; }
    .wf-navbar .theme-toggle.lang-toggle { padding: 0 .5rem; }
}
