/*
 * Player quiz skin — LearnDash WpProQuiz markup inside the course player shell.
 *
 * WS-B: quizzes (sfwd-quiz) now render through the same focus-mode player
 * shell as lessons/topics (learndash/ld30/focus/content.php + parts/player/
 * shell.php), with the LearnDash quiz app (the_content() output — the
 * WpProQuiz_* markup + [LDAdvQuiz] shortcode) dropped into the main panel
 * in place of the video panel. This stylesheet skins THAT markup only; it
 * never touches the shell chrome (topbar, sidebar, buttons) — those already
 * carry Calm Workspace styling from player.css.
 *
 * Enqueued only on quiz steps (learndash/ld30/focus/content.php), and only
 * after LearnDash's own 'learndash_quiz_front_css' (see the dependency
 * array on that wp_enqueue_style() call) so these rules always win the
 * cascade over LearnDash's hardcoded legacy colors.
 *
 * Scoped under .player__quiz-panel (the wrapper shell.php renders around
 * the quiz content) so nothing here can leak onto any other page that
 * happens to render a [LDAdvQuiz] shortcode outside the player.
 *
 * Real class names verified against the installed LearnDash source:
 *   - sfwd-lms/themes/legacy/templates/learndash_quiz_front.css (the
 *     stylesheet these rules override)
 *   - sfwd-lms/includes/lib/wp-pro-quiz/js/wpProQuiz_front.js (client-
 *     rendered markup: correct/incorrect feedback, review dots, etc.)
 *   - sfwd-lms/includes/lib/wp-pro-quiz/lib/view/WpProQuiz_View_FrontQuiz.php
 *     and themes/legacy/templates/quiz/partials/show_quiz_start_box.php
 *     (server-rendered start box)
 *
 * Tokens only — canonical tokens.css custom properties (--blue, --ink,
 * --card-border, --r-card, --r-btn, --font, --green*, --error, etc.), no
 * hardcoded hex. There is no dedicated "--error-fill"/"--red-danger-fill"
 * tint token yet, so the incorrect-answer background tint below is derived
 * from --error via color-mix() (same technique player.css already uses for
 * --player-dark) rather than a hardcoded hex — flagged in the WS-B task
 * Result for the orchestrator in case a real fill token should be added.
 *
 * @package Soofos
 */

/* --------------------------------------------------------------------------
 * Card container
 * -------------------------------------------------------------------------- */
.player__quiz-panel {
    font-family: var(--font);
    color: var(--ink);
}

.player__quiz-panel .wpProQuiz_content {
    margin: 0;
    padding: 24px;
    background: var(--pl-surface);
    border: 1px solid var(--card-border);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-soft);
    font-family: var(--font);
    color: var(--ink);
}

.player__quiz-panel .wpProQuiz_content h2,
.player__quiz-panel .wpProQuiz_content h3,
.player__quiz-panel .wpProQuiz_checkPage h3,
.player__quiz-panel .wpProQuiz_results h3 {
    margin: 0 0 12px;
    font-family: var(--font);
    font-size: 16px;
    font-weight: 800;
    color: var(--ink);
}

/* --------------------------------------------------------------------------
 * Question progress + text
 * -------------------------------------------------------------------------- */
.player__quiz-panel .wpProQuiz_question_page {
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 700;
    color: var(--muted);
}

.player__quiz-panel .wpProQuiz_question_page span {
    font-weight: 700;
    color: var(--muted);
}

.player__quiz-panel .wpProQuiz_question_text {
    margin-bottom: 16px;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.4;
    color: var(--ink);
}

/* --------------------------------------------------------------------------
 * Answer list + rows (selectable rows: hover / selected / correct / incorrect)
 * -------------------------------------------------------------------------- */
