/* =========================================================
   Math quiz – question card, answers, results (used by js/quiz.js)
   The section and card frame are laid out in site.css.
   ========================================================= */
.quiz {
  --qz-ink: #2a1608;
  --qz-accent: #ff6b00;
  --qz-accent-d: #e85d04;
}

/* Top bar: counter, topic, streak, live score, timer, progress */
.quiz .qz-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px 8px;
  background: linear-gradient(180deg, rgba(255, 248, 225, 0.85) 0%, rgba(255, 253, 248, 0.5) 100%);
  border-bottom: 1.5px solid rgba(255, 122, 0, 0.22);
  position: relative;
  flex-shrink: 0;
}

.quiz .qz-top-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.quiz .qz-counter {
  font: 700 15px/1 var(--serif);
  color: var(--qz-ink);
}

.quiz .qz-topic {
  font: 700 12px/1 var(--sinhala);
  color: #7a3e14;
  background: rgba(253, 177, 14, 0.22);
  border: 1px solid rgba(255, 122, 0, 0.35);
  padding: 4px 10px;
  border-radius: 12px;
}

.quiz .qz-top-stats {
  display: flex;
  align-items: center;
  gap: 14px;
}

.quiz .qz-streak {
  font: 700 13px/1 var(--ui);
  color: #ff6b00;
  background: rgba(194, 49, 38, 0.1);
  border: 1px solid rgba(194, 49, 38, 0.25);
  padding: 5px 10px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.quiz .qz-flame {
  font-size: 15px;
}

.quiz .qz-score-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--qz-ink);
  color: #ffc46b;
  padding: 5px 12px;
  border-radius: 12px;
  font: 700 13px/1 var(--ui);
  box-shadow: 0 2px 6px rgba(42, 22, 8, 0.2);
}

.quiz .qz-score-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.85;
}

.quiz .qz-score-val {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
}

/* Circular Timer Ring */
.quiz .qz-timer-wrap {
  position: relative;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.quiz .qz-timer-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.quiz .qz-timer-bg {
  fill: none;
  stroke: rgba(0, 0, 0, 0.08);
  stroke-width: 3.2;
}

.quiz .qz-timer-bar {
  fill: none;
  stroke: #ff8a1f;
  stroke-width: 3.2;
  stroke-linecap: round;
  transition: stroke-dasharray 0.3s linear, stroke 0.3s ease;
}

.quiz .qz-timer-text {
  position: absolute;
  font: 800 12px/1 var(--ui);
  color: var(--qz-ink);
}

/* Animated gradient progress bar */
.quiz .qz-progress-bar-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3.5px;
  background: rgba(0, 0, 0, 0.06);
}

.quiz .qz-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #2a1608 0%, #ff6b00 50%, #ff8c1a 100%);
  transition: width 0.4s ease;
}

/* Content Slider & Question Stage */
.quiz .qz-content-slider {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.quiz .qz-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 30px;
}

.quiz .qz-stage.qz-anim-enter {
  animation: qzFadeIn 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.quiz .qz-stage.qz-shake {
  animation: qzShake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* Question Math Typography */
.quiz .qz-question-box {
  width: 100%;
  max-width: 960px;
  text-align: center;
  margin-bottom: 12px;
}

.quiz .qz-q-text {
  font: 700 23px/1.35 var(--sinhala);
  color: #1a1a1a;
  letter-spacing: 0.2px;
}

.quiz .qz-math {
  font-family: var(--round), var(--arial);
  font-weight: 800;
  color: var(--qz-ink);
  margin: 0 4px;
}

.quiz .qz-frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  text-align: center;
  font-size: 0.88em;
  margin: 0 3px;
  line-height: 1;
}

.quiz .qz-num {
  border-bottom: 1.6px solid currentColor;
  padding: 0 4px;
  line-height: 1.1;
}

.quiz .qz-den {
  padding: 0 4px;
  line-height: 1.1;
}

/* Answer Area */
.quiz .qz-answer-area {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

/* Input Type */
.quiz .qz-input-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
}

.quiz .qz-text-input {
  width: 440px;
  height: 52px;
  background: #ffffff;
  border: 2px solid rgba(255, 122, 0, 0.65);
  border-radius: 14px;
  font: 800 24px/52px var(--arial);
  color: #2b1600;
  text-align: center;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.04);
}

