/* League-wide pages (templates/_league.html): sortable tables, leaderboards, injury lists, venues. */
body { min-height: 100vh; display: flex; flex-direction: column; }
.lg { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 32px 24px 64px; }
.lg-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.lg-title { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; }
.lg-sub { color: var(--text3); font-size: 14px; margin-top: 4px; max-width: 720px; line-height: 1.5; }
.lg-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.lg-credit { color: var(--text3); font-size: 12.5px; margin-top: 32px; line-height: 1.6; }
.lg-credit a, .lg-sub a { color: var(--text2); }
.lg-empty { color: var(--text3); padding: 48px 0; text-align: center; }

/* Segmented toggle (links) */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg2); border: 1px solid var(--border); border-radius: 999px; }
.seg a {
  padding: 6px 13px; font-size: 13px; font-weight: 500; color: var(--text3); text-decoration: none;
  border-radius: 999px; white-space: nowrap;
}
.seg a:hover { color: var(--text); }
.seg a.on { color: var(--text); background: var(--bg4); }
.lg-link { font-size: 13px; font-weight: 500; color: var(--accent); text-decoration: none; }
.lg-link:hover { text-decoration: underline; }

/* Sortable table. The wrapper scrolls (both ways) so the header row stays in view down a long table. */
.lt-wrap {
  overflow: auto; max-height: calc(100vh - var(--header-h) - 48px);
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.lt { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.lt th {
  position: sticky; top: 0; z-index: 2; padding: 10px; text-align: right; white-space: nowrap;
  font-size: 11px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; color: var(--text3);
  background: var(--bg2); border-bottom: 1px solid var(--border);
}
.lt thead.two-rows tr:first-child th { height: 30px; padding: 8px 10px 0; border-bottom: 0; }
.lt thead.two-rows tr + tr th { top: 30px; }
.lt th.grp { text-align: center; color: var(--text2); letter-spacing: .3px; }
.lt th.grp span { display: block; border-bottom: 1px solid var(--border2); padding-bottom: 5px; }
.lt th.has-help { text-decoration: underline dotted color-mix(in srgb, var(--text3) 60%, transparent); text-underline-offset: 3px; cursor: help; }
.lt th[data-sort] { cursor: pointer; user-select: none; }
.lt th[data-sort]:hover { color: var(--text); }
.lt th.sorted { color: var(--accent); }
.lt th.sorted::after { content: " ↓"; }
.lt th.sorted.asc::after { content: " ↑"; }
.lt th:first-child, .lt td:first-child { text-align: left; position: sticky; left: 0; background: var(--bg2); z-index: 1; }
.lt th:first-child { z-index: 3; }
.lt td { padding: 8px 10px; text-align: right; font-family: var(--mono); font-size: 13px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.lt tbody tr:last-child td { border-bottom: none; }
.lt tbody tr:hover td { background: var(--bg3); }
.lt .gs { border-left: 1px solid var(--border); }
.lt td .rk { display: block; font-family: var(--sans); font-size: 10.5px; color: var(--text3); }
/* Top 5 / bottom 5: a tinted cell is easier to spot down a column than colored text alone. */
.lt td.top { background: color-mix(in srgb, var(--green) 11%, var(--bg2)); }
.lt td.bottom { background: color-mix(in srgb, var(--red) 10%, var(--bg2)); }
.lt td.top .v { color: var(--green); font-weight: 600; }
.lt td.bottom .v { color: var(--red); }
.lt td.top .rk, .lt td.bottom .rk { color: var(--text2); }
.lt-legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; color: var(--text3); }
.lt-legend .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-left: 6px; }
.lt-legend .sw:first-child { margin-left: 0; }
.lt-legend .sw.top { background: color-mix(in srgb, var(--green) 35%, var(--bg2)); }
.lt-legend .sw.bottom { background: color-mix(in srgb, var(--red) 35%, var(--bg2)); }
.lt-legend .lt-hint { margin-left: auto; }

/* Team cell */
.tm { display: flex; align-items: center; gap: 10px; font-family: var(--sans); text-decoration: none; color: inherit; }
.tm img { width: 24px; height: 24px; object-fit: contain; flex-shrink: 0; }
.tm b { font-weight: 600; font-size: 13.5px; }
.tm small { color: var(--text3); font-size: 12px; }

/* Player names link to their pages */
.pl-link { color: inherit; text-decoration: none; }
.pl-link:hover b, .pl-link:hover { color: var(--accent); }

/* Leaderboard cards */
.lb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.lb { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px 16px 8px; }
.lb h2 { font-size: 14px; font-weight: 650; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.lb h2 small { font-size: 11.5px; font-weight: 500; color: var(--text3); }
.lb ol { list-style: none; }
.lb li { display: grid; grid-template-columns: 18px 34px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 7px 0; border-top: 1px solid var(--border); }
.lb li:first-child { border-top: 0; }
.lb .n { font-family: var(--mono); font-size: 12px; color: var(--text3); }
.lb .hs { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--bg3); }
.lb .who { min-width: 0; }
.lb .who b { display: block; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .who small { font-size: 11.5px; color: var(--text3); }
.lb .val { font-family: var(--mono); font-size: 15px; font-weight: 600; }
.lb li:first-child .val { color: var(--accent); }
.lb li.more { display: none; }
.lb.open li.more { display: grid; }
.lb .bar { display: block; height: 3px; margin-top: 5px; border-radius: 2px; background: var(--bg3); overflow: hidden; }
.lb .bar i { display: block; height: 100%; border-radius: 2px; background: color-mix(in srgb, var(--accent) 55%, transparent); }
.lb li:first-child .bar i { background: var(--accent); }
/* The leader gets a bigger photo. */
.lb li:first-child { grid-template-columns: 18px 46px minmax(0, 1fr) auto; padding: 9px 0 10px; }
.lb li:first-child .hs { width: 46px; height: 46px; }
.lb li:first-child .val { font-size: 19px; }
.lb-more {
  width: 100%; margin: 4px 0 8px; padding: 7px; font: inherit; font-size: 12.5px; font-weight: 500; color: var(--text2);
  background: none; border: 1px dashed var(--border2); border-radius: var(--radius-sm); cursor: pointer;
}
.lb-more:hover { color: var(--text); border-color: var(--text3); }
.lb-more span + span, .lb.open .lb-more span:first-child { display: none; }
.lb.open .lb-more span + span { display: inline; }
.lg-jump { display: flex; gap: 6px; flex-wrap: wrap; margin: -6px 0 22px; }
.lg-jump a {
  padding: 5px 12px; font-size: 13px; font-weight: 500; color: var(--text2); text-decoration: none;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 999px;
}
.lg-jump a:hover { color: var(--text); border-color: var(--border2); }
.lb-group { scroll-margin-top: calc(var(--header-h) + 16px); }
.lb-group { font-size: 13px; font-weight: 600; color: var(--text3); letter-spacing: .3px; text-transform: uppercase; margin: 28px 0 12px; }
.lb-group:first-child { margin-top: 0; }

/* Injuries: one card per team */
.inj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; align-items: start; }
.inj { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 14px 16px; }
.inj-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.inj-head .count { font-size: 12px; color: var(--text3); white-space: nowrap; }
.inj-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 0; border-top: 1px solid var(--border); }
.inj-row .who b { font-size: 13.5px; font-weight: 600; }
.inj-row .who small { font-family: var(--mono); font-size: 11.5px; color: var(--text3); margin-left: 5px; }
.inj-row .why { display: block; font-size: 12px; color: var(--text3); margin-top: 2px; }
.inj-row .key { font-size: 9.5px; font-weight: 700; color: var(--accent); margin-left: 5px; }
.inj-row .tags { display: flex; gap: 5px; justify-content: flex-end; flex-wrap: wrap; }
.pill { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; color: var(--text2); background: var(--bg3); }
.pill.bad { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }
.pill.warn { color: var(--orange); background: color-mix(in srgb, var(--orange) 14%, transparent); }
.pill.good { color: var(--green); background: color-mix(in srgb, var(--green) 13%, transparent); }
.inj { scroll-margin-top: calc(var(--header-h) + 16px); }
.inj-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 8px; }
.inj-summary .inj-head b { font-size: 15px; }
.inj-good { border-top: 3px solid var(--green); }
.inj-bad { border-top: 3px solid var(--red); }
.team-jump { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.team-jump a {
  position: relative; display: grid; place-items: center; width: 38px; height: 38px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
}
.team-jump a:hover { border-color: var(--border2); background: var(--bg3); }
.team-jump img { width: 24px; height: 24px; object-fit: contain; }
.team-jump span {
  position: absolute; top: -5px; right: -5px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; color: #fff; background: var(--red);
}
@media (max-width: 860px) { .inj-summary { grid-template-columns: minmax(0, 1fr); } }
.inj-none { font-size: 13px; color: var(--text3); padding: 6px 0 4px; }

/* Venues */
.v-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.v-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; display: flex; flex-direction: column; }
.v-photo { aspect-ratio: 2 / 1; background: var(--bg3) center / cover no-repeat; position: relative; }
.v-photo small { position: absolute; right: 6px; bottom: 5px; font-size: 10px; color: #fff; background: rgb(0 0 0 / .55); padding: 1px 6px; border-radius: 4px; max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-photo small a { color: #fff; }
.v-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.v-head { display: flex; align-items: center; gap: 10px; }
.v-head img { width: 30px; height: 30px; object-fit: contain; }
.v-name { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.v-where { font-size: 12.5px; color: var(--text3); margin-top: 2px; }
.v-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.v-facts div { background: var(--bg3); border-radius: var(--radius-sm); padding: 7px 9px; min-width: 0; }
.v-facts dt { font-size: 10.5px; color: var(--text3); text-transform: uppercase; letter-spacing: .4px; }
.v-facts dd { font-size: 13px; font-weight: 600; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-note { font-size: 13px; line-height: 1.55; color: var(--text2); }
.v-dims { font-family: var(--mono); font-size: 12px; color: var(--text3); }

@media (max-width: 640px) {
  .lg { padding: 20px 16px 48px; }
  .lg-title { font-size: 25px; }
  .inj-grid, .v-grid, .lb-grid { grid-template-columns: minmax(0, 1fr); }
}
