/* The Auditor's page. Tokens are the marketing site's (brand.css): no colour here that is not one of
   them, apart from the text colour with alpha for shadows. Radii are 12px, buttons are pills. */

:root {
  --pf-white: #FFFFFF;
  --pf-tint: #F8FAFC;
  --pf-blue50: #EFF6FF;
  --pf-blue100: #DBEAFE;
  --pf-blue: #2563EB;
  --pf-blue-deep: #1D4ED8;
  --pf-text: #0F172A;
  --pf-muted: #475569;
  --pf-border: #E2E8F0;
  --pf-border-strong: #CBD5E1;
  --pf-red: #DC2626;
  --pf-green: #16A34A;
  --sans: 'Open Sans', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .10);
  --shadow-lift: 0 2px 6px rgba(15, 23, 42, .07), 0 8px 24px rgba(15, 23, 42, .10);
  --radius: 12px;
  --radius-pill: 999px;
  --ease: 180ms ease;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--pf-tint);
  color: var(--pf-text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, p { margin: 0; }
a { color: var(--pf-blue); }
a:hover { color: var(--pf-blue-deep); }
button, input { font: inherit; color: inherit; }
/* A hidden view must stay hidden whatever display its class gives it. */
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--pf-blue); outline-offset: 2px; }
::selection { background: var(--pf-blue100); color: var(--pf-text); }
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* -- Header and footer ----------------------------------------------------- */

.top { display: flex; align-items: center; gap: 14px; padding: 14px 24px; background: var(--pf-white); border-bottom: 1px solid var(--pf-border); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--pf-text); text-decoration: none; font-weight: 700; font-size: 15px; }
.brand:hover { color: var(--pf-text); }
.brand__mark { display: block; width: 30px; height: 30px; border-radius: 8px; }
.top__tag { color: var(--pf-muted); font-size: 13px; }
.foot { display: flex; justify-content: center; gap: 16px; padding: 18px 24px 26px; color: var(--pf-muted); font-size: 12.5px; }
.foot a { color: var(--pf-muted); }
.noscript { margin: 0 auto 24px; padding: 0 24px; max-width: 640px; text-align: center; color: var(--pf-muted); }

/* -- Layout: the professor beside the form, then alone and large for the call -- */

.app {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 36px 24px 28px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, 420px);
  gap: 36px;
  align-items: start;
  align-content: start;
}
.app[data-view="call"] { grid-template-columns: minmax(0, 1fr); max-width: 940px; gap: 18px; padding-top: 28px; }

.stage { position: relative; min-width: 0; }
.stage__frame {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  max-height: calc(100vh - 150px);
  width: 100%;
  background: var(--pf-border);
  border: 1px solid var(--pf-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
}
.app[data-view="call"] .stage__frame { aspect-ratio: 16 / 9; max-height: calc(100vh - 300px); min-height: 300px; }
/* A ring that swells with his voice says who is speaking; --voice is set once a frame by app.js. */
.stage__frame::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; box-shadow: inset 0 0 0 0 var(--pf-blue); transition: box-shadow 120ms linear; }
.stage__frame[data-mode="speaking"]::after { box-shadow: inset 0 0 0 calc(2px + var(--voice, 0) * 3px) var(--pf-blue); }
.stage__face { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 24%; transform-origin: 50% 60%; animation: breathe 5s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.012); } }

.pill {
  position: absolute; top: 14px; left: 14px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--pf-white); border: 1px solid var(--pf-border); border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--pf-muted);
}
.pill__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--pf-border-strong); }
.pill[data-state="connecting"] .pill__dot { animation: pulse 1.2s ease-in-out infinite; }
.pill[data-state="listening"] .pill__dot { background: var(--pf-green); animation: pulse 1.8s ease-in-out infinite; }
.pill[data-state="speaking"] .pill__dot { background: var(--pf-blue); animation: pulse 1s ease-in-out infinite; }
.pill[data-state="muted"] .pill__dot { background: var(--pf-red); }
.pill[data-state="text"] .pill__dot { background: var(--pf-blue); }
@keyframes pulse { 50% { opacity: .35; transform: scale(.8); } }

.counter {
  position: absolute; top: 14px; right: 14px;
  padding: 5px 14px;
  background: var(--pf-blue50); border: 1px solid var(--pf-blue100); border-radius: var(--radius-pill);
  font-size: 12.5px; font-weight: 600; color: var(--pf-blue-deep); font-variant-numeric: tabular-nums;
}

.caption {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  width: min(88%, 720px); max-height: 42%; overflow-y: auto;
  padding: 12px 16px 13px;
  background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: saturate(180%) blur(12px); backdrop-filter: saturate(180%) blur(12px);
  border: 1px solid var(--pf-border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: left;
  transition: opacity var(--ease);
}
.caption.is-empty { opacity: 0; pointer-events: none; }
.caption__who { display: block; margin-bottom: 2px; font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--pf-blue); }
.caption__text { font-size: 16.5px; line-height: 1.5; }

