/* ============================================================
   exam-cases.css — "Cases for this test" strip + Mystery patient
   ─────────────────────────────────────────────────────────────
   PURPOSE : The compact strip under the exam toolbar
             (html-templates/exam/exam-case-strip.html, js/exam-cases/)
             and the mystery patient's diagnose dialog.
             The mystery LOCK (what it hides) is not here: it shares
             the Assess mode's leak list in css/strabismus-exam/sx-exam.css.
   LAYOUT  : one head row (title · group tabs · actions), one chip row,
             one "what to look for" line. Phones: every row scrolls
             sideways instead of wrapping, so the eyes stay high.
   ============================================================ */

.xc-strip[hidden],
html[data-exam-embed] .xc-strip { display: none !important; }

.xc-strip {
  /* No stacking context of its own: the shell's sticky header must stay on
     top when the page scrolls, and the toolbar's popovers (z 210) open over it. */
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: -6px -6px 10px;
  padding: 6px 8px 8px;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: var(--surface-sunken);
  color: var(--text);
  font-size: 12.5px;
  min-width: 0;
}
.xc-strip *, .xc-dialog * { box-sizing: border-box; }
.xc-strip[data-collapsed="true"] { padding-block: 4px; }

/* ── Head row ─────────────────────────────────────────────────── */
.xc-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.xc-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  height: 28px;
  padding: 0 8px 0 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.xc-toggle:hover { background: var(--surface); }
.xc-toggle--static { margin: 0; padding-inline-start: 8px; cursor: default; }
.xc-toggle--static:hover { background: transparent; }
.xc-toggle__chev { display: inline-flex; color: var(--text-soft); transition: transform 150ms ease; }
.xc-toggle__chev svg { width: 16px; height: 16px; }
.xc-toggle[aria-expanded="false"] .xc-toggle__chev { transform: rotate(-90deg); }
[dir="rtl"] .xc-toggle[aria-expanded="false"] .xc-toggle__chev { transform: rotate(90deg); }
.xc-toggle__text { display: inline-flex; align-items: baseline; gap: 5px; white-space: nowrap; }
.xc-toggle__k { color: var(--text-soft); font-weight: 500; }
.xc-toggle strong { font-weight: 700; }
.xc-toggle__exam { color: var(--text-soft); font-weight: 500; }
.xc-toggle__exam::before { content: "·"; margin-inline-end: 5px; }

.xc-groups {
  display: flex;
  gap: 4px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
  margin-bottom: -2px;
  /* fade the end that scrolls, so a cut-off tab reads as "more →" */
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 20px), transparent);
          mask-image: linear-gradient(to right, #000 calc(100% - 20px), transparent);
}
[dir="rtl"] .xc-groups {
  -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 20px), transparent);
          mask-image: linear-gradient(to left, #000 calc(100% - 20px), transparent);
}
.xc-groups::-webkit-scrollbar { display: none; }

.xc-group {
  position: relative;
  flex: none;
  height: 26px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.xc-group:hover { color: var(--text); background: var(--surface); }
.xc-group[aria-pressed="true"] {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px var(--shadow-color);
}
/* The current patient's group, when another group is open. */
.xc-group__dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-inline-start: 5px;
  vertical-align: middle;
  border-radius: 50%;
  background: var(--accent);
}

.xc-tools {
  display: flex;
  gap: 6px;
  flex: none;
  margin-inline-start: auto;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.xc-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 11px;
  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;
  white-space: nowrap;
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}
.xc-btn svg { width: 14px; height: 14px; flex: none; }
[dir="rtl"] .xc-note--elsewhere .xc-btn svg { transform: scaleX(-1); }
.xc-btn:hover { color: var(--text); border-color: var(--accent); }
.xc-btn--accent {
  color: var(--accent-strong);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: var(--accent-tint);
}
.xc-btn--accent:hover { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); color: var(--accent-strong); }
.xc-btn--primary {
  color: var(--on-accent);
  border-color: var(--accent);
  background: var(--accent);
}
.xc-btn--primary:hover { color: var(--on-accent); background: var(--accent-strong); border-color: var(--accent-strong); }
.xc-btn--primary:disabled { opacity: 0.45; cursor: not-allowed; }
.xc-btn--quiet { background: transparent; }
.xc-btn--sm { height: 26px; padding: 0 9px; }

.xc-strip :focus-visible,
.xc-dialog :focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ── Chip row ─────────────────────────────────────────────────── */
.xc-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.xc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* One sideways-scrolling row at every width: a group never grows the strip. */
.xc-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 5px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  padding: 1px 0;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 18px), transparent);
          mask-image: linear-gradient(to right, #000 calc(100% - 18px), transparent);
}
[dir="rtl"] .xc-chips {
  -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 18px), transparent);
          mask-image: linear-gradient(to left, #000 calc(100% - 18px), transparent);
}
.xc-chips::-webkit-scrollbar { display: none; }
.xc-chips .xc-chip { flex: none; scroll-snap-align: start; }

.xc-chip {
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}
.xc-chip:hover { border-color: var(--accent); }
.xc-chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent-strong);
  font-weight: 700;
}

