/* ═══════════════════════════════════════════════════════════════════════════
   exam-caption.css — The narration card of the automatic exams
   (js/guide/exam-caption.js: Cover Test, H-Test, Krimsky).

   A light brand card instead of the old dark translucent box, which sat on
   the brows and target and hid the eyes on a phone. The JS chooses its place:
     [data-mode="float"]  wider screens, absolutely placed in the exam field;
                          --xc-y is the top offset of the chosen slot, and
                          changing it glides the card there.
     [data-mode="inline"] phones, in flow directly under the exam field
                          (inside the pinned card, so it stays with the eyes).
   Only the Stop button takes pointer events.
   ═══════════════════════════════════════════════════════════════════════════ */

.exam-caption {
  --xc-line: color-mix(in srgb, var(--accent) 14%, var(--surface));
  position: absolute;
  left: 50%;
  top: 0;
  z-index: 130;              /* above the docked tools (the fixation target is 120) */
  box-sizing: border-box;
  width: min(500px, calc(100% - 32px));
  padding: 12px 14px 13px;
  translate: -50% var(--xc-y, 10px);
  border: 1px solid color-mix(in srgb, var(--accent) 16%, var(--border-soft));
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
  box-shadow:
    0 1px 2px hsl(var(--shadow-color) / 0.08),
    0 16px 36px -16px hsl(var(--shadow-color) / 0.38);
  color: var(--text);
  text-align: start;
  pointer-events: none;
  opacity: 0;
  scale: 0.97;
  transition:
    opacity 200ms ease,
    scale 280ms cubic-bezier(0.2, 0.8, 0.2, 1),
    translate 420ms cubic-bezier(0.22, 1, 0.36, 1);
}
.exam-caption.is-in { opacity: 1; scale: 1; }
.exam-caption[hidden] { display: none; }

/* ── Header: live dot · AUTOMATIC EXAM · Step n of N · stage · Stop ────── */
.xc-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.xc-dot {
  flex: none;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent);
  animation: xc-live 1.8s ease-out infinite;
}
.exam-caption[data-final="true"] .xc-dot { animation: none; }
.xc-kicker {
  flex: none;
  font-size: 10.5px; font-weight: 700; line-height: 1;
  letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--accent);
}
.xc-count {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  font-size: 12px; font-weight: 600; line-height: 1.2;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.xc-stop {
  flex: none;
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 28px;
  padding: 0 11px 0 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  font: inherit; font-size: 12px; font-weight: 600; line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}
.xc-stop svg { width: 12px; height: 12px; fill: currentColor; }
.xc-stop:hover {
  color: var(--warn-strong);
  border-color: color-mix(in srgb, var(--warn) 40%, var(--border));
  background: var(--warn-tint);
}
.xc-stop:active { scale: 0.96; }
.xc-stop:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* ── Segmented progress: one segment per stage ─────────────────────────── */
.xc-steps {
  display: flex;
  gap: 3px;
  margin: 10px 0 10px;
  padding: 0;
  list-style: none;
}
.xc-steps li {
  position: relative;
  flex: 1 1 0;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--xc-line);
}
.xc-steps li[data-state="done"] { background: var(--accent); }
.xc-steps li[data-state="now"]::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  background: var(--accent);
  transform-origin: left center;
  animation: xc-fill 1.6s ease-in-out infinite alternate;
}
.exam-caption[dir="rtl"] .xc-steps li[data-state="now"]::after { transform-origin: right center; }
.exam-caption[data-final="true"] .xc-steps li[data-state="now"]::after { animation: none; }
.xc-sr {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── Body: what is happening, then why ─────────────────────────────────── */
.xc-body { display: grid; gap: 3px; }
.xc-title {
  font-size: 15px; font-weight: 700; line-height: 1.3;
  letter-spacing: -0.005em;
  color: var(--text);
}
.xc-text {
  margin: 0;
  font-size: 13.5px; line-height: 1.5;
  color: var(--text-soft);
}
.xc-why {
  margin: 6px 0 0;
  padding-top: 7px;
  border-top: 1px solid var(--border-soft);
  font-size: 12.5px; line-height: 1.5;
  color: var(--text-soft);
}
.xc-why b { margin-inline-end: 6px; font-weight: 700; color: var(--accent); }
.xc-why[hidden] { display: none; }

/* ── Phone: in flow under the eyes ─────────────────────────────────────── */
.exam-caption[data-mode="inline"] {
  position: relative;
  left: auto; top: auto;
  z-index: auto;
  width: auto;
  margin: 8px 2px 0;
  padding: 10px 12px 11px;
  translate: none;
  border-color: color-mix(in srgb, var(--accent) 18%, var(--surface));
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
  scale: 1;
  transition: opacity 200ms ease;
}
/* The live dot already says "automatic exam"; the room goes to "Step n of N · stage". */
.exam-caption[data-mode="inline"] .xc-kicker { display: none; }
.exam-caption[data-mode="inline"] .xc-steps { margin: 8px 0; }
.exam-caption[data-mode="inline"] .xc-stop { min-height: 32px; }
.exam-caption[data-mode="inline"] .xc-title { font-size: 14.5px; }
.exam-caption[data-mode="inline"] .xc-text { font-size: 13px; }
.exam-caption[data-mode="inline"] .xc-why { font-size: 12px; }

@keyframes xc-live {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
  70%  { box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent); }
}
@keyframes xc-fill {
  from { transform: scaleX(0.3); }
  to   { transform: scaleX(0.85); }
}

@media (prefers-reduced-motion: reduce) {
  .exam-caption { transition: opacity 150ms ease; scale: 1; }
  .xc-dot, .xc-steps li[data-state="now"]::after { animation: none; }
  .xc-steps li[data-state="now"]::after { transform: scaleX(0.5); }
}
