/**
 * English Activity Styles — eng-activity.css
 * ───────────────────────────────────────────
 * Styles for the English activity shell: speak button states,
 * waveform visualiser, companion bubble, phase theming, and
 * child-state indicators.
 *
 * Based on english_implementation.md §11.
 *
 * File: public/english/eng-activity.css
 * Phase: 4 — Activity Shell
 */

/* ==========================================================================
   1. SPEAK BUTTON
   ========================================================================== */

/* Base — finger-friendly, always visible in speech phases */
.eng-speak-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: none;
  font-size: 2.4rem;
  cursor: pointer;
  transition: all 0.2s ease;
  margin: 1.5rem auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 10;
  color: #fff;
  outline: none;
}

.eng-speak-btn:focus-visible {
  outline: 3px solid #6366f1;
  outline-offset: 3px;
}

/* Idle — inviting green, pulsing gently */
.eng-speak-btn--idle {
  background: #10b981;
  animation: eng-pulse 2s infinite;
}

/* Listening — bright red, enlarged, ring */
.eng-speak-btn--listening {
  background: #ef4444;
  transform: scale(1.12);
  box-shadow:
    0 0 0 12px rgba(239, 68, 68, 0.25),
    0 4px 16px rgba(0, 0, 0, 0.18);
  animation: none;
}

/* Processing — neutral grey, spinner */
.eng-speak-btn--processing {
  background: #6b7280;
  animation: eng-spin 1s linear infinite;
  pointer-events: none;
}

/* Success — amber, bounce celebration */
.eng-speak-btn--success {
  background: #f59e0b;
  animation: eng-bounce 0.5s ease;
}

/* Loading — WASM models initialising; button disabled with pulse */
.eng-speak-btn--loading {
  background: #9ca3af;
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
  animation: eng-loading-pulse 1.5s ease-in-out infinite;
}

/* Hidden (for non-speech phases) */
.eng-speak-btn--hidden {
  display: none;
}

/* ==========================================================================
   2. KEYFRAMES
   ========================================================================== */

@keyframes eng-pulse {
  0%,
  100% {
    box-shadow:
      0 0 0 0 rgba(16, 185, 129, 0.4),
      0 4px 16px rgba(0, 0, 0, 0.18);
  }
  50% {
    box-shadow:
      0 0 0 10px rgba(16, 185, 129, 0),
      0 4px 16px rgba(0, 0, 0, 0.18);
  }
}

@keyframes eng-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes eng-loading-pulse {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 0.7;
  }
}

@keyframes eng-bounce {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.2);
  }
  70% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes eng-wave {
  0%,
  100% {
    height: 6px;
  }
  50% {
    height: 24px;
  }
}

@keyframes eng-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   3. WAVEFORM VISUALISER
   ========================================================================== */

.eng-waveform {
  display: none; /* shown via JS when listening */
  align-items: center;
  gap: 3px;
  height: 32px;
  margin: 0.5rem auto;
  justify-content: center;
}

.eng-waveform__bar {
  width: 4px;
  border-radius: 2px;
  background: #ef4444;
  animation: eng-wave 0.8s ease-in-out infinite;
  height: 6px;
}

.eng-waveform__bar:nth-child(2) {
  animation-delay: 0.1s;
}
.eng-waveform__bar:nth-child(3) {
  animation-delay: 0.2s;
}
.eng-waveform__bar:nth-child(4) {
  animation-delay: 0.3s;
}
.eng-waveform__bar:nth-child(5) {
  animation-delay: 0.2s;
}

/* ==========================================================================
   4. PHASE THEME COLOURS
   ========================================================================== */

.eng-phase--observe {
  --eng-accent: #f59e0b;
} /* warm amber  */
.eng-phase--listen {
  --eng-accent: #3b82f6;
} /* calm blue   */
.eng-phase--speak {
  --eng-accent: #10b981;
} /* active green */
.eng-phase--build {
  --eng-accent: #8b5cf6;
} /* explore purple */
.eng-phase--express {
  --eng-accent: #ef4444;
} /* celebrate red */

