/* Home (.home-*), exam detail (.exam-*) and progress (.prog-*). Shared components live in components.css. */

/* ---- Home ------------------------------------------------------------------------ */
.home-header .page-eyebrow { margin-bottom: var(--sp-1); }
.home-stats { margin-top: var(--sp-8); }
.home-continue-section + .home-stats { margin-top: var(--sp-6); }
.home-count { flex: none; }

.home-continue-grid { display: grid; gap: var(--sp-4); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .home-continue-grid.is-multi { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.home-continue {
  display: grid; align-items: center; gap: var(--sp-3) var(--sp-4);
  grid-template-columns: auto minmax(0, 1fr);
  padding: var(--sp-4);
}
.home-continue-icon { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.home-continue-main { min-width: 0; }
.home-continue-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.home-continue-title { font-size: var(--fs-lg); font-weight: 650; line-height: 1.3; min-width: 0; }
.home-continue .progress { margin-top: 10px; max-width: 440px; background: color-mix(in srgb, var(--accent) 20%, transparent); }
.home-continue-count { margin-top: 6px; font-size: var(--fs-xs); color: var(--text-2); }
.home-continue-btn { grid-column: 1 / -1; }
@media (min-width: 640px) {
  .home-continue { grid-template-columns: auto minmax(0, 1fr) auto; padding: var(--sp-5) var(--sp-6); }
  .home-continue-btn { grid-column: auto; }
}

.home-grid { display: grid; gap: var(--sp-3); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .home-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); } }
@media (min-width: 1024px) { .home-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1180px) { .home-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.home-exam { display: flex; flex-direction: column; padding: var(--sp-4); }
@media (min-width: 768px) { .home-exam { padding: var(--sp-5); } }
.home-exam.is-open { border-color: var(--accent-border); }
.home-exam-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.home-exam-head .badge { margin-top: 1px; }
.home-exam-title { font-size: 17px; font-weight: 650; line-height: 1.3; min-width: 0; }
.home-exam-title a { color: var(--text); }
.home-exam-title a:hover { text-decoration: none; }
.home-exam-sub { margin-top: 2px; font-size: var(--fs-sm); color: var(--text-2); line-height: 1.4; }
.home-exam-meta { margin: 6px 0 var(--sp-4); font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.home-exam-bar { margin: calc(-1 * var(--sp-1)) 0 var(--sp-4); }
/* margin-top:auto pins the footer to the bottom so cards in a row line up. */
.home-exam-foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  min-height: 49px; margin-top: auto; padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}
.home-status {
  display: inline-flex; align-items: flex-start; gap: 6px; flex: 1 1 auto; min-width: 0;
  font-size: var(--fs-xs); font-weight: 550; color: var(--text-3); line-height: 1.4; font-variant-numeric: tabular-nums;
}
.home-status .icon { margin-top: 1px; }
.home-status-open { color: var(--accent-text); }
.home-status-open .icon { color: var(--accent); }
.home-status-done { color: var(--text-2); }
.home-status-done .icon { color: var(--success); }
.home-cta {
  flex: none; display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-sm); font-weight: 600; color: var(--accent); white-space: nowrap;
}
.home-cta .icon { transition: transform var(--dur) var(--ease); }
.home-exam:hover .home-cta .icon, .home-exam:focus-within .home-cta .icon { transform: translateX(3px); }
.home-exam-foot .btn { flex: none; }

/* Phone: one grouped list instead of 14 tall cards. The section heading already names the kind, so the badge goes. */
@media (max-width: 639.98px) {
  .home-grid { gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
  .home-exam { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: var(--sp-3); padding: 12px 16px; border: 0; border-radius: 0; box-shadow: none; }
  .home-exam + .home-exam { border-top: 1px solid var(--border); }
  .home-exam.is-open { background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }
  .card-hover.home-exam:hover { transform: none; box-shadow: none; }
  .home-exam > *, .home-status { grid-column: 1; }
  .home-exam-head .badge { display: none; }
  .home-exam-title { font-size: var(--fs-base); }
  .home-exam-sub, .home-exam-meta { margin: 0; font-size: var(--fs-xs); }
  /* After `.home-exam > *` so the full-width column wins; order puts the bar under the status line. */
  .home-exam-bar { grid-column: 1 / -1; order: 1; margin: 8px 0 0; }
  .home-exam-foot { display: contents; }
  .home-status { margin-top: 4px; }
  .home-exam-foot > :last-child { grid-column: 2; grid-row: 1 / span 4; }
  /* Rows sit inside an overflow:hidden group, so the outward focus ring would be clipped; draw it inside instead. */
  .home-exam .stretched-link:focus-visible::after { box-shadow: inset 0 0 0 2px var(--accent); border-radius: 0; }
}

.home-start-title { font-size: var(--fs-lg); font-weight: 650; }
.home-steps { display: grid; gap: var(--sp-4); margin: var(--sp-5) 0 0; padding: 0; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 768px) { .home-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-6); } }
.home-step { display: flex; align-items: flex-start; gap: var(--sp-3); }
.home-step-title { font-size: var(--fs-base); font-weight: 650; }
.home-step-body { margin-top: 2px; font-size: var(--fs-sm); color: var(--text-2); }
.home-start-cta { margin-top: var(--sp-6); padding-top: var(--sp-5); border-top: 1px solid var(--border); }
@media (max-width: 479.98px) { .home-start-cta .btn { width: 100%; } }

