/* ==========================================================================
   LIMACE - Design System for Dyslexia Accessibility
   Version: 1.0.0

   This CSS implements WCAG AAA accessibility standards specifically
   optimized for users with dyslexia. All design decisions prioritize
   readability and cognitive load reduction.

   FR37-40: Dyslexia accessibility requirements
   NFR10-18: Non-functional accessibility requirements
   ========================================================================== */

/* ==========================================================================
   1. CSS Variables (Design Tokens)
   All values are based on UX Design Specification and PRD requirements
   ========================================================================== */
:root {
  /* Colors - NFR14, NFR15 */
  --color-bg: #FFF8E7;           /* Cream background for dyslexia (FR38) */
  --color-bg-card: #FFFFFF;      /* White cards for contrast */
  --color-white: #FFFFFF;        /* Pure white for button text */
  --color-text: #212121;         /* Dark text - 12.6:1 contrast ratio */
  --color-text-muted: #666666;   /* Secondary text */
  --color-success: #4CAF50;      /* Positive feedback (FR35) */
  --color-success-light: rgba(76, 175, 80, 0.3);  /* Success with opacity for feedback */
  --color-success-subtle: rgba(76, 175, 80, 0.1); /* Success very light for backgrounds */
  --color-accent: #2196F3;       /* Action buttons */
  --color-accent-hover: #1976D2; /* Accent hover state */
  --color-progress-track: rgba(0, 0, 0, 0.1); /* Progress bar background track */

  /* Typography - FR37, NFR10, NFR11, NFR12, NFR13 */
  --font-family: 'OpenDyslexic', sans-serif;
  --font-size-base: 24px;        /* NFR11: >= 24px */
  --font-size-lg: 32px;          /* Titles */
  --font-size-xl: 48px;          /* Ticket checkmark */
  --line-height: 1.8;            /* NFR12: 1.8 interlignage */
  --letter-spacing: 0.12em;      /* NFR13: +12% letter spacing */

  /* Spacing */
  --spacing-xs: 8px;
  --spacing-sm: 16px;
  --spacing-md: 24px;
  --spacing-lg: 32px;
  --spacing-xl: 48px;

  /* Interactive - NFR18 */
  --tap-target: 64px;            /* Touch target minimum */
  --focus-outline: 3px solid var(--color-accent);

  /* Border Radius */
  --border-radius-sm: 6px;       /* Small elements (progress bar) */
  --border-radius-md: 8px;       /* Buttons */
  --border-radius-lg: 12px;      /* Cards */

  /* Animation */
  --transition-fast: 200ms ease;
  --transition-feedback: 300ms ease;
}

/* ==========================================================================
   2. Font Face Declarations
   Self-hosted for offline-first (FR41)
   ========================================================================== */
@font-face {
  font-family: 'OpenDyslexic';
  src: url('/static/fonts/OpenDyslexic-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap; /* Prevents FOIT */
}

@font-face {
  font-family: 'OpenDyslexic';
  src: url('/static/fonts/OpenDyslexic-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ==========================================================================
   3. CSS Reset
   Minimal reset for consistent cross-browser rendering
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ==========================================================================
   4. Base Styles
   Dyslexia-optimized typography defaults
   ========================================================================== */
html {
  font-size: var(--font-size-base);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  font-size: 1rem;
  line-height: var(--line-height);
  letter-spacing: var(--letter-spacing);
  color: var(--color-text);
  background-color: var(--color-bg);
  text-align: left; /* NFR16: Never justify - always left align */
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height for mobile */
  display: flex;
  flex-direction: column;
}

/* Ensure all text inherits dyslexia-friendly styles */
h1, h2, h3, h4, h5, h6 {
  font-family: inherit;
  line-height: var(--line-height);
  letter-spacing: var(--letter-spacing);
  text-align: left;
}

h1 {
  font-size: var(--font-size-xl);
  font-weight: 700;
}

h2 {
  font-size: var(--font-size-lg);
  font-weight: 700;
}

p {
  margin-bottom: var(--spacing-md);
}

/* Links */
a {
  color: var(--color-accent);
  text-decoration: underline;
}

a:hover {
  text-decoration: none;
}

/* ==========================================================================
   5. Button Components
   FR39: Single action button per screen
   NFR18: 64px minimum touch target
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-target);
  padding: var(--spacing-sm) var(--spacing-md);
  font-family: inherit;
  font-size: inherit;
  line-height: var(--line-height);
  letter-spacing: var(--letter-spacing);
  text-align: center;
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: background-color var(--transition-fast),
              border-color var(--transition-fast),
              transform var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.98);
}

.btn:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

/* Primary button - main action */
.btn-primary {
  width: 100%;
  background-color: var(--color-accent);
  color: var(--color-white);
  font-weight: 700;
}

.btn-primary:hover {
  background-color: var(--color-accent-hover);
}

/* Response button - exercise answers */
.btn-response {
  width: 100%;
  background-color: var(--color-bg-card);
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

.btn-response:hover {
  border-color: var(--color-accent);
}

/* Ghost button - secondary actions */
.btn-ghost {
  background-color: transparent;
  color: var(--color-text);
  border-color: transparent;
}

.btn-ghost:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

/* ==========================================================================
   6. Card Component
   Exercise cards with white background for contrast
   ========================================================================== */
.card {
  background-color: var(--color-bg-card);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-lg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.card-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-md);
}

/* ==========================================================================
   7. Progress Bar
   FR6: Visual progress gauge
   ========================================================================== */
.progress-bar {
  width: 100%;
  height: 12px;
  background-color: rgba(0, 0, 0, 0.1);
  border-radius: var(--border-radius-sm);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background-color: var(--color-success);
  border-radius: var(--border-radius-sm);
  transition: width var(--transition-fast);
}

/* Accessible progress bar with ARIA support */
.progress-bar[role="progressbar"] {
  position: relative;
}

/* ==========================================================================
   8. Feedback Animations
   FR35: Positive feedback on correct answers
   FR36: Show correct answer on errors (no negative sound)
   ========================================================================== */

/* Correct answer - subtle green flash (300ms) */
.feedback-correct {
  animation: flash-green var(--transition-feedback) ease;
}

@keyframes flash-green {
  0%, 100% {
    background-color: transparent;
  }
  50% {
    background-color: var(--color-success-light);
  }
}

/* Show correct answer - highlight the right option */
/* Note: !important needed to override .btn-response border styles */
.feedback-show-answer {
  border-color: var(--color-success) !important;
  background-color: var(--color-success-subtle) !important;
}

/* Fade transition between exercises */
.fade-enter {
  opacity: 0;
}

.fade-enter-active {
  opacity: 1;
  transition: opacity var(--transition-fast);
}

.fade-exit {
  opacity: 1;
}

.fade-exit-active {
  opacity: 0;
  transition: opacity var(--transition-fast);
}

/* ==========================================================================
   9. Accessibility
   WCAG AAA compliance for dyslexia
   ========================================================================== */

/* Focus visible for all interactive elements */
:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

/* Remove default focus outline, rely on focus-visible */
:focus:not(:focus-visible) {
  outline: none;
}

/* Skip link for keyboard navigation */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  z-index: 1000;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--color-accent);
  color: var(--color-white);
  text-decoration: none;
  font-weight: 700;
}

.skip-link:focus {
  top: 0;
}

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   10. Layout
   Mobile-first, centered content
   ========================================================================== */
.container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: var(--spacing-md);
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: var(--spacing-md);
}

