/* ============================================================
   CBQ Leaderboard — v4.7.10
   Used by [cbq_leaderboard] shortcode + auto-created /leaderboard page.
   ============================================================ */

.cbq-leaderboard-page {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 16px;
    font-family: 'Inter', 'Baloo Tamma 2', 'Kannada Fallback', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.cbq-lb-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.cbq-lb-title {
    font-size: 28px;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 4px;
    letter-spacing: -.02em;
}
.cbq-lb-sub {
    font-size: 14px;
    color: #64748b;
    margin: 0;
    font-weight: 500;
}

/* My rank pill */
.cbq-lb-my-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    color: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 12px -2px rgba(99, 102, 241, .35);
    font-size: 13px;
    font-weight: 600;
}
.cbq-lb-my-lbl { opacity: .9; }
.cbq-lb-my-num { font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.cbq-lb-my-of { opacity: .7; font-size: 12px; }
.cbq-lb-my-empty {
    padding: 10px 14px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    font-size: 12.5px;
    color: #64748b;
    font-weight: 500;
}

/* Tabs */
.cbq-lb-filters {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    flex-wrap: wrap;
    padding: 6px;
    background: #f1f5f9;
    border-radius: 12px;
}
.cbq-lb-tabs {
    display: inline-flex;
    gap: 2px;
    flex-wrap: wrap;
}
.cbq-lb-tab {
    padding: 7px 14px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #64748b;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s ease;
    white-space: nowrap;
}
.cbq-lb-tab:hover {
    background: rgba(255, 255, 255, .6);
    color: #0f172a;
}
.cbq-lb-tab.is-active {
    background: #fff;
    color: #2563eb;
    box-shadow: 0 2px 6px -2px rgba(37, 99, 235, .25);
}
.cbq-lb-type-filter select {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12.5px;
    font-weight: 600;
    color: #0f172a;
    background: #fff;
    cursor: pointer;
}
.cbq-lb-type-filter select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}

/* List */
.cbq-lb-body {
    position: relative;
    min-height: 120px;
    transition: opacity .2s ease;
}
.cbq-lb-body.is-loading { opacity: .5; }
.cbq-lb-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.cbq-lb-row {
    display: grid;
    grid-template-columns: 48px 44px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    transition: all .2s cubic-bezier(.4, 0, .2, 1);
}
.cbq-lb-row:hover {
    border-color: #cbd5e1;
    transform: translateX(2px);
    box-shadow: 0 4px 10px -2px rgba(15, 23, 42, .06);
}

