/* Battles screen (T-008 / R-007; v3.1 T4-003) - "What happened in my games?".

   Screen-scoped rules only: every colour, radius, pill, chip and art chip comes
   from web/css/tokens.css + web/css/components.css. Nothing here redefines a
   token or a component class.

   Layout intent (D-044): a day-grouped list of calm three-line rows, each with a
   3px result bar on its left edge (colour is the SECOND signal - the pill always
   spells WIN / LOSS / DRAW out, R-005). Line 1 = result chip, opponent, score,
   trophy change; line 2 = the OPPONENT's 8 cards (the tracked player's own deck
   is identical row after row and lives in the detail sheet); line 3 = muted
   category / mode / time. All numbers are tabular. The battle count rides in the
   app-bar title at every width; from 1024px the list uses the extra width as a
   second column, with the day headers spanning both. */

/* R-005 TEXT FLOOR. The shared `.tiny` is 12px (components.css); the rule below
   is kept as a guard so a future change of the shared size cannot push this
   screen's mixed-case lines (relative time, the day line, the mode, the duel
   note) under the floor. Scoped to this screen's own subtree. */
#battles-body .tiny { font-size: 12px; }

/* The local chip row: All / Wins / Losses / Draws, the removable day chip while a
   `?day=` calendar jump is active, and the ONE Filter chip (mode, deck and
   opponent live in its sheet). It WRAPS rather than scrolls: the old
   horizontally scrolling row pushed the Deck and Opponent chips - and an active
   day chip - off a 390px screen where nothing said they existed. */
.bt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 8px;
}
/* 12px side padding instead of the shared 14px: it is what lets "All Wins Losses
   Draws" and a "Filter · N" chip share ONE line at 390px (they are 6px too wide
   at 14px, which would strand the Filter chip alone on a second line). */
.bt-chips .chip { padding: 0 12px; }

.bt-list { display: flex; flex-direction: column; gap: 6px; }

/* R2-12: the loading state (a player switch, a first visit, a retry) - four
   placeholder rows about the height of a real three-line row, so the list does
   not jump when the answer lands. The shimmer is the shared `.skeleton`. */
.bt-list .bt-skel { height: 84px; border-radius: 12px; }

/* The day header: ONE quiet line - "TODAY   16W 13L 1D · −120 Trophy Road" with
   the battle count muted at the far end. A partial day (the last one in the
   loaded window) has no count and its figures read "... so far" in muted ink;
   the stats wrap rather than truncate, so "so far" is never cut off. */
.bt-dayhead {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  padding: 8px 2px 0;
}
.bt-dayhead:first-child { padding-top: 0; }
.bt-dayname { color: var(--ink-2); flex: none; }
.bt-daystats { min-width: 0; }
.bt-daycount { margin-left: auto; flex: none; }

/* E1-01 / D-035. The day net is a TROPHY ROAD figure (ladder rows only), so
   it says so right beside the number: a bare signed number on a day that also
   had Path of Legends battles is read as trophies, and was. The unit rides
   with the number - the two never wrap apart - and drops out of the tabular
   figures the rest of the line uses, since it is a word, not a column. */
.bt-daynet { white-space: nowrap; }
.bt-daynet-unit { font-variant-numeric: normal; color: var(--ink-3); }

/* ---------- one battle ---------- */

.bt-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  padding: 9px 12px;
  text-align: left;
  border-left: 3px solid var(--ink-3);
  cursor: pointer;
}
.bt-row.bt-win { border-left-color: var(--good); }
.bt-row.bt-loss { border-left-color: var(--bad); }
.bt-row.bt-draw { border-left-color: var(--ink-3); }
.bt-row:hover { background: var(--s3); }

/* line 1 */
.bt-l1 { display: flex; align-items: center; gap: 10px; min-width: 0; }
/* WIN / LOSS / DRAW chips share one width so the opponent names line up. */
.bt-l1 .pill { flex: none; min-width: 46px; }
.bt-opp {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  color: var(--ink);
}
.bt-opp b { font-weight: 800; }
.bt-partner { font-weight: 600; }
.bt-score { display: flex; align-items: baseline; gap: 10px; flex: none; }
.bt-crowns { font-size: 18px; }
.bt-tchange { min-width: 36px; text-align: right; font-weight: 800; }

/* line 2: the opponent's cards (or the no-deck note, INV-6) */
.bt-l2 { min-width: 0; }
.bt-l2 .art-row { gap: 4px; flex-wrap: nowrap; }
.bt-duel { font-weight: 700; }

/* line 3: muted meta. The mode is the only piece allowed to shrink (a
   challenge's name can be long); the time at the end never gets cut off. */
.bt-l3 { display: flex; align-items: baseline; min-width: 0; white-space: nowrap; }
.bt-l3 > * { flex: none; }
.bt-l3 .bt-mode { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.bt-sep { white-space: pre; }
.bt-cat { color: var(--ink-2); }

/* ---------- pagination / empty ---------- */

/* The Load-more button is the shared `.list-more` (components.css) - nothing of
   its look lives here. */
.bt-more-wrap { padding: 12px 0 4px; }
.bt-empty, .bt-fail {
  padding: 40px 16px;
  text-align: center;
  background: var(--s1);
  border: 1px solid var(--line);
  border-radius: 16px;
}
/* A failed first load: the reason in the shared error red, then the way out. */
.bt-fail { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.bt-fail .error-text { margin-top: 0; }

/* ---------- the Filter sheet: Deck, Opponent, (Day), Game mode ---------- */

.bt-filter-group { display: flex; flex-direction: column; gap: 4px; }
.bt-filter-row { width: 100%; text-align: left; cursor: pointer; min-height: 44px; }
.bt-filter-row.on { color: var(--gold); }
.bt-filter-note { flex: none; }
.bt-opp-input { flex: none; width: 100%; }
.bt-picker { display: flex; flex-direction: column; }
.bt-pick-row { width: 100%; text-align: left; cursor: pointer; min-height: 44px; }
.bt-pick-row.on { color: var(--gold); }
.bt-pick-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt-pick-note { flex: none; }
/* The mode list's failed state (R1-11): the reason, then Retry beneath it. The
   list takes programmatic focus while a Retry reloads it (tabindex=-1) and is
   not a control, so it draws no focus ring of its own. */
.bt-pick-fail { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 4px 0; }
.bt-pick-fail .error-text { margin-top: 0; }
.bt-picker:focus { outline: none; }

/* ---------- app-bar count (desktop, where the title is visible) ---------- */

.bt-appbar-count { margin-left: 8px; vertical-align: middle; }
/* Visually hidden, still read: the ", " that keeps the heading's accessible name
   "Battles, 3,585" instead of "Battles3,585". */
.bt-vh {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

@media (min-width: 1024px) {
  .bt-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 16px;
    align-items: start;
  }
  .bt-dayhead { grid-column: 1 / -1; }
  /* The cards stay a fixed, modest size - a row is half the content width here
     and an 8-card strip stretched across it would be absurd - and the row gets
     a little more air than it has on a phone. */
  .bt-row { padding: 12px 16px; gap: 8px; }
  .bt-l2 .art-row { gap: 5px; }
  .bt-l2 .art.sm { width: 34px; height: 41px; }
}

/* F2-03: the inline "that page failed" line, between the list and the button
   the failure turned into "Retry". */
.bt-page-error { text-align: center; }
