/* Hallmark · pre-emit critique: P5 H5 E5 S5 R5 V4 */
/* Hallmark · component: match-card · genre: editorial (the CHAG data-led system) · theme: tokens.css (locked)
 * every button uses the site's raised 3D edge (components.css .btn: --shadow-3d, pressed flat 3 px on :active, flat
 *   when disabled, --color-focus-ring outline)
 * states (row "+ Add"): default · hover · focus-visible · active · disabled (not addable) · success ("✓ Added",
 *   data-slip-added) - loading / error: n/a, adding is local and instant; sync problems are reported by the slip
 * states (header toggle): default · hover (also on header hover) · focus-visible · active · expanded / collapsed
 * contrast: text on --color-surface / --color-bg-secondary, both themes, >= 4.5:1 (header band measured 8:1);
 *   odds keep the navy chip (tokens.css --color-odds-*) because Chag Yellow on white fails contrast
 *
 * One card per fixture: a shared header (competition, kickoff, status, both teams) on a slightly darker band, a
 * toggle that hides or shows the match's prediction rows (open by default), one row per prediction, and a footer.
 * About 30% smaller than the approved concept through type and spacing only - never a transform (blurred text,
 * broken hit areas). The "+ Add" button follows the concept exactly (80 x 44 px, outlined, 8 px radius).
 *
 * Scope: every selector starts with .match-card / .match-row / .match-card-list. Nothing here may reach the
 * Prediction Slip (.prediction-slip*, .slip-*), whose appearance and behaviour stay exactly as they are. */

/* Margins between cards and around the list (owner request 2026-11-30). */
.match-card-list {
  display: grid;
  gap: var(--space-16);
  min-width: 0;
  margin-block: var(--space-8) var(--space-16);
}

.match-card {
  container: match-card / inline-size;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  color: var(--color-text-primary);
}

.match-card--featured {
  border-color: var(--color-accent);
  box-shadow: inset 3px 0 0 var(--color-accent);
}

/* ---- header ---- */

/* The header sits on the same slightly darker band as the footer (owner request 2026-11-30), so the match identity
   reads apart from the prediction rows. Crests take the card surface so they still stand out on that band. */
.match-card__head {
  padding: 0.375rem var(--space-16);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
}

.match-card__head .crest-badge {
  background: var(--color-surface);
}

/* One line always (owner decision 2026-12-01): league logo and name on the left (the name shortens with an ellipsis
   if it must), kickoff, status and the toggle on the right - never wrapped onto a second line. */
.match-card__meta {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-8);
  font-size: var(--font-size-metadata);
  font-weight: var(--font-weight-bold);
  line-height: 1.5;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.match-card__competition {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
}

.match-card__competition-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-card__meta-end {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: var(--space-8);
  white-space: nowrap;
}

.match-card__when {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--space-4) var(--space-8);
}

/* The teams with "Expert Pick" at the end of the line, next to the away team (owner decision 2026-12-01). */
.match-card__teams {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  margin-top: var(--space-4);
}

.match-card__teams .matchup-row {
  flex: 1 1 auto;
  min-width: 0;
  margin-top: 0;
}

/* "Expert Pick" (header) and the row tags ("Expert" in a mixed card, "Model + Analyst") at 9 px, on the existing
   source-badge colours (navy on light, yellow on dark - both AA); text, never colour alone. */
.match-card__expert,
.match-row__expert,
.match-row__source {
  flex: none;
  padding: 0.125rem var(--space-4);
  font-size: var(--font-size-metadata-compact);
  font-weight: var(--font-weight-bold);
  line-height: 1.3;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.match-card__expert {
  text-transform: none;
}

.match-row__expert,
.match-row__source {
  margin-top: 2px;
  text-transform: uppercase;
}

/* An all-Expert card names its source once, in the header; its row tags appear on phones only (below). */
.match-row__expert--phone {
  display: none;
}

/* Phones (owner request 2026-12-01): no "Expert Pick" beside the away team - every Expert row carries a smaller
   "Expert" tag instead, so the pick's source is still stated in text. */
@media (max-width: 767.98px) {
  .match-card__expert {
    display: none;
  }

  .match-row__expert,
  .match-row__expert--phone {
    display: inline-block;
    padding: 1px 3px;
    font-size: 0.5rem; /* 8 px */
    letter-spacing: 0.03em;
  }
}

.match-card__flag {
  letter-spacing: 0.04em;
}

@media (min-width: 768px) {
  .match-card .matchup-row .team-name {
    font-size: var(--font-size-body-sm);
  }

  .match-card .matchup-row__team .crest-badge {
    width: 1.5rem;
    height: 1.5rem;
  }

  .match-card .matchup-row__team .crest-badge__initial {
    font-size: var(--font-size-metadata);
  }
}

/* ---- collapsible header (match-cards.js; without JavaScript the rows simply stay open) ---- */

.match-card__toggle {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-input);
  background: var(--color-control-bg);
  color: var(--color-text-primary);
  cursor: pointer;
  box-shadow: var(--shadow-3d);
  transition: border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

/* 24 px visible + 2 x 10 px = a 44 px touch area. */
.match-card__toggle::before {
  content: "";
  position: absolute;
  inset: -0.625rem;
}

.match-card__chevron {
  transform: rotate(180deg);
  transition: transform var(--transition-fast);
}

.match-card.is-collapsed .match-card__chevron {
  transform: none;
}

.match-card__toggle:hover,
.match-card.is-collapsible .match-card__head:hover .match-card__toggle {
  border-color: var(--color-text-primary);
  background: var(--color-bg-secondary);
}

.match-card__toggle:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}

