/* Idle guide: animate a GOLD OVERLAY while preserving each button's original theme.
   Each cycle: normal appearance -> bright gold frame -> normal appearance. */
/* Single pulse target for the unanswered A-D group: no per-choice flashing. */
#quizApp .quiz-idle-active:not(:disabled),
#quizApp #quizOptions.quiz-idle-options {
  position: relative;
  isolation: isolate;
  /* Preserve the existing button/option background, border and text colors. */
}
#quizApp .quiz-idle-active:not(:disabled)::after,
#quizApp #quizOptions.quiz-idle-options::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 2px solid #ffd574;
  border-radius: 13px;
  background: rgba(255, 206, 75, .08);
  box-shadow: 0 0 0 3px rgba(255, 201, 71, .22),
              0 0 18px 4px rgba(255, 188, 47, .42),
              inset 0 0 10px rgba(255, 213, 116, .12);
  pointer-events: none;
  opacity: 0;
  animation: sf-guide-blink 1.8s ease-in-out infinite;
}
/* Keep the grouped highlight around the full grid, not each option. */
#quizApp #quizOptions.quiz-idle-options .quiz-option::after {
  content: none !important;
}
@keyframes sf-guide-blink {
  0%, 18%, 100% { opacity: 0; }
  48%, 65% { opacity: 1; }
}
#quizHeroSummary[data-state="hidden"] { display: none !important; }
#quizHeroSummary[data-state^="result"] { display: block; }
#quizHeroSummary[data-state="result-pass"] { border-color: rgba(167, 211, 132, .35); }
#quizHeroSummary[data-state="result-review"] { border-color: rgba(229, 198, 122, .45); }
@media (prefers-reduced-motion: reduce) {
  #quizApp .quiz-idle-active:not(:disabled)::after,
  #quizApp #quizOptions.quiz-idle-options::after {
    animation: none;
    opacity: 1; /* Static guide for reduced-motion preference. */
  }
}

/* Back navigation arrow: 3x stroke weight (4.5 vs 1.5), retain button proportions. */
#quizApp #prevQuestion { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
#quizApp #prevQuestion .quiz-back-arrow { width: 20px; height: 20px; flex: none; display: block; }

/* The next-question arrow mirrors the previously strengthened back arrow. */
#quizApp #nextQuestion { display:inline-flex; align-items:center; justify-content:center; gap:8px; }
#quizApp #nextQuestion .quiz-forward-arrow { display:block; flex:0 0 20px; width:20px; height:20px; }
#quizApp #nextQuestion > span {min-width:0; }


/* Focus mode: once the learner starts answering or reaches question 2,
   keep only the exam workspace visible to reduce distraction. */
body.quiz-focus-mode .quiz-hero,
body.quiz-focus-mode .quiz-note {
  display: none !important;
}
body.quiz-focus-mode .quiz-page-shell {
  /* The site header is fixed; keep the exam card physically below it even
     when scrollY = 0. custom.js maintains --header-height on resize. */
  padding-top: calc(var(--header-height, 80px) + 12px) !important;
}
body.quiz-focus-mode .quiz-container {
  gap: 0 !important;
}
body.quiz-focus-mode .quiz-panel {
  margin-top: 0 !important;
}
body.quiz-focus-mode .quiz-main {
  padding-top: 0 !important;
}
body.quiz-focus-mode .quiz-panel__top {
  padding-top: 14px;
}
body.quiz-focus-mode .quiz-progress-block {
  margin-top: 6px;
}
#quizApp.quiz-panel--focus-mode {
  scroll-margin-top: 14px;
}
/* The result card can also be scrolled to programmatically after submission. */
#quizApp #quizResultPanel {
  scroll-margin-top: calc(var(--header-height, 80px) + 14px);
}


/* Navigation heading is centred; retain its small green marker at the left.
   Scoped to E-Training so other quiz/Lab headings keep their original layout. */
.quiz-page #quizApp .quiz-navigation-section > .quiz-section-heading {
  position: relative;
  justify-content: center;
  text-align: center;
  width: 100%;
}
.quiz-page #quizApp .quiz-navigation-section > .quiz-section-heading > .quiz-section-heading__bar {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}


