/* ==========================================================================
   Assessment — the overview dashboard, the skill radar and the wizard
   --------------------------------------------------------------------------
   Composed entirely from the tokens in base.css. Two rules drive the layout:

   * A case diagram is *sized by its container*. `case_thumbnail()` emits a
     viewBox-only SVG so it can be drawn crisply at any size — which also means
     an unstyled one expands to fill whatever box it lands in. Every diagram on
     these pages therefore goes through `.case-diagram` with an explicit size
     modifier.
   * The wizard is one step per screen. Rating 119 cases is a rhythm, and the
     rhythm breaks the moment the student has to scroll to find the buttons.
   ========================================================================== */

/* --------------------------------------------------------------------- */
/* Case diagrams                                                          */
/* --------------------------------------------------------------------- */

.case-diagram {
  --diagram-size: 96px;
  width: var(--diagram-size);
  height: var(--diagram-size);
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--ink-050);
  overflow: hidden;
}

.case-diagram > svg,
.case-diagram > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.case-diagram--xs { --diagram-size: 48px; }
.case-diagram--sm { --diagram-size: 64px; }
.case-diagram--md { --diagram-size: 120px; }
.case-diagram--lg {
  --diagram-size: 240px;
  background: transparent;
}

.case-diagram__none {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--ink-300);
  font-weight: 680;
  font-size: 0.9rem;
  background: repeating-linear-gradient(45deg, var(--ink-050) 0 6px, var(--paper) 6px 12px);
}

/* --------------------------------------------------------------------- */
/* Overview — head, goal selector, first run                              */
/* --------------------------------------------------------------------- */

.goal-form {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.goal-form__label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-400);
}
.goal-form select { width: auto; min-width: 168px; }

.first-run {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
  background:
    linear-gradient(180deg, var(--accent-soft), var(--paper) 62%);
  border-color: #d9e0ff;
}
.first-run__text { max-width: 62ch; }
.first-run__title { margin-bottom: var(--space-2); }
.first-run__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

/* --------------------------------------------------------------------- */
/* Overview — one card per CFOP step                                      */
/* --------------------------------------------------------------------- */

.phase-scores {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.phase-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  border-top: 3px solid var(--phase-color, var(--ink-200));
}
.phase-card--cross { --phase-color: var(--phase-cross); }
.phase-card--f2l { --phase-color: var(--phase-f2l); }
.phase-card--oll { --phase-color: var(--phase-oll); }
.phase-card--pll { --phase-color: var(--phase-pll); }

.phase-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.phase-card__score {
  margin: 0;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.phase-card__score b {
  font-size: 2.1rem;
  font-weight: 680;
  color: var(--ink-900);
  letter-spacing: -0.03em;
}
.phase-card__score small {
  font-size: 0.9rem;
  color: var(--ink-400);
  margin-left: 2px;
}
.phase-card__none {
  font-size: 2.1rem;
  font-weight: 680;
  color: var(--ink-300);
}
.phase-card.is-unknown .meter { opacity: 0.5; }

.phase-card__meta,
.phase-card__time {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-500);
}
.phase-card__target { color: var(--ink-400); }
.phase-card__time { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.phase-card__cta {
  margin-top: auto;
  padding-top: var(--space-2);
  font-size: 0.86rem;
  font-weight: 580;
}

/* Assessed / timed / untouched, as one quiet stacked bar. */
.coverage {
  display: flex;
  height: 5px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: var(--ink-100);
}
.coverage__seg { display: block; height: 100%; }
.coverage__seg--measured { background: var(--success); }
.coverage__seg--assessed { background: var(--warn); }
.coverage__seg--untouched { background: var(--ink-200); }

/* --------------------------------------------------------------------- */
/* Overview — the projection                                              */
/* --------------------------------------------------------------------- */

.projection { margin-bottom: var(--space-5); }

.projection__headline {
  display: grid;
  grid-template-columns: minmax(170px, auto) minmax(0, 1fr);
  align-items: center;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}
.projection__headline .stat__value.is-over { color: var(--danger); }

.projection__bar {
  display: flex;
  height: 56px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--ink-100);
}
.projection__seg {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  padding: 0 var(--space-3);
  color: #fff;
  overflow: hidden;
}
.projection__seg b {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.85;
  white-space: nowrap;
}
.projection__seg i {
  font-style: normal;
  font-size: 0.92rem;
  font-weight: 640;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.projection__seg--cross { background: var(--phase-cross); }
.projection__seg--f2l { background: var(--phase-f2l); }
.projection__seg--oll { background: var(--phase-oll); color: #4a3200; }
.projection__seg--pll { background: var(--phase-pll); }

.projection__note {
  margin: var(--space-4) 0 0;
  font-size: 0.82rem;
  color: var(--ink-400);
  max-width: 76ch;
}

.delta--over { color: var(--danger); font-weight: 600; }
.delta--under { color: var(--success); font-weight: 600; }

/* --------------------------------------------------------------------- */
/* The skill radar                                                        */
/* --------------------------------------------------------------------- */

.spider-card { margin-bottom: var(--space-5); }

.spider {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-3);
  justify-items: center;
}
.spider[aria-busy="true"] { opacity: 0.6; }

.spider__crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  justify-self: start;
  font-size: 0.85rem;
}
.spider__crumb {
  border: 0;
  background: none;
  font: inherit;
  color: var(--accent);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.spider__crumb:hover { background: var(--accent-soft); }
.spider__crumb.is-current {
  color: var(--ink-900);
  font-weight: 620;
  cursor: default;
}
.spider__sep { color: var(--ink-300); }

.spider__zoom {
  margin-left: var(--space-2);
  padding: 2px 10px;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-pill);
  background: var(--paper);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 580;
  color: var(--ink-500);
  cursor: pointer;
}
.spider__zoom:hover { border-color: var(--accent); color: var(--accent); }

