/* ==========================================================================
   Practice Sets module — CBT interface, results, and the gamified leaderboard.
   Namespaced under .pm- so nothing here can leak into the rest of the site.
   ========================================================================== */

:root {
    --pm-answered: #16a34a;
    --pm-notans:   #dc2626;
    --pm-notvis:   #cbd5e1;
    --pm-marked:   #7c3aed;
    --pm-ansmark:  #0d9488;
    --pm-current:  #f59e0b;
}

/* ── CBT layout ─────────────────────────────────────────────────────────── */
.pm-cbt { border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden; background: #fff; }
.pm-cbt-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 18px; background: #0f172a; color: #fff;
}
.pm-cbt-title { font-weight: 600; }
.pm-cbt-timer {
    font-weight: 700; font-variant-numeric: tabular-nums;
    background: #1e293b; padding: 6px 14px; border-radius: 999px;
}
.pm-timer-danger { background: var(--pm-notans) !important; animation: pmPulse 1s infinite; }
@keyframes pmPulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

.pm-cbt-body { display: grid; grid-template-columns: 1fr 300px; gap: 0; }
.pm-cbt-main { padding: 22px; min-height: 420px; display: flex; flex-direction: column; }
.pm-cbt-side { border-left: 1px solid #e2e8f0; padding: 18px; background: #f8fafc; }

.pm-q-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.pm-q-number { font-weight: 600; color: #334155; }
.pm-save-state { font-size: .8rem; color: var(--pm-answered); font-weight: 600; }
.pm-q-text { font-size: 1.12rem; line-height: 1.6; margin-bottom: 8px; }
.pm-q-desc { color: #64748b; margin-bottom: 12px; }

.pm-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
/* Questions & options sit on a WHITE surface (requested). */
.pm-option {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px;
    background: #fff; color: #0f172a;
    border: 2px solid #e2e8f0; border-radius: 10px; cursor: pointer; transition: all .15s;
}
/* On hover: keep the white background, colour the text with the site navbar navy. */
.pm-option:hover { border-color: #071a52; background: #fff; color: #071a52; }
.pm-option:hover .pm-option-text,
.pm-option:hover .pm-option-key { color: #071a52; }
.pm-option input { width: 18px; height: 18px; accent-color: #071a52; }
.pm-option:has(input:checked) { border-color: #071a52; background: #f4f7ff; }
.pm-option-key {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 50%; background: #e2e8f0;
    font-weight: 700; font-size: .85rem; flex: 0 0 auto;
}
.pm-option:has(input:checked) .pm-option-key { background: #071a52; color: #fff; }

.pm-cbt-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 16px; border-top: 1px solid #e2e8f0; }

/* Candidate + counters + palette */
.pm-candidate { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-weight: 600; }
.pm-avatar {
    width: 42px; height: 42px; border-radius: 50%; background: #2563eb; color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.pm-counters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 16px; font-size: .78rem; }
.pm-c { display: flex; align-items: center; gap: 6px; }
.pm-c b { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; border-radius: 6px; color: #fff; padding: 0 4px; }
.pm-c-answered b { background: var(--pm-answered); }
.pm-c-notans b { background: var(--pm-notans); }
.pm-c-notvis b { background: var(--pm-notvis); color: #334155; }
.pm-c-marked b { background: var(--pm-marked); }
.pm-c-ansmarked b { background: var(--pm-ansmark); }

.pm-palette { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.pm-pal {
    aspect-ratio: 1; border: none; border-radius: 8px; font-weight: 700; font-size: .9rem;
    background: var(--pm-notvis); color: #334155; cursor: pointer; transition: transform .1s;
}
.pm-pal:hover { transform: scale(1.08); }
.pm-pal-answered { background: var(--pm-answered); color: #fff; }
.pm-pal-not_answered { background: var(--pm-notans); color: #fff; }
.pm-pal-not_visited { background: var(--pm-notvis); color: #334155; }
.pm-pal-marked { background: var(--pm-marked); color: #fff; }
.pm-pal-answered_marked { background: var(--pm-ansmark); color: #fff; }
.pm-pal-current { outline: 3px solid var(--pm-current); outline-offset: 1px; }

@media (max-width: 800px) {
    .pm-cbt-body { grid-template-columns: 1fr; }
    .pm-cbt-side { border-left: none; border-top: 1px solid #e2e8f0; }
}

/* ── Result page ────────────────────────────────────────────────────────── */
.pm-result-hero { border: none; background: linear-gradient(135deg, #eff6ff, #f0fdf4); }
.pm-score-ring {
    width: 150px; height: 150px; border-radius: 50%; margin: 0 auto;
    background: conic-gradient(#16a34a calc(var(--pct) * 1%), #e2e8f0 0);
    display: flex; align-items: center; justify-content: center;
}
.pm-score-inner {
    width: 118px; height: 118px; border-radius: 50%; background: #fff;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.pm-score-num { font-size: 2rem; font-weight: 800; color: #0f172a; }
.pm-review-opt { padding: 8px 12px; border: 1px solid #e2e8f0; border-radius: 8px; }
.pm-opt-correct { background: #dcfce7; border-color: #16a34a; }
.pm-opt-wrong { background: #fee2e2; border-color: #dc2626; }
.pm-topic-bar { height: 10px; border-radius: 999px; }
.pm-standing .pm-big { font-size: 1.6rem; font-weight: 800; }
.pm-big { font-size: 1.6rem; font-weight: 800; }
.pm-set-card { transition: transform .15s, box-shadow .15s; }
.pm-set-card:hover { transform: translateY(-4px); box-shadow: 0 12px 28px rgba(0,0,0,.10); }

/* ==========================================================================
   Gamified leaderboard
   ========================================================================== */
.pm-lb { max-width: 900px; margin: 0 auto; }
.pm-public-head { margin: 24px 0; }
.pm-public-title { font-weight: 800; }

/* PUBG-style top-3 squad */
.pm-squad {
    background: radial-gradient(circle at 50% 0%, #1e293b, #0f172a);
    border-radius: 16px; padding: 20px 12px 0; color: #fff; margin-bottom: 26px;
    box-shadow: 0 16px 40px rgba(15,23,42,.35); overflow: hidden;
}
.pm-squad-title {
    text-align: center; font-weight: 800; letter-spacing: 2px; margin-bottom: 8px;
    background: linear-gradient(90deg,#f59e0b,#fde68a,#f59e0b);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    animation: pmShimmer 3s linear infinite; background-size: 200% auto;
}
@keyframes pmShimmer { to { background-position: 200% center; } }

.pm-podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; }
.pm-podium-slot { flex: 1; max-width: 200px; text-align: center; position: relative; }
.pm-slot-1 { z-index: 3; }
.pm-podium-avatar {
    width: 66px; height: 66px; border-radius: 50%; margin: 0 auto 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem; font-weight: 800; color: #0f172a;
    background: linear-gradient(135deg,#cbd5e1,#94a3b8); border: 3px solid #e2e8f0;
}
.pm-king {
    width: 84px; height: 84px; font-size: 2rem;
    background: linear-gradient(135deg,#fde68a,#f59e0b);
    border: 3px solid #fbbf24; box-shadow: 0 0 26px rgba(245,158,11,.8);
    animation: pmKingGlow 2s ease-in-out infinite;
}
@keyframes pmKingGlow { 0%,100% { box-shadow: 0 0 18px rgba(245,158,11,.6);} 50% { box-shadow: 0 0 34px rgba(245,158,11,1);} }
.pm-podium-name { font-weight: 700; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-king-name { color: #fde68a; font-size: 1.05rem; }
.pm-podium-pts { font-size: .8rem; color: #cbd5e1; margin-bottom: 8px; }
.pm-medal { font-size: 1.4rem; }
.pm-crown { font-size: 2rem; animation: pmFloat 2.4s ease-in-out infinite; }
@keyframes pmFloat { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-8px);} }

.pm-podium-stand {
    border-radius: 8px 8px 0 0; display: flex; align-items: flex-start; justify-content: center;
    padding-top: 8px; font-weight: 800; font-size: 1.1rem;
    animation: pmRise .6s ease-out both;
}
.pm-stand-1 { height: 96px; background: linear-gradient(180deg,#f59e0b,#b45309); color:#fff; }
.pm-stand-2 { height: 70px; background: linear-gradient(180deg,#94a3b8,#475569); color:#fff; }
.pm-stand-3 { height: 54px; background: linear-gradient(180deg,#d97706,#92400e); color:#fff; }
@keyframes pmRise { from { transform: scaleY(0); transform-origin: bottom; } to { transform: scaleY(1); } }
.pm-empty { opacity: .45; }

/* "Kings of the panel" list */
.pm-kings { display: flex; flex-direction: column; gap: 8px; }
.pm-king-row {
    display: flex; align-items: center; gap: 14px; padding: 12px 16px;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
    animation: pmSlideIn .4s ease-out both;
}
@keyframes pmSlideIn { from { opacity: 0; transform: translateX(-16px);} to { opacity: 1; transform: none; } }
.pm-king-row.pm-rank-1 { border: none; background: linear-gradient(90deg,#fffbeb,#fef3c7); box-shadow: 0 6px 18px rgba(245,158,11,.25); }
.pm-king-row.pm-rank-2 { background: linear-gradient(90deg,#f8fafc,#f1f5f9); }
.pm-king-row.pm-rank-3 { background: linear-gradient(90deg,#fff7ed,#ffedd5); }
.pm-king-row.pm-me { outline: 2px solid #2563eb; }
.pm-king-rank { width: 34px; text-align: center; font-size: 1.3rem; font-weight: 800; color: #64748b; }
.pm-king-avatar {
    width: 44px; height: 44px; border-radius: 50%; flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; color: #fff; background: linear-gradient(135deg,#3b82f6,#1d4ed8);
}
.pm-rank-1 .pm-king-avatar { background: linear-gradient(135deg,#f59e0b,#b45309); }
.pm-king-info { flex: 1; min-width: 0; }
.pm-king-nm { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-king-sub { font-size: .78rem; color: #64748b; }
.pm-king-pts { font-weight: 800; font-size: 1.15rem; color: #0f172a; }
.pm-king-pts small { font-size: .7rem; color: #94a3b8; font-weight: 600; margin-left: 2px; }

.pm-my-standing {
    margin-top: 14px; padding: 12px 18px; border-radius: 12px; text-align: center;
    background: #eff6ff; border: 1px dashed #2563eb; display: flex; gap: 12px; justify-content: center; align-items: center;
}
.pm-my-standing strong { font-size: 1.3rem; }

.pm-join-cta {
    margin: 30px auto; max-width: 640px; padding: 28px; border-radius: 16px;
    background: linear-gradient(135deg,#0f172a,#1e293b); color: #fff;
}
.pm-join-cta .btn { margin: 6px; }

/* The leaderboard rows may follow the OS theme, but the EXAM surface stays
   white on purpose (requested) — questions and options never go dark. */
@media (prefers-color-scheme: dark) {
    .pm-king-row { background: #1e293b; border-color: #334155; color: #e2e8f0; }
    .pm-score-inner { background: #1e293b; }
}

/* ==========================================================================
   Distraction-free exam layout (users.layouts.practice-exam)
   ========================================================================== */
.pm-exam-body { margin: 0; background: #eef2f7; min-height: 100vh; }
.pm-exam-topbar {
    position: sticky; top: 0; z-index: 1030;
    background: linear-gradient(90deg, #071a52 0%, #0b2e75 100%);
    color: #fff; box-shadow: 0 4px 20px rgba(0,0,0,.15);
}
.pm-exam-topbar-inner {
    max-width: 1200px; margin: 0 auto; padding: 10px 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.pm-exam-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pm-exam-logo { height: 34px; width: auto; }
.pm-exam-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.pm-exam-topbar-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.pm-exam-timer {
    font-weight: 800; font-variant-numeric: tabular-nums;
    background: rgba(255,255,255,.15); padding: 6px 14px; border-radius: 999px; white-space: nowrap;
}
.pm-exam-timer.pm-untimed { opacity: .8; }
.pm-exam-main { max-width: 1200px; margin: 18px auto; padding: 0 16px; }

/* On the exam page the CBT card is the focus; give it room. */
.pm-exam-main .pm-cbt { box-shadow: 0 10px 30px rgba(15,23,42,.10); }
.pm-question { background: #fff; }

/* Locked (paused) — blur the content behind the overlay. */
.pm-cbt.pm-locked .pm-cbt-body { filter: blur(6px); pointer-events: none; user-select: none; }
.pm-pause-overlay {
    position: fixed; inset: 0; z-index: 1080;
    background: rgba(7,26,82,.55); backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center;
}
.pm-pause-card {
    background: #fff; border-radius: 16px; padding: 34px 40px; text-align: center;
    max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.pm-pause-icon { font-size: 3rem; color: #071a52; }
.pm-pause-card h3 { margin: 8px 0; color: #071a52; }
.pm-pause-card p { color: #64748b; }
.pm-btn-pause { border-color: rgba(255,255,255,.6); }

/* Submit confirmation overlay (custom — no Bootstrap JS dependency). */
.pm-confirm-overlay {
    position: fixed; inset: 0; z-index: 1090;
    background: rgba(7,26,82,.55); backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.pm-confirm-overlay.d-none { display: none !important; }
.pm-confirm-card {
    background: #fff; border-radius: 16px; padding: 26px 30px; width: 100%; max-width: 460px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.pm-confirm-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 12px; }
.pm-confirm-actions form { margin: 0; }

@media (max-width: 640px) {
    .pm-exam-name { max-width: 34vw; font-size: .9rem; }
    .pm-exam-topbar-actions .btn { padding: 4px 8px; }
}
