/* ==========================================================================
   exam-history.css — "My exams" (js/exam-history/ui/history-view.js).
   Tool-agnostic: reads the page's calm tokens (retinoscopy-theme.css:
   --surface, --surface-sunken, --border(-soft), --text(-soft/-faint),
   --accent(-strong), --ret-ok/with/info-*) with neutral fallbacks.
   Logical properties throughout (Arabic RTL); no horizontal scroll at 360px.
   ========================================================================== */

.exh {
  --exh-surface: var(--surface, #fff);
  --exh-sunken: var(--surface-sunken, #f3f6f5);
  --exh-border: var(--border, #d3dbd9);
  --exh-border-soft: var(--border-soft, #e2e8e6);
  --exh-text: var(--text, #15201e);
  --exh-soft: var(--text-soft, #44514e);
  --exh-faint: var(--text-faint, #63706d);
  --exh-accent: var(--accent, #2f7d6d);
  --exh-accent-strong: var(--accent-strong, #22604f);
  display: block;
  container: exh / inline-size;
  min-inline-size: 0;
  color: var(--exh-text);
}
.exh *, .exh *::before, .exh *::after { box-sizing: border-box; }

.exh-sr {
  position: absolute !important;
  inline-size: 1px; block-size: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap;
}

.exh-lead { margin: 0 0 12px; font-size: 13px; line-height: 1.5; color: var(--exh-soft); }

/* ── Toolbar: filter tabs + level ────────────────────────────────────── */
.exh-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-block-end: 12px;
}
.exh-tabs {
  display: flex; flex: 1 1 auto; gap: 4px; min-inline-size: 0;
  padding: 4px; border-radius: 12px; background: var(--exh-sunken);
}
.exh-tab {
  display: inline-flex; flex: 1 1 0; align-items: center; justify-content: center; gap: 6px;
  min-block-size: 44px; min-inline-size: 0; padding-inline: 10px;
  border: 1px solid transparent; border-radius: 9px;
  background: transparent; color: var(--exh-soft);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.exh-tab:hover { color: var(--exh-text); }
.exh-tab[aria-selected="true"] {
  background: var(--exh-surface); border-color: var(--exh-border-soft); color: var(--exh-accent-strong);
  box-shadow: var(--ret-shadow-sm, 0 1px 2px rgba(18, 32, 30, 0.05));
}
.exh-tab__n {
  min-inline-size: 22px; padding: 1px 6px; border-radius: 999px;
  background: var(--exh-sunken); color: var(--exh-soft);
  font-size: 12px; font-variant-numeric: tabular-nums; text-align: center;
}
.exh-tab[aria-selected="true"] .exh-tab__n { background: var(--ret-info-tint, #e7eef5); color: var(--ret-info-ink, #2f5275); }
.exh-level { flex: 0 1 auto; min-inline-size: 0; }
.exh-level select {
  min-block-size: 44px; max-inline-size: 100%; padding-inline: 12px 32px;
  border: 1px solid var(--exh-border); border-radius: 12px;
  background-color: var(--exh-surface); color: var(--exh-text);
  font: inherit; font-size: 14px;
}

/* ── Notice (pin limit / offline) ────────────────────────────────────── */
.exh-notice {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 0 0 12px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--ret-with, #b48a3c);
  background: var(--ret-with-tint, #f7f0e2); color: var(--ret-with-ink, #6e4c10);
  font-size: 13px; line-height: 1.45;
}
.exh-notice svg { flex: none; margin-block-start: 2px; }

/* ── List + rows ─────────────────────────────────────────────────────── */
.exh-results { min-inline-size: 0; }
.exh-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.exh-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "score body" "actions actions";
  align-items: center; gap: 10px 12px;
  padding: 12px; border: 1px solid var(--exh-border-soft); border-radius: 14px;
  background: var(--exh-surface);
}
.exh-row[data-pinned="true"] { border-color: var(--ret-info, #56789c); }
@container exh (min-width: 620px) {
  .exh-row { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "score body actions"; }
}
.exh-score {
  grid-area: score;
  display: grid; place-items: center; align-content: center;
  inline-size: 56px; block-size: 56px; border-radius: 14px;
  background: var(--exh-sunken); color: var(--exh-text);
  font-variant-numeric: tabular-nums; line-height: 1;
}
.exh-score b { font-size: 20px; font-weight: 700; }
.exh-score span { margin-block-start: 3px; font-size: 12px; font-weight: 600; color: var(--exh-soft); }
.exh-row__body { grid-area: body; min-inline-size: 0; }
.exh-row__title { margin: 0; font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }
.exh-row__meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  margin: 4px 0 0; font-size: 13px; color: var(--exh-soft);
}
.exh-xp { font-weight: 600; color: var(--ret-ok-ink, #22603f); }
.exh-row__badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; }
.exh-row__actions { grid-area: actions; display: flex; flex-wrap: wrap; gap: 6px; min-inline-size: 0; }
.exh-row__actions .exh-btn { flex: 1 1 auto; }
@container exh (min-width: 620px) { .exh-row__actions .exh-btn { flex: 0 0 auto; } }

.exh-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  background: var(--exh-sunken); color: var(--exh-soft);
  font-size: 12px; font-weight: 600;
}
.exh-badge[data-tone="warn"] { background: var(--ret-with-tint, #f7f0e2); color: var(--ret-with-ink, #6e4c10); }
.exh-badge[data-tone="pin"] { background: var(--ret-info-tint, #e7eef5); color: var(--ret-info-ink, #2f5275); }

/* ── Buttons (44px targets) ──────────────────────────────────────────── */
.exh-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-block-size: 44px; min-inline-size: 44px; padding: 8px 14px;
  border: 1px solid var(--exh-border); border-radius: 12px;
  background: var(--exh-surface); color: var(--exh-text);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.exh-btn:hover:not(:disabled) { border-color: var(--exh-accent); color: var(--exh-accent-strong); }
.exh-btn--primary { background: var(--exh-accent); border-color: var(--exh-accent); color: #fff; }
.exh-btn--primary:hover:not(:disabled) { background: var(--exh-accent-strong); border-color: var(--exh-accent-strong); color: #fff; }
.exh-btn--quiet { background: transparent; border-color: var(--exh-border-soft); color: var(--exh-soft); }
.exh-btn[aria-pressed="true"] { border-color: var(--ret-info, #56789c); color: var(--ret-info-ink, #2f5275); }
.exh-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.exh-btn svg { flex: none; }
.exh-more { display: flex; inline-size: 100%; margin-block-start: 10px; }

.exh-tab:focus-visible,
.exh-btn:focus-visible,
.exh-level select:focus-visible {
  outline: 2px solid var(--exh-accent);
  outline-offset: 2px;
}

/* The back arrow icon points "back" in RTL; mirror it for LTR. */
html:not([dir=rtl]) [data-exh="back"] svg { transform: scaleX(-1); }

/* ── Skeleton ────────────────────────────────────────────────────────── */
.exh-row--skeleton { grid-template-columns: 56px minmax(0, 1fr); grid-template-areas: "a b"; min-block-size: 82px; }
.exh-row--skeleton i {
  display: block; block-size: 56px; border-radius: 14px;
  background: linear-gradient(90deg, var(--exh-sunken) 0%, var(--exh-border-soft) 50%, var(--exh-sunken) 100%);
  background-size: 200% 100%;
  animation: exh-shimmer 1.4s ease-in-out infinite;
}
.exh-row--skeleton i:last-child { block-size: 16px; inline-size: 70%; border-radius: 6px; }
@keyframes exh-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ── Empty / error ───────────────────────────────────────────────────── */
.exh-empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  margin: 0; padding: 28px 16px; border: 1px dashed var(--exh-border); border-radius: 14px;
  color: var(--exh-soft); font-size: 14px; line-height: 1.5; text-align: center;
}
.exh-empty svg { color: var(--exh-faint); }

/* ── Detail ──────────────────────────────────────────────────────────── */
.exh-detail__head {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px;
  margin-block-end: 12px; padding-block-end: 12px; border-block-end: 1px solid var(--exh-border-soft);
}
.exh-detail__head > .exh-btn { justify-self: start; }
.exh-detail__title { min-inline-size: 0; }
.exh-detail__head .exh-row__actions { grid-area: auto; }
.exh-detail__head .exh-row__meta .exh-badge { margin-inline-start: 2px; }
@container exh (min-width: 620px) {
  .exh-detail__head { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; }
}
.exh-report { min-inline-size: 0; }
.exh-report .rx-table-wrap { max-inline-size: 100%; overflow-x: auto; }

@container exh (max-width: 400px) {
  .exh-row { padding: 10px; gap: 8px 10px; }
  .exh-score { inline-size: 48px; block-size: 48px; }
  .exh-btn { padding-inline: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .exh-row--skeleton i { animation: none; }
  .exh * { transition: none !important; }
}