.spider__chart {
  position: relative;
  width: 100%;
  max-width: 560px;
  padding: var(--space-2);
}

.spider__svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.spider__svg.is-entering { animation: spider-in var(--dur) var(--ease); }

@keyframes spider-in {
  from { opacity: 0; transform: scale(0.985); }
  to { opacity: 1; transform: none; }
}

.spider__ring {
  fill: none;
  stroke: var(--ink-200);
  stroke-width: 1.5;
}
.spider__ring--outer { fill: var(--ink-050); stroke: var(--ink-200); }
.spider__spoke { stroke: var(--ink-200); stroke-width: 1; }
.spider__target {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-dasharray: 10 8;
  opacity: 0.65;
}

.spider__area {
  fill: rgba(61, 90, 254, 0.16);
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linejoin: round;
}
.spider__area-line { stroke: var(--accent); stroke-width: 3; }

.spider__dot {
  fill: var(--accent);
  stroke: var(--paper);
  stroke-width: 2;
  transition: r var(--dur-fast) var(--ease);
}
.spider__dot--cross { fill: var(--phase-cross); }
.spider__dot--f2l { fill: var(--phase-f2l); }
.spider__dot--oll { fill: var(--phase-oll); }
.spider__dot--pll { fill: var(--phase-pll); }
.spider__dot.is-empty { fill: var(--paper); stroke: var(--ink-300); }
.spider__dot.is-active { stroke: var(--ink-900); stroke-width: 3; }

.spider__label {
  fill: var(--ink-500);
  font-family: var(--font-sans);
  font-weight: 560;
}
.spider__label.is-empty { fill: var(--ink-300); }
.spider__label.is-active { fill: var(--ink-900); font-weight: 700; }

.spider__hit {
  fill: transparent;
  cursor: default;
}
.spider__hit[role="button"] { cursor: pointer; }
.spider__hit:hover { fill: rgba(61, 90, 254, 0.05); }
.spider__hit:focus-visible {
  fill: rgba(61, 90, 254, 0.09);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.spider__readout {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: var(--space-2);
  min-height: 24px;
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink-400);
  text-align: center;
}
.spider__readout-name { color: var(--ink-900); }
.spider__readout-value {
  font-variant-numeric: tabular-nums;
  font-weight: 640;
  color: var(--accent);
}
.spider__readout-value.is-empty { color: var(--ink-400); font-weight: 500; }
.spider__readout-meta { color: var(--ink-400); }

.spider__empty,
.spider__none {
  margin: 0;
  padding: var(--space-4);
  text-align: center;
  font-size: 0.86rem;
  color: var(--ink-400);
}
.spider__empty {
  position: absolute;
  left: 50%;
  bottom: 4%;
  transform: translateX(-50%);
  max-width: 24ch;
  background: rgba(255, 255, 255, 0.86);
  border-radius: var(--radius-sm);
}

