/* ============================================================================
 * app.css — Sportsbook's own styles, on top of the kit's components.css.
 *
 * Colour comes only from tokens.css. If a value here looks like it wants a
 * hex code, it wants a token instead.
 * ========================================================================= */

/* The brand name carries the turf green: the one place green is used as
 * type rather than as something to press. */
.brand-name { color: var(--accent); }

/* --- tab bar -------------------------------------------------------------
 * The active tab gets a gold bar along its top edge, over the green label.
 * The bar is gold because gold is the highlight colour in this palette. It
 * is a FILL, so --gold's 2.4:1 contrast on white does not matter here; the
 * label under it stays green and passes on its own.
 *
 * `position: relative` is needed for the ::before; the kit's .tab has none. */
.tab { position: relative; }
.tab.active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 28%;
  right: 28%;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--gold);
}

/* Five labels at 375px: "Scorecard" is the longest, and at the kit's 0.7rem
 * it fits with room to spare. If a label is ever renamed to something
 * longer, check 375×667 before shipping — it will truncate, not wrap. */
.tab-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* --- topbar --------------------------------------------------------------
 * This topbar carries one more button than the kit's (the Settings gear),
 * and at 390px that was enough to truncate the brand to "Sport…". So the
 * Install label drops away below 430px instead of the kit's 380px, and the
 * Account button runs tighter. Re-check 375×667 if a button is ever added. */
#account-btn { padding-inline: 12px; }
@media (max-width: 430px) {
  .install-btn-label { display: none; }
  .install-btn { padding: 8px 10px; }
}

/* ==========================================================================
 * Screens. Flat kebab-case with a component prefix, per house rule 3.
 * ======================================================================== */

.view-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 8px; }
.view-title { margin: 4px 0 8px; font-family: var(--font-display); font-size: 1.35rem; color: var(--ink); }
.section { margin: 18px 0; }
.section-head { margin: 0 0 8px; font-size: 1.05rem; font-weight: 800; color: var(--ink); }
.section-sub { margin: -4px 0 10px; color: var(--ink-soft); font-size: 0.875rem; }
.sub-head { margin: 14px 0 8px; font-size: 0.95rem; font-weight: 800; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.mini-head { margin: 10px 0 4px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-faint); }
.fine { font-size: 0.8rem; color: var(--ink-faint); }
.center { text-align: center; justify-content: center; }
.card-list { display: grid; gap: 8px; }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.loading { padding: 20px; text-align: center; color: var(--ink-faint); font-size: 0.875rem; }
.as-of { margin: 0 0 6px; font-size: 0.75rem; color: var(--ink-faint); }
.as-of.stale { color: var(--gold-ink); font-weight: 700; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; min-height: 0; }

/* The demo banner is gold on purpose: it is the highlight colour, and this
 * is the one message that must not be scrolled past. Text is --gold-ink on
 * --gold-bg (4.5:1), never --gold on white. */
.demo-banner {
  margin: 0 0 10px; padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--gold-bg); color: var(--gold-ink); font-size: 0.8rem; font-weight: 700;
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
}

/* --- team badge ----------------------------------------------------------- */
.team-badge {
  flex: none; display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px;
  font-size: 0.7rem; font-weight: 800; letter-spacing: 0.02em;
}
.team-badge.sm { width: 28px; height: 28px; border-radius: 8px; font-size: 0.62rem; }

