/* ==========================================================================
   Inline Quiz Flow - CSS-only transitions for inline HTMX quiz containers
   Replaces modal-based quiz with embedded inline experience
   ========================================================================== */

/* --- Base Container: Expand/Collapse Animation --- */

.inline-quiz-container {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 300ms ease;
  overflow: hidden;
  border-radius: 12px;
  margin-top: 12px;
  background: var(--iq-body-bg, #f8f9fa);
  color: var(--iq-body-text, #1d1d1f);
}

.inline-quiz-container > * {
  overflow: hidden;
}

.inline-quiz-container--active {
  grid-template-rows: 1fr;
  border: 1px solid rgba(128, 128, 128, 0.12);
}

.inline-quiz-container--pre {
  margin-top: 0;
  margin-bottom: 16px;
}

.inline-quiz-container--post {
  margin-top: 16px;
}

/* --- Quiz Slide Transitions --- */

.quiz-slide {
  padding: 16px;
  animation: quizSlideIn 250ms ease forwards;
}

.inline-quiz-slide {
  padding: 16px;
  animation: quizSlideIn 250ms ease forwards;
}

/* Quiz slide question text */
.quiz-slide__question-text {
  font-family: 'Poppins', sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--iq-body-text, #1d1d1f);
  margin: 0 0 16px;
}

/* Quiz answer cards */
.quiz-answer-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  min-height: 44px;
  border: 1px solid rgba(128, 128, 128, 0.15);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 200ms ease, background 200ms ease, box-shadow 200ms ease;
  position: relative;
  margin-bottom: 8px;
  background: transparent;
}

.quiz-answer-card:hover {
  border-color: rgba(128, 128, 128, 0.3);
  background: rgba(128, 128, 128, 0.04);
}

.quiz-answer-card--selected {
  border-color: var(--iq-brand-color-1, #003399);
  background: color-mix(in srgb, var(--iq-brand-color-1, #003399) 6%, transparent);
  box-shadow: 0 0 0 1px var(--iq-brand-color-1, #003399);
}

.quiz-answer-card__radio {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.quiz-answer-card__indicator {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(128, 128, 128, 0.3);
  flex-shrink: 0;
  transition: all 200ms ease;
}

.quiz-answer-card--selected .quiz-answer-card__indicator {
  border-color: var(--iq-brand-color-1, #003399);
  background: var(--iq-brand-color-1, #003399);
  box-shadow: inset 0 0 0 3px var(--iq-body-bg, #f8f9fa);
}

.quiz-answer-card__text {
  font-family: 'Poppins', sans-serif;
  font-size: 0.85rem;
  color: var(--iq-body-text, #1d1d1f);
  line-height: 1.4;
}

.quiz-answer-card__img {
  max-width: 80px;
  border-radius: 6px;
  margin-left: auto;
}

.quiz-slide__question-img {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 12px;
}

.quiz-slide__actions {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.quiz-slide__loading {
  text-align: center;
  padding: 12px;
  color: var(--iq-body-text, #1d1d1f);
  opacity: 0.6;
}

@keyframes quizSlideIn {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* --- Progress Dots --- */

.quiz-progress-dots {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0 16px;
  flex-wrap: wrap;
}

.quiz-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transition: all 250ms ease;
  flex-shrink: 0;
}

.quiz-dot--completed {
  background: var(--iq-brand-color-1, #003399);
}

.quiz-dot--active {
  background: transparent;
  border: 2px solid var(--iq-brand-color-1, #003399);
  animation: dotPulse 1.2s ease-in-out infinite;
}

.quiz-dot--upcoming {
  background: rgba(128, 128, 128, 0.2);
}

@keyframes dotPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.3);
    opacity: 0.7;
  }
}

/* --- Answer Option Cards (inline flow) --- */

.inline-quiz-container .quiz-answer-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  min-height: 44px;
  border: 1px solid rgba(128, 128, 128, 0.15);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 200ms ease, background 200ms ease, box-shadow 200ms ease;
  position: relative;
}

.inline-quiz-container .quiz-answer-option:hover {
  border-color: rgba(128, 128, 128, 0.3);
  background: rgba(128, 128, 128, 0.04);
}

.inline-quiz-container .quiz-answer-option.selected {
  border-color: var(--iq-brand-color-1, #6366f1);
  background: color-mix(in srgb, var(--iq-brand-color-1, #6366f1) 6%, transparent);
  box-shadow: 0 0 0 1px var(--iq-brand-color-1, #6366f1);
}

.inline-quiz-container .quiz-answer-radio {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.inline-quiz-container .quiz-answer-text {
  font-family: 'Poppins', sans-serif;
  font-size: 0.85rem;
  color: var(--iq-body-text, #1d1d1f);
  line-height: 1.4;
}

/* --- Feedback Card --- */

.inline-quiz-feedback {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 10px;
  border: 1px solid rgba(128, 128, 128, 0.1);
  animation: feedbackFadeIn 250ms ease forwards;
}

@keyframes feedbackFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.inline-quiz-feedback--correct {
  background: rgba(34, 197, 94, 0.06);
  border-color: rgba(34, 197, 94, 0.25);
}

.inline-quiz-feedback--correct .inline-quiz-feedback__icon {
  color: #22c55e;
}

.inline-quiz-feedback--incorrect {
  background: rgba(239, 68, 68, 0.06);
  border-color: rgba(239, 68, 68, 0.25);
}

.inline-quiz-feedback--incorrect .inline-quiz-feedback__icon {
  color: #ef4444;
}

.inline-quiz-feedback__header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inline-quiz-feedback__icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.inline-quiz-feedback__title {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--iq-body-text, #1d1d1f);
  margin: 0;
}

.inline-quiz-feedback__body {
  font-family: 'Poppins', sans-serif;
  font-size: 0.82rem;
  color: var(--iq-body-text, #1d1d1f);
  line-height: 1.5;
  opacity: 0.8;
}

.inline-quiz-feedback__correct-answer {
  font-weight: 500;
  color: var(--iq-body-text, #1d1d1f);
}

/* --- Buttons (inline context) — Modern compact style --- */

.inline-quiz-container .quiz-btn {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 0.72rem;
  padding: 6px 14px;
  border-radius: 5px;
  border: none;
  cursor: pointer;
  transition: all 180ms cubic-bezier(0.4, 0, 0.2, 1);
  min-height: unset;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.inline-quiz-container .quiz-btn i {
  font-size: 0.65rem;
}

.inline-quiz-container .quiz-btn--primary {
  background: var(--iq-brand-color-1, #003399);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 51, 153, 0.25);
}

.inline-quiz-container .quiz-btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 51, 153, 0.35);
  filter: brightness(1.15);
}

.inline-quiz-container .quiz-btn--primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(0, 51, 153, 0.2);
}

.inline-quiz-container .quiz-btn--primary:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  filter: none;
}

.inline-quiz-container .quiz-btn--secondary {
  background: rgba(128, 128, 128, 0.08);
  color: var(--iq-body-text, #1d1d1f);
  border: 1px solid rgba(128, 128, 128, 0.15);
}

.inline-quiz-container .quiz-btn--secondary:hover {
  background: rgba(128, 128, 128, 0.14);
  border-color: rgba(128, 128, 128, 0.25);
}

/* --- Error State --- */

.inline-quiz-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 16px;
  text-align: center;
  color: var(--iq-body-text, #1d1d1f);
}

.inline-quiz-error i {
  font-size: 1.5rem;
  color: #ef4444;
  opacity: 0.7;
}

.inline-quiz-error p {
  font-family: 'Poppins', sans-serif;
  font-size: 0.85rem;
  margin: 0;
}

/* ==========================================================================
   Mobile-First Responsive (below 768px)
   ========================================================================== */

@media (max-width: 768px) {
  .inline-quiz-container {
    border-radius: 8px;
    margin-top: 8px;
  }

  .inline-quiz-slide {
    padding: 12px;
  }

  /* Full-width stacked answer cards */
  .inline-quiz-container .quiz-answer-option {
    width: 100%;
    min-height: 48px;
    padding: 14px 16px;
  }

  /* Stacked buttons */
  .inline-quiz-container .quiz-actions,
  .quiz-slide__actions {
    flex-direction: column;
    gap: 8px;
  }

  .inline-quiz-container .quiz-btn {
    width: 100%;
    justify-content: center;
    min-height: unset;
    font-size: 0.72rem;
  }

  /* Progress dots: horizontal scroll for many questions */
  .quiz-progress-dots {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .quiz-progress-dots::-webkit-scrollbar {
    display: none;
  }

  .inline-quiz-feedback {
    padding: 14px;
  }
}

/* ==========================================================================
   Quiz Slide/Fade Transitions (Task 2.2)
   HTMX swap-based transitions + View Transition API progressive enhancement
   Requirements: 4.3, 8.1, 8.4
   ========================================================================== */

/* --- Slide-Out Keyframes (old content leaving) --- */

@keyframes quizSlideOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-12px);
  }
}

/* --- HTMX Swap Class-Based Transitions (Fallback) ---
   HTMX adds these classes during swap lifecycle:
   - .htmx-swapping: applied to OLD content being removed
   - .htmx-settling: applied while NEW content settles in
   - .htmx-added: applied to NEW content just inserted
   ---------------------------------------------------------------- */

/* Old content sliding out during swap */
.inline-quiz-slide.htmx-swapping {
  animation: quizSlideOut 250ms ease forwards;
  pointer-events: none;
}

/* New content sliding in after swap settles */
.inline-quiz-slide.htmx-added {
  animation: quizSlideIn 250ms ease forwards;
}

/* Container-level swap timing for smooth sequencing */
.inline-quiz-container .htmx-swapping {
  opacity: 0;
  transition: opacity 150ms ease;
}

.inline-quiz-container .htmx-settling {
  opacity: 1;
  transition: opacity 150ms ease 100ms;
}

/* --- View Transition API (Progressive Enhancement) ---
   Modern browsers supporting the View Transition API get native
   cross-fade with directional slide. Falls back to class-based
   animations above for older browsers.
   ---------------------------------------------------------------- */

@supports (view-transition-name: none) {
  .inline-quiz-slide {
    view-transition-name: quiz-slide;
  }

  /* Prevent duplicate view-transition-name conflicts when swapping */
  .inline-quiz-slide.htmx-swapping {
    view-transition-name: none;
  }

  ::view-transition-old(quiz-slide) {
    animation: quizSlideOut 250ms ease forwards;
  }

  ::view-transition-new(quiz-slide) {
    animation: quizSlideIn 250ms ease forwards;
  }
}

/* --- Reduced Motion: Respect user preference --- */

@media (prefers-reduced-motion: reduce) {
  .inline-quiz-slide,
  .inline-quiz-slide.htmx-swapping,
  .inline-quiz-slide.htmx-added {
    animation-duration: 0ms;
  }

  .inline-quiz-container .htmx-swapping,
  .inline-quiz-container .htmx-settling {
    transition-duration: 0ms;
  }

  @supports (view-transition-name: none) {
    ::view-transition-old(quiz-slide),
    ::view-transition-new(quiz-slide) {
      animation-duration: 0ms;
    }
  }
}

/* ==========================================================================
   Celebration: Confetti, Gauge, and Score Display
   Requirements: 7.1, 8.2, 9.4
   Modern celebration — gradient glow, animated gauge, floating confetti
   ========================================================================== */

/* --- Celebration Wrapper --- */

.celebration-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 40px 20px;
  position: relative;
  overflow: hidden;
  animation: celebrationReveal 500ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
  background: radial-gradient(ellipse at 50% 0%, rgba(0, 51, 153, 0.06) 0%, transparent 70%);
}

@keyframes celebrationReveal {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.celebration-wrapper--pass {
  --celebration-accent: #10b981;
  --celebration-gauge-color: #10b981;
  --celebration-glow: rgba(16, 185, 129, 0.15);
}

.celebration-wrapper--fail {
  --celebration-accent: #6b7280;
  --celebration-gauge-color: #6b7280;
  --celebration-glow: rgba(107, 114, 128, 0.08);
}

/* --- Confetti Container — more dynamic, 3D feel --- */

.celebration-confetti {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

.celebration-confetti__piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 10px;
  opacity: 0;
  animation: confettiBurst 3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Confetti shapes: alternate circles and squares */
.celebration-confetti__piece:nth-child(odd) { border-radius: 50%; }
.celebration-confetti__piece:nth-child(even) { border-radius: 2px; transform: rotate(45deg); }

/* Vibrant confetti colors */
.celebration-confetti__piece:nth-child(1) { background: #fbbf24; width: 12px; height: 12px; }
.celebration-confetti__piece:nth-child(2) { background: #10b981; }
.celebration-confetti__piece:nth-child(3) { background: #3b82f6; width: 8px; height: 8px; }
.celebration-confetti__piece:nth-child(4) { background: #f43f5e; width: 11px; height: 11px; }
.celebration-confetti__piece:nth-child(5) { background: #8b5cf6; }
.celebration-confetti__piece:nth-child(6) { background: #06b6d4; width: 9px; height: 9px; }
.celebration-confetti__piece:nth-child(7) { background: #f59e0b; width: 7px; height: 7px; }
.celebration-confetti__piece:nth-child(8) { background: #ec4899; }
.celebration-confetti__piece:nth-child(9) { background: #14b8a6; width: 12px; height: 12px; }
.celebration-confetti__piece:nth-child(10) { background: #6366f1; }
.celebration-confetti__piece:nth-child(11) { background: #f97316; width: 8px; height: 8px; }
.celebration-confetti__piece:nth-child(12) { background: #a855f7; width: 11px; height: 11px; }

/* Burst pattern — confetti explodes from center-top */
.celebration-confetti__piece:nth-child(1)  { left: 10%; animation-delay: 0s; }
.celebration-confetti__piece:nth-child(2)  { left: 20%; animation-delay: 0.08s; }
.celebration-confetti__piece:nth-child(3)  { left: 30%; animation-delay: 0.16s; }
.celebration-confetti__piece:nth-child(4)  { left: 40%; animation-delay: 0.04s; }
.celebration-confetti__piece:nth-child(5)  { left: 50%; animation-delay: 0.12s; }
.celebration-confetti__piece:nth-child(6)  { left: 60%; animation-delay: 0.2s; }
.celebration-confetti__piece:nth-child(7)  { left: 70%; animation-delay: 0.06s; }
.celebration-confetti__piece:nth-child(8)  { left: 80%; animation-delay: 0.14s; }
.celebration-confetti__piece:nth-child(9)  { left: 88%; animation-delay: 0.1s; }
.celebration-confetti__piece:nth-child(10) { left: 5%;  animation-delay: 0.18s; }
.celebration-confetti__piece:nth-child(11) { left: 45%; animation-delay: 0.22s; }
.celebration-confetti__piece:nth-child(12) { left: 75%; animation-delay: 0.02s; }

@keyframes confettiBurst {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg) scale(0.5);
  }
  10% {
    opacity: 1;
    transform: translateY(-10px) rotate(30deg) scale(1.2);
  }
  30% {
    opacity: 1;
    transform: translateY(40px) rotate(120deg) translateX(20px) scale(1);
  }
  60% {
    opacity: 0.8;
    transform: translateY(120px) rotate(260deg) translateX(-15px) scale(0.9);
  }
  100% {
    opacity: 0;
    transform: translateY(250px) rotate(420deg) translateX(10px) scale(0.6);
  }
}

/* --- Celebration Gauge — modern glowing ring --- */

.celebration-gauge {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(160px, 45vw);
  height: min(160px, 45vw);
  z-index: 2;
  filter: drop-shadow(0 0 20px var(--celebration-glow, rgba(16, 185, 129, 0.15)));
  animation: gaugeAppear 600ms cubic-bezier(0.16, 1, 0.3, 1) 200ms forwards;
  opacity: 0;
}

@keyframes gaugeAppear {
  from {
    opacity: 0;
    transform: scale(0.6) rotate(-10deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

.celebration-gauge svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.celebration-gauge__track {
  fill: none;
  stroke: rgba(128, 128, 128, 0.08);
  stroke-width: 6;
}

.celebration-gauge__circle {
  fill: none;
  stroke: var(--celebration-gauge-color, #10b981);
  stroke-width: 6;
  stroke-linecap: round;
  animation: gaugeGrow 1000ms cubic-bezier(0.34, 1.56, 0.64, 1) 500ms forwards;
  stroke-dashoffset: var(--gauge-circumference, 440);
}

@keyframes gaugeGrow {
  from {
    stroke-dashoffset: var(--gauge-circumference, 440);
  }
  to {
    stroke-dashoffset: var(--gauge-offset, 0);
  }
}

/* --- Score display (centered inside gauge) — bold modern --- */

.celebration-score {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  z-index: 3;
  animation: scorePopIn 400ms cubic-bezier(0.16, 1, 0.3, 1) 700ms forwards;
  opacity: 0;
}

@keyframes scorePopIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.celebration-score__percentage {
  font-family: 'Poppins', sans-serif;
  font-weight: 800;
  font-size: 2rem;
  color: var(--celebration-accent, #10b981);
  line-height: 1;
  letter-spacing: -0.5px;
}

.celebration-score__detail {
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  font-size: 0.72rem;
  color: var(--iq-body-text, #1d1d1f);
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- Celebration Message — modern with emoji support --- */

.celebration-message {
  text-align: center;
  z-index: 2;
  animation: messageSlideUp 400ms ease 800ms forwards;
  opacity: 0;
}

@keyframes messageSlideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.celebration-message__title {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--iq-body-text, #1d1d1f);
  margin: 0 0 6px;
  line-height: 1.3;
}

.celebration-message__subtitle {
  font-family: 'Poppins', sans-serif;
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--iq-body-text, #1d1d1f);
  opacity: 0.65;
  margin: 0;
  line-height: 1.4;
}

/* ==========================================================================
   Celebration: Mobile Responsive (<768px)
   ========================================================================== */

@media (max-width: 768px) {
  .celebration-wrapper {
    padding: 28px 14px;
    gap: 16px;
  }

  .celebration-gauge {
    width: min(130px, 42vw);
    height: min(130px, 42vw);
  }

  .celebration-score__percentage {
    font-size: 1.5rem;
  }

  .celebration-score__detail {
    font-size: 0.65rem;
  }

  .celebration-message__title {
    font-size: 1rem;
  }

  .celebration-message__subtitle {
    font-size: 0.78rem;
  }

  /* Reduce confetti piece count visually on mobile — hide extras */
  .celebration-confetti__piece:nth-child(n+9) {
    display: none;
  }

  .celebration-confetti__piece {
    width: 7px;
    height: 7px;
  }
}

/* ==========================================================================
   Inline Celebration View (inline_celebration.html)
   ========================================================================== */

.inline-celebration {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px 16px;
  position: relative;
  overflow: hidden;
  animation: celebrationFadeIn 300ms ease forwards;
}

@keyframes celebrationFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* --- Confetti Particles (CSS-only) --- */

.inline-celebration__confetti {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  opacity: 0;
  animation: confettiFall 2.5s ease-in-out forwards;
}

.confetti-piece--1  { left: 5%;  animation-delay: 0s;    background: #6366f1; border-radius: 50%; }
.confetti-piece--2  { left: 15%; animation-delay: 0.15s; background: #f59e0b; border-radius: 2px; }
.confetti-piece--3  { left: 25%; animation-delay: 0.3s;  background: #22c55e; border-radius: 50%; }
.confetti-piece--4  { left: 35%; animation-delay: 0.1s;  background: #ec4899; border-radius: 2px; }
.confetti-piece--5  { left: 45%; animation-delay: 0.25s; background: #3b82f6; border-radius: 50%; }
.confetti-piece--6  { left: 55%; animation-delay: 0.05s; background: #f97316; border-radius: 2px; }
.confetti-piece--7  { left: 65%; animation-delay: 0.35s; background: #8b5cf6; border-radius: 50%; }
.confetti-piece--8  { left: 75%; animation-delay: 0.2s;  background: #14b8a6; border-radius: 2px; }
.confetti-piece--9  { left: 85%; animation-delay: 0.4s;  background: #ef4444; border-radius: 50%; }
.confetti-piece--10 { left: 92%; animation-delay: 0.12s; background: #eab308; border-radius: 2px; }
.confetti-piece--11 { left: 10%; animation-delay: 0.28s; background: #06b6d4; border-radius: 50%; width: 8px; height: 8px; }
.confetti-piece--12 { left: 50%; animation-delay: 0.08s; background: #a855f7; border-radius: 2px; width: 8px; height: 8px; }

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }
  25% {
    opacity: 1;
    transform: translateY(80px) rotate(120deg) translateX(15px);
  }
  50% {
    opacity: 0.8;
    transform: translateY(180px) rotate(240deg) translateX(-10px);
  }
  75% {
    opacity: 0.5;
    transform: translateY(280px) rotate(360deg) translateX(8px);
  }
  100% {
    opacity: 0;
    transform: translateY(380px) rotate(480deg) translateX(-5px);
  }
}

/* --- SVG Circular Gauge --- */

.inline-celebration__gauge {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.inline-celebration__svg {
  width: 100%;
  height: 100%;
  animation: gaugeScaleIn 400ms ease forwards;
}

@keyframes gaugeScaleIn {
  from {
    opacity: 0;
    transform: scale(0.7);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.inline-celebration__gauge-fill {
  transition: stroke-dasharray 600ms ease;
}

/* Pass = green gauge fill */
.inline-celebration--passed .inline-celebration__gauge-fill {
  stroke: #22c55e;
}

/* Fail = red gauge fill */
.inline-celebration--failed .inline-celebration__gauge-fill {
  stroke: #ef4444;
}

/* Score text overlay (centered inside gauge) */
.inline-celebration__score-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.inline-celebration__score-count {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--iq-body-text, #1d1d1f);
}

/* --- Content (icon + message) --- */

.inline-celebration__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.inline-celebration__icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.inline-celebration__icon--success {
  background: rgba(34, 197, 94, 0.12);
  color: #22c55e;
}

.inline-celebration__icon--info {
  background: rgba(128, 128, 128, 0.1);
  color: #6b7280;
}

/* Fail state: muted confetti-less appearance */
.inline-celebration--failed .inline-celebration__icon--info {
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
}

.inline-celebration__title {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: var(--iq-body-text, #1d1d1f);
  margin: 0;
}

.inline-celebration__subtitle {
  font-family: 'Poppins', sans-serif;
  font-size: 0.85rem;
  color: var(--iq-body-text, #1d1d1f);
  opacity: 0.7;
  margin: 0;
  line-height: 1.5;
}

/* --- Actions --- */

.inline-celebration__actions {
  margin-top: 8px;
}

/* --- Feedback-first wrapper (last answer feedback before showing celebration) --- */

.inline-celebration__feedback-first {
  padding: 16px;
  animation: feedbackFadeIn 250ms ease forwards;
}

/* ==========================================================================
   Celebration Mobile Responsive
   ========================================================================== */

@media (max-width: 768px) {
  .inline-celebration {
    padding: 20px 12px;
    gap: 12px;
  }

  .inline-celebration__gauge {
    width: 100px;
    height: 100px;
  }

  .inline-celebration__score-count {
    font-size: 1.1rem;
  }

  .inline-celebration__icon {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  .inline-celebration__title {
    font-size: 0.92rem;
  }

  .confetti-piece {
    width: 8px;
    height: 8px;
  }
}

/* ==========================================================================
   POST Quiz Exam Mode — Rich header, progress bar, enhanced feedback
   ========================================================================== */

/* --- Exam Header (question number + progress bar) --- */

.quiz-exam-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 14px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(128, 128, 128, 0.1);
}

.quiz-exam-header__step {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.quiz-exam-header__number {
  font-family: 'Poppins', sans-serif;
  font-weight: 800;
  font-size: 2rem;
  line-height: 1;
  color: var(--iq-brand-color-1, #003399);
}

.quiz-exam-header__of {
  font-family: 'Poppins', sans-serif;
  font-weight: 400;
  font-size: 1rem;
  color: var(--iq-body-text, #1d1d1f);
  opacity: 0.5;
}

.quiz-exam-header__bar {
  width: 100%;
  height: 4px;
  background: rgba(128, 128, 128, 0.1);
  border-radius: 100px;
  overflow: hidden;
}

.quiz-exam-header__bar-fill {
  height: 100%;
  background: var(--iq-brand-color-1, #003399);
  border-radius: 100px;
  transition: width 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

.quiz-exam-header__label {
  font-family: 'Poppins', sans-serif;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--iq-body-text, #1d1d1f);
  opacity: 0.5;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- Enhanced feedback for POST quiz --- */

.inline-quiz-feedback__explanation-text {
  font-family: 'Poppins', sans-serif;
  font-size: 0.78rem;
  color: var(--iq-body-text, #1d1d1f);
  opacity: 0.75;
  line-height: 1.5;
  padding: 8px 12px;
  background: rgba(128, 128, 128, 0.04);
  border-radius: 6px;
  border-left: 3px solid var(--iq-brand-color-1, #003399);
  margin-top: 6px;
}

.inline-quiz-feedback__explanation-text i {
  color: #fbbf24;
  margin-right: 6px;
}

.inline-quiz-feedback__encouragement {
  font-family: 'Poppins', sans-serif;
  font-size: 0.8rem;
  color: var(--iq-body-text, #1d1d1f);
  margin: 0;
  padding: 6px 0;
}

.inline-quiz-feedback__encouragement i {
  color: #fbbf24;
  margin-right: 4px;
}

.inline-quiz-feedback__explanation-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--iq-brand-color-1, #003399);
  text-decoration: none;
  margin-top: 6px;
  transition: opacity 0.15s ease;
}

.inline-quiz-feedback__explanation-link:hover {
  opacity: 0.7;
  text-decoration: underline;
}

/* --- Mobile adjustments for exam header --- */

@media (max-width: 768px) {
  .quiz-exam-header__number {
    font-size: 1.6rem;
  }
  
  .quiz-exam-header__of {
    font-size: 0.85rem;
  }
}

/* --- POST quiz hint (no correct answer revealed) --- */

.inline-quiz-feedback__hint {
  font-family: 'Poppins', sans-serif;
  font-size: 0.8rem;
  color: var(--iq-body-text, #1d1d1f);
  opacity: 0.85;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.inline-quiz-feedback__hint i {
  color: #f59e0b;
  flex-shrink: 0;
}

/* ==========================================================================
   POST Quiz Drawer — Course Info Card
   ========================================================================== */

.post-quiz-drawer__course-info {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: rgba(128, 128, 128, 0.04);
  border: 1px solid rgba(128, 128, 128, 0.08);
  border-radius: 10px;
}

.post-quiz-drawer__course-img {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.post-quiz-drawer__course-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.post-quiz-drawer__course-title {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--iq-body-text, #1d1d1f);
  margin: 0;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.post-quiz-drawer__course-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.post-quiz-drawer__badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.62rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(128, 128, 128, 0.08);
  color: var(--iq-body-text, #1d1d1f);
  opacity: 0.75;
}

.post-quiz-drawer__badge--cert {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  opacity: 1;
}

.post-quiz-drawer__badge--cert i {
  color: #10b981;
}

.post-quiz-drawer__badge i {
  font-size: 0.58rem;
}

/* ==========================================================================
   MID Quiz: Merge lesson-quiz-box and inline container into one visual block
   ========================================================================== */

.lesson-quiz-box + .inline-quiz-container--active {
  margin-top: 0;
  border-top: none;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.lesson-quiz-box:has(+ .inline-quiz-container--active) {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: none;
  margin-bottom: 0;
}

/* Hide the "Rispondi" button when quiz is already open */
.lesson-quiz-box:has(+ .inline-quiz-container--active) .lesson-quiz-box__btn {
  display: none;
}
