/* leggully - site styles (Bootstrap 5.3 underneath)
   Brand: Pitch #0F3D2E, Ball Red #B3261E, Bail Gold #E8C15A, Linen #F4EFE3, Ink #14201A
   Type:  Bricolage Grotesque 800 (display), IBM Plex Sans (text), IBM Plex Mono 500 (stats) */

:root,
[data-bs-theme="light"] {
  /* brand */
  --pitch: #0F3D2E;
  --ball: #B3261E;
  --gold: #E8C15A;
  --linen: #F4EFE3;
  --ink-brand: #14201A;

  /* roles */
  --surface: var(--linen);          /* page background */
  --panel: #FBF8F1;                 /* cards, tiles */
  --panel-2: #EAE3D2;               /* hover, empty bars, chips */
  --line: #DDD5C0;
  --ink: var(--ink-brand);          /* body text */
  --ink-2: #3E4C44;
  --ink-3: #5A6A60;
  --accent: var(--ball);            /* links, live */
  --accent-hover: var(--pitch);
  --head-bg: var(--pitch);          /* nav, headers, footer */
  --head-ink: var(--linen);
  --head-ink-2: #B9C7BE;
  --record: var(--gold);            /* highlights, records */
  --home: var(--pitch);             /* team slot 1 */
  --away: #A67C1A;                  /* team slot 2: Bail Gold deepened for 3:1 on Linen */
  --win: var(--pitch);
  --loss: var(--ball);
  --nr: #7E8B83;
  --injured: var(--ball);

  --font-display: "Bricolage Grotesque", "IBM Plex Sans", system-ui, sans-serif;
  --font-text: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-stats: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --bs-body-bg: var(--surface);
  --bs-body-color: var(--ink);
  --bs-border-color: var(--line);
  --bs-link-color-rgb: 179, 38, 30;
  --bs-link-hover-color-rgb: 15, 61, 46;
  --bs-font-sans-serif: var(--font-text);
}

/* Dark mode: the brand has no dark palette, so this sets the Linen-on-Pitch
   look from the logo lock-up across the page. */
[data-bs-theme="dark"] {
  --surface: #0E1813;
  --panel: #15241C;
  --panel-2: #1E3128;
  --line: #2A4036;
  --ink: var(--linen);
  --ink-2: #C9D2CC;
  --ink-3: #9FB0A5;
  --accent: #EF7A6E;                /* Ball Red lifted for dark backgrounds */
  --accent-hover: var(--gold);
  --head-bg: #0A2A1F;
  --head-ink: var(--linen);
  --head-ink-2: #9FB0A5;
  --home: #5FB48A;
  --away: var(--gold);
  --win: #3C8F68;
  --loss: #C8392F;
  --nr: #5E6F65;
  --injured: #EF7A6E;
  --bs-body-bg: var(--surface);
  --bs-body-color: var(--ink);
  --bs-border-color: var(--line);
  --bs-link-color-rgb: 239, 122, 110;
  --bs-link-hover-color-rgb: 232, 193, 90;
}

