/* Recall - styles tuned for cognitive accessibility.
   Design choices, all deliberate for a brain-injury audience:
   - One highly legible typeface (Atkinson Hyperlegible, built for low vision)
     used everywhere, so the eye never has to adjust between faces.
   - A calm, low-saturation "fog" palette. No pure white (glare) and no pure
     black (harsh edges). Plenty of luminance contrast for text.
   - Large type, wide line spacing, short line lengths, big touch targets.
   - One thing on screen at a time; one accent colour for the action that
     matters most right now.
   - Meaning is never carried by colour alone (every state has a text label).
   - Motion is minimal and fully removed under prefers-reduced-motion. */

:root {
  --bg: #e7ecec;
  --surface: #f1f4f4;
  --surface-2: #dce3e3;
  --border: #c4d0d0;

  --text: #283339;
  --text-muted: #55636b;

  --accent: #3f807a;
  --accent-strong: #2f655f;
  --accent-soft: #d9e7e4;
  --on-accent: #ffffff;

  --recording: #b9743e;     /* warm clay, not an alarming red */
  --recording-soft: #f0e1d3;
  --danger: #8f564d;

  --focus: #15506e;

  --radius: 16px;
  --gap: 20px;
  --tap: 60px;              /* minimum touch target */
  --maxw: 560px;

  --font: "Atkinson Hyperlegible", system-ui, -apple-system, Segoe UI, sans-serif;
  --fs-base: 19px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b2326;
    --surface: #232d31;
    --surface-2: #2c373b;
    --border: #3a474c;
    --text: #e6ebec;
    --text-muted: #a7b4b8;
    --accent: #5ba59c;
    --accent-strong: #74bcb3;
    --accent-soft: #2b3b39;
    --on-accent: #10201d;
    --recording: #d39256;
    --recording-soft: #3a2f24;
    --danger: #d08c83;
    --focus: #7cc4e6;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  /* respect the iOS safe areas */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 20px 80px;
}

/* --- header --- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 28px;
}
.app-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.01em;
}
.app-header .sub {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* --- typography --- */
h2 { font-size: 1.25rem; margin: 0 0 12px; font-weight: 700; }
p  { margin: 0 0 12px; }
.muted { color: var(--text-muted); }

/* --- cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: var(--gap);
}

/* --- buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: var(--tap);
  padding: 14px 20px;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
}
.btn:hover { background: var(--accent-soft); }
.btn.primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { background: transparent; }
.btn.small { width: auto; min-height: 48px; font-size: 1rem; padding: 10px 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
a.btn { text-decoration: none; }
.btn-row { display: flex; flex-direction: column; gap: 12px; }

/* visible keyboard focus everywhere */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* --- the record control: the one bold element --- */
.recorder { text-align: center; }
.record-btn {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: 4px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 8px auto 16px;
}
.record-btn .mic { width: 48px; height: 48px; }
.record-btn[data-state="recording"] {
  border-color: var(--recording);
  background: var(--recording-soft);
  color: var(--recording);
}
.record-btn[data-state="recording"] .ring {
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.06); opacity: 0.85; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
.timer {
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  min-height: 1.6em;
}

/* --- access code entry --- */
#register-code { margin-bottom: 16px; }
#register-code label { display: block; font-weight: 700; margin-bottom: 8px; }
#access-code {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 16px;
  font-family: inherit;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* --- editor / results --- */
textarea {
  width: 100%;
  min-height: 160px;
  padding: 16px;
  font-family: inherit;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
}
.result-body {
  white-space: pre-wrap;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 18px;
  margin: 12px 0 18px;
  font-size: 1.05rem;
}

/* --- history --- */
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 12px;
}
.history-item .meta { min-width: 0; }
.history-item .title { font-weight: 700; }
.history-item .kind {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 12px;
  margin-bottom: 4px;
}

/* --- status messages --- */
.status {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 12px 0;
  font-weight: 700;
}
.status.info  { background: var(--accent-soft); color: var(--accent-strong); }
.status.error { background: var(--recording-soft); color: var(--danger); }

.hidden { display: none !important; }
.center { text-align: center; }
.spacer { height: 12px; }

/* a calm full-screen busy state */
.busy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px;
  color: var(--text-muted);
}
.dots::after {
  content: "";
  animation: dots 1.4s steps(4, end) infinite;
}
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