.main-content:has(.ticket-screen) {
  align-items: stretch;
  justify-content: flex-start;
  padding: var(--spacing-sm);
}

/* Center content vertically */
.center-vertical {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100%;
}

/* Stack children with gap */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.stack-lg {
  gap: var(--spacing-lg);
}

/* ==========================================================================
   11. Ticket Screen (Completion)
   FR7: Clear completion screen with checkmark
   ========================================================================== */
.ticket-screen {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  text-align: left;
  width: 100%;
  letter-spacing: normal;
}

.ticket-checkmark {
  font-size: 4rem;
  color: var(--color-success);
  margin-bottom: var(--spacing-sm);
}

.ticket-date {
  font-size: var(--font-size-lg);
  color: var(--color-text);
  margin-bottom: var(--spacing-sm);
}

.summary-container {
  margin-top: var(--spacing-md);
}

.summary-text {
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
  margin: var(--spacing-xs) 0;
}

.streak-text {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-accent);
}

/* ==========================================================================
   12. Utility Classes
   ========================================================================== */

/* Text utilities */
.text-center {
  text-align: center;
}

.text-muted {
  color: var(--color-text-muted);
}

.text-success {
  color: var(--color-success);
}

.text-lg {
  font-size: var(--font-size-lg);
}

.text-xl {
  font-size: var(--font-size-xl);
}

/* Spacing utilities */
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }

/* Display utilities */
.hidden {
  display: none !important;
}

.visible {
  display: block !important;
}

/* ==========================================================================
   13. Onboarding Styles
   FR2: Profile creation in 30 seconds
   FR39: Single field per screen
   ========================================================================== */

/* Onboarding step container */
.onboarding-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-lg);
  width: 100%;
  max-width: 400px;
}

.onboarding-step.hidden {
  display: none;
}

/* Onboarding label */
.onboarding-label {
  font-size: var(--font-size-lg);
  font-weight: 700;
  text-align: center;
  line-height: var(--line-height);
  letter-spacing: var(--letter-spacing);
}

/* Dyslexia-friendly input field */
.input-dyslexia {
  width: 100%;
  min-height: var(--tap-target);
  padding: var(--spacing-sm) var(--spacing-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  letter-spacing: var(--letter-spacing);
  border: 2px solid var(--color-text-muted);
  border-radius: var(--border-radius-md);
  background-color: var(--color-bg-card);
  color: var(--color-text);
  text-align: left;
}

.input-dyslexia::placeholder {
  color: var(--color-text-muted);
  opacity: 0.7;
}

.input-dyslexia:focus {
  outline: var(--focus-outline);
  outline-offset: 2px;
  border-color: var(--color-accent);
}

/* Input error state for validation feedback */
.input-dyslexia.input-error {
  border-color: #E53935;
  animation: shake 0.3s ease;
}

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

/* Grade level buttons container */
.grade-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  width: 100%;
}

/* Grade selection button */
.btn-grade {
  width: 100%;
  min-height: var(--tap-target);
  background-color: var(--color-bg-card);
  color: var(--color-text);
  border: 2px solid var(--color-text-muted);
  font-size: var(--font-size-base);
  font-weight: 700;
}

.btn-grade:hover,
.btn-grade:focus {
  border-color: var(--color-accent);
  background-color: var(--color-accent);
  color: var(--color-white);
}

/* ==========================================================================
   14. Journey Page Styles (Story 2.2)
   ========================================================================== */

.journey-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height for mobile */
  padding: var(--spacing-sm);
  padding-bottom: var(--spacing-lg);
  text-align: center;
  overflow-y: auto;
  box-sizing: border-box;
}

/* Welcome message - hidden when exercise is active */
.journey-welcome {
  font-size: 2rem;
  color: var(--color-text);
  margin-bottom: var(--spacing-md);
}

/* Hide welcome when exercise card is visible */
.journey-container:has(.exercise-card) .journey-welcome {
  display: none;
}

.journey-message {
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
}

.journey-complete-message {
  font-size: var(--font-size-lg);
  color: var(--color-text);
  margin-bottom: var(--spacing-lg);
}

/* ==========================================================================
   15. Exercise Styles (Story 3.1)
   FR5: Daily journey with 4 stages
   FR35: Positive feedback on correct answers
   ========================================================================== */

.exercise-container {
  width: 100%;
  max-width: 500px;
}

/* Exercise card - white background for contrast */
.exercise-card {
  background-color: var(--color-bg-card);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-sm);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
  text-align: center;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Stage indicator */
.exercise-stage {
  font-size: 1rem;
  color: var(--color-text-muted);
  margin-bottom: 0;
}

/* Exercise content - main text */
.exercise-content {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--color-text);
  line-height: var(--line-height);
  letter-spacing: var(--letter-spacing);
  margin-bottom: 0;
}

/* Options container */
.exercise-options {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  width: 100%;
  margin-top: var(--spacing-sm);
}

