/* Sports Team Picker (#025). Only this tool's own pieces; everything else is the shared tool frame and the shared rule
   rows. Colours come from the site's variables only (tests/catalogue.test.mjs checks there are no hex values here). */

/* ---------- players ---------- */
.tp-names { min-height: 168px; font-size: 17px; line-height: 1.55; }
.tp-status { margin: -2px 0 0; min-height: 1.4em; font-size: 14px; color: var(--slate); font-variant-numeric: tabular-nums; }
.tp-status.is-problem, .tp-shape .is-problem { color: var(--graphite); font-weight: 600; }

/* Levels: one quiet row per player. Everyone starts Steady, so a changed row is the one that stands out: its level is
   filled dark and its name bolder. The control is three real radio buttons, labelled with the player's name. */
.tp-tally { margin: 0; min-height: 1.4em; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tp-rows { border-radius: var(--r-card); background: var(--white); box-shadow: inset 0 0 0 1px var(--silver); overflow: hidden; }
.tp-rows__empty { margin: 0; padding: 18px 16px; font-size: 14px; color: var(--steel); }
.tp-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 7px 7px 7px 14px; }
/* The name and its level share a line wherever the screen allows (375px phones included); long names wrap beside it. */
@media (min-width: 360px) { .tp-row { flex-wrap: nowrap; } .tp-row .tp-tag { flex-basis: 100%; } .tp-row:has(.tp-tag) { flex-wrap: wrap; } }
.tp-row + .tp-row { box-shadow: inset 0 1px 0 var(--mist); }
.tp-row__name { flex: 1 1 4em; min-width: 0; font-size: 16px; overflow-wrap: anywhere; }
.tp-row.is-set .tp-row__name { font-weight: 600; }
.tp-seg { flex: none; display: inline-flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--mist); }
.tp-seg__o { position: relative; }
.tp-seg__o input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.tp-seg__o span { display: block; min-width: 50px; min-height: 32px; padding: 7px 8px; border-radius: 7px; font-size: 13px; font-weight: 500; line-height: 1.2; text-align: center; color: var(--slate); transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease; }
.tp-seg__o input:checked + span { background: var(--white); color: var(--graphite); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.tp-seg__o--1 input:checked + span, .tp-seg__o--3 input:checked + span { background: var(--graphite); color: var(--white); box-shadow: none; }
.tp-seg__o input:focus-visible + span { outline: 3px solid var(--graphite); outline-offset: 1px; }
.tp-seg__o:active span { transform: scale(.97); }
.tp-tag { flex: 0 1 9.5em; width: 9.5em; min-width: 0; height: 34px; font-size: 14px; }
.tp-tags-add { justify-self: start; }
.tp-tags-hint { margin: 0; }
.tp-spread { margin: 4px 0 0; padding: 0; border: 0; display: grid; gap: 8px; }
.tp-spread legend { padding: 0; margin-bottom: 8px; font-size: 15px; font-weight: 600; }
.tp-spread__note { margin: 0; font-size: 14px; color: var(--slate); }
.tp-spread__note:empty { display: none; }

/* ---------- set-up ---------- */
.tp-split .chips { margin-bottom: 4px; }
.tp-count { display: flex; align-items: center; gap: 12px; }
.tp-count__l { font-size: 15px; font-weight: 600; }
.tp-shape { margin: 0; min-height: 1.4em; font-size: 15px; color: var(--slate); font-variant-numeric: tabular-nums; }
.tp-left { margin: 4px 0 0; padding: 0; border: 0; min-width: 0; }
.tp-left legend { padding: 0; margin-bottom: 8px; font-size: 15px; font-weight: 600; }
.tp-left__opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---------- the teams ---------- */
/* The teams are the point of the page: names large, teams as plain columns, nothing else competing. */
.tp-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-top: 16px; }
.tp-bar__note { margin: 0; font-size: 14px; color: var(--slate); }
.tp-switch { position: relative; display: inline-flex; align-items: center; gap: 9px; min-height: 36px; font-size: 14px; font-weight: 600; cursor: pointer; }
.tp-switch input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.tp-switch__track { position: relative; flex: none; width: 36px; height: 22px; border-radius: 11px; background: var(--silver); transition: background-color 180ms ease; }
.tp-switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--white); box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform 180ms var(--ease-out); }
.tp-switch input:checked + .tp-switch__track { background: var(--graphite); }
.tp-switch input:checked + .tp-switch__track::after { transform: translateX(14px); }
.tp-switch input:focus-visible + .tp-switch__track { outline: 3px solid var(--graphite); outline-offset: 2px; }
.tp-hint { margin: 4px 0 0; font-size: 14px; color: var(--steel); }
.tp-note { margin: 10px 0 0; font-size: 14px; color: var(--slate); }