.match-card__toggle:active {
  box-shadow: none;
  transform: translateY(1px);
}

.match-card.is-collapsible .match-card__head {
  cursor: pointer;
}

.match-card.is-collapsed .match-card__head {
  border-bottom: 0;
}

/* ---- rows ---- */

.match-card__rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.match-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5.5rem 3.5rem;
  align-items: center;
  gap: var(--space-8) var(--space-12);
  padding: var(--space-4) var(--space-16);
}

/* A tiny grey line between the predictions of one match (owner decision 2026-12-01). */
.match-row + .match-row {
  border-top: 1px solid var(--color-line);
}

.match-row--locked {
  grid-template-columns: minmax(0, 1fr) auto;
}

.match-row--settled {
  grid-template-columns: minmax(0, 1fr) auto;
}

.match-row__pick {
  min-width: 0;
}

.match-row__market,
.match-row__label {
  margin: 0;
  font-size: var(--font-size-metadata);
  font-weight: var(--font-weight-bold);
  line-height: 1.4;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.match-row__market {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--space-8);
}

.match-row__tier {
  padding: 0 var(--space-4);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-control-bg);
  letter-spacing: 0.04em;
  color: var(--color-text-primary);
}

.match-row__lock {
  flex-shrink: 0;
}

.match-row__selection {
  margin: 1px 0 0;
  font-size: var(--font-size-control);
  font-weight: var(--font-weight-bold);
  line-height: 1.35;
  color: var(--color-text-primary);
  overflow-wrap: anywhere;
}

.match-row__note {
  margin: 2px 0 0;
  font-size: var(--font-size-metadata);
  line-height: 1.4;
  color: var(--color-text-secondary);
}

.match-row__pick .badge {
  margin-top: var(--space-4);
}

.match-row__metric {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  margin: 0;
}

.match-row__metric--odds {
  align-items: flex-end;
  text-align: right;
}

.match-row__value {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  margin: 0;
  font-size: var(--font-size-control);
  font-weight: var(--font-weight-bold);
  line-height: 1.3;
  color: var(--color-text-primary);
}

.match-row__value--muted {
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.match-row .confidence-badge {
  padding: 0 var(--space-4);
  font-size: var(--font-size-metadata);
}

.match-row__odds {
  padding: 1px 0.375rem;
  font-size: var(--font-size-control);
}

.match-row__result {
  justify-self: end;
  text-align: right;
}

/* ---- row actions ---- */

.match-row__action {
  justify-self: end;
}

/* The row buttons ARE the site's 3D button: `btn btn-ghost match-row__button` in the template, so the raised edge,
   the ghost hover fill (never an underline), the pressed-flat :active, the focus ring and the disabled look all come
   from components.css. Only the shape and colour are set here: half the concept's 80 x 44 px button (owner request
   2026-11-30) - a 40 x 22 px visible box with 11 px text and a 4 px radius, outlined, a step lighter than the card in
   the dark theme (white on the light theme, so the ghost hover fill stays visible). It widens only as far as
   "✓ Added" needs, inside its fixed 56 px column, so the odds never move. */
.match-row__button.btn {
  --match-add-bg: var(--color-control-bg);
  position: relative;
  min-width: 2.5rem;
  min-height: 1.375rem;
  padding: 0 var(--space-4);
  border-color: var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--match-add-bg);
  color: var(--color-text-primary);
  font-size: var(--font-size-control-compact);
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
}

/* 22 px visible + 2 x 11 px = a 44 px tall touch area (48 px wide). */
.match-row__button.btn::before {
  content: "";
  position: absolute;
  inset: -0.6875rem -0.25rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .match-row__button.btn {
    --match-add-bg: var(--color-surface-elevated);
  }
}

