/**
 * missions-enhanced.css
 * Owns: all animation, feedback, recap, timer, and enhanced interaction styles for mission gameplay.
 * Does NOT own: base layout, theme variables, dashboard styles.
 */

/* ─── Screen Transitions ──────────────────────────────────────────────────── */
.screen.active {
  animation: screenFadeIn 0.28s ease;
}

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

/* ─── Question Card Enhanced ──────────────────────────────────────────────── */
.question-card {
  transition: border-color 0.3s;
}

.question-card.shake {
  animation: questionShake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes questionShake {
  0%, 100% { transform: translateX(0); }
  15%       { transform: translateX(-8px) rotate(-1deg); }
  30%       { transform: translateX(8px) rotate(1deg); }
  45%       { transform: translateX(-6px); }
  60%       { transform: translateX(6px); }
  75%       { transform: translateX(-3px); }
  90%       { transform: translateX(3px); }
}

.question-card.breach {
  border-color: rgba(255, 60, 122, 0.5) !important;
  box-shadow: 0 0 32px rgba(255, 60, 122, 0.18);
  animation: questionShake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.question-card.defense {
  border-color: rgba(0, 240, 255, 0.4) !important;
  box-shadow: 0 0 32px rgba(0, 240, 255, 0.14);
  animation: shieldGlow 0.6s ease;
}

@keyframes shieldGlow {
  0%   { box-shadow: 0 0 0px rgba(0,240,255,0); }
  50%  { box-shadow: 0 0 48px rgba(0,240,255,0.35); }
  100% { box-shadow: 0 0 32px rgba(0,240,255,0.14); }
}

/* ─── Answer Options Enhanced ─────────────────────────────────────────────── */
.option-btn.correct {
  border-color: #00ff88 !important;
  background: rgba(0,255,136,0.1) !important;
  color: #00ff88 !important;
  animation: optionCorrect 0.4s ease;
}

@keyframes optionCorrect {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.025); }
  100% { transform: scale(1); }
}

.option-btn.incorrect {
  border-color: var(--accent-warm) !important;
  background: rgba(255,60,122,0.08) !important;
  color: var(--accent-warm) !important;
  animation: optionWrong 0.35s ease;
}

@keyframes optionWrong {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-4px); }
  75%       { transform: translateX(4px); }
}

/* Inline explanation block that replaces the hidden explanation-box */
.answer-feedback-inline {
  margin-top: 14px;
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 0.88rem;
  line-height: 1.6;
  animation: feedbackSlideIn 0.3s ease;
}

@keyframes feedbackSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.answer-feedback-inline.correct-feedback {
  background: rgba(0,255,136,0.06);
  border: 1px solid rgba(0,255,136,0.2);
  color: var(--fg);
}

.answer-feedback-inline.incorrect-feedback {
  background: rgba(255,60,122,0.06);
  border: 1px solid rgba(255,60,122,0.2);
  color: var(--fg);
}

.feedback-verdict {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  font-weight: 700;
}

