/* MotoSched styles. Phone layout first; wider screens only get a little more
   room. Every color is a token below so light and dark themes stay in sync. */

/* Color tokens. Contrast ratios (WCAG) were checked for both themes:
     light: text/bg 16.45, text/surface 17.79, muted/bg 6.99, muted/surface 7.56,
            accent/surface 6.67, badge text on live 6.54, on warn 6.80,
            on accent 6.67, on neutral 7.56, focus/bg 6.17
     dark:  text/bg 16.43, text/surface 14.60, muted/bg 8.69, muted/surface 7.73,
            accent/surface 7.94, badge text on live 8.15, on warn 11.71,
            on accent 8.93, on neutral 8.69, focus/bg 8.93
   Targets: 4.5:1 for text, 3:1 for badges and focus rings. Re-check if you
   change a value. */
:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #15181d;
  --muted: #4b5563;
  --accent: #0b5cad;
  --live: #b3261e;
  --warn: #8a4b00;
  --focus: #0b5cad;
  --border: #c9ced6;
  --on-badge: #ffffff;
  --neutral: #4b5563;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101318;
    --surface: #1a1f27;
    --text: #eef1f5;
    --muted: #a9b2bf;
    --accent: #7cb7ff;
    --live: #ff8a80;
    --warn: #ffc35c;
    --focus: #7cb7ff;
    --border: #3a4250;
    --on-badge: #101318;
    --neutral: #a9b2bf;
  }
}

/* 100% keeps the user's browser text size; everything else is in rem so it
   scales with it (constitution III). */
html {
  font-size: 100%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0 auto;
  max-width: 40rem;
  padding-inline: 1rem;
  padding-block: 0.75rem 2rem;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1.125rem;
  line-height: 1.5;
  /* Long names wrap rather than pushing the page sideways at 320px. */
  overflow-wrap: anywhere;
}

@media (min-width: 48rem) {
  body {
    max-width: 44rem;
  }
}

h1 {
  margin: 0;
  font-size: 1.5rem;
}

h2 {
  margin: 1.25rem 0 0.5rem;
  font-size: 1.125rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

p {
  margin: 0.25rem 0;
}

a {
  color: var(--accent);
}

/* The hidden attribute must win over any display rule below. */
[hidden] {
  display: none !important;
}

.card {
  margin: 0;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
}

/* Badges always carry text, so color is never the only cue. */
.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: var(--neutral);
  color: var(--on-badge);
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.4;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* 2.75rem is 44px at default text size: a comfortable tap target. */
button,
footer a {
  min-height: 2.75rem;
}

button {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

/* --- Event cards (US1) --- */

.card__series {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.card__name {
  margin: 0.125rem 0;
  font-size: 1.125rem;
  line-height: 1.3;
}

.card__venue,
.card__when,
.card__status {
  margin: 0;
}

.card__venue {
  color: var(--muted);
}

.card__status {
  margin-top: 0.375rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  align-items: center;
}

.countdown {
  font-weight: 700;
}

.region-body {
  display: grid;
  gap: 0.75rem;
}

/* A gentle pulsing ring draws the eye to a live race. The ring pulses, not
   the badge itself, so the badge text never loses contrast. People who ask
   for reduced motion get a still badge; the "Live" text carries the meaning
   either way. */
@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 var(--live); }
  100% { box-shadow: 0 0 0 0.5rem transparent; }
}

.badge--live {
  background: var(--live);
  animation: live-pulse 1.6s ease-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .badge--live {
    animation: none;
  }
}

/* The next race to start stands out from the rest of the list. */
#next .card {
  border: 2px solid var(--accent);
}

#next .card__name {
  font-size: 1.375rem;
}

/* --- Upcoming list (US2) --- */

#upcoming ul,
#between ul {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Upcoming cards are a little tighter than the live and next-up ones, so
   more of the list fits on a phone screen. */
#upcoming .card {
  padding: 0.5rem 0.875rem;
}

#upcoming .card__status {
  margin-top: 0.125rem;
}

/* --- Trust labels and footer (US6) --- */

/* Uncertain information uses the amber warn color; a race that won't run
   as listed uses the neutral grey. Each badge also says what it means. */
.badge--unconfirmed,
.badge--tbc {
  background: var(--warn);
}

.badge--postponed,
.badge--cancelled {
  background: var(--neutral);
}

/* Muted is 6.99:1 on the page background in light mode and 8.69:1 in dark,
   well above the 4.5:1 needed for body text. */
footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 1rem;
}

.footer__sources {
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.footer__sources a {
  display: inline-flex;
  align-items: center;
}

/* --- Series filter chips (US3) --- */

/* Chips wrap onto a second line rather than scrolling sideways, so every
   option is visible on a narrow phone. */
#filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* 1rem text (a step below body text) lets all six chips fit on two rows on a
   375px phone, keeping Next up on the first screen. */
.chip {
  border-radius: 999px;
  padding: 0.375rem 0.875rem;
  font-size: 1rem;
}

/* The chosen chip is filled, and also bold, so it stands out without relying
   on color alone. */
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-badge);
  font-weight: 700;
}

/* --- Between seasons (US4) --- */

/* A quieter card than a race: no border emphasis, muted note. */
#between li {
  background: transparent;
  border-style: dashed;
}

.between__line {
  margin: 0;
}

.between__note {
  margin: 0.125rem 0 0;
  color: var(--muted);
  font-size: 1rem;
}
