/* features/coach-rail.css — the coach rail and the drill after a wrong quiz answer (features/coach-rail.js), the drill
   marker and counter tag (features/quiz-engine.js), and the two drill lines on the results.
   Source of truth: ~/Desktop/CertAnvil/Prototypes/combined-coach-drill/index.html (After) + POLISH.md, approved 24 Nov.
   Motion: BRAND.md §6 tokens (--dgm-ease = the house curve, --dgm-press 150ms, --dgm-lift 220ms, --dgm-step 60ms).
   Only transform and opacity move. Reduced motion keeps the fades and drops every move and delay.
   Spacing rhythm 8 / 12 / 16 / 24. Hover only for a mouse (UAT 610). */

html[data-theme="dark"] {
  --cr-ink: var(--text); --cr-ink-soft: var(--text-mid); --cr-muted: var(--text-dim);
  --cr-deep: oklch(0.86 0.135 64); --cr-on-accent: oklch(0.18 0.020 275);
  --cr-surface: var(--surface); --cr-surface-2: var(--surface3); --cr-soft: var(--dg-rule-soft);
}
html[data-theme="light"] {
  --cr-ink: var(--text); --cr-ink-soft: var(--text-mid); --cr-muted: var(--text-dim);
  --cr-deep: oklch(0.42 0.150 52); --cr-on-accent: oklch(0.985 0.010 85);
  --cr-surface: oklch(0.992 0.004 85); --cr-surface-2: var(--surface3); --cr-soft: var(--dg-rule-soft);
}

/* ── arrivals (added only when a tap or a reply brings something in; a repaint is instant) ── */
@keyframes cr-arrive { from { opacity: 0; transform: translateY(6px); } }
@keyframes cr-fade { from { opacity: 0; } }
@keyframes cr-spin { to { transform: rotate(360deg); } }
@keyframes cr-pulse { 50% { opacity: .55; } }
@keyframes cr-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0% 0; } }
html[data-theme] body .cr-in { animation: cr-arrive var(--dgm-lift, 220ms) var(--dgm-ease, cubic-bezier(0.16, 1, 0.3, 1)) both; }
html[data-theme] body .cr-in.cr-d1 { animation-delay: var(--dgm-step, 60ms); }
html[data-theme] body .cr-in-fade { animation: cr-fade var(--dgm-lift, 220ms) var(--dgm-ease, cubic-bezier(0.16, 1, 0.3, 1)) both; }

/* ── the rail ── */
html[data-theme] body .cr-host { margin-top: 24px; font-family: Inter, -apple-system, system-ui, sans-serif; color: var(--cr-ink); }
html[data-theme] body .cr-host[hidden], html[data-theme] body .cr-host [hidden] { display: none !important; }
html[data-theme] body .cr-host button {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: center; box-shadow: none;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
html[data-theme] body .cr-host button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
html[data-theme] body .cr-host button:disabled { cursor: default; }
html[data-theme] body .cr-host p { margin: 0; }
html[data-theme] body .cr-rail { display: block; }
html[data-theme] body .cr-step { position: relative; display: flex; gap: 12px; align-items: flex-start; }
html[data-theme] body .cr-nd {
  flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  font: 600 12px/1 'Fraunces', Georgia, serif; background: var(--accent); color: var(--cr-on-accent);
}
html[data-theme] body .cr-s1 > .cr-nd { margin-top: 12px; }   /* centred on the 44px step button */
html[data-theme] body .cr-s2 .cr-nd { background: var(--bg); color: var(--cr-deep); border: 1.5px solid var(--accent); }
html[data-theme] body .cr-sb { flex: 1; min-width: 0; }
/* the line from step 1 to step 2 is decoration: it fades with step 2, it never draws */
html[data-theme] body .cr-s1::after {
  content: ""; position: absolute; left: 9px; top: 36px; bottom: -2px; width: 2px; border-radius: 2px;
  background: color-mix(in oklab, var(--accent) 55%, var(--border)); opacity: 0;
  transition: opacity var(--dgm-lift, 220ms) var(--dgm-ease) var(--dgm-step, 60ms);
}
html[data-theme] body .cr-rail.is-on .cr-s1::after { opacity: 1; }
html[data-theme] body .cr-s1.has { padding-bottom: 20px; }
html[data-theme] body .cr-s2.cr-in { animation-delay: var(--dgm-step, 60ms); }
html[data-theme] body .cr-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0 16px; }