.quiz .qz-text-input:focus {
  border-color: var(--qz-ink);
  box-shadow: 0 0 0 4px rgba(253, 177, 14, 0.35);
  background: #fffdf8;
}

.quiz .qz-text-input.qz-input-correct {
  border-color: #2e7d32;
  background: #e8f5e9;
  color: #1b5e20;
}

.quiz .qz-text-input.qz-input-wrong {
  border-color: #c62828;
  background: #ffebee;
  color: #b71c1c;
}

/* MCQ 4-Option Grid */
.quiz .qz-mcq-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  width: 720px;
  max-width: 100%;
}

.quiz .qz-mcq-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 8px 16px;
  background: #ffffff;
  border: 2px solid rgba(255, 122, 0, 0.4);
  border-radius: 12px;
  font: 700 17px/1.2 var(--sinhala);
  color: #2b1600;
  cursor: pointer;
  text-align: left;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
}

.quiz .qz-mcq-card:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: #ff8a1f;
  box-shadow: 0 6px 14px rgba(255, 122, 0, 0.22);
  background: #fffdf8;
}

.quiz .qz-mcq-card.qz-selected {
  border-color: var(--qz-ink);
  background: #fff4e5;
  box-shadow: 0 0 0 3px rgba(42, 22, 8, 0.18);
}

.quiz .qz-mcq-card:focus-visible {
  outline: 3px solid #ff8c1a;
  outline-offset: 2px;
}

.quiz .qz-mcq-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(255, 122, 0, 0.2);
  font: 800 12px/1 var(--ui);
  color: var(--qz-ink);
  flex-shrink: 0;
}

.quiz .qz-mcq-val {
  flex: 1;
}

.quiz .qz-mcq-card.qz-mcq-correct {
  border-color: #2e7d32 !important;
  background: #e8f5e9 !important;
  color: #1b5e20 !important;
  box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.25) !important;
}

.quiz .qz-mcq-card.qz-mcq-wrong {
  border-color: #c62828 !important;
  background: #ffebee !important;
  color: #b71c1c !important;
  box-shadow: 0 0 0 2px rgba(198, 40, 40, 0.2) !important;
}