/* Server-confirmed answer saving: visible retry when any answer is unsaved. */
.quiz-page #quizApp .exam-save-state {
  flex-wrap: wrap;
  gap: 9px;
  font-size: 12px;
  line-height: 1.5;
}
.quiz-page #quizApp .exam-save-state #examSaveText {
  flex: 1 1 210px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.quiz-page #quizApp .exam-save-state[data-state="error"] {
  background: #40241f;
  border: 1px solid #e79b72;
  color: #fff0db;
  box-shadow: 0 0 0 2px rgba(231,155,114,.12);
}
.quiz-page #quizApp .exam-save-retry:not([hidden]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid #f5cd8b;
  border-radius: 9px;
  background: #f5cd8b;
  color: #332315;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.quiz-page #quizApp .exam-save-retry:disabled { opacity: .55; cursor: wait; }
.quiz-page #quizApp .exam-save-retry:focus-visible { outline: 3px solid #fff1c4; outline-offset: 2px; }
.quiz-page #quizApp .quiz-option.is-awaiting-save {
  border-color: #e7bb77;
  box-shadow: inset 0 0 0 1px rgba(231,187,119,.18);
}


/* =============================================================
   E-Training GUI Step 4: concise progress + contextual actions.
   Scope these overrides to #quizApp (not other Quiz/Lab pages).
   ============================================================= */
body.quiz-page #quizApp .quiz-progress__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
body.quiz-page #quizApp .quiz-progress__detail {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}
body.quiz-page #quizApp .quiz-progress__eyebrow {
  color: #add4ba;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
}
body.quiz-page #quizApp #quizProgressText {
  font-size: clamp(14px, 1.5vw, 16px);
  color: #f0f6ed;
  font-weight: 750;
  line-height: 1.4;
}
body.quiz-page #quizApp .quiz-progress__value {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
  margin-left: auto;
}
body.quiz-page #quizApp #quizProgressPercent {
  color: #e8d19a;
  font-size: clamp(23px, 3vw, 30px);
  font-weight: 800;
  line-height: 1.15;
}
body.quiz-page #quizApp .quiz-progress__value small {
  font-size: 10px;
  font-weight: 500;
  color: #a7c6b1;
  line-height: 1.5;
}
body.quiz-page #quizApp .quiz-state-badge[hidden],
body.quiz-page #quizApp .quiz-button[hidden],
body.quiz-page #quizApp .exam-submit-button[hidden] {
  display: none !important;
}
/* Space for the actual question, not an artificially tall desktop placeholder. */
body.quiz-page #quizApp .quiz-question-section {
  min-height: 0;
  min-width: 0;
}
body.quiz-page #quizApp .quiz-answer-section,
body.quiz-page #quizApp .quiz-navigation-section {
  min-width: 0;
}
body.quiz-page #quizApp .quiz-question-card {
  min-width: 0;
  align-items: stretch;
}
body.quiz-page #quizApp .quiz-navigation-section .quiz-controls {
  width: 100%;
  max-width: 720px;
  margin-inline: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
body.quiz-page #quizApp .quiz-navigation-section .quiz-controls[data-layout="single"] > .quiz-button:not([hidden]) {
  grid-column: 1 / -1;
  width: 100%;
  max-width: 360px;
  margin-inline: auto;
}
body.quiz-page #quizApp .quiz-navigation-section .quiz-jump-unanswered:not([hidden]) {
  width: min(100%, 360px);
  min-height: 44px;
  margin: 12px auto 0;
  justify-content: center;
  font-size: 13px;
  background: #1d3d2d;
  border-color: #577c5e;
}
body.quiz-page #quizApp .quiz-question-section,
body.quiz-page #quizApp .quiz-navigation-section,
body.quiz-page #quizApp .quiz-answer-section {
  scroll-margin-top: calc(var(--header-height, 80px) + 12px);
}
@media (max-width: 850px) {
  body.quiz-page #quizApp .quiz-question-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 11px;
  }
  body.quiz-page #quizApp .quiz-stage {padding: 10px;}
  body.quiz-page #quizApp .quiz-question-section,
  body.quiz-page #quizApp .quiz-answer-section,
  body.quiz-page #quizApp .quiz-navigation-section {padding: 15px;}
}
@media (max-width: 440px) {
  body.quiz-page #quizApp .quiz-progress-block {padding: 12px 13px;}
  body.quiz-page #quizApp .quiz-progress__meta {gap: 9px; flex-wrap: nowrap;}
  body.quiz-page #quizApp #quizProgressText {font-size: 13px;}
  body.quiz-page #quizApp .quiz-progress__eyebrow {font-size: 11px;}
  body.quiz-page #quizApp #quizProgressPercent {font-size: 23px;}
  body.quiz-page #quizApp .quiz-progress__value small {font-size: 9px;}
  body.quiz-page #quizApp .quiz-navigation-section .quiz-controls {gap: 9px;}
  body.quiz-page #quizApp .quiz-navigation-section .quiz-button {
    min-width: 0;
    min-height: 48px;
    font-size: 13px;
    line-height: 1.4;
    padding: 10px 7px;
  }
  body.quiz-page #quizApp #nextQuestion .quiz-forward-arrow,
  body.quiz-page #quizApp #prevQuestion .quiz-back-arrow {
    width: 18px;
    height: 18px;
    flex-basis: 18px;
  }
  body.quiz-page #quizApp .quiz-navigation-section .quiz-controls[data-layout="single"] > .quiz-button:not([hidden]) {
    max-width: none;
  }
}
/* Prominent without stretching a single action across a wide desktop canvas. */
body.quiz-page #quizApp .quiz-question-card > .exam-submit-button:not([hidden]) {
  grid-column: 1 / -1;
  justify-self: center;
  width: min(100%, 520px);
}
@media (max-width: 639px) {
  body.quiz-page #quizApp .quiz-question-card > .exam-submit-button:not([hidden]) {
    width: 100%;
  }
}