/* OD | OS — the clinical abbreviations stay Latin and left-to-right. */
.xc-eye {
  display: inline-flex;
  flex: none;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  direction: ltr;
}
.xc-eye__btn {
  min-width: 36px;
  height: 24px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.xc-eye__btn[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

/* ── What to look for / belongs elsewhere ─────────────────────── */
.xc-note {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 0;
  padding: 6px 10px;
  border-radius: 10px;
  line-height: 1.45;
  color: var(--text);
}
.xc-note svg { width: 15px; height: 15px; flex: none; margin-top: 1px; color: var(--accent); }
.xc-note__k { font-weight: 700; color: var(--accent-strong); margin-inline-end: 2px; }
.xc-note__k::after { content: ":"; }
.xc-note--hint { background: var(--surface); border: 1px solid var(--border-soft); }
.xc-note--elsewhere {
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  background: var(--note-tint);
  border: 1px solid color-mix(in srgb, var(--note) 35%, transparent);
  color: var(--note-strong);
}

/* ── Mystery patient (strip body) ─────────────────────────────── */
.xc-mystery {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 2px 4px;
}
.xc-mystery__lead { margin: 0; flex: 1 1 220px; color: var(--text); }
.xc-mystery__streak {
  flex: none;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--text-soft);
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.xc-mystery__acts { display: flex; gap: 6px; flex: none; }

/* Toolbar patient button while the patient is unknown: neutral dot, no "Change". */
.exam-current[data-normal="mystery"] .exam-current__dot {
  background: var(--text-faint);
  box-shadow: 0 0 0 3px var(--surface);
}
.exam-current[data-normal="mystery"] .exam-current__change { display: none; }
.exam-current[data-normal="mystery"] { cursor: default; }

/* ── Diagnose dialog ──────────────────────────────────────────── */
.xc-dialog {
  margin: auto;            /* the site's reset zeroes the UA's centring margin */
  width: min(560px, calc(100vw - 32px));
  max-height: min(86vh, 720px);
  max-height: min(86dvh, 720px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 60px -20px var(--shadow-color), 0 2px 6px var(--shadow-color);
  overflow: hidden;
}
.xc-dialog::backdrop { background: color-mix(in srgb, var(--text) 28%, transparent); }
.xc-dialog__inner {
  display: flex;
  flex-direction: column;
  max-height: inherit;
  margin: 0;
}
.xc-dialog__head { padding: 18px 20px 10px; }
.xc-dialog__title { margin: 0; font-size: 17px; font-weight: 700; }
.xc-dialog__lead { margin: 4px 0 0; color: var(--text-soft); font-size: 13px; }
.xc-dialog__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 20px 14px;
  overflow: auto;
  overscroll-behavior: contain;
  font-size: 13px;
}
.xc-dialog__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border-soft);
}
.xc-dialog__foot .xc-btn { height: 34px; padding: 0 14px; font-size: 13px; }

.xc-dx-group { margin: 0; padding: 0; border: 0; min-width: 0; }
.xc-dx-group legend {
  padding: 0;
  margin-bottom: 6px;
  color: var(--text-soft);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.xc-dx-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.xc-dx-chips .xc-chip { white-space: normal; height: auto; min-height: 30px; padding-block: 5px; text-align: start; }
.xc-dx-eye .xc-eye__btn { min-width: 48px; height: 28px; }

.xc-verdict::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-inline-end: 8px;
  border-radius: 50%;
  vertical-align: 1px;
  background: var(--text-faint);
}
[data-verdict="correct"] .xc-verdict { color: var(--accent-strong); }
[data-verdict="correct"] .xc-verdict::before { background: var(--accent); }
:is([data-verdict="wrong"], [data-verdict="side"]) .xc-verdict { color: var(--warn-strong); }
:is([data-verdict="wrong"], [data-verdict="side"]) .xc-verdict::before { background: var(--warn); }

.xc-compare { display: grid; gap: 8px; margin: 0; }
.xc-compare > div {
  display: grid;
  grid-template-columns: minmax(90px, auto) 1fr;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface-sunken);
}
.xc-compare dt { color: var(--text-soft); font-weight: 600; }
.xc-compare dd { margin: 0; font-weight: 700; }
.xc-dialog .xc-note--hint { background: var(--accent-tint); border-color: transparent; }
.xc-dialog__streak { margin: 0; color: var(--text-soft); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ── Phones / narrow cards: rows scroll sideways, never wrap ─── */
@media (max-width: 700px) {
  .xc-strip { margin-inline: -4px; padding-inline: 6px; }
  .xc-head { gap: 4px; }
  .xc-toggle { min-width: 0; flex: 0 1 auto; overflow: hidden; }
  .xc-toggle__k { display: none; }      /* "Cases for" — the exam name says it */
  .xc-tools { flex: 0 0 auto; }
  .xc-btn span { max-width: 9.5em; overflow: hidden; text-overflow: ellipsis; }
  /* "All conditions" keeps its name for assistive tech, shows only the icon. */
  .xc-tools [data-act="all"] { padding-inline: 8px; }
  .xc-tools [data-act="all"] span {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  .xc-note { font-size: 12px; padding: 5px 8px; }
  .xc-mystery__lead { flex-basis: 100%; }
  .xc-dialog__foot { flex-wrap: wrap; }
  .xc-dialog__foot .xc-btn { flex: 1 1 auto; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .xc-toggle__chev, .xc-chip, .xc-btn { transition: none; }
}
