/* ═══════════════════════════════════════════
   Speech Training — Card-based UI
   Calm, minimal, distraction-free
   ═══════════════════════════════════════════ */

/* ── Hide nav/chrome during play ── */
.activity-game-body header,
.activity-game-body .navbar,
.activity-game-body .guest-navbar,
.activity-game-body .mobile-bottom-nav,
.activity-game-body footer,
.activity-game-body .footer,
.activity-game-body #kittu-widget,
.activity-game-body .kittu-widget,
.activity-game-body [id*="kittu"],
.activity-game-body #chat-notification-badge,
.activity-game-body #floating-chat-container {
  display: none !important;
}

/* ── Module select grid ── */
.speech-modules-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important;
}

.speech-module-card {
  position: relative;
}

.speech-module-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.speech-module-badge--listen {
  background: #f3e5f5;
  color: #7b1fa2;
}

.speech-module-badge--soon {
  background: #fff3e0;
  color: #e65100;
}

.speech-module-card--coming-soon {
  cursor: default !important;
  pointer-events: none;
  position: relative;
}

/* ── Full-screen play layout ── */
.speech-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: linear-gradient(160deg, #f0faf8 0%, #f7f7ff 50%, #f2f0fe 100%);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Top bar ── */
.speech-topbar {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  position: sticky;
  top: 0;
  z-index: 50;
}

.speech-topbar-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: #555;
  text-decoration: none;
  transition: background 0.15s;
}
.speech-topbar-back:hover { background: rgba(0,0,0,0.05); }

.speech-topbar-center {
  flex: 1;
  text-align: center;
}

.speech-topbar-module {
  font-weight: 700;
  font-size: 1rem;
  color: #333;
}

.speech-topbar-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  background: #f3e5f5;
  color: #7b1fa2;
  vertical-align: middle;
}
.speech-topbar-badge--demo {
  background: #e8f5e9;
  color: #2e7d32;
}

.speech-topbar-progress {
  display: block;
  font-size: 0.78rem;
  color: #999;
  margin-top: 2px;
}

.speech-topbar-actions {
  display: flex;
  gap: 6px;
}

.speech-topbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #555;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s;
}
.speech-topbar-btn:hover { background: rgba(0,0,0,0.05); }

/* ── Card area ── */
.speech-card-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
}

/* Loading */
.speech-loading {
  text-align: center;
  color: #999;
}
.speech-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e0e0e0;
  border-top-color: #1d9a8a;
  border-radius: 50%;
  animation: speechSpin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes speechSpin { to { transform: rotate(360deg); } }

/* Card */
.speech-card {
  width: min(480px, 100%);
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
  padding: 32px 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.speech-card--enter {
  animation: cardEnter 0.35s ease-out;
}
@keyframes cardEnter {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Card image */
.speech-card-image {
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1;
  border-radius: 16px;
  overflow: hidden;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
}

.speech-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 16px;
}

.speech-card-icon-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #e8f5e9 0%, #e3f2fd 100%);
  border-radius: 16px;
  flex-direction: column;
  gap: 8px;
}

.speech-card-emoji {
  font-size: 6rem;
  line-height: 1;
}

.speech-card-icon-placeholder span {
  font-size: 5rem;
  font-weight: 800;
  color: #1d9a8a;
  letter-spacing: -2px;
  text-transform: uppercase;
}

/* Card text */
.speech-card-text {
  width: 100%;
}

.speech-card-word {
  font-size: 1.8rem;
  font-weight: 700;
  color: #333;
  margin: 0;
  line-height: 1.3;
}

/* Replay button */
.speech-replay-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border: 2px solid #1d9a8a;
  border-radius: 50px;
  background: transparent;
  color: #1d9a8a;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.speech-replay-btn:hover {
  background: #1d9a8a;
  color: #fff;
  transform: scale(1.05);
}
.speech-replay-btn:active {
  transform: scale(0.98);
}

/* Audio actions row */
.speech-audio-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

/* My Turn button */
.speech-myturn-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border: 2px solid #6a60f0;
  border-radius: 50px;
  background: transparent;
  color: #6a60f0;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.speech-myturn-btn:hover {
  background: #6a60f0;
  color: #fff;
  transform: scale(1.05);
}
.speech-myturn-btn:active {
  transform: scale(0.98);
}
.speech-myturn-btn--listening {
  background: #6a60f0;
  color: #fff;
  animation: myturnPulse 1.2s ease-in-out infinite;
}
@keyframes myturnPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(106, 96, 240, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(106, 96, 240, 0); }
}

