/* =====================================================================
   premium.css — premium component layer for Adam's Sports Dashboard.
   Loaded AFTER styles.css + wc.css so it wins ties. Pure CSS, no new DOM
   required for the re-skin; the knockout bracket classes are emitted by
   wc.js (renderWcBracket). Reversible by removing one <link>.
   ===================================================================== */

/* ---- GLOBAL: never let the page scroll sideways (clip keeps sticky working;
   the nav-tabs and knockout bracket keep their own internal overflow scroll) ---- */
html { overflow-x: clip; }

/* ---- GLOBAL: one reduced-motion guard (replaces scattered blocks) ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- GLOBAL: premium, radius-aware focus ring ---- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: inherit;
  box-shadow: 0 0 0 4px rgba(255, 203, 5, 0.20);
}

/* ---- PREMIUM CARD ---- */
.card {
  position: relative;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm), var(--ring-inset);
  transition: transform var(--dur) var(--ease-out),
              border-color var(--dur) var(--ease-out),
              box-shadow var(--dur) var(--ease-out);
}
.card::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  background: var(--grad-card-sheen);
  pointer-events: none;
  opacity: 0.7;
}
.card > * { position: relative; }
.card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md), var(--ring-inset);
}
.card[data-sport="f1"] { border-top: 2px solid color-mix(in srgb, var(--f1) 60%, transparent); }
.card[data-sport="rugby"] { border-top: 2px solid color-mix(in srgb, var(--rugby) 60%, transparent); }
.card[data-sport="football"], .card[data-sport="wc"] { border-top: 2px solid color-mix(in srgb, var(--football) 60%, transparent); }