/* step 1 button: Fraunces, bronze outline; fills bronze the moment it is tapped */
html[data-theme] body .cr-host .cr-why {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border-radius: 11px;
  border: 1.5px solid var(--accent); background: var(--cr-surface); color: var(--cr-deep);
  font: 600 16px/1.2 'Fraunces', Georgia, serif;
  transition: transform var(--dgm-press) var(--dgm-ease), background-color var(--dgm-press) var(--dgm-ease), color var(--dgm-press) var(--dgm-ease), border-color var(--dgm-press) var(--dgm-ease), opacity var(--dgm-press) var(--dgm-ease);
}
html[data-theme] body .cr-host .cr-why[aria-pressed="true"] { background: var(--accent); color: var(--cr-on-accent); }
html[data-theme] body .cr-host .cr-skip {
  display: inline-flex; align-items: center; gap: 3px; min-height: 44px; padding: 0 2px;
  font-size: 13.5px; font-weight: 600; color: var(--cr-ink-soft);
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in oklab, var(--cr-muted) 55%, transparent);
  transition: transform var(--dgm-press) var(--dgm-ease), color var(--dgm-press) var(--dgm-ease), opacity var(--dgm-press) var(--dgm-ease);
}
html[data-theme] body .cr-host .cr-skip .cr-ic { flex: none; color: var(--cr-deep); }

/* step 2 */
html[data-theme] body .cr-host .cr-fuzzy { text-wrap: balance; font: 600 15.5px/1.3 'Fraunces', Georgia, serif; color: var(--cr-ink); margin: 0 0 12px; }
html[data-theme] body .cr-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: stretch; }
html[data-theme] body .cr-pair.is-stack { grid-template-columns: 1fr; }
html[data-theme] body .cr-drill-b { display: flex; flex-direction: column; }
html[data-theme] body .cr-drill-b > .cr-btn { flex: 1; }   /* the drill button matches its neighbour's height */
html[data-theme] body .cr-drill-a { margin-top: 12px; }
html[data-theme] body .cr-drill-a:empty { display: none; }
html[data-theme] body .cr-drill-only .cr-drill-a { margin-top: 0; }
html[data-theme] body .cr-host .cr-help { font-size: 12.5px; line-height: 1.45; color: var(--cr-muted); text-align: center; margin-top: 8px; padding: 0 6px; }

/* the step-2 buttons and the drill button */
html[data-theme] body .cr-host .cr-ex, html[data-theme] body .cr-host .cr-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 46px; padding: 6px 10px;
  font-size: 14px; font-weight: 650; line-height: 1.25; border-radius: 11px;
  border: 1.5px solid color-mix(in oklab, var(--accent) 55%, var(--border)); color: var(--cr-deep); background: var(--cr-surface);
  transition: transform var(--dgm-press) var(--dgm-ease), background-color var(--dgm-press) var(--dgm-ease), border-color var(--dgm-press) var(--dgm-ease), color var(--dgm-press) var(--dgm-ease), opacity var(--dgm-press) var(--dgm-ease);
}
html[data-theme] body .cr-host .cr-ex[aria-pressed="true"] { background: var(--accent); color: var(--cr-on-accent); border-color: var(--accent); }
html[data-theme] body .cr-host .cr-btn.is-busy { color: var(--cr-ink-soft); border-style: dashed; background: var(--cr-surface-2); cursor: progress; }
html[data-theme] body .cr-host .cr-sp {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  border: 2px solid color-mix(in oklab, var(--accent) 30%, transparent); border-top-color: var(--accent);
  animation: cr-spin .8s linear infinite;
}
/* Drilled: finished, not tappable. Green tint, green border and a tick, so it never reads as the bronze "selected" */
html[data-theme] body .cr-host .cr-btn.is-done {
  gap: 6px; font-weight: 700; color: var(--cr-ink); border: 1.5px solid var(--pass);
  background: color-mix(in oklab, var(--pass) 12%, var(--cr-surface)); cursor: default;
}
html[data-theme] body .cr-host .cr-btn.is-done .cr-ic { color: var(--pass); }
/* while a reply is being written, the other actions wait */
html[data-theme] body .cr-rail.is-busy [data-cr-act]:not([aria-pressed="true"]) { opacity: .5; pointer-events: none; }

