/*
 * ascent-live.css — the Ascent #live standings block.
 * Scoped asc-live-* / asc-chip classes (the lo-* convention, own prefix), built
 * on the site's design tokens so it follows the theme. Status colours:
 * waiting grey / on-course blue (pulsing dot) / finished green / DNS-DNF grey
 * struck — mirrored by the chips the client script renders.
 */

/* Status bar: updated stamp + connection pill; collapses when both hidden. */
.asc-live-status {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.asc-live-status:not(:has(> :not([hidden]))) {
  display: none;
}
.asc-live-updated,
.asc-live-error {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--default-color), transparent 94%);
  color: color-mix(in srgb, var(--default-color), transparent 25%);
}
.asc-live-error {
  background: color-mix(in srgb, #ef4444, transparent 90%);
  color: #b3261e;
}

/* Notes (pre-draw / final standings) + skeleton/empty states. */
.asc-live-note,
.asc-live-skeleton,
.asc-live-empty {
  text-align: center;
  padding: 18px 14px;
  border: 1px dashed color-mix(in srgb, var(--heading-color), transparent 80%);
  border-radius: 14px;
  color: color-mix(in srgb, var(--default-color), transparent 25%);
  font-size: 15px;
}
.asc-live-note.final {
  border-style: solid;
  border-color: color-mix(in srgb, var(--accent-color), transparent 60%);
  background: color-mix(in srgb, var(--accent-color), transparent 92%);
  color: var(--heading-color);
  font-weight: 700;
  margin-bottom: 12px;
}

/* The standings table. Wide content scrolls inside its own container. */
.asc-live-scroll {
  overflow-x: auto;
}
.asc-live-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface-color);
  border: 1px solid color-mix(in srgb, var(--heading-color), transparent 86%);
  border-radius: 14px;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}
.asc-live-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: left;
  color: color-mix(in srgb, var(--default-color), transparent 35%);
  padding: 10px 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--heading-color), transparent 86%);
}
/* Headers follow their column's alignment — 3/4/5 are the numeric columns
   (start/time/speed), right-aligned like their cells. */
.asc-live-table th:nth-child(3),
.asc-live-table th:nth-child(4),
.asc-live-table th:nth-child(5) {
  text-align: right;
}
.asc-live-table td {
  padding: 9px 12px;
  border-top: 1px solid color-mix(in srgb, var(--heading-color), transparent 92%);
  vertical-align: middle;
}
/* Opaque row background: reorders animate with a FLIP glide (transform on the
   row), so a traveling row must cover — not blend into — the rows it passes. */
.asc-live-table tbody tr {
  background: var(--surface-color);
}
.asc-live-table tbody tr:first-child td {
  border-top: none;
}

.asc-cell-rank {
  width: 52px;
  font-weight: 800;
  color: var(--heading-color);
}
.asc-cell-rank.muted {
  color: color-mix(in srgb, var(--default-color), transparent 45%);
  font-weight: 600;
}
.asc-live-name {
  display: block;
  font-weight: 600;
  color: var(--heading-color);
  overflow-wrap: anywhere;
}
.asc-live-sub {
  display: block;
  font-size: 12px;
  color: color-mix(in srgb, var(--default-color), transparent 40%);
}
.asc-cell-start {
  width: 72px;
  font-size: 14px;
  text-align: right;
  color: color-mix(in srgb, var(--default-color), transparent 25%);
}
.asc-cell-time {
  width: 92px;
  font-size: 15px;
  text-align: right;
}
.asc-cell-time.final {
  font-weight: 800;
  color: var(--heading-color);
}
/* Avg speed — numeric only (the header carries the km/h unit). */
.asc-cell-speed {
  width: 64px;
  font-size: 14px;
  text-align: right;
  color: color-mix(in srgb, var(--default-color), transparent 25%);
}
.asc-cell-chip {
  width: 130px;
  text-align: right;
}

/* Row tints per state. */
.asc-live-row.is-biking td {
  background: color-mix(in srgb, #3b82f6, transparent 93%);
}
.asc-live-row.top td {
  background: color-mix(in srgb, var(--accent-color), transparent 92%);
}
.asc-live-row.is-dns td,
.asc-live-row.is-dnf td {
  color: color-mix(in srgb, var(--default-color), transparent 50%);
}
.asc-live-row.is-dns .asc-live-name,
.asc-live-row.is-dnf .asc-live-name {
  text-decoration: line-through;
  color: color-mix(in srgb, var(--default-color), transparent 40%);
}

/* Status chips (grey / pulsing blue / green / amber DNF / red DNS). */
.asc-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.asc-chip.waiting {
  background: #eceff3;
  color: #4b5563; /* 5.2:1 on #eceff3 — WCAG AA for the 12px bold label */
}
.asc-chip.biking {
  background: #dbeafe;
  color: #1d4ed8;
}
.asc-chip.biking::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3b82f6;
  animation: asc-pulse 1.6s ease-in-out infinite;
}
@keyframes asc-pulse {
  50% {
    opacity: 0.25;
  }
}
@media (prefers-reduced-motion: reduce) {
  .asc-chip.biking::before {
    animation: none;
  }
}
.asc-chip.finished {
  background: #dcfce7;
  color: #15803d;
}
.asc-chip.finished::before {
  content: "✓";
}
/* DNF (quit mid-race) amber vs DNS (never started) red — distinct from each
   other and from the waiting grey; the mobile × glyph inherits the tone.
   Both pairs hold WCAG AA for the 12px bold label. */
.asc-chip.dnf {
  background: #fef3c7;
  color: #92400e;
}
.asc-chip.dns {
  background: #fee2e2;
  color: #b91c1c;
}

/* Mobile: slim paddings, dot-only chips (the aria-label keeps them readable
   to assistive tech), tighter fixed columns. */
@media (max-width: 575px) {
  .asc-live-table th,
  .asc-live-table td {
    padding: 8px 7px;
  }
  .asc-cell-rank {
    width: 40px;
  }
  .asc-cell-start {
    width: 52px;
    font-size: 13px;
  }
  .asc-cell-time {
    width: 70px;
    font-size: 14px;
  }
  .asc-cell-speed {
    width: 44px;
    font-size: 13px;
  }
  .asc-cell-chip {
    width: 34px;
  }
  .asc-chip {
    font-size: 0;
    padding: 4px;
  }
  .asc-chip.waiting::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
  }
  /* DNS/DNF collapse to an × so they stay distinguishable from the waiting
     dot when the label text is hidden. */
  .asc-chip.dns::before,
  .asc-chip.dnf::before {
    content: "×";
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
  }
  .asc-chip.finished::before {
    font-size: 12px;
  }
  .asc-chip.biking::before {
    width: 9px;
    height: 9px;
  }
}