/* ---- LIVE STATE (feed + WC match cards) ---- */
.feed-item.live,
.wc-match-card--live {
  position: relative;
  border-color: color-mix(in srgb, var(--live) 45%, transparent);
  box-shadow: var(--glow-live), var(--ring-inset);
}
.feed-item.live::after,
.wc-match-card--live::after {
  content: "";
  position: absolute; left: 0; top: 10%; bottom: 10%; width: 3px;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, var(--live), var(--live-2));
  box-shadow: 0 0 12px var(--live);
}
.live-pill, .live-now-chip, .wc-live-dot {
  display: inline-flex; align-items: center; gap: 6px;
  font: 700 var(--fs-eyebrow)/1 var(--font-display);
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 9px; border-radius: var(--radius-pill);
  color: var(--live-fg);
  background: var(--live-bg);
  border: 1px solid color-mix(in srgb, var(--live) 55%, transparent);
}
.live-pill::before, .live-now-chip::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--live);
  animation: live-ping 1.6s var(--ease-out) infinite;
}
@keyframes live-ping {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 60%, transparent); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
/* one-shot score pop — JS adds .just-scored on change */
.just-scored { animation: score-pop 0.35s var(--ease-spring); }
@keyframes score-pop { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* ---- SECTION HEADER / EYEBROW ---- */
.eyebrow {
  font: 600 var(--fs-eyebrow)/1 var(--font-display);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase; color: var(--muted);
}

/* ---- LEAGUE TABLE / STANDINGS + QUALIFICATION ZONES ---- */
.panel-body tbody tr,
.wc-group-table tbody tr {
  transition: background var(--dur-fast) var(--ease-out);
}
.panel-body tbody tr:hover td,
.wc-group-table tbody tr:hover td { background: var(--surface); }
/* qualification rail — JS sets data-zone on <tr> */
tr[data-zone] td:first-child { position: relative; }
tr[data-zone] td:first-child::before {
  content: ""; position: absolute; left: 0; top: 12%; bottom: 12%;
  width: 3px; border-radius: 2px;
}
tr[data-zone="auto"] td:first-child::before { background: var(--qual-auto); }
tr[data-zone="play"] td:first-child::before { background: var(--qual-play); }
tr[data-zone="drop"] td:first-child::before { background: var(--qual-drop); }
tr[data-zone="auto"] td { background: var(--qual-auto-bg); }
tr[data-zone="play"] td { background: var(--qual-play-bg); }
tr[data-zone="drop"] td { background: var(--qual-drop-bg); }
.qual-legend {
  display: flex; flex-wrap: wrap; gap: var(--space-3);
  margin-top: var(--space-3); font-size: var(--fs-xs); color: var(--muted);
}
.qual-legend span { display: inline-flex; align-items: center; gap: 6px; }
.qual-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.qual-legend .z-auto { background: var(--qual-auto); }
.qual-legend .z-play { background: var(--qual-play); }
.qual-legend .z-drop { background: var(--qual-drop); }

/* ============================================================
   KNOCKOUT BRACKET (emitted by wc.js renderWcBracket)
   Desktop: horizontal round columns w/ connectors.
   Mobile: round-selector tabs -> one round at a time.
   ============================================================ */
.wc-bracket { margin-top: var(--space-6); }
.wc-bracket__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-4);
}
.wc-ko-tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.wc-ko-tab {
  font: 700 var(--fs-xs)/1 var(--font-display);
  letter-spacing: 0.04em; text-transform: uppercase;
  padding: 7px 12px; border-radius: var(--radius-pill);
  color: var(--text-2); background: var(--surface-2);
  border: 1px solid var(--border); cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
.wc-ko-tab:hover { color: var(--text); border-color: var(--border-strong); }
.wc-ko-tab.is-active {
  color: var(--on-accent); background: var(--grad-accent);
  border-color: transparent; box-shadow: var(--glow-accent);
}
.wc-bracket__rounds {
  display: flex; gap: var(--space-7); overflow-x: auto;
  padding-bottom: var(--space-3);
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
}
.wc-ko-round {
  flex: 0 0 clamp(210px, 22vw, 264px);
  display: flex; flex-direction: column; justify-content: space-around;
  gap: var(--space-4); scroll-snap-align: start;
}
.wc-ko-round__label {
  font: 700 var(--fs-xs)/1 var(--font-display);
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted); margin-bottom: var(--space-1);
  display: flex; align-items: center; gap: 8px;
}
.wc-ko-round__label::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.wc-ko-ties { display: flex; flex-direction: column; justify-content: space-around; gap: var(--space-4); flex: 1; }
.wc-ko-tie {
  position: relative;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.wc-ko-tie:hover { border-color: var(--border-strong); }
.wc-ko-tie.is-live {
  border-color: color-mix(in srgb, var(--live) 45%, transparent);
  box-shadow: var(--glow-live);
}
.wc-ko-tie.has-brazil { border-color: color-mix(in srgb, var(--wc-b) 55%, transparent); }
.wc-ko-team {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  font-size: var(--fs-sm); color: var(--text-2);
}
.wc-ko-team + .wc-ko-team { border-top: 1px solid var(--border-hair); }
.wc-ko-team .wc-flag { width: 22px; height: 15px; border-radius: 3px; flex: none; }
.wc-ko-team__name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wc-ko-team__score {
  margin-left: auto;
  font: 800 var(--fs-md)/1 var(--font-display);
  font-variant-numeric: tabular-nums; color: var(--text-2);
}
.wc-ko-team__pens { font-size: var(--fs-xs); color: var(--muted); margin-left: 4px; font-variant-numeric: tabular-nums; }
.wc-ko-team.is-winner { color: var(--text); }
.wc-ko-team.is-winner .wc-ko-team__name { font-weight: 800; }
.wc-ko-team.is-winner .wc-ko-team__score { color: var(--win); }
.wc-ko-team.is-winner::before {
  content: ""; width: 3px; align-self: stretch; border-radius: 2px;
  background: var(--win); margin: 2px 2px 2px -4px;
}
.wc-ko-team.is-out { color: var(--muted); }
.wc-ko-team.is-out .wc-ko-team__score { color: var(--muted); }
.wc-ko-team.is-tbd { color: var(--muted); font-style: italic; }
.wc-ko-team.is-tbd .wc-flag,
.wc-ko-team--placeholder {
  opacity: 0.7;
}
.wc-ko-tie--tbd { border-style: dashed; background: var(--surface); }
.wc-ko-tie__meta {
  font-size: 10px; color: var(--muted); text-align: center;
  padding: 2px 0 3px; letter-spacing: 0.03em;
}
/* desktop connectors — short stub out of each tie toward the next round */
@media (min-width: 760px) {
  .wc-ko-tabs { display: none; }
  .wc-ko-round:not(:last-child) .wc-ko-tie::after {
    content: ""; position: absolute;
    right: calc(-1 * var(--space-7) / 2 - 1px); top: 50%;
    width: calc(var(--space-7) / 2); height: 2px;
    background: var(--border-strong);
  }
  .wc-ko-round:not(:first-child) .wc-ko-tie::before {
    content: ""; position: absolute;
    left: calc(-1 * var(--space-7) / 2 - 1px); top: 50%;
    width: calc(var(--space-7) / 2); height: 2px;
    background: var(--border-strong);
  }
}
/* mobile — one round at a time via tabs */
@media (max-width: 759px) {
  .wc-bracket__rounds { display: block; overflow: visible; }
  .wc-ko-round { display: none; flex: 1 1 auto; }
  .wc-ko-round.is-active { display: flex; }
  .wc-ko-round__label { display: none; }
}
/* champion crown — the final's winner */
.wc-ko-champion {
  margin-top: var(--space-5);
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 140% at 50% 0%, rgba(255, 203, 5, 0.18), transparent 60%),
    var(--elevated);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: var(--glow-accent), var(--ring-inset);
  text-align: center;
}
.wc-ko-champion__eyebrow { font: 700 var(--fs-eyebrow)/1 var(--font-display); letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent-2); }
.wc-ko-champion__trophy { font-size: 2.4rem; line-height: 1; filter: drop-shadow(0 4px 14px rgba(255, 203, 5, 0.4)); }
.wc-ko-champion__name { font: 800 var(--fs-2xl)/1 var(--font-display); color: var(--text); display: flex; align-items: center; gap: 10px; }
.wc-ko-champion__name .wc-flag { width: 34px; height: 23px; border-radius: 4px; }

