/* =================================================================
   PAES Practice · Lesson Engine - Duolingo-grade visual layer
   Tight feedback, particle bursts, character reaction states.
   ================================================================= */

:root {
  --ll-bg: #0A4D9B;
  --ll-bg-deep: #073876;
  --ll-gold: #27A9E1;
  --ll-gold-bright: #FFD15C;
  --ll-teal: #27A9E1;
  --ll-cream: #F7F3EC;
  --ll-correct: #58CC02;
  --ll-wrong: #FF4B4B;
  --ll-card: #FFF8EC;
  --ll-text: #0A4D9B;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  background: linear-gradient(180deg, var(--ll-bg-deep) 0%, var(--ll-bg) 100%);
  color: #fff;
  min-height: 100vh;
  user-select: none;
  overflow-x: hidden;
}

/* ---------- Header (hearts, streak, exit) ---------- */
.ll-header {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.ll-progress-bar {
  flex: 1;
  height: 14px;
  /* Roast caught the track being indistinguishable from the fill. Track
     darkened with an inset shadow so the unfilled portion reads as a
     trough, not just a slightly-different shade. */
  background: rgba(0,0,0,0.42);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 100px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 3px rgba(0,0,0,0.35);
}
.ll-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ll-correct) 0%, #7FE85F 100%);
  border-radius: 100px;
  width: 0%;
  transition: width 0.4s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.18), inset 0 2px 0 rgba(255,255,255,0.3);
}
.ll-hearts {
  display: flex; gap: 4px; align-items: center;
}
.ll-heart {
  font-size: 22px;
  transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1), opacity 0.4s ease;
}
.ll-heart.lost {
  opacity: 0.18;
  transform: scale(0.85);
  filter: grayscale(100%);
}
.ll-heart.lost-now {
  animation: heart-break 0.6s cubic-bezier(0.4,0,0.2,1) forwards;
}
@keyframes heart-break {
  0% { transform: scale(1); }
  30% { transform: scale(1.4) rotate(-15deg); }
  60% { transform: scale(0.7) rotate(20deg); }
  100% { transform: scale(0.85) rotate(0); opacity: 0.18; filter: grayscale(100%); }
}
.ll-exit {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.85);
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}
.ll-exit:hover { background: rgba(255,255,255,0.12); }
.ll-streak-pill {
  background: linear-gradient(135deg, rgba(39,169,225,0.25), rgba(239,64,47,0.15));
  border: 1px solid rgba(39,169,225,0.4);
  color: var(--ll-gold);
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 12.5px;
  font-weight: 800;
  display: inline-flex; align-items: center; gap: 6px;
}

/* ---------- Stage ----------
   Round-11 brief: stop caging games in tiny centred boxes. Static
   lessons (intro, MCQ, video) keep the 860px readable column for
   text density. The workstation engine renders into a `.ws-proc`
   grid which wants the full viewport, so when that's mounted the
   :has() rule below blows out the cap. POS is the model: edge-to-
   edge with sensible side padding, no dead blue gutters. */
.ll-stage {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 24px 100px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  min-height: calc(100vh - 60px);
}
.ll-stage:has(.ws-proc),
.ll-stage:has(.ws-stage),
.ll-stage:has(.ws-scale-stage),
.ll-stage:has(.ws-task-stage) {
  max-width: none;
  align-items: stretch;
  padding: 16px 28px 80px;
}