/* messages in the drill slot */
html[data-theme] body .cr-host .cr-msg { padding: 12px 14px; border-radius: 12px; font-size: 14px; font-weight: 600; line-height: 1.4; color: var(--cr-ink); }
html[data-theme] body .cr-host .cr-msg p { margin-bottom: 12px; }
html[data-theme] body .cr-host .cr-added { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--pass); background: color-mix(in oklab, var(--pass) 10%, var(--cr-surface)); }
html[data-theme] body .cr-host .cr-added .cr-ic { flex: none; color: var(--pass); margin-top: 1px; }
html[data-theme] body .cr-host .cr-fail { border: 1px solid color-mix(in oklab, var(--fail) 40%, var(--border)); background: color-mix(in oklab, var(--fail) 7%, var(--cr-surface)); }
html[data-theme] body .cr-host .cr-limit { border: 1px solid color-mix(in oklab, var(--warn) 45%, var(--border)); background: color-mix(in oklab, var(--warn) 9%, var(--cr-surface)); }
html[data-theme] body .cr-host .cr-sm {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 44px; padding: 0 12px;
  font-size: 14px; font-weight: 650; border-radius: 11px; border: 1px solid var(--border); color: var(--cr-ink-soft);
  transition: transform var(--dgm-press) var(--dgm-ease), background-color var(--dgm-press) var(--dgm-ease), border-color var(--dgm-press) var(--dgm-ease);
}

/* the reply card: arrives once, then only its words change */
html[data-theme] body .cr-host .cr-card {
  margin-top: 12px; padding: 12px 14px; border-radius: 14px;
  border: 1px solid color-mix(in oklab, var(--accent) 30%, var(--border)); background: var(--cr-surface);
}
html[data-theme] body .cr-host .cr-text { font-size: 14.5px; line-height: 1.55; color: var(--cr-ink); }
html[data-theme] body .cr-host .cr-reply-fail p { font-size: 14px; font-weight: 600; color: var(--cr-ink); margin-bottom: 12px; }
html[data-theme] body .cr-host .cr-ldg { min-height: 24px; display: flex; align-items: center; }
html[data-theme] body .cr-host .cr-shimmer { position: relative; display: inline-block; color: var(--cr-muted); font-size: 14.5px; font-weight: 600; }
html[data-theme] body .cr-host .cr-shimmer::before {
  content: attr(data-text); position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(90deg, transparent 0 40%, var(--cr-ink) 50%, transparent 60% 100%);
  background-size: 400% 100%; background-repeat: no-repeat; -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent; animation: cr-shimmer 2s linear infinite;
}
html.cr-paused body .cr-host .cr-shimmer::before { animation-play-state: paused; }
/* "Report this answer": its 44px tap area overlaps the card padding instead of adding empty space */
html[data-theme] body .cr-host .cr-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; margin: 10px 0 -10px; }
html[data-theme] body .cr-host .cr-tag {
  font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--cr-muted);
  border: 1px solid var(--border); border-radius: 6px; padding: 3px 7px; margin: 4px 0;
}
html[data-theme] body .cr-host .cr-tag.cr-obj { color: var(--cr-deep); border-color: color-mix(in oklab, var(--accent) 38%, var(--border)); }
html[data-theme] body .cr-host .cr-rep-wrap { margin-left: auto; }
html[data-theme] body .cr-host .cr-rep {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 2px; font-size: 12.5px; font-weight: 500; color: var(--cr-muted);
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in oklab, var(--cr-muted) 50%, transparent);
  transition: transform var(--dgm-press) var(--dgm-ease), color var(--dgm-press) var(--dgm-ease);
}
html[data-theme] body .cr-host .cr-rep.is-done { text-decoration: none; color: var(--pass); font-weight: 600; cursor: default; }

/* Study and Report this question: quiet links under the rail */
html[data-theme] body .cr-host .cr-links {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0 16px;
  margin-top: 24px; padding-top: 4px; border-top: 1px solid var(--cr-soft);
}
html[data-theme] body .cr-host .cr-links .resource-link { margin: 0; padding: 0; border: 0; background: none; }
html[data-theme] body .cr-host .cr-links .resource-dive-btn, html[data-theme] body .cr-host .cr-links .report-btn {
  display: inline-flex; align-items: center; width: auto; min-height: 44px; padding: 0 2px; border: 0; border-radius: 0; background: none;
  font-size: 13.5px; font-weight: 500; color: var(--cr-ink-soft); text-align: left;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in oklab, var(--cr-muted) 55%, transparent);
  transition: transform var(--dgm-press) var(--dgm-ease), color var(--dgm-press) var(--dgm-ease);
}
html[data-theme] body .cr-host .cr-links .report-btn.reported { text-decoration: none; color: var(--cr-muted); }
html[data-theme] body .cr-host .cr-links .resource-dive-btn::before, html[data-theme] body .cr-host .cr-links .report-btn::before { content: none; }