/* ---- COARSE-POINTER TOUCH TARGETS ---- */
@media (hover: none) and (pointer: coarse) {
  .wc-ko-tab { min-height: 40px; }
}

/* ---- MOBILE TOPBAR POLISH (fit the action row on phones) ---- */
@media (max-width: 640px) {
  /* The "matches today" chip duplicates the World Cup tab — drop it on phones
     so the action row never overflows the viewport. */
  .wc-topbar-chip { display: none !important; }
  /* Install button becomes icon-only (the install banner covers the prompt). */
  #install-btn .btn-label { display: none; }
  .topbar-actions { gap: 6px; }
  /* Wide data tables scroll inside their card instead of pushing the page. */
  .panel-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* Tighten table cell padding on phones so team names aren't clipped. */
  .panel-body table td, .panel-body table th { padding-left: 6px; padding-right: 6px; }
  .panel-body .team-cell { gap: 5px; }
  /* Page-level sideways-scroll backstop is now global (see top of file). */
}

/* ---- WC NOW/NEXT HERO (forward-looking, replaces stale countdown) ---- */
.wc-nownext {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-5) var(--space-6);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 160% at 0% 0%, rgba(58, 160, 255, 0.14), transparent 55%),
    var(--elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm), var(--ring-inset);
  margin-bottom: var(--space-4);
}
.wc-nownext__eyebrow {
  font: 700 var(--fs-eyebrow)/1 var(--font-display);
  letter-spacing: var(--tracking-eyebrow); text-transform: uppercase;
  color: var(--accent-2);
}
.wc-nownext__row {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  font-size: var(--fs-base); color: var(--text-2);
}
.wc-nownext__row strong { color: var(--text); }
.wc-nownext__row .wc-flag { width: 24px; height: 16px; border-radius: 3px; }
.wc-nownext__row--brazil { font-size: var(--fs-md); color: var(--text); }
.wc-nownext__cd {
  margin-left: auto;
  font: 800 var(--fs-sm)/1 var(--font-display);
  font-variant-numeric: tabular-nums;
  color: var(--on-accent); background: var(--grad-accent);
  padding: 5px 10px; border-radius: var(--radius-pill);
}
.wc-nownext__row--final .wc-nownext__cd { color: var(--accent-2); background: rgba(255, 203, 5, 0.14); }
.wc-nownext__row--champ { font-size: var(--fs-lg); color: var(--accent-2); font-weight: 800; }

/* ---- WC groups demoted to a collapsed archive during knockouts ---- */.wc-groups-archive {
  margin-top: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.wc-groups-archive > summary {
  cursor: pointer; list-style: none;
  padding: var(--space-3) var(--space-4);
  font: 700 var(--fs-sm)/1 var(--font-display);
  color: var(--text-2); display: flex; align-items: center; gap: 8px;
}
.wc-groups-archive > summary::-webkit-details-marker { display: none; }
.wc-groups-archive > summary::before { content: "▸"; color: var(--muted); transition: transform var(--dur-fast) var(--ease-out); }
.wc-groups-archive[open] > summary::before { transform: rotate(90deg); }
.wc-groups-archive > summary:hover { color: var(--text); }
.wc-groups-archive .wc-groups { padding: 0 var(--space-4) var(--space-4); }

/* ---- Rugby result/fixture lists: side-by-side on wide cards ---- */
.rugby-split { display: grid; gap: var(--space-2) var(--space-7); }
.rugby-split .rugby-col > .sub:first-child { margin-top: 0; }
@media (min-width: 900px) {
  .card-wide .rugby-split { grid-template-columns: 1fr 1fr; align-items: start; }
}
/* Hug the centre score so wide rows don't spread into empty gaps.
   Desktop-only — on phones the natural compact layout fits better. */
@media (min-width: 700px) {
  .rugby-col table td:nth-child(2) { text-align: right; }
  .rugby-col table td:nth-child(2) .team-cell { flex-direction: row-reverse; }
  .rugby-col table td.score, .rugby-col table td:nth-child(3) { text-align: center; white-space: nowrap; width: 1%; }
  .rugby-col table td:first-child { white-space: nowrap; width: 1%; color: var(--muted); }
}

/* ---- LIGHT-THEME CONTRAST FIXES ---- */
/* The hero is always a dark colored gradient surface, so its text must stay
   light in BOTH themes (it was inheriting the dark light-mode --text). */
.hero-card { color: #fff; }
.hero-card .hero-label { color: rgba(255, 255, 255, 0.92); }
.hero-card .hero-countdown { color: #fff; }
/* Tinted chips use pale accent text that washes out on white — darken it in
   light mode while keeping the coloured tint + border for meaning. */
:root[data-theme="light"] .feed-tag,
:root[data-theme="light"] .watch-chip,
:root[data-theme="light"] .chip-tier,
:root[data-theme="light"] .wc-group-tag,
:root[data-theme="light"] .cat-badge,
:root[data-theme="light"] .badge { color: #1f2937; }
:root[data-theme="light"] .feed-tag { border-color: rgba(15, 23, 42, 0.16); }
