/* Mithran's Buddy - classroom-friendly, high-contrast, mobile-first */

:root {
  --bg: #f6f3ec;
  --panel: #ffffff;
  --ink: #14211f;
  --muted: #4a5a57;
  --brand: #0f3d3e;      /* deep cedar green */
  --accent: #b6382c;     /* Haida-style red used sparingly */
  --listen: #1f8a4c;
  --think: #b7791f;
  --speak: #1d5fbf;
  --error: #b42318;
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.4;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.screen {
  min-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
}
.screen[hidden] { display: none; }

.title {
  margin: 0;
  font-size: clamp(2rem, 8vw, 3rem);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand);
}

.subtitle {
  margin: 0;
  font-size: 1.25rem;
  color: var(--muted);
  max-width: 28ch;
}

.buddy-icon {
  font-size: clamp(5rem, 28vw, 8rem);
  line-height: 1;
  width: 1.5em;
  height: 1.5em;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: 0 0 0 6px var(--brand) inset, 0 8px 24px rgba(0, 0, 0, 0.12);
  transition: transform 0.3s ease;
}
body[data-state="speaking"] .buddy-icon { transform: scale(1.06); }

.status {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 1.6rem;
  font-weight: 700;
  padding: 10px 22px;
  border-radius: 999px;
  background: var(--panel);
  border: 3px solid currentColor;
  color: var(--muted);
}
.status .dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: currentColor;
}
.status[data-state="listening"] { color: var(--listen); }
.status[data-state="listening"] .dot { animation: pulse 1.6s ease-in-out infinite; }
.status[data-state="awaiting"] { color: var(--speak); background: #eaf2ff; }
.status[data-state="awaiting"] .dot { animation: pulse 0.8s ease-in-out infinite; }
.status[data-state="followup"] { color: var(--listen); background: #e9f7ee; }
.status[data-state="followup"] .dot { animation: pulse 1.1s ease-in-out infinite; }
.status[data-state="thinking"] { color: var(--think); }
.status[data-state="speaking"] { color: var(--speak); }
.status[data-state="error"] { color: var(--error); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.75); }
}
@media (prefers-reduced-motion: reduce) {
  .status .dot { animation: none !important; }
  .buddy-icon { transition: none; }
}

.hint { margin: 0; font-size: 1.4rem; color: var(--ink); }

/* Last answered question + Buddy's answer */
.caption {
  width: 100%;
  max-width: 560px;
  background: var(--panel);
  border-radius: var(--radius);
  border: 3px solid var(--brand);
  padding: 14px 18px;
  text-align: left;
  display: grid;
  gap: 10px;
}
.caption[hidden] { display: none; }
.caption p { margin: 0; display: grid; gap: 2px; }
.caption-label {
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.caption-q span:last-child { font-size: 1.15rem; font-weight: 600; }
.caption-a span:last-child { font-size: 1.35rem; line-height: 1.35; color: var(--brand); }
.footer-label { margin: 8px 0 0; font-size: 1.1rem; font-weight: 600; color: var(--brand); }

.big-btn {
  appearance: none;
  border: 0;
  border-radius: var(--radius);
  font: inherit;
  font-size: 1.5rem;
  font-weight: 800;
  min-height: 72px;
  width: min(100%, 360px);
  padding: 16px 24px;
  cursor: pointer;
  color: #fff;
  touch-action: manipulation;
}
.big-btn.start { background: var(--brand); }
.big-btn.stop { background: var(--accent); }
.big-btn:focus-visible { outline: 4px solid #f2b705; outline-offset: 4px; }
.big-btn:disabled { background: #8a9593; cursor: not-allowed; }

.notice {
  margin: 0;
  padding: 14px 18px;
  border-radius: 12px;
  background: #fff4f2;
  border: 2px solid var(--error);
  color: var(--error);
  font-weight: 600;
  text-align: left;
  max-width: 34ch;
  list-style-position: inside;
}

/* ---------------- Debug / test mode ---------------- */
.debug {
  margin-top: 32px;
  padding: 16px;
  border-radius: 12px;
  background: #101820;
  color: #e6edf3;
  font-size: 0.95rem;
}
.debug h2, .debug h3 { margin: 0.4em 0; }
.debug a { color: #7cc4ff; }
.debug .small { font-size: 0.85rem; color: #a9b4be; }
.test-form { display: flex; gap: 8px; }
.test-form input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1rem;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #3a4652;
  background: #0b1117;
  color: inherit;
}
.debug button {
  font: inherit;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #3a4652;
  background: #1f2a35;
  color: inherit;
  cursor: pointer;
}
.samples { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.samples button { font-size: 0.85rem; padding: 6px 10px; }
.test-result {
  white-space: pre-wrap;
  background: #0b1117;
  padding: 10px;
  border-radius: 8px;
  min-height: 3em;
}
.record {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px 10px;
  margin: 0 0 10px;
  padding: 10px;
  border-radius: 8px;
  border-left: 5px solid #e5534b;
  background: #0b1117;
  word-break: break-word;
}
.record.pass { border-left-color: #3fb950; }
.record dt { color: #a9b4be; }
.record dd { margin: 0; }
