/* Swap drills: the battle-shaped card screen. Theirs above (the biggest thing, inside the
   deadline ring), yours below, and in the bottom third the attack area (stay) with the
   bench stacked on the right, where the swap buttons are in the game. */

.swap__intro,
.swap__result {
  display: grid;
  gap: var(--space-16);
}

.swap__intro { padding-top: var(--space-16); }

.swap__panel {
  display: grid;
  gap: var(--space-10);
}

.swap__team {
  display: grid;
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.swap__team .muted {
  display: inline-block;
  min-width: 52px;
}

/* The stage fills the screen below the app bar; nothing scrolls during a card. Sized to
   the small viewport (svh: browser toolbars showing), so it fits however they move; 100vh
   is the fallback. Their card absorbs the difference between phones. */
.swap__stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto auto;
  gap: var(--space-10);
  max-width: var(--column);
  height: calc(100vh - 64px);
  height: calc(100svh - 64px);
  margin: 0 auto;
  padding: var(--space-4) var(--page-pad) var(--space-14);
}

.swap__card {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: var(--space-4);
  padding: var(--space-14) var(--space-16);
  border-radius: var(--radius-card);
  background: var(--card);
  box-shadow: var(--shadow-card);
  text-align: center;
}

.swap__label {
  font-size: var(--text-13);
  color: var(--muted);
}

.swap__name {
  font-size: var(--text-25);
  font-weight: 800;
  line-height: 1.1;
}

.swap__name--them {
  font-size: clamp(var(--text-25), min(11vw, 5.5svh), var(--text-46));
}

/* Short screens (small phones with every toolbar showing): their card gives up its label
   and a step of chip size before anything can spill. */
@media (max-height: 640px) {
  .swap__card--them .swap__label { display: none; }
  .swap__card--them .type-chip--large { font-size: var(--text-15); }
}

.swap__types {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-4);
}

/* Their card sits inside the deadline ring: a faint track and the time left on top. */
.swap__them {
  position: relative;
  display: grid;
  padding: 7px;
}

.swap__card--them {
  height: 100%;
}

.swap__ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.swap__ring rect {
  x: 2px;
  y: 2px;
  width: calc(100% - 4px);
  height: calc(100% - 4px);
  rx: 25px;
  fill: none;
  stroke-width: 3px;
}

.swap__ring-track { stroke: var(--line); }

.swap__ring-time {
  stroke: var(--you);
  stroke-dasharray: 100;
  stroke-dashoffset: 0;
}

.swap__slow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-4);
  padding: var(--space-4) var(--space-10);
  border-radius: var(--radius-pill);
  background: var(--bad-bg);
  color: var(--bad);
  font-weight: 700;
}

.swap__vs {
  display: flex;
  align-items: center;
  gap: var(--space-10);
  color: var(--muted);
  font-size: var(--text-13);
}

.swap__vs::before,
.swap__vs::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--line);
}

/* Your lead: one row (label, name, types), so their card keeps the height. */
.swap__card--you {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  column-gap: var(--space-10);
  row-gap: var(--space-4);
  padding: var(--space-10) var(--space-16);
}

.swap__card--you .swap__name { font-size: var(--text-19); }

/* Bottom third: attack (stay) left, bench right, in team order. */
.swap__controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: var(--space-10);
  min-height: clamp(184px, 32svh, 300px); /* grows if the bench's names and types need it */
}

.swap__bench {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: var(--space-10);
}

.swap__choice {
  position: relative;
  display: grid;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.swap__attack {
  align-content: center;
  justify-items: center;
  gap: var(--space-4);
  padding: var(--space-16);
  border-color: var(--you);
  background: var(--you);
  color: var(--on-dark);
  text-align: center;
}

.swap__attack-label {
  font-size: var(--text-25);
  font-weight: 800;
}

.swap__swap {
  align-content: center;
  justify-items: start;
  gap: 2px;
  padding: var(--space-10) var(--space-14);
  text-align: left;
}

.swap__swap-name {
  font-size: var(--text-17);
  font-weight: 700;
  line-height: 1.15;
}

.swap__swap-types {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

/* Compact chips on the bench, so both types fit on one row. */
.swap__swap-types .type-chip {
  gap: 3px;
  padding: 1px 7px 1px 5px;
}

.swap__swap-types .type-glyph {
  width: 12px;
  height: 12px;
}

/* The verdict, immediately and without words: green with a check, red with a cross; the
   answer gets its check too, and everything else steps back. */
.swap__controls.is-decided .swap__choice {
  cursor: default;
  opacity: 0.45;
}

.swap__controls.is-decided .swap__choice.is-correct,
.swap__controls.is-decided .swap__choice.is-wrong,
.swap__controls.is-decided .swap__choice.is-answer {
  opacity: 1;
}

.swap__choice.is-correct,
.swap__choice.is-answer {
  border-color: var(--good);
  outline: 3px solid var(--good);
  outline-offset: -3px;
  background: var(--good-bg);
  color: var(--ink);
}

.swap__choice.is-wrong {
  border-color: var(--bad);
  outline: 3px solid var(--bad);
  outline-offset: -3px;
  background: var(--bad-bg);
  color: var(--ink);
}

.swap__mark {
  position: absolute;
  top: var(--space-10);
  right: var(--space-10);
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-pill);
  color: var(--on-dark);
  font-size: var(--text-19);
  font-weight: 800;
}

.swap__mark:empty { display: none; }
.is-correct .swap__mark,
.is-answer .swap__mark { background: var(--good); }
.is-wrong .swap__mark { background: var(--bad); }

.swap__verdict {
  font-size: var(--text-25);
  font-weight: 800;
}

.swap__verdict[data-kind="correct"] { color: var(--good); }
.swap__verdict[data-kind="wrong"],
.swap__verdict[data-kind="slow"] { color: var(--bad); }
