/* The student's «التحدي» tab: scheduled challenges (student-challenge.js). Phone-first, design tokens only. */

/* the old stage quiz stays in the page for one release, hidden: only the challenges show in this tab */
#panel-quiz > :not(#ch-st-root) { display: none !important; }
.chs { display: flex; flex-direction: column; gap: var(--s4); }
.chs:empty { display: none; }
/* math (student-challenge-core.js mathHtml): the text reads right to left like the book, each number is its own
   left-to-right piece; a fixed direction here, so an option made only of numbers («٧ : ٩») is never flipped */
.chs bdi.math-text, .chs-fb bdi.math-text { unicode-bidi: isolate; direction: rtl; }
.chs bdi[dir="ltr"] { unicode-bidi: isolate; direction: ltr; }
/* hints and the «الصحيحة» line: the math font (the page font's ٠–٩ are small next to ²، ÷ and ٫) */
.chs-hint bdi.math-text, .chs-rv-hint bdi.math-text, .chs-fb bdi.math-text { font-family: var(--f-math); font-size: 17.5px; }

/* ---- cards ---- */
.chs-card { padding: var(--s5) var(--s4); display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s2); }
.chs-big-ic { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; font-size: 44.5px; background: var(--tint); color: var(--primary); margin-bottom: var(--s1); }
.chs-up .chs-big-ic { background: var(--reward-tint); color: var(--reward); }
.chs-ic-ok { background: var(--success-tint); color: var(--success); }
.chs-ic-lock { background: var(--tint); color: var(--primary); }
.chs-kicker { font-family: var(--f-head); font-weight: var(--hw); font-size: 18.5px; color: var(--on-tint); }
.chs-title { font-family: var(--f-head); font-weight: 800; font-size: 24px; line-height: 1.35; color: var(--text); overflow-wrap: anywhere; }
.chs-lessons, .chs-when { display: inline-flex; align-items: flex-start; gap: 6px; font-size: 15.5px; color: var(--muted); line-height: 1.5; }
.chs-lessons i, .chs-when i { font-size: 20px; flex: none; margin-top: 1px; color: var(--on-tint); }
.chs-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s2); }
.chs-pill, .chs-count { display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding-inline: 12px; border-radius: var(--r-pill); font-size: 14.5px; font-weight: 700; }
.chs-pill i, .chs-count i { font-size: 17.5px; }
.chs-pill--test { background: var(--tint); color: var(--on-tint); }
.chs-pill--train { background: var(--success-tint); color: var(--on-success); }
.chs-count { background: rgb(var(--border-rgb) / .5); color: var(--muted); }
.chs-note { font-size: 15px; color: var(--muted); }
.chs-sub { font-size: 16.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.chs-sub i, .chs-score i { color: var(--reward); }
.chs-score { font-family: var(--f-head); font-weight: 800; font-size: 36px; line-height: 1.2; color: var(--text); display: inline-flex; align-items: center; gap: 8px; }
.chs-card .btn { margin-top: var(--s2); }
.chs-card .btn + .btn { margin-top: 0; }

/* the clock: «يبدأ بعد …» / «باقي ٤٨ دقيقة» */
.chs-timer { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; padding: 8px var(--s3); border-radius: var(--r-btn); background: var(--reward-tint); color: var(--on-reward); font-family: var(--f-head); font-weight: 800; font-size: 18.5px; }
.chs-timer i { font-size: 24px; }
.chs-timer--soft { background: rgb(var(--border-rgb) / .45); color: var(--muted); font-size: 16.5px; min-height: 40px; }
.chs-timer.is-low { background: var(--error-tint); color: var(--error); }
@media (prefers-reduced-motion: no-preference) { .chs-timer.is-low i { animation: chsPulse 1.2s ease-in-out infinite; } }
@keyframes chsPulse { 50% { transform: scale(1.15); } }

/* live: a coloured edge and a «جاري الآن» tag */
.chs-live { border: 2px solid var(--success); box-shadow: 0 0 0 4px var(--success-tint), var(--card-shadow); }
.chs-live-tag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: var(--r-pill); background: var(--success-tint); color: var(--on-success); font-weight: 800; font-size: 15.5px; }
.chs-live-tag i { font-size: 20px; }
@media (prefers-reduced-motion: no-preference) { .chs-live-tag i { animation: chsPulse 1.6s ease-in-out infinite; } }

.chs-next { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 15px; color: var(--muted); text-align: center; }
.chs-next i { font-size: 20px; color: var(--primary); flex: none; }