/* Response button - 64px touch target */
.response-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--tap-target);
  padding: var(--spacing-sm) var(--spacing-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: 700;
  line-height: var(--line-height);
  letter-spacing: var(--letter-spacing);
  color: var(--color-text);
  background-color: var(--color-bg-card);
  border: 2px solid var(--color-text-muted);
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: border-color var(--transition-fast),
              background-color var(--transition-fast),
              transform var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.response-btn:hover {
  border-color: var(--color-accent);
}

.response-btn:active {
  transform: scale(0.98);
}

.response-btn:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

.response-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Selected response - brief feedback highlight */
.response-selected {
  border-color: var(--color-accent);
  background-color: rgba(33, 150, 243, 0.1);
}

/* Correct response - flash vert subtil (300ms) FR35 */
.response-correct {
  border-color: var(--color-success);
  background-color: var(--color-success-light);
  transition: background-color var(--transition-feedback);
}

/* Reveal correct answer after incorrect response FR36 */
.response-correct-reveal {
  border-color: var(--color-success);
  background-color: var(--color-success-subtle);
}

/* Incorrect response - neutral state (no red, no punishment) */
.response-incorrect {
  opacity: 0.7;
}

/* Respect prefers-reduced-motion for feedback animations */
@media (prefers-reduced-motion: reduce) {
  .response-correct,
  .response-correct-reveal {
    transition: none;
  }
}

/* Progress indicator */
.exercise-progress {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: 0;
  margin-top: var(--spacing-sm);
}

/* Fade animation for exercise transitions (200ms per UX spec) */
.exercise-fade {
  opacity: 0;
  transition: opacity 200ms ease;
}

.exercise-visible {
  opacity: 1;
}

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .exercise-fade {
    opacity: 1;
    transition: none;
  }
}

/* ==========================================================================
   16. Progress Bar Styles (Story 3.2)
   FR6: Visual progress gauge for daily journey
   ========================================================================== */

/* Progress bar container - track */
.progress-bar {
  width: 100%;
  max-width: 500px;
  height: 12px;
  background-color: var(--color-progress-track);
  border-radius: var(--border-radius-md);
  overflow: hidden;
  margin-bottom: var(--spacing-md);
}

/* Progress bar fill - the green bar that grows */
.progress-fill {
  height: 100%;
  width: 0%;
  background-color: var(--color-success);
  border-radius: var(--border-radius-md);
  transition: width 300ms ease-out;
}

/* Respect prefers-reduced-motion for progress animation */
@media (prefers-reduced-motion: reduce) {
  .progress-fill {
    transition: none;
  }
}

/* ==========================================================================
   17. Responsive Design
   iPad landscape priority (768x1024+)
   ========================================================================== */

/* Tablet (iPad) */
@media (min-width: 768px) {
  :root {
    /* Maintain 24px for tablet - dyslexia needs consistent sizing */
    --font-size-base: 24px;
  }

  .container {
    max-width: 700px;
  }

  .card {
    padding: var(--spacing-xl);
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .container {
    max-width: 800px;
  }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 500px) {
  .main-content {
    padding: var(--spacing-sm);
  }

  .card {
    padding: var(--spacing-md);
  }
}

/* ==========================================================================
   18. Grapheme Presentation Styles (Story 4.2)
   FR10: Multisensory grapheme presentation
   FR11: Audio phoneme playback
   ========================================================================== */

/* Grapheme card - container for presentation */
.grapheme-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-lg);
  padding: var(--spacing-xl);
  background: var(--color-bg-card);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px;
}

/* Grapheme display - large, tappable (AC #1: 48px+, AC #3: 64px touch target) */
/* CRITICAL FR10: font-size MUST be >= 48px for dyslexia accessibility - DO NOT REDUCE */
.grapheme-display {
  font-family: var(--font-family);
  font-size: var(--font-size-xl);  /* 48px minimum - FR10 requirement */
  font-weight: 700;
  color: var(--color-text);
  background: transparent;
  border: 3px solid var(--color-accent);
  border-radius: var(--border-radius-lg);
  cursor: pointer;
  min-width: var(--tap-target);  /* 64px - touch target */
  min-height: var(--tap-target);
  padding: var(--spacing-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast),
              border-color var(--transition-fast),
              transform var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.grapheme-display:hover {
  background-color: rgba(33, 150, 243, 0.1);
  border-color: var(--color-accent-hover);
}

.grapheme-display:active {
  transform: scale(0.98);
  background-color: rgba(33, 150, 243, 0.2);
}

.grapheme-display:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

/* Mnemonic image - sized and centered */
.mnemonic-image {
  max-width: 200px;
  max-height: 200px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--border-radius-md);
}

/* Mnemonic emoji display */
.mnemonic-emoji {
  font-size: 5rem;
  line-height: 1;
  padding: var(--spacing-md);
  background-color: var(--color-bg);
  border-radius: var(--border-radius-lg);
}

/* Example word text */
.grapheme-example {
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
  margin: 0;
}

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .grapheme-display {
    transition: none;
  }
}

/* ==========================================================================
   19. Auditory Discrimination Styles (Story 4.3)
   FR12: Auditory discrimination exercise
   Child hears phoneme and selects matching grapheme from 3-4 options
   ========================================================================== */

/* Discrimination container - vertical layout */
.discrimination-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-lg);
  padding: var(--spacing-md);
  width: 100%;
}

/* Audio replay button - circular speaker icon (AC #4) */
.audio-replay-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--color-accent);
  color: var(--color-white);
  font-size: 32px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast),
              background-color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.audio-replay-btn:hover {
  transform: scale(1.05);
  background-color: var(--color-accent-hover);
}

.audio-replay-btn:active {
  transform: scale(0.95);
}

.audio-replay-btn:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

.audio-replay-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Options grid - 2x2 layout for 4 options (AC #1) */
.discrimination-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-lg);
  width: 100%;
  max-width: 400px;
}

/* Grapheme option button - large, tappable (AC #1: 64px touch target) */
.grapheme-option-btn {
  /* FR12: Touch target minimum 64px */
  min-width: var(--tap-target);
  min-height: var(--tap-target);
  padding: var(--spacing-lg);

  font-family: var(--font-family);
  font-size: var(--font-size-xl);  /* 48px - same as grapheme display */
  font-weight: 700;
  color: var(--color-text);

  background: var(--color-bg-card);
  border: 3px solid var(--color-text-muted);
  border-radius: var(--border-radius-lg);
  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  transition: border-color var(--transition-fast),
              transform var(--transition-fast),
              background-color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.grapheme-option-btn:hover {
  border-color: var(--color-accent);
}

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

.grapheme-option-btn:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

.grapheme-option-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .audio-replay-btn,
  .grapheme-option-btn {
    transition: none;
  }
}

/* ==========================================================================
   20. Syllable Reading Styles (Story 4.4)
   FR13: Syllable reading with grapheme highlighting
   Child reads syllables containing the target grapheme
   ========================================================================== */

/* Syllable reading container - vertical layout */
.syllable-reading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-lg);
  padding: var(--spacing-md);
  width: 100%;
}

