/* ==========================================================================
   BILIKIDS - UNIT 1: ALL ABOUT YOU (KIDS 7-10 AÑOS)
   ========================================================================== */

:root {
  --font-display: 'Fredoka', cursive, -apple-system, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #eef2ff;
  --secondary: #0ea5e9;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;

  --card-bg: #ffffff;
  --border-subtle: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --shadow-card: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 50%, #f1f5f9 100%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header & Tabs */
.unit-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 20px;
}

.unit-nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.btn-back-map {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  color: #334155;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  transition: all 0.2s;
}

.btn-back-map:hover {
  background: #e2e8f0;
  color: #0f172a;
  transform: translateX(-2px);
}

.unit-title-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.unit-tag-pill {
  background: #ede9fe;
  color: #7c3aed;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}

.unit-name-head {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: #0f172a;
}

.unit-score-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fef3c7;
  color: #92400e;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid #fde68a;
}

/* Tabs Bar */
.activity-tabs-bar {
  max-width: 1100px;
  margin: 18px auto 8px;
  padding: 0 20px;
  width: 100%;
}

.tabs-track {
  display: flex;
  gap: 8px;
  background: #ffffff;
  padding: 6px;
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
  overflow-x: auto;
}

.tab-btn {
  flex: 1;
  min-width: 140px;
  border: none;
  background: transparent;
  padding: 10px 14px;
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.tab-btn:hover {
  background: #f8fafc;
  color: #0f172a;
}

.tab-btn.active {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Main Content Views */
.unit-workspace {
  max-width: 1100px;
  margin: 12px auto 40px;
  padding: 0 20px;
  width: 100%;
}

.activity-view {
  display: none;
  animation: fadeIn 0.3s ease;
}

.activity-view.active-view {
  display: block;
}

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

/* --------------------------------------------------------------------------
   ACTIVIDAD 1: DIÁLOGO INTERACTIVO (ESCENARIOS DE LA VIDA REAL)
   -------------------------------------------------------------------------- */
.story-container {
  background: #ffffff;
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-subtle);
  max-width: 900px;
  margin: 0 auto;
}

/* Selector de Escenarios */
.scenarios-selector-wrap {
  margin-bottom: 20px;
  background: #f8fafc;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid #e2e8f0;
}

.scenarios-label {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.scenarios-chips-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}

.scenario-chip-btn {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 8px 14px;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.scenario-chip-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.scenario-chip-btn.active {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.story-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #f1f5f9;
  flex-wrap: wrap;
  gap: 12px;
}

.story-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.story-badge {
  background: #ede9fe;
  color: #7c3aed;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 8px;
}

.story-heading {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: #0f172a;
}

.story-progress-track {
  width: 140px;
  height: 8px;
  background: #f1f5f9;
  border-radius: 999px;
  overflow: hidden;
}

.story-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #10b981);
  width: 10%;
  transition: width 0.3s ease;
}

/* Área de conversación / Chat interactivo */
.story-chat-flow {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 240px;
  max-height: 480px;
  overflow-y: auto;
  padding: 14px;
  background: #fdfefe;
  border: 1px solid #f1f5f9;
  border-radius: 18px;
  margin-bottom: 18px;
  scroll-behavior: smooth;
}

.chat-bubble-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  animation: slideInChat 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-bubble-row.from-maya {
  flex-direction: row-reverse;
}

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

.character-avatar-bubble {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  background: #ede9fe;
  box-shadow: 0 4px 10px rgba(0,0,0,0.06);
  flex-shrink: 0;
  position: relative;
}

.character-avatar-bubble.maya {
  background: #fce7f3;
}
.character-avatar-bubble.clerk {
  background: #fef3c7;
}

.character-avatar-bubble.talking {
  animation: pulseAvatar 1s infinite;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.25);
}

@keyframes pulseAvatar {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.chat-message-bubble {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  padding: 12px 16px;
  max-width: 80%;
  position: relative;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
}

.from-alex .chat-message-bubble {
  border-top-left-radius: 4px;
  background: #f8fafc;
  border-color: #cbd5e1;
}

.from-maya .chat-message-bubble {
  border-top-right-radius: 4px;
  background: #faf5ff;
  border-color: #d8b4fe;
}

.from-clerk .chat-message-bubble {
  border-top-left-radius: 4px;
  background: #fffbeb;
  border-color: #fde68a;
}

.chat-sender-name {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  color: #6366f1;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.from-maya .chat-sender-name {
  color: #db2777;
}
.from-clerk .chat-sender-name {
  color: #b45309;
}

.chat-text-en {
  font-size: 1.02rem;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.4;
  margin-bottom: 3px;
}

.chat-text-es {
  font-size: 0.8rem;
  color: #64748b;
  font-style: italic;
}

.chat-listen-btn {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.72rem;
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}

.chat-listen-btn:hover {
  background: #ede9fe;
  color: #6d28d9;
}

/* Caja de Decisión / Quiz para el Alumno */
.story-prompt-card {
  background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 100%);
  border: 2px solid #86efac;
  border-radius: 18px;
  padding: 16px;
  animation: slideInChat 0.25s ease;
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.08);
}

.prompt-badge {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: #15803d;
  background: #dcfce7;
  padding: 3px 10px;
  border-radius: 999px;
  display: inline-block;
  margin-bottom: 6px;
}

.prompt-question {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: #0f172a;
  margin-bottom: 12px;
}

