@import url("tokens.css");

.livescores {
  max-width: 1100px;
  margin: 0 auto;
  /* base.html's nav is `position: fixed; height: 70px`, so this can't
     go below 70px without sliding back under it. The profile page uses
     130px, but that page has a big avatar/header block that wants the
     extra room — this page's header is a single line, so 106px (70px
     nav + a comfortable ~36px gap) is enough clearance without the
     empty-looking gap 130px left underneath the nav here. */
  padding: 106px 20px 64px;
}

.livescores-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.livescores-header h1 {
  font-family: var(--font-display);
  color: var(--text);
  margin: 0;
}

.livescores-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.ls-badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--surface-2);
  color: var(--text-mid);
}
.ls-badge--live    { background: var(--accent); color: var(--on-accent); }
.ls-badge--soon    { background: var(--surface-2); color: var(--text); border: 1px solid var(--accent); }
.ls-badge--idle    { background: var(--surface-2); color: var(--text-muted); }
.ls-badge--offline { background: var(--surface-2); color: var(--danger); }

.livescores-search {
  position: relative;
  margin-bottom: 20px;
}
.ls-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.ls-search-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 2.5rem 0.7rem 2.5rem;
  font-size: 1rem;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
/* Replaced by our own .ls-search-clear button below — the native one
   is tiny and inconsistent across browsers, exactly what was too
   fiddly to tap. */
.ls-search-input::-webkit-search-cancel-button,
.ls-search-input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}
.ls-search-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
}
.ls-search-clear:hover,
.ls-search-clear:focus-visible {
  color: var(--text);
  background: var(--surface-2);
}
.ls-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 228, 56, 0.2);
}
.ls-search-input::placeholder {
  color: var(--text-muted);
}

