/* Clash Royale Stats 3.0.0 - "Arena" component classes (T-002 / R-002 / R-005).

   The component layer of design/v3/parts/common.css, reproduced with the same
   values. Everything here is a reusable primitive the ten screen tasks compose;
   nothing here knows about a particular screen. Layout (app bar / chip row /
   tab bar / sidebar / content grid) lives in web/css/shell.css.

   Deliberate additions over common.css - the artboards are static pictures, a
   real UI needs the interactive states:
     - every control selector also matches <button>/<a> (the artboards use <span>),
       so chips and segs are real keyboard-operable controls;
     - :focus-visible rings (R-005);
     - .livedot.stale/.error/.pulse (states the artboards never show);
     - .art.xs (the artboards inline-style it in design/v3/build.py);
     - the .sheet primitive, .skeleton shimmer and .hidden.
   `.tnum` lives in web/css/tokens.css with the rest of the base type.

   v3.1 (T4-001) adds the shared primitives the focus round's screens compose:
   `.seg.views` (CRUI.viewTabs), the `.card-head` / `.card-title` / `.card-sub`
   head hierarchy and `.info-tip` (CRUI.infoTip). T4-010 added `.list-more`
   (the one in-list expand button) and anchors an info tip's note to its card
   head.

   T-016 dropped `.hair` (never used by any screen). `.art.lg` stays even though
   no screen asks for that size today: `size` is a documented parameter of
   CRUI.art(card, size, extra), so deleting the rule would make `art(c, "lg")`
   silently render at the default size instead. */

/* ---------- type ramp ---------- */