body {
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
main { flex: 1; }

h1, h2, h3, .match-title, .section-title, .sub-title, .panel-title {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -.01em;
  line-height: 1.1;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

.muted { color: var(--ink-3); }
.empty { color: var(--ink-3); font-style: italic; }
.v { color: var(--ink-3); font-weight: 400; margin: 0 .15em; }

/* stats typeface */
.num, .tile-value, .fx-dm, .rs, .phase-cell .big, .ml-scores b,
.facts dd, .chip-result, .stat {
  font-family: var(--font-stats);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ---------- chrome ---------- */

.site-nav {
  background: var(--head-bg);
  color: var(--head-ink);
  padding: .75rem 0;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  color: var(--head-ink);
}
.brand:hover { text-decoration: none; color: var(--head-ink); }
.brand-mark { width: 34px; height: 34px; flex: none; }
.wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.75rem;
  letter-spacing: -.03em;
  line-height: 1;
  color: var(--linen);
  padding-bottom: .12em;
}
.wordmark span { color: var(--gold); }

.site-footer {
  background: var(--head-bg);
  color: var(--head-ink-2);
  font-size: .85rem;
  padding: 1.75rem 0 2.5rem;
  margin-top: 3rem;
}
.site-footer a { color: var(--gold); }
.site-footer a:hover { color: var(--linen); }
.site-footer .wordmark { font-size: 1.25rem; display: inline-block; margin-bottom: .4rem; }

/* ---------- headings ---------- */

.page-head { margin: .75rem 0 2rem; }
.eyebrow {
  text-transform: uppercase;
  font-size: .75rem;
  letter-spacing: .08em;
  font-weight: 500;
  color: var(--ink-3);
  margin-bottom: .4rem;
}
.eyebrow a { color: var(--accent); }
.page-head h1 { font-size: clamp(2rem, 5vw, 2.9rem); letter-spacing: -.03em; margin-bottom: .6rem; }
.lede { color: var(--ink-2); max-width: 60ch; font-size: 1.05rem; }

/* Match header: a Pitch panel, like the dark logo lock-up */
.match-head {
  background: var(--head-bg);
  color: var(--head-ink);
  border-radius: 20px;
  padding: 1.6rem 1.6rem 1.4rem;
  margin: .5rem 0 1.5rem;
  --home: #6FBF97;                  /* team colours that read on Pitch */
  --away: var(--gold);
}
.match-head .eyebrow a { color: var(--gold); }
.match-title {
  font-size: clamp(1.9rem, 5.5vw, 3.2rem);
  letter-spacing: -.035em;
  line-height: 1.05;
  margin-bottom: .75rem;
}
.match-head .v { color: var(--head-ink-2); }
.match-meta {
  display: flex; flex-wrap: wrap; gap: .4rem 1.1rem;
  color: var(--head-ink-2); margin: 0; align-items: center;
}
.badge-format {
  font-size: .72rem; font-weight: 500; text-transform: uppercase; letter-spacing: .06em;
  border: 1px solid rgba(244, 239, 227, .35); border-radius: 999px; padding: .15rem .65rem;
  color: var(--head-ink);
}

.section-title { font-size: 1.45rem; margin: 0 0 .9rem; }
.section-title .muted { font-family: var(--font-text); font-weight: 400; letter-spacing: 0; }
.sub-title { font-size: 1.15rem; margin: 1.8rem 0 .7rem; }
.panel-title { font-size: 1.2rem; margin-bottom: .8rem; }

/* team identity: colour dot + name (never colour alone) */
.team { display: inline-flex; align-items: center; gap: .4em; }
.team .dot {
  width: .6em; height: .6em; border-radius: 50%; flex: none;
  background: var(--home);
}
.team.is-away .dot { background: var(--away); }

/* ---------- fixture list ---------- */

.fx-list { list-style: none; padding: 0; margin: 0; border-top: 2px solid var(--ink); }
.fx-row {
  position: relative;
  display: grid;
  grid-template-columns: 4.4rem 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem .5rem;
  border-bottom: 1px solid var(--line);
}
.fx-row.has-stats:hover { background: var(--panel); }
.fx-date { display: flex; flex-direction: column; line-height: 1.2; }
.fx-day { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 500; }
.fx-dm { font-size: 1.05rem; }
.fx-main { display: flex; flex-direction: column; min-width: 0; }
.fx-teams { font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; letter-spacing: -.02em; color: var(--ink); }
a.fx-teams:hover { text-decoration: none; color: var(--accent); }
.fx-meta { color: var(--ink-3); font-size: .85rem; }
.pill {
  font-size: .75rem; font-weight: 500; border-radius: 999px; padding: .22rem .7rem;
  background: var(--panel-2); color: var(--ink-2); white-space: nowrap;
}
.pill-ready { background: var(--ball); color: #fff; }
.chip {
  border: 1px solid var(--line); border-radius: 999px; padding: .3rem .9rem;
  color: var(--ink); background: var(--panel);
}
.chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
@media (max-width: 575px) {
  .fx-row { grid-template-columns: 3.6rem 1fr; }
  .fx-status { grid-column: 2; }
}

/* ---------- key number tiles ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 2rem;
}
.tile {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 1.1rem 1.2rem;
}
.tile-label { font-size: .78rem; color: var(--ink-2); font-weight: 500; }
.tile-value { font-size: 2rem; line-height: 1.2; margin: .25rem 0 .4rem; }
.tile-value .dash { color: var(--ink-3); margin: 0 .12em; }
.tile-note { font-size: .8rem; color: var(--ink-3); }

.split { display: flex; gap: 2px; height: 8px; margin-bottom: .5rem; }
.split .seg { border-radius: 4px; background: var(--home); min-width: 4px; }
.split .seg.is-away { background: var(--away); }
.split .seg.empty { background: var(--panel-2); }

/* ---------- tabs ---------- */

.match-tabs { border-bottom: 1px solid var(--line); margin-bottom: 1.6rem; gap: 1.4rem; }
.match-tabs .nav-link { color: var(--ink-2); font-weight: 500; padding: .6rem 0; }
.match-tabs .nav-link:hover { color: var(--ink); }
.match-tabs .nav-link.active { color: var(--ink); border-bottom-color: var(--ball); border-bottom-width: 3px; }
.team-pills .nav-link {
  color: var(--ink-2); border: 1px solid var(--line); margin-right: .5rem; border-radius: 999px;
}
.team-pills .nav-link.active { background: var(--head-bg); color: var(--head-ink); border-color: var(--head-bg); }
.team-pills .nav-link.active .team { --home: #6FBF97; --away: var(--gold); }

/* ---------- panels, facts ---------- */

.card-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 1.25rem 1.3rem; height: 100%;
}
.facts { margin: 1rem 0; }
.facts > div {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: .45rem 0; border-bottom: 1px solid var(--line);
}
.facts > div:last-child { border-bottom: 0; }
.facts dt { font-weight: 400; color: var(--ink-2); }
.facts dd { margin: 0; text-align: right; }
.facts dd .muted { font-family: var(--font-text); font-weight: 400; }
.facts-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); column-gap: 2rem;
}
.facts-grid > div:last-child { border-bottom: 1px solid var(--line); }
/* records (highest / lowest total) get the Bail Gold highlight */
.facts .record dd b {
  background: var(--gold); color: var(--ink-brand); border-radius: 4px; padding: 0 .35em; font-weight: 500;
}

.form-chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chip-result {
  width: 1.75rem; height: 1.75rem; display: inline-grid; place-items: center;
  border-radius: 6px; font-size: .78rem; color: #fff;
  background: var(--nr); cursor: default;
}
.chip-result.r-w { background: var(--win); }
.chip-result.r-l { background: var(--loss); }

/* ---------- tables ---------- */

.stats-table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--ink);
  --bs-table-border-color: var(--line);
  font-size: .9rem;
  margin-bottom: 0;
}
.stats-table thead th {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-2); font-weight: 500; white-space: nowrap;
  border-bottom: 2px solid var(--ink);
}
.stats-table tbody th { font-weight: 500; }
.stats-table td.num, .stats-table th.num { text-align: right; }
.stats-table .strong { font-weight: 600; }
.stats-table td:first-child { white-space: nowrap; }
.stats-table tr.past td { color: var(--ink-3); }
.stats-table tr.injured .pname { color: var(--injured); text-decoration: line-through; text-decoration-thickness: 1px; }
.stats-table .outs { color: var(--loss); font-weight: 600; }
.stats-table tbody tr:hover > * { background: var(--panel); }