/* ---- Exam detail --------------------------------------------------------------- */
.exam-eyebrow {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2);
  margin-bottom: 10px;
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-2);
}
.exam-header { margin-bottom: var(--sp-5); }
.exam-header .page-title { font-size: var(--fs-2xl); }
@media (min-width: 768px) { .exam-header .page-title { font-size: var(--fs-3xl); } }

.exam-layout { display: grid; gap: var(--sp-5); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1024px) {
  .exam-layout {
    grid-template-columns: minmax(0, 1fr) 320px;
    grid-template-areas: "hero aside" "history aside";
    align-items: start;
    gap: var(--sp-6) var(--sp-8);
  }
  .exam-hero { grid-area: hero; }
  .exam-aside { grid-area: aside; position: sticky; top: calc(var(--header-h) + var(--sp-6)); }
  .exam-history { grid-area: history; }
}

.exam-hero-title { font-size: var(--fs-lg); font-weight: 650; }
.exam-desc { margin-top: var(--sp-2); color: var(--text-2); max-width: 66ch; }
.exam-facts {
  display: grid; gap: 10px var(--sp-5);
  grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr));
  margin: var(--sp-5) 0 0; padding: 0;
}
.exam-facts li { display: flex; align-items: center; gap: 10px; font-size: var(--fs-sm); color: var(--text); }
.exam-facts .icon { color: var(--accent); }

.exam-tasks { margin-top: var(--sp-5); padding-top: var(--sp-5); border-top: 1px solid var(--border); }
.exam-tasks-title { font-size: var(--fs-sm); font-weight: 650; color: var(--text); }
.exam-task-list { display: grid; gap: var(--sp-2); margin-top: var(--sp-3); padding: 0; }
@media (min-width: 768px) { .exam-task-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2) var(--sp-5); } }
.exam-task-list li { display: flex; align-items: baseline; gap: 10px; font-size: var(--fs-sm); color: var(--text-2); line-height: 1.45; }
.exam-task-id {
  flex: none; min-width: 34px; padding: 1px 6px;
  border-radius: 6px; background: var(--accent-soft); color: var(--accent-text);
  font-size: 12px; font-weight: 650; text-align: center;
}

.exam-cta { margin-top: var(--sp-6); padding-top: var(--sp-6); border-top: 1px solid var(--border); }
.exam-draft { max-width: 480px; margin-bottom: var(--sp-5); }
.exam-actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); }
.exam-cta-note { margin-top: var(--sp-3); font-size: var(--fs-xs); color: var(--text-3); }
@media (max-width: 479.98px) {
  .exam-actions { flex-direction: column; }
  .exam-actions .btn { width: 100%; }
}

