/* =============================================================================
 * quiz.css — the Education quiz (js/quiz.js): the quiz page (#/quiz) and its parts in the IDP
 * =============================================================================
 * Built from the site's tokens (css/styles.css) and the shared "hub-" pieces (css/kitchen-idp.css): white cards with
 * hairlines, the serif for headings, ink buttons. The three categories have fixed colours (the same whatever the
 * club's theme), like the IDP's areas. Phone first; logical properties, so Arabic mirrors.
 *
 *   1. Categories' colours, the count on the Education link
 *   2. Above the quiz: the banner, the player's points, the quizzes from the staff
 *   3. Categories and quizzes
 *   4. Playing: progress, question, answers, the explanation
 *   5. The result: the score ring, saved, the questions missed
 *   6. In the IDP: a player's Quiz tab, the squad, "Give a quiz", the quizzes of a talk or a goal
 *   7. Responsive, touch, motion, print
 * ========================================================================== */

/* ------------------------------------------- 1. COLOURS, THE COUNT ON THE LINK */
.quiz-cat-1 { --cat: #3d6b4f; --cat-soft: #ebf5ee; }   /* A · Performance */
.quiz-cat-2 { --cat: #5b6b3a; --cat-soft: #f2f5eb; }   /* B · Daily lifestyle */
.quiz-cat-3 { --cat: #8a5a00; --cat-soft: #fbefd2; }   /* C · In practice */
.quiz-cat-4 { --cat: #0b3a75; --cat-soft: #e0e9f6; }
.quiz-cat-5 { --cat: #4f3f8f; --cat-soft: #ebe7f7; }
.quiz-cat-6 { --cat: #0f6b63; --cat-soft: #dcf1ee; }

/* The quizzes the staff gave a player and they have not passed yet: on the Education link and the Quiz tab (whose
   ::after is its underline: the count is its ::before, placed after the label as the tab is a flex box) */
a[data-route="education"][data-count]::after, a[data-edu-tab="quiz"][data-count]::before {
  content: attr(data-count); display: inline-block; min-width: 1.35em; margin-inline-start: .35em; padding: .05em .4em;
  font: 700 .7rem/1.35 var(--font-body); text-align: center; vertical-align: .15em; color: #fff; background: #b00020; border-radius: 999px;
}
a[data-edu-tab="quiz"][data-count]::before { order: 1; }

/* ------------------------------------------------------ 2. ABOVE THE QUIZ */
.quiz { display: grid; gap: var(--s5); max-width: 52rem; }
.quiz-head { display: grid; gap: var(--s4); }
.quiz-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin: 0; padding: .7rem 1rem;
  font-size: .9375rem; font-weight: 600; color: #4d3b00; background: #fff6d6; border: 1px solid #e8c24a; border-radius: var(--radius-ctl);
}
.quiz-banner.is-login { color: var(--ink); background: var(--white); border-color: var(--line); }
.quiz-banner.is-login > span:nth-child(2) { flex: 1 1 14rem; }
.quiz-banner-icon { display: grid; flex: none; }
.quiz-banner-icon svg { width: 1.2rem; height: 1.2rem; }
.quiz-staff-link { margin: 0; font-size: .9375rem; }
.quiz-staff-link a { font-weight: 600; color: var(--ink); }

.quiz-tiles { margin-bottom: var(--s4); }
.quiz-dash .hub-tiles:last-child { margin-bottom: 0; }
.quiz-recent { display: grid; gap: .35rem; margin: 0; padding: 0; list-style: none; }
.quiz-recent li {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: .6rem;
  padding: .5rem .75rem; font-size: .9375rem; background: var(--paper); border-radius: 12px;
}
.quiz-recent-icon { font-size: 1.1rem; }
.quiz-recent-title { font-weight: 600; overflow-wrap: anywhere; }
.quiz-recent-date { font-size: .8125rem; color: var(--grey-700); white-space: nowrap; }
.quiz-score-chip {
  display: inline-flex; align-items: center; gap: .25rem; padding: .1rem .5rem; font-size: .8125rem; font-weight: 700;
  font-variant-numeric: tabular-nums; color: var(--grey-700); background: var(--mist); border-radius: 999px; white-space: nowrap;
}
.quiz-score-chip.is-pass { color: #1d6b2f; background: #e2f2e5; }
.quiz-score-chip.is-full { color: #fff; background: #1d6b2f; }

.quiz-given-list { display: grid; gap: var(--s2); margin: 0; padding: 0; list-style: none; }
.quiz-given-list + .quiz-given-list { margin-top: var(--s3); }
.quiz-given-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .75rem; padding: .75rem .9rem;
  background: var(--white); border: 1px solid var(--line); border-inline-start: 4px solid var(--ink); border-radius: 14px;
}
.quiz-given-item.is-new { box-shadow: 0 0 0 2px #b00020; }
.quiz-given-item.is-overdue { border-inline-start-color: #b00020; }
.quiz-given-item.is-done { border-inline-start-color: #1d6b2f; background: var(--paper); }
.quiz-given-icon { font-size: 1.5rem; line-height: 1; }
.quiz-given-main { display: grid; gap: .2rem; min-width: 0; }
.quiz-given-name { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.quiz-given-note { margin: .15rem 0 0; padding: .4rem .65rem; font-size: .875rem; background: var(--mist); border-radius: 10px; overflow-wrap: anywhere; }
.quiz-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .7rem; margin: 0; font-size: .8125rem; color: var(--grey-700); }
.quiz-meta .is-overdue { font-weight: 700; color: #b00020; }
.quiz-meta .is-pass { font-weight: 700; color: #1d6b2f; }

/* ---------------------------------------------------- 3. CATEGORIES, QUIZZES */
.quiz-stage { display: grid; gap: var(--s4); }
.quiz-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; font-size: .875rem; color: var(--grey-700); }
.quiz-crumb { display: inline-flex; align-items: center; padding: .2rem 0; font: inherit; font-weight: 600; color: var(--grey-700); background: none; border: 0; cursor: pointer; }
button.quiz-crumb:hover { color: var(--ink); text-decoration: underline; }
.quiz-crumb.is-here { font-weight: 500; cursor: default; }
.quiz-crumb-sep { opacity: .5; }

.quiz-section { display: grid; gap: var(--s4); }
.quiz-h { margin: 0; font: 500 var(--step-2)/1.15 var(--font-display); }
.quiz-sub { margin: -.5rem 0 0; color: var(--grey-700); }
.quiz-result .quiz-sub { margin: 0; }

.quiz-cats, .quiz-topics { display: grid; gap: var(--s3); }
.quiz-topics { grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); }
.quiz-cat, .quiz-topic {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--s4); width: 100%;
  padding: var(--s4) var(--s5); text-align: start; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--white); border: 1.5px solid var(--line); border-radius: var(--radius-card);
  transition: border-color .15s, transform .15s var(--ease), box-shadow .15s;
}
.quiz-cat { border-color: color-mix(in srgb, var(--cat) 25%, var(--line)); }
.quiz-cat:hover, .quiz-topic:hover { border-color: var(--cat, var(--ink)); box-shadow: 0 10px 24px -18px rgb(20 20 19 / .5); transform: translateY(-1px); }
.quiz-cat:focus-visible, .quiz-topic:focus-visible { outline: 3px solid var(--cat, var(--ink)); outline-offset: 2px; }
.quiz-cat-emoji {
  display: grid; place-items: center; width: 3.5rem; height: 3.5rem; font-size: 1.6rem; line-height: 1;
  background: var(--cat-soft, var(--mist)); border-radius: 16px;
}
.quiz-cat-emoji.is-small { width: 2.75rem; height: 2.75rem; font-size: 1.3rem; border-radius: 12px; }
.quiz-cat-body, .quiz-topic-body { display: grid; gap: .25rem; min-width: 0; }
.quiz-cat-label { margin: 0; font-size: .75rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--cat, var(--grey-700)); }
[lang="ar"] .quiz-cat-label { letter-spacing: 0; text-transform: none; }
.quiz-cat-title { font: 500 var(--step-1)/1.2 var(--font-display); }
.quiz-cat-meta { font-size: .875rem; color: var(--grey-700); }
.quiz-cat-head { display: flex; align-items: center; gap: var(--s3); }
.quiz-chevron { display: grid; color: var(--grey-500); }
.quiz-chevron svg { width: 1.25rem; height: 1.25rem; }
[dir="rtl"] .quiz-chevron svg { transform: scaleX(-1); }

.quiz-topic { padding: var(--s4); gap: var(--s3); border-radius: 18px; }
.quiz-topic.is-given { border-color: #b00020; }
.quiz-topic-icon { font-size: 1.9rem; line-height: 1; }
.quiz-topic-title { font-weight: 700; overflow-wrap: anywhere; }

/* A bar: --p is its share (set by js/quiz.js) */
.quiz-bar { position: relative; display: block; width: 100%; height: 6px; overflow: hidden; background: var(--mist); border-radius: 999px; }
.quiz-bar.is-big { height: 8px; }
.quiz-bar-fill {
  position: absolute; inset-block: 0; inset-inline-start: 0; width: var(--p, 0%);
  background: var(--cat, var(--ink)); border-radius: inherit; transition: width .4s var(--ease);
}

/* ------------------------------------------------------------ 4. PLAYING */
.quiz-play { display: grid; gap: var(--s4); max-width: 42rem; }
.quiz-play.is-fresh, .quiz-result.is-fresh { animation: quiz-in .25s var(--ease); }
.quiz-progress { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); font-size: .875rem; }
.quiz-progress-title { font-weight: 600; color: var(--grey-700); overflow-wrap: anywhere; }
.quiz-progress-n { flex: none; font-weight: 800; font-variant-numeric: tabular-nums; }
.quiz-question { margin: 0; font: 600 var(--step-1)/1.4 var(--font-body); }
.quiz-question:focus { outline: none; }
.quiz-options { display: grid; gap: var(--s2); }
.quiz-option {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: .8rem; width: 100%; min-height: 3.25rem;
  padding: .75rem 1rem; text-align: start; font: inherit; font-size: .9375rem; font-weight: 600; color: var(--ink); cursor: pointer;
  background: var(--white); border: 2px solid var(--line); border-radius: 14px; transition: border-color .15s, background-color .15s;
}
.quiz-option:hover:not([aria-disabled="true"]) { border-color: var(--cat, var(--ink)); background: var(--cat-soft, var(--mist)); }
.quiz-option:focus-visible { outline: 3px solid var(--cat, var(--ink)); outline-offset: 2px; }
.quiz-option[aria-disabled="true"] { cursor: default; }
.quiz-letter {
  display: grid; place-items: center; width: 1.9rem; height: 1.9rem; font-size: .875rem; font-weight: 800;
  color: var(--grey-700); background: var(--mist); border-radius: 50%;
}
.quiz-letter svg { width: 1.1rem; height: 1.1rem; }
.quiz-option-text { overflow-wrap: anywhere; }
.quiz-option.is-right { color: #13461f; background: #e2f2e5; border-color: #1d6b2f; }
.quiz-option.is-right .quiz-letter { color: #fff; background: #1d6b2f; }
.quiz-option.is-wrong { color: #7a0016; background: #fbe3e6; border-color: #b00020; }
.quiz-option.is-wrong .quiz-letter { color: #fff; background: #b00020; }
.quiz-option.is-out { opacity: .6; }

.quiz-feedback { display: grid; gap: var(--s3); }
.quiz-feedback:empty { display: none; }
.quiz-verdict { margin: 0; font-weight: 800; animation: quiz-in .2s var(--ease); }
.quiz-verdict.is-right { color: #1d6b2f; }
.quiz-verdict.is-wrong { color: #b00020; }
.quiz-why {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .6rem; margin: 0; padding: .85rem 1rem;
  font-size: .9375rem; line-height: 1.55; background: var(--cat-soft, var(--mist)); border-radius: 14px; animation: quiz-in .25s var(--ease);
}
.quiz-why-icon { display: grid; color: var(--cat, var(--ink)); }
.quiz-why-icon svg { width: 1.25rem; height: 1.25rem; }
.quiz-next { width: 100%; justify-content: center; }

@keyframes quiz-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------ 5. THE RESULT */
.quiz-result { display: grid; justify-items: center; gap: var(--s3); max-width: 42rem; padding: var(--s6) var(--s5); text-align: center; }
.quiz-result-emoji { margin: 0; font-size: 3rem; line-height: 1; }
.quiz-result-title { margin: 0; font: 500 var(--step-2)/1.15 var(--font-display); }
.quiz-result-title:focus { outline: none; }
.quiz-ring {
  display: grid; place-content: center; justify-items: center; width: 8.5rem; height: 8.5rem; margin: var(--s2) 0; border-radius: 50%;
  background: radial-gradient(closest-side, var(--white) 79%, transparent 80%), conic-gradient(var(--cat, var(--ink)) var(--p, 0%), var(--mist) 0);
}
.quiz-ring-score { font: 600 2rem/1 var(--font-display); font-variant-numeric: tabular-nums; color: var(--cat, var(--ink)); }
.quiz-ring-label { font-size: .8125rem; color: var(--grey-700); }
.quiz-result-text { max-width: 32rem; margin: 0; color: var(--grey-700); }
.quiz-saved, .quiz-given-done {
  display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .4rem; margin: 0; padding: .5rem .9rem;
  font-size: .9375rem; font-weight: 600; color: var(--grey-700); background: var(--mist); border-radius: 12px;
}
.quiz-saved.is-ok, .quiz-given-done.is-pass { color: #1d6b2f; background: #e2f2e5; }
.quiz-saved.is-error { color: #a3001b; background: #fbe3e6; }
.quiz-saved-icon { display: grid; }
.quiz-saved-icon svg { width: 1.1rem; height: 1.1rem; }
.quiz-link-btn { padding: 0; font: inherit; font-weight: 700; color: var(--ink); text-decoration: underline; background: none; border: 0; cursor: pointer; }
.quiz-review { width: 100%; text-align: start; background: var(--paper); border-radius: 14px; }
.quiz-review summary { padding: .75rem 1rem; font-weight: 700; cursor: pointer; }
.quiz-review ol { display: grid; gap: var(--s3); margin: 0; padding: 0 1rem 1rem 2.25rem; }
.quiz-review-q { margin: 0 0 .25rem; font-weight: 600; }
.quiz-review-a { display: flex; gap: .4rem; margin: 0; color: #1d6b2f; }
.quiz-review-icon { display: grid; flex: none; padding-top: .15rem; }
.quiz-review-icon svg { width: 1rem; height: 1rem; }
.quiz-result-actions { justify-content: center; }

/* ------------------------------------------------------------ 6. IN THE IDP */
.quiz-panel { display: grid; gap: var(--s4); }
.quiz-panel > p { margin: 0; }
.quiz-panel-part .hub-h { margin-bottom: var(--s3); }
.quiz-by-cat + .quiz-by-cat { margin-top: var(--s4); }
.quiz-by-cat-title { margin: 0 0 var(--s2); font-size: .875rem; font-weight: 800; color: var(--cat); }
.quiz-by-topic { display: grid; gap: .3rem; margin: 0; padding: 0; list-style: none; }
.quiz-by-topic li {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(4rem, 1fr) auto; align-items: center; gap: .3rem .75rem;
  padding: .55rem .75rem; background: var(--paper); border-radius: 12px;
}
.quiz-by-topic li.is-none { color: var(--grey-700); }
.quiz-by-topic-name { font-weight: 600; overflow-wrap: anywhere; }
.quiz-by-topic-score { font-weight: 800; font-variant-numeric: tabular-nums; }
.quiz-by-topic .quiz-meta, .quiz-by-topic .quiz-missed { grid-column: 1 / -1; }
.quiz-missed summary { font-size: .8125rem; font-weight: 700; color: #b00020; cursor: pointer; }
.quiz-missed ul { margin: .35rem 0 0; padding-inline-start: 1.25rem; font-size: .875rem; }

.quiz-state { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .55rem; font-size: .75rem; font-weight: 700; border-radius: 999px; }
.quiz-state.is-open { color: var(--ink); background: var(--mist); }
.quiz-state.is-overdue { color: #fff; background: #b00020; }
.quiz-state.is-pass { color: #1d6b2f; background: #e2f2e5; }

.quiz-give-open { justify-self: start; }
.quiz-give { display: grid; gap: var(--s3); }
.quiz-give .hub-h, .quiz-give .hub-hint { margin: 0; }
.quiz-give fieldset, .quiz-talk fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.quiz-give legend { margin-bottom: .4rem; font-size: .875rem; font-weight: 700; }
.quiz-pick { display: grid; gap: var(--s3); }
.quiz-pick-cat legend { font-size: .8125rem; font-weight: 800; color: var(--cat); }
.quiz-pick-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.quiz-pick-chip {
  display: inline-flex; align-items: center; gap: .4rem; min-height: 38px; padding: .3rem .75rem .3rem .55rem; font-size: .875rem; font-weight: 600;
  background: var(--white); border: 1.5px solid var(--line); border-radius: 999px; cursor: pointer;
}
.quiz-pick-chip:has(input:checked) { color: var(--cat, var(--ink)); background: var(--cat-soft, var(--mist)); border-color: var(--cat, var(--ink)); }
.quiz-pick-chip input { width: 1rem; height: 1rem; margin: 0; accent-color: var(--cat, var(--ink)); }
.quiz-pick-chip.is-all { margin-bottom: .4rem; }

.quiz-squad .quiz-bar { max-width: 7rem; margin-top: .3rem; }
.quiz-squad-last { font-size: .875rem; overflow-wrap: anywhere; }

.quiz-linked { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0 0; padding: 0; list-style: none; }
.quiz-linked .quiz-state { font-size: .8125rem; }

/* ---------------------------------------------- 7. RESPONSIVE, TOUCH, MOTION, PRINT */
@media (max-width: 560px) {
  .quiz-cat, .quiz-topic { padding: var(--s4); gap: var(--s3); }
  .quiz-cat-emoji { width: 2.9rem; height: 2.9rem; font-size: 1.35rem; }
  .quiz-recent li { grid-template-columns: auto minmax(0, 1fr) auto; }
  .quiz-recent-date { display: none; }
  .quiz-given-item { grid-template-columns: auto minmax(0, 1fr); }
  .quiz-given-item > .btn-primary, .quiz-given-item > .hub-icon-btn { grid-column: 1 / -1; justify-self: start; }
  .quiz-by-topic li { grid-template-columns: minmax(0, 1fr) auto; }
  .quiz-by-topic .quiz-bar { grid-column: 1 / -1; grid-row: 2; }
  .quiz-result { padding: var(--s5) var(--s4); }
}
@media (pointer: coarse) {
  .quiz-option { min-height: 3.5rem; }
  .quiz-crumb, .quiz-pick-chip { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .quiz-play, .quiz-result, .quiz-why, .quiz-verdict { animation: none; }
  .quiz-cat, .quiz-topic, .quiz-bar-fill { transition: none; }
  .quiz-cat:hover, .quiz-topic:hover { transform: none; }
}
@media print {
  .quiz-give, .quiz-give-open, .quiz-notice, .quiz-result-actions { display: none !important; }
}
