/* ─── Reset & base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #f4f7f4;
  --primary:  #2d6a4f;
  --accent:   #52b788;
  --glow:     #74c69d;
  --text:     #1b3a2d;
  --muted:    #6b8f7a;
  --card-bg:  #ffffff;
  --radius:   16px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ─── Animated wave background ─── */
body::before, body::after {
  content: '';
  position: fixed;
  left: -10%;
  width: 120%;
  height: 50vh;
  border-radius: 45%;
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
}
body::before {
  bottom: -120px;
  background: var(--accent);
  animation: wave 8s ease-in-out infinite;
}
body::after {
  bottom: -160px;
  background: var(--glow);
  animation: wave 10s ease-in-out infinite reverse;
}
@keyframes wave {
  0%, 100% { transform: rotate(-3deg) translateY(0); }
  50%      { transform: rotate(3deg) translateY(-30px); }
}

/* ─── Screen wrapper ─── */
.screen {
  display: none;
  min-height: 100vh;
  padding: 2rem 1.5rem;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.screen.active { display: flex; }
.screen { position: relative; z-index: 1; }

/* ─── Card ─── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 4px 24px rgba(45, 106, 79, 0.10);
  text-align: center;
}

/* ─── Typography ─── */
h1 { font-size: 1.7rem; font-weight: 700; margin-bottom: 0.75rem; color: var(--primary); }
h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: 0.5rem; color: var(--primary); }
p  { color: var(--muted); font-size: 1rem; line-height: 1.6; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: 50px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 10px rgba(45, 106, 79, 0.25);
}
.btn-primary:hover { background: #245a41; box-shadow: 0 4px 16px rgba(45, 106, 79, 0.30); }
.btn-secondary {
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 400;
  padding: 0.4rem 1rem;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-secondary:hover { color: var(--primary); }

/* ─── Mic button ─── */
#micBtn {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 2.5rem;
  border: none;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s, background 0.15s;
  box-shadow: 0 4px 20px rgba(45, 106, 79, 0.25);
  margin: 1.5rem auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
#micBtn:hover { background: #3d9e6e; transform: scale(1.04); }
#micBtn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

#micBtn.listening {
  background: var(--primary);
  animation: micPulse 1.2s ease-in-out infinite;
}

#waveform {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(116, 198, 157, 0.6); }
  50%       { box-shadow: 0 0 0 22px rgba(116, 198, 157, 0); }
}

#micBtn.shake {
  animation: micShake 0.4s ease;
}
@keyframes micShake {
  0%,100%  { transform: translateX(0); }
  20%      { transform: translateX(-7px); }
  40%      { transform: translateX(7px); }
  60%      { transform: translateX(-5px); }
  80%      { transform: translateX(5px); }
}

#micBtn.pop {
  animation: micPop 0.35s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
@keyframes micPop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* ─── Chrono ─── */
#chrono {
  font-size: 0.85rem;
  color: var(--muted);
  height: 1.4em;
  margin-top: -0.5rem;
  margin-bottom: 0.5rem;
  font-variant-numeric: tabular-nums;
}

/* ─── Interim transcript ─── */
#interimText {
  min-height: 1.6em;
  font-size: 0.95rem;
  color: #aab8b0;
  font-style: italic;
  margin: 0.5rem 0;
  transition: color 0.2s;
}

/* ─── Feedback message ─── */
#feedback {
  font-size: 1rem;
  font-weight: 600;
  min-height: 1.6em;
  color: var(--primary);
  margin: 0.25rem 0 0.75rem;
  transition: color 0.2s;
}
#feedback.error { color: #c0392b; }
#feedback.success { color: var(--primary); }

/* ─── Attempt counter ─── */
#attemptCounter {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

/* ─── Fallback text input ─── */
#fallbackSection {
  margin-top: 1.25rem;
  display: none;
}
#fallbackSection.visible { display: block; }
.fallback-notice {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}
#textInput {
  width: 100%;
  padding: 0.65rem 1rem;
  border: 2px solid #d0e4d8;
  border-radius: 10px;
  font-size: 1rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 0.75rem;
}
#textInput:focus { border-color: var(--accent); }

/* ─── Waiting screen dots ─── */
.dots-loader {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 1.5rem 0 1rem;
}
.dots-loader span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: dotPulse 1.4s ease-in-out infinite;
}
.dots-loader span:nth-child(2) { animation-delay: 0.22s; }
.dots-loader span:nth-child(3) { animation-delay: 0.44s; }
@keyframes dotPulse {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40%            { transform: scale(1);   opacity: 1;   }
}

/* ─── Unlocked screen ─── */
#screen-unlocked {
  animation: fadeSlideUp 0.55s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

.guide-wrapper {
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: 0 0 4rem;
}

/* ─── Callout / note verte ─── */
.callout-note {
  background: #d8f3dc;
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
  font-size: 0.95rem;
  color: var(--primary);
  line-height: 1.55;
}
.callout-note strong { font-weight: 700; }

/* ─── Markdown rendered content ─── */
.md-content h1 { font-size: 1.8rem; margin: 2rem 0 0.75rem; color: var(--primary); }
.md-content h2 { font-size: 1.35rem; margin: 2rem 0 0.6rem; color: var(--primary); border-bottom: 2px solid #d0e4d8; padding-bottom: 0.4rem; }
.md-content h3 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; color: var(--text); }
.md-content p  { margin: 0.75rem 0; color: var(--text); font-size: 0.97rem; }
.md-content ul, .md-content ol { margin: 0.75rem 0 0.75rem 1.5rem; color: var(--text); font-size: 0.97rem; }
.md-content li { margin: 0.35rem 0; }
.md-content strong { color: var(--primary); font-weight: 700; }
.md-content em { font-style: italic; }
.md-content hr { border: none; border-top: 2px solid #d0e4d8; margin: 2rem 0; }
.md-content blockquote {
  border-left: 4px solid var(--accent);
  background: #f0faf3;
  margin: 1rem 0;
  padding: 0.75rem 1.25rem;
  border-radius: 0 10px 10px 0;
  color: var(--primary);
  font-style: italic;
}
.md-content code {
  background: #e8f4ec;
  color: #1a4731;
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
}
.md-content pre {
  background: #1b3a2d;
  color: #b7e4c7;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.25rem 0;
  font-size: 0.875rem;
  line-height: 1.65;
}
.md-content pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: inherit;
}
.md-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* ─── Action buttons (écran déverrouillé) ─── */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.btn-action {
  width: 100%;
  justify-content: center;
  font-size: 1rem;
  padding: 0.85rem 1.5rem;
  text-decoration: none;
}
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--accent);
  font-weight: 600;
}
.btn-outline:hover { background: #f0faf3; }

/* ─── Mobile screen ─── */
#screen-mobile .card { max-width: 380px; }
#screen-mobile .emoji-big { font-size: 4rem; margin-bottom: 0.75rem; display: block; }
#screen-mobile #copyConfirm {
  font-size: 0.8rem;
  color: var(--accent);
  min-height: 1.4em;
  margin-top: 0.5rem;
}

/* ─── Reveal animation ─── */
.reveal-in {
  animation: fadeSlideUp 0.4s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

/* ─── Word displayed below mic ─── */
.word-to-say {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.03em;
  margin: 0.25rem 0 0.75rem;
}
