/* Public standings */
.standings-page {
  --standings-accent: #ad1928;
  --standings-accent-line: #d62737;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--workspace);
}

html[data-theme="dark"] .standings-page {
  --standings-accent: #ff7882;
  --standings-accent-line: #ef3949;
}

.standings-header {
  background: var(--card);
  border-bottom: 2px solid var(--standings-accent-line);
}

.standings-header-inner, .standings-main {
  width: min(100%, 1220px);
  margin-inline: auto;
  padding-inline: clamp(12px, 3.5vw, 36px);
}

.standings-header-inner, .standings-heading, .standings-filter-row, .standings-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.standings-header-inner { min-height: 58px; padding-block: 8px; }
.standings-main {
  flex: 1;
  padding-block: clamp(22px, 4vw, 40px) 48px;
}

.standings-brand {
  display: inline-flex;
}

.standings-brand img {
  display: block;
  width: clamp(112px, 24vw, 144px);
  height: auto;
}

html[data-theme="light"] .standings-brand img {
  filter: brightness(.58) contrast(1.3);
}

.standings-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.standings-page .standings-submit-button {
  background: #b62030;
  border-color: #b62030;
  color: #fff;
  text-decoration: none;
}
.standings-page .standings-submit-button:hover {
  background: #991727;
  border-color: #991727;
}
.submission-panel {
  max-width: 620px;
  padding: clamp(16px, 4vw, 28px);
}
.submission-panel p {
  margin: 0 0 16px;
  color: var(--muted-foreground);
}
.submission-panel .submission-error { color: var(--standings-accent); }
.submission-form {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}
.submission-form label { font-weight: 600; }
.submission-form small { color: var(--muted-foreground); }
.submission-form .btn { justify-self: start; margin-top: 8px; }
.submission-form fieldset {
  min-width: 0;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.submission-form legend { padding-inline: 5px; }
.submission-form fieldset :is(input, select, small) { display: block; margin-top: 6px; }
.submission-form input[type="file"] {
  height: auto;
  min-height: 36px;
  padding: 5px 8px;
  line-height: 1.35;
}
.submission-form input[type="file"]::file-selector-button {
  margin: 0 8px 0 0;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--secondary);
  color: inherit;
  font: inherit;
  vertical-align: middle;
}
.submission-consent { display: flex; align-items: baseline; gap: 8px; }
.submission-consent input { flex: none; }
.standings-footer { border-top: 1px solid var(--border); color: var(--muted-foreground); font-size: .875rem; }
.standings-footer .standings-actions { gap: 8px 16px; }
.standings-footer a, .legal-panel a, .submission-consent a { color: var(--standings-accent); text-decoration: underline; }
.legal-panel { max-width: 820px; padding: clamp(16px, 4vw, 32px); line-height: 1.65; overflow-wrap: anywhere; }
.legal-panel h2 { font-size: 1.125rem; margin: 22px 0 6px; }
.legal-panel p, .legal-panel ul { margin: 0 0 10px; }
.legal-panel ul { padding-left: 22px; }
.standings-heading { margin-bottom: 20px; align-items: end; }
.standings-heading h1 { font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -.035em; line-height: 1.25; }
.standings-heading p { margin-top: 4px; color: var(--muted-foreground); }
#lb-last-updated-text { font-size: .8125rem; }

.standings-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 18px;
}

.standings-summary > div, .standings-panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-xs);
}

.standings-summary > div { padding: clamp(10px, 2vw, 16px); }
.standings-summary dt { color: var(--muted-foreground); font-size: .8125rem; }
.standings-summary dd { font-size: clamp(1rem, 2.3vw, 1.5rem); font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.standings-summary dd.standings-summary-note { font-size: .8125rem; font-weight: 400; color: var(--muted-foreground); }
#stat-p1-time { color: var(--standings-accent); }

.standings-controls { display: grid; gap: 12px; padding: 14px; border-bottom: 1px solid var(--border); }
.standings-toggle { display: inline-flex; gap: 3px; padding: 3px; background: var(--secondary); border-radius: var(--radius-md); }
.standings-toggle button {
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted-foreground);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.standings-toggle button[aria-pressed="true"] {
  background: color-mix(in srgb, var(--standings-accent) 10%, var(--card));
  border-color: var(--standings-accent-line);
  color: var(--standings-accent);
}
.standings-toggle button span { margin-left: 3px; font-size: .8em; color: var(--muted-foreground); }
.standings-inputs { justify-content: flex-start; }
.standings-inputs > input { flex: 1 1 240px; max-width: 440px; }
.standings-tier { display: flex; align-items: center; gap: 8px; font-weight: 550; min-width: 0; }
.standings-tier select { min-width: 0; width: min(230px, 55vw); }
.standings-empty { padding: 30px 14px; text-align: center; color: var(--muted-foreground); }

.standings-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.standings-table :is(th, td) { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.standings-table th { color: var(--muted-foreground); background: var(--workspace); font-size: .8rem; font-weight: 600; }
.standings-table tr:last-child td { border-bottom: 0; }
.standings-table tbody tr:hover { background: var(--accent); }
.standings-table :is(.standing-stint, .standing-average, .standing-fastest, .standing-gap, .standing-previous) { text-align: right; white-space: nowrap; }
.standings-table .standing-rank { width: 58px; text-align: center; }
.standings-rank-number { color: var(--muted-foreground); font-weight: 600; }
.standings-table .is-first .standings-rank-number { color: var(--primary-ink); }
.standing-driver { overflow-wrap: anywhere; }
.standing-driver strong, .standing-stint strong { font-weight: 650; }
.standings-secondary { display: block; color: var(--muted-foreground); font-size: .8rem; }
.standing-tier-label {
  display: inline-block;
  max-width: 100%;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--tier-color, var(--border));
  border-radius: var(--radius-sm);
  background: var(--secondary);
  overflow-wrap: anywhere;
}
.standing-metric-label { display: none; }
.standings-pagination { border-top: 1px solid var(--border); padding: 11px 14px; }
.standings-pagination p { color: var(--muted-foreground); font-size: .8125rem; }

@media (max-width: 880px) {
  .standings-table, .standings-table tbody { display: block; }
  .standings-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    clip-path: inset(50%);
    overflow: hidden;
    white-space: nowrap;
  }
  .standings-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, .75fr) repeat(3, minmax(0, 1fr));
    align-items: baseline;
    gap: 8px 5px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }
  .standings-table tbody tr:last-child { border-bottom: 0; }
  .standings-table tbody td { padding: 0; border: 0; }
  .standings-table .standing-rank { grid-column: 1; grid-row: 1; width: auto; text-align: left; }
  .standings-table .standing-driver { grid-column: 2 / 4; grid-row: 1; }
  .standings-table .standing-stint { grid-column: 4; grid-row: 1; text-align: right; }
  .standings-table .standing-tier { grid-column: 2 / -1; grid-row: 2; font-size: .8125rem; }
  .standings-table :is(.standing-average, .standing-fastest, .standing-gap, .standing-previous) {
    grid-row: 3;
    text-align: left;
    font-size: .86rem;
  }
  .standing-metric-label { display: block; color: var(--muted-foreground); font-size: .69rem; font-weight: 500; }
}

@media (max-width: 430px) {
  .standings-controls, .standings-pagination { padding: 10px; }
  .standings-page .btn, .standings-toggle button { min-height: 40px; }
  .standings-summary { gap: 6px; }
  .standings-table tbody tr { padding-inline: 10px; }
}