/* =============================================================
   Step 5 — Thai start summary + clearer result and review CTA.
   Result controls are placed before the full answer review.
   ============================================================= */
body.quiz-page .quiz-hero__summary-label {
  font-size: 12px;
  letter-spacing: .02em;
  color: #cee0d0;
}
body.quiz-page .quiz-hero__stats span {
  display: block;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
body.quiz-page .quiz-hero__stats strong {
  font-variant-numeric: tabular-nums;
}
body.quiz-page #quizApp .quiz-result-panel:not([hidden]) {
  gap: 15px;
  padding: clamp(16px, 2vw, 28px);
}
body.quiz-page #quizApp .result-score-ring {
  width: 152px;
  height: 152px;
  border-width: 8px;
  box-shadow: 0 0 0 5px rgba(173, 216, 134, .055);
}
body.quiz-page #quizApp .result-score-ring strong {
  font-size: 39px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
body.quiz-page #quizApp .result-summary h2 {
  font-size: clamp(23px, 3vw, 30px);
  font-weight: 800;
  line-height: 1.25;
}
body.quiz-page #quizApp .result-requirement {
  max-width: 580px;
  margin: 10px auto 0;
  padding: 10px 14px;
  border: 1px solid #4e6a51;
  border-radius: 11px;
  background: #193729;
  color: #e9dbac;
  font-weight: 650;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}
body.quiz-page #quizApp .result-actions {
  display: grid;
  width: min(100%, 650px);
  margin-inline: auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
body.quiz-page #quizApp .result-actions > .quiz-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 49px;
  padding: 11px 14px;
  border-radius: 11px;
  text-align: center;
  font-weight: 700;
  line-height: 1.35;
  text-decoration: none;
}
body.quiz-page #quizApp .result-actions .result-action--review {
  grid-column: 1 / -1;
  min-height: 56px;
  background: #b4db8d;
  color: #14251b;
  border: 1px solid #d1eaa9;
  font-weight: 800;
  font-size: clamp(15px, 2vw, 17px);
}
body.quiz-page #quizApp .result-actions .result-action--review:hover,
body.quiz-page #quizApp .result-actions .result-action--review:focus-visible {
  background: #c9eca6;
  color: #102418;
  border-color: #e3f5bf;
}
body.quiz-page #quizApp .result-review-section {
  margin-top: 8px;
  min-width: 0;
}
body.quiz-page #quizApp .result-review-section h3 {
  margin: 0 0 12px;
  padding-bottom: 8px;
  color: #eef4e7;
  font-size: 15px;
  font-weight: 750;
  line-height: 1.45;
  border-bottom: 1px solid #3c5b45;
}
@media (max-width: 639px) {
  body.quiz-page .quiz-hero__stats>div {padding-inline: 3px;}
  body.quiz-page .quiz-hero__stats strong {font-size: clamp(17px, 5vw, 21px);}
  body.quiz-page .quiz-hero__stats span {font-size: 10px;}
  body.quiz-page #quizApp .result-requirement {font-size: 12px;}
  body.quiz-page #quizApp .result-actions {grid-template-columns: minmax(0, 1fr);}
  body.quiz-page #quizApp .result-actions .result-action--review {grid-column: 1;}
  body.quiz-page #quizApp .result-actions > .quiz-button {width: 100%;}
}
body.quiz-page #quizApp .result-review-section { grid-column: 1 / -1; }
