/* War screen styles (T-014 / R-011, Arena restyle).

   Composes web/css/tokens.css + components.css primitives (.card/.card-flat/
   .seg/.pill/.tag/.meter/.art/.eyebrow/.h2/.num/.tnum) - nothing here
   redefines a component, only screen-specific layout/spacing.

   `.round-details`/`.round-row`/`.round-row-head`/`.round-crowns`/`.vs-line`/
   `.vs-label` style the OUTPUT of window.WarTab.buildRoundDetails, which is
   also called by web/screens/battles.js's detail sheet (T-008) - defined once,
   here, since this file owns the renderer (see web/screens/war.js header).
   Plain global class names are fine: CSS is document-wide regardless of
   which <link> declared a rule, and no other screen defines these names. */

/* ---------- local range chip (D-021: War keeps its own, not the global sheet) */

/* No top padding: the shell's `.content` padding owns the gap under the top bar
   (T4-010), so War's first block sits where every other screen's does. The seg's
   own 3px padding already holds its 2px focus ring + offset inside the scroller. */
.war-range-slot {
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 0 6px;
}
.war-range-slot::-webkit-scrollbar { display: none; }
.war-range-slot .seg { width: max-content; }

/* The six options are 415px wide, more than a 390px phone has: fade the right
   edge so the cut-off "90d" reads as "scrolls on". A mask, not an overlay, so it
   never covers an option's hit area - and never over a focused control: a keyboard
   user on the last option must see it and its ring at full contrast.

   The fade is a cue for options BEYOND the right edge, so it is the row's own
   state, not a constant (T4-038): web/screens/war.js sets `.war-range-more` while
   the row overflows and is not scrolled to its end. Scrolled to the end it used to
   stay on and dim the last option ("90d") until it was focused; on a ~446-767px
   screen, where all six fit, it was on with nothing to scroll to. (Battles'
   `.bt-chips` is not a second user of this cue: it wraps instead of scrolling.) */
@media (max-width: 767px) {
  .war-range-slot.war-range-more {
    -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent);
    mask-image: linear-gradient(90deg, #000 85%, transparent);
  }
  .war-range-slot.war-range-more:focus-within { -webkit-mask-image: none; mask-image: none; }
}

/* ---------- scope line: "every mode - the filter chip doesn't apply" (R-011) ----------
   One short muted line + a tappable info tip carrying the full sentence. On a
   phone the tip sits at the row's right edge so its right-aligned popover
   (300px wide) stays on screen; from 768px up it hugs the text and the popover
   opens to the RIGHT of the button instead - the shared right-aligned one would
   run left under the 240px sidebar at 1024px+. */

.war-note {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 8px;
}
.war-note-text { flex: 1; min-width: 0; }
@media (min-width: 768px) {
  .war-note-text { flex: none; }
  .war-note .info-tip-note { right: auto; left: 0; }
}

/* ---------- empty states ---------- */

.war-empty-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 52px 20px;
  text-align: center;
}
.war-empty-small { padding: 14px 2px; }

/* Nothing painted yet (first visit, or the first load after a player switch):
   a few shimmering bars until /war answers; removed on success or failure
   (G3 R1-04). */
.war-loading { display: flex; flex-direction: column; gap: 10px; padding: 22px 18px; }
.war-skel { height: 14px; border-radius: 6px; }
.war-skel:nth-child(1) { width: 88%; }
.war-skel:nth-child(2) { width: 70%; }
.war-skel:nth-child(3) { width: 52%; }

/* ---------- layout ---------- */

/* A grid item's automatic minimum width is its MIN-CONTENT width, and the weekly
   chart's Chart.js canvas starts at the 300px of an unsized <canvas>: on a phone the
   one-column grid (`.grid-2`, a single `1fr` track) could not get narrower than that
   canvas plus its card's 34px = 334px. Below ~366px the page scrolled sideways
   (body's `overflow-x: hidden` clipped it silently): the second KPI tile and the
   percentages ran off the screen, at 360px the right gutter shrank to 10px, and
   Chart.js never got to shrink a canvas whose box never shrank (T4-038; the same
   defect as the G3 R2-17 landing card, in a grid instead of a flex row). Letting
   the items shrink lets the track take the screen's width. */
#war-populated .grid-2 > * { min-width: 0; }

.war-top-col { display: flex; flex-direction: column; gap: 12px; }

.war-kpi-row { display: flex; gap: 10px; }
.war-kpi { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.war-kpi-value { font-size: 28px; }

.war-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

/* ---------- by battle type ---------- */

.war-kind-list { display: flex; flex-direction: column; }
.war-kind-row-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}
.war-kind-row-item:first-child { border-top: 0; }
.war-kind-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.war-kind-label { width: 92px; flex: none; font-weight: 800; }
.war-kind-games { width: 68px; flex: none; text-align: right; }
.war-kind-row-item .meter { flex: 1; }
.war-kind-row-item .pct { width: 48px; flex: none; text-align: right; font-weight: 800; }

/* The fixed columns (swatch 10 + label 92 + games 68 + percentage 48 + four 10px
   gaps) take 258px, and a 320px phone has 254px inside this card: the meter is
   squeezed to nothing (16px at 340, 36px at 360). Below 360px the row wraps instead:
   swatch, name, games and percentage stay on the first line, and the meter - the
   row's picture - gets a line of its own at the card's full width. 360px and up is
   the single line it always was. */
@media (max-width: 359px) {
  .war-kind-row-item { flex-wrap: wrap; row-gap: 6px; }
  .war-kind-games { flex: 1; }
  .war-kind-row-item .meter { order: 1; flex: 1 0 100%; }
}

/* ---------- weekly stacked chart ---------- */

.war-chart-box { position: relative; height: 200px; }
.war-legend { display: flex; gap: 12px; font-size: 12px; color: var(--ink-2); }
.war-legend .key { display: inline-flex; align-items: center; gap: 5px; }
.war-legend .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- duels ---------- */

.war-duels-list, .war-boats-list { display: flex; flex-direction: column; gap: 8px; }

.war-duel-row { padding: 0; overflow: hidden; }
.war-duel-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}
.war-duel-summary::-webkit-details-marker { display: none; }
.war-duel-summary::marker { content: ""; }
/* The row clips (overflow: hidden, for its rounded corners), and the global
   focus ring is drawn OUTSIDE the box - so on the summary, the only control in
   the row, it was cut off entirely: a keyboard reader could not see where focus
   was (R2-09 keeps focus on the same summary across a refresh; it has to be
   visible). Drawn inside the box instead, following the row's own radius. */
.war-duel-summary { border-radius: 12px; }
.war-duel-summary:focus-visible { outline-offset: -2px; }
.war-duel-rounds { width: 42px; flex: none; text-align: right; font-weight: 800; }
.war-duel-opp { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.war-duel-summary > .i { flex: none; color: var(--ink-3); transition: transform .15s ease; }
.war-duel-row[open] .war-duel-summary > .i { transform: rotate(90deg); }
.war-duel-row .round-details { padding: 0 14px 14px; }

/* ---------- boat battles ---------- */

.war-boat-row { display: flex; align-items: center; gap: 10px; }
.war-boat-side { width: 74px; flex: none; }
.war-boat-towers { flex: 1; min-width: 0; }

/* ---------- shared duel round-details renderer (see file header) ---------- */

.round-details { display: flex; flex-direction: column; gap: 12px; }
.round-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.round-row:first-child { padding-top: 0; border-top: 0; }
.round-row-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.round-crowns { font-weight: 800; }
.vs-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.vs-label { flex: none; width: 28px; font-size: 11px; font-weight: 800; color: var(--ink-3); }