/* Podium styling for top 3 */
.cbq-lb-row.is-top1 {
    background: linear-gradient(135deg, #fef3c7 0%, #fffbeb 60%);
    border-color: #fbbf24;
    position: relative;
    overflow: hidden;
}
.cbq-lb-row.is-top1::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(251, 191, 36, .2), transparent 50%);
    pointer-events: none;
}
.cbq-lb-row.is-top2 {
    background: linear-gradient(135deg, #e0e7ff 0%, #eef2ff 60%);
    border-color: #a5b4fc;
}
.cbq-lb-row.is-top3 {
    background: linear-gradient(135deg, #fed7aa 0%, #fff7ed 60%);
    border-color: #fdba74;
}

.cbq-lb-rank {
    font-size: 20px;
    font-weight: 800;
    color: #64748b;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    letter-spacing: -.02em;
}
.cbq-lb-row.is-top1 .cbq-lb-rank { font-size: 28px; animation: cbq-lb-medal-bob 2.4s ease-in-out infinite; }
.cbq-lb-row.is-top2 .cbq-lb-rank { font-size: 26px; }
.cbq-lb-row.is-top3 .cbq-lb-rank { font-size: 25px; }
@keyframes cbq-lb-medal-bob {
    0%, 100% { transform: translateY(0) rotate(-3deg); }
    50%      { transform: translateY(-2px) rotate(3deg); }
}

.cbq-lb-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px -1px rgba(0, 0, 0, .1);
}
.cbq-lb-row.is-top1 .cbq-lb-avatar { border-color: #fbbf24; box-shadow: 0 0 0 3px rgba(251, 191, 36, .3); }
.cbq-lb-row.is-top2 .cbq-lb-avatar { border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(165, 180, 252, .3); }
.cbq-lb-row.is-top3 .cbq-lb-avatar { border-color: #fdba74; box-shadow: 0 0 0 3px rgba(253, 186, 116, .3); }

.cbq-lb-info { min-width: 0; z-index: 1; position: relative; }
.cbq-lb-name {
    font-size: 14.5px;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -.005em;
    margin-bottom: 2px;
}
.cbq-lb-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11.5px;
    color: #64748b;
    font-weight: 500;
}
.cbq-lb-streak {
    color: #c2410c;
    font-weight: 700;
}

.cbq-lb-score {
    text-align: right;
    z-index: 1;
    position: relative;
}
.cbq-lb-score-num {
    display: block;
    font-size: 18px;
    font-weight: 800;
    color: #0f172a;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.01em;
    line-height: 1.1;
}
.cbq-lb-row.is-top1 .cbq-lb-score-num { color: #92400e; }
.cbq-lb-score-lbl {
    font-size: 10px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* Empty state */
.cbq-lb-empty {
    text-align: center;
    padding: 50px 20px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
}
.cbq-lb-empty-icon { font-size: 48px; margin-bottom: 8px; opacity: .6; }
.cbq-lb-empty h3 {
    font-size: 17px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 4px;
}
.cbq-lb-empty p {
    font-size: 13px;
    color: #64748b;
    margin: 0;
}

/* Mobile */
@media (max-width: 600px) {
    .cbq-leaderboard-page { padding: 16px 12px; }
    .cbq-lb-title { font-size: 22px; }
    .cbq-lb-sub { font-size: 13px; }
    .cbq-lb-header { gap: 12px; }
    .cbq-lb-my-pill { padding: 8px 12px; font-size: 12px; }
    .cbq-lb-my-num { font-size: 16px; }
    .cbq-lb-filters { padding: 5px; gap: 8px; }
    .cbq-lb-tab { padding: 6px 10px; font-size: 12px; }
    .cbq-lb-row { grid-template-columns: 36px 36px 1fr auto; gap: 9px; padding: 8px 11px; }
    .cbq-lb-avatar { width: 36px; height: 36px; }
    .cbq-lb-rank { font-size: 16px; }
    .cbq-lb-row.is-top1 .cbq-lb-rank,
    .cbq-lb-row.is-top2 .cbq-lb-rank,
    .cbq-lb-row.is-top3 .cbq-lb-rank { font-size: 22px; }
    .cbq-lb-name { font-size: 13px; }
    .cbq-lb-meta { gap: 8px; font-size: 10.5px; }
    .cbq-lb-score-num { font-size: 15px; }
    .cbq-lb-score-lbl { font-size: 9px; }
}

/* Dark mode */
html[data-mcqp-theme="dark"] .cbq-lb-title { color: #f8fafc; }
html[data-mcqp-theme="dark"] .cbq-lb-sub { color: #94a3b8; }
html[data-mcqp-theme="dark"] .cbq-lb-filters { background: #0f172a; }
html[data-mcqp-theme="dark"] .cbq-lb-tab { color: #94a3b8; }
html[data-mcqp-theme="dark"] .cbq-lb-tab:hover { background: rgba(148, 163, 184, .1); color: #f8fafc; }
html[data-mcqp-theme="dark"] .cbq-lb-tab.is-active { background: #1e293b; color: #60a5fa; }
html[data-mcqp-theme="dark"] .cbq-lb-type-filter select {
    background: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}
html[data-mcqp-theme="dark"] .cbq-lb-row { background: #1e293b; border-color: #334155; }
html[data-mcqp-theme="dark"] .cbq-lb-row:hover { border-color: #475569; }
html[data-mcqp-theme="dark"] .cbq-lb-row.is-top1 {
    background: linear-gradient(135deg, rgba(251, 191, 36, .15) 0%, rgba(251, 191, 36, .05) 60%);
    border-color: rgba(251, 191, 36, .4);
}
html[data-mcqp-theme="dark"] .cbq-lb-row.is-top2 {
    background: linear-gradient(135deg, rgba(165, 180, 252, .15) 0%, rgba(165, 180, 252, .05) 60%);
    border-color: rgba(165, 180, 252, .4);
}
html[data-mcqp-theme="dark"] .cbq-lb-row.is-top3 {
    background: linear-gradient(135deg, rgba(253, 186, 116, .15) 0%, rgba(253, 186, 116, .05) 60%);
    border-color: rgba(253, 186, 116, .4);
}
html[data-mcqp-theme="dark"] .cbq-lb-name { color: #f8fafc; }
html[data-mcqp-theme="dark"] .cbq-lb-meta { color: #94a3b8; }
html[data-mcqp-theme="dark"] .cbq-lb-score-num { color: #f8fafc; }
html[data-mcqp-theme="dark"] .cbq-lb-row.is-top1 .cbq-lb-score-num { color: #fbbf24; }
html[data-mcqp-theme="dark"] .cbq-lb-empty { background: #1e293b; border-color: #334155; }
html[data-mcqp-theme="dark"] .cbq-lb-empty h3 { color: #f8fafc; }
html[data-mcqp-theme="dark"] .cbq-lb-empty p { color: #94a3b8; }
html[data-mcqp-theme="dark"] .cbq-lb-my-empty { background: #1e293b; border-color: #475569; color: #94a3b8; }

@media (prefers-reduced-motion: reduce) {
    .cbq-lb-row.is-top1 .cbq-lb-rank { animation: none !important; }
}
/* ============================================================
   v4.12.342 — Test Leaderboard MODAL: dark-mode contrast fix.

   Reverts v4.12.341 (which de-modal'd the leaderboard into an inline
   section per a redesign request). User reverted: prefer modal popup,
   just fix the dark-mode visibility issue from the original screenshots.

   This file's history on this surface:
     v338: first dark-mode attempt — wrong direction (tried to dark-paint
           rank-1 card; correct is keep gold + dark text on top)
     v339: correct direction but v340 revealed the file wasn't loading
           on the isolated route at all
     v340: fixed the missing <link> in advanced-cbt.php — file now loads
     v341: full de-modal redesign per mockup (now reverted)
     v342 (this): clean modal-popup dark-mode rules, reusing v339's
           correct approach + v340's CSS-load fix + v341's refined
           mockup-derived color tokens. !important throughout because
           engine's `.mcqp-tlb-*` rules in current-affairs/assets/
           frontend-styles.css have equal specificity and load order
           is not guaranteed across entry points (3 different files
           print the engine sheet).

   STRUCTURE preserved (modal stays as modal):
     - Fixed-position centered modal with backdrop + close X
     - Engine's openModal() / closeModal() flow untouched
     - body scroll lock untouched
     - Escape-to-close untouched

   ONLY dark-mode contrast is fixed:
     - rank-1 card + YOUR-RANK pill: keep their always-light gold
       gradient bg, force DARK text on top (contrast win)
     - rank-2/3 cards: explicit dark surface + visible borders
     - title/subtitle: brighter for readability on light header
     - table thead/rows/scores: dark-mode tokens

   LIGHT MODE: zero rules outside html[data-mcqp-theme="dark"] —
   light mode of leaderboard untouched.
   ============================================================ */

/* --- Rank-1 podium card: keep gold gradient (engine), force DARK text --- */
html[data-mcqp-theme="dark"] .mcqp-tlb-podium-card.rank-1,
html[data-mcqp-theme="dark"] .mcqp-tlb-podium-card.rank-1 * {
    color: #1f2937 !important;
}
html[data-mcqp-theme="dark"] .mcqp-tlb-podium-card.rank-1 .mcqp-tlb-podium-name {
    color: #111827 !important;
    font-weight: 700;
}
html[data-mcqp-theme="dark"] .mcqp-tlb-podium-card.rank-1 .mcqp-tlb-podium-time {
    color: #4b5563 !important;
}
html[data-mcqp-theme="dark"] .mcqp-tlb-podium-card.rank-1 .mcqp-tlb-podium-pill {
    background: #f59e0b !important;
    color: #111827 !important;
    border-color: #d97706 !important;
}

/* --- "YOUR RANK" badge (header, top-right): keep gold bg, DARK text --- */
html[data-mcqp-theme="dark"] .mcqp-tlb-myrank,
html[data-mcqp-theme="dark"] .mcqp-tlb-myrank * {
    color: #1f2937 !important;
}
html[data-mcqp-theme="dark"] .mcqp-tlb-myrank-num {
    color: #111827 !important;
}
html[data-mcqp-theme="dark"] .mcqp-tlb-myrank-lbl {
    color: #374151 !important;
    font-weight: 700;
}

/* --- Rank-2 & 3 podium cards: explicit dark surface + visible border --- */
html[data-mcqp-theme="dark"] .mcqp-tlb-podium-card.rank-2,
html[data-mcqp-theme="dark"] .mcqp-tlb-podium-card.rank-3 {
    background: #2a2f3e !important;
    border: 1px solid rgba(148, 163, 184, .25) !important;
    color: #e6ebf6 !important;
}
html[data-mcqp-theme="dark"] .mcqp-tlb-podium-card.rank-2 .mcqp-tlb-podium-name,
html[data-mcqp-theme="dark"] .mcqp-tlb-podium-card.rank-3 .mcqp-tlb-podium-name {
    color: #f8fafc !important;
    font-weight: 700;
}
html[data-mcqp-theme="dark"] .mcqp-tlb-podium-card.rank-2 .mcqp-tlb-podium-time,
html[data-mcqp-theme="dark"] .mcqp-tlb-podium-card.rank-3 .mcqp-tlb-podium-time {
    color: #94a3b8 !important;
}

/* --- Modal dialog itself: dark surface --- */
html[data-mcqp-theme="dark"] .mcqp-tlb-modal .mcqp-tlb-dialog {
    background: #1a1f2e !important;
    border: 1px solid rgba(148, 163, 184, .15) !important;
}

/* --- Close button (X, top-right): readable on dark dialog --- */
html[data-mcqp-theme="dark"] .mcqp-tlb-modal .mcqp-tlb-close {
    background: rgba(30, 41, 60, .85) !important;
    border-color: rgba(148, 163, 184, .25) !important;
    color: #cbd5e1 !important;
}
html[data-mcqp-theme="dark"] .mcqp-tlb-modal .mcqp-tlb-close:hover {
    background: rgba(51, 65, 85, .95) !important;
    color: #f1f5f9 !important;
}

/* --- Header title + subtitle --- */
html[data-mcqp-theme="dark"] .mcqp-fe .mcqp-tlb-title {
    color: #f8fafc !important;
}
html[data-mcqp-theme="dark"] .mcqp-fe .mcqp-tlb-sub {
    color: #fbbf24 !important;
}

/* --- Body section bg --- */
html[data-mcqp-theme="dark"] .mcqp-fe .mcqp-tlb-body {
    background: #1a1f2e !important;
}

/* --- Table: header row + body rows + visible separators --- */
html[data-mcqp-theme="dark"] .mcqp-tlb-thead {
    color: #94a3b8 !important;
    font-weight: 600;
    border-bottom: 1px solid rgba(148, 163, 184, .2) !important;
}
html[data-mcqp-theme="dark"] .mcqp-tlb-tr {
    border-bottom: 1px solid rgba(148, 163, 184, .12) !important;
}
html[data-mcqp-theme="dark"] .mcqp-tlb-tr-name,
html[data-mcqp-theme="dark"] .mcqp-tlb-tr-time {
    color: #e6ebf6 !important;
}
html[data-mcqp-theme="dark"] .mcqp-tlb-tr-rank,
html[data-mcqp-theme="dark"] .mcqp-tlb-row-sub {
    color: #94a3b8 !important;
}

/* --- Score colors: brighten for dark-bg readability --- */
html[data-mcqp-theme="dark"] .mcqp-tlb-tr-score.score-green { color: #84cc16 !important; }
html[data-mcqp-theme="dark"] .mcqp-tlb-tr-score.score-amber { color: #fbbf24 !important; }
html[data-mcqp-theme="dark"] .mcqp-tlb-tr-score.score-red   { color: #f87171 !important; }

/* --- "is-me" highlight row (purple-tinted) --- */
html[data-mcqp-theme="dark"] .mcqp-tlb-tr.is-me {
    background: rgba(99, 102, 241, .12) !important;
    border: 1px solid rgba(99, 102, 241, .3) !important;
}
html[data-mcqp-theme="dark"] .mcqp-tlb-tr.is-me .mcqp-tlb-tr-rank,
html[data-mcqp-theme="dark"] .mcqp-tlb-tr.is-me .mcqp-tlb-tr-name {
    color: #c7d2fe !important;
}
html[data-mcqp-theme="dark"] .mcqp-tlb-tr.is-me .mcqp-tlb-tr-time {
    color: #a5b4fc !important;
}
html[data-mcqp-theme="dark"] .mcqp-tlb-tr.is-me .mcqp-tlb-tr-score {
    color: #c7d2fe !important;
}

/* --- "..." divider before is-me row --- */
html[data-mcqp-theme="dark"] .mcqp-tlb-divider {
    color: #94a3b8 !important;
}

/* --- Empty / loading states --- */
html[data-mcqp-theme="dark"] .mcqp-tlb-loading,
html[data-mcqp-theme="dark"] .mcqp-tlb-empty {
    color: #94a3b8 !important;
}