/* Syllable display - extra large for readability (AC #1) */
/* FR13, NFR11: Very large text (48-72px) for dyslexia accessibility */
.syllable-display {
  font-family: var(--font-family);
  font-size: clamp(48px, 10vw, 72px);
  font-weight: 700;
  letter-spacing: var(--letter-spacing);
  line-height: var(--line-height);
  color: var(--color-text);
  text-align: center;
  padding: var(--spacing-lg);
  background: var(--color-bg-card);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  min-width: 200px;
}

/* AC #3: Syllable is tappable to validate reading */
.syllable-tappable {
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color var(--transition-fast),
              transform var(--transition-fast),
              box-shadow var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.syllable-tappable:hover {
  border-color: var(--color-accent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.syllable-tappable:active {
  transform: scale(0.98);
}

.syllable-tappable:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

/* Regular syllable text (non-highlighted parts) */
.syllable-part {
  color: var(--color-text);
}

/* Target grapheme highlighted in accent color (AC #1) */
.syllable-grapheme-highlight {
  color: var(--color-accent);
  font-weight: 700;
}

/* Button row - audio and "J'ai lu" buttons side by side */
.syllable-button-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--spacing-lg);
  flex-wrap: wrap;
  justify-content: center;
}

/* Audio replay button for syllable (AC #2) */
.syllable-audio-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--color-bg-card);
  border: 2px solid var(--color-text-muted);
  color: var(--color-text);
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--transition-fast),
              transform var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.syllable-audio-btn:hover {
  border-color: var(--color-accent);
}

.syllable-audio-btn:active {
  transform: scale(0.95);
}

.syllable-audio-btn:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

.syllable-audio-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* "J'ai lu" validation button (AC #3) */
/* Touch target 64px minimum as per UX spec */
.syllable-read-btn {
  min-width: var(--tap-target);
  min-height: var(--tap-target);
  padding: var(--spacing-md) var(--spacing-xl);
  font-family: var(--font-family);
  font-size: var(--font-size-lg);
  font-weight: 700;
  background: var(--color-accent);
  color: var(--color-white);
  border: none;
  border-radius: var(--border-radius-lg);
  cursor: pointer;
  transition: background-color var(--transition-fast),
              transform var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.syllable-read-btn:hover {
  background-color: var(--color-accent-hover);
}

.syllable-read-btn:active {
  transform: scale(0.98);
}

.syllable-read-btn:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

/* Audio error hint - pulse animation to draw attention */
.audio-error-hint {
  animation: pulse-hint 0.5s ease-in-out 3;
}

@keyframes pulse-hint {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(33, 150, 243, 0.4);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 8px rgba(33, 150, 243, 0);
  }
}

/* Respect prefers-reduced-motion for syllable reading */
@media (prefers-reduced-motion: reduce) {
  .syllable-display,
  .syllable-audio-btn,
  .syllable-read-btn,
  .audio-error-hint {
    transition: none;
    animation: none;
  }
}

/* ==========================================================================
   21. Borel-Maisonny Gesture Display (Story 4.5)
   FR14: Display Borel-Maisonny phonetic gestures as animated GIFs
   Gestures help children associate sounds with hand movements
   ========================================================================== */

/* Images row - mnemonic image and gesture side by side */
.grapheme-images-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-lg);
  flex-wrap: wrap;
  padding: var(--spacing-sm) 0;
}