.sortable th[data-sort] { cursor: pointer; user-select: none; }
.sortable th[data-sort]:hover { color: var(--accent); }
.sortable th[aria-sort] { color: var(--ink); }
.sortable th[aria-sort="descending"]::after { content: " ↓"; color: var(--accent); }
.sortable th[aria-sort="ascending"]::after { content: " ↑"; color: var(--accent); }

.tag {
  font-size: .64rem; font-weight: 600; border: 1px solid var(--line); border-radius: 4px;
  padding: 0 .3em; color: var(--ink-2); text-decoration: none; vertical-align: 1px;
}
.tag-injured { color: var(--injured); border-color: var(--injured); }

.recent { white-space: nowrap; }
.rs {
  display: inline-block; min-width: 2.2rem; text-align: center;
  background: var(--panel-2); border-radius: 4px; padding: 0 .25rem; margin-right: 2px;
  font-size: .8rem; cursor: default;
}
.rs.hi { background: var(--gold); color: var(--ink-brand); }   /* 50+ or 3+ wickets */

/* paired phase bars */
.phase-table td { width: 40%; }
.phase-table thead th { white-space: normal; }
@media (max-width: 575px) {
  .phase-table .muted.small { display: none; }
  .phase-cell { gap: .35rem; }
}
.phase-cell { display: flex; align-items: center; gap: .6rem; }
.phase-cell .big { min-width: 2.8rem; }
.hbar { flex: 1; height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.hbar .fill { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--home); }
.hbar .fill.is-away { background: var(--away); }