:root[data-theme="dark"] .match-row__button.btn {
  --match-add-bg: var(--color-surface-elevated);
}

/* Not addable (the fixture has started, or the slip refuses it): the site's disabled button, never yellow. */
.match-row__button.btn:disabled:not([data-slip-added]) {
  border-color: var(--color-border);
}

/* Added to the slip (prediction-slip.js sets data-slip-added with "✓ Added"): Chag Yellow with navy text, pressed
   flat like any disabled 3D button, but at full strength - it is a confirmation, not an unavailable control. */
.match-row__button.btn[data-slip-added] {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  opacity: 1;
  cursor: default;
}

/* Unlock with Premium: the full-size 3D button, sized to its words (only "+ Add" was halved). */
.match-row__button--secondary.btn {
  min-height: var(--touch-target-min);
  padding: 0 var(--space-12);
  border-radius: var(--radius-md);
  font-size: var(--font-size-control);
}

.match-row__button--secondary.btn::before {
  content: none;
}

.match-row__analysis {
  grid-column: 1 / -1;
  padding-top: var(--space-4);
  border-top: 1px dashed var(--color-border);
  font-size: var(--font-size-control);
}

/* ---- footer ---- */

.match-card__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4) var(--space-12);
  padding: 2px var(--space-16);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  font-size: var(--font-size-metadata);
  line-height: 1.5;
  color: var(--color-text-secondary);
}

.match-card__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 1.5rem;
  font-size: var(--font-size-control);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  text-decoration: none;
  white-space: nowrap;
}

/* 24 px visible + 2 x 10 px = a 44 px touch area. */
.match-card__link::before {
  content: "";
  position: absolute;
  inset: -0.625rem -0.25rem;
}

.match-card__link:hover {
  color: var(--color-text-primary);
  text-decoration: none;
}

.match-card__link-arrow {
  display: inline-block;
  transition: transform var(--transition-fast);
}

.match-card__link:hover .match-card__link-arrow {
  transform: translateX(3px);
}

.match-card__link:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}

/* Results: a completed match - the final score sits where "vs" is. */
.matchup-row__score {
  font-size: var(--font-size-body-sm);
  font-weight: var(--font-weight-black);
  letter-spacing: 0;
  color: var(--color-text-primary);
  white-space: nowrap;
}

.match-card--result .match-card__foot {
  justify-content: flex-end;
}

/* Match Detail: the page already shows the match, so the card is just its rows. */
.match-card--headless .match-row:first-child {
  border-top: 0;
}

/* ---- narrow cards (phones, and narrow columns such as the homepage hero) ----
   A size container, so the layout follows the card's own width wherever it is placed. */

@container match-card (max-width: 34rem) {
  .match-card__head {
    padding: 0.375rem var(--space-12);
  }

  /* The header line stays one line on a phone: 9 px text, tighter tracking and gaps (owner decision 2026-12-01). */
  .match-card__meta {
    gap: var(--space-4);
    font-size: var(--font-size-metadata-compact);
    letter-spacing: 0.03em;
  }

  .match-card__meta-end,
  .match-card__when {
    gap: var(--space-4);
  }

  /* Pick | odds | "+ Add" stays one row on a phone now that the card carries no confidence; the button column stays
     56 px so "✓ Added" never moves the odds. */
  .match-row {
    grid-template-columns: minmax(0, 1fr) auto 3.5rem;
    gap: var(--space-4) var(--space-8);
    padding: var(--space-4) var(--space-12);
  }

  .match-row--locked {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .match-row--settled {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  /* Smaller prediction text on phones (owner requests 2026-12-01): the pick and the odds at 11 px, like "+ Add", so a
     pick such as "Both Teams to Score: Yes" keeps to one line beside its odds; the "ODDS" label at 9 px. */
  .match-row__selection,
  .match-row__value {
    font-size: var(--font-size-control-compact);
  }

  .match-row__label {
    font-size: var(--font-size-metadata-compact);
  }

  .match-card__foot {
    padding: 2px var(--space-12);
  }
}

@container match-card (max-width: 21rem) {
  .match-row--locked {
    grid-template-columns: minmax(0, 1fr);
  }

  .match-row--locked .match-row__action {
    justify-self: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .match-card__toggle,
  .match-card__chevron,
  .match-card__link-arrow {
    transition: none;
  }

  .match-card__link:hover .match-card__link-arrow {
    transform: none;
  }

  .match-row__button:active {
    transform: none;
  }
}