.feedback-verdict.verdict-correct { color: #00ff88; }
.feedback-verdict.verdict-wrong   { color: var(--accent-warm); }

.feedback-correct-answer {
  font-size: 0.82rem;
  color: var(--fg-muted);
  margin-top: 4px;
}

.feedback-correct-answer strong {
  color: #00ff88;
}

/* ─── XP Pop Reward ───────────────────────────────────────────────────────── */
.xp-pop {
  position: fixed;
  pointer-events: none;
  z-index: 9000;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: #00f0ff;
  text-shadow: 0 0 12px rgba(0,240,255,0.6);
  animation: xpPop 1.1s ease forwards;
}

@keyframes xpPop {
  0%   { opacity: 0; transform: translateY(0) scale(0.6); }
  20%  { opacity: 1; transform: translateY(-10px) scale(1.1); }
  70%  { opacity: 1; transform: translateY(-40px) scale(1); }
  100% { opacity: 0; transform: translateY(-65px) scale(0.9); }
}

/* ─── Timed Challenge Mode ────────────────────────────────────────────────── */
.mission-timer-bar {
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  margin-bottom: 20px;
  overflow: hidden;
}

.mission-timer-fill {
  height: 100%;
  background: var(--gradient-accent);
  border-radius: 4px;
  transition: width 1s linear, background-color 0.5s;
  transform-origin: left;
}

.mission-timer-fill.warning {
  background: linear-gradient(90deg, #ff9900, #ff3c7a);
}

.mission-timer-fill.critical {
  background: linear-gradient(90deg, #ff3c7a, #ff0055);
  animation: timerPulse 0.5s ease infinite alternate;
}

@keyframes timerPulse {
  from { opacity: 1; }
  to   { opacity: 0.6; }
}

.mission-timer-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.75rem;
  color: var(--fg-muted);
}

.mission-timer-value {
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.mission-timer-value.warning  { color: #ff9900; }
.mission-timer-value.critical { color: var(--accent-warm); }

.timer-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.75rem;
  color: var(--fg-muted);
  cursor: pointer;
  user-select: none;
  transition: color 0.2s;
}
.timer-mode-toggle:hover { color: var(--fg); }
.timer-mode-toggle input[type="checkbox"] { cursor: pointer; accent-color: var(--accent); }

/* Timed mode active indicator on mission info */
.timed-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.65rem;
  font-family: var(--font-display);
  letter-spacing: 0.1em;
  color: #ff9900;
  background: rgba(255,153,0,0.1);
  border: 1px solid rgba(255,153,0,0.2);
  border-radius: 20px;
  padding: 3px 10px;
  margin-left: 8px;
  animation: timerBlink 1.4s ease infinite alternate;
}

@keyframes timerBlink {
  from { opacity: 1; }
  to   { opacity: 0.55; }
}

/* ─── Mission Recap Screen ────────────────────────────────────────────────── */
.mission-recap-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0,0,0,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s ease;
  overflow-y: auto;
}

.mission-recap-card {
  background: var(--bg-card);
  border: 1px solid rgba(0,240,255,0.14);
  border-radius: 16px;
  padding: 40px 36px;
  max-width: 520px;
  width: 100%;
  position: relative;
  box-shadow: 0 0 80px rgba(0,240,255,0.1);
  animation: recapSlideUp 0.45s cubic-bezier(0.22, 0.9, 0.36, 1);
}

@keyframes recapSlideUp {
  from { opacity: 0; transform: translateY(30px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.recap-top-bar {
  height: 3px;
  background: var(--gradient-accent);
  border-radius: 3px 3px 0 0;
  position: absolute;
  top: 0; left: 0; right: 0;
}

.recap-header {
  text-align: center;
  margin-bottom: 28px;
}

.recap-result-icon {
  font-size: 3rem;
  margin-bottom: 8px;
  animation: iconBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}

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

.recap-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--fg);
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.recap-subtitle {
  font-size: 0.88rem;
  color: var(--fg-muted);
}

/* Score ring */
.recap-score-ring {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.score-ring-svg {
  transform: rotate(-90deg);
}

.score-ring-track {
  fill: none;
  stroke: rgba(255,255,255,0.06);
  stroke-width: 7;
}

.score-ring-fill {
  fill: none;
  stroke-width: 7;
  stroke-linecap: round;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.22, 0.9, 0.36, 1);
}

.score-ring-fill.passing { stroke: url(#recap-ring-gradient); }
.score-ring-fill.failing { stroke: var(--accent-warm); }

.score-ring-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.score-ring-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.score-ring-pct {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--fg);
}

.score-ring-pct-small {
  font-size: 0.8rem;
  color: var(--fg-muted);
}

/* Stats row */
.recap-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.recap-stat-item {
  background: var(--bg-surface);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 10px;
  padding: 14px 10px;
  text-align: center;
}

.recap-stat-value {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 3px;
}

.recap-stat-value.xp-val   { color: #ffd700; }
.recap-stat-value.time-val { color: #a78bfa; }
.recap-stat-value.class-val { color: #34d399; }

.recap-stat-label {
  font-size: 0.65rem;
  color: var(--fg-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Choices made row */
.recap-choices-section {
  margin-bottom: 20px;
}

.recap-section-title {
  font-size: 0.7rem;
  font-family: var(--font-display);
  letter-spacing: 0.1em;
  color: var(--fg-muted);
  text-transform: uppercase;
  margin-bottom: 10px;
}

.recap-choice-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.82rem;
}

.recap-choice-row:last-child { border-bottom: none; }

.recap-choice-icon { font-size: 0.9rem; flex-shrink: 0; margin-top: 2px; }
.recap-choice-text { color: var(--fg-muted); flex: 1; line-height: 1.45; }
.recap-choice-text strong { color: var(--fg); font-weight: 600; }

/* Class comparison bar */
.recap-class-compare {
  background: var(--bg-surface);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 0.82rem;
}

.recap-class-bars {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.class-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.class-bar-label {
  width: 60px;
  font-size: 0.72rem;
  color: var(--fg-muted);
  flex-shrink: 0;
}

.class-bar-track {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 6px;
  overflow: hidden;
}

.class-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 1s cubic-bezier(0.22, 0.9, 0.36, 1) 0.5s;
}

.class-bar-fill.you-fill   { background: var(--gradient-accent); }
.class-bar-fill.class-fill { background: rgba(255,255,255,0.2); }

.class-bar-pct {
  width: 36px;
  font-size: 0.72rem;
  color: var(--fg-muted);
  text-align: right;
  flex-shrink: 0;
}

/* Badge unlock row */
.recap-badge-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255,215,0,0.05);
  border: 1px solid rgba(255,215,0,0.15);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 20px;
  animation: badgeRowPulse 1.5s ease infinite alternate;
}

@keyframes badgeRowPulse {
  from { box-shadow: 0 0 0px rgba(255,215,0,0); }
  to   { box-shadow: 0 0 18px rgba(255,215,0,0.12); }
}

.recap-badge-emoji { font-size: 2rem; }
.recap-badge-info  { flex: 1; }

.recap-badge-name {
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: #ffd700;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}

.recap-badge-desc {
  font-size: 0.78rem;
  color: var(--fg-muted);
}

/* Action buttons */
.recap-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.btn-recap-dashboard {
  background: var(--gradient-accent);
  border: none;
  border-radius: 10px;
  color: #000;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 14px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  text-align: center;
}

.btn-recap-dashboard:hover { opacity: 0.88; transform: translateY(-1px); }

.btn-recap-retry {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: var(--fg-muted);
  font-family: var(--font-body);
  font-size: 0.82rem;
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  text-align: center;
}
.btn-recap-retry:hover { border-color: rgba(255,255,255,0.2); color: var(--fg); }

.btn-recap-share {
  background: rgba(0,240,255,0.07);
  border: 1px solid rgba(0,240,255,0.15);
  border-radius: 10px;
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 0.82rem;
  padding: 12px;
  cursor: pointer;
  transition: background 0.2s;
  text-align: center;
}
.btn-recap-share:hover { background: rgba(0,240,255,0.12); }

.btn-recap-family-share {
  background: rgba(168,85,247,0.10);
  border: 1px solid rgba(168,85,247,0.30);
  border-radius: 10px;
  color: #a855f7;
  font-family: var(--font-body);
  font-size: 0.82rem;
  padding: 12px;
  cursor: pointer;
  transition: background 0.2s;
  text-align: center;
}
.btn-recap-family-share:hover { background: rgba(168,85,247,0.18); }

/* ─── Easter Egg / Hidden Clickable ──────────────────────────────────────── */
.easter-egg-target {
  cursor: pointer;
  transition: filter 0.2s, transform 0.2s;
  user-select: none;
}

.easter-egg-target:hover {
  filter: brightness(1.4) drop-shadow(0 0 6px var(--accent));
  transform: scale(1.08);
}

.easter-egg-popup {
  position: fixed;
  z-index: 9500;
  pointer-events: none;
  animation: eggPop 2.2s ease forwards;
}

@keyframes eggPop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.5) rotate(-10deg); }
  18%  { opacity: 1; transform: translate(-50%, -60%) scale(1.1) rotate(4deg); }
  60%  { opacity: 1; transform: translate(-50%, -80%) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(-50%, -110%) scale(0.9) rotate(2deg); }
}

.easter-egg-popup-inner {
  background: var(--bg-card);
  border: 1px solid rgba(0,240,255,0.3);
  border-radius: 10px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 0 24px rgba(0,240,255,0.18);
  white-space: nowrap;
}

.easter-egg-popup-icon { font-size: 1.2rem; }
.easter-egg-popup-label {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.easter-egg-popup-xp {
  font-family: var(--font-display);
  font-size: 0.7rem;
  color: #ffd700;
  font-weight: 700;
  margin-left: 4px;
}

/* Lore card modal */
.lore-card-overlay {
  position: fixed;
  inset: 0;
  z-index: 9800;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.25s ease;
}

.lore-card {
  background: linear-gradient(160deg, #0f0f2a 0%, #1a1a3e 100%);
  border: 1px solid rgba(0,240,255,0.25);
  border-radius: 14px;
  padding: 32px 28px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 0 60px rgba(0,240,255,0.15);
  animation: recapSlideUp 0.35s cubic-bezier(0.22, 0.9, 0.36, 1);
}

.lore-card-icon { font-size: 2.5rem; margin-bottom: 12px; }
.lore-card-title {
  font-family: var(--font-display);
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 4px;
}
.lore-card-headline {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--fg);
  margin-bottom: 14px;
}
.lore-card-body {
  font-size: 0.88rem;
  color: var(--fg-muted);
  line-height: 1.65;
  margin-bottom: 20px;
}
.lore-card-xp {
  display: inline-block;
  background: rgba(255,215,0,0.1);
  border: 1px solid rgba(255,215,0,0.25);
  color: #ffd700;
  font-family: var(--font-display);
  font-size: 0.8rem;
  padding: 5px 14px;
  border-radius: 20px;
  margin-bottom: 18px;
}
.btn-lore-close {
  background: var(--gradient-accent);
  border: none;
  border-radius: 8px;
  color: #000;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 10px 24px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-lore-close:hover { opacity: 0.85; }

/* ─── Scene Transition ────────────────────────────────────────────────────── */
.scene-transition-out {
  animation: sceneOut 0.22s ease forwards;
}
.scene-transition-in {
  animation: sceneIn 0.28s ease;
}

@keyframes sceneOut {
  to { opacity: 0; transform: translateX(-14px); }
}
@keyframes sceneIn {
  from { opacity: 0; transform: translateX(14px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ─── Correct/Wrong overlay flash ────────────────────────────────────────── */
.answer-flash-overlay {
  position: fixed;
  inset: 0;
  z-index: 8500;
  pointer-events: none;
  opacity: 0;
}

.answer-flash-overlay.flash-correct {
  background: rgba(0, 255, 136, 0.07);
  animation: flashBright 0.35s ease;
}

.answer-flash-overlay.flash-wrong {
  background: rgba(255, 60, 122, 0.08);
  animation: flashBright 0.35s ease;
}

@keyframes flashBright {
  0%   { opacity: 0; }
  30%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ─── Sound Hook Button States ────────────────────────────────────────────── */
.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--fg-dim);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s;
}
.sound-toggle:hover { color: var(--fg-muted); }
.sound-toggle.sound-on { color: var(--accent); }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 520px) {
  .mission-recap-card { padding: 28px 20px; }
  .recap-stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .recap-stat-value { font-size: 0.95rem; }
}