/* empty / loading */
.chs-empty .chs-empty-h { font-family: var(--f-head); font-weight: 800; font-size: 21px; color: var(--text); }
.chs-empty p:last-child { max-width: 30ch; line-height: 1.7; }
.chs-loading { flex-direction: row; justify-content: center; gap: 8px; padding-block: var(--s6); }
.chs-loading span { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); opacity: .3; }
@media (prefers-reduced-motion: no-preference) {
    .chs-loading span { animation: chsDot 1s ease-in-out infinite; }
    .chs-loading span:nth-child(2) { animation-delay: .15s; }
    .chs-loading span:nth-child(3) { animation-delay: .3s; }
}
@keyframes chsDot { 50% { opacity: 1; transform: translateY(-4px); } }

/* past challenges: compact rows */
.chs-past { padding: var(--s3) var(--s3) var(--s2); }
.chs-past-h { display: flex; align-items: center; gap: 6px; font-family: var(--f-head); font-weight: var(--hw); font-size: 17.5px; color: var(--text); padding: 0 var(--s1) var(--s2); }
.chs-past-h i { font-size: 22px; color: var(--primary); }
.chs-past ul { list-style: none; margin: 0; padding: 0; }
.chs-past li + li { border-top: 1px solid var(--border); }
.chs-row { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 60px; padding: 8px var(--s1); background: none; border: 0; color: inherit; text-align: start; cursor: pointer; border-radius: var(--r-btn); }
.chs-row:hover { background: var(--tint); }
.chs-row:focus-visible { outline: 3px solid var(--primary); outline-offset: -2px; }
.chs-row-ic { width: 38px; height: 38px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--tint); color: var(--primary); font-size: 21px; }
.chs-row-t { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.chs-row-t b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chs-row-t small { font-size: 14px; color: var(--muted); }
.chs-row-s { flex: none; display: inline-flex; align-items: center; gap: 4px; font-weight: 800; font-size: 15.5px; color: var(--text); }
.chs-row-s i { color: var(--reward); }
.chs-row-go { flex: none; color: var(--muted); font-size: 17.5px; }

/* ---- playing: the top bar, the dots, the question, the answers ---- */
.chs-play-top { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.chs-back { width: 48px; height: 48px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-size: 24px; cursor: pointer; }
.chs-back:hover { background: var(--tint); }
.chs-back:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.chs-play-id { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.chs-play-id b { font-family: var(--f-head); font-weight: 800; font-size: 18.5px; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
.chs-play-id small { font-size: 15.5px; color: var(--on-tint); font-weight: 700; }
.chs-timer--sm { width: auto; min-height: 40px; font-size: 16.5px; padding-inline: 12px; }
.chs-timer--sm i { font-size: 21px; }
.chs-dots { display: flex; gap: 5px; }
.chs-dots i { flex: 1; height: 8px; border-radius: var(--r-pill); background: var(--tint); }
.chs-dots i.is-done { background: var(--primary); }
.chs-dots i.is-now { background: var(--reward); }
.chs-q { padding: var(--s4); display: flex; flex-direction: column; gap: var(--s2); }
.chs-q-k { display: inline-flex; align-items: center; gap: 6px; font-size: 15.5px; color: var(--muted); }
.chs-q-k i { font-size: 20px; color: var(--primary); }
.chs-q-t { font-family: var(--f-math); font-weight: var(--dw); font-size: 23px; line-height: 1.6; color: var(--text); overflow-wrap: anywhere; }
.chs-answers { grid-template-columns: 1fr 1fr; }
.chs-ans { justify-content: flex-start; text-align: start; font-size: 20px; padding: 10px 12px; min-height: 60px; }
.chs-letter { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--tint); color: var(--on-tint); font-family: var(--f-head); font-weight: 700; font-size: 15.5px; }
.chs-ans[aria-pressed="true"] .chs-letter { background: var(--primary); color: var(--on-primary); }
.chs-ans .chs-x { position: absolute; inset-block-start: 6px; inset-inline-end: 6px; font-size: 22px; color: var(--error); display: none; }
.chs-ans.chs-wrong { border-color: var(--error); background: var(--error-tint); opacity: 1 !important; box-shadow: none; }
.chs-ans.chs-wrong .chs-x { display: block; }
.chs-ans.chs-wrong .ok { display: none; }
.chs-ans.opt-reveal .chs-letter { background: var(--success); color: #fff; }
/* long options (word problems) read better one per row */
@media (max-width: 420px) { .chs-answers { grid-template-columns: 1fr; } .chs-ans { min-height: 56px; } }

.chs-fb { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 8px var(--s3); border-radius: var(--r-btn); font-weight: 800; font-size: 17.5px; text-align: center; flex-wrap: wrap; }
.chs-fb i { font-size: 24px; }
.chs-fb--ok { background: var(--success-tint); color: var(--on-success); }
.chs-fb--no { background: var(--error-tint); color: var(--error); }
.chs-hint p:last-child { line-height: 1.7; }
.chs-skip { font-size: 16.5px; }

/* ---- review ---- */
.chs-rv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s3); }
.chs-rv { padding: var(--s4); display: flex; flex-direction: column; gap: var(--s2); border-inline-start: 4px solid var(--border); }
.chs-rv--ok { border-inline-start-color: var(--success); }
.chs-rv--no { border-inline-start-color: var(--error); }
.chs-rv-h { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); font-size: 15.5px; color: var(--muted); }
.chs-rv-b { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; padding: 2px 10px; border-radius: var(--r-pill); background: rgb(var(--border-rgb) / .5); }
.chs-rv--ok .chs-rv-b { background: var(--success-tint); color: var(--on-success); }
.chs-rv--no .chs-rv-b { background: var(--error-tint); color: var(--error); }
.chs-rv-t { font-family: var(--f-math); font-weight: var(--dw); font-size: 20px; line-height: 1.6; color: var(--text); overflow-wrap: anywhere; }
.chs-rv-os { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.chs-rv-o { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 10px; border-radius: var(--r-btn); border: 1px solid var(--border); font-family: var(--f-math); font-size: 17.5px; }
.chs-rv-o > i { font-size: 24px; flex: none; }
.chs-rv-o .chs-letter { width: 22px; height: 22px; font-size: 13px; }
.chs-rv-o small { margin-inline-start: auto; font-family: var(--f-body); font-size: 13px; font-weight: 700; color: var(--muted); }
.chs-rv-o.is-right { border-color: var(--success); background: var(--success-tint); color: var(--on-success); }
.chs-rv-o.is-right > i { color: var(--success); }
.chs-rv-o.is-wrong { border-color: var(--error); background: var(--error-tint); color: var(--error); }
.chs-rv-hint { display: flex; align-items: flex-start; gap: 6px; padding: 8px 10px; border-radius: var(--r-btn); background: var(--reward-tint); color: var(--on-reward); font-size: 15.5px; line-height: 1.7; }
.chs-rv-hint i { font-size: 20px; flex: none; margin-top: 2px; color: var(--warn); }

/* ---- the in-app banner (any tab): «بدأ التحدي!» ---- */
.chs-banner { position: fixed; z-index: 60; inset-inline: var(--s3); top: calc(var(--s3) + env(safe-area-inset-top, 0px)); max-width: 520px; margin-inline: auto; display: flex; align-items: center; gap: var(--s3); padding: var(--s3); border-radius: var(--r-card); color: #fff; background: linear-gradient(110deg, var(--primary), var(--deep)); box-shadow: 0 14px 34px -10px rgb(var(--primary-rgb) / .6); animation: chsDown .3s cubic-bezier(.2, .8, .2, 1); }
.chs-banner--remind { background: linear-gradient(110deg, #C2410C, #B91C1C); box-shadow: 0 14px 34px -10px rgb(185 28 28 / .55); }
.chs-banner-ic { width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; background: rgb(255 255 255 / .18); font-size: 27.5px; }
.chs-banner-t { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.chs-banner-t b { font-family: var(--f-head); font-weight: 800; font-size: 17.5px; }
.chs-banner-t small { font-size: 14.5px; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chs-banner-go { flex: none; background: #fff; color: var(--deep); font-weight: 800; }
.chs-banner--remind .chs-banner-go { color: #B91C1C; }
.chs-banner-x { width: 36px; height: 36px; flex: none; border-radius: 50%; border: 0; background: rgb(255 255 255 / .15); color: #fff; display: grid; place-items: center; font-size: 20px; cursor: pointer; }
.chs-banner-x:focus-visible, .chs-banner-go:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
@media (max-width: 420px) {
    .chs-banner { flex-wrap: wrap; }
    .chs-banner-t { flex-basis: calc(100% - 44px - 36px - 2 * var(--s3)); }
    .chs-banner-go { width: 100%; order: 4; }
}
@media (prefers-reduced-motion: reduce) { .chs-banner { animation: none; } }
@keyframes chsDown { from { transform: translateY(-120%); opacity: 0; } }

/* «متصدرات التحديات» (student-rank.js): the place number after the three medals, the stars */
#ch-rank-root .lb-n { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 9999px; background: var(--surface); font-size: 15.5px; color: var(--muted); }
#ch-rank-root .lb-time { display: inline-flex; align-items: center; gap: 4px; }
#ch-rank-root .lb-time i { color: #f59e0b; }
.chs-place:empty { display: none; }