/* -- The panel and its views ----------------------------------------------- */

.panel { min-width: 0; padding: 30px 30px 26px; background: var(--pf-white); border: 1px solid var(--pf-border); border-radius: var(--radius); box-shadow: var(--shadow); }
.app[data-view="call"] .panel { padding: 0; background: none; border: 0; box-shadow: none; }
.view h1 { font-size: clamp(24px, 3.2vw, 30px); line-height: 1.2; font-weight: 700; outline: none; }
.lede { margin-top: 10px; color: var(--pf-muted); font-size: 15.5px; }
.lede strong { color: var(--pf-text); font-weight: 600; overflow-wrap: anywhere; }
.notice { margin-top: 16px; padding: 12px 14px; background: var(--pf-blue50); border: 1px solid var(--pf-blue100); border-radius: var(--radius); font-size: 14px; color: var(--pf-text); }
form { margin: 0; }
#gate-form, #code-form { margin-top: 22px; }

.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 5px; font-size: 13.5px; font-weight: 600; }
.field input {
  display: block; width: 100%;
  padding: 11px 14px;
  font-size: 16px; line-height: 1.4;
  background: var(--pf-white); border: 1px solid var(--pf-border-strong); border-radius: var(--radius);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.field input:focus { outline: none; border-color: var(--pf-blue); box-shadow: 0 0 0 3px var(--pf-blue100); }
.field input[aria-invalid="true"] { border-color: var(--pf-red); }
.field__error, .form__status { margin-top: 6px; font-size: 13px; font-weight: 600; color: var(--pf-red); }
.field__error:empty, .form__status:empty { display: none; }
.form__status { margin: 4px 0 12px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.check { display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start; margin-top: 12px; font-size: 13.5px; line-height: 1.5; color: var(--pf-muted); }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--pf-blue); }
.check input[aria-invalid="true"] { outline: 2px solid var(--pf-red); outline-offset: 1px; }
.check + .field__error { margin-left: 30px; }
.turnstile { margin-top: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 26px;
  font-size: 15px; font-weight: 600; line-height: 1.2; text-align: center; text-decoration: none;
  color: var(--pf-white); background: var(--pf-blue);
  border: 1px solid var(--pf-blue); border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease), transform var(--ease);
}
.btn:hover { color: var(--pf-white); background: var(--pf-blue-deep); border-color: var(--pf-blue-deep); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn--block { width: 100%; margin-top: 18px; }
.btn--quiet { color: var(--pf-text); background: var(--pf-white); border-color: var(--pf-border-strong); }
.btn--quiet:hover { color: var(--pf-text); background: var(--pf-blue50); border-color: var(--pf-blue); }
.btn--quiet[disabled]:hover { background: var(--pf-white); border-color: var(--pf-border-strong); }
.btn--small { padding: 10px 18px; font-size: 14px; }
.btn--end { padding: 10px 18px; font-size: 14px; color: var(--pf-red); background: var(--pf-white); border-color: var(--pf-border-strong); }
.btn--end:hover { color: var(--pf-red); background: var(--pf-white); border-color: var(--pf-red); }
.fine { margin-top: 12px; font-size: 12.5px; line-height: 1.5; color: var(--pf-muted); }
.link { margin-top: 14px; padding: 0; background: none; border: 0; font-size: 13.5px; color: var(--pf-blue); text-decoration: underline; cursor: pointer; }
.link:hover { color: var(--pf-blue-deep); }
.link[disabled] { opacity: .45; cursor: not-allowed; }

.code-input { text-align: center; font-size: 28px !important; font-weight: 600; letter-spacing: .38em; font-variant-numeric: tabular-nums; padding-left: calc(14px + .38em) !important; }
.resend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--pf-border); }
.resend .btn { padding: 9px 18px; font-size: 14px; }
.resend .fine { margin-top: 0; }
/* Empty until a new code is sent; it takes no room meanwhile and stays in the page as a live region. */
.resend__sent:empty { margin: 0; }

/* -- The call: what you said, a note when something needs saying, the control bar -- */

