/* ============================================================
   CULTURILY — LESSON / QUIZ ENGINE STYLES
   lesson.html — quiz UI, feedback panel, end screen, modals
   ============================================================ */

/* ── Loading splash (reuses app-loading-logo from app.css) ── */

.lesson-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-6);
  min-height: 100dvh;
  background: var(--bg);
}

.app-loading-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.app-loading-logo-mark {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-loading-logo-mark svg {
  width: 24px;
  height: 24px;
}

.app-loading-logo-name {
  font-family: 'Fraunces', Georgia, serif;
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
}

/* ── Lesson shell layout ─────────────────────────────────── */

.lesson-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: var(--app-width);
  margin: 0 auto;
}

/* ── Top bar ─────────────────────────────────────────────── */

.lesson-top-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.lesson-back-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-full);
  color: var(--text-muted);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.lesson-back-btn:hover,
.lesson-back-btn:active {
  background: var(--surface-3);
  color: var(--text-primary);
}

/* Progress bar */
.lesson-progress-track {
  flex: 1;
  height: 10px;
  background: var(--surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
}

.lesson-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-full);
  transition: width 0.4s var(--ease-out);
}

/* Hearts */
.lesson-hearts {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  font-weight: 700;
  font-size: var(--text-base);
  color: var(--text-primary);
}

.lesson-hearts-icon {
  font-size: 18px;
  line-height: 1;
}

.lesson-hearts-count {
  min-width: 18px;
  text-align: center;
}

/* Shake animation when hearts drop */
@keyframes heartShake {
  0%, 100% { transform: scale(1); }
  20%       { transform: scale(1.3) rotate(-8deg); }
  40%       { transform: scale(1.2) rotate(6deg); }
  60%       { transform: scale(1.1) rotate(-4deg); }
  80%       { transform: scale(1.05); }
}

.lesson-hearts.is-shaking .lesson-hearts-icon {
  animation: heartShake 0.45s var(--ease) forwards;
}

/* ── Main question area ──────────────────────────────────── */

.lesson-main {
  flex: 1;
  padding: var(--sp-6) var(--sp-5) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  overflow-y: auto;
}

/* Question header */
.question-header {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.question-type-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.question-prompt {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: var(--leading-snug);
  color: var(--text-primary);
}

/* ── Option buttons ──────────────────────────────────────── */

.options-grid {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

/* True/false layout — 2 wide side-by-side */
.options-grid.is-true-false {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}

.option-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-4) var(--sp-4);
  background: var(--surface-2);
  border: 2px solid var(--border-strong);
  border-radius: var(--r-lg);
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition:
    background var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
  line-height: var(--leading-snug);
}

.option-btn:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--accent);
}

.option-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.option-btn:disabled {
  cursor: default;
}

/* Option key badge (A / B / C / D) */
.option-key {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-4);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-subtle);
  text-transform: uppercase;
}

/* True/false: center text, larger */
.options-grid.is-true-false .option-btn {
  justify-content: center;
  text-align: center;
  font-size: var(--text-lg);
  font-weight: 700;
  padding: var(--sp-5) var(--sp-3);
}

/* ── Correct state ───────────────────────────────────────── */

.option-btn.is-correct {
  background: var(--success-dim);
  border-color: var(--success);
  color: var(--success);
}

.option-btn.is-correct .option-key {
  background: var(--success);
  color: #0e0e0e;
}

@keyframes correctPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.04); }
  70%  { transform: scale(0.98); }
  100% { transform: scale(1); }
}

.option-btn.is-correct {
  animation: correctPop 0.35s var(--ease-spring) forwards;
}

/* ── Wrong state ─────────────────────────────────────────── */

.option-btn.is-wrong {
  background: var(--error-dim);
  border-color: var(--error);
  color: var(--error);
}

.option-btn.is-wrong .option-key {
  background: var(--error);
  color: #fff;
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  15%       { transform: translateX(-6px); }
  30%       { transform: translateX(5px); }
  45%       { transform: translateX(-4px); }
  60%       { transform: translateX(3px); }
  75%       { transform: translateX(-2px); }
}

.option-btn.is-wrong {
  animation: wrongShake 0.4s var(--ease) forwards;
}

/* Reveal the correct answer while wrong one shows red */
.option-btn.is-reveal {
  background: var(--success-dim);
  border-color: var(--success);
  color: var(--success);
}

