/* ============================================================================
   QUIZ FX LAYER — GSAP + Procedural Three.js (img2threejs) + Lottie Motion Design
   ============================================================================ */

/* Disable conflicting CSS entrance animations inside #quiz-screen when GSAP drives them */
#quiz-screen.gsap-ready .q-card,
#quiz-screen.gsap-ready .q-opt,
#quiz-screen.gsap-ready .q-feedback,
#quiz-screen.gsap-ready .stamp {
  animation: none !important;
}

/* Ambient counter-motion aura behind quiz content */
#quiz-screen {
  isolation: isolate;
}
#quiz-screen::before {
  content: "";
  position: fixed;
  top: -12%;
  left: 50%;
  width: 460px;
  height: 360px;
  transform: translate3d(-50%, 0, 0);
  background: radial-gradient(circle, rgba(255, 198, 41, 0.14) 0%, rgba(74, 123, 255, 0.12) 45%, transparent 72%);
  pointer-events: none;
  z-index: 0;
  will-change: transform;
}
#quiz-screen .q-wrap {
  position: relative;
  z-index: 2;
}

/* GPU-composited Progress Bar (scaleX instead of width) */
.q-bar-track {
  position: relative;
  height: 9px !important;
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.55);
}
.q-bar-fill {
  width: 100% !important;
  transform-origin: left center;
  transform: scaleX(0);
  transition: none !important;
  will-change: transform;
  background: linear-gradient(90deg, #ff5e3a 0%, #ffc629 65%, #fff0a8 100%) !important;
  box-shadow: 0 0 14px rgba(255, 198, 41, 0.55);
}

/* ==================== PROCEDURAL 3D STAGE (img2threejs) ==================== */
.q-stage-3d {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 14px;
  background: radial-gradient(120% 100% at 50% 15%, #1a2c5e 0%, #0a1024 70%, #060914 100%);
  border: 1.5px solid rgba(110, 155, 255, 0.36);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 14px 34px rgba(0, 0, 0, 0.58);
  will-change: transform, opacity;
  touch-action: pan-y;
}

.q-stage-3d.stage-cover {
  aspect-ratio: 16 / 8.5;
  margin: 8px 0 12px;
  background: radial-gradient(120% 100% at 50% 20%, rgba(26, 44, 94, 0.72) 0%, rgba(8, 12, 26, 0.88) 100%);
  border-color: rgba(255, 198, 41, 0.38);
}

.q-stage-3d.stage-roundabout {
  aspect-ratio: 16 / 10;
  border-color: rgba(255, 71, 71, 0.52);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 14px 36px rgba(255, 59, 48, 0.22),
    0 10px 28px rgba(0, 0, 0, 0.65);
}

.q-stage-3d .q-stage-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.26;
  filter: saturate(1.15) blur(1px);
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.q-stage-3d.webgl-off .q-stage-fallback {
  opacity: 1;
  filter: none;
}

.q-stage-3d canvas.q-three-cv {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  display: block;
  z-index: 2;
  pointer-events: none;
}

/* Cinematic vignette + live HUD pill inside 3D stage */
.q-stage-3d::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(6, 10, 24, 0.12) 0%, transparent 40%, rgba(6, 10, 24, 0.62) 100%);
  pointer-events: none;
  z-index: 3;
}

.q-stage-chip {
  position: absolute;
  top: 9px;
  left: 9px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 99px;
  background: rgba(8, 13, 30, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
  font: 800 10px/1 system-ui;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #e2e8f0;
}

.q-stage-chip i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2fd27a;
  box-shadow: 0 0 8px #2fd27a;
  display: inline-block;
}
.q-stage-chip.warn i {
  background: #ffc629;
  box-shadow: 0 0 8px #ffc629;
}
.q-stage-chip.danger i {
  background: #ff4747;
  box-shadow: 0 0 10px #ff4747;
}

.q-stage-caption {
  position: absolute;
  bottom: 8px;
  left: 10px;
  right: 10px;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font: 700 11px/1.2 system-ui;
  color: rgba(241, 245, 249, 0.9);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}

/* ==================== ELEVATED QUIZ OPTIONS & MICRO-INTERACTIONS ==================== */
.q-opt {
  position: relative;
  overflow: hidden;
  will-change: transform, opacity;
  border: 1.5px solid rgba(99, 132, 224, 0.32) !important;
  background: linear-gradient(180deg, rgba(25, 38, 78, 0.92), rgba(14, 22, 48, 0.96)) !important;
  backdrop-filter: blur(8px);
}