/* Gesture GIF display (FR14) */
/* Borel-Maisonny hand gesture animation */
.gesture-display {
  width: clamp(120px, 20vw, 160px);
  height: auto;
  border-radius: var(--border-radius-md);
  background: var(--color-bg-card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  object-fit: contain;
}

/* Gesture label for accessibility */
.gesture-label {
  font-size: calc(var(--font-size-base) * 0.75);
  color: var(--color-text-muted);
  text-align: center;
  margin-top: var(--spacing-xs);
}

/* Reduced motion: pause GIF animation */
/* Note: This class is added via JS when prefers-reduced-motion is detected */
/* Most browsers will show the first frame of a GIF when animation is unwanted */
.gesture-display.reduced-motion {
  /* Browsers handle this automatically, but we can hint */
  animation-play-state: paused;
}

/* Responsive: Stack images vertically on very small screens */
@media (max-width: 480px) {
  .grapheme-images-row {
    flex-direction: column;
    gap: var(--spacing-md);
  }

  .gesture-display {
    width: clamp(100px, 30vw, 140px);
  }
}

/* Respect prefers-reduced-motion for gesture animations */
/* NOTE: CSS cannot pause GIF animations. For animated GIFs, the JS adds
   .reduced-motion class which documents intent. When real animated GIFs
   are added, consider using <picture> with static fallback, or replacing
   src via JS when prefers-reduced-motion is detected. Current placeholders
   are static (1 frame) so this is a no-op for now. */
@media (prefers-reduced-motion: reduce) {
  .gesture-display {
    /* Placeholder for future animated GIF handling */
  }
}

/* ==========================================================================
   22. Syllabic Colorization (Story 5.1)
   FR15: Display words with alternating colored syllables for easier reading
   Colors are high-contrast for dyslexia accessibility (WCAG AA >= 4.5:1)
   ========================================================================== */

/* Syllable color tokens - high contrast against cream background #FFF8E7 */
/* Color 1: Blue #1565C0 - contrast ratio 5.43:1 against #FFF8E7 (WCAG AA) */
/* Color 2: Deep Orange #BF360C - contrast ratio 5.29:1 against #FFF8E7 (WCAG AA) */
:root {
  --color-syllable-1: #1565C0;
  --color-syllable-2: #BF360C;
}

/* Colorized word container - inherits font settings for consistency */
.colorized-word {
  display: inline;
  font-family: var(--font-family);
  font-size: inherit;
  line-height: var(--line-height);
  letter-spacing: var(--letter-spacing);
}

/* Syllable 1 - Blue (odd syllables: 1st, 3rd, 5th...) */
.syllable-1 {
  color: var(--color-syllable-1);
  font-weight: 700;
}

/* Syllable 2 - Orange (even syllables: 2nd, 4th, 6th...) */
.syllable-2 {
  color: var(--color-syllable-2);
  font-weight: 700;
}

/* Large colorized word display - used in word reading exercises */
.colorized-word-display {
  font-size: clamp(36px, 8vw, 56px);
  text-align: center;
  padding: var(--spacing-lg);
  background: var(--color-bg-card);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   23. Word Pronunciation Audio (Story 5.2)
   FR16: Tap word or audio button to hear pronunciation via TTS
   Accessibility: 44x44px touch targets (WCAG), aria-labels, keyboard support
   ========================================================================== */

/* Tappable word - click/tap to speak */
.word-tappable {
  cursor: pointer;
  display: inline-block;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--border-radius-md);
  transition: background-color var(--transition-fast),
              transform var(--transition-fast);
  /* Touch feedback */
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* Hover effect (desktop) */
.word-tappable:hover {
  background-color: rgba(33, 150, 243, 0.1);
}

/* Active/pressed state - visual feedback */
.word-tappable:active {
  background-color: rgba(33, 150, 243, 0.2);
  transform: scale(0.98);
}

/* Focus state for keyboard navigation */
.word-tappable:focus {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

/* Focus-visible for better UX (hide outline on mouse click) */
.word-tappable:focus:not(:focus-visible) {
  outline: none;
}

.word-tappable:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

/* Word + Audio button container */
.word-audio-container {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  flex-wrap: nowrap;
}

/* Audio button - 44x44px minimum touch target (WCAG) */
.word-audio-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  width: 48px;
  height: 48px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background-color: var(--color-accent);
  color: var(--color-white);
  font-size: 24px;
  cursor: pointer;
  transition: background-color var(--transition-fast),
              transform var(--transition-fast);
  /* Touch feedback */
  -webkit-tap-highlight-color: transparent;
  /* Prevent text selection on long press */
  user-select: none;
}

/* Hover state (desktop) */
.word-audio-btn:hover {
  background-color: var(--color-accent-hover);
}

/* Active/pressed state */
.word-audio-btn:active {
  transform: scale(0.92);
  background-color: var(--color-accent-hover);
}

/* Focus state for keyboard navigation */
.word-audio-btn:focus {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

/* Focus-visible for better UX */
.word-audio-btn:focus:not(:focus-visible) {
  outline: none;
}

.word-audio-btn:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

/* Disabled state (when speaking) */
.word-audio-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Speaking state - visual feedback while TTS is active */
.word-speaking {
  background-color: rgba(33, 150, 243, 0.15);
  animation: pulse-speaking 1s ease-in-out infinite;
}

.word-audio-btn--speaking {
  background-color: var(--color-accent-hover);
  animation: pulse-speaking 1s ease-in-out infinite;
}

@keyframes pulse-speaking {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* Error state - brief red flash when TTS fails */
.word-tts-error {
  background-color: rgba(229, 57, 53, 0.2) !important;
  animation: shake-error 0.3s ease;
}

.word-audio-btn--error {
  background-color: #E53935 !important;
  animation: shake-error 0.3s ease;
}

@keyframes shake-error {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* Responsive: Ensure touch targets remain accessible on small screens */
@media (max-width: 480px) {
  .word-audio-container {
    gap: var(--spacing-xs);
  }

  .word-audio-btn {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .word-tappable,
  .word-audio-btn {
    transition: none;
  }

  .word-tappable:active,
  .word-audio-btn:active {
    transform: none;
  }

  .word-speaking,
  .word-audio-btn--speaking {
    animation: none;
  }

  .word-tts-error,
  .word-audio-btn--error {
    animation: none;
  }
}

/* ==========================================================================
   24. Word-Image Association Exercise (Story 5.3)
   FR17: Child matches colorized word with corresponding image
   Uses feedback system from Story 3.3 (FR35, FR36)
   ========================================================================== */

/* Exercise container - vertical layout */
.word-image-exercise {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-lg);
  padding: var(--spacing-md);
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
}

/* Instruction text */
.word-image-instruction {
  font-size: var(--font-size-lg);
  color: var(--color-text-secondary);
  text-align: center;
  margin: 0;
}

/* Word display area with audio button */
.word-image-display {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--spacing-md);
  background: var(--color-bg-card);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  min-height: 80px;
}

/* Make word larger in this context */
.word-image-display .colorized-word {
  font-size: clamp(28px, 6vw, 40px);
}

/* Image options grid - 2x2 layout */
.word-image-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-md);
  width: 100%;
  max-width: 400px;
}

/* Individual image option button */
.word-image-option {
  aspect-ratio: 1;
  min-width: 80px;
  min-height: 80px;
  padding: var(--spacing-sm);
  border: 3px solid var(--color-text-muted);
  border-radius: var(--border-radius-lg);
  background: var(--color-bg-card);
  cursor: pointer;
  transition: border-color var(--transition-fast),
              transform var(--transition-fast),
              box-shadow var(--transition-fast);
  /* Touch feedback */
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  /* Center image */
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Image inside button */
.word-image-option-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Fallback emoji when image fails to load */
.word-image-fallback {
  font-size: 48px;
  opacity: 0.5;
}

/* Hover state (desktop) */
.word-image-option:hover {
  border-color: var(--color-accent);
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.2);
}

/* Active/pressed state */
.word-image-option:active {
  transform: scale(0.96);
}

/* Focus state for keyboard navigation */
.word-image-option:focus {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

/* Focus-visible for better UX */
.word-image-option:focus:not(:focus-visible) {
  outline: none;
}

.word-image-option:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

/* Disabled state (after selection) */
.word-image-option:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

/* Correct answer feedback (FR35) - reuse existing class pattern */
.word-image-option.response-correct {
  border-color: var(--color-success);
  background-color: rgba(76, 175, 80, 0.1);
  animation: feedback-flash 0.3s ease;
}

/* Incorrect answer feedback (FR36) - neutral, no red */
.word-image-option.response-incorrect {
  border-color: var(--color-text-secondary);
  opacity: 0.6;
}

/* Reveal correct answer when user selects wrong one */
.word-image-option.response-correct-reveal {
  border-color: var(--color-success);
  border-width: 4px;
  box-shadow: 0 0 12px rgba(76, 175, 80, 0.4);
}

/* Responsive: Stack on very small screens if needed */
@media (max-width: 320px) {
  .word-image-grid {
    gap: var(--spacing-sm);
  }

  .word-image-option {
    min-width: 70px;
    min-height: 70px;
  }
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .word-image-option {
    transition: none;
  }

  .word-image-option:active {
    transform: none;
  }

  .word-image-option.response-correct {
    animation: none;
  }
}

/* ==========================================================================
   25. Complex Grapheme Highlighting (Story 5.4)
   FR18: Child sees complex graphemes (ou, an, ch, etc.) highlighted in words
   Works within syllable colorization (FR15) without disrupting readability
   ========================================================================== */

/* Highlighted grapheme - distinct from syllable colors */
.grapheme-highlight {
  /* Visual distinction: underline + subtle background */
  border-bottom: 2px solid var(--color-accent);
  background-color: rgba(33, 150, 243, 0.08);
  border-radius: 2px;
  padding: 0 1px;
  /* Interactive element */
  cursor: pointer;
  /* Smooth transitions */
  transition: background-color var(--transition-fast),
              border-color var(--transition-fast),
              transform var(--transition-fast);
}

/* Hover state - more prominent */
.grapheme-highlight:hover {
  background-color: rgba(33, 150, 243, 0.15);
  border-bottom-color: var(--color-accent);
}

/* Active/pressed state */
.grapheme-highlight:active {
  transform: scale(0.98);
}

/* Focus state for keyboard navigation */
.grapheme-highlight:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

/* Focus-visible for better UX */
.grapheme-highlight:focus:not(:focus-visible) {
  outline: none;
}

.grapheme-highlight:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

/* Speaking state - visual feedback during TTS */
.grapheme-highlight--speaking {
  background-color: rgba(33, 150, 243, 0.25);
  border-bottom-color: var(--color-accent);
  animation: grapheme-pulse 0.6s ease-in-out;
}

/* Error state */
.grapheme-highlight--error {
  border-bottom-color: var(--color-error, #f44336);
  background-color: rgba(244, 67, 54, 0.1);
}

/* Pulse animation for speaking state */
@keyframes grapheme-pulse {
  0%, 100% {
    background-color: rgba(33, 150, 243, 0.15);
  }
  50% {
    background-color: rgba(33, 150, 243, 0.3);
  }
}

/* Ensure grapheme highlight works within syllable colors */
.syllable-1 .grapheme-highlight,
.syllable-2 .grapheme-highlight {
  /* Inherit text color from syllable */
  color: inherit;
}

/* Container modifier for words with highlights */
.colorized-word--with-highlights {
  /* Slightly more spacing to accommodate underlines */
  letter-spacing: 0.01em;
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .grapheme-highlight {
    transition: none;
  }

  .grapheme-highlight:active {
    transform: none;
  }

  .grapheme-highlight--speaking {
    animation: none;
    background-color: rgba(33, 150, 243, 0.25);
  }
}

/* ==========================================================================
   26. Calendar View (Story 7.1)
   FR30: Display calendar of completed journeys
   Monthly view showing completion status for each day
   ========================================================================== */

/* Calendar container - centered layout */
.calendar-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--spacing-md);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
  max-width: 500px;
  margin: 0 auto;
}

/* Month header - French month name + year */
.calendar-header {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-text);
  text-align: center;
  text-transform: capitalize;
  margin-bottom: var(--spacing-md);
}

/* Weekday labels row */
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--spacing-xs);
  width: 100%;
  margin-bottom: var(--spacing-sm);
}