/* every press: 150ms scale(.97) */
html[data-theme] body .cr-host button:active:not(:disabled) { transform: scale(.97); }
@media (hover: hover) and (pointer: fine) {
  html[data-theme] body .cr-host .cr-why:hover:not([aria-pressed="true"]) { background: color-mix(in oklab, var(--accent) 10%, var(--cr-surface)); }
  html[data-theme] body .cr-host .cr-ex:hover:not([aria-pressed="true"]), html[data-theme] body .cr-host .cr-btn:hover:not(:disabled) { background: color-mix(in oklab, var(--accent) 12%, var(--cr-surface)); }
  html[data-theme] body .cr-host .cr-sm:hover { background: color-mix(in oklab, var(--cr-ink) 5%, transparent); }
  html[data-theme] body .cr-host .cr-skip:hover, html[data-theme] body .cr-host .cr-links .resource-dive-btn:hover,
  html[data-theme] body .cr-host .cr-links .report-btn:hover:not(:disabled), html[data-theme] body .cr-host .cr-rep:not(.is-done):hover { color: var(--cr-ink); text-decoration-color: currentColor; }
}
@media (max-width: 360px) { html[data-theme] body .cr-pair { grid-template-columns: 1fr; } }

/* ── drill questions: the marker above the stem, the counter tag, the done line ── */
html[data-theme] body .q-drill-marker {
  display: flex; align-items: center; gap: 8px; margin: 0 0 12px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid color-mix(in oklab, var(--accent) 30%, var(--border)); background: color-mix(in oklab, var(--accent) 9%, var(--cr-surface));
  font: 800 11.5px/1.3 Inter, -apple-system, system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--cr-deep);
}
html[data-theme] body .q-drill-marker[hidden] { display: none; }
html[data-theme] body .q-drill-marker .cr-ic { flex: none; }
html[data-theme] body .q-drill-tag { color: var(--cr-deep); font-weight: 700; white-space: nowrap; }
html[data-theme] body .cr-drill-done {
  margin-top: 12px; display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px;
  border: 1px solid color-mix(in oklab, var(--accent) 30%, var(--border)); background: color-mix(in oklab, var(--accent) 9%, var(--cr-surface));
  font-size: 14px; font-weight: 600; line-height: 1.4; color: var(--cr-ink); flex-basis: 100%; width: 100%;
}
html[data-theme] body .cr-drill-done .cr-ic { flex: none; color: var(--cr-deep); margin-top: 1px; }

/* ── desktop results: the two drill lines under the difficulty boxes, small and grey, no card (results polish, 24 Nov).
   The phone's lines (#ios-results .ir-drill) are styled in lift-ios.css with the rest of the phone results. ── */
html[data-theme] body .r-drill { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 8px; margin-top: 12px; text-align: left;
  animation: cr-fade 520ms var(--dgm-ease) 130ms backwards; }
html[data-theme] body .r-drill[hidden] { display: none; }
html[data-theme] body .r-drill-line { font: 600 12.5px/1.35 Inter, sans-serif; color: var(--text-mid); font-variant-numeric: tabular-nums; }
html[data-theme] body .r-drill-note { font: 500 12px/1.35 Inter, sans-serif; color: var(--text-dim); }

/* Reduced motion: keep the fades (they say what changed), drop every move and every delay */
@media (prefers-reduced-motion: reduce) {
  @keyframes cr-arrive { from { opacity: 0; } }
  html[data-theme] body .cr-in.cr-d1, html[data-theme] body .cr-s2.cr-in, html[data-theme] body .r-drill { animation-delay: 0ms; }
  html[data-theme] body .cr-s1::after { transition-delay: 0ms; }
  html[data-theme] body .cr-host button:active:not(:disabled) { transform: none; }
  html[data-theme] body .cr-host .cr-shimmer::before { display: none; }
  html[data-theme] body .cr-host .cr-sp { animation: cr-pulse 1.2s ease-in-out infinite; border-color: var(--accent); }
}