.option-btn.is-reveal .option-key {
  background: var(--success);
  color: #0e0e0e;
}

/* Dimmed unchosen options after answering */
.option-btn.is-dimmed {
  opacity: 0.4;
}

/* ── Feedback panel ──────────────────────────────────────── */

.feedback-panel {
  display: none;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-4);
  border-radius: var(--r-lg);
  border: 2px solid transparent;
}

.feedback-panel.is-visible {
  display: flex;
}

.feedback-panel.is-correct-fb {
  background: var(--success-dim);
  border-color: var(--success);
}

.feedback-panel.is-wrong-fb {
  background: var(--error-dim);
  border-color: var(--error);
}

.feedback-top {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.feedback-icon {
  font-size: 20px;
  line-height: 1;
}

.feedback-heading {
  font-size: var(--text-lg);
  font-weight: 700;
}

.feedback-panel.is-correct-fb .feedback-heading {
  color: var(--success);
}

.feedback-panel.is-wrong-fb .feedback-heading {
  color: var(--error);
}

.feedback-explanation {
  font-size: var(--text-sm);
  color: var(--text-subtle);
  line-height: var(--leading-relaxed);
}

/* ── Lesson footer ───────────────────────────────────────── */

.lesson-footer {
  padding: var(--sp-4) var(--sp-5) var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  background: var(--bg);
  border-top: 1px solid var(--border);
}

/* Combo chip */
.lesson-combo {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--warning-dim);
  border: 1.5px solid var(--warning);
  border-radius: var(--r-full);
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--warning);
}

/* Continue button */
.lesson-continue-btn {
  width: 100%;
  padding: var(--sp-4);
  font-size: var(--text-lg);
  font-weight: 700;
  border-radius: var(--r-lg);
}

/* ── Modals (hearts + generic) ───────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--sp-5);
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-2xl);
  padding: var(--sp-8) var(--sp-6);
  max-width: 360px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  box-shadow: var(--shadow-xl);
}

.modal-icon {
  font-size: 52px;
  line-height: 1;
}

.modal-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
}

.modal-body {
  font-size: var(--text-sm);
  color: var(--text-subtle);
  line-height: var(--leading-relaxed);
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
}

.btn-full {
  width: 100%;
}

/* ── End of lesson screen ────────────────────────────────── */

.lesson-end {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-overlay);
  padding: var(--sp-6) var(--sp-5);
  overflow-y: auto;
}

.lesson-end-inner {
  max-width: var(--app-width);
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-6);
  text-align: center;
}

/* Stars */
.end-stars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
}

.end-star {
  font-size: 44px;
  line-height: 1;
  opacity: 0.25;
  transition: opacity 0.3s var(--ease), transform 0.4s var(--ease-spring);
  display: inline-block;
}

.end-star.is-earned {
  opacity: 1;
}

.end-star-center {
  font-size: 60px;
  margin-bottom: 4px;
}

/* Star pop animation */
@keyframes starPop {
  0%   { transform: scale(0.4) rotate(-15deg); opacity: 0; }
  60%  { transform: scale(1.2) rotate(5deg);  opacity: 1; }
  80%  { transform: scale(0.95); }
  100% { transform: scale(1) rotate(0deg);   opacity: 1; }
}

.end-star.pop {
  animation: starPop 0.5s var(--ease-spring) forwards;
}

/* Heading */
.end-heading {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  font-weight: 900;
  color: var(--text-primary);
  line-height: var(--leading-tight);
}

.end-subheading {
  font-size: var(--text-lg);
  color: var(--text-subtle);
  margin-top: calc(-1 * var(--sp-4));
}

/* Stats row */
.end-stats {
  display: flex;
  gap: var(--sp-5);
  justify-content: center;
  width: 100%;
}

.end-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-1);
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-3);
}

.end-stat-value {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--accent);
}

.end-stat-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Perfect score bonus */
.end-bonus {
  background: var(--warning-dim);
  border: 1.5px solid var(--warning);
  border-radius: var(--r-full);
  padding: var(--sp-2) var(--sp-5);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--warning);
}

/* Streak chip */
.end-streak-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  background: rgba(251, 191, 36, 0.12);
  border: 1.5px solid var(--warning);
  border-radius: var(--r-full);
  padding: var(--sp-2) var(--sp-5);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--warning);
}

/* Action buttons */
.end-actions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  width: 100%;
}