.eng-phase {
  border-top: 3px solid var(--eng-accent, #e5e7eb);
  padding-top: 0.75rem;
  margin-top: 0.5rem;
}

/* ==========================================================================
   5. COMPANION SPEECH BUBBLE
   ========================================================================== */

.eng-companion-bubble {
  background: #fffbeb;
  border: 2px solid var(--eng-accent, #f59e0b);
  border-radius: 1.5rem;
  padding: 0.75rem 1.25rem;
  font-size: 1.1rem;
  line-height: 1.6;
  max-width: 90%;
  margin: 0.75rem auto;
  text-align: center;
  display: none; /* shown via JS when AI speaks */
  animation: eng-fade-in 0.3s ease;
}

.eng-companion-bubble:not(:empty) {
  display: block;
}

/* ==========================================================================
   6. SUCCESS REINFORCEMENT (private, no scores)
   ========================================================================== */

.eng-success-private {
  background: #d1fae5;
  border-radius: 1rem;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  color: #065f46;
  text-align: center;
  margin: 0.5rem auto;
  max-width: 80%;
  display: none; /* shown via JS after child speaks */
  animation: eng-fade-in 0.3s ease;
}

/* ==========================================================================
   7. SCENE IMAGE (observe phase)
   ========================================================================== */

.eng-scene-image {
  text-align: center;
  margin: 0.75rem auto;
  max-width: 100%;
}

.eng-scene-image img {
  max-width: 100%;
  max-height: 240px;
  border-radius: 1rem;
  object-fit: cover;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

/* ==========================================================================
   8. TARGET PHRASE (listen-repeat phase)
   ========================================================================== */

.eng-target-phrase {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 600;
  color: #1e40af;
  background: #eff6ff;
  padding: 0.5rem 1rem;
  border-radius: 0.75rem;
  margin: 0.5rem auto;
  max-width: 80%;
}

/* ==========================================================================
   9. TTS OVERLAY (visual cue when AI is speaking)
   ========================================================================== */

.eng-tts-overlay {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--eng-accent, #3b82f6), transparent);
  animation: eng-tts-slide 1.5s ease-in-out infinite;
  z-index: 100;
  pointer-events: none;
}

@keyframes eng-tts-slide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* ==========================================================================
   10. CHILD STATE INDICATOR (dev only)
   ========================================================================== */

.eng-child-state-indicator {
  position: fixed;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  z-index: 200;
  font-family: monospace;
  pointer-events: none;
  display: none; /* enable via JS: element.style.display = 'block' */
}

/* ==========================================================================
   11. RESPONSIVE ADJUSTMENTS
   ========================================================================== */

/* Larger speak button on small touch screens */
@media (max-width: 480px) {
  .eng-speak-btn {
    width: 80px;
    height: 80px;
    font-size: 2rem;
  }

  .eng-companion-bubble {
    font-size: 1rem;
    padding: 0.5rem 0.75rem;
  }

  .eng-scene-image img {
    max-height: 180px;
  }
}

/* Tablet — slightly larger button for younger children */
@media (min-width: 481px) and (max-width: 1024px) {
  .eng-speak-btn {
    width: 96px;
    height: 96px;
    font-size: 2.6rem;
  }
}

/* Ensure speak button is accessible above fixed footers */
@media (max-height: 500px) {
  .eng-speak-btn {
    margin: 0.75rem auto;
  }
}

/* ==========================================================================
   12. DARK MODE SUPPORT (follows prefers-color-scheme)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
  .eng-companion-bubble {
    background: #1c1917;
    color: #fde68a;
    border-color: var(--eng-accent, #f59e0b);
  }

  .eng-success-private {
    background: #064e3b;
    color: #a7f3d0;
  }

  .eng-target-phrase {
    background: #1e3a5f;
    color: #93c5fd;
  }

  .eng-child-state-indicator {
    background: rgba(255, 255, 255, 0.15);
  }
}

/* ==========================================================================
   13. PRINT (hide interactive elements)
   ========================================================================== */

@media print {
  .eng-speak-btn,
  .eng-waveform,
  .eng-tts-overlay,
  .eng-child-state-indicator {
    display: none !important;
  }
}