.calendar-weekday {
  font-size: calc(var(--font-size-base) * 0.75);
  font-weight: 700;
  color: var(--color-text-muted);
  text-align: center;
  padding: var(--spacing-xs);
}

/* Calendar grid - 7 columns for days */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--spacing-xs);
  width: 100%;
}

/* Base day cell styles */
.calendar-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: var(--spacing-xs);
  background: var(--color-bg-card);
  border-radius: var(--border-radius-md);
  text-align: center;
}

/* Empty cell (padding before month starts) */
.calendar-day--empty {
  background: transparent;
}

/* Day number */
.calendar-day-number {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

/* Completion indicator */
.calendar-day-indicator {
  font-size: calc(var(--font-size-base) * 0.75);
  line-height: 1;
  margin-top: 2px;
}

/* Completed day - green checkmark (AC #2) */
.calendar-day--completed {
  background: var(--color-success-subtle);
}

.calendar-day--completed .calendar-day-indicator {
  color: var(--color-success);
}

/* Missed day - subtle X, not judgmental (AC #3) */
.calendar-day--missed {
  background: var(--color-bg-card);
}

.calendar-day--missed .calendar-day-indicator {
  color: var(--color-text-muted);
  opacity: 0.5;
}

/* Today highlighted (AC #4) */
.calendar-day--today {
  border: 3px solid var(--color-accent);
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.2);
}

/* Future days grayed out (AC #5) */
.calendar-day--future {
  opacity: 0.4;
}

.calendar-day--future .calendar-day-number {
  color: var(--color-text-muted);
}

/* Responsive: Smaller cells on very small screens */
@media (max-width: 400px) {
  .calendar-day {
    min-height: 40px;
    padding: 4px;
  }

  .calendar-day-number {
    font-size: calc(var(--font-size-base) * 0.875);
  }

  .calendar-day-indicator {
    font-size: calc(var(--font-size-base) * 0.625);
  }
}

/* ============================== */
/* 27. Streak Display (Story 7.2, FR31) */
/* ============================== */

/* Streak text - sober display, no flames or excessive animations (AC #2) */
/* Note: Use utility classes (mt-md, mb-md) in HTML for margins - consistent with project patterns */
.streak-text {
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
  text-align: center;
  /* Inherit OpenDyslexic and accessibility styles */
  font-family: inherit;
  line-height: inherit;
  letter-spacing: inherit;
}

/* ============================== */
/* 28. Journey Summary (Story 7.3, FR32) */
/* ============================== */

/* Summary container - sober display, no celebration effects (AC #3, AC #4) */
.summary-container {
  margin-top: var(--spacing-lg);
  text-align: center;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* Summary text lines - muted, positive framing only */
.summary-text {
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-sm);
  /* Inherit OpenDyslexic and accessibility styles (AC #5) */
  font-family: inherit;
  line-height: inherit;
  letter-spacing: inherit;
}

/* Remove bottom margin from last summary text */
.summary-text:last-child {
  margin-bottom: 0;
}

/* ============================== */
/* 29. Karaoke Reading (Story 8.1, FR19) */
/* ============================== */

/* Karaoke container - centered phrase display */
.karaoke-container {
  text-align: center;
  padding: var(--spacing-lg);
  max-width: 600px;
  margin: 0 auto;
}