/* Feedback Region */
.quiz .qz-feedback-wrap {
  min-height: 44px;
  width: 100%;
  max-width: 820px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.quiz .qz-feedback-banner {
  font: 700 15px/1.3 var(--sinhala);
  border-radius: 8px;
  padding: 3px 14px;
  margin-bottom: 2px;
  display: inline-block;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.quiz .qz-feedback-expl {
  font: 500 13px/1.35 var(--sinhala);
  color: #555;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.quiz .qz-feedback-wrap.qz-is-correct .qz-feedback-banner {
  opacity: 1;
  background: rgba(46, 125, 50, 0.12);
  border: 1.5px solid #2e7d32;
  color: #1b5e20;
}

.quiz .qz-feedback-wrap.qz-is-correct .qz-feedback-expl {
  opacity: 1;
  color: #2e7d32;
}

.quiz .qz-feedback-wrap.qz-is-wrong .qz-feedback-banner {
  opacity: 1;
  background: rgba(198, 40, 40, 0.1);
  border: 1.5px solid #c62828;
  color: #b71c1c;
}

.quiz .qz-feedback-wrap.qz-is-wrong .qz-feedback-expl {
  opacity: 1;
  color: #8a1f1f;
}

/* Action Buttons */
.quiz .qz-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 4px 24px 14px;
  flex-shrink: 0;
}

.quiz .qz-btn {
  min-height: 48px;
  min-width: 190px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 20px;
  transition: transform 0.18s ease, filter 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.quiz .qz-btn:focus-visible {
  outline: 3px solid #ff8c1a;
  outline-offset: 3px;
}

.quiz .qz-btn-si {
  font: 700 15px/1.2 var(--sinhala);
}

.quiz .qz-btn-en {
  font: 600 11px/1 var(--ui);
  opacity: 0.88;
  margin-top: 2px;
  letter-spacing: 0.3px;
}

.quiz .qz-btn-submit {
  background: var(--qz-ink);
  color: #ffc46b;
  box-shadow: 0 4px 14px rgba(42, 22, 8, 0.25);
}

.quiz .qz-btn-submit:hover:not(:disabled) {
  filter: brightness(1.12);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(42, 22, 8, 0.35);
}

.quiz .qz-btn-submit:active:not(:disabled) {
  transform: scale(0.98);
}

.quiz .qz-btn-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.quiz .qz-btn-next {
  background: #e8dccb;
  color: #8c735d;
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.quiz .qz-btn-next.qz-btn-active {
  background: linear-gradient(135deg, #ff8c1a 0%, #ff8a1f 100%);
  color: var(--qz-ink);
  opacity: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(255, 122, 0, 0.35);
}

.quiz .qz-btn-next.qz-btn-active:hover {
  filter: brightness(1.08);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(255, 122, 0, 0.45);
}

.quiz .qz-btn-next.qz-btn-active:active {
  transform: scale(0.98);
}

/* Results Screen View */
.quiz .qz-results-view {
  flex: 1;
  padding: 16px 36px 18px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 122, 0, 0.5) transparent;
}

.quiz .qz-results-view::-webkit-scrollbar {
  width: 6px;
}

.quiz .qz-results-view::-webkit-scrollbar-thumb {
  background: rgba(255, 122, 0, 0.5);
  border-radius: 4px;
}

.quiz .qz-res-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  margin-bottom: 12px;
}

.quiz .qz-res-ring-wrap {
  position: relative;
  width: 90px;
  height: 90px;
  flex-shrink: 0;
}

.quiz .qz-res-ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.quiz .qz-res-ring-bg {
  fill: none;
  stroke: rgba(0, 0, 0, 0.08);
  stroke-width: 9;
}

.quiz .qz-res-ring-bar {
  fill: none;
  stroke: #2e7d32;
  stroke-width: 9;
  stroke-linecap: round;
}

.quiz .qz-res-ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.quiz .qz-res-score-big {
  font: 800 24px/1 var(--ui);
  color: var(--qz-ink);
}

.quiz .qz-res-score-total {
  font: 600 11px/1 var(--ui);
  color: #777;
}

.quiz .qz-res-meta {
  text-align: left;
}

.quiz .qz-res-title {
  font: 800 22px/1.2 var(--sinhala);
  color: var(--qz-ink);
  margin-bottom: 2px;
}

.quiz .qz-res-sub {
  font: 500 13px/1.3 var(--ui);
  color: #555;
  margin-bottom: 8px;
}

.quiz .qz-res-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quiz .qz-res-pill {
  font: 600 12px/1 var(--sinhala);
  background: rgba(253, 177, 14, 0.2);
  border: 1px solid rgba(255, 122, 0, 0.4);
  color: #2a1608;
  padding: 4px 10px;
  border-radius: 12px;
}

/* Topics to revisit box */
.quiz .qz-res-topics-box {
  background: #fff8e7;
  border: 1.5px solid rgba(255, 122, 0, 0.45);
  border-radius: 14px;
  padding: 8px 16px;
  margin-bottom: 12px;
  text-align: left;
}

.quiz .qz-res-topics-title {
  font: 700 13px/1.2 var(--sinhala);
  color: #7a3e14;
  margin-bottom: 4px;
}

.quiz .qz-res-topics-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font: 600 12px/1.3 var(--sinhala);
  color: #3b1b00;
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Collapsible review list */
.quiz .qz-review-section {
  margin-bottom: 14px;
}

.quiz .qz-review-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #f4ede1;
  border: 1.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  font: 700 14px/1 var(--sinhala);
  color: var(--qz-ink);
  cursor: pointer;
  transition: background 0.2s;
}

.quiz .qz-review-toggle:hover {
  background: #ede3d2;
}

.quiz .qz-review-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 122, 0, 0.4) transparent;
}

