/* The migration hub's own parts (rule 506): the hero card "Every move, counted twice" (kit/HubHero.astro), Find your
   move (kit/MoveFinder.astro) and What a plain import leaves behind (kit/ImportDiff.astro). The card head takes its look
   from kit-build.css (kbb__ classes), which SectionRenderer links with this file only on a page that draws one of
   these. Three states, one colour each: arrives green, rebuilt or listed amber, left behind red. */

.khh,
.kmf,
.kid {
  --st-moves: #00a35c;
  --st-rebuilt: #b7791f;
  --st-cannot: #df2f4a;
}
.khh [hidden],
.kmf [hidden],
.kid [hidden] {
  display: none !important;
}

/* ---------- hero: every move, counted twice ---------- */

.hero__hub {
  align-self: center;
}
.khh__card {
  display: grid;
  gap: var(--s-4);
}
.khh .kbb__head {
  margin-bottom: 0;
}
.khh__live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--accent-deep);
}
.khh__live i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--st-moves);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--st-moves) 60%, transparent);
  animation: khh-pulse 1.8s var(--ease) infinite;
}
@keyframes khh-pulse {
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.khh__tiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center; /* 19 tiles: the short last row sits centred (rule 158a) */
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.khh__tiles > li {
  flex: 0 0 calc((100% - 54px) / 10 - 0.01px);
  min-width: 0;
}
.khh__tile {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--accent-deep);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.khh__tile .tool-tile {
  width: 26px;
  height: 26px;
}
.khh__tile:hover,
.khh__tile.is-on {
  border-color: var(--accent);
  box-shadow: 0 8px 18px -12px color-mix(in srgb, var(--accent) 90%, transparent);
  transform: translateY(-2px);
}
.khh__tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.khh__tile--any {
  border-style: dashed;
}
.khh__play {
  display: grid;
  gap: 10px;
  padding: var(--s-4);
  border: 1px solid var(--line);
  background: var(--paper);
}
.khh__route {
  display: grid;
  grid-template-columns: auto minmax(40px, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 0;
}
.khh__name {
  grid-column: 1 / -1;
  font-weight: 550;
  color: var(--ink);
}
.khh__lane,
.kmf__lane {
  position: relative;
  height: 2px;
  background: repeating-linear-gradient(90deg, var(--line-2) 0 6px, transparent 6px 11px);
  overflow: visible;
}
.khh__lane i,
.kmf__lane i {
  position: absolute;
  top: -3px;
  left: 0;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0;
  animation: khh-run 2.4s linear infinite;
}
.khh__lane i:nth-child(2),
.kmf__lane i:nth-child(2) { animation-delay: 0.6s; }
.khh__lane i:nth-child(3),
.kmf__lane i:nth-child(3) { animation-delay: 1.2s; }
.kmf__lane i:nth-child(4) { animation-delay: 1.8s; }
@keyframes khh-run {
  0% { left: 0; opacity: 0; }
  12% { opacity: 1; }
  88% { opacity: 1; }
  100% { left: calc(100% - 8px); opacity: 0; }
}
.khh__counts {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.khh__counts li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 20px;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-left: 3px solid var(--line-2);
  background: var(--paper-2);
  font-size: var(--fs-small);
  transition: border-color 300ms var(--ease);
}
.khh__counts li.is-done {
  border-left-color: var(--st-moves);
}
.khh__n {
  display: inline-flex;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.khh__eq {
  color: var(--muted);
}
.khh__tick {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: var(--st-moves);
  background: color-mix(in srgb, var(--st-moves) 14%, transparent);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 250ms var(--ease), transform 250ms var(--ease);
}
.khh__counts li.is-done .khh__tick {
  opacity: 1;
  transform: scale(1);
}
.khh__fine,
.kmf__fine {
  margin: 0;
  font-size: var(--fs-mono-sm);
  color: var(--muted);
}
.khh .kbb__go {
  margin-top: 0;
}

/* ---------- Find your move ---------- */

.kmf {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: var(--s-5);
  align-items: start;
  margin-top: var(--s-5);
}
.kmf__pick {
  display: grid;
  gap: var(--s-4);
}
.kmf__ask {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: var(--accent-deep);
}
.kmf__group {
  display: grid;
  gap: 8px;
}
.kmf__gh {
  margin: 0;
  color: var(--muted);
}
.kmf__tiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center; /* a short last row sits centred, never alone at the left (rule 158a) */
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.kmf__tiles > li {
  flex: 0 1 150px;
  min-width: 0;
}
.kmf__tile {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 10px 6px 6px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: var(--fs-small);
  line-height: 1.25;
  text-decoration: none;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.kmf__tile:hover {
  border-color: var(--accent);
}
.kmf__tile[aria-current='true'] {
  border-color: var(--accent);
  background: var(--accent-tint);
  box-shadow: inset 3px 0 0 var(--accent);
  font-weight: 550;
}
.kmf__tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.kmf__logo {
  display: inline-grid;
  flex: none;
}
.kmf__logo--any,
.kmf__any {
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px dashed var(--line-2);
  color: var(--accent-deep);
}
.kmf__any {
  display: inline-grid;
  width: 48px;
  height: 48px;
}
.kmf__card {
  position: sticky;
  top: calc(var(--sticky-top, 80px) + 16px);
  display: grid;
  gap: var(--s-4);
  padding: var(--s-5);
  border: 1px solid var(--line);
  background:
    radial-gradient(80% 50% at 100% 0%, var(--accent-tint) 0%, transparent 65%),
    var(--paper);
  box-shadow: var(--shadow-card);
}
.kmf__card.is-swap {
  animation: kmf-swap 420ms var(--ease);
}
@keyframes kmf-swap {
  from { opacity: 0.35; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.kmf__route {
  display: grid;
  grid-template-columns: auto minmax(60px, 1fr) auto;
  align-items: center;
  gap: var(--s-3);
}
.kmf__title {
  display: grid;
  gap: 4px;
}
.kmf__kicker {
  margin: 0;
  color: var(--accent-deep);
}
.kmf__name {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 500;
  line-height: 1.25;
}
.kmf__rows {
  display: grid;
  margin: 0;
  border-top: 1px solid var(--line);
}
.kmf[data-mode='move'] .kmf__rows--other,
.kmf[data-mode='other'] .kmf__rows--move {
  display: none;
}
.kmf__row {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: var(--s-3);
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.kmf__row dt {
  display: inline-flex;
  align-items: flex-start;
  gap: 7px;
  margin: 0;
  padding-top: 2px;
  color: var(--muted);
}
.kmf__row dt svg {
  flex: none;
  color: var(--accent-deep);
}
.kmf__row dd {
  margin: 0;
  font-size: var(--fs-small);
  line-height: 1.55;
  color: var(--ink-2, var(--ink));
}
.kmf__row dd p {
  margin: 0;
}
.kmf__row strong {
  font-weight: 600;
  color: var(--ink);
}
/* the cut-over rule as a label: amber for a freeze window, green when the team keeps working */
.kmf__rule {
  display: inline-flex;
  margin-bottom: 6px;
  padding: 3px 10px;
  border: 1px solid color-mix(in srgb, var(--st-rebuilt) 45%, var(--line));
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--st-rebuilt) 10%, var(--paper));
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
}
.kmf__row[data-keeps='true'] .kmf__rule {
  border-color: color-mix(in srgb, var(--st-moves) 45%, var(--line));
  background: color-mix(in srgb, var(--st-moves) 10%, var(--paper));
}
.kmf__rulebody {
  display: block;
}
/* a tool with no picture (rule 236): its name as plain text, never initials */
.kmf__logo:empty {
  display: none;
}
.kmf__tile:has(.kmf__logo:empty) {
  padding-left: 12px;
}
.kmf__word {
  display: inline-grid;
  place-items: center;
  min-height: 48px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: var(--fs-small);
  font-weight: 550;
  line-height: 1.2;
  text-align: center;
}
.khh__route .kmf__word {
  min-height: 40px;
}
.khh__word {
  font-size: 9px;
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
  color: var(--ink);
}
.kmf__chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.kmf__chips li {
  padding: 3px 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-pill);
  background: var(--paper);
  font-size: var(--fs-small);
}
.kmf__counts {
  display: grid;
  gap: 4px;
  margin: 0 0 6px;
  padding: 0;
  list-style: none;
}
.kmf__counts li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 16px;
  align-items: center;
  gap: 10px;
  padding: 5px 10px;
  border-left: 3px solid var(--st-moves);
  background: var(--paper-2);
}
.kmf__counts svg {
  color: var(--st-moves);
}
.kmf__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}
.kmf__why {
  flex-basis: 100%;
  order: 3;
  margin: 0;
  font-size: var(--fs-xs);
  line-height: 1.4;
  color: var(--muted);
}
.kmf__page {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- What a plain import leaves behind ---------- */

.kid {
  display: grid;
  gap: var(--s-4);
  margin-top: var(--s-5);
}
.kid__switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--line);
}
.kid__opt {
  display: grid;
  gap: 4px;
  justify-items: start;
  padding: var(--s-4);
  border: 0;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.kid__opt + .kid__opt {
  border-left: 1px solid var(--line);
}
.kid__opt[aria-pressed='true'] {
  background: var(--accent-tint);
  box-shadow: inset 0 -3px 0 var(--accent);
}
.kid__opt:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.kid__optt {
  font-weight: 600;
}
.kid__optl {
  font-size: var(--fs-small);
  color: var(--muted);
}
.kid__tally {
  margin-top: 4px;
  color: var(--accent-deep);
}
.kid__body {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
  gap: var(--s-5);
  align-items: start;
}
.kid__rec {
  position: sticky;
  top: calc(var(--sticky-top, 80px) + 16px);
  display: grid;
  gap: var(--s-3);
  margin: 0;
  padding: var(--s-4);
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow-card);
}
.kid__rech {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 10px;
  align-items: start;
}
.kid__rech > span:nth-child(2) {
  display: grid;
  gap: 2px;
}
.kid__recic {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  background: var(--accent-tint);
  color: var(--accent-deep);
}
.kid__rect {
  font-weight: 600;
  color: var(--ink);
}
.kid__recs,
.kid__recs p {
  margin: 0;
  font-size: var(--fs-small);
  color: var(--muted);
}
.kid__demo {
  grid-column: 1 / -1;
  color: var(--muted);
}
.kid__parts {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.kid__part {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: var(--fs-small);
  transition: opacity 360ms var(--ease), background-color 360ms var(--ease), border-color 360ms var(--ease);
  transition-delay: calc(var(--i) * 40ms);
}
.kid__pdot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--st-moves);
}
.kid__part[data-st='rebuilt'] .kid__pdot { background: var(--st-rebuilt); }
.kid__part[data-st='cannot'] {
  opacity: 0.92; /* was 0.55: its text was under 4.5:1; the dashed border says it does not move (T6, 20 Nov 2026) */
  border-style: dashed;
  background: transparent;
}
.kid__part[data-st='cannot'] .kid__pdot {
  background: transparent;
  border: 1.5px solid var(--st-cannot);
}
.kid__part[data-st='cannot'] .kid__pname {
  text-decoration: line-through;
  text-decoration-color: var(--st-cannot);
}
.kid__fine {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
}
.kid__list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}
.kid__row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: var(--s-3);
  padding: 12px 0 12px 12px;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid var(--st-moves);
  transition: border-color 360ms var(--ease);
}
.kid__row[data-st='rebuilt'] { border-left-color: var(--st-rebuilt); }
.kid__row[data-st='cannot'] { border-left-color: var(--st-cannot); }
.kid__item {
  font-weight: 600;
  color: var(--ink);
}
.kid__what {
  display: grid;
  gap: 2px;
  font-size: var(--fs-small);
  line-height: 1.5;
}
.kid__st {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  /* text colours with AA contrast in both themes (the bright status colours stay for the dots; T6, 20 Nov 2026) */
  color: var(--ok-ink);
}
.kid__what[data-st='rebuilt'] .kid__st { color: var(--warn-ink); }
.kid__what[data-st='cannot'] .kid__st { color: var(--danger); }
.kid__target {
  color: var(--ink);
}
.kid__note {
  color: var(--muted);
}