/* Mic feedback area */
.speech-mic-feedback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.speech-mic-pulse {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6a60f0, #9c27b0);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  animation: micPulse 1s ease-in-out infinite;
}
@keyframes micPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(106, 96, 240, 0.4); }
  50% { transform: scale(1.1); box-shadow: 0 0 0 16px rgba(106, 96, 240, 0); }
}

.speech-mic-status {
  font-size: 0.85rem;
  color: #6a60f0;
  font-weight: 600;
  margin: 0;
}

/* Speech feedback message */
.speech-feedback-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 50px;
  background: linear-gradient(135deg, #e8f5e9, #f3e5f5);
  color: #4caf50;
  font-size: 0.9rem;
  font-weight: 600;
  animation: feedbackIn 0.4s ease-out;
}
.speech-feedback-msg i {
  color: #ff9800;
  font-size: 1.1rem;
}
@keyframes feedbackIn {
  from { opacity: 0; transform: translateY(8px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Match percentage bar */
.speech-match-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 80%;
  max-width: 280px;
}

.speech-match-track {
  flex: 1;
  height: 10px;
  border-radius: 5px;
  background: #e8e8e8;
  overflow: hidden;
}

.speech-match-fill {
  height: 100%;
  border-radius: 5px;
  background: #4caf50;
  transition: width 0.6s ease-out;
  width: 0;
}

.speech-match-percent {
  font-size: 0.9rem;
  font-weight: 700;
  min-width: 36px;
  text-align: right;
}

/* Encouragement */
.speech-encouragement {
  font-size: 0.9rem;
  color: #1d9a8a;
  font-weight: 600;
  min-height: 1.4em;
  opacity: 0;
  transition: opacity 0.4s;
}
.speech-encouragement--visible {
  opacity: 1;
}

/* ── Bottom bar ── */
.speech-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px 20px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0,0,0,0.06);
}

.speech-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 14px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.speech-nav-btn--skip {
  background: #f5f5f5;
  color: #888;
}
.speech-nav-btn--skip:hover {
  background: #eee;
  color: #666;
}

.speech-nav-btn--next {
  background: linear-gradient(135deg, #1d9a8a, #6a60f0);
  color: #fff;
  box-shadow: 0 4px 12px rgba(29, 154, 138, 0.25);
}
.speech-nav-btn--next:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(29, 154, 138, 0.3);
}

/* Progress dots */
.speech-progress-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 200px;
  overflow: hidden;
}

.speech-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e0e0e0;
  transition: all 0.2s;
  flex-shrink: 0;
}
.speech-dot--active {
  background: #1d9a8a;
  transform: scale(1.3);
}
.speech-dot--done {
  background: #a5d6d0;
}

/* Progress bar (for large card sets) */
.speech-progress-bar {
  width: 120px;
  height: 6px;
  border-radius: 3px;
  background: #e0e0e0;
  overflow: hidden;
}
.speech-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #1d9a8a, #6a60f0);
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 0;
}

/* ── Overlays ── */
.speech-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.speech-overlay-panel {
  background: #fff;
  border-radius: 20px;
  width: min(400px, 100%);
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.speech-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.speech-overlay-header h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: #333;
}

.speech-overlay-close {
  border: none;
  background: #f5f5f5;
  border-radius: 10px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #666;
}

/* Settings */
.speech-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
}
.speech-setting span {
  font-weight: 500;
  color: #555;
}
.speech-setting select {
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.85rem;
}
.speech-setting-tip {
  margin: 8px 0 0;
  padding: 10px 12px;
  background: #e3f2fd;
  border-radius: 8px;
  font-size: 0.75rem;
  color: #1565c0;
  line-height: 1.5;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.speech-setting-tip i {
  margin-top: 2px;
  flex-shrink: 0;
}

.speech-setting input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: #1d9a8a;
}

/* ── Group label on card ── */
.speech-card-group-label {
  font-size: 0.7rem;
  color: #9C27B0;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 2px 0;
}

/* ── Group tabs (Atman-style paged modules) ── */
.speech-group-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px;
  margin-bottom: 8px;
  justify-content: center;
}
.speech-group-tab {
  padding: 5px 14px;
  font-size: 0.75rem;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  background: #fff;
  color: #666;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.speech-group-tab:hover {
  border-color: #9C27B0;
  color: #9C27B0;
}
.speech-group-tab.active {
  background: #9C27B0;
  color: #fff;
  border-color: #9C27B0;
}

