/* ===========================================================================
   Yap — design tokens
   The visual world is unchanged from the prototype. Colour values that failed
   WCAG contrast were darkened to the nearest passing tone in the same hue.
   =========================================================================== */
:root {
  --bg: #f5f3ef;
  --card: #fff;
  --text: #171717;
  --muted: #6f6b65;          /* was #77736d — 4.25:1 on --bg, now 4.77:1 */
  --line: #dedbd5;           /* decorative hairlines */
  --line-strong: #8f8a80;    /* interactive borders — 3.4:1, meets 1.4.11 */
  --dark: #171717;
  /* Accent ramp. #ff5a36 is the brand orange and stays the brand orange, but
     it only reaches 2.8:1 on the page ground and 3.1:1 behind white text —
     both below WCAG. So it is used for marks and fills that carry no text,
     and two darkened steps carry the cases that do. */
  --accent: #ff5a36;         /* graphics only: record button, pulse, icons */
  --accent-text: #ef4a29;    /* display type on light — 3.4:1 */
  --accent-fill: #d13e1c;    /* fills behind white text — 4.8:1 */
  --soft: #eeeae4;
  --danger: #b3251a;
  --danger-soft: #fdece9;
  --filler-bg: #ffe1d8;
  --filler-ink: #a3391f;
  --on-dark-muted: #c9c4bc;
  --focus: #171717;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* Browser surfaces the design still owns ------------------------------------ */
::selection { background: var(--accent); color: #fff; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 6px;
}
.video-shell :focus-visible,
.fix :focus-visible { outline-color: #fff; }
* { scrollbar-color: var(--line-strong) transparent; scrollbar-width: thin; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 3px solid var(--bg);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px; top: -60px;
  z-index: 50;
  background: var(--dark);
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 12px; }

/* Header -------------------------------------------------------------------- */
header {
  height: 72px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5%;
  gap: 12px;
}
.logo { font-weight: 900; font-size: 28px; letter-spacing: -1.5px; }
.dot { color: var(--accent-text); }
.header-right { display: flex; align-items: center; gap: 8px; }
.pill {
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  background: transparent;
  white-space: nowrap;
}
button.pill { border-color: var(--line-strong); }
button.pill:hover { color: var(--text); border-color: var(--text); }

main { width: min(1160px, 92%); margin: auto; padding: 36px 0 60px; }
.screen { display: none; }
.screen.active { display: block; }

/* Landing ------------------------------------------------------------------- */
.hero { min-height: min(68vh, 620px); padding: clamp(16px, 4vh, 48px) 0 40px; display: grid; place-items: center; }
.hero-in { max-width: 780px; text-align: center; }

/* One-time staged entrance: eyebrow, heading, paragraph, then the CTA. */
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.hero-copy > *, .hero-cta {
  animation: rise 460ms var(--ease) both;
}
.hero-copy > .eyebrow { animation-delay: 0ms; }
.hero-copy > h1       { animation-delay: 70ms; }
.hero-copy > p        { animation-delay: 140ms; }
.hero-cta             { animation-delay: 220ms; }

/* Two-column hero: the pitch on the left, the way in on the right. */
.hero-split {
  max-width: 1120px;
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: clamp(32px, 5vw, 72px);
  align-items: center;
}
.hero .hero-copy p { margin: 0; max-width: 520px; }  /* outranks .hero p's auto margins */
.hero-cta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  justify-self: end;
  width: min(100%, 320px);
}
/* The outputs, listed plainly. Gives the column weight and answers the
   question the headline raises: feedback on what, exactly? */
.hero-returns {
  list-style: none;
  margin: 14px 0 0;
  padding: 18px 0 0;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 9px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}
.hero-returns li { position: relative; padding-left: 16px; }
.hero-returns li::before {
  content: ""; position: absolute; left: 0; top: 0.55em;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
.hero-cta .btn { width: 100%; text-align: center; }
.btn.big { padding: 19px 24px; font-size: 17px; }
.hero-note {
  margin: 14px 0 0 !important;
  font-size: 12px !important;
  color: var(--muted);
  text-align: left;
}
.eyebrow {
  display: inline-flex; gap: 8px; align-items: center;
  border: 1px solid var(--line);
  padding: 9px 13px; border-radius: 999px;
  font-size: 12px; color: var(--muted);
}
.pulse { width: 7px; height: 7px; background: var(--accent); border-radius: 50%; }
h1 {
  font-size: clamp(42px, 5.2vw, 70px);
  line-height: 1.02; letter-spacing: -2.8px;
  margin: 22px 0 18px;
  text-wrap: balance;
}
h1 span { color: var(--accent-text); }
.hero p {
  font-size: 18px; line-height: 1.6; color: var(--muted);
  max-width: 540px; margin: 0 auto 28px;
}
.actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

/* Buttons ------------------------------------------------------------------- */
button { font: inherit; cursor: pointer; }
.btn {
  border: 0; border-radius: 14px;
  padding: 15px 22px; font-weight: 700;
  transition: transform 0.18s var(--ease), background-color 0.18s var(--ease),
    border-color 0.18s var(--ease), color 0.18s var(--ease), opacity 0.18s var(--ease);
}
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) { transform: translateY(-1px); }
}
.btn:active:not(:disabled) { transform: translateY(0) scale(0.96); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; transform: none; }
.primary { background: var(--dark); color: #fff; }
.primary:hover:not(:disabled) { background: #000; }
.accent { background: var(--accent-fill); color: #fff; }
.accent:hover:not(:disabled) { background: #b93615; }
.secondary { background: #fff; border: 1px solid var(--line-strong); color: var(--text); }
.secondary:hover:not(:disabled) { border-color: var(--text); background: var(--soft); }
.btn.small { padding: 11px 15px; font-size: 14px; border-radius: 11px; }

.heading { text-align: center; margin: 20px auto 36px; }
.heading h2 { font-size: clamp(34px, 5vw, 52px); letter-spacing: -2px; margin: 0 0 10px; }
.heading p { color: var(--muted); }

/* Mode grid ----------------------------------------------------------------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.mode {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; padding: 22px; text-align: left; min-height: 145px;
  color: var(--text);
  transition: transform 0.22s var(--ease), border-color 0.22s var(--ease),
    box-shadow 0.22s var(--ease);
}
@media (hover: hover) and (pointer: fine) {
  .mode:hover {
    border-color: #222;
    transform: translateY(-2px);
    box-shadow: 0 10px 24px -14px rgba(23, 23, 23, 0.35);
  }
}
.mode:active { transform: scale(0.98); }
.icon { margin-bottom: 16px; color: var(--accent); display: block; }
.icon svg { display: block; }
.mode h3 { margin: 0 0 5px; }
.mode p { font-size: 13px; color: var(--muted); margin: 0; }

/* Prompt -------------------------------------------------------------------- */
.wrap { max-width: 820px; margin: 40px auto; }
.back {
  border: 0; background: transparent; color: var(--muted);
  padding: 4px 2px; margin-bottom: 20px; border-radius: 8px;
}
.back:hover { color: var(--text); }
.prompt {
  background: #fff; border: 1px solid var(--line);
  border-radius: 28px; padding: clamp(28px, 6vw, 58px);
}
.meta { font-size: 12px; color: var(--muted); margin-bottom: 14px; letter-spacing: 0.04em; }
/* Topic chips: same control as the duration toggles, one size down. */
.topics { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 24px; }
.topics .time { font-size: 12px; padding: 7px 11px; }
.prompt h2 {
  font-size: clamp(32px, 5vw, 58px); line-height: 1.08;
  letter-spacing: -2.5px; margin: 0 0 34px; text-wrap: balance;
}
.prompt-bottom {
  display: flex; justify-content: space-between; align-items: center;
  gap: 15px; flex-wrap: wrap;
}
.times { display: flex; gap: 6px; }
fieldset.times-set { border: 0; padding: 0; margin: 0; }
fieldset.times-set legend { font-size: 12px; color: var(--muted); padding: 0 0 7px; }
.time {
  border: 1px solid var(--line-strong); background: var(--bg);
  border-radius: 9px; padding: 9px 12px; font-size: 13px;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.18s var(--ease), color 0.18s var(--ease),
    border-color 0.18s var(--ease);
}
.time:hover { border-color: var(--text); }
.time[aria-pressed="true"] { background: var(--dark); color: #fff; border-color: var(--dark); }

.choices { display: flex; gap: 26px; flex-wrap: wrap; }

/* Recorder ------------------------------------------------------------------ */
.rec { max-width: 900px; margin: auto; }
.rec-top { display: flex; justify-content: space-between; margin-bottom: 15px; align-items: center; gap: 12px; }
.status { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.rdot { width: 9px; height: 9px; border-radius: 50%; background: #aaa; flex: none; }
.rdot.live { background: #df4c40; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.3; } }
.timer { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.timer.warn { color: var(--danger); }

.video-shell {
  position: relative; aspect-ratio: 16/9; background: #1b1b1b;
  border-radius: 28px; overflow: hidden;
}
.camera-preview {
  width: 100%; height: 100%; object-fit: cover;
  transform: scaleX(-1); display: none;
}
.camera-preview.live { display: block; }
.overlay {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 45px 25px 25px; color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
  font-size: 15px; line-height: 1.4;
  display: none;
}
.overlay.show { display: block; }

/* Voice-only stage. Occupies the same frame the camera would, so the screen
   reports that the microphone is working rather than showing a dead box. */
.audio-stage {
  position: absolute; inset: 0;
  display: grid; place-content: center; justify-items: center;
  gap: 26px; padding: 24px; background: #1b1b1b;
}
.audio-stage[hidden] { display: none; }
.meter {
  display: flex; align-items: flex-end; gap: 5px;
  height: 90px; width: min(320px, 62vw);
}
.meter i {
  flex: 1; min-height: 4px; height: 4px;
  background: var(--accent); border-radius: 99px;
  transform-origin: bottom;
  /* Height is written every animation frame by audioMeter.js, which does its
     own rise/fall smoothing. A CSS transition on height would fight that and
     thrash layout, so only opacity is transitioned here. */
  transition: opacity 90ms linear;
  opacity: 0.35;
  will-change: height;
}
.meter i.on { opacity: 1; }
.audio-hint { margin: 0; color: #b8b3ac; font-size: 14px; text-align: center; }

/* Permission / error gate inside the camera frame */
.gate {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: clamp(20px, 5vw, 40px);
  text-align: center; color: #efece7;
  background: #1b1b1b;
  /* The frame has a fixed aspect ratio, so tall content must scroll rather
     than push the buttons out of sight. */
  overflow-y: auto;
  overscroll-behavior: contain;
}
.gate[hidden] { display: none; }
.gate-in { max-width: 460px; }
.gate-mark { color: var(--accent); margin-bottom: 18px; display: inline-block; }
.gate h3 { margin: 0 0 10px; font-size: clamp(19px, 2.6vw, 24px); letter-spacing: -0.6px; }
.gate p { margin: 0 0 22px; font-size: 14px; line-height: 1.6; color: #b8b3ac; }
.gate .btn.secondary { background: #fff; border-color: #fff; }
.gate-steps {
  margin: 0 0 22px; padding: 0; list-style: none;
  font-size: 13px; line-height: 1.7; color: #b8b3ac; text-align: left;
}
.gate-steps li { padding-left: 18px; position: relative; }
.gate-steps li::before {
  content: ""; position: absolute; left: 0; top: 9px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
}
.gate-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.rec-controls { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 20px; }
.record {
  width: 68px; height: 68px; border-radius: 50%;
  border: 7px solid var(--dark); background: var(--accent);
  transition: transform 0.22s var(--ease), border-radius 0.22s var(--ease),
    background-color 0.22s var(--ease), opacity 0.2s var(--ease);
}
.record:disabled { opacity: 0.35; cursor: not-allowed; }
.record.live { background: #df4c40; border-radius: 18px; transform: scale(0.9); }
.note { text-align: center; color: var(--muted); font-size: 13px; margin: 14px 0 0; }
.privacy-line { text-align: center; color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.linkish {
  background: none; border: 0; padding: 0; color: var(--muted);
  text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: var(--line-strong); font-size: inherit;
}
.linkish:hover { color: var(--text); text-decoration-color: currentColor; }

.countdown {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.9); color: #fff;
  display: none; place-items: center; z-index: 9;
}
.countdown.show { display: grid; }
.countdown div { font-size: min(30vw, 180px); font-weight: 900; font-variant-numeric: tabular-nums; }

/* Analysing ----------------------------------------------------------------- */
.analysis { min-height: 65vh; display: grid; place-items: center; text-align: center; }
.analysis h2 { letter-spacing: -1px; }
.spin {
  width: 52px; height: 52px; border: 3px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%;
  margin: auto; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.stage { color: var(--muted); min-height: 1.5em; }
.stage-list {
  list-style: none; margin: 26px auto 0; padding: 0;
  max-width: 300px; text-align: left;
  font-size: 13px; color: var(--muted);
}
.stage-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 0; opacity: 0.4;
  transition: opacity 0.3s var(--ease), color 0.3s var(--ease);
}
.stage-list li[data-state="active"] { opacity: 1; color: var(--text); font-weight: 600; }
.stage-list li[data-state="done"] { opacity: 1; }
.stage-tick { width: 14px; height: 14px; flex: none; color: var(--accent); }
.stage-list li[data-state="pending"] .stage-tick { color: var(--line-strong); }

/* Results ------------------------------------------------------------------- */
.results { max-width: 950px; margin: auto; }
.result-hero { text-align: center; padding: 20px 0 45px; }
.label { font-size: 12px; color: var(--muted); letter-spacing: 0.06em; }
.score {
  font-size: clamp(80px, 14vw, 150px); font-weight: 900;
  letter-spacing: -7px; line-height: 0.9; margin: 14px;
  font-variant-numeric: tabular-nums;
}
.score span { color: var(--accent-text); }
.message { color: var(--muted); max-width: 560px; margin: auto; line-height: 1.5; }

.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 22px; padding: 24px; }
.card.full { grid-column: 1/-1; }
.card h3 { margin: 0 0 18px; }
.metric { margin-bottom: 16px; }
.metric:last-child { margin-bottom: 0; }
.metric-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 7px; }
.metric-row b { font-variant-numeric: tabular-nums; }
.progress { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--dark); border-radius: 99px; }
.feedback { font-size: 14px; color: var(--muted); line-height: 1.65; }
.feedback:last-child { margin-bottom: 0; }
.feedback b { color: var(--text); }
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  font-size: 12px; border: 1px solid var(--line); padding: 7px 9px;
  border-radius: 999px; color: var(--muted); font-variant-numeric: tabular-nums;
}
button.chip {
  border-color: var(--line-strong); background: #fff;
  transition: border-color 0.18s var(--ease), color 0.18s var(--ease);
}
button.chip:hover { border-color: var(--text); color: var(--text); }
.chip .chip-time { color: var(--text); font-weight: 700; }
.big-number { font-size: 36px; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -1.2px; }
.big-number small { font-size: 14px; color: var(--muted); font-weight: 400; letter-spacing: 0; }
.transcript {
  background: var(--bg); padding: 18px; border-radius: 14px;
  line-height: 1.8; color: #45413d; max-height: 340px; overflow-y: auto;
}
.transcript-word { border-radius: 4px; padding: 1px 0; }
button.transcript-word {
  background: none; border: 0; font: inherit; color: inherit;
  padding: 1px 2px; cursor: pointer;
}
button.transcript-word:hover { background: var(--soft); }
.filler { background: var(--filler-bg); color: var(--filler-ink); padding: 2px 5px; border-radius: 5px; font-weight: 600; }
.quote { letter-spacing: -0.8px; font-size: 22px; line-height: 1.35; margin: 14px 0; text-wrap: pretty; }
.fix { background: var(--dark); color: #fff; border-radius: 22px; padding: 28px; }
.fix h3 { margin: 0; }
.fix h2 { font-size: 28px; letter-spacing: -1px; text-wrap: balance; }
.fix p { color: var(--on-dark-muted); line-height: 1.6; }
.result-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 30px; }

.playback { width: 100%; border-radius: 14px; background: #1b1b1b; display: block; aspect-ratio: 16/9; }
.playback-audio { width: 100%; display: block; }
.playback-audio[hidden] { display: none; }
.playback[hidden] { display: none; }
.marker-row { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 14px; }
.notice {
  font-size: 13px; color: var(--muted); line-height: 1.6;
  border: 1px dashed var(--line-strong); border-radius: 14px; padding: 14px;
}

/* Footer --------------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 20px;
  padding: 26px 5% 34px;
  text-align: center;
}
.site-footer p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.site-footer a {
  color: var(--text);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line-strong);
}
.site-footer a:hover { text-decoration-color: currentColor; }
.footer-sep { color: var(--line-strong); }

/* Error screen -------------------------------------------------------------- */
.error-wrap { max-width: 560px; margin: 60px auto; text-align: center; }
.error-card {
  background: #fff; border: 1px solid var(--line);
  border-radius: 24px; padding: clamp(28px, 5vw, 44px);
}
.error-mark { color: var(--danger); margin-bottom: 16px; display: inline-block; }
.error-card h2 { margin: 0 0 12px; font-size: 26px; letter-spacing: -1px; }
.error-card p { color: var(--muted); line-height: 1.6; margin: 0 0 24px; }
.error-hint {
  background: var(--danger-soft); color: #7a1a12; border-radius: 12px;
  padding: 12px 14px; font-size: 13px; line-height: 1.6;
  text-align: left; margin: 0 0 22px;
}

/* Privacy dialog ------------------------------------------------------------ */
dialog.sheet {
  border: 1px solid var(--line); border-radius: 24px;
  padding: clamp(24px, 5vw, 36px); max-width: 540px; width: calc(100% - 32px);
  background: #fff; color: var(--text);
}
dialog.sheet::backdrop { background: rgba(23, 23, 23, 0.55); }
dialog.sheet h2 { margin: 0 0 6px; font-size: 26px; letter-spacing: -1.2px; }
dialog.sheet h3 { margin: 22px 0 6px; font-size: 15px; }
dialog.sheet p { color: var(--muted); line-height: 1.65; font-size: 14px; margin: 0; }
.sheet-actions { margin-top: 28px; display: flex; justify-content: flex-end; }

/* Responsive ---------------------------------------------------------------- */
.video-shell.voice-only { aspect-ratio: 21/9; }

/* Below ~960px the two hero columns fight for width; stack them. */
@media (max-width: 960px) {
  .hero-split { grid-template-columns: 1fr; gap: 28px; }
  .hero-cta { justify-self: start; width: min(100%, 360px); }
}

@media (max-width: 700px) {
  .hero-cta { width: 100%; }
  .choices { gap: 18px; }
  .video-shell.voice-only { aspect-ratio: 4/3; }
  .grid, .result-grid { grid-template-columns: 1fr; }
  .card.full { grid-column: auto; }
  h1 { letter-spacing: -2px; }
  main { padding: 24px 0 48px; }
  .prompt-bottom { align-items: flex-start; flex-direction: column; }
  .prompt-bottom .actions { width: 100%; }
  .prompt-bottom .actions .btn { flex: 1 1 auto; }
  .video-shell { aspect-ratio: 3/4; border-radius: 22px; }
  .rec-controls { gap: 10px; }
  .rec-controls .btn { padding: 15px 16px; }
  .record { width: 64px; height: 64px; }
  .result-actions .btn { flex: 1 1 auto; }
}

@media (max-width: 380px) {
  header { padding: 0 4%; }
  .pill { font-size: 11px; padding: 7px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .rdot.live { animation: none; opacity: 1; }
}
