/* Hallmark · pre-emit critique: P5 H5 E5 S5 R5 V4 */
/* Owner request 2026-12-03 (the approved match-card image): visible border lines - the card outline, a box around the
 * predictions with a line between each, a bar at the start of each prediction row, an outlined "+ Add" and odds chip
 * and a framed "vs" - and stronger text (white picks and team names in the dark theme, a brighter card header). The
 * --color-card-* / --color-control-border / --color-row-accent / --color-text-strong tokens (tokens.css) carry it; the
 * 2026-12-01 no-border rule still holds everywhere else. */
/* 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-card-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-card-meta);
}

.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 line, under a line separating it from the competition and kickoff line (owner request 2026-12-03). */
.match-card__teams {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-card-border);
}

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

/* The pick's source tag sits right beside the pick (owner request 2026-12-03, superseding the 2026-12-01 header
   badge): a yellow "Expert" (Chag Yellow, navy text, both themes) for a Chag Sports Expert pick, and "Model +
   Analyst" on the existing source-badge colours for a hybrid one - 9 px, uppercase, text, never colour alone. */
.match-row__expert,
.match-row__source {
  flex: none;
  padding: 1px var(--space-4);
  border-radius: 3px;
  font-size: var(--font-size-metadata-compact);
  font-weight: var(--font-weight-bold);
  line-height: 1.3;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.match-row__expert {
  border: 0;
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

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

/* Team names in the strongest text, and "vs" in a small framed box (owner request 2026-12-03). */
.match-card .matchup-row .team-name {
  font-weight: var(--font-weight-bold);
  color: var(--color-text-strong);
}

.match-card .matchup-row__vs {
  padding: 1px var(--space-4);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-sm);
  background: var(--color-control-bg);
  line-height: 1.4;
  color: var(--color-text-primary);
}

@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 ---- */

/* The predictions sit in their own outlined box, inset from the card edges (owner request 2026-12-03). No overflow
   clipping, so the "+ Add" touch areas reaching past the first and last rows stay usable. */
.match-card__rows {
  margin: var(--space-8) var(--space-12);
  padding: 0;
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-input);
  list-style: none;
}

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

/* The bar at the start of each prediction row (owner request 2026-12-03): Chag Yellow on navy, navy on the light
   theme (yellow on white is too faint). Decorative - the row's text carries the meaning. */
.match-row::before {
  content: "";
  position: absolute;
  top: var(--space-8);
  bottom: var(--space-8);
  left: var(--space-8);
  width: 3px;
  border-radius: 2px;
  background: var(--color-row-accent);
}

.match-row--locked::before {
  background: var(--color-text-muted);
}

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

.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-control-border);
  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;
}

/* A locked VIP row: the lock icon and "VIP" only, always one row with "Unlock with VIP" beside it at every width
   (owner requests 2026-12-03) - the label and the button never wrap. */
.match-row__locked-label {
  flex-wrap: nowrap;
  gap: var(--space-4);
  white-space: nowrap;
}

.match-row--locked .match-row__button {
  white-space: nowrap;
}

.match-row__locked-label .match-row__lock {
  color: var(--color-card-meta);
}

/* One row always (owner request 2026-12-03): the pick and its tag never wrap; when the row is too narrow the pick
   text ends with an ellipsis as the last resort (its full text stays in the tooltip and is read in full by assistive
   technology - the truncation is visual only). The tag never shrinks. */
.match-row__selection {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--space-8);
  min-width: 0;
  margin: 1px 0 0;
  font-size: var(--font-size-control);
  font-weight: var(--font-weight-bold);
  line-height: 1.35;
  color: var(--color-text-strong);
  overflow-wrap: anywhere;
}

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

/* Shortened picks (apps.core.team_names.pick_phone_labels): shown in a phone-width card instead of the full pick,
   which stays in the page for assistive technology. */
.match-row__pick-short {
  display: none;
}

@container match-card (max-width: 34rem) {
  .match-row__pick-text--narrow > .match-row__pick-full {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .match-row__pick-text--narrow > .match-row__pick-short--narrow {
    display: inline;
  }
}

@container match-card (max-width: 21rem) {
  .match-row__pick-text--tight > .match-row__pick-full {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .match-row__pick-text--tight > .match-row__pick-short--narrow {
    display: none;
  }

  .match-row__pick-text--tight > .match-row__pick-short--tight {
    display: inline;
  }
}

.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;
}

/* "ODDS" and the price on one line, the price in its yellow chip (owner request 2026-12-03). */
.match-row__metric--odds {
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-8);
  text-align: right;
}

.match-row__metric--odds .match-row__label {
  color: var(--color-card-meta);
}

.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 {
  min-width: 2.75rem;
  padding: 2px var(--space-8);
  font-size: var(--font-size-control);
  font-weight: var(--font-weight-bold);
  text-align: center;
}

.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-control-border);
  border-radius: var(--radius-sm);
  background: var(--match-add-bg);
  color: var(--color-text-strong);
  font-size: var(--font-size-control-compact);
  font-weight: var(--font-weight-bold);
  white-space: nowrap;
}

.match-row__button.btn:hover:not(:disabled) {
  border-color: var(--color-text-strong);
}

/* 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-card-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 VIP": the same size as "+ Add" (owner request 2026-12-03) - 22 px tall, 11 px bold text, outlined,
   4 px radius - only as wide as its words; the touch area stays 44 px tall through the shared ::before above. */
.match-row__button--secondary.btn {
  padding: 0 var(--space-8);
}

.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);
  font-weight: var(--font-weight-semibold);
  line-height: 1.5;
  color: var(--color-card-meta);
}

.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-strong);
  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 (owner request 2026-12-03): every spare pixel goes to the pick -
     a narrower prediction-box inset, tighter row padding and gaps, and a 52 px button column (still wide enough for
     "✓ Added", so the odds never move). */
  .match-row {
    grid-template-columns: minmax(0, 1fr) auto 3.25rem;
    gap: var(--space-4) 6px;
    padding: var(--space-4) 6px var(--space-4) 13px;
  }

  .match-row::before {
    left: 5px;
  }

  .match-row__selection {
    gap: var(--space-4);
  }

  .match-row__expert,
  .match-row__source {
    padding: 1px 3px;
    letter-spacing: 0.02em;
  }

  .match-row__metric--odds {
    gap: var(--space-4);
  }

  .match-row__odds {
    min-width: 0;
    padding: 2px var(--space-4);
  }

  /* "Not available" may take two short lines inside its own cell rather than squeeze the pick. */
  .match-row__metric--odds .match-row__value--muted {
    max-width: 3.75rem;
    line-height: 1.15;
    white-space: normal;
  }

  .match-card__rows {
    margin: var(--space-8) var(--space-4);
  }

  .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);
  }
}

@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;
  }
}