.tp-teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 28px 30px; margin-top: 24px; }
@media (min-width: 561px) {
  .tp-teams[data-cols="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tp-teams[data-cols="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tp-teams[data-cols="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  /* Mix lines wrap to two lines in narrow columns; keeping room for two keeps names level across a row of teams. */
  .tp-teams[data-cols="3"] .tp-mix, .tp-teams[data-cols="4"] .tp-mix { min-height: 2.7em; }
}
.tp-team { min-width: 0; break-inside: avoid; }
.tp-team h3 { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 0; padding-bottom: 7px; border-bottom: 2px solid var(--graphite); font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.tp-team h3 span { min-width: 0; overflow-wrap: anywhere; }
.tp-team h3 small { flex: none; font-size: 13px; font-weight: 500; color: var(--steel); font-variant-numeric: tabular-nums; }
.tp-mix { margin: 6px 0 0; font-size: 13px; color: var(--steel); line-height: 1.35; font-variant-numeric: tabular-nums; }
.tp-broken { margin: 8px 0 0; padding: 2px 0 2px 9px; border-left: 3px solid var(--graphite); font-size: 13px; font-weight: 600; line-height: 1.35; }
.tp-team ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; }

/* Each player is a button: tap one, then one on another team, to swap them. The tap target is the whole row (at
   least 44px tall) while the name lines up with the team name above. */
.tp-p { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; width: calc(100% + 16px); min-height: 44px; margin: 0 -8px; padding: 8px; border: 0; border-radius: 8px; background: none; color: var(--graphite); font: inherit; font-size: 17px; line-height: 1.3; text-align: left; cursor: pointer; transition: background-color 140ms ease, color 140ms ease, box-shadow 140ms ease; -webkit-tap-highlight-color: transparent; }
.tp-p__n { min-width: 0; overflow-wrap: anywhere; }
.tp-p:focus-visible { outline: 3px solid var(--graphite); outline-offset: 0; }
.tp-p[aria-pressed="true"] { background: var(--graphite); color: var(--white); }
.tp-teams.is-picking .tp-p:not([aria-pressed="true"]) { box-shadow: inset 0 0 0 1px var(--silver); }
.tp-lv, .tp-tgs { display: none; }
.tp-teams.show-levels .tp-lv { display: inline; margin-left: auto; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--steel); }
.tp-teams.show-levels .tp-tgs { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.tp-tg { padding: 1px 6px; border-radius: 4px; background: var(--mist); color: var(--slate); font-size: 12px; font-weight: 600; }
.tp-p[aria-pressed="true"] .tp-lv { color: var(--silver); }
.tp-p[aria-pressed="true"] .tp-tg { background: var(--slate); color: var(--white); }
@media (hover: hover) { .tp-p:hover:not([aria-pressed="true"]) { background: var(--mist); } }

/* Subs: across the full width under the teams, names in a row. */
.tp-subs { grid-column: 1 / -1; }
.tp-subs h3 { border-bottom-style: dashed; border-bottom-width: 1.5px; }
.tp-subs ul { display: flex; flex-wrap: wrap; gap: 2px 18px; }
.tp-subs li { min-width: 0; }
.tp-subs .tp-p { width: auto; }

.tp-team--empty h3 { border-bottom-color: var(--silver); color: var(--slate); }
.tp-subs.tp-team--empty ul { display: grid; }
.tp-slot { height: 1.3em; margin: 6px 0; border-bottom: 1px dashed var(--silver); }
.tp-more { margin: 8px 0 0; font-size: 13px; color: var(--steel); }
.tp-empty { margin: 0; padding: 36px 0 20px; font-size: 15px; color: var(--steel); }

/* New teams settle into place; a swapped pair flashes once; a change leaves the old teams faint until made again. */
.tp-in { animation: tp-in 240ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 14ms); }
@keyframes tp-in { from { opacity: 0; transform: translateY(5px); } }
.tp-swapped { animation: tp-swap 700ms var(--ease-out); }
@keyframes tp-swap { from { background: var(--silver); } }
@media (prefers-reduced-motion: reduce) { .tp-in, .tp-swapped { animation: none; } }
.tp-paper.is-stale .tp-teams { opacity: .38; transition: opacity 200ms ease; }
.tp-paper.is-stale .tp-p { cursor: default; }
.tp-stale { margin: 0 0 12px; padding: 10px 14px; border-radius: 10px; background: var(--white); box-shadow: inset 0 0 0 1.5px var(--graphite); font-size: 14px; font-weight: 600; }

#tp-again svg { width: 18px; height: 18px; }

/* While a player is picked on a phone or tablet, the next step stays in view at the bottom of the screen, wherever the
   other team is. Wider screens show the same words above the teams. */
.tp-pickbar { position: fixed; z-index: 30; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 8px 8px 16px; border-radius: 14px; background: var(--graphite); color: var(--white); box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .45); }
.tp-pickbar[hidden] { display: none; }
.tp-pickbar p { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.35; }
.tp-pickbar .btn { flex: none; background: var(--white); color: var(--graphite); box-shadow: none; }
@media (min-width: 901px) { .tp-pickbar { display: none !important; } }
/* Inside a frame on another page, the frame is as tall as the tool, so the frame's "bottom of the screen" is the bottom
   of the tool, usually out of sight. There the tool works as it does on a wide screen: the hint above the teams says
   what to do, and tapping the picked player again (or Escape) cancels. */