@media (max-width: 600px) {
  .speech-group-tabs {
    gap: 4px;
    padding: 0 10px;
  }
  .speech-group-tab {
    padding: 4px 10px;
    font-size: 0.68rem;
  }
}

/* Summary */
.speech-overlay-panel--summary {
  text-align: center;
  padding: 36px 28px;
}

.speech-summary-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #e8f5e9;
  color: #4caf50;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin: 0 auto 16px;
}

.speech-summary-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #333;
  margin: 0 0 4px;
}

.speech-summary-player {
  font-size: 0.85rem;
  color: #999;
  margin: 0 0 24px;
}

.speech-summary-stats {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 28px;
}

.speech-summary-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px;
  background: #f8f9fa;
  border-radius: 12px;
  min-width: 80px;
}

.speech-summary-num {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1d9a8a;
}

.speech-summary-label {
  font-size: 0.72rem;
  color: #999;
  margin-top: 2px;
}

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

.speech-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.speech-btn--primary {
  background: linear-gradient(135deg, #1d9a8a, #6a60f0);
  color: #fff;
  box-shadow: 0 4px 12px rgba(29, 154, 138, 0.25);
}
.speech-btn--primary:hover {
  transform: translateY(-1px);
}

.speech-btn--outline {
  background: #fff;
  color: #555;
  border: 1px solid #ddd;
}
.speech-btn--outline:hover {
  background: #f8f8f8;
}

/* Guest overlay */
.speech-overlay-panel--guest {
  text-align: center;
  padding: 36px 28px;
}

/* ── Mobile responsive ── */
@media (max-width: 600px) {
  .speech-card {
    padding: 24px 20px;
    border-radius: 20px;
  }

  .speech-card-image {
    max-width: 260px;
  }

  .speech-card-word {
    font-size: 1.5rem;
  }

  .speech-card-icon-placeholder span {
    font-size: 3.5rem;
  }

  .speech-card-emoji {
    font-size: 4rem;
  }

  .speech-bottom-bar {
    padding: 10px 16px 16px;
  }

  .speech-nav-btn {
    padding: 8px 14px;
    font-size: 0.82rem;
  }

  .speech-summary-stats {
    gap: 8px;
  }

  .speech-summary-stat {
    padding: 10px 12px;
    min-width: 60px;
  }

  .speech-summary-num {
    font-size: 1.1rem;
  }

  .speech-topbar {
    padding: 10px 14px;
  }

  .speech-topbar-module {
    font-size: 0.88rem;
  }

  .speech-thumb {
    width: 52px;
  }
  .speech-thumbnail-strip {
    gap: 6px;
    padding: 8px 10px;
  }
  .speech-thumb__label {
    font-size: 0.55rem;
    max-width: 48px;
  }
}


/* ═══════════════════════════════════════════
   Thumbnail Strip — Quick card navigation
   ═══════════════════════════════════════════ */
.speech-thumbnail-strip {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}

.speech-thumbnail-strip::-webkit-scrollbar {
  height: 4px;
}

.speech-thumbnail-strip::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 2px;
}

.speech-thumb {
  flex: 0 0 auto;
  width: 64px;
  cursor: pointer;
  text-align: center;
  border-radius: 10px;
  padding: 4px;
  border: 2px solid transparent;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  background: #f8f9fa;
}

.speech-thumb:hover {
  border-color: #1d9a8a;
  transform: scale(1.05);
}

.speech-thumb--active {
  border-color: #1d9a8a;
  background: rgba(29, 154, 138, 0.08);
  box-shadow: 0 2px 8px rgba(29, 154, 138, 0.2);
}

.speech-thumb img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  background: #eee;
}

.speech-thumb__label {
  display: block;
  font-size: 0.6rem;
  color: #666;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60px;
  font-weight: 500;
  margin-left: auto;
  margin-right: auto;
}

.speech-thumb__emoji {
  font-size: 1.6rem;
  line-height: 1;
  padding: 6px 0;
}

.speech-thumb__letter {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1d9a8a;
  padding: 8px 0;
}

.speech-thumb--active .speech-thumb__label {
  color: #1d9a8a;
  font-weight: 600;
}

/* Browse button (toggle thumbnail strip) */
.speech-nav-btn--browse {
  background: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 1rem;
  color: #666;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.speech-nav-btn--browse:hover {
  background: #e8f5f3;
  color: #1d9a8a;
  border-color: #1d9a8a;
}

.speech-nav-btn--browse.speech-nav-btn--active {
  background: #1d9a8a;
  color: #fff;
  border-color: #1d9a8a;
}