/* ---------- batting thresholds (Batting tab) ---------- */

.threshold-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .75rem 2rem; margin-bottom: 1.4rem;
}
.threshold-head p { max-width: 70ch; }
.threshold-switch { margin: 0; white-space: nowrap; font-weight: 500; }
.threshold-switch .form-check-input { cursor: pointer; }
.threshold-switch .form-check-input:checked { background-color: var(--pitch); border-color: var(--pitch); }
.threshold-switch .form-check-input:focus { box-shadow: 0 0 0 .2rem rgba(15, 61, 46, .25); border-color: var(--pitch); }
.threshold-table td.num { cursor: default; }
.threshold-table tr.few td { color: var(--ink-3); }
/* every cell holds both numbers; the switch picks one */
.threshold-table .as-odds { display: none; }
body.show-odds .threshold-table .as-pct { display: none; }
body.show-odds .threshold-table .as-odds { display: inline; }

/* ---------- match lists ---------- */

.match-list { list-style: none; padding: 0; margin: 0; border-top: 2px solid var(--ink); }
.match-list li {
  display: grid; grid-template-columns: 11rem 1fr 15rem; gap: .3rem 1rem;
  padding: .8rem 0; border-bottom: 1px solid var(--line); align-items: baseline;
}
.ml-date { font-size: .85rem; }
.ml-scores { display: flex; flex-direction: column; }
.ml-scores b { margin-left: .25rem; }
.ml-result { color: var(--ink-2); font-size: .9rem; }
@media (max-width: 767px) {
  .match-list li { grid-template-columns: 1fr; }
}

.frozen-note {
  margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--line);
  color: var(--ink-3); font-size: .85rem;
}

/* ---------- links inside the dark match header (venue, teams) ----------
   Cream on Pitch, Bail Gold when hovered, pressed or focused - never the
   page's red/green link colours, which don't read on the dark panel. */

.match-head .match-meta a,
.match-head .match-meta a:visited,
.match-title a,
.match-title a:visited {
  color: var(--head-ink);
  text-decoration: underline;
  text-decoration-color: rgba(244, 239, 227, .4);
  text-underline-offset: .2em;
}
.match-head .match-meta a:hover,
.match-head .match-meta a:active,
.match-head .match-meta a:focus-visible {
  color: var(--gold);
  text-decoration-color: var(--gold);
}
/* team names: the coloured-dot layout hides a normal underline, so use a border */
.match-title a,
.match-title a:visited { text-decoration: none; }
.match-title a .team { border-bottom: 2px solid rgba(244, 239, 227, .3); padding-bottom: .02em; }
.match-title a:hover,
.match-title a:active,
.match-title a:focus-visible { color: var(--gold); text-decoration: none; }
.match-title a:hover .team,
.match-title a:active .team,
.match-title a:focus-visible .team { border-bottom-color: var(--gold); }
.match-head a:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; border-radius: 4px; }

/* ---------- team pages ---------- */

.h2h-bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--panel-2); min-width: 80px; }
.h2h-bar .w { background: var(--win); }
.h2h-bar .l { background: var(--loss); }

/* ---------- key facts (fixture pages) ---------- */

.key-facts { margin: 0 0 1.75rem; }
.key-facts ul { margin: 0; padding-left: 1.1rem; max-width: 80ch; color: var(--ink-2); }
.key-facts li { margin-bottom: .35rem; }
.key-facts li::marker { color: var(--ball); }