.toolframe-framed .tp-pickbar { display: none !important; }

.tp-send { margin-top: 20px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.tp-send h2 { margin: 0; color: var(--slate); }
.tp-send__btns { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 560px) {
  .tp-left__opts { grid-template-columns: 1fr; }
  /* Phones: the shared bar puts Download PDF first; here Balance again is the action people repeat, so it leads. */
  .result-bar__actions:has(#tp-again:not([hidden])) #tp-again { grid-column: 1 / -1; order: -2; }
  .result-bar__actions:has(#tp-again:not([hidden])) [data-pdf] { grid-column: auto; order: 0; }
  .result-bar__actions:has(#tp-again:not([hidden])) .btn { padding-inline: 12px; white-space: nowrap; }
  .tp-send__btns { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .tp-send__btns .btn { width: 100%; justify-content: center; min-height: 44px; white-space: nowrap; }
  .tp-send__btns #tp-copy { grid-column: 1 / -1; }
  .tp-teams { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 18px; }
  .tp-p { font-size: 16px; }
  .tp-seg__o span { min-width: 0; padding: 7px 7px; font-size: 12.5px; }
  .tp-teams.show-levels .tp-lv { margin-left: 0; flex-basis: 100%; }
}

@media print {
  .tp-teams { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7mm 8mm; margin-top: 7mm; }
  .tp-teams[data-cols="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 14mm; }
  .tp-teams[data-cols="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tp-teams[data-cols="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: 6mm; }
  .tp-team h3 { font-size: 12pt; padding-bottom: 1.5mm; border-bottom-width: 1.5pt; }
  .tp-team h3 small { font-size: 9pt; }
  .tp-team ul { gap: 1.8mm; margin-top: 2.5mm; }
  .tp-p, .tp-subs .tp-p { display: block; width: auto; min-height: 0; margin: 0; padding: 0; border-radius: 0; background: none !important; color: inherit !important; box-shadow: none !important; font-size: 11.5pt; animation: none; }
  .tp-subs ul { gap: 1.8mm 6mm; }
  .tp-paper.is-stale .tp-teams { opacity: 1; }
}