.view--call { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.you { min-height: 22px; font-size: 14px; color: var(--pf-muted); overflow-wrap: anywhere; }
.you b { font-weight: 600; color: var(--pf-text); }
.call-note { max-width: 560px; font-size: 14.5px; color: var(--pf-muted); }
.call-note:empty { display: none; }
.call-note.is-problem { color: var(--pf-text); font-weight: 600; }

.bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px;
  padding: 8px 10px;
  background: var(--pf-white); border: 1px solid var(--pf-border); border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lift);
}
.round {
  position: relative; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0;
  color: var(--pf-blue); background: var(--pf-blue50);
  border: 1px solid var(--pf-blue100); border-radius: 50%;
  cursor: pointer; transition: background var(--ease), border-color var(--ease);
}
.round:hover { background: var(--pf-blue100); }
.round svg { width: 20px; height: 20px; }
.round__off { display: none; }
.round[aria-pressed="true"] { color: var(--pf-red); background: var(--pf-white); border-color: var(--pf-red); }
.round[aria-pressed="true"] .round__on { display: none; }
.round[aria-pressed="true"] .round__off { display: block; }
/* The level ring: it brightens with the visitor's own voice, so they can see they are being heard. */
.round__ring { position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--pf-green); opacity: var(--level, 0); transition: opacity 80ms linear; pointer-events: none; }
.vol { display: inline-flex; align-items: center; gap: 6px; color: var(--pf-muted); }
.vol svg { width: 18px; height: 18px; flex: none; }
.vol input { width: 92px; accent-color: var(--pf-blue); }
.say { display: inline-flex; gap: 6px; min-width: 0; }
.say input { width: 240px; min-width: 0; padding: 9px 16px; font-size: 16px; background: var(--pf-white); border: 1px solid var(--pf-border-strong); border-radius: var(--radius-pill); }
.say input:focus { outline: none; border-color: var(--pf-blue); box-shadow: 0 0 0 3px var(--pf-blue100); }
/* Typing is the whole conversation when there is no microphone, so the message box leads the bar. */
.bar--text .say { order: 0; }
.retry { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

.done__body { margin-top: 14px; font-size: 15px; color: var(--pf-muted); }
.done__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

/* -- Narrow screens: one column, captions under the picture --------------- */

@media (max-width: 860px) {
  .top { padding: 12px 16px; }
  .top__tag { display: none; }
  .app, .app[data-view="call"] { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 16px 16px 20px; }
  .stage__frame { aspect-ratio: 3 / 2; max-height: none; }
  .app[data-view="call"] .stage__frame { aspect-ratio: 1 / 1; max-height: 52vh; min-height: 0; }
  .panel { padding: 22px 20px 20px; }
  .caption { position: static; transform: none; width: auto; max-height: none; margin-top: 12px; -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--pf-white); }
  .caption.is-empty { opacity: 1; }
  .caption.is-empty .caption__text { min-height: 1.5em; }
  .caption__text { font-size: 16px; }
  .bar { border-radius: 24px; padding: 10px; }
  .say { order: 5; flex: 1 1 100%; }
  .bar--text .say { order: 0; }
  .say input { flex: 1; width: auto; }
  .vol { flex: 1; justify-content: center; }
  .vol input { width: 100%; max-width: 160px; }
}

/* -- Embedded in the marketing site's launcher panel (?embed=1): no chrome, no margins -- */

body.embed { min-height: 0; background: var(--pf-white); }
body.embed .top, body.embed .foot { display: none; }
body.embed .app, body.embed .app[data-view="call"] { display: block; max-width: none; padding: 0; }
body.embed .stage__frame { aspect-ratio: auto; height: 112px; max-height: none; min-height: 0; border: 0; border-bottom: 1px solid var(--pf-border); border-radius: 0; box-shadow: none; }
body.embed .stage__face { object-position: 50% 5%; }
body.embed .app[data-view="call"] .stage__frame { height: auto; aspect-ratio: 4 / 3; max-height: 46vh; }
body.embed .app[data-view="call"] .stage__face { object-position: 50% 24%; }
body.embed .panel, body.embed .app[data-view="call"] .panel { padding: 14px 16px 18px; border: 0; border-radius: 0; box-shadow: none; }
body.embed .view h1 { font-size: 20px; }
body.embed .lede { margin-top: 4px; font-size: 13.5px; line-height: 1.45; }
body.embed #gate-form, body.embed #code-form { margin-top: 12px; }
body.embed .field { margin-bottom: 8px; }
body.embed .field label { margin-bottom: 3px; font-size: 13px; }
body.embed .field input { padding: 8px 12px; }
body.embed .check { margin-top: 8px; font-size: 12.5px; line-height: 1.4; }
body.embed .btn--block { margin-top: 12px; padding: 12px 26px; }
body.embed .caption { position: static; transform: none; width: auto; max-height: none; margin: 12px 16px 0; -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--pf-white); }
body.embed .caption.is-empty { opacity: 1; }
body.embed .caption.is-empty .caption__text { min-height: 1.5em; }
body.embed .caption__text { font-size: 15px; }
body.embed .bar { border-radius: 24px; padding: 10px; }
body.embed .say { order: 5; flex: 1 1 100%; }
body.embed .bar--text .say { order: 0; }
body.embed .say input { flex: 1; width: auto; }
body.embed .vol { flex: 1; justify-content: center; }
body.embed .vol input { width: 100%; max-width: 160px; }

/* -- Motion is opt out: no breathing, no pulsing, no swelling ring -------- */

@media (prefers-reduced-motion: reduce) {
  .stage__face, .pill__dot { animation: none !important; }
  .stage__frame::after, .caption, .btn, .field input, .round, .round__ring { transition: none !important; }
  .stage__frame[data-mode="speaking"]::after { box-shadow: inset 0 0 0 4px var(--pf-blue); }
}