/* Phrase container with generous line height for word spacing */
.karaoke-phrase {
  font-size: var(--font-size-lg);
  line-height: 2.2;
  /* Inherit OpenDyslexic and accessibility styles (AC #6) */
  font-family: inherit;
  letter-spacing: inherit;
  /* Ensure text wraps properly on mobile */
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

/* Individual word spans for highlighting */
.karaoke-word {
  display: inline-block;
  padding: var(--spacing-xs) var(--spacing-sm);
  margin: var(--spacing-xs);
  border-radius: var(--border-radius-md);
  /* Smooth highlight transition (AC #4) */
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

/* Active/highlighted word during speech (AC #3) */
.karaoke-word--active {
  background-color: rgba(124, 179, 66, 0.25); /* --color-success with transparency */
  box-shadow: 0 0 0 3px rgba(124, 179, 66, 0.4);
}

/* Hint text for pause instruction */
.karaoke-hint {
  margin-top: var(--spacing-lg);
  font-size: calc(var(--font-size-base) * 0.75);
  color: var(--color-text-muted);
  opacity: 0.7;
}

/* Paused state indicator - matches .karaoke-wrapper--paused class from JS */
.karaoke-wrapper--paused .karaoke-hint::after {
  content: ' (en pause)';
}

/* TTS unavailable notice (L1 review follow-up - v1.0.2) */
.karaoke-tts-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  margin-bottom: var(--spacing-md);
  background-color: rgba(255, 193, 7, 0.15); /* Amber/warning color */
  border-radius: var(--border-radius-md);
  border: 1px solid rgba(255, 193, 7, 0.3);
}

.karaoke-tts-notice__icon {
  font-size: calc(var(--font-size-base) * 1.2);
}

.karaoke-tts-notice__text {
  font-size: calc(var(--font-size-base) * 0.85);
  color: var(--color-text-muted);
}

/* Speed control (Story 8.2, FR20) */
.karaoke-speed-control {
  display: flex;
  justify-content: center;
  gap: var(--spacing-xs);
  margin-bottom: var(--spacing-md);
  padding: 0 var(--spacing-sm);
  max-width: 100%;
}

.karaoke-speed-btn {
  padding: var(--spacing-xs) var(--spacing-sm);
  min-height: 44px; /* Touch target accessibility */
  flex: 1;
  max-width: 100px;
  border-radius: var(--border-radius-md);
  background-color: var(--color-bg);
  border: 2px solid var(--color-text-muted);
  color: var(--color-text);
  font-family: inherit;
  font-size: calc(var(--font-size-base) * 0.8);
  cursor: pointer;
  transition: all 0.2s ease;
}

.karaoke-speed-btn:hover {
  border-color: var(--color-accent);
}

.karaoke-speed-btn--active {
  background-color: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-white);
}

.karaoke-speed-btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* ============================================
   30. Echo Mode (Story 8.3, FR21)
   ============================================ */

.echo-container {
  text-align: center;
  padding: var(--spacing-lg);
}

.echo-phrase {
  margin: var(--spacing-lg) 0;
}

.echo-instruction {
  font-size: calc(var(--font-size-base) * 0.9);
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-md);
}

/* "À toi !" indicator (AC #2) */
.echo-your-turn {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-success);
  margin: var(--spacing-md) 0;
}

.echo-your-turn--visible {
  animation: echo-pulse 1s ease-in-out 3;
}

@keyframes echo-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.85;
  }
}

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .echo-your-turn--visible {
    animation: none;
  }
}

/* Replay button (AC #5) */
.echo-replay-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  min-width: 64px; /* Touch target */
  min-height: 64px;
  border-radius: 50%;
  background-color: var(--color-bg-card);
  border: 2px solid var(--color-text-muted);
  font-size: calc(var(--font-size-base) * 1.5);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin: var(--spacing-md) 0;
}

.echo-replay-btn:hover {
  border-color: var(--color-accent);
  background-color: var(--color-bg);
}

.echo-replay-btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

.echo-replay-btn:active {
  transform: scale(0.95);
}

/* Continue button (AC #4) */
.echo-continue-btn {
  display: block;
  width: 100%;
  padding: var(--spacing-md) var(--spacing-lg);
  min-height: var(--tap-target);
  margin-top: var(--spacing-lg);
  background-color: var(--color-accent);
  color: var(--color-white);
  border: none;
  border-radius: var(--border-radius-md);
  font-family: inherit;
  font-size: var(--font-size-base);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.echo-continue-btn:hover {
  background-color: var(--color-accent-hover);
  transform: translateY(-1px);
}

.echo-continue-btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

.echo-continue-btn:active {
  transform: translateY(0);
}

/* ===========================================
   31. Phonemic Segmentation (Story 9.1, FR22)
   =========================================== */

/* Main container */
.segmentation-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-lg);
  padding: var(--spacing-lg);
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
}

/* Instruction text */
.segmentation-instruction {
  font-size: calc(var(--font-size-base) * 0.9);
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: var(--spacing-sm);
}

/* Word display area */
.segmentation-word-display {
  font-size: clamp(36px, 8vw, 56px);
  text-align: center;
  background: var(--color-bg-card);
  padding: var(--spacing-lg) var(--spacing-xl);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  min-width: 200px;
}

/* Options container - vertical stack */
.segmentation-options {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  width: 100%;
  max-width: 400px;
}

/* Option button */
.segmentation-option {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--spacing-sm);
  min-height: var(--tap-target);
  padding: var(--spacing-md);
  background: var(--color-bg-card);
  border: 3px solid var(--color-text-muted);
  border-radius: var(--border-radius-lg);
  cursor: pointer;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
  font-family: inherit;
}

.segmentation-option:hover:not(:disabled) {
  border-color: var(--color-accent);
}

.segmentation-option:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

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

.segmentation-option:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Phoneme boxes container */
.phoneme-boxes {
  display: flex;
  justify-content: center;
  gap: var(--spacing-sm);
}

/* Individual phoneme box */
.phoneme-box {
  width: 36px;
  height: 36px;
  background: var(--color-accent);
  border-radius: var(--border-radius-sm);
  opacity: 0.6;
}

/* Feedback states - reuse existing patterns */
.segmentation-option.response-correct {
  border-color: var(--color-success);
  background-color: var(--color-success-light);
}

.segmentation-option.response-correct .phoneme-box {
  background: var(--color-success);
  opacity: 1;
}

.segmentation-option.response-incorrect {
  border-color: var(--color-text-muted);
  opacity: 0.5;
}

.segmentation-option.response-correct-reveal {
  border-color: var(--color-success);
  background-color: var(--color-success-light);
  animation: reveal-correct 0.3s ease-out;
}

.segmentation-option.response-correct-reveal .phoneme-box {
  background: var(--color-success);
  opacity: 1;
}

@keyframes reveal-correct {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
  }
}