.q-opt::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.09) 50%, transparent 70%);
  transform: translate3d(-120%, 0, 0);
  pointer-events: none;
}

.q-opt:hover {
  border-color: rgba(255, 198, 41, 0.6) !important;
}

.q-opt.selected {
  border-color: #ffc629 !important;
  background: linear-gradient(180deg, rgba(44, 58, 108, 0.96), rgba(22, 32, 68, 0.98)) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 0 0 2px rgba(255, 198, 41, 0.28),
    0 10px 24px rgba(0, 0, 0, 0.45) !important;
}

.q-opt.right {
  border-color: #2fd27a !important;
  background: linear-gradient(180deg, rgba(19, 68, 46, 0.96), rgba(11, 41, 28, 0.98)) !important;
  box-shadow: 0 0 22px rgba(47, 210, 122, 0.28) !important;
}

.q-opt.wrong {
  border-color: #ff4747 !important;
  background: linear-gradient(180deg, rgba(74, 22, 30, 0.96), rgba(45, 13, 18, 0.98)) !important;
  box-shadow: 0 0 22px rgba(255, 71, 71, 0.28) !important;
}

.q-opt-chev {
  margin-left: auto;
  width: 22px;
  height: 22px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.55);
  flex-shrink: 0;
  transition: transform 0.16s cubic-bezier(0.23, 1, 0.32, 1), color 0.16s ease, background 0.16s ease;
}
.q-opt:hover .q-opt-chev,
.q-opt.selected .q-opt-chev {
  transform: translateX(2px);
  color: #ffc629;
  background: rgba(255, 198, 41, 0.16);
}

/* ==================== LOTTIE-STYLE SVG COUNTDOWN RING (STEP 4) ==================== */
.q-timer-ring {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px 4px 6px;
  border-radius: 99px;
  background: rgba(255, 71, 71, 0.14);
  border: 1.5px solid rgba(255, 71, 71, 0.65);
  font: 900 16px/1 'Arial Black', system-ui;
  color: #ff8a8a;
  font-variant-numeric: tabular-nums;
}
.q-timer-ring svg {
  width: 24px;
  height: 24px;
  transform: rotate(-90deg);
}
.q-timer-ring .ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.14);
  stroke-width: 3;
}
.q-timer-ring .ring-fg {
  fill: none;
  stroke: #ff5b5b;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 56.55;
  stroke-dashoffset: 0;
}
.q-timer-ring.urgent {
  background: rgba(255, 59, 48, 0.28);
  border-color: #ff4747;
  color: #fff;
  box-shadow: 0 0 18px rgba(255, 71, 71, 0.45);
}

/* ==================== LOTTIE-STYLE STROKE CHECKMARK & SPINNER ==================== */
.q-lottie-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: rgba(255, 198, 41, 0.14);
  border: 1.5px solid rgba(255, 198, 41, 0.45);
}
.q-lottie-badge.done {
  background: rgba(47, 210, 122, 0.18);
  border-color: #2fd27a;
}
.q-lottie-badge svg {
  width: 14px;
  height: 14px;
  display: block;
}
.q-lottie-spin {
  animation: qLottieSpin 0.85s linear infinite;
}
@keyframes qLottieSpin {
  to { transform: rotate(360deg); }
}

/* Emoji-Free Custom Icon Badges & Option Typography (kept in quiz-fx.css so IDE never strips them) */
.q-ico-box {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1b2a54, #101936);
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.q-ico-box.red { background: linear-gradient(135deg, #4a1520, #280c14); border-color: rgba(255, 71, 71, 0.45); }
.q-ico-box.amber { background: linear-gradient(135deg, #4a3310, #261a08); border-color: rgba(255, 198, 41, 0.45); }
.q-ico-box.green { background: linear-gradient(135deg, #113b2a, #092017); border-color: rgba(47, 210, 122, 0.45); }
.q-ico-box.blue { background: linear-gradient(135deg, #16305c, #0c1b36); border-color: rgba(74, 123, 255, 0.45); }
.q-ico-box svg { width: 22px; height: 22px; display: block; }
.q-opt-body { display: flex; flex-direction: column; gap: 2px; }
.q-opt-body strong { font: 800 14.5px/1.25 system-ui; color: #ffffff; }
.q-opt-body small { margin: 0; font: 500 12px/1.3 system-ui; color: #94a3b8; }
.q-opt-letter {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font: 900 15px 'Arial Black', system-ui;
  background: #1b284d;
  border: 1.5px solid #4a7bff66;
  color: #ffc629;
}

/* Feedback particle burst dots */
.q-fx-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 20;
}
.q-fx-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  will-change: transform, opacity;
}