/* ---------- Boss (character) ---------- */
.ll-boss {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--boss-c, #27A9E1), var(--boss-c-dark, #0E5A5A));
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
  font-size: 78px;
  box-shadow: 0 14px 30px rgba(0,0,0,0.4);
  position: relative;
  transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
.ll-boss.cheer { animation: boss-cheer 0.8s ease-out; }
.ll-boss.oops  { animation: boss-oops 0.5s ease-out; }
@keyframes boss-cheer {
  0% { transform: scale(1) rotate(0); }
  30% { transform: scale(1.15) rotate(-8deg); }
  60% { transform: scale(1.1) rotate(8deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes boss-oops {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}
.ll-boss-name {
  text-align: center;
  font-size: 12px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  font-weight: 700;
  margin-bottom: 32px;
}

/* ---------- Prompt ---------- */
.ll-prompt {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.6px;
  text-align: center;
  line-height: 1.25;
  margin-bottom: 32px;
  max-width: 720px;
}
.ll-prompt-sub {
  font-size: 15px;
  color: rgba(255,255,255,0.65);
  text-align: center;
  margin-top: -22px;
  margin-bottom: 32px;
}

/* ---------- Multiple choice ---------- */
.ll-mc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
  max-width: 640px;
}
.ll-mc-btn {
  background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.02) 100%);
  border: 2px solid rgba(255,255,255,0.12);
  border-bottom: 4px solid rgba(255,255,255,0.16);
  color: #fff;
  padding: 22px 24px;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
  display: flex; align-items: center; gap: 14px;
}
.ll-mc-btn:hover { border-color: var(--ll-gold); background: rgba(39,169,225,0.08); }
.ll-mc-btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.ll-mc-btn.correct {
  border-color: var(--ll-correct);
  background: rgba(88,204,2,0.18);
  border-bottom-color: #3BA000;
}
.ll-mc-btn.wrong {
  border-color: var(--ll-wrong);
  background: rgba(255,75,75,0.12);
  border-bottom-color: #B33030;
  animation: shake 0.4s ease;
}
.ll-mc-btn.disabled { pointer-events: none; opacity: 0.5; }
.ll-mc-letter {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: rgba(255,255,255,0.12);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px;
  flex-shrink: 0;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ---------- Tap target ---------- */
.ll-scene {
  position: relative;
  background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  padding: 30px;
  width: 100%;
  max-width: 720px;
  display: flex; flex-wrap: wrap; gap: 20px; justify-content: center;
}
.ll-tt-target {
  background: linear-gradient(180deg, #fff 0%, #e8e8e8 100%);
  border: 3px solid rgba(255,255,255,0.2);
  border-bottom-width: 5px;
  border-radius: 16px;
  padding: 22px 26px;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--ll-text);
  transition: transform 0.1s ease, border-color 0.15s ease;
  min-width: 140px;
}
.ll-tt-target:hover { transform: translateY(-3px); border-color: var(--ll-gold); }
.ll-tt-target.correct { border-color: var(--ll-correct); background: linear-gradient(180deg, #b3f078 0%, #58CC02 100%); color: #1a3300; }
.ll-tt-target.wrong { border-color: var(--ll-wrong); background: linear-gradient(180deg, #ffb3b3 0%, #FF4B4B 100%); color: #4a0000; animation: shake 0.4s ease; }
.ll-tt-target .ll-tt-glyph { font-size: 56px; display: block; margin-bottom: 8px; line-height: 1; }

/* ---------- Match pairs ---------- */
.ll-match-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 26px;
  width: 100%;
  max-width: 720px;
}
.ll-match-col { display: flex; flex-direction: column; gap: 10px; }
.ll-match-item {
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border: 2px solid rgba(255,255,255,0.1);
  border-bottom-width: 4px;
  border-radius: 12px;
  padding: 16px 18px;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
  text-align: left;
}
.ll-match-item:hover { border-color: var(--ll-gold); }
.ll-match-item.selected { border-color: var(--ll-gold); background: rgba(39,169,225,0.15); }
.ll-match-item.matched { border-color: var(--ll-correct); background: rgba(88,204,2,0.15); pointer-events: none; opacity: 0.6; }
.ll-match-item.miss { border-color: var(--ll-wrong); animation: shake 0.4s ease; }

/* ---------- Reorder ---------- */
.ll-reorder-list {
  display: flex; flex-direction: column; gap: 10px;
  width: 100%; max-width: 600px;
}
.ll-reorder-item {
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border: 2px solid rgba(255,255,255,0.1);
  border-bottom-width: 4px;
  border-radius: 12px;
  padding: 16px 18px;
  cursor: grab;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  display: flex; align-items: center; gap: 14px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.ll-reorder-item:hover { border-color: var(--ll-gold); }
.ll-reorder-item.dragging { opacity: 0.6; cursor: grabbing; transform: scale(1.02); }
.ll-reorder-handle { font-size: 18px; opacity: 0.4; }
.ll-reorder-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px;
  flex-shrink: 0;
}

/* ---------- Listen step ---------- */
.ll-listen-btn {
  background: linear-gradient(135deg, var(--ll-teal), #0E5A5A);
  color: #fff; border: none;
  padding: 16px 28px; border-radius: 100px;
  font-size: 16px; font-weight: 800; cursor: pointer;
  font-family: inherit;
  box-shadow: 0 8px 18px rgba(39,169,225,0.35);
  margin-bottom: 8px;
  transition: transform 0.15s ease;
}
.ll-listen-btn:hover { transform: translateY(-2px); }
.ll-listen-replay { margin-bottom: 14px; }

/* ---------- Video step ---------- */
.ll-video-wrap {
  width: 100%; max-width: 720px;
  border-radius: 18px; overflow: hidden;
  background: #000; box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  margin-bottom: 28px;
  aspect-ratio: 16 / 9;
}
.ll-video-wrap video, .ll-video-wrap iframe { width: 100%; height: 100%; display: block; }
.ll-video-overlay {
  position: relative;
}
.ll-video-caption {
  position: absolute; bottom: 14px; left: 14px; right: 14px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  backdrop-filter: blur(6px);
}

/* ---------- CTA / Continue ---------- */
.ll-footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  padding: 16px 24px;
  background: linear-gradient(180deg, transparent 0%, rgba(8,26,45,0.92) 30%, rgba(8,26,45,0.96) 100%);
  display: flex; justify-content: center;
  pointer-events: none;
  z-index: 50;
}
.ll-footer.show { pointer-events: auto; }
.ll-feedback {
  background: var(--ll-card);
  color: var(--ll-text);
  border-radius: 14px;
  padding: 18px 22px 16px;
  max-width: 720px;
  width: 100%;
  display: flex; gap: 14px; align-items: flex-start;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.4);
  transform: translateY(120%);
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1);
  pointer-events: auto;
}
.ll-footer.show .ll-feedback { transform: translateY(0); }
.ll-feedback.correct { background: linear-gradient(180deg, #d8f5b4, #a8e870); border-left: 6px solid var(--ll-correct); }
.ll-feedback.wrong   { background: linear-gradient(180deg, #ffd6d6, #ff9a9a); border-left: 6px solid var(--ll-wrong); }
.ll-feedback-ico {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 22px; font-weight: 800;
}
.ll-feedback.correct .ll-feedback-ico { background: var(--ll-correct); color: #fff; }
.ll-feedback.wrong   .ll-feedback-ico { background: var(--ll-wrong); color: #fff; }
.ll-feedback-body { flex: 1; }
.ll-feedback-title { font-size: 16px; font-weight: 800; margin-bottom: 4px; letter-spacing: -0.2px; }
.ll-feedback-text  { font-size: 14px; line-height: 1.5; color: rgba(10,77,155,0.85); }
.ll-feedback-cta {
  background: var(--ll-text); color: #fff;
  border: none; padding: 11px 22px;
  border-radius: 100px;
  font-size: 14px; font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  align-self: center;
}
.ll-feedback.correct .ll-feedback-cta { background: var(--ll-correct); }
.ll-feedback.wrong   .ll-feedback-cta { background: var(--ll-wrong); }

/* ---------- Particles (correct burst) ---------- */
.ll-particles { position: fixed; pointer-events: none; z-index: 90; }
.ll-particle {
  position: absolute; width: 12px; height: 12px;
  border-radius: 50%;
  pointer-events: none;
  animation: particle-fly 1.1s cubic-bezier(0.4,0,0.2,1) forwards;
}
@keyframes particle-fly {
  0%   { transform: translate(0,0) scale(1) rotate(0); opacity: 1; }
  100% { transform: var(--end-tr) scale(0); opacity: 0; }
}

/* ---------- Win screen ---------- */
.ll-win {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  /* Solid navy + dust-mote layer instead of the previous 92% translucent
     backdrop. The roast caught the still-visible scene bleeding through
     the rubric panel and making "Independent" badges + the Save-and-continue
     CTA unreadable on a classroom tablet under fluorescent light. */
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255,209,92,0.18) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(39,169,225,0.18) 0%, transparent 55%),
    linear-gradient(180deg, #0F2A48 0%, #08182B 100%);
  opacity: 0; pointer-events: none;
  transition: opacity 0.4s ease;
}
.ll-win.show { opacity: 1; pointer-events: auto; }
.ll-win-card {
  /* Roast caught the modal washed out — pale blue on pale cream. Now
     using full white card + dark navy text for unambiguous contrast. */
  background: #fff;
  color: #0A2540;
  border-radius: 22px;
  padding: 36px 36px 32px;
  max-width: 480px;
  text-align: center;
  box-shadow: 0 22px 50px rgba(0,0,0,0.5);
  transform: scale(0.92);
  transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
  border: 1px solid rgba(0,0,0,0.06);
}
.ll-win.show .ll-win-card { transform: scale(1); }
.ll-win-trophy {
  width: 90px; height: 90px;
  background: linear-gradient(135deg, var(--ll-gold-bright), var(--ll-gold));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  font-size: 50px;
  box-shadow: 0 14px 30px rgba(39,169,225,0.5);
}
.ll-win h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.6px; margin-bottom: 6px; color: #0A2540; }
.ll-win-sub { font-size: 14.5px; color: #2a3848; margin-bottom: 22px; font-weight: 500; }
.ll-win-stats { display: flex; gap: 8px; margin-bottom: 22px; }
.ll-win-stat {
  flex: 1;
  background: rgba(10,77,155,0.06);
  border-radius: 12px;
  padding: 12px 6px;
  text-align: center;
}
.ll-win-stat .lab { font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase; color: rgba(10,77,155,0.55); font-weight: 800; margin-bottom: 4px; }
.ll-win-stat .val { font-size: 22px; font-weight: 800; letter-spacing: -0.4px; }
.ll-win-actions { display: flex; flex-direction: column; gap: 8px; }
.ll-win-btn {
  padding: 13px 22px; border-radius: 100px; border: none;
  font-weight: 800; font-size: 14px; cursor: pointer; font-family: inherit;
}
.ll-win-btn.primary { background: var(--ll-correct); color: #fff; }
.ll-win-btn.secondary { background: rgba(10,77,155,0.1); color: rgba(10,77,155,0.7); }

/* ---------- Game over ---------- */
.ll-gameover {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8,26,45,0.92); backdrop-filter: blur(12px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.4s ease;
}
.ll-gameover.show { opacity: 1; pointer-events: auto; }
.ll-gameover .ll-win-trophy { background: linear-gradient(135deg, #ff9a9a, #FF4B4B); box-shadow: 0 14px 30px rgba(255,75,75,0.4); }

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .ll-prompt { font-size: 22px; }
  .ll-mc-grid { grid-template-columns: 1fr; }
  .ll-match-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .ll-boss { width: 100px; height: 100px; font-size: 60px; }
}