.prompt-options-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prompt-option-btn {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 14px;
  text-align: left;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: #1e293b;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.prompt-option-btn:hover {
  border-color: #6366f1;
  background: #f5f3ff;
  transform: translateX(4px);
}

.prompt-option-btn.correct-choice {
  border-color: #10b981;
  background: #ecfdf5;
  color: #065f46;
}

.prompt-option-btn.wrong-choice {
  border-color: #ef4444;
  background: #fef2f2;
  color: #991b1b;
  animation: shakeBtn 0.3s;
}

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

/* Pantalla Final de la Historia */
.story-completed-box {
  text-align: center;
  padding: 28px 18px;
  background: linear-gradient(180deg, #faf5ff 0%, #ffffff 100%);
  border: 2px solid #e9d5ff;
  border-radius: 18px;
}

.story-complete-icon {
  font-size: 3rem;
  margin-bottom: 8px;
}

.story-complete-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: #0f172a;
  margin-bottom: 6px;
}

.story-complete-desc {
  font-size: 0.92rem;
  color: #64748b;
  margin-bottom: 20px;
}

.story-actions-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   ACTIVIDAD 2: WORD EXPLORER (VOCABULARIO CLAVE)
   -------------------------------------------------------------------------- */
.words-container {
  background: #ffffff;
  border-radius: 24px;
  padding: 28px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-subtle);
}

.category-filter-chips {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.category-chip {
  border: 1px solid var(--border-subtle);
  background: #f8fafc;
  padding: 6px 14px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s;
}

.category-chip.active {
  background: #ede9fe;
  border-color: #8b5cf6;
  color: #6b21a8;
}

.words-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

@media (max-width: 900px) {
  .words-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .words-grid { grid-template-columns: repeat(2, 1fr); }
}

.word-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.word-card:hover {
  transform: translateY(-4px);
  background: #ffffff;
  border-color: #6366f1;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.12);
}

.word-card:active {
  transform: scale(0.98);
}

.word-icon {
  font-size: 2.2rem;
  margin-bottom: 6px;
}

.word-english {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 2px;
}

.word-ipa {
  font-size: 0.75rem;
  color: #6366f1;
  font-family: monospace;
  margin-bottom: 4px;
}

.word-spanish {
  font-size: 0.82rem;
  color: #64748b;
}

.word-audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #4f46e5;
  background: #eef2ff;
  padding: 4px 10px;
  border-radius: 999px;
  margin-top: 8px;
}

/* --------------------------------------------------------------------------
   ACTIVIDAD 3: SENTENCE BUILDER (GRAMMAR LAB)
   -------------------------------------------------------------------------- */
.sentence-builder-box {
  background: #ffffff;
  border-radius: 24px;
  padding: 32px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-subtle);
  text-align: center;
}

.challenge-counter {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 700;
  color: #6366f1;
  background: #eef2ff;
  padding: 4px 12px;
  border-radius: 999px;
  display: inline-block;
  margin-bottom: 12px;
}

.prompt-translation {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 8px;
}

.grammar-tip {
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 24px;
}

/* Área de Construcción */
.dropzone-target {
  min-height: 72px;
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  border-radius: 18px;
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
  transition: all 0.2s;
}

.dropzone-target.correct {
  border-color: #10b981;
  background: #ecfdf5;
}

.dropzone-target.error {
  border-color: #ef4444;
  background: #fef2f2;
}

/* Banco de palabras */
.word-bank {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
  min-height: 52px;
}

.word-tile {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  padding: 10px 18px;
  background: #ffffff;
  color: #0f172a;
  border: 2px solid #e2e8f0;
  border-bottom: 4px solid #cbd5e1;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.word-tile:hover {
  transform: translateY(-2px);
  border-color: #818cf8;
  border-bottom-color: #6366f1;
}

.word-tile:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}

.word-tile.placed {
  opacity: 0.35;
  pointer-events: none;
  border-style: dashed;
}

.builder-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.btn-builder {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-builder-reset {
  background: #f1f5f9;
  color: #475569;
}
.btn-builder-reset:hover {
  background: #e2e8f0;
}

.btn-builder-check {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}
.btn-builder-check:hover {
  transform: scale(1.02);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.45);
}

.btn-builder-next {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #ffffff;
  display: none;
}

/* --------------------------------------------------------------------------
   ACTIVIDAD 4: SPEAKING QUEST (RECONOCIMIENTO Y VOZ)
   -------------------------------------------------------------------------- */
.speaking-container {
  background: #ffffff;
  border-radius: 24px;
  padding: 32px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-subtle);
  text-align: center;
}

.speaking-card {
  max-width: 600px;
  margin: 0 auto;
}

.speaking-target-phrase {
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: #0f172a;
  margin: 16px 0 6px;
}

.speaking-spanish-hint {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.listen-sample-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 9px 20px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
  transition: all 0.2s;
}

.listen-sample-btn:hover {
  background: #e2e8f0;
}

.mic-action-box {
  margin: 20px 0;
}

.btn-record-mic {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #ffffff;
  font-size: 2.2rem;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-record-mic:hover {
  transform: scale(1.06);
  box-shadow: 0 12px 28px rgba(99, 102, 241, 0.5);
}

.btn-record-mic.recording {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 0 0 10px rgba(239, 68, 68, 0.25);
  animation: pulseMic 1.2s infinite;
}

@keyframes pulseMic {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { transform: scale(1.08); box-shadow: 0 0 0 16px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.speaking-feedback-area {
  min-height: 60px;
  margin-top: 18px;
}

.speech-result-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: #0f172a;
}

.speech-score-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 16px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
}