.spider__data { width: 100%; }
.spider__data > summary {
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 580;
  color: var(--ink-500);
  padding: var(--space-2) 0;
}
.spider__data > summary:hover { color: var(--ink-900); }

.spider__row.is-active { background: var(--accent-soft); }
.spider__rowdrill {
  border: 0;
  background: none;
  font: inherit;
  color: var(--accent);
  padding: 0;
  text-align: left;
  cursor: pointer;
}
.spider__rowdrill:hover { text-decoration: underline; }

/* --------------------------------------------------------------------- */
/* Coverage + weakest                                                     */
/* --------------------------------------------------------------------- */

.coverage-card,
.weakest-card { margin-bottom: var(--space-5); }
.coverage-card__cta { margin: var(--space-4) 0 0; }

.weakest {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-2);
}
.weakest__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border: 1px solid var(--ink-100);
  border-radius: var(--radius);
  background: var(--paper);
}
.weakest__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1 1 auto;
  min-width: 0;
  color: inherit;
}
.weakest__link:hover { text-decoration: none; }
.weakest__link:hover b { color: var(--accent); }
.weakest__text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.weakest__text b {
  color: var(--ink-900);
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.weakest__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.weakest__actions {
  display: flex;
  gap: var(--space-1);
  margin-left: auto;
}
.weakest__empty { color: var(--ink-400); font-size: 0.9rem; }

/* --------------------------------------------------------------------- */
/* The wizard                                                             */
/* --------------------------------------------------------------------- */

.wz-body { background-attachment: fixed; }

.wz {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-width: 1080px;
  margin-inline: auto;
}
.wz[aria-busy="true"] .wz-slot { opacity: 0.55; }

.wz-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
}
.wz-top__title { margin: 0; font-size: 1.35rem; }
.wz-top__scope { margin: 0; color: var(--ink-400); font-size: 0.88rem; }

.wz-progress {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.wz-progress__bar {
  --pct: 0;
  flex: 1 1 auto;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--ink-100);
  overflow: hidden;
}
.wz-progress__bar > i {
  display: block;
  height: 100%;
  width: calc(var(--pct) * 1%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--phase-f2l));
  transition: width var(--dur) var(--ease);
}
.wz-progress__text {
  margin: 0;
  font-size: 0.84rem;
  color: var(--ink-500);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.wz-progress__text b { color: var(--ink-900); }

/* ---- a step ---- */

.wz-slot { min-height: 420px; }

.wz-step {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  background: var(--paper);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}
.wz-step:focus { outline: none; }
.wz-step:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.wz-step__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.wz-step__eyebrow {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-400);
  font-weight: 640;
}
.wz-step__count {
  margin-left: auto;
  font-size: 0.82rem;
  color: var(--ink-400);
  font-variant-numeric: tabular-nums;
}
.wz-step__title { margin: 0; font-size: 1.5rem; }
.wz-step__lede { margin: 0; color: var(--ink-500); }

/* ---- the case stage: diagram + facts ---- */

.wz-stage {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-6);
}
/* A step with no diagram (the cross) gives its text the full width rather
   than leaving a hole where the picture would be. */
.wz-stage--plain { grid-template-columns: minmax(0, 1fr); }

.wz-facts { display: flex; flex-direction: column; gap: var(--space-3); }
.wz-facts__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-400);
}
.wz-facts__current {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-500);
}
.wz-facts__current b { color: var(--ink-900); }
.wz-facts__current--none { color: var(--ink-400); font-style: italic; }

.wz-alg { margin: 0; }
.wz-alg > summary {
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 560;
  color: var(--ink-500);
  list-style: none;
}
.wz-alg > summary::-webkit-details-marker { display: none; }
.wz-alg > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 6px;
  color: var(--ink-300);
  transition: transform var(--dur-fast) var(--ease);
}
.wz-alg[open] > summary::before { transform: rotate(90deg); }
.wz-alg > summary:hover { color: var(--ink-900); }
.wz-alg .alg { margin-top: var(--space-2); }
.wz-alg__link { display: block; margin-top: var(--space-2); font-size: 0.84rem; }
.wz-alg--none { color: var(--ink-400); font-size: 0.86rem; }

/* ---- the group strip ---- */

