/*
 * Learning Mode Styles
 * Clean, child-friendly interface for letter/number/shape tracing
 */

/* Learning Picker Screen */
.learn-picker {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(253, 121, 168, 0.25) 0%, transparent 70%),
    linear-gradient(145deg, #6C5CE7 0%, #A29BFE 45%, #FD79A8 100%);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 5000;
  padding: calc(60px + env(safe-area-inset-top, 0px)) 20px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.learn-picker-content {
  text-align: center;
  max-width: 600px;
  width: 100%;
}

.learn-title {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--color-text-light);
  margin: 0 0 8px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  animation: titleDrop 0.5s var(--ease-out-back) forwards;
}

.learn-subtitle {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  margin: 0 0 32px;
}

/* Learning Cards */
.learn-cards {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.learn-card {
  background: var(--color-card-bg);
  border: none;
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  min-width: 160px;
  flex: 1;
  max-width: 200px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-card);
  border-bottom: 4px solid rgba(0, 0, 0, 0.08);
  transition:
    transform 0.15s var(--ease-out-smooth),
    box-shadow 0.15s ease,
    border-bottom-width 0.1s ease;
}

@media (hover: hover) {
  .learn-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-card-hover);
  }
}

.learn-card:active {
  transform: translateY(2px);
  border-bottom-width: 1px;
  box-shadow: var(--shadow-card-active);
  transition-duration: 0.05s;
}

.learn-card-emoji {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--color-brand);
  line-height: 1;
}

.learn-card[data-category="numbers"] .learn-card-emoji {
  color: var(--color-accent-warm);
}

.learn-card[data-category="shapes"] .learn-card-emoji {
  color: var(--color-accent);
}

.learn-card-name {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--color-text-dark);
}

