/* Public recorder. Self-contained: it no longer loads /theme/theme.css,
   which stays the dark mono theme of the team's own tools (admin, emulator,
   wakeword UI). Visitors are strangers and parents, so this page uses the
   brand palette from assets/brand/README.md instead:
     paper  #FFFDF8  the device shell
     ink    #12191D  the screen, exactly as measured
     teal   #1B7F9B  the glow of the eyes, the only light on the device
   plus the terracotta of the mute switch, darkened, for "recording" only. */

@font-face {
  font-family: "Quicksand";
  src: url("/static/brand/quicksand.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --paper: #FFFDF8;
  --ink: #12191D;
  --muted: #4F5B61;
  --line: #E2DED5;
  --field: #FFFFFF;
  --action: #1B7F9B;
  --action-hi: #156A82;
  --action-soft: #E3F1F5;
  --rec: #B1402B;
  --ok: #24744A;
  --warn-bg: #FBF0D9;
  --warn-line: #D9B36A;
  --error: #A8382E;
  --head: "Quicksand", "Segoe UI", system-ui, sans-serif;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--paper); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.6 var(--text);
  -webkit-text-size-adjust: 100%;
}

.page { max-width: 560px; margin: 0 auto; padding: 20px 20px 40px; }

/* ---- header / footer ---- */

.site-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 36px; }
.brand { display: block; line-height: 0; }
.brand img { width: 112px; height: auto; }
.head-actions { display: flex; align-items: center; gap: 6px; }
.head-actions button, .lang-toggle {
  font: 600 15px/1 var(--head);
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0;
  text-decoration: none;
  cursor: pointer;
}
.head-actions button:hover, .lang-toggle:hover { background: var(--action-soft); }

.site-foot { margin-top: 48px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 10px; }
.site-foot a { color: var(--ink); }
.site-foot .langs { display: inline-flex; gap: 8px; margin-left: auto; }
.site-foot .langs a { text-decoration: none; color: var(--muted); }
.site-foot .langs a.cur { color: var(--ink); font-weight: 600; text-decoration: underline; }
.site-foot p { margin: 2px 0; }

/* ---- type ---- */

h1 {
  font: 700 clamp(28px, 6vw, 36px)/1.15 var(--head);
  letter-spacing: -0.01em;
  margin: 0 0 20px;
  text-wrap: balance;
}
h2 { font: 700 21px/1.25 var(--head); margin: 32px 0 10px; }
h3 { font: 700 17px/1.3 var(--head); margin: 0 0 8px; }
p { margin: 0 0 14px; }
.lead { font-size: 18px; }
.dim { color: var(--muted); }
.small { font-size: 14px; }
.error { color: var(--error); font-weight: 600; }
.ok { color: var(--ok); font-weight: 600; }

a { color: var(--action-hi); text-underline-offset: 2px; }
a:hover { color: var(--ink); }

ul.plain { padding-left: 20px; margin: 0 0 8px; }
ul.plain li { margin-bottom: 8px; }
ul.plain li::marker { color: var(--action); }

code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
}

/* ---- the device render ---- */