/* --- event card: away over home, status at the right ---------------------- */
.event-card {
  width: 100%; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px;
  padding: 10px 12px; text-align: left; font: inherit; color: var(--ink);
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm); cursor: pointer;
}
.event-card.is-live { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.event-sides { display: grid; gap: 6px; min-width: 0; }
.score-side { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; min-width: 0; }
.score-team { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.score-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-record { font-size: 0.75rem; color: var(--ink-faint); }
.score-pts { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; color: var(--ink-soft); }
.score-side.won .score-name, .score-side.won .score-pts { color: var(--ink); }
.score-side.won .score-pts::after { content: " ◂"; color: var(--gold); font-size: 0.7rem; }
.event-status { font-size: 0.78rem; font-weight: 700; color: var(--ink-soft); white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.is-live .event-status { color: var(--accent); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  .live-dot { animation: live-pulse 1.6s ease-in-out infinite; }
  @keyframes live-pulse { 50% { opacity: 0.35; } }
}
.event-pick { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--ink-soft); }

/* --- headlines ------------------------------------------------------------ */
.headline-list { display: grid; gap: 8px; }
.headline {
  display: grid; gap: 3px; padding: 12px; border-radius: var(--radius-sm);
  background: var(--bg-raised); border: 1px solid var(--line); text-decoration: none; color: var(--ink);
  user-select: text;
}
.headline-title { font-weight: 700; line-height: 1.3; }
.headline-summary { font-size: 0.85rem; color: var(--ink-soft); line-height: 1.35; }
.headline-meta { font-size: 0.75rem; color: var(--ink-faint); }

/* --- segmented control ---------------------------------------------------- */
.segmented { display: flex; gap: 4px; padding: 4px; margin: 0 0 12px; background: var(--bg-sunken); border-radius: var(--radius-pill); }
.seg {
  flex: 1; min-height: 40px; border: 0; border-radius: var(--radius-pill); background: transparent;
  font: inherit; font-weight: 700; font-size: 0.875rem; color: var(--ink-soft); cursor: pointer;
}
.seg.active { background: var(--bg-raised); color: var(--accent); box-shadow: var(--shadow-sm); }

/* --- stat tiles ----------------------------------------------------------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(68px, 1fr)); gap: 8px; }
.stat-tile { display: grid; gap: 2px; padding: 8px; border-radius: var(--radius-sm); background: var(--bg-sunken); text-align: center; }
.stat-value { font-size: 1.15rem; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.7rem; color: var(--ink-faint); font-weight: 700; }
.total-card { display: grid; justify-items: center; gap: 2px; }
.total-card .stat-value { font-size: 2.4rem; color: var(--accent); }

/* --- chart (single series; see scorecard.js for the spec) ------------------ */
.chart { width: 100%; height: auto; display: block; }
.chart-bar { fill: var(--accent); }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-tick { fill: var(--ink-faint); font-size: 9px; }
.chart-label { fill: var(--ink); font-size: 10px; font-weight: 700; }

/* --- pick'em -------------------------------------------------------------- */
.pick-row { display: grid; gap: 6px; }
.pick-options { display: flex; gap: 6px; align-items: center; }
.pick-btn {
  flex: 1; min-height: 44px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--bg-raised); font: inherit; font-weight: 800; color: var(--ink-soft); cursor: pointer;
}
.pick-btn.picked { background: var(--accent); border-color: transparent; color: var(--accent-contrast); }
.pick-btn:disabled { opacity: 0.55; cursor: default; }
.pick-btn.picked:disabled { opacity: 0.8; }
.pick-locked { font-size: 0.75rem; color: var(--ink-faint); white-space: nowrap; }
.history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.history-row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center;
  padding: 10px 12px; background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 0.85rem;
}
.history-row > :nth-child(2) { color: var(--ink-faint); font-size: 0.78rem; grid-row: 2; }
.history-row > :nth-child(3) { grid-row: 1 / span 2; grid-column: 2; }

/* --- leagues -------------------------------------------------------------- */
.upsell { border-color: color-mix(in srgb, var(--gold) 50%, var(--line)); }
.league-row {
  display: grid; gap: 2px; width: 100%; padding: 12px; text-align: left; font: inherit; cursor: pointer;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink);
}
.league-name { font-weight: 800; }
.league-meta { font-size: 0.78rem; color: var(--ink-faint); }
.invite-card { text-align: center; }
.invite-code {
  margin: 4px 0 8px; font-family: var(--font-mono); font-size: 2rem; font-weight: 800;
  letter-spacing: 0.18em; color: var(--accent); user-select: all;
}
.qr-box { width: 180px; margin: 0 auto; background: #ffffff; border-radius: var(--radius-sm); }
.qr-box svg { display: block; width: 100%; height: auto; }
.invite-card .btn-row { justify-content: center; }
.benefits { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--ink-soft); font-size: 0.9rem; }

/* --- forms ---------------------------------------------------------------- */
.form { display: grid; gap: 10px; }
.form-error { margin: 0; min-height: 1em; color: var(--bad); font-size: 0.85rem; }
.form-error:empty { display: none; }
.code-input { font-family: var(--font-mono); font-size: 1.4rem; letter-spacing: 0.2em; text-transform: uppercase; text-align: center; }
.search-row { display: grid; grid-template-columns: 1fr minmax(110px, 40%); gap: 8px; margin-bottom: 12px; }