.display { font-family: var(--display); font-weight: 800; letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.num { font-family: var(--display); font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.h1 { font-family: var(--display); font-weight: 800; font-size: 28px; letter-spacing: -0.02em; line-height: 1.05; margin: 0; }
.h2 { font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; line-height: 1.2; margin: 0; }
.muted { color: var(--ink-3); }
.sec { color: var(--ink-2); }
.small { font-size: 12px; }
.tiny { font-size: 12px; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.gold { color: var(--gold); }

/* ---------- surfaces ---------- */

.card { background: var(--s1); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.card-flat { background: var(--s2); border-radius: 12px; padding: 12px 14px; }

/* ---------- controls ---------- */

.chip {
  height: 36px; padding: 0 14px; border-radius: 999px;
  background: var(--s2); border: 1px solid var(--line); color: var(--ink-2);
  font-weight: 700; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex: none;
}
.chip.on { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.chip.ghost { background: transparent; }

.seg { display: inline-flex; background: var(--s2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg span, .seg button {
  padding: 7px 12px; min-height: 36px; display: inline-flex; align-items: center;
  border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--ink-2);
  background: transparent; border: 0; white-space: nowrap;
}
.seg span.on, .seg button.on { background: var(--gold); color: var(--gold-ink); }

.btn {
  height: 44px; padding: 0 18px; border-radius: 12px;
  background: var(--s2); border: 1px solid var(--line-2); color: var(--ink);
  font-weight: 800; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn.sm { height: 36px; padding: 0 14px; font-size: 13px; border-radius: 10px; }
/* The ONE destructive button (T5-030c / SA5): white on #c6343a is 5.2:1, the token red under
   white text is 3.7:1. Account's Delete / sheet confirms and the Admin console's Purge /
   Delete / Disable confirms all use it; a screen adds only its own :disabled look. */
.btn.danger { background: #c6343a; border-color: #c6343a; color: #fff; }

.iconbtn {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--s2); border: 1px solid var(--line); color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}

.pill { display: inline-flex; align-items: center; justify-content: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.pill.win { background: var(--good-soft); color: var(--good); }
.pill.loss { background: var(--bad-soft); color: var(--bad); }
.pill.draw { background: var(--s3); color: var(--ink-2); }

.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; background: var(--s3); color: var(--ink-2); }
.tag.ranked { background: var(--blue-soft); color: #7fb3f0; }
.tag.ladder { background: rgba(180,90,242,.18); color: #cf9af7; }
.tag.war { background: rgba(217,89,38,.18); color: #f08a5c; }
.tag.challenge { background: rgba(25,158,112,.18); color: #4fd0a0; }
.tag.two { background: var(--s3); color: var(--ink-2); }

/* Sub-view switcher (CRUI.viewTabs, R-012): the same radiogroup as `.seg`,
   full width with equal segments on a phone, auto width from 768px up. The
   button is 40px tall (the 3px padding + 1px border make the control 48px), so
   a thumb never has to aim. */
.seg.views { display: flex; width: 100%; margin-bottom: 16px; }
.seg.views button {
  flex: 1 1 0; min-width: 0; min-height: 40px; justify-content: center;
}
@media (min-width: 768px) {
  .seg.views { display: inline-flex; width: auto; }
  .seg.views button { flex: none; padding-left: 18px; padding-right: 18px; }
}

/* ---------- in-list expand button (T4-010) ----------
   ONE control for every "there is more of this list" button - Cards, Deck
   insights, Habits and Battles each used to draw their own (transparent text,
   filled bar, outlined pill, 220px button). Full width under the list, 40px
   tall, filled `--s2`, muted until hovered.
   Label grammar (every screen, so the list reads the same everywhere):
     "Show all (N)"   expands a capped list to its full length of N rows
     "Show more (N)"  reveals the next page; N is how many rows are still hidden
     "Show less"      collapses it again
   Battles pages from the server, so it keeps its "Load more" wording but uses
   the class. N carries a thousands separator (`toLocaleString()`). */
.list-more {
  display: flex; align-items: center; justify-content: center;
  margin-top: 8px; width: 100%; min-height: 40px;
  border: 0; border-radius: 10px;
  background: var(--s2); color: var(--ink-2);
  font-size: 13px; font-weight: 700;
}
.list-more:hover { color: var(--ink); }

/* ---------- card head hierarchy (R-012) ----------
   One head shape for every card: a title (the question the card answers), at
   most ONE short muted scope line under it, and an optional action on the right
   (an info tip, a toggle). Screens opt in by using the classes; nothing here
   restyles a card that does not. */
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.card-title { font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; line-height: 1.2; margin: 0; }
.card-sub { font-size: 12px; line-height: 1.35; color: var(--ink-3); }

/* ---------- info tip (CRUI.infoTip, R-012) ----------
   A <details> whose <summary> is the "i" button and whose note is a popover
   under it. Outside a card head, `position: relative` on the details anchors the
   note, right-aligned to the button.

   Inside a `.card-head` the CARD HEAD is the anchor instead (T4-010): the
   button is not always the head's right-most item (Trends' trophy card puts a
   Trophy Road / Path of Legends toggle after it), and a note right-aligned to a
   button in the middle of the row ran off the LEFT edge of a phone (measured
   left = -27 and -167 at 390px). A note that spans the head can never leave the
   card, so it can never leave the screen. From 768px up the note keeps a
   readable measure and hangs from the head's right edge.

   The button's hit area is 40x40 (the touch floor used everywhere else); the
   -4px margin hands the extra 4px back so the glyph and the head's height do
   not move. */
.info-tip { position: relative; display: inline-flex; flex: none; }
.card-head { position: relative; }
.card-head .info-tip { position: static; }
.info-tip > summary {
  list-style: none; cursor: pointer;
  min-width: 40px; min-height: 40px; margin: -4px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-3);
}
.info-tip > summary::-webkit-details-marker { display: none; }
.info-tip > summary::marker { content: ""; }
.info-tip > summary:hover,
.info-tip > summary:focus-visible,
.info-tip[open] > summary { color: var(--ink); }
.info-tip > summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 0; }
.info-tip-note {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 30;
  width: min(300px, 85vw);
  padding: 10px 12px; border-radius: 12px;
  background: var(--s2); border: 1px solid var(--line-2);
  box-shadow: 0 8px 28px rgba(0,0,0,.5);
  font-size: 12px; font-weight: 500; line-height: 1.45; letter-spacing: 0; text-transform: none;
  color: var(--ink-2); text-align: left; white-space: normal;
}
.card-head .info-tip-note { left: 0; right: 0; width: auto; max-width: none; }
@media (min-width: 768px) {
  .card-head .info-tip-note { left: auto; width: min(340px, 100%); }
}
.info-tip-note p { margin: 0; }
.info-tip-note p + p { margin-top: 8px; }

/* ---------- meters ---------- */

.meter { position: relative; height: 8px; border-radius: 4px; background: var(--s3); overflow: visible; }
.meter .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--blue); }
/* CRUI.pctSpan's `.pct` is read down a column (Cards, Habits, Deck insights,
   matchups), so it gets tabular figures like every other compared number
   (R-002). The 2.0.0 shim used to carry this rule; T-016 deleted the shim. */
.pct { font-variant-numeric: tabular-nums; }
.pct.low-sample, .low-sample { color: var(--ink-3); font-style: italic; font-weight: 600; }
.meter .base { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink-3); border-radius: 1px; }

/* ---------- card art chips ---------- */

.art { position: relative; width: 40px; height: 48px; border-radius: 8px; background: var(--s3); border: 1.5px solid var(--line-2); overflow: hidden; flex: none; }
.art img { width: 100%; height: 100%; object-fit: cover; }
.art .el { position: absolute; left: 2px; bottom: 2px; width: 15px; height: 15px; border-radius: 50%; background: var(--elixir); color: #fff; font-size: 9px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.art .ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; color: var(--ink-2); }
.art.xs { width: 22px; height: 26px; border-radius: 5px; border-width: 1px; }
.art.xs .el, .art.sm .el { display: none; }
.art.xs .ph { font-size: 9px; }
.art.sm { width: 28px; height: 34px; border-radius: 6px; }
.art.sm .ph { font-size: 10px; }
.art.md { width: 48px; height: 58px; border-radius: 9px; }
.art.lg { width: 64px; height: 77px; border-radius: 10px; }
.art.lg .el { width: 18px; height: 18px; font-size: 11px; left: 3px; bottom: 3px; }
.art.lg .ph { font-size: 16px; }
.art.rare { border-color: #c27a3a; }
.art.epic { border-color: #9d6fd0; }
.art.legendary { border-color: #62bcd0; }
.art.champion { border-color: var(--gold); }
.art.dim { opacity: .38; }
.art.req { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold), 0 0 14px rgba(245,184,61,.35); }
.art .evo { position: absolute; right: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--gold); color: var(--gold-ink); display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 800; }
.art .chk { position: absolute; right: 2px; bottom: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--gold); color: var(--gold-ink); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; }

/* ---------- app bar / tab bar / sidebar chrome ---------- */

.appbar { height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 16px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--gold); color: var(--gold-ink); font-family: var(--display); font-weight: 800; font-size: 14px; display: flex; align-items: center; justify-content: center; flex: none; }

.livedot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 8px var(--good); flex: none; }
.livedot.stale { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.livedot.error { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
.livedot.pulse { animation: cr-pulse 1s ease-out; }
@keyframes cr-pulse { 0% { transform: scale(1.9); } 100% { transform: scale(1); } }

/* Positioning of .tabbar is shell.css's job (the artboards absolutely position
   it inside a 390x844 phone frame); the surface values below are the artboard's. */
.tabbar { height: 84px; padding: 8px 8px 22px; display: flex; align-items: stretch; background: rgba(11,14,20,.94); border-top: 1px solid var(--line); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--ink-3); font-size: 11px; font-weight: 700; border-radius: 12px; min-height: 44px; }
.tab.on { color: var(--gold); }
.tab.on .ico { background: var(--gold-soft); }
.tab .ico { width: 44px; height: 28px; border-radius: 999px; display: flex; align-items: center; justify-content: center; }

.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 8px auto 10px; }

.side { width: 240px; background: var(--s1); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 20px 14px; gap: 6px; }
.nav { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px; border-radius: 12px; color: var(--ink-2); font-weight: 700; font-size: 14px; }
.nav.on { background: var(--gold-soft); color: var(--gold); }

/* ---------- lists / icons ---------- */

.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.i { display: inline-flex; flex: none; vertical-align: middle; }

/* ---------- focus rings (R-005) ---------- */

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.chip:focus-visible, .btn:focus-visible, .iconbtn:focus-visible,
.tab:focus-visible, .nav:focus-visible, .seg button:focus-visible,
.avatar:focus-visible, .row:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px;
}

/* ---------- sheet primitive (R-001 / R-005) ----------
   Mobile: a bottom sheet. >=1024px: a centered dialog. The kernel
   (web/app.js openSheet/closeSheet) owns role=dialog, aria-modal, the labelled
   title, the focus trap, `inert` on the app root and the body scroll lock. */

.sheet-root { position: fixed; inset: 0; z-index: 200; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(4,6,11,.66); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 92vh; max-height: 92dvh;
  display: flex; flex-direction: column;
  background: var(--s1);
  border-top: 1px solid var(--line-2);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -12px 40px rgba(0,0,0,.5);
  padding-bottom: env(safe-area-inset-bottom);
  animation: cr-sheet-up .18s ease-out;
}
@keyframes cr-sheet-up { from { transform: translateY(14px); opacity: .7; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 0 16px 8px; }
.sheet-head .h1 { font-size: 24px; flex: 1; min-width: 0; }
.sheet-body { padding: 0 16px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.sheet-foot { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); }
.sheet-foot:empty { display: none; }
body.sheet-open { overflow: hidden; }
/* The dialog container is where the kernel parks focus when the control that held
   it was removed (R1-10). It is not a control: no ring around the whole sheet. */
.sheet-panel:focus, .sheet-panel:focus-visible { outline: none; }

.art-row { display: flex; gap: 3px; flex-wrap: wrap; align-items: center; }

@media (min-width: 1024px) {
  .sheet-panel {
    left: 50%; right: auto; bottom: auto; top: 50%;
    transform: translate(-50%, -50%);
    width: min(560px, calc(100vw - 64px));
    max-height: min(80vh, 760px);
    border: 1px solid var(--line-2); border-radius: 18px;
    animation: none;
  }
  .sheet-panel .grab { display: none; }
  .sheet-head { padding-top: 16px; }
}

/* ---------- skeleton / utilities ---------- */

.skeleton {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--s2) 25%, var(--s3) 37%, var(--s2) 63%);
  background-size: 400% 100%;
  animation: cr-shimmer 1.4s ease infinite;
}
@keyframes cr-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.hidden { display: none !important; }
