/*
 * Viirtue Qualifier Tool, Web Light mode.
 *
 * Brand tokens, header, card, and button rules are deliberately identical to
 * viirtue_app/otp/public/style.css so the two apps read as one product. Anything
 * below "Qualifier-specific" is new surface this tool needs: the phase list, the
 * live call panel, the SIP dialogue, and the audio meter.
 */
:root {
  --viirtue-purple: #673490;
  --viirtue-purple-dark: #43225e;
  --viirtue-blue: #2ec0e1;
  --hero-navy: #2d3b6b;
  --electric-purple: #7506dd;
  --off-white: #fdfbfe;
  --digital-black: #04111c;
  --grey: #777;
  --card-border: #e2d1f1;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --shadow-md: 0 4px 12px rgba(67, 34, 94, 0.08);
  --shadow-lg: 0 8px 24px rgba(67, 34, 94, 0.12);

  --ok: #1a7f37;
  --warn: #b06f00;
  --bad: #b3261e;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #fff;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  color: var(--digital-black);
  background: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header, mirrored from the viirtue.app splash ---------- */
.site-header {
  border-bottom: 1px solid var(--card-border);
}
.header-inner {
  width: min(1200px, calc(100% - 48px));
  margin: 0 auto;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}
.lockup img {
  width: auto;
  height: 30px;
  display: block;
}
.lockup .divider {
  width: 1px;
  height: 22px;
  background: var(--card-border);
}
.apps-tag {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--viirtue-purple);
}
.header-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--viirtue-purple-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-decoration: none;
  text-transform: uppercase;
}
.header-link span {
  color: var(--electric-purple);
  font-size: 16px;
  transition: transform 150ms ease;
}
.header-link:hover span {
  transform: translate(2px, -2px);
}
.header-link:focus-visible,
.lockup:focus-visible {
  outline: 3px solid rgba(46, 192, 225, 0.55);
  outline-offset: 4px;
}

.page-intro {
  width: min(1200px, calc(100% - 48px));
  margin: 0 auto;
  padding: 44px 0 28px;
  text-align: center;
}
.eyebrow {
  color: var(--viirtue-purple);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
  font-size: 13px;
  margin: 0 0 10px;
}
.page-intro h1 {
  color: var(--viirtue-purple-dark);
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0 0 14px;
}
.lede {
  color: #59616c;
  font-size: 16px;
  line-height: 1.6;
  margin: 0 auto;
  max-width: 42em;
}

.shell {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 24px 64px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  position: relative;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 50px rgba(67, 34, 94, 0.1);
  padding: 32px 36px 34px;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--viirtue-blue);
}
.card.is-live::before {
  background: linear-gradient(90deg, var(--viirtue-blue), var(--electric-purple), var(--viirtue-blue));
  background-size: 200% 100%;
  animation: sweep 2.4s linear infinite;
}
@keyframes sweep {
  to {
    background-position: -200% 0;
  }
}
.section-eyebrow {
  color: var(--viirtue-blue);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
  font-size: 12px;
  margin: 0 0 8px;
}
.card h2 {
  color: var(--viirtue-purple-dark);
  font-size: clamp(20px, 4vw, 26px);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 18px;
}

.btn-primary,
.btn-secondary {
  font: inherit;
  font-weight: 700;
  border-radius: var(--radius-pill);
  padding: 13px 24px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, box-shadow 0.15s, transform 0.15s;
}
.btn-primary {
  background: var(--electric-purple);
  color: #fff;
  box-shadow: 0 8px 20px rgba(117, 6, 221, 0.16);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 11px 24px rgba(117, 6, 221, 0.22);
}
.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
  box-shadow: none;
}
.btn-secondary {
  background: #fff;
  color: var(--viirtue-purple-dark);
  border-color: var(--viirtue-purple);
}
.btn-secondary:hover:not(:disabled) {
  background: #f7f1fc;
}
.btn-danger {
  background: #fff;
  color: var(--bad);
  border-color: var(--bad);
}
.btn-danger:hover:not(:disabled) {
  background: #fdf2f1;
}
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-danger:focus-visible {
  outline: 3px solid rgba(46, 192, 225, 0.5);
  outline-offset: 3px;
}

.note {
  font-size: 14px;
  color: var(--viirtue-purple-dark);
  margin: 12px 0 0;
}
.muted {
  color: var(--grey);
}

/*
 * Notice at collection, under the run button. Small and quiet, but readable — it is
 * the only place the page says what the test keeps, so it must not be decorative.
 */
