/* =============================================================================
   examgen_loader.css — Track C (C2) per-job exam-generation loader card
   -----------------------------------------------------------------------------
   The on-brand "Generating your practice exam" card (examgen_loader.js builds the
   DOM): the app favicon mark, the title + subject, a staged checklist, an honest
   terracotta progress underline, and an aria-live caption. Theme-aware via tokens.
   Motion is compositor-friendly only (transform/opacity); honors reduced-motion.
   ========================================================================== */

.egl-card {
  --egl-terra: #c0664a;            /* loader terracotta accent (no global token) */
  width: min(480px, 92vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-6) var(--sp-5);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--r3);
  box-shadow: 0 18px 48px oklch(20% 0.02 239 / 0.22);
  color: var(--ink);
  text-align: center;
}

.egl-mark {
  width: auto;
  height: 62px;
  display: block;
  transform-origin: 50% 100%;
  animation: egl-breathe 4.6s ease-in-out infinite;
  filter: drop-shadow(0 6px 16px oklch(20% 0.02 239 / 0.12));
}
/* paused/done: stop the breathing pulse */
.egl-card.is-done .egl-mark,
.egl-card.is-failed .egl-mark { animation: none; }

.egl-title {
  font-family: var(--font-head, "Newsreader", Georgia, serif);
  font-weight: 500;
  font-size: clamp(18px, 2.4vw, 23px);
  line-height: 1.15;
  margin: 0;
}

.egl-subject {
  margin: calc(-1 * var(--sp-2)) 0 0;
  font-family: var(--font-data, ui-monospace, monospace);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-subtle);
}

/* ------------------------------------------------------- the checklist --- */
.egl-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  text-align: left;
}

.egl-step {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: 14px;
  color: var(--ink-subtle);
  transition: color var(--dur-normal) var(--ease-out);
}

.egl-step-mark {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  position: relative;
}

/* running card: rows not yet filled read as actively in-progress (a gentle pulse
   on the marks) WITHOUT claiming any single row complete unless a caller-supplied
   progress fraction has actually filled it (see stepStates in examgen_loader.js —
   still no timer, still no faked ticks). Filled (.is-done) marks hold still. */
.egl-card.is-running .egl-step { color: var(--ink-muted); }
.egl-card.is-running .egl-step.is-pending .egl-step-mark {
  border-color: var(--egl-terra);
  animation: egl-pulse 1.6s ease-in-out infinite;
}
.egl-card.is-running .egl-step.is-pending:nth-child(2) .egl-step-mark { animation-delay: 0.2s; }
.egl-card.is-running .egl-step.is-pending:nth-child(3) .egl-step-mark { animation-delay: 0.4s; }
.egl-card.is-running .egl-step.is-pending:nth-child(4) .egl-step-mark { animation-delay: 0.6s; }
.egl-card.is-running .egl-step.is-pending:nth-child(5) .egl-step-mark { animation-delay: 0.8s; }

/* done: every row filled (the only time completion is asserted). Filled dot —
   the same honest mark language as the 6-stage generate loader (.igl-step);
   the earlier checkmark glyph was retired with the honesty pass. */
.egl-step.is-done { color: var(--ink); }
.egl-step.is-done .egl-step-mark {
  background: var(--egl-terra);
  border-color: var(--egl-terra);
}

.egl-sr {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ----------------------------------------------------- progress + cap --- */
.egl-progress {
  position: relative;
  width: 100%;
  height: 3px;
  border-radius: 3px;
  overflow: hidden;
  background: color-mix(in oklch, var(--ink) 12%, transparent);
}
.egl-bar {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  width: 32%;
  border-radius: 3px;
  background: var(--egl-terra);
  animation: egl-sweep 1.7s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
/* done sets an inline width:100% → a settled determinate bar (no sweep). */
.egl-card.is-done .egl-bar { animation: none; }
/* queued: nothing running yet — hold the bar still at the start. */
.egl-card.is-queued .egl-bar { animation: none; transform: translateX(-110%); }
.egl-card.is-failed .egl-bar { animation: none; background: var(--border-strong); width: 100%; }

.egl-caption {
  margin: 0;
  font-family: var(--font-data, ui-monospace, monospace);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-subtle);
  min-height: 1.2em;
}
.egl-card.is-failed .egl-caption { color: var(--accent); text-transform: none; letter-spacing: 0.02em; }

@keyframes egl-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes egl-pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }
@keyframes egl-sweep { 0% { transform: translateX(-110%); } 100% { transform: translateX(420%); } }

@media (prefers-reduced-motion: reduce) {
  .egl-mark { animation: none; }
  .egl-card.is-running .egl-step-mark { animation: none; }
  .egl-bar { animation: none; width: 100%; }
}