.device { margin: 0 0 24px; }
.device img { display: block; width: 100%; height: auto; border-radius: 14px; background: #8f9497; }
.device figcaption { font-size: 14px; color: var(--muted); margin-top: 8px; }

/* ---- buttons and fields ---- */

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: 700 16px/1.2 var(--head);
  color: var(--ink);
  background: var(--field);
  border: 1.5px solid #C9C4B9;
  border-radius: 10px;
  padding: 12px 18px;
  margin: 0 8px 8px 0;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease-out, border-color 120ms ease-out;
}
button:hover:not(:disabled), .btn:hover { border-color: var(--ink); color: var(--ink); }
button:active:not(:disabled), .btn:active { background: var(--action-soft); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

button.accent, .btn.accent { background: var(--action); border-color: var(--action); color: #fff; }
button.accent:hover:not(:disabled), .btn.accent:hover { background: var(--action-hi); border-color: var(--action-hi); color: #fff; }
button.danger { background: var(--field); border-color: var(--error); color: var(--error); }
button.danger:hover:not(:disabled) { background: var(--error); color: #fff; }
.btn.wide { display: flex; width: 100%; margin: 16px 0 0; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
summary:focus-visible, [role=tab]:focus-visible {
  outline: 3px solid var(--action);
  outline-offset: 2px;
}

input[type=text], select {
  width: 100%;
  font: 400 16px/1.4 var(--text);
  color: var(--ink);
  background: var(--field);
  border: 1.5px solid #C9C4B9;
  border-radius: 10px;
  padding: 11px 12px;
  margin: 6px 0 12px;
}
input[type=text]:focus, select:focus { border-color: var(--action); outline: none; }
input::placeholder { color: #7A8489; }

label { color: var(--ink); }
.field-label { display: block; margin-top: 14px; font-weight: 600; font-size: 15px; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row > button, .row > .btn { margin: 0; }
.choice { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.choice .btn { margin: 0; }
h2.q { margin-top: 32px; }

label.check { display: flex; gap: 12px; align-items: flex-start; margin: 14px 0; font-size: 15px; cursor: pointer; }
label.check input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--action); }

.notice, .warn-box {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 12px 0;
}

/* ---- consent ---- */

.summary { background: var(--field); border: 1px solid var(--line); border-radius: 14px; padding: 4px 18px 6px; margin: 16px 0 20px; }
.summary h2 { margin-top: 16px; }
.summary ul.plain li { margin-bottom: 10px; }

/* ---- personal code ---- */

.code-box { margin: 20px 0; }
.code-box code {
  display: block;
  text-align: center;
  font-size: clamp(26px, 8vw, 34px);
  letter-spacing: 0.08em;
  padding: 16px;
  border-radius: 14px;
  border: 2px dashed #C9C4B9;
  user-select: all;
}

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 16px 0 24px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; font-weight: 600; }
form + form { margin-top: 4px; }

/* ---- recorder ---- */

.tabs { display: flex; gap: 6px; padding: 4px; background: #F1EEE6; border-radius: 12px; margin: 20px 0 14px; }
.tab { flex: 1; margin: 0; border: 0; background: transparent; font-size: 14px; padding: 10px 8px; line-height: 1.3; }
.tab.active { background: var(--field); box-shadow: 0 1px 2px rgba(18, 25, 29, 0.12); }
.tab:hover:not(:disabled) { border: 0; }

/* The take card holds everything for the next clip. */
.take {
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 18px 20px;
  text-align: center;
}
.take-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left; }
.take-num { font: 700 15px/1.2 var(--head); color: var(--muted); white-space: nowrap; }
.take[data-category="negative"] .take-top { display: none; }

.goal { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; list-style: none; margin: 0; padding: 0; }
.goal li { width: 12px; height: 12px; border-radius: 4px; background: #E9E5DC; }
.goal li.done { background: var(--action); }
.goal li.now { background: var(--field); box-shadow: inset 0 0 0 2px var(--action); }

.next-up {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--action-soft);
  color: var(--ink);
  font-size: 15px;
  text-align: left;
}
.next-up.done { background: #E2F1E8; }

.face { display: block; width: 120px; height: auto; margin: 18px auto 0; }
.face-screen { fill: var(--ink); }
.face-eye {
  fill: #EAF6FA;
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 180ms cubic-bezier(0.25, 1, 0.5, 1), opacity 120ms ease-out;
}
.face-count { fill: #EAF6FA; font: 700 52px var(--head); }
.take:has(.record-btn.recording) .face-eye { transform: scaleY(1.3); fill: #fff; }
.face:has(#countdown:not(:empty)) .face-eye { opacity: 0; }

.prompt { margin: 16px 0 4px; }
.say { margin: 0; font: 600 16px/1.3 var(--head); color: var(--muted); }
.say .word { display: block; font: 700 clamp(34px, 9vw, 44px)/1.1 var(--head); color: var(--ink); margin-top: 2px; }
.how { margin: 12px 0 0; }
.how strong {
  display: inline-block;
  font: 700 clamp(19px, 5vw, 22px)/1.3 var(--head);
  color: var(--ink);
  background: #FBEBC4;
  padding: 6px 14px;
  border-radius: 10px;
}
.prompt.fresh .how strong { animation: fresh 1.4s cubic-bezier(0.25, 1, 0.5, 1); }
@keyframes fresh {
  0% { transform: scale(1.12); box-shadow: 0 0 0 6px rgba(217, 179, 106, 0.55); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(217, 179, 106, 0); }
}
.hint { font-size: 14px; color: var(--muted); margin: 12px auto 0; max-width: 40ch; }
.take .warn-box { text-align: left; font-size: 15px; }

.meter { height: 6px; max-width: 120px; margin: 14px auto 0; background: #E9E5DC; border-radius: 3px; overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--ok); transition: width 60ms linear; }
.meter span.hot { background: var(--rec); }
.meter span.low { background: var(--warn-line); }

button.record-btn {
  display: flex;
  width: 100%;
  margin: 14px 0 0;
  padding: 18px;
  font-size: 19px;
  border-radius: 14px;
  background: var(--action);
  border-color: var(--action);
  color: #fff;
}
button.record-btn:hover:not(:disabled) { background: var(--action-hi); border-color: var(--action-hi); color: #fff; }
button.record-btn.recording, button.record-btn.recording:hover { background: var(--rec); border-color: var(--rec); }

/* While a clip is waiting to be sent, Send is the next step, not Record. */
.take:has(#review:not([hidden])) button.record-btn:not(.recording) {
  background: var(--field); border-color: #C9C4B9; color: var(--ink); padding: 12px; font-size: 16px;
}

#timer { font: 700 20px/1.4 var(--head); margin-top: 8px; color: var(--ink); }
#timer:empty, #status:empty { display: none; }
#status { margin-top: 8px; font-size: 15px; color: var(--muted); }

.review { margin-top: 14px; text-align: left; }
.review audio { width: 100%; margin-bottom: 10px; }
.review .row button { flex: 1; }

.options { margin: 18px 0 0; border-bottom: 1px solid var(--line); }
.options summary { cursor: pointer; padding: 12px 0; font: 600 15px var(--head); color: var(--muted); }
.options summary:hover { color: var(--ink); }
.options[open] { padding-bottom: 8px; }

.switch-row { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--muted); margin: 4px 0 8px; }
.switch-row input { margin-top: 3px; accent-color: var(--action); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.divider { display: flex; align-items: center; gap: 12px; margin: 28px 0 14px; color: var(--muted); font-size: 14px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.upload-panel label { display: block; font-size: 15px; margin-bottom: 10px; color: var(--muted); }
.upload-panel input[type=file] { width: 100%; margin-bottom: 10px; font: 15px var(--text); }
.upload-panel button { width: 100%; margin: 0; }

/* ---- progress ---- */

.progress-box { margin-top: 36px; }
.progress-box h3 { margin-bottom: 12px; }
.bar { height: 10px; background: #E9E5DC; border-radius: 5px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--action); border-radius: 5px; }
.progress-box .dim { margin: 6px 0 14px; font-size: 14px; }

/* ---- help dialog ---- */

.help-dialog {
  width: min(580px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  background: var(--paper);
  color: var(--ink);
  border: 0;
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 20px 50px rgba(18, 25, 29, 0.3);
}
.help-dialog::backdrop { background: rgba(18, 25, 29, 0.55); }
.help-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 4px; }
.help-head h2 { margin: 0; }
.help-close { font-size: 26px; line-height: 1; padding: 4px 12px; margin: 0; border: 0; background: transparent; }
.help-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 16px 0; border-bottom: 1px solid var(--line); }
.help-tabs button { margin: 0 0 -1px; border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; font-size: 14px; padding: 10px 10px 9px; }
.help-tabs button:hover:not(:disabled) { border: 0; border-bottom: 3px solid var(--line); }
.help-tabs button[aria-selected=true] { border-bottom-color: var(--action); color: var(--ink); }
.help-body { padding: 8px 20px 20px; overflow-y: auto; max-height: calc(100vh - 160px); }
.sample { margin: 12px 0; padding: 10px 12px; border-radius: 10px; background: var(--field); border: 1px solid var(--line); }
.sample audio { width: 100%; }
.sample figcaption { margin-top: 6px; font-size: 15px; }
.sample.good figcaption::before { content: "✓ "; color: var(--ok); font-weight: 700; }
.sample.bad figcaption::before { content: "✗ "; color: var(--error); font-weight: 700; }

/* ---- legal pages ---- */

.legal h1 { margin-bottom: 8px; }
.legal h2 { margin-top: 30px; font-size: 19px; }
.legal .meta { color: var(--muted); }
.legal table { border-collapse: collapse; width: 100%; margin: 8px 0 14px; font-size: 15px; }
.legal td, .legal th { text-align: left; vertical-align: top; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); }
.legal th { color: var(--muted); font-weight: 600; }

@media (max-width: 420px) {
  .page { padding: 14px 16px 32px; }
  .site-head { margin-bottom: 24px; }
  .choice .btn { width: 100%; }
  .site-foot .langs { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* Upload is the fallback, so it should not compete with Record. */
.upload-panel button.accent { background: var(--field); border-color: #C9C4B9; color: var(--ink); }
.upload-panel button.accent:hover:not(:disabled) { background: var(--field); border-color: var(--ink); color: var(--ink); }
input[type=file]::file-selector-button {
  font: 600 14px var(--head);
  color: var(--ink);
  background: #F1EEE6;
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  margin-right: 10px;
  cursor: pointer;
}
