/* =========================================================
   Team cards and the team sheet (assets/js/team-card.js).
   One card per team: logo, name, conference, Q1 record, overall record, and the
   published ranks as tinted tiles. A card opens the full team sheet in a side panel.
   Built for /bracket/forecast/ (2026-10-16); Bracket Studio's pool adopts the same card.
   Geometry and type come from tokens.css only (npm run check:css ratchets literals).
   ========================================================= */

.tcard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: var(--s-2); }
@media (min-width: 1100px) {
  .tcard-grid.is-line { grid-template-columns: repeat(var(--n), minmax(0, 1fr)); }
}

.tcard {
  display: grid; gap: var(--s-2); width: 100%; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--s-2) 10px; color: var(--text); font: inherit;
  transition: border-color .15s, transform .15s;
}
.tcard:hover { border-color: var(--muted); transform: translateY(-1px); }
.tcard:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.tcard.is-flagged { border-color: var(--studio-border); }

.tcard-top { display: grid; grid-template-columns: auto 28px minmax(0, 1fr) auto; gap: var(--s-2); align-items: center; }
.tcard-top.no-rank { grid-template-columns: 28px minmax(0, 1fr) auto; }
.tcard-rank { font-family: var(--fd); font-weight: 700; font-size: var(--t-lede); line-height: 1; color: var(--sub); min-width: 20px; text-align: right; font-variant-numeric: tabular-nums; }
.tcard-logo { width: 28px; height: 28px; object-fit: contain; display: block; }
.tcard-name { min-width: 0; }
.tcard-name b { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-weight: 600; font-size: var(--t-body); line-height: 1.2; }
.tcard-name small { display: block; color: var(--muted); font-size: var(--t-label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcard-rec { font-family: var(--fm); font-size: var(--t-meta); color: var(--sub); }
.tcard-tag { justify-self: start; font-size: var(--t-mini); color: var(--orange); border: 1px solid var(--studio-border); border-radius: var(--r-sm); padding: 0 5px; }

.tcard-mets { display: grid; grid-template-columns: repeat(var(--m, 7), minmax(0, 1fr)); gap: calc(var(--s-1) / 2); }
.tcard-met { border-radius: var(--r-sm); padding: 3px 0; text-align: center; background: var(--surface); }
.tcard-met span { display: block; font-family: var(--fd); font-size: var(--t-mini); letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
.tcard-met b { display: block; font-family: var(--fm); font-weight: 500; font-size: var(--t-meta); font-variant-numeric: tabular-nums; }
.tcard-met.is-sort { box-shadow: inset 0 0 0 1px var(--sub); }
/* Last season's rank, carried over until this season's publishes: no tint, dashed edge. */
.tcard-met.is-stale, .tsheet-mets b.is-stale { background: none; outline: 1px dashed var(--muted); outline-offset: -1px; }
.tcard-met.is-stale b { color: var(--muted); }
.rank-t1 { background: var(--rank-t1); }
.rank-t2 { background: var(--rank-t2); }
.rank-t3 { background: var(--rank-t3); }

/* Six-team seed lines on one row: the name wraps, the conference moves to the sheet. */
@media (min-width: 1100px) {
  .tcard-grid.is-tight .tcard { padding: var(--s-2); }
  .tcard-grid.is-tight .tcard-top { gap: var(--s-1); }
  .tcard-grid.is-tight .tcard-name b { font-size: var(--t-ui); }
  .tcard-grid.is-tight .tcard-conf { display: none; }
  .tcard-grid.is-tight .tcard-met b { font-size: var(--t-label); letter-spacing: -.02em; }
}

.tcard-scale { display: inline-flex; align-items: center; gap: var(--s-1); color: var(--muted); font-size: var(--t-label); }
.tcard-scale i { display: inline-block; width: 18px; height: 10px; border-radius: var(--r-sm); }

/* ── The team sheet ─────────────────────────────────────── */
.tsheet { margin: 0 0 0 auto; height: 100%; max-height: 100%; width: min(520px, 100%); max-width: 100%; border: 0; border-left: 1px solid var(--border); padding: 0; background: var(--surface); color: var(--text); }
.tsheet::backdrop { background: rgba(1, 10, 22, 0.66); }
.tsheet-body { padding: max(20px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) 32px 20px; display: grid; gap: var(--s-5); }
.tsheet-head { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: var(--s-3); align-items: center; }
.tsheet-head .tcard-logo { width: 64px; height: 64px; }
.tsheet-head h2 { margin: 0; font-family: var(--fe); font-weight: 500; font-size: var(--t-h2); line-height: 1.15; }
.tsheet-head small { color: var(--muted); }
.tsheet-seed { margin-top: var(--s-1); font-family: var(--fd); font-weight: 700; font-size: var(--t-ui); letter-spacing: .1em; text-transform: uppercase; color: var(--orange); }
.tsheet-x { align-self: start; width: 34px; height: 34px; border-radius: var(--r-pill); border: 1px solid var(--border); background: none; color: var(--sub); cursor: pointer; font-size: var(--t-strong); }
.tsheet h3 { margin: 0 0 var(--s-2); font-family: var(--fd); font-weight: 500; font-size: var(--t-label); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.tsheet-kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.tsheet-kv.is-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tsheet-kv div, .tsheet-quads div { background: var(--card); border-radius: var(--r-md); padding: var(--s-2) 10px; }
.tsheet-kv span { display: block; color: var(--muted); font-size: var(--t-label); }
.tsheet-kv b, .tsheet-quads b { font-family: var(--fm); font-weight: 500; font-size: var(--t-strong); }
.tsheet-quads { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-2); text-align: center; }
.tsheet-quads span { display: block; font-family: var(--fd); font-size: var(--t-label); letter-spacing: .1em; color: var(--muted); }
.tsheet-mets { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tsheet-mets td { padding: 7px 0; border-bottom: 1px solid var(--border); }
.tsheet-mets td:first-child { font-weight: 600; }
.tsheet-mets td.who { color: var(--muted); font-size: var(--t-meta); padding-inline: var(--s-2); }
.tsheet-mets td.who a { color: inherit; }
.tsheet-mets td.r { text-align: right; }
.tsheet-mets td.r b { display: inline-block; min-width: 40px; text-align: center; border-radius: var(--r-sm); padding: 1px 6px; font-family: var(--fm); font-weight: 500; }
.tsheet-games { display: grid; gap: var(--s-1); }
.tsheet-game { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto auto; gap: var(--s-2); align-items: center; background: var(--card); border-radius: var(--r-md); padding: 7px 10px; }
.tsheet-game .tcard-logo { width: 20px; height: 20px; }
.tsheet-game .o { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tsheet-game .o small { color: var(--muted); margin-left: var(--s-1); }
.tsheet-game .nt { font-family: var(--fm); font-size: var(--t-label); color: var(--muted); }
.tsheet-game .sc { font-family: var(--fm); font-size: var(--t-meta); }
.tsheet-game .sc.w { color: var(--ok); }
.tsheet-game .sc.l { color: var(--danger); }
.tsheet-note { color: var(--muted); font-size: var(--t-meta); margin: 0; }
@media (max-width: 760px) { .tsheet-kv { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (prefers-reduced-motion: reduce) { .tcard { transition: none; } .tcard:hover { transform: none; } }