.quiz .qz-rev-card {
  background: #ffffff;
  border-radius: 10px;
  padding: 8px 14px;
  text-align: left;
  border-left: 4px solid #999;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.quiz .qz-rev-card.qz-rev-ok {
  border-left-color: #2e7d32;
  background: #fafdfa;
}

.quiz .qz-rev-card.qz-rev-bad {
  border-left-color: #c62828;
  background: #fffafa;
}

.quiz .qz-rev-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.quiz .qz-rev-num {
  font: 700 12px/1 var(--ui);
  color: #333;
}

.quiz .qz-rev-topic {
  font: 600 11px/1 var(--sinhala);
  color: #777;
}

.quiz .qz-rev-badge {
  margin-left: auto;
  font: 700 11px/1 var(--sinhala);
  padding: 2px 8px;
  border-radius: 8px;
}

.quiz .qz-rev-badge-ok {
  background: #e8f5e9;
  color: #1b5e20;
}

.quiz .qz-rev-badge-bad {
  background: #ffebee;
  color: #b71c1c;
}

.quiz .qz-rev-q {
  font: 700 14px/1.3 var(--sinhala);
  color: #222;
  margin-bottom: 4px;
}

.quiz .qz-rev-details {
  font: 500 12px/1.4 var(--sinhala);
  color: #444;
}

.quiz .qz-rev-ans {
  margin-bottom: 2px;
}

.quiz .qz-rev-correct {
  color: #1b5e20;
  margin-bottom: 2px;
}

.quiz .qz-rev-expl {
  color: #666;
  font-size: 11px;
}

/* Results action buttons */
.quiz .qz-res-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

/* Confetti Sparkles */
.quiz .qz-confetti-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 10;
}

.quiz .qz-sparkle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: qzSparkleBurst 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* Animations */
@keyframes qzFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes qzShake {

  10%,
  90% {
    transform: translate3d(-2px, 0, 0);
  }

  20%,
  80% {
    transform: translate3d(4px, 0, 0);
  }

  30%,
  50%,
  70% {
    transform: translate3d(-6px, 0, 0);
  }

  40%,
  60% {
    transform: translate3d(6px, 0, 0);
  }
}

@keyframes qzSparkleBurst {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(var(--scale, 1)) rotate(0deg);
  }

  100% {
    opacity: 0;
    transform: translate(var(--tx, 0), var(--ty, -100px)) scale(0.2) rotate(var(--rot, 360deg));
  }
}

@media (prefers-reduced-motion: reduce) {

  .quiz .qz-stage.qz-anim-enter,
  .quiz .qz-stage.qz-shake,
  .quiz .qz-sparkle,
  .quiz .qz-mcq-card,
  .quiz .qz-btn {
    animation: none !important;
    transition: none !important;
  }
}


/* ---------- small screens ---------- */
@media (max-width: 720px) {
  .quiz .qz-topbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 14px 10px;
  }

  .quiz .qz-top-info {
    flex-wrap: wrap;
    gap: 6px;
  }

  .quiz .qz-stage {
    padding: 14px 14px 8px;
  }

  .quiz .qz-mcq-grid {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .quiz .qz-input-wrap {
    width: 100%;
    max-width: 100%;
  }

  .quiz .qz-actions {
    padding: 8px 14px 16px;
    gap: 10px;
  }

  .quiz .qz-btn {
    flex: 1;
    min-width: 0;
    min-height: 52px;
    padding: 6px 10px;
  }

  .quiz .qz-btn-si {
    font-size: 13.5px;
  }
}