/* --- tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-raised); }
.stat-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.stat-table th, .stat-table td { padding: 7px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.stat-table thead th { color: var(--ink-faint); font-size: 0.7rem; font-weight: 800; }
.stat-table tbody th { text-align: left; font-weight: 700; color: var(--ink); }
.stat-table thead th:first-child { text-align: left; }
.stat-table tr:last-child > * { border-bottom: 0; }
.stat-table th.linkish { color: var(--accent); text-decoration: none; }

/* --- detail sheet --------------------------------------------------------- */
.detail-actions { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.star-btn {
  width: 44px; height: 44px; flex: none; border-radius: var(--radius-pill); border: 1px solid var(--line-strong);
  background: var(--bg-raised); color: var(--ink-faint); font-size: 1.25rem; cursor: pointer;
}
.star-btn.on { color: var(--gold); border-color: var(--gold); background: var(--gold-bg); }

/* --- squad game ----------------------------------------------------------- */
.squad-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.budget-bar { display: grid; gap: 6px; margin-bottom: 10px; font-size: 0.85rem; font-weight: 700; color: var(--ink-soft); }
.meter { height: 8px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 15%, var(--bg-sunken)); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.meter > span.over { background: var(--bad); }
.slot-list { display: grid; gap: 6px; }
.slot-row {
  display: grid; grid-template-columns: 44px 1fr auto auto auto; align-items: center; gap: 6px;
  padding: 4px 6px; background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.slot-pos { font-size: 0.72rem; font-weight: 800; color: var(--ink-faint); text-align: center; }
.slot-pick {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 8px;
  min-height: 44px; padding: 4px 0; background: none; border: 0; text-align: left; font: inherit; color: var(--ink); cursor: pointer; min-width: 0;
}
.slot-pick > .team-badge { grid-row: 1 / span 2; }
.slot-pick.static { cursor: default; grid-template-columns: 1fr; }
.slot-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-meta { font-size: 0.72rem; color: var(--ink-faint); }
.slot-empty { grid-column: 1 / -1; color: var(--accent); font-weight: 700; font-size: 0.875rem; }
.slot-price { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink-soft); font-size: 0.85rem; padding: 0 4px; }
.cap-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--bg-raised);
  font-weight: 800; font-size: 0.8rem; color: var(--ink-faint); cursor: pointer;
}
.cap-btn.on { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.icon-btn.sm { width: 36px; height: 36px; font-size: 0.8rem; }
.picker-list { display: grid; gap: 4px; margin-top: 10px; }
.picker-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; width: 100%; min-height: 48px;
  padding: 6px 8px; font: inherit; text-align: left; color: var(--ink); cursor: pointer;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.picker-row:disabled { opacity: 0.5; cursor: default; }
.picker-name { display: grid; font-weight: 700; min-width: 0; }
.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.board-row {
  display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.board-row.me { border-color: var(--gold); background: var(--gold-bg); }
.board-rank { font-weight: 800; color: var(--ink-faint); }
.board-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-pts { font-weight: 800; font-variant-numeric: tabular-nums; }

/* --- players & favorites -------------------------------------------------- */
.player-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; width: 100%; min-height: 48px;
  padding: 8px 12px; font: inherit; text-align: left; color: var(--ink); cursor: pointer;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.player-row > :first-child:not(.team-badge) { grid-column: 1 / span 2; }
.player-name { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-meta { font-size: 0.78rem; color: var(--ink-faint); white-space: nowrap; }
.fav-team { display: grid; gap: 6px; padding: 10px; background: var(--bg-sunken); border-radius: var(--radius); }
.fav-team-head { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; font: inherit; color: var(--ink); cursor: pointer; text-align: left; min-height: 44px; }
.fav-team-name { font-weight: 800; flex: 1; }
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.team-toggle {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; min-height: 52px; padding: 6px 10px;
  font: inherit; text-align: left; color: var(--ink); cursor: pointer;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.team-toggle-name { font-weight: 700; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-toggle-star { color: var(--line-strong); font-size: 1.1rem; }
.team-toggle.on { border-color: var(--gold); background: var(--gold-bg); }
.team-toggle.on .team-toggle-star { color: var(--gold); }

/* Every hover rule behind (hover: hover) — iOS sticks :hover to the last
 * tapped element (house rule 10b). */
@media (hover: hover) {
  .event-card:hover, .headline:hover, .league-row:hover, .player-row:hover, .picker-row:not(:disabled):hover,
  .team-toggle:hover { border-color: var(--line-strong); }
  .pick-btn:not(:disabled):not(.picked):hover { border-color: var(--accent); color: var(--accent); }
}

/* Panels stacked directly in a view need air between them; the kit's .panel
 * carries none, because inside a sheet it is usually alone. */
.view > .panel, .section > .panel, .view > div > .panel { margin-bottom: 12px; }
.slot-empty { grid-row: 1 / span 2; align-self: center; }