/* Segmentation replay button - 64px as per Story 9.1 spec (smaller than .audio-replay-btn 80px) */
.segmentation-replay-btn {
  width: 64px;
  height: 64px;
  min-width: 64px;
  min-height: 64px;
  border-radius: 50%;
  background: var(--color-accent);
  color: var(--color-white);
  font-size: 28px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast),
              background-color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.segmentation-replay-btn:hover {
  transform: scale(1.05);
  background-color: var(--color-accent-hover);
}

.segmentation-replay-btn:active {
  transform: scale(0.95);
}

.segmentation-replay-btn:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

.segmentation-replay-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
  .segmentation-option {
    transition: none;
  }

  .segmentation-option.response-correct-reveal {
    animation: none;
  }

  .segmentation-replay-btn {
    transition: none;
  }
}

/* ===========================================
   32. Phonemic Elision (Story 9.2, FR23)
   =========================================== */

/* Main container - reuses structure from segmentation */
.elision-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-lg);
  padding: var(--spacing-lg);
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
}

/* Instruction text */
.elision-instruction {
  font-size: calc(var(--font-size-base) * 0.9);
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: var(--spacing-sm);
}

/* Word display area */
.elision-word-display {
  font-size: clamp(36px, 8vw, 56px);
  text-align: center;
  background: var(--color-bg-card);
  padding: var(--spacing-lg) var(--spacing-xl);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  min-width: 200px;
}

/* Options container - 2x2 grid for text options */
.elision-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-md);
  width: 100%;
  max-width: 400px;
}

/* Option button - text-based */
.elision-option {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: var(--tap-target);
  padding: var(--spacing-md);
  background: var(--color-bg-card);
  border: 3px solid var(--color-text-muted);
  border-radius: var(--border-radius-lg);
  cursor: pointer;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
  font-family: inherit;
  font-size: clamp(24px, 5vw, 32px);
}

.elision-option:hover:not(:disabled) {
  border-color: var(--color-accent);
}

.elision-option:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

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

.elision-option:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Feedback states */
.elision-option.response-correct {
  border-color: var(--color-success);
  background-color: var(--color-success-light);
}

.elision-option.response-incorrect {
  border-color: var(--color-text-muted);
  opacity: 0.5;
}

.elision-option.response-correct-reveal {
  border-color: var(--color-success);
  background-color: var(--color-success-light);
  animation: reveal-correct 0.3s ease-out;
}

/* Elision replay button - 64px as per Story 9.1 pattern */
.elision-replay-btn {
  width: 64px;
  height: 64px;
  min-width: 64px;
  min-height: 64px;
  border-radius: 50%;
  background: var(--color-accent);
  color: var(--color-white);
  font-size: 28px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast),
              background-color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.elision-replay-btn:hover {
  transform: scale(1.05);
  background-color: var(--color-accent-hover);
}

.elision-replay-btn:active {
  transform: scale(0.95);
}

.elision-replay-btn:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

.elision-replay-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
  .elision-option {
    transition: none;
  }

  .elision-option.response-correct-reveal {
    animation: none;
  }

  .elision-replay-btn {
    transition: none;
  }
}

/* ===========================================
   33. Phonemic Fusion (Story 9.3, FR24)
   =========================================== */

/* Main container */
.fusion-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 0;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

/* Instruction text */
.fusion-instruction {
  font-size: calc(var(--font-size-base) * 0.9);
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: var(--spacing-sm);
}

/* Phoneme display area */
.fusion-phoneme-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  font-size: clamp(20px, 5vw, 40px);
  text-align: center;
  background: var(--color-bg-card);
  padding: var(--spacing-sm);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  flex-wrap: wrap;
  max-width: 100%;
  box-sizing: border-box;
}

/* Individual phoneme styling */
.fusion-phoneme {
  background: var(--color-accent);
  color: var(--color-white);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--border-radius-md);
  font-weight: bold;
  font-family: inherit;
  flex-shrink: 1;
  min-width: fit-content;
}

/* Separator between phonemes */
.fusion-separator {
  font-size: 1em;
  color: var(--color-text-muted);
  font-weight: normal;
  flex-shrink: 0;
}

/* Options container - 2x2 grid */
.fusion-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-sm);
  width: 100%;
  box-sizing: border-box;
}

/* Option button - image + word */
.fusion-option {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: var(--spacing-xs);
  min-height: 110px;
  padding: var(--spacing-sm);
  background: var(--color-bg-card);
  border: 2px solid var(--color-text-muted);
  border-radius: var(--border-radius-lg);
  cursor: pointer;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
  font-family: inherit;
}

.fusion-option:hover:not(:disabled) {
  border-color: var(--color-accent);
}

.fusion-option:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

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

.fusion-option:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Option image */
.fusion-option-image {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

/* Option word text */
.fusion-option-word {
  font-size: var(--font-size-base);
  text-align: center;
  white-space: nowrap;
}

/* Feedback states */
.fusion-option.response-correct {
  border-color: var(--color-success);
  background-color: var(--color-success-light);
}

.fusion-option.response-incorrect {
  border-color: var(--color-text-muted);
  opacity: 0.5;
}

.fusion-option.response-correct-reveal {
  border-color: var(--color-success);
  background-color: var(--color-success-light);
  animation: reveal-correct 0.3s ease-out;
}

/* Fusion replay button - 64px as per Story 9.1 pattern */
.fusion-replay-btn {
  width: 64px;
  height: 64px;
  min-width: 64px;
  min-height: 64px;
  border-radius: 50%;
  background-color: var(--color-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: transform var(--transition-fast),
              background-color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.fusion-replay-btn:hover {
  transform: scale(1.05);
  background-color: var(--color-accent-hover);
}

.fusion-replay-btn:active {
  transform: scale(0.95);
}

.fusion-replay-btn:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

.fusion-replay-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
  .fusion-option {
    transition: none;
  }

  .fusion-option.response-correct-reveal {
    animation: none;
  }

  .fusion-replay-btn {
    transition: none;
  }
}

/* ==========================================================================
   Reset Cache Button - Accessible on all pages for debugging
   ========================================================================== */
.reset-cache-btn {
  position: fixed;
  bottom: 10px;
  right: 10px;
  z-index: 9999;
  padding: 8px 12px;
  font-size: 12px;
  font-family: system-ui, sans-serif;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.reset-cache-btn:hover,
.reset-cache-btn:focus {
  opacity: 1;
}

.reset-cache-btn:active {
  transform: scale(0.95);
}