.exam-aside { display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
/* Below 1024 the tutor card is hidden too, so an aside without stats would only leave an empty grid row. */
@media (max-width: 1023.98px) { .exam-aside.no-stats { display: none; } }
.exam-stats { display: grid; gap: var(--sp-3); grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 639.98px) {
  .exam-stats .stat { padding: 12px; }
  .exam-stats .stat-value { font-size: var(--fs-xl); }
}
@media (min-width: 1024px) {
  .exam-stats { grid-template-columns: minmax(0, 1fr); }
  .exam-stats .stat { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 2px var(--sp-3); }
  .exam-stats .stat-label { grid-column: 1; }
  .exam-stats .stat-value { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: var(--fs-2xl); }
  .exam-stats .stat-sub { grid-column: 1; }
}
.exam-tutor-head { display: flex; align-items: flex-start; gap: var(--sp-3); margin-bottom: var(--sp-4); }

.exam-history .section-header { align-items: center; }
.exam-attempt .list-item-title, .exam-attempt .list-item-sub { display: block; }
.exam-attempt .list-item-title { font-size: 15px; }
.exam-attempt .list-item-sub b { color: var(--text); }
.exam-attempt .list-item-meta > .icon { color: var(--text-3); }
.exam-attempt.is-discarded .list-item-title { color: var(--text-2); font-weight: 550; }
/* Narrow phones: the icon tile and sub-line already carry the status, so the badge is for screen readers only
   and each row title fits on one line. */
@media (max-width: 479.98px) {
  .exam-attempt .list-item-meta .badge {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
  }
}

/* ---- Progress ------------------------------------------------------------------- */
/* Chart series: mocks take the accent; drills take the reference palette's orange.
   Validated (dataviz six checks) against --surface in both modes. */
.prog-page { --series-mock: #4F46E5; --series-drill: #eb6834; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .prog-page { --series-mock: #9085e9; --series-drill: #d95926; }
}
:root[data-theme="dark"] .prog-page { --series-mock: #9085e9; --series-drill: #d95926; }

.prog-chart-head {
  display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap;
  gap: var(--sp-3) var(--sp-6);
  margin-bottom: var(--sp-4);
}
.prog-legend { margin: 0; padding: 0; padding-top: 4px; }
.prog-key { flex: none; overflow: visible; }

.prog-plot {
  position: relative;
  min-height: 228px;
  margin: 0 calc(-1 * var(--sp-2));
  border-radius: var(--radius-sm);
  cursor: pointer;
  touch-action: pan-y;
  -webkit-user-select: none; user-select: none;
}
.prog-svg { display: block; overflow: visible; font-family: var(--font); }
.prog-grid { stroke: var(--border); stroke-width: 1; shape-rendering: crispEdges; }
.prog-tick { fill: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.prog-ref { stroke: var(--text-3); stroke-width: 1.5; stroke-dasharray: 5 4; }
.prog-ref-label, .prog-label {
  paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round;
  font-variant-numeric: tabular-nums;
}
.prog-ref-label { fill: var(--text-2); font-size: 12px; font-weight: 600; }
.prog-label { fill: var(--text); font-size: 13px; font-weight: 700; }
.prog-crosshair { stroke: var(--border-strong); stroke-width: 1; shape-rendering: crispEdges; }
.prog-line { fill: none; stroke: var(--series-mock); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.prog-pt {
  stroke: var(--surface); stroke-width: 4; paint-order: stroke; /* 2px surface ring outside a full-size mark */
  transform-box: fill-box; transform-origin: center;
  transition: transform var(--dur-fast) var(--ease);
}
.prog-pt-mock { fill: var(--series-mock); }
.prog-pt-drill { fill: var(--series-drill); }
.prog-pt.is-active { transform: scale(1.3); }
.prog-halo { fill-opacity: .16; pointer-events: none; }
.prog-halo-mock { fill: var(--series-mock); }
.prog-halo-drill { fill: var(--series-drill); }
.prog-table .prog-pt, .prog-legend .prog-pt { stroke-width: 0; }

.prog-tip {
  position: absolute; top: 0; left: 0; z-index: 2;
  min-width: 128px; padding: 8px 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-md);
  font-size: var(--fs-xs); line-height: 1.4; white-space: nowrap;
  pointer-events: none;
}
.prog-tip-value { display: flex; align-items: baseline; gap: 8px; }
.prog-tip-value strong { font-size: var(--fs-base); font-weight: 700; }
.prog-tip-value span { color: var(--text-2); font-variant-numeric: tabular-nums; }
.prog-tip-series { display: flex; align-items: center; gap: 6px; margin-top: 2px; color: var(--text-2); font-weight: 550; }
.prog-tip-key { flex: none; width: 12px; height: 2px; border-radius: 1px; }
.prog-tip-key-mock { background: var(--series-mock); }
.prog-tip-key-drill { background: var(--series-drill); }
.prog-tip-date { color: var(--text-3); }
.prog-chart-note { margin-top: var(--sp-2); font-size: var(--fs-xs); color: var(--text-3); }

/* Chart and mastery pair up (and stretch to equal height) from 1200px; below that the domain names would wrap. */
.prog-split { display: grid; gap: var(--sp-4); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1200px) { .prog-split { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: var(--sp-6); } }

.prog-code {
  flex: none; display: inline-block;
  padding: 1px 6px; border-radius: 6px;
  background: var(--surface-2); color: var(--text-2);
  font-size: 12px; font-weight: 650; line-height: 1.5; font-variant-numeric: tabular-nums;
}
.prog-domain-list { display: flex; flex-direction: column; gap: 18px; margin: 0; padding: 0; }
.prog-domain-name { display: flex; align-items: baseline; gap: 8px; font-weight: 550; line-height: 1.35; }
.prog-domain-value { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); }
.prog-domain-value b { color: var(--text); font-size: var(--fs-sm); }
.prog-flag { display: inline-flex; color: var(--warning); }
@media (max-width: 479.98px) { .prog-domain-count { display: none; } }
.prog-domain .progress-head { align-items: flex-start; }
.prog-domains { display: flex; flex-direction: column; }
.prog-domain-legend { margin-top: auto; padding-top: var(--sp-5); }

.prog-train-list { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); margin: 0; padding: 0; }
.prog-train { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.prog-train-head { display: flex; align-items: center; gap: var(--sp-2); }
.prog-train-name { flex: 1 1 auto; min-width: 0; font-size: var(--fs-sm); font-weight: 600; line-height: 1.35; }
.prog-courses { margin: 6px 0 0; padding: 0; }
.prog-course {
  display: flex; align-items: center; gap: var(--sp-2);
  min-height: 36px; margin: 0 -8px; padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm); color: var(--text);
}
.prog-course > .icon:first-child { color: var(--text-3); }
.prog-course > span { flex: 1 1 auto; min-width: 0; }
.prog-course > .icon:last-child { color: var(--text-3); }
a.prog-course:hover { background: var(--surface-2); text-decoration: none; }
a.prog-course:hover > span { text-decoration: underline; text-underline-offset: 2px; }
@media (pointer: coarse) { .prog-course { min-height: var(--tap); } }
.prog-train-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3) var(--sp-4); margin-top: var(--sp-4); }
.prog-train-note { flex: 1 1 320px; margin: 0; font-size: var(--fs-xs); color: var(--text-3); }
/* Overrides .btn-block's full width (components.css loads first); phones keep the full-width button. */
@media (min-width: 768px) { .prog-ask { width: auto; flex: none; } }

.prog-table tbody tr { cursor: pointer; }
.prog-exam { display: flex; align-items: center; gap: 10px; min-width: 0; }
.prog-exam-main { min-width: 0; }
.prog-exam-link { color: var(--text); font-weight: 600; }
.prog-table tbody tr:hover .prog-exam-link { color: var(--accent-text); }
.prog-exam-sub { font-size: 12px; color: var(--text-3); }
.prog-table .prog-go { width: 34px; padding-left: 0; color: var(--text-3); text-align: right; }
@media (max-width: 639.98px) {
  .prog-table th, .prog-table td { padding: 10px 12px; }
  .prog-table .prog-go { padding: 10px 10px 10px 0; }
}
.prog-empty { margin-top: var(--sp-2); }