/* the eight trust promises: four to a row on a wide screen, two full rows with no hole */
@media (min-width: 1100px) {
  .band--cards[data-variant~='lift'] .cards--lift {
    --cols: 4 !important;
  }
}

/* the signers' answers: two cards side by side, the full width (no empty right half), as on the other money pages */
.band--folds .kfolds__panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
  max-width: none;
}
.band--folds .kfolds__panel[hidden] {
  display: none;
}
/* an odd count leaves the last answer alone in its row: it spans the full width (nth-of-type: the hidden h3 is a child too) */
.band--folds .kfolds__panel > details:last-of-type:nth-of-type(odd) {
  grid-column: 1 / -1;
}
.band--folds .kfolds__panelname {
  grid-column: 1 / -1;
}
.band--folds .kfolds__fold {
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 0 var(--s-4);
}

/* ---------- narrow screens ---------- */

@media (max-width: 899px) {
  .kmf,
  .kid__body {
    grid-template-columns: minmax(0, 1fr);
  }
  .kmf__card,
  .kid__rec {
    position: static;
  }
  /* on a phone the list under it says each part, so the record card keeps only its head */
  .kid__parts {
    display: none;
  }
  .kmf__tiles > li {
    flex-basis: calc(50% - 3px);
  }
  .khh__tiles > li {
    flex-basis: calc((100% - 24px) / 5 - 0.01px);
  }
}
/* a tablet: the card is as wide as the page text, so ten to a row keeps the tiles near their logo size (no big near-empty
   squares); the phone rule below takes over at 600px */