.learn-card-desc {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* Tracking toggle */
.learn-tracking-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.learn-toggle-label {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.95rem;
  font-weight: 500;
}

.learn-select {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 0.95rem;
  cursor: pointer;
}

.learn-select option {
  color: #1e293b;
  background: #fff;
}

/* Settings button */
.learn-settings-btn {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 8px 20px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

.learn-settings-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* Learning HUD */
.learn-hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  pointer-events: none;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 0;
}

.learn-hud-top {
  display: flex;
  align-items: center;
  gap: 16px;
  pointer-events: auto;
}

.learn-exit-btn {
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.learn-exit-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

.learn-hud-info {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 10px 18px;
  flex: 1;
  min-width: 0;
}

.learn-current-item {
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

/* Level Badge — seeded mastery level for the session */
.learn-level-badge {
  font-size: 0.9rem;
  font-weight: 700;
  color: #a5f3fc;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Coin Counter */
.learn-coin-counter {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 10px 16px;
  pointer-events: auto;
  flex-shrink: 0;
}

.learn-coin-icon {
  font-size: 1.2rem;
  color: #fbbf24;
}

.learn-coin-count {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fbbf24;
}

/* Progress Dots */
.learn-progress-dots {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.learn-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transition: background 0.3s, transform 0.3s;
}

.learn-dot.done {
  background: #4ade80;
  transform: scale(1.1);
}

.learn-dot.current {
  background: #fbbf24;
  animation: dotPulse 1.2s ease-in-out infinite;
}

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

/* Encouragement text */
.learn-encouragement {
  pointer-events: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  animation: encouragePop 1.2s ease forwards;
  z-index: 200;
}

@keyframes encouragePop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  40% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(1); }
}

/* Completion Screen */
.learn-complete {
  position: fixed;
  inset: 0;
  background: linear-gradient(145deg, #6C5CE7 0%, #A29BFE 45%, #FD79A8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5500;
  animation: fadeIn 0.4s ease;
}

.learn-complete-content {
  text-align: center;
  padding: 40px;
}

.learn-complete-stars {
  font-size: 3rem;
  color: #fbbf24;
  margin-bottom: 16px;
  animation: starsIn 0.6s ease;
}

@keyframes starsIn {
  0% { transform: scale(0) rotate(-45deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.learn-complete-title {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--color-text-light);
  margin: 0 0 12px;
}

.learn-complete-message {
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.85);
  margin: 0 0 32px;
}

.learn-complete-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.learn-complete-btn {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 14px;
  padding: 14px 32px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.learn-complete-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.learn-complete-btn.primary {
  background: #fff;
  color: #667eea;
  border-color: #fff;
}

.learn-complete-btn.primary:hover {
  background: #f0f0ff;
}

/* Session Results */
.learn-session-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 10px;
  max-width: 400px;
  margin: 0 auto 24px;
}

.learn-result-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 12px 8px;
}

.learn-result-letter {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
}

.learn-result-stars {
  font-size: 1.2rem;
  color: #fbbf24;
  letter-spacing: 2px;
}

/* Mobile responsive */
@media (max-width: 480px) {
  .learn-title {
    font-size: 2rem;
  }

  .learn-cards {
    flex-direction: column;
    align-items: center;
  }

  .learn-card {
    max-width: 100%;
    width: 100%;
    flex-direction: row;
    padding: 20px 24px;
    gap: 16px;
    text-align: left;
  }

  .learn-card-emoji {
    font-size: 1.8rem;
    min-width: 48px;
    text-align: center;
  }

  .learn-card-name {
    font-size: 1.1rem;
  }

  .learn-card-desc {
    font-size: 0.8rem;
  }

  .learn-complete-title {
    font-size: 2rem;
  }
}

/* Picker action buttons row */
.learn-picker-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* Progress Dashboard */
.learn-dashboard {
  position: fixed;
  inset: 0;
  background: linear-gradient(145deg, #6C5CE7 0%, #A29BFE 45%, #FD79A8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  padding: 20px;
  padding-top: calc(20px + env(safe-area-inset-top, 0px));
}

.learn-dashboard-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
}

.dash-tab {
  padding: 8px 20px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.dash-tab.active {
  background: rgba(100, 200, 255, 0.3);
  border-color: rgba(100, 200, 255, 0.6);
}

.learn-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 500px;
  margin: 0 auto 20px;
}

.dash-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  transition: background 0.2s;
}

.dash-cell.not-started { background: rgba(255, 255, 255, 0.05); }
.dash-cell.attempted { background: rgba(251, 191, 36, 0.15); }
.dash-cell.mastered { background: rgba(74, 222, 128, 0.2); }

.dash-cell-letter {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
}

.dash-cell-stars {
  font-size: 0.8rem;
  color: #fbbf24;
}

.learn-dashboard-stats {
  display: flex;
  gap: 8px;
  justify-content: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.learn-progress-btn {
  padding: 8px 20px;
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

.learn-progress-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* Settings row toggle */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.setting-hint {
  display: block;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 2px;
}

.setting-toggle {
  width: 44px;
  height: 24px;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

.setting-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.setting-toggle:checked {
  background: rgba(74, 222, 128, 0.6);
}

.setting-toggle:checked::after {
  transform: translateX(20px);
}

/* Camera Permission Overlay (learn)
   .camera-permission in ui.css only carries background/blur/flex — on
   index.html the fixed inset-0 positioning comes from .screen-overlay,
   whose visibility is driven by an .active class learn.ts never toggles
   (learn only flips .hidden). The overlay used to borrow its screen
   coverage from being nested inside the fixed .learn-picker; now that it
   lives at body level (so the group-picker flow can't hide its parent),
   it needs its own positioning. Above the pickers (5000), below the
   parental gate (6000). */
#learnCameraPermission {
  position: fixed;
  inset: 0;
  z-index: 5600;
}

/* Group Picker */
.learn-group-picker {
  position: fixed;
  inset: 0;
  background: linear-gradient(145deg, #6C5CE7 0%, #A29BFE 45%, #FD79A8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  padding: 20px;
  padding-top: calc(20px + env(safe-area-inset-top, 0px));
}

.learn-section-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 900;
  color: var(--color-text-light);
  margin: 0 0 24px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.learn-group-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto 24px;
}

.learn-group-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
  color: #fff;
}

.learn-group-card:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(100, 200, 255, 0.5);
  transform: translateY(-2px);
}

.learn-group-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.learn-group-card .group-name {
  font-size: 1.1rem;
  font-weight: 700;
}

.learn-group-card .group-letters {
  font-size: 1.3rem;
  letter-spacing: 4px;
  color: rgba(255, 255, 255, 0.7);
}

.learn-group-card .group-progress {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
}

.learn-back-btn {
  margin-top: 12px;
  padding: 10px 24px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.2s;
}

.learn-back-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Hide game elements not needed in learn mode */
.learn-picker .game-grid,
.learn-picker .control-panel,
.learn-picker .character-builder,
.learn-picker .power-bar {
  display: none;
}
