/* race.cloudprime.co.uk — the one stylesheet every public page links:
   the homepage, the four race watchers and Races Near Me. Served from the site
   root with nav.js. The Training area keeps its own styles.css but copies the
   token block below, so it never depends on this file being deployed first.

   Tokens: muted and accent text are set per colour scheme so both pass 4.5:1
   on the page background. Status colours are white-on-colour, so they hold
   in either scheme. */
:root {
  color-scheme: light dark;
  --accent: #2f6fdb;        /* fills: active pills, the current section */
  --accent-text: #2f6fdb;   /* accent used AS text (links, labels) */
  --muted: #5f6368;         /* secondary text */
  --line: rgba(128,128,128,.3);
  --line-strong: rgba(128,128,128,.5);
  --chrome: #f3f4f6;        /* the site bar */
  --chrome-text: #3c4043;
  --ok: #1a7f37;
  --warn: #b35900;          /* fills; --warn-text when used as text */
  --warn-text: #b35900;
  --bad: #8a1f1f;
  --measure: 56rem;         /* one page width, site-wide */
  --nav-h: 2.9rem;
}
@media (prefers-color-scheme: dark) {
  :root { --accent-text: #7aa5f5; --muted: #a0a4ab; --warn-text: #f0a050; --chrome: #181a20; --chrome-text: #cfd3dc; }
}

* { box-sizing: border-box; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; margin: 0; line-height: 1.45;
       background: Canvas; color: CanvasText; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
::placeholder { color: var(--muted); opacity: 1; }
a { color: inherit; text-underline-offset: .18em; }
.skip { position: absolute; left: -999px; top: .5rem; z-index: 30; padding: .5rem .8rem; border-radius: .5rem; background: Canvas; }
.skip:focus { left: 1rem; }

/* The site bar. Every page ships it in its HTML with at least a Home link, so
   the page never jumps when nav.js fills in the rest, and a page whose script
   failed still has a way home. */
.site-nav-bar { display: flex; gap: .25rem; align-items: center; flex-wrap: wrap; min-height: var(--nav-h);
                padding: .3rem .8rem; background: var(--chrome); border-bottom: 1px solid var(--line); }
.site-nav-bar a { color: var(--chrome-text); text-decoration: none; padding: .5rem .7rem; border-radius: .4rem;
                  font-size: .9rem; font-weight: 600; line-height: 1; white-space: nowrap; }
.site-nav-bar a:hover { background: rgba(128,128,128,.15); }
.site-nav-bar a[aria-current] { background: var(--accent); color: #fff; }
@media (max-width: 720px) {
  /* One row that scrolls sideways, not three rows of links; nav.js fades
     whichever edge has more links past it. */
  .site-nav-bar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .site-nav-bar::-webkit-scrollbar { display: none; }
  .site-nav-bar a { flex-shrink: 0; }
  .site-nav-bar.fade-r { -webkit-mask-image: linear-gradient(90deg,#000 85%,transparent); mask-image: linear-gradient(90deg,#000 85%,transparent); }
  .site-nav-bar.fade-l { -webkit-mask-image: linear-gradient(90deg,transparent,#000 15%); mask-image: linear-gradient(90deg,transparent,#000 15%); }
  .site-nav-bar.fade-l.fade-r { -webkit-mask-image: linear-gradient(90deg,transparent,#000 15%,#000 85%,transparent);
                                mask-image: linear-gradient(90deg,transparent,#000 15%,#000 85%,transparent); }
}

/* The page frame. */
.page { max-width: var(--measure); margin: 0 auto; padding: 1.5rem 1rem 3rem; }
h1 { margin: 0 0 .25rem; font-size: 1.5rem; line-height: 1.2; }
.meta { color: var(--muted); font-size: .9rem; margin: 0 0 1rem; }
.empty { color: var(--muted); }
.stale { background: var(--warn); color: #fff; padding: .5rem .75rem; border-radius: .4rem; font-size: .9rem; margin: 0 0 1rem; }
.source-status { background: var(--bad); color: #fff; padding: .5rem .75rem; border-radius: .4rem; font-size: .9rem; margin: 0 0 1rem; }
.source-status ul { margin: 0; padding-left: 1.1rem; }
.source-status li { margin: .15rem 0; }

/* Race lists: the watchers and Races Near Me. A row of controls per question
   (Show / Within / When), each a group of pill buttons with aria-pressed. */
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: 0 0 .75rem; }
.controls-label { color: var(--muted); font-size: .85rem; min-width: 3.6rem; }
.pill { font: inherit; font-size: .875rem; min-height: 2.25rem; padding: .25rem .85rem; border: 1px solid var(--line-strong);
        border-radius: 1.2rem; background: transparent; color: inherit; cursor: pointer; }
.pill:hover { border-color: rgba(128,128,128,.9); }
.pill[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.search-input { font: inherit; font-size: 1rem; min-height: 2.25rem; padding: .25rem .8rem; border: 1px solid var(--line-strong);
                border-radius: 1.2rem; background: transparent; color: inherit; min-width: 11rem; flex: 1 1 11rem; max-width: 20rem; }
.sort-control { display: none; }
.sort-control select { font: inherit; font-size: 1rem; min-height: 2.25rem; padding: .2rem .4rem; border: 1px solid var(--line-strong);
                       border-radius: .4rem; background: transparent; color: inherit; }
.table-wrap { overflow-x: auto; margin-top: .5rem; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
/* A sortable heading is a real button inside the <th>, so the cell keeps its
   column-header role and aria-sort is valid on it. */
th .sortbtn { font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit; background: none; border: 0;
              padding: .2rem 0; margin: -.2rem 0; cursor: pointer; white-space: nowrap; }
th .sortbtn:hover { color: CanvasText; }
.arr { font-size: .75em; }
td.date { white-space: nowrap; font-variant-numeric: tabular-nums; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.dist { color: var(--muted); }
td.links { white-space: nowrap; }
.tag { display: inline-block; font-size: .75rem; padding: .1rem .4rem; border-radius: .25rem; border: 1px solid var(--line-strong);
       background: rgba(128,128,128,.12); white-space: nowrap; }
.badge { display: inline-block; font-size: .7rem; font-weight: 700; padding: .1rem .35rem; border-radius: .25rem; margin-left: .3rem; }
.badge-new { background: var(--ok); color: #fff; }
.badge-changed { background: var(--warn); color: #fff; }
tr.hidden { display: none; }

/* Phones: each event becomes a card instead of a wide table. */
@media (max-width: 640px) {
  .page { padding: 1rem 1rem 2.5rem; }
  .sort-control { display: inline-flex; align-items: center; gap: .3rem; }
  .controls-label { min-width: 0; }
  .table-wrap { overflow-x: visible; }
  thead { display: none; }
  table, tbody, td { display: block; }
  table { font-size: 1rem; }
  tr { display: flex; flex-direction: column; border: 1px solid var(--line-strong); border-radius: .5rem; padding: .6rem .8rem; margin-bottom: .6rem; }
  tr.hidden { display: none; }
  td { border: none; padding: .1rem 0; }
  td:empty { display: none; }
  td.name { order: -1; font-weight: 600; font-size: 1.05rem; margin-bottom: .1rem; }
  .num { text-align: left; }
  td.dist { color: inherit; }
  td.links a { display: inline-block; padding: .35rem 0; }
}
