@layer components {
  /* Affiliate odds card (1X2). Client-rendered by the `odds` controller; ships
     hidden and collapses to nothing unless odds are present AND the user is 18+
     (see odds_controller.js). One commercial partner only — never a comparison
     grid on the overview. */

  /* Ship hidden + collapse-when-empty: only `filled` is laid out, mirroring the
     ad-slot `data-ad-state` pattern so a minor / no-partner match leaves no gap,
     no skeleton, no phantom margin. */
  .odds-card[data-odds-state="loading"],
  .odds-card[data-odds-state="empty"] {
    display: none;
  }

  .odds-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
  }

  /* Header: market name left, partner brand right. */
  .odds-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
  }

  .odds-card__title {
    min-width: 0;
    overflow: hidden;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--color-text);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Partner brand (Luckia) top-right — logo when the asset exists, else the house
     name as a text mark. Required attribution so the host never looks like the
     operator. */
  .odds-card__brand {
    display: inline-flex;
    align-items: center;
    flex: none;
  }

  .odds-card__brand-logo {
    height: 22px;
    width: auto;
    max-width: 96px;
    object-fit: contain;
    display: block;
  }

  /* 1 / X / 2 — three equal tap targets in one row. */
  .odds-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-2);
  }

  /* Each cell: outcome label left, decimal odd (+ movement triangle) right. */
  .odds-cell {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    min-height: 3rem; /* ≥ 44px touch target */
    padding: 0 var(--space-3);
    background: var(--color-surface-sunken);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    text-decoration: none;
    transition:
      background-color 0.15s ease,
      border-color 0.15s ease;
  }

  a.odds-cell:active {
    background: var(--color-surface-active);
    border-color: var(--color-accent);
  }

  @media (hover: hover) {
    a.odds-cell:hover {
      background: var(--color-surface-hover);
      border-color: var(--color-accent);
    }
  }

  .odds-cell__label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-muted);
  }

  .odds-cell__price {
    font-size: 1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--color-text);
  }

  /* A single suspended outcome — grey the cell, keep the row shape so it never jumps. */
  .odds-cell--suspended {
    color: var(--color-text-disabled);
    pointer-events: none;
  }

  .odds-cell--suspended .odds-cell__price,
  .odds-cell--suspended .odds-cell__label {
    color: var(--color-text-disabled);
  }

  /* Bonus / boost CTA — a bordered row under the odds. Left: descriptive text;
     right: the accent action. Inviting (accent action + hover lift) without an
     aggressive "bet now". Client-rendered only when the env BETTING_BONUS_URL
     stand-in is set, so it is country-gated. */
  .odds-bonus-slot:empty {
    display: none;
  }

  .odds-bonus {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--color-surface-sunken);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition:
      background-color 0.15s ease,
      border-color 0.15s ease;
  }

  .odds-bonus__text {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-secondary);
  }

  /* Accent chevron on the right — the descriptive text is the whole CTA, so no
     redundant action word. */
  .odds-bonus::after {
    content: "\203A"; /* › */
    flex: none;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
    color: var(--color-accent);
  }

  a.odds-bonus:active {
    background: var(--color-surface-active);
    border-color: var(--color-accent);
  }

  @media (hover: hover) {
    a.odds-bonus:hover {
      background: var(--color-surface-hover);
      border-color: var(--color-accent);
    }
  }

  /* Chat variant — compact, low-salience secondary layer (the community vote is
     the primary object). Full-bleed under the grada header (no wrapper padding,
     square, side borders dropped) with a subtle bicolor MATCH gradient (home
     colour left → away colour right, from the --team-color-* vars the grada sets)
     so it stands out a touch, like the home highlight-video cards. */
  .odds-card--chat {
    gap: var(--space-2);
    padding: var(--space-3);
    border-width: 0 0 1px;
    border-radius: 0;
    background: linear-gradient(
      90deg,
      color-mix(in srgb, var(--team-color-home, var(--color-accent)) 18%, var(--color-surface)) 0%,
      var(--color-surface) 50%,
      color-mix(in srgb, var(--team-color-away, var(--color-accent)) 18%, var(--color-surface)) 100%
    );
  }

  .odds-card--chat .odds-cell {
    min-height: 2.5rem;
  }

  /* ── Odds-tab markets book (Sofascore-style): "Ofrecido por <partner>" up top,
     then every market as its own rounded card — coloured movement triangles, and
     Over/Under markets grouped into threshold rows (line · Más de · Menos de).
     Collapse-when-empty (the /odds endpoint returns [] until the sync runs). ── */
  .odds-markets[data-consensus-state="loading"],
  .odds-markets[data-consensus-state="empty"] {
    display: none;
  }

  /* Partner attribution, right-aligned above the cards. */
  .odds-book {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
  }

  .odds-book__offered {
    font-size: 0.75rem;
    color: var(--color-text-muted);
  }

  .odds-book__logo {
    display: block;
    height: 20px;
    width: auto;
    max-width: 84px;
    object-fit: contain;
  }

  .odds-markets__body {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
  }

  /* One market = one rounded card. */
  .odds-mkt {
    padding: var(--space-3);
    background: var(--color-surface);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
  }

  .odds-mkt__name {
    margin: 0 0 var(--space-2);
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--color-text);
  }

  /* Regular market → a row of outcome chips. */
  .odds-mkt__chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  /* Each chip stacks label over price so a long outcome label (team names on
     first_to_score / asian_handicap) gets the full chip width instead of being
     truncated to "Port…"; the short 1X2/BTTS labels read fine stacked too. The
     flex basis + wrap lets high-cardinality markets (correct_score, ht_ft) break
     to a new row rather than crushing every chip into one line. */
  .odds-chip {
    display: flex;
    flex: 1 1 4.5rem;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: var(--space-1);
    min-width: 0;
    padding: var(--space-2) var(--space-3);
    background: var(--color-surface-sunken);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    text-align: center;
  }

  .odds-chip__label {
    overflow: hidden;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Over/Under market → threshold rows: line · Más de · Menos de. */
  .odds-mkt__lines {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
  }

  .odds-line {
    display: grid;
    grid-template-columns: 2.5rem 1fr 1fr;
    align-items: center;
    gap: var(--space-2);
  }

  .odds-line__value {
    font-size: 0.75rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--color-text-muted);
    text-align: center;
  }

  .odds-ou {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-1);
    min-width: 0;
    min-height: 2.5rem;
    padding: var(--space-1) var(--space-2);
    background: var(--color-surface-sunken);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
  }

  .odds-ou--empty {
    background: transparent;
    border-color: transparent;
  }

  .odds-ou__label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
  }

  /* Shared: decimal odd + coloured movement triangle (green up / red down). */
  .odds-chip__value,
  .odds-ou__value {
    flex: none;
    font-size: 0.875rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--color-text);
  }

  .odds-chip__value[data-trend="up"]::after,
  .odds-ou__value[data-trend="up"]::after {
    content: " \25B2"; /* ▲ */
    font-size: 0.5rem;
    color: var(--color-success);
    vertical-align: middle;
  }

  .odds-chip__value[data-trend="down"]::after,
  .odds-ou__value[data-trend="down"]::after {
    content: " \25BC"; /* ▼ */
    font-size: 0.5rem;
    color: var(--color-card-red);
    vertical-align: middle;
  }

  .odds-unavailable {
    padding: var(--space-6) var(--space-4);
    color: var(--color-text-muted);
    font-size: 0.875rem;
    text-align: center;
  }

  /* ── Responsible-gambling disclaimer — small card at the bottom of any page
     with betting content (the "everyone does it" footer pattern). Gated 18+ via
     the `age-reveal` controller: a minor sees no betting chrome at all. ── */
  .betting-disclaimer[hidden] {
    display: none;
  }

  .betting-disclaimer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-4);
    padding: var(--space-3);
    font-size: 0.6875rem;
    color: var(--color-text-muted);
    background: var(--color-surface-sunken);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md);
  }

  .betting-disclaimer__age {
    padding: 0 var(--space-1);
    font-weight: 700;
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
  }

  .betting-disclaimer__help {
    color: var(--color-text-muted);
    text-decoration: underline;
  }
}