.wz-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  list-style: none;
  margin: 0;
  padding: 0;
}
.wz-strip__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 56px;
}
.wz-strip__name {
  font-size: 0.72rem;
  color: var(--ink-400);
  font-variant-numeric: tabular-nums;
  max-width: 56px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- the 0-5 rating scale ---- */

.wz-answer { margin: 0; }

.rating {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.rating__legend {
  padding: 0 0 var(--space-2);
  font-size: 0.88rem;
  font-weight: 580;
  color: var(--ink-700);
}
.rating__options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: var(--space-2);
}
.rating__option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: var(--space-3);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius);
  background: var(--paper);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease);
}
.rating__option:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.rating__option:active,
.rating__option.is-pressed {
  transform: translateY(1px);
  background: var(--accent-soft);
}
.rating__option[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.rating__key {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 6px;
  background: var(--ink-100);
  border-bottom: 2px solid var(--ink-200);
  color: var(--ink-700);
  font-size: 0.78rem;
  font-weight: 660;
}
.rating__option[aria-pressed="true"] .rating__key {
  background: var(--accent);
  border-color: #2a41d8;
  color: #fff;
}
.rating__label {
  font-size: 0.86rem;
  font-weight: 560;
  color: var(--ink-900);
  line-height: 1.25;
}
.rating__pips { display: flex; gap: 3px; }
.rating__pips i {
  width: 12px;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--ink-200);
}
.rating__pips i.on { background: var(--accent); }

.wz-answer__note {
  margin: var(--space-3) 0 0;
  font-size: 0.82rem;
  color: var(--ink-400);
}

.wz-groupapply {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px dashed var(--ink-200);
  border-radius: var(--radius);
  font-size: 0.84rem;
  font-weight: 400;
  color: var(--ink-500);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.wz-groupapply:hover { border-color: var(--ink-300); }
.wz-groupapply:has(input:checked),
.wz-groupapply.is-on {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-soft);
  color: var(--ink-700);
}
.wz-groupapply b { color: var(--ink-900); }

/* ---- navigation and help ---- */

.wz-nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding-top: var(--space-2);
  border-top: 1px solid var(--ink-100);
}
.wz-nav [data-nav="finish"] { margin-left: auto; }

/* The shortcuts belong to assessment.js. Until it has started, the page must
   not advertise keys that do nothing — with JavaScript off the wizard is a
   plain multi-page form and says so by staying quiet. */
.wz kbd:not(.rating__key) { display: none; }
.wz.has-shortcuts kbd:not(.rating__key) { display: inline-block; }
.wz-help { display: none; }
.wz.has-shortcuts .wz-help { display: block; }

.wz-help {
  border: 1px solid var(--ink-200);
  border-radius: var(--radius);
  background: var(--ink-050);
  padding: var(--space-3) var(--space-4);
}
.wz-help__title {
  margin: 0 0 var(--space-2);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-400);
}
.wz-help__keys {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.82rem;
  color: var(--ink-500);
}

kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--paper);
  border: 1px solid var(--ink-200);
  border-bottom-width: 2px;
  color: var(--ink-700);
  font-size: 0.76rem;
  font-weight: 620;
  text-align: center;
  line-height: 1.4;
}

.wz-empty { margin-block: var(--space-5); }
.wz-empty__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
  margin-top: var(--space-4);
}
.wz-empty code {
  background: var(--ink-100);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.86em;
}

/* --------------------------------------------------------------------- */
/* Summary                                                                */
/* --------------------------------------------------------------------- */

.summary-scores,
.summary-changes,
.summary-next { margin-bottom: var(--space-5); }