@media (min-width: 601px) and (max-width: 899px) {
  .khh__tiles > li {
    flex-basis: calc((100% - 54px) / 10 - 0.01px);
  }
}
@media (max-width: 899px) {
  .kmf__row,
  .kid__row {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }
  .kid__switch,
  .band--folds .kfolds__panel {
    grid-template-columns: minmax(0, 1fr);
  }
  .kid__opt + .kid__opt {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (prefers-reduced-motion: reduce) {
  .khh__lane i,
  .kmf__lane i,
  .khh__live i {
    animation: none;
    opacity: 0;
  }
  .kmf__card.is-swap {
    animation: none;
  }
  .kid__part,
  .kid__row,
  .khh__tile,
  .khh__tick {
    transition: none;
  }
}

/* a phone (rule 158a, layout.hero-height): the hub card's tile grid in seven to a row (each tile at least 44px) */
@media (max-width: 600px) {
  .hero__hub .khh__card {
    gap: var(--s-2);
  }
  .hero__hub .khh__live {
    display: none;
  }
  /* seven to a row, each tile at least 44px even at 360: 2px gaps and the row runs 6px into the card's padding */
  .hero__hub .khh__tiles {
    gap: 2px;
    margin-inline: -6px;
  }
  .hero__hub .khh__tiles > li {
    flex-basis: calc((100% - 12px) / 7 - 0.01px);
  }
  .hero__hub .khh__play {
    gap: 4px;
    padding: var(--s-2) var(--s-3);
  }
  /* the drawn route (two logos and a dashed lane) is decorative: the move's name under it stays */
  .hero__hub .khh__route .khh__end,
  .hero__hub .khh__route .khh__lane {
    display: none;
  }
  .hero__hub .khh__counts {
    gap: 4px;
  }
  .hero__hub .khh__counts li {
    padding: 3px 10px;
  }
}