.ls-search-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.ls-search-fab {
  position: fixed;
  left: 16px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--text-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
/* Toggled on by JS via IntersectionObserver once the real search bar
   scrolls out of view -- see ls-search-fab in livescores.js. Kept out
   of the way on the left edge, well clear of the card column. */
.ls-search-fab--visible {
  opacity: 1;
  pointer-events: auto;
}
.ls-search-fab:hover,
.ls-search-fab:focus-visible {
  color: var(--text);
  border-color: var(--accent);
}

/* A league with zero matches while actively searching disappears
   entirely, rather than sitting there with an empty "no matches"
   state under its own heading — the page-level #ls-search-empty
   message covers the case where neither league has anything. */
.livescores-league--hidden {
  display: none;
}

.livescores-columns {
  display: grid;
  /* minmax(0, 1fr), not 1fr: a plain 1fr column won't shrink below its
     content's min width, so one long team name pushed the whole page wider
     than a phone screen. */
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
}
.livescores-league { min-width: 0; }
@media (min-width: 800px) {
  .livescores-columns { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}

/* The active league sits first via JS-set `order`; a backburner league
   (nothing live, nothing starting soon) is muted and collapsed by
   default rather than removed, so it's a glance away, not gone. */
.livescores-league--backburner .ls-league-title,
.livescores-league--backburner .ls-league-summary {
  color: var(--text-muted);
}

.ls-league-details summary {
  cursor: pointer;
  list-style: none;
}
.ls-league-details summary::-webkit-details-marker { display: none; }

.ls-league-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.ls-league-substatus {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
}

.livescores-games {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ls-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Game cards ───────────────────────────────────────────────────────
   Compact by default: one status/column-header line, then one line per team
   with the quarter scores and the total in the same row. Tapping a card
   (.ls-card--open, set from livescores.js) scales it up and reveals the
   last play, odds and the ESPN link. Sizes hang off a few custom properties
   so the open state only has to override them. */
.ls-card {
  --ls-logo: 24px;
  --ls-q-w: 22px;
  --ls-total-w: 32px;
  --ls-name-size: 0.95rem;
  --ls-q-size: 0.82rem;
  --ls-total-size: 1.05rem;
  --ls-meta-size: 0.72rem;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px 9px;
}
.ls-card--in   { border-color: var(--accent); }
.ls-card--post { opacity: 0.75; }

.ls-card--open {
  --ls-logo: 34px;
  --ls-q-w: 24px;
  --ls-total-w: 38px;
  --ls-name-size: 1.05rem;
  --ls-q-size: 0.95rem;
  --ls-total-size: 1.55rem;
  --ls-meta-size: 0.85rem;
  padding: 14px 16px;
  opacity: 1;
}

/* The whole scoreboard is one big tap target. Reset every button default
   so it reads as part of the card. */
.ls-card-toggle {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 8px;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ls-card-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Status on the left, quarter headers (1 2 3 4 T) over their columns on
   the right. */
.ls-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
  min-height: 1.1rem;
  color: var(--text-mid);
  font-size: var(--ls-meta-size);
}
.ls-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}
.ls-card--open .ls-chevron { transform: rotate(180deg); }

.ls-status-line {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  line-height: 1.25;
  /* Two lines at most while collapsed (down & distance can be long); the
     open card shows all of it. */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.ls-card--open .ls-status-line {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}
/* Open: the status gets the full first line and the column headers drop
   to their own line above the scores, so neither is squeezed on a phone. */
.ls-card--open .ls-meta-row { flex-wrap: wrap; row-gap: 6px; margin-bottom: 4px; }
.ls-card--open .ls-status-line { flex: 1 1 calc(100% - 24px); }
.ls-card--open .ls-nums--head { margin-left: auto; }
.ls-status-line--alert {
  color: var(--text);
  font-weight: 700;
}

.ls-team-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
  color: var(--text);
  font-weight: 500;
}
.ls-card--open .ls-team-row { padding: 5px 0; gap: 8px; }

.ls-team-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}
.ls-card--open .ls-team-identity { gap: 8px; }

.ls-team-logo {
  flex-shrink: 0;
  width: var(--ls-logo);
  height: var(--ls-logo);
  object-fit: contain;
}
.ls-team-logo--placeholder {
  display: inline-block;
}

.ls-team-name {
  display: flex;
  align-items: center;
  min-width: 0;
  font-size: var(--ls-name-size);
  font-weight: 700;
  line-height: 1.2;
}
.ls-team-name-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The record is extra width the compact card can't spare. */
.ls-team-record {
  display: none;
  flex-shrink: 0;
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.8rem;
  margin-left: 6px;
}
.ls-card--open .ls-team-name { display: block; }
.ls-card--open .ls-team-name-text { display: inline; white-space: normal; overflow: visible; }
.ls-card--open .ls-ball { display: inline-block; vertical-align: middle; }
.ls-card--open .ls-team-record { display: block; margin-left: 0; }

/* Quarter cells + total: fixed-width columns shared by the header row and
   both team rows, so they line up. */
.ls-nums {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  font-variant-numeric: tabular-nums;
}
.ls-q {
  width: var(--ls-q-w);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--ls-q-size);
  font-weight: 400;
}
.ls-q--cur {
  color: var(--text);
  font-weight: 700;
}
.ls-total {
  width: var(--ls-total-w);
  text-align: right;
  font-size: var(--ls-total-size);
  font-weight: 700;
  color: var(--text);
}
.ls-nums--head .ls-q,
.ls-nums--head .ls-total {
  font-size: var(--ls-meta-size);
  font-weight: 600;
  color: var(--text-muted);
}

.ls-ball {
  margin-right: 5px;
  flex-shrink: 0;
}

/* Everything below only exists once the card is open. */
.ls-card-more { display: none; }
.ls-card--open .ls-card-more {
  display: block;
  margin-top: 10px;
}

.ls-last-play {
  margin: 0;
  color: var(--text-mid);
  font-size: 0.9rem;
  font-style: italic;
  line-height: 1.35;
}

.ls-odds-line {
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  color: var(--text-mid);
  font-size: 0.85rem;
}
.ls-last-play + .ls-odds-line { margin-top: 10px; }
.ls-card-more > .ls-odds-line:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.ls-odds-source {
  color: var(--text-muted);
}

.ls-espn-link {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-decoration: none;
}
.ls-espn-link:hover,
.ls-espn-link:focus-visible {
  color: var(--accent);
  text-decoration: underline;
}