.consent-note {
  font-size: 12px;
  line-height: 1.6;
  color: var(--grey);
  margin: 10px 0 0;
  max-width: 62ch;
}
.consent-note a {
  color: var(--grey);
  text-decoration-color: var(--card-border);
  text-underline-offset: 3px;
}
.consent-note a:hover {
  color: var(--viirtue-purple-dark);
}

/* ================= Qualifier-specific ================= */

/* ---------- Start card ---------- */
.start-row {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 18px;
}
#turnstile-widget:empty {
  display: none;
}

/* ---------- Phase list ---------- */
.phases {
  list-style: none;
  padding: 0;
  margin: 0;
}
.phases li {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 11px 0;
  border-bottom: 1px solid #f0e8f7;
}
.phases li:last-child {
  border-bottom: 0;
}
.phase-dot {
  width: 12px;
  height: 12px;
  margin-top: 5px;
  border-radius: var(--radius-pill);
  background: #e4e0ea;
  justify-self: center;
}
.phase-label {
  font-size: 15px;
  color: var(--digital-black);
}
.phase-detail {
  display: block;
  font-size: 13px;
  color: var(--grey);
  margin-top: 3px;
}
.phase-state {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--grey);
  padding-top: 3px;
}
li[data-state="running"] .phase-dot {
  background: var(--electric-purple);
  animation: pulse 1.1s ease-in-out infinite;
}
li[data-state="running"] .phase-state {
  color: var(--electric-purple);
}
li[data-state="done"] .phase-dot {
  background: var(--ok);
}
li[data-state="done"] .phase-state {
  color: var(--ok);
}
li[data-state="failed"] .phase-dot {
  background: var(--bad);
}
li[data-state="failed"] .phase-state {
  color: var(--bad);
}
li[data-state="skipped"] .phase-dot {
  background: #d8d3de;
}
@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(117, 6, 221, 0.45);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(117, 6, 221, 0);
  }
}

/* ---------- Live call panel ---------- */
.call-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.call-endpoint {
  font-size: 13px;
  color: var(--grey);
}
.call-head-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

/*
 * Call timer, styled like a desk phone's. Tabular figures so the digits do not
 * jitter as the seconds tick.
 */
.call-timer {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--viirtue-purple-dark);
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bad);
}
.live-badge::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: var(--radius-pill);
  background: var(--bad);
  animation: pulse-red 1.2s ease-in-out infinite;
}
@keyframes pulse-red {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.25;
  }
}

/* Audio meter: scope canvas over a level bar. */
.meter {
  background: #1a0f26;
  border-radius: var(--radius-md);
  padding: 14px 16px 16px;
  margin-bottom: 18px;
}
.scope {
  display: block;
  width: 100%;
  height: 84px;
}
.level-track {
  position: relative;
  height: 10px;
  margin-top: 12px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.level-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--viirtue-blue), var(--electric-purple));
  transition: width 60ms linear;
}
.level-peak {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  left: 0%;
  background: #fff;
  opacity: 0.85;
  transition: left 140ms ease-out;
}
.meter-legend {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}
.meter-legend strong {
  color: #fff;
  font-variant-numeric: tabular-nums;
}

/* SIP dialogue */
.sip-log {
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
  /* Tall enough for the full happy path — INVITE, 100, 200 OK, ACK, BYE —
     without clipping the last row and starting to scroll. */
  max-height: 232px;
  overflow-y: auto;
  border: 1px solid #f0e8f7;
  border-radius: var(--radius-md);
}
.sip-log li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid #f6f1fa;
  font-size: 13px;
}
.sip-log li:last-child {
  border-bottom: 0;
}
.sip-arrow {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--grey);
  font-size: 12px;
}
.sip-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: #f4f1f8;
  color: var(--viirtue-purple-dark);
  min-width: 62px;
  text-align: center;
}
.sip-code[data-kind="ok"] {
  background: #e7f5ec;
  color: var(--ok);
}
.sip-code[data-kind="bad"] {
  background: #fdecea;
  color: var(--bad);
}
.sip-code[data-kind="out"] {
  background: #f1e8fb;
  color: var(--electric-purple);
}
.sip-text {
  color: #59616c;
}

/* Stat tiles, live and results */
/*
 * Four metrics per row, and they MUST stay on one row on a phone.
 *
 * `auto-fit` with a minimum width wrapped the fourth tile onto a line of its
 * own, which reads as a layout bug rather than a layout choice. A fixed
 * 4-column grid keeps the set together as one readout and lets the tiles narrow
 * instead. Type scales with the viewport so the numbers still fit at the
 * squeezed width, and `min-width: 0` is what actually lets a grid item shrink
 * below its content — without it the row overflows instead of compressing.
 *
 * Labels wrap rather than truncate. "Edge RTT" reading as "Edge R…" is worse
 * than it taking two lines, and equal-height grid rows absorb the second line.
 */
.tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-bottom: 18px;
}
.tile {
  background: #faf7fd;
  border: 1px solid #f0e8f7;
  border-radius: var(--radius-md);
  padding: 8px 9px;
  min-width: 0;
}
.tile-label {
  display: block;
  font-size: clamp(8px, 2.4vw, 10px);
  line-height: 1.25;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--grey);
  margin-bottom: 3px;
  overflow-wrap: break-word;
}
.tile-value {
  font-size: clamp(13px, 4vw, 19px);
  font-weight: 750;
  color: var(--viirtue-purple-dark);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  white-space: nowrap;
}
.tile-value small {
  font-size: 0.62em;
  font-weight: 600;
  color: var(--grey);
  margin-left: 1px;
}

.call-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---------- Results ---------- */
.score {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.score-value {
  font-size: clamp(38px, 8vw, 54px);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--viirtue-purple-dark);
  font-variant-numeric: tabular-nums;
}
.score-max {
  font-size: 18px;
  font-weight: 700;
  color: var(--grey);
}
.verdict-pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: #f4f1f8;
  color: var(--viirtue-purple-dark);
}
.verdict-pill[data-tier="deskphone"] {
  background: #e7f5ec;
  color: var(--ok);
}
.verdict-pill[data-tier="webphone"] {
  background: #e6f7fb;
  color: #10707f;
}
.verdict-pill[data-tier="marginal"] {
  background: #fdf4e3;
  color: var(--warn);
}
.verdict-pill[data-tier="notready"] {
  background: #fdecea;
  color: var(--bad);
}
/* "unknown" means the run never got far enough to score the network — a Worker or
   session failure, not a verdict about the prospect. It keeps the neutral default. */
.verdict-pill[data-tier="unknown"] {
  background: #f4f1f8;
  color: var(--grey);
}

details.raw {
  margin-top: 18px;
  border-top: 1px solid #f0e8f7;
  padding-top: 14px;
}
details.raw summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--viirtue-purple);
}
details.raw pre {
  background: #faf7fd;
  border: 1px solid #f0e8f7;
  border-radius: var(--radius-md);
  padding: 14px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.5;
  margin: 12px 0 0;
}

.limits {
  font-size: 13px;
  color: var(--grey);
  line-height: 1.6;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--card-border);
}
.footer-inner {
  width: min(1200px, calc(100% - 48px));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  /* Centred to match the page intro and the cards above it. */
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--grey);
  font-size: 12px;
}
.footer-rule {
  width: 18px;
  height: 2px;
  flex: 0 0 auto;
  background: var(--viirtue-blue);
}
.legal-links {
  display: flex;
  align-items: center;
  gap: 16px;
}
.legal-links a {
  color: var(--grey);
  text-decoration-color: var(--card-border);
  text-underline-offset: 3px;
}
.legal-links a:hover {
  color: var(--viirtue-purple-dark);
}

@media (max-width: 560px) {
  .card {
    padding: 26px 22px 28px;
  }
  .header-inner,
  .page-intro,
  .footer-inner {
    width: calc(100% - 32px);
  }
  .shell {
    padding: 8px 16px 48px;
  }
}

/* Respect a reduced-motion preference: the pulses and the sweep are decoration. */
@media (prefers-reduced-motion: reduce) {
  .card.is-live::before,
  .phase-dot,
  .live-badge::before {
    animation: none;
  }
  .level-fill,
  .level-peak {
    transition: none;
  }
}

/* ---------- Call panel after the call ends ---------- */
/*
 * The panel stays on screen once the call is over. The SIP dialogue is the most
 * interesting thing on the page and it reads as a record of what happened, so it
 * is kept rather than torn down. Only the live cues are dropped.
 */
.card.is-ended::before {
  background: var(--card-border);
  animation: none;
}
.card.is-ended .live-badge {
  color: var(--grey);
}
.card.is-ended .live-badge::before {
  background: var(--grey);
  animation: none;
}
.card.is-ended .call-timer {
  color: var(--grey);
}
.card.is-ended .meter {
  opacity: 0.55;
}
.card.is-ended .call-actions {
  display: none;
}

/* ---------- Raw report actions ---------- */
.raw-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.btn-small {
  padding: 7px 16px;
  font-size: 13px;
}
.copy-status {
  font-size: 13px;
  color: var(--ok);
}
