/* Factory reset page: mobile first, light and dark. Colours as tokens; contrast >= 4.5:1 for text. */
:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #5d5d63;
  --line: #d8d8de;
  --accent: #0a5ec8;       /* buttons (white text 6:1), links, the microphone */
  --accent-text: #ffffff;
  --accent-soft: #dce9fb;
  --ok: #1b7f35;
  --attention: #8a4b00;
  --attention-bg: #fff2dc;
  --lock: #3a3a40;
  --lock-key: #6b6b73;
  --lock-led: #3ccf63;
  --phone: #1c1c1e;
  --phone-screen: #4a5a72;
  --wave: #0a5ec8;
  --placeholder: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #f2f2f7;
    --muted: #a1a1a8;
    --line: #3a3a3c;
    --accent: #0a5ec8;
    --accent-text: #ffffff;
    --accent-soft: #15325a;
    --ok: #3ccf63;
    --attention: #ffc061;
    --attention-bg: #3a2a10;
    --lock: #5a5a62;
    --lock-key: #8e8e96;
    --phone: #d8d8de;
    --phone-screen: #3d4f6b;
    --wave: #6ea8ff;
    --placeholder: #ff7a70;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* also for elements given a display below (buttons, bars) */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
main { max-width: 560px; margin: 0 auto; }
.app-title { margin: 0 0 4px; font-size: 14px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 12px; }
h1:focus { outline: none; }
h2 { font-size: 17px; margin: 22px 0 6px; }
p { margin: 10px 0; }
.small { font-size: 14px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* wording still to be supplied by product management (strings.js) */
.placeholder { outline: 2px dashed var(--placeholder); outline-offset: 2px; color: var(--placeholder); }

.steps, .tips { margin: 6px 0 12px; padding-left: 1.4em; }
.steps li, .tips li { margin: 6px 0; }
.note { background: var(--card); border-radius: 12px; padding: 12px 14px; }
.attention { background: var(--attention-bg); color: var(--attention); border-radius: 12px; padding: 12px 14px; font-weight: 600; }

button {
  display: block; width: 100%; min-height: 52px; margin: 14px 0 0; padding: 12px 20px;
  font: inherit; font-weight: 600; border-radius: 14px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button.primary { background: var(--accent); color: var(--accent-text); border: 0; }
button.secondary { background: var(--card); color: var(--text); border: 2px solid var(--line); }
button:focus-visible { outline: 3px solid var(--wave); outline-offset: 3px; }
button:active { transform: scale(.99); }

/* ---- account: who is signed in, sign out ---- */
.account { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 8px; color: var(--muted); }
.account > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.link {
  display: inline-block; flex: none; width: auto; min-height: 44px; margin: 0; padding: 0 4px;
  background: none; border: 0; color: var(--wave); font-weight: 600;
}

/* ---- listening ---- */
.phase { font-weight: 600; font-size: 19px; min-height: 2.9em; margin: 4px 0; }
.progress, .level-bar { display: block; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.progress > i, .level-bar > i {
  display: block; height: 100%; width: 100%; background: var(--accent);
  transform: scaleX(0); transform-origin: left center; transition: transform .1s linear;
}
.level { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
.level-bar { flex: 1; }
.level-bar > i { background: var(--ok); }

/* ---- submitting ---- */
.spinner {
  width: 48px; height: 48px; margin: 28px auto; border-radius: 50%;
  border: 5px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- success: the code, grouped 4 + 4 ---- */
.code {
  display: flex; justify-content: center; gap: .45em; flex-wrap: wrap; margin: 18px 0 6px;
  font: 700 clamp(42px, 14vw, 64px)/1.1 ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-variant-numeric: tabular-nums; letter-spacing: .06em; color: var(--text);
  background: var(--card); border-radius: 16px; padding: 18px 8px;
  user-select: all; -webkit-user-select: all;
}

/* ---- illustration ---- */
.illus { margin: 8px 0; }
.illus svg { display: block; width: 100%; height: auto; max-height: 240px; }
.lock-body { fill: var(--lock); }
.key { fill: var(--lock-key); }
.lock-led { fill: var(--lock-led); }
.phone-body { fill: var(--phone); }
.phone-screen { fill: var(--phone-screen); }
.phone-port { fill: var(--muted); }
.mic { fill: var(--accent); }
.mic-ring { fill: none; stroke: var(--wave); stroke-width: 2; }
.mic-lead { fill: none; stroke: var(--wave); stroke-width: 1.5; }
.mic-label, .near-label { fill: var(--text); font-size: 15px; font-weight: 600; font-family: inherit; }
.wave { fill: none; stroke: var(--wave); stroke-width: 3.5; stroke-linecap: round; opacity: 0; }
.near-bracket { fill: none; stroke: var(--text); stroke-width: 1.5; }
.near { opacity: 0; }

/* the phone comes in from the right, holds a few cm in front of the keypad, and goes back; the tones radiate */
.phone { animation: approach 5s ease-in-out infinite; }
.near { animation: near 5s ease-in-out infinite; }
.wave { animation: wave 1.5s ease-out infinite; }
.w2 { animation-delay: .25s; }
.w3 { animation-delay: .5s; }
@keyframes approach {
  0%, 10% { transform: translateX(52px); }
  42%, 86% { transform: translateX(0); }
  100% { transform: translateX(52px); }
}
@keyframes near {
  0%, 40% { opacity: 0; }
  48%, 82% { opacity: 1; }
  90%, 100% { opacity: 0; }
}
@keyframes wave {
  0% { opacity: 0; }
  25% { opacity: 1; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  /* static: the phone at its close position, the tones and the distance shown */
  .phone, .near, .wave, .spinner { animation: none; }
  .wave, .near { opacity: 1; }
  .w2 { opacity: .7; }
  .w3 { opacity: .4; }
  .progress > i, .level-bar > i { transition: none; }
}