.player__quiz-panel .wpProQuiz_content .wpProQuiz_questionList {
    margin-bottom: 16px;
    padding: 0;
    background: transparent;
    border: 0;
    list-style: none;
    overflow: visible;
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_questionListItem:not(.ld-sortable__item) {
    margin: 0 0 8px;
    padding: 12px 14px;
    background: var(--pl-surface);
    background-image: none;
    border: 1px solid var(--card-border);
    border-radius: var(--r-card-sm);
    list-style: none;
    transition: background-color .15s ease, border-color .15s ease;
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_questionListItem:not(.ld-sortable__item):hover {
    background: var(--blue-tint);
    border-color: var(--blue-border);
}

/* Selected answer (progressive enhancement — browsers without :has()
   support simply keep the plain unselected row style, no functional loss). */
.player__quiz-panel .wpProQuiz_content .wpProQuiz_questionListItem:not(.ld-sortable__item):has(input:checked) {
    background: var(--blue-fill);
    border-color: var(--blue);
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_questionListItem input,
.player__quiz-panel .wpProQuiz_content .wpProQuiz_questionListItem label {
    margin: 0;
    font-weight: 400;
    font-size: 14px;
    color: var(--ink);
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_questionListItem input[type="radio"],
.player__quiz-panel .wpProQuiz_content .wpProQuiz_questionListItem input[type="checkbox"] {
    margin-right: 8px;
    accent-color: var(--blue);
}

/* Correct / incorrect feedback on an answer row, applied by LearnDash's own
   JS after checking (wpProQuiz_front.js). */
.player__quiz-panel .wpProQuiz_content .wpProQuiz_answerCorrect {
    background: var(--green-fill) !important;
    border-color: var(--green) !important;
    font-weight: 700;
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_answerCorrect label {
    font-weight: 700;
    color: var(--green-ink);
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_answerIncorrect {
    background: color-mix(in srgb, var(--error) 8%, var(--pl-surface)) !important;
    border-color: var(--error) !important;
    font-weight: 700;
}

/* "You missed this correct answer" marker (shown alongside the incorrect
   selection) — an outline only, so it reads as informational rather than
   as a second filled state competing with the incorrect row above it. */
.player__quiz-panel .wpProQuiz_content .wpProQuiz_answerCorrectIncomplete {
    border: 1px solid var(--green) !important;
    font-weight: 700;
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_cloze input.wpProQuiz_answerCorrect {
    background-color: var(--green-fill);
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_cloze input.wpProQuiz_answerIncorrect {
    background-color: color-mix(in srgb, var(--error) 10%, var(--pl-surface));
}

/* Free-text / essay response box. */
.player__quiz-panel .wpProQuiz_content .wpProQuiz_response {
    margin-bottom: 15px;
    padding: 12px 14px;
    background: var(--pl-surface);
    border: 1px solid var(--card-border);
    border-radius: var(--r-card-sm);
    box-shadow: none;
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_response span {
    font-weight: 700;
    color: var(--ink);
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_cloze input[type="text"] {
    border-bottom: 1px solid var(--card-border);
    color: var(--ink);
    font-family: var(--font);
}

/* Per-question correct/incorrect feedback message (JS-injected,
   .wpProQuiz_correct / .wpProQuiz_incorrect wrap a .wpProQuiz_AnswerMessage). */
.player__quiz-panel .wpProQuiz_content .wpProQuiz_correct .wpProQuiz_AnswerMessage,
.player__quiz-panel .wpProQuiz_content .wpProQuiz_AnswerMessage.wpProQuiz_correct {
    padding: 10px 12px;
    background: var(--green-fill);
    border: 1px solid var(--green);
    border-radius: var(--r-card-sm);
    color: var(--green-ink);
    font-weight: 700;
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_incorrect .wpProQuiz_AnswerMessage,
.player__quiz-panel .wpProQuiz_content .wpProQuiz_AnswerMessage.wpProQuiz_incorrect {
    padding: 10px 12px;
    background: color-mix(in srgb, var(--error) 8%, var(--pl-surface));
    border: 1px solid var(--error);
    border-radius: var(--r-card-sm);
    color: var(--error);
    font-weight: 700;
}

/* --------------------------------------------------------------------------
 * Buttons — Start / Continue / Next / Back / Check / Finish
 * (LearnDash renders these as <input type="button" class="wpProQuiz_button">
 * both server-side — the start box (themes/legacy/templates/quiz/partials/
 * show_quiz_start_box.php:54 `<input class="wpProQuiz_button" type="button"
 * name="startQuiz">`), the check/finish box (show_quiz_check_page_box.php:79
 * `name="endQuizSummary"`) and the result box (show_quiz_result_box.php:299,
 * 320, 339 `name="restartQuiz"`/`"reShowQuestion"`/`"showToplist"`) — and
 * client-side via wpProQuiz_front.js for the in-question Check/Next/Back
 * controls (show_quiz_questions_box.php:671-790, class
 * "wpProQuiz_button wpProQuiz_QuestionButton").
 *
 * CORRECTED grounding — the previous version of this comment (specificity
 * argument only, no !important) was wrong; a live-QA pass on
 * devsoofos.local/quiz/quiz-what-did-you-learn/ found the button still red
 * and re-verified against the actual rendered DOM/CSSOM, not static source:
 *
 * 1. `.learndash-wrapper` IS present. WpProQuiz's own front-end renderer
 *    wraps `.wpProQuiz_content` in `<div class="learndash-wrapper
 *    learndash-wrapper--quiz">` (learndash_get_wrapper_class(),
 *    sfwd-lms/themes/helpers.php:31-69), itself nested inside the
 *    `[LDAdvQuiz]` shortcode's own `<div class="learndash ...">`
 *    (ld_quiz.php:413) — confirmed in the raw server-rendered HTML, not
 *    JS-injected. So LD's own colored button rules DO match here (ld30
 *    learndash.min.css `.learndash-wrapper .wpProQuiz_content
 *    .wpProQuiz_button, .wpProQuiz_button2` — background #235af3,
 *    border-radius 20px, padding 1em, max-width 385px, no !important,
 *    specificity (0,3,0)/(0,3,0) with no tag). Our rules below already
 *    out-specificity that (extra ancestor classes + `input` tag), which is
 *    why shape properties like border-radius already render correctly
 *    un-escalated — confirmed via computed style (border-radius: 8px, i.e.
 *    var(--r-btn), already won with no !important before this fix).
 *
 * 2. The red is a site-configured LearnDash branding/color option: LD
 *    injects an inline <style> block in <head> when an admin sets a custom
 *    accent color (here #FF4859, this site's --red) containing, among many
 *    unrelated selectors:
 *      .learndash-wrapper .wpProQuiz_content .wpProQuiz_button:not([disabled])
 *        :not(.wpProQuiz_button_reShowQuestion):not(.wpProQuiz_button_restartQuiz),
 *      .learndash-wrapper .wpProQuiz_content .wpProQuiz_button2:not([disabled])
 *        { background-color: #FF4859 !important; color: #000000; }
 *    — specificity (0,6,0): 6 class/attribute/:not() tokens, no tag, and
 *    that selector is NOT hover-gated for these two branches (only the
 *    shared `.ld-button:hover` branch earlier in the same selector list
 *    is), so it forces red at rest too. A second block repeats the same
 *    red (no !important) on :hover — redundant given the block above. A
 *    third forces wpProQuiz_button_reShowQuestion/_restartQuiz's :hover to
 *    green #39da8a !important, specificity (0,4,0). Verified exhaustively
 *    via `document.styleSheets`/inline <style> introspection on the live
 *    page: no other !important rule touches these buttons' background or
 *    color — `color` itself is never forced with !important anywhere.
 *
 * Fix: escalate our selectors' specificity past (0,6,0) using REAL,
 * always server-rendered ancestor classes — our own shell wrappers
 * (.player, .player__video-panel, .player__quiz-panel) plus LD's own
 * `.learndash`/`.learndash-wrapper` — rather than artificial class
 * repetition, and add !important on exactly the properties the branding
 * style forces (background/background-color, color) plus border-radius as
 * defense-in-depth against a future LD version adding !important there
 * too. Justified because LD itself uses !important first; per the task's
 * specificity rule ("use !important only if LD itself uses it"), that
 * condition is met. Disabled state gets the same treatment: LD's ld30
 * default `.wpProQuiz_button[disabled]` (learndash.css:3334, specificity
 * (0,4,0)) sets `background-color:#f6f8fa !important; color:#73738c
 * !important` and was verified live (temporarily toggling `disabled` on
 * the real button) to still win over our un-escalated, non-!important
 * `:disabled` rule.
 * -------------------------------------------------------------------------- */
.player .player__video-panel .player__quiz-panel .learndash .learndash-wrapper .wpProQuiz_content input.wpProQuiz_button,
.player .player__video-panel .player__quiz-panel .learndash .learndash-wrapper .wpProQuiz_content input[type="button"]:not(.wpProQuiz_button2),
.player .player__video-panel .player__quiz-panel .learndash .learndash-wrapper .wpProQuiz_content input[type="submit"]:not(.wpProQuiz_button2) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 0 20px;
    background: var(--blue) !important;
    color: var(--on-navy) !important;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 800;
    border: 0;
    border-radius: var(--r-btn) !important;
    cursor: pointer;
    transition: background-color .15s ease;
}

.player .player__video-panel .player__quiz-panel .learndash .learndash-wrapper .wpProQuiz_content input.wpProQuiz_button:hover,
.player .player__video-panel .player__quiz-panel .learndash .learndash-wrapper .wpProQuiz_content input[type="button"]:not(.wpProQuiz_button2):hover,
.player .player__video-panel .player__quiz-panel .learndash .learndash-wrapper .wpProQuiz_content input[type="submit"]:not(.wpProQuiz_button2):hover {
    background: var(--blue-hover) !important;
}

.player .player__video-panel .player__quiz-panel .learndash .learndash-wrapper .wpProQuiz_content input.wpProQuiz_button:disabled,
.player .player__video-panel .player__quiz-panel .learndash .learndash-wrapper .wpProQuiz_content input[type="button"]:not(.wpProQuiz_button2):disabled,
.player .player__video-panel .player__quiz-panel .learndash .learndash-wrapper .wpProQuiz_content input[type="submit"]:not(.wpProQuiz_button2):disabled {
    background: var(--faint) !important;
    color: var(--muted) !important;
    cursor: not-allowed;
}

/* Retake Quiz / Review Questions (show_quiz_result_box.php:299,320) — LD
 * gives these a distinct class (wpProQuiz_button_restartQuiz /
 * _reShowQuestion) alongside wpProQuiz_button, and LD's own ld30 CSS
 * (learndash.css:3093-3096, by [name] attribute) styles them a separate
 * dark grey rather than the primary blue used for Start/Check/Next — i.e.
 * LD itself treats these as secondary actions. Per the semantic-colour rule
 * (primary blue reserved for the main forward action), render them as the
 * same neutral ghost treatment as .wpProQuiz_button2 below instead of
 * reusing LD's grey. The branding inline style forces their :hover to
 * green #39da8a !important (specificity (0,4,0), see comment above) — the
 * escalated selector + !important below beats it on both counts.
 */
.player .player__video-panel .player__quiz-panel .learndash .learndash-wrapper .wpProQuiz_content input.wpProQuiz_button.wpProQuiz_button_reShowQuestion,
.player .player__video-panel .player__quiz-panel .learndash .learndash-wrapper .wpProQuiz_content input.wpProQuiz_button.wpProQuiz_button_restartQuiz {
    background: var(--pl-surface) !important;
    color: var(--ink) !important;
    border: 1px solid var(--card-border) !important;
}

.player .player__video-panel .player__quiz-panel .learndash .learndash-wrapper .wpProQuiz_content input.wpProQuiz_button.wpProQuiz_button_reShowQuestion:hover,
.player .player__video-panel .player__quiz-panel .learndash .learndash-wrapper .wpProQuiz_content input.wpProQuiz_button.wpProQuiz_button_restartQuiz:hover {
    background: var(--blue-tint) !important;
    border-color: var(--blue-border) !important;
}

/* "View Answers: Student/Correct" filter toggle + review-page Previous/Next
 * (show_quiz_questions_box.php:491, show_quiz_review_buttons.php:31,46) —
 * also caught by the branding style's base-state red block above (its
 * `.wpProQuiz_button2:not([disabled])` branch), same escalation needed. */
.player .player__video-panel .player__quiz-panel .learndash .learndash-wrapper .wpProQuiz_content input.wpProQuiz_button2 {
    height: 36px;
    padding: 0 14px;
    background: var(--pl-surface) !important;
    color: var(--ink) !important;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 700;
    border: 1px solid var(--card-border) !important;
    border-radius: var(--r-btn);
    box-shadow: none;
    text-shadow: none;
}

.player .player__video-panel .player__quiz-panel .learndash .learndash-wrapper .wpProQuiz_content input.wpProQuiz_button2:hover {
    background: var(--blue-tint) !important;
    border-color: var(--blue-border) !important;
}

/* --------------------------------------------------------------------------
 * Timer + progress
 * -------------------------------------------------------------------------- */
.player__quiz-panel .wpProQuiz_content .wpProQuiz_time_limit .time {
    color: var(--ink);
    font-weight: 700;
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_time_limit .wpProQuiz_progress {
    background-color: var(--blue);
    border-radius: 999px;
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_time_limit_expired {
    color: var(--error);
}

/* --------------------------------------------------------------------------
 * Results — portal-style numbers
 * -------------------------------------------------------------------------- */
.player__quiz-panel .wpProQuiz_content .wpProQuiz_resultTable {
    margin: 16px 0;
    width: 100%;
    padding: 16px;
    background: var(--blue-tint);
    border: 1px solid var(--card-border);
    border-radius: var(--r-card-sm);
    font-weight: 700;
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_resultName {
    border-right: 1px solid var(--card-border);
    color: var(--ink);
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_points,
.player__quiz-panel .wpProQuiz_content .wpProQuiz_earned_points,
.player__quiz-panel .wpProQuiz_content .wpProQuiz_graded_points {
    color: var(--deep-blue);
    font-weight: 800;
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_resultValue_AvgScore .progress-meter {
    background-color: var(--blue-border);
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_resultValue_YourScore .progress-meter {
    background-color: var(--blue);
}

/* --------------------------------------------------------------------------
 * Review (question dots) + legend
 * -------------------------------------------------------------------------- */
.player__quiz-panel .wpProQuiz_content .wpProQuiz_reviewQuestion,
.player__quiz-panel .wpProQuiz_content .wpProQuiz_box {
    background: var(--pl-surface);
    border: 1px solid var(--card-border);
    border-radius: var(--r-card-sm);
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_reviewQuestion li {
    background-color: var(--pl-surface);
    border: 1px solid var(--card-border);
    border-radius: var(--r-card-sm);
    color: var(--ink);
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_reviewQuestion li.wpProQuiz_reviewQuestionSolved,
.player__quiz-panel .wpProQuiz_content .wpProQuiz_box li.wpProQuiz_reviewQuestionSolved,
.player__quiz-panel .wpProQuiz_content .wpProQuiz_reviewQuestion li.wpProQuiz_reviewQuestionSolvedCorrect,
.player__quiz-panel .wpProQuiz_content .wpProQuiz_box li.wpProQuiz_reviewQuestionSolvedCorrect {
    background-color: var(--green-fill);
    border-color: var(--green);
    color: var(--green-ink);
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_reviewQuestion li.wpProQuiz_reviewQuestionSolvedIncorrect,
.player__quiz-panel .wpProQuiz_content .wpProQuiz_box li.wpProQuiz_reviewQuestionSolvedIncorrect {
    background-color: color-mix(in srgb, var(--error) 10%, var(--pl-surface));
    border-color: var(--error);
    color: var(--error);
}

/* Flagged-for-review dot: amber (attention/flagged), never red — matches
   the platform's semantic-color rule (red is destructive/convert only). */
.player__quiz-panel .wpProQuiz_content .wpProQuiz_reviewQuestion li.wpProQuiz_reviewQuestionReview,
.player__quiz-panel .wpProQuiz_content .wpProQuiz_box li.wpProQuiz_reviewQuestionReview {
    background-color: var(--amber-fill);
    border-color: var(--amber);
    color: var(--amber-text-2);
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_reviewLegend span.wpProQuiz_AnweredColor,
.player__quiz-panel .wpProQuiz_content .wpProQuiz_reviewLegend span.wpProQuiz_reviewColor_AnswerCorrect {
    background-color: var(--green);
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_reviewLegend span.wpProQuiz_reviewColor_Review {
    background-color: var(--amber);
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_reviewLegend span.wpProQuiz_reviewColor_AnswerIncorrect {
    background-color: var(--error);
}

.player__quiz-panel .wpProQuiz_content .wpProQuiz_reviewLegend span.wpProQuiz_reviewQuestion_Target,
.player__quiz-panel .wpProQuiz_content .wpProQuiz_reviewQuestion li.wpProQuiz_reviewQuestionTarget {
    border-color: var(--blue);
    background-color: var(--blue-fill);
    box-shadow: none;
}

/* --------------------------------------------------------------------------
 * Lock / prerequisite / registered-user-only gating messages — amber
 * (attention), matching the platform's "weak/pending/flagged = amber" rule.
 * -------------------------------------------------------------------------- */
.player__quiz-panel .wpProQuiz_lock,
.player__quiz-panel .wpProQuiz_prerequisite,
.player__quiz-panel .wpProQuiz_startOnlyRegisteredUser,
.player__quiz-panel .wpProQuiz_loadQuiz {
    border: 1px solid var(--amber);
    background-color: var(--amber-fill);
    border-radius: var(--r-card-sm);
}

.player__quiz-panel .wpProQuiz_lock p,
.player__quiz-panel .wpProQuiz_prerequisite p,
.player__quiz-panel .wpProQuiz_startOnlyRegisteredUser p,
.player__quiz-panel .wpProQuiz_loadQuiz p {
    color: var(--amber-text-2);
    font-weight: 700;
}

/* --------------------------------------------------------------------------
 * Essay upload feedback (LD default CSS hardcodes plain "red"/"green" here)
 * -------------------------------------------------------------------------- */
.player__quiz-panel .wpProQuiz_content .uploadEssayMessage_fail {
    color: var(--error);
}

.player__quiz-panel .wpProQuiz_content .uploadEssayMessage_success {
    color: var(--green-ink);
}