.end-actions .btn {
  padding: var(--sp-4);
  font-size: var(--text-lg);
  font-weight: 700;
  border-radius: var(--r-lg);
}

/* ── Shareable result card ───────────────────────────────── */

.share-card {
  width: 100%;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 16px;
  padding: 20px 20px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  margin-bottom: 4px;
}

.share-card-flag {
  font-size: 2rem;
  line-height: 1;
}

.share-card-score {
  font-family: 'Cabinet Grotesk', system-ui, sans-serif;
  font-size: 2.75rem;
  font-weight: 900;
  color: #CCFF00;
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 4px 0 0;
}

.share-card-lesson {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #f8f8f8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.share-card-stars {
  font-size: 1.1rem;
  letter-spacing: 2px;
  margin: 2px 0;
}

.share-card-tagline {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 0.875rem;
  color: #999;
  line-height: 1.4;
  margin-top: 2px;
}

.share-card-url {
  font-family: 'Cabinet Grotesk', system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  color: #CCFF00;
  letter-spacing: 0.04em;
  margin-top: 6px;
  opacity: 0.8;
}

/* ── Fade-in for question transition ─────────────────────── */

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

.question-header,
.options-grid {
  animation: questionFadeIn 0.25s var(--ease-out) both;
}

/* ── Lesson intro splash ─────────────────────────────────── */
/* Always dark — this is a transitional splash, not a content page.
   Hardcoded colours so it looks great in both light and dark themes. */

.lesson-intro {
  position: fixed;
  inset: 0;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  cursor: pointer;
  opacity: 1;
  transition: opacity 0.28s ease-in;
}

.lesson-intro.is-hiding {
  opacity: 0;
  pointer-events: none;
}

.lesson-intro-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--sp-6) var(--sp-5);
  width: 100%;
  max-width: var(--app-width);
  gap: var(--sp-2);
}

.lesson-intro-eyebrow {
  font-size: var(--text-xs);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 0;
}

.lesson-intro-number {
  font-size: var(--text-sm);
  font-weight: 700;
  color: #CCFF00;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin: 0;
}

.lesson-intro-title {
  font-family: var(--font-display);
  font-size: clamp(var(--text-2xl), 6vw, var(--text-4xl));
  font-weight: 700;
  color: #ffffff;
  line-height: 1.15;
  margin: var(--sp-3) 0 var(--sp-6);
}

.lesson-intro-tap {
  font-size: var(--text-xs);
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 0.06em;
  margin: 0;
  animation: pulse 2s ease-in-out infinite;
}

/* ── End screen back link ────────────────────────────────── */

.end-back-link {
  display: block;
  text-align: center;
  font-size: var(--text-sm);
  color: var(--text-subtle);
  text-decoration: underline;
  text-underline-offset: 3px;
  margin-top: var(--sp-2);
  padding: var(--sp-2);
  transition: color var(--t-fast) var(--ease);
}

.end-back-link:hover {
  color: var(--text-muted);
}

/* ── Hearts modal additions ──────────────────────────────── */

.hearts-regen-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--text-subtle);
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-4);
}

.hearts-regen-info i { font-size: 15px; }

.gem-refill-balance {
  font-size: var(--text-xs);
  opacity: 0.75;
  margin-left: var(--sp-1);
}

.hearts-escape-valves {
  display: flex;
  gap: var(--sp-2);
  justify-content: center;
  flex-wrap: wrap;
}

.hearts-escape-valves .btn {
  flex: 1;
  min-width: 120px;
  font-size: var(--text-xs);
  gap: var(--sp-1);
}

/* Ad overlay — replaces modal content during countdown */
.ad-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) 0;
}

.ad-overlay-label {
  font-size: var(--text-sm);
  color: var(--text-subtle);
}

.ad-overlay-sub {
  font-size: var(--text-xs);
  color: var(--text-disabled);
}

.ad-progress-track {
  width: 100%;
  height: 6px;
  background: var(--surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
}

.ad-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: var(--r-full);
  transition: width 0.1s linear;
}

/* ── Profile referral card ───────────────────────────────── */

.pf-referral-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.pf-referral-desc {
  font-size: var(--text-sm);
  color: var(--text-subtle);
  line-height: var(--leading-relaxed);
}

.pf-referral-code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.pf-referral-code {
  font-family: 'Cabinet Grotesk', monospace;
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.08em;
}