.summary-scores__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
}
.summary-score {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: flex-start;
  padding: var(--space-3);
  border: 1px solid var(--ink-100);
  border-radius: var(--radius);
}
.summary-score__value {
  font-size: 1.9rem;
  font-weight: 680;
  color: var(--ink-900);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.summary-score.is-unknown .summary-score__value { color: var(--ink-300); }
.summary-score__meta { font-size: 0.8rem; color: var(--ink-400); }
.summary-score .meter { align-self: stretch; }

.summary-changes__empty { color: var(--ink-400); font-size: 0.9rem; }
.summary-changes tr.is-weak th a { color: var(--danger); }

.rating-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 620;
  background: var(--ink-100);
  color: var(--ink-700);
  white-space: nowrap;
}
.rating-chip--0,
.rating-chip--1 { background: var(--danger-soft); color: var(--danger); }
.rating-chip--2 { background: var(--warn-soft); color: var(--warn); }
.rating-chip--3 { background: var(--accent-soft); color: #2a41d8; }
.rating-chip--4,
.rating-chip--5 { background: var(--success-soft); color: var(--success); }

/* --------------------------------------------------------------------- */
/* Phone                                                                  */
/* --------------------------------------------------------------------- */

@media (max-width: 860px) {
  .projection__headline { grid-template-columns: 1fr; gap: var(--space-4); }
  .projection__bar { height: 48px; }
  .first-run { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 620px) {
  .phase-scores { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3); }
  .phase-card { padding: var(--space-4); }
  .phase-card__score b,
  .phase-card__none { font-size: 1.7rem; }

  .wz-step { padding: var(--space-4); border-radius: var(--radius); }
  .wz-stage {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: var(--space-4);
  }
  .wz-facts { align-items: center; }
  .wz-facts__meta { justify-content: center; }

  /* The diagram and the six buttons have to share one phone screen: that is
     the whole loop — look at the case, press a number. Anything else (the
     algorithm, group-apply, the nav) may sit below the fold. */
  .case-diagram--lg { --diagram-size: min(46vw, 168px); }
  .wz-step { gap: var(--space-3); }
  .wz-step__head { gap: var(--space-2); font-size: 0.9rem; }
  .wz-step__eyebrow { font-size: 0.7rem; }
  .wz-step__count { margin-left: 0; width: 100%; }
  .wz-step__title { font-size: 1.25rem; }
  .wz-stage { gap: var(--space-3); }

  /* Six one-line rows beat a 2×3 grid of guesses: the key, the word and the
     pips stay on one line and the thumb has a full-width target. */
  .rating__options { grid-template-columns: 1fr; gap: 5px; }
  .rating__option {
    flex-direction: row;
    align-items: center;
    gap: var(--space-3);
    padding: 8px var(--space-3);
  }
  .rating__label { flex: 1 1 auto; }

  /* Every pixel above the step pushes the rating buttons off the phone
     screen, so the run header compacts to one line. */
  .wz-top { align-items: center; gap: var(--space-3); }
  .wz-top__title { font-size: 1.05rem; }
  .wz-top__scope { font-size: 0.78rem; }
  .wz { gap: var(--space-3); }
  .wz-nav { justify-content: space-between; }
  .wz-nav [data-nav="finish"] { margin-left: 0; }
  .wz.has-shortcuts .wz-help { display: none; }

  .spider__chart { padding: 0; }

  /* Diagram + name + two buttons do not fit across a phone; let the buttons
     take their own row rather than pushing the page sideways. */
  .weakest { grid-template-columns: 1fr; }
  .weakest__item { flex-wrap: wrap; }
  .weakest__actions { margin-left: auto; }
  .weakest__link { flex: 1 1 180px; }
}

@media (prefers-reduced-motion: reduce) {
  .spider__svg.is-entering { animation: none; }
  .wz-progress__bar > i,
  .spider__dot,
  .rating__option { transition: none; }
}

@media print {
  .wz-help, .wz-nav, .spider__crumbs { display: none !important; }
  .spider__data[open] { display: block; }
}

/* --------------------------------------------------------------------- */
/* The numbers table: sortable, and aligned                               */
/* --------------------------------------------------------------------- */

/* base.css right-aligns `td.num` but leaves `th` left-aligned, so the
   headers never sat above their own values. Centre both for the numeric
   columns so a column reads as one thing. */
/* The table carries both classes, and base.css's `table.data td.num` (0,2,2)
   outranks a plain `.spider__table td.num` (0,2,1) — so name both classes to
   win, rather than reaching for !important. */
table.data.spider__table th.num,
table.data.spider__table td.num {
  text-align: center;
}

.spider__table th.num .spider__sort { justify-content: center; }

/* A header is a control now. It keeps the header's typography — this is a
   sort affordance, not a button in a table. */
.spider__sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  text-align: inherit;
  cursor: pointer;
  min-height: 32px;
}

.spider__sort:hover { color: var(--ink-900); }
.spider__sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Reserve the arrow's width always, so sorting a column does not shift the
   header text sideways. */
.spider__sortarrow {
  display: inline-block;
  min-width: 0.75em;
  font-size: 0.9em;
  color: var(--accent);
}

.spider__table th[aria-sort]:not([aria-sort='none']) { color: var(--ink-900); }
