/* ------------------------------------------------------------------
   Design tokens — THE REAL MTB BIELEFELD COLOURS.

   Taken from the club app (`mtb-bielefeld-app/src/theme.ts` and
   `brand.ts`), not eyeballed. The blue is the ICC conversion of the
   binding print definition C90 M50 Y20 K5; that file documents why
   that conversion and not one of the three alternatives.

   Two colours there are RESERVED and deliberately absent here: the
   clay ochre #a9600f belongs to the club app's difficulty rating
   ("Sonst nirgends") and the berry violet #863c73 to its highlights.
   Borrowing either would invent a third meaning a reader has to
   decode. --warn below is the club's `warning`, which its own comment
   places in the ochre family on purpose.

   Every pair here clears WCAG AA (worst: 5.02:1 for --brand as text).
   If the club ever names its own digital hex, it goes in brand.ts
   over there first — this file follows.
   ------------------------------------------------------------------ */
:root {
  --club-dark: #1b587a;      /* club blue, pressed state — headers, primary button */
  --brand: #25749e;          /* BRAND_BLUE — time and interaction: clocks, links, active */
  --brand-light: #62aeda;    /* same hue lightened — for use ON --club-dark */
  --go: #2e6b4a;             /* success — start */
  --stop: #af3626;           /* danger — finish; see .tapbtn note below */
  --warn: #8c5a16;           /* warning — offline, limits */
  --paper: #dfe4e7;          /* daylight-readable background, desaturated brand hue */
  --card: #fbfcfd;
  --ink: #111c22;
  --muted: #495b65;
  --line: #b7c2c8;           /* card borders — decorative, cards also differ by fill */
  --line-strong: #7a929f;    /* input borders — 3.17:1, the only thing marking an
                                empty field; --line would be 1.77:1 (WCAG 1.4.11) */
  --danger: #af3626;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.45;
}
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }

/* ---------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: var(--club-dark); color: #fff;
}
.brand {
  color: #fff; text-decoration: none;
  font-weight: 800; letter-spacing: 0.02em; font-size: 1.1rem;
}
.brand span { color: var(--brand-light); }
.topbar-right { display: flex; gap: 10px; align-items: center; }
.lang {
  background: transparent; color: #fff;
  border: 1px solid rgba(255,255,255,0.4); border-radius: 8px;
  padding: 3px 10px; font-weight: 600; font-size: 0.85rem;
  /* 44px is the touch floor; the box stays visually small because the
     extra height is padding, not a taller border box. */
  min-height: 44px; min-width: 44px;
}
.lang:focus-visible, .menu-toggle:focus-visible {
  outline: 3px solid var(--brand-light); outline-offset: 2px;
}
.conn {
  font-size: 0.75rem; padding: 3px 8px; border-radius: 999px;
  background: rgba(255,255,255,0.15);
}
.conn.offline { background: var(--warn); }

main { max-width: 640px; margin: 0 auto; padding: 16px 14px 60px; }

/* ------------------------------------------------------------ cards */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.eyebrow {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted); margin: 0 0 8px;
}
h1 { font-size: 1.35rem; margin: 0 0 4px; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 2px 0 0; }

.field { margin-bottom: 12px; }
.field label {
  display: block; font-size: 0.8rem; font-weight: 600;
  margin-bottom: 4px; color: var(--muted);
}
.field input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--card);
}
.field input:focus { outline: 2px solid var(--club-dark); outline-offset: 1px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; border: none; border-radius: 10px;
  padding: 11px 18px; font-weight: 700;
  background: var(--club-dark); color: #fff;
  min-height: 44px;
}
.btn.secondary { background: var(--card); color: var(--club-dark); border: 1.5px solid var(--club-dark); }
.btn.small { padding: 6px 12px; min-height: 44px; font-size: 0.85rem; }
.btn.block { width: 100%; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* code input — big, digit-friendly */
.code-input input {
  font-family: var(--mono); font-size: 1.6rem; letter-spacing: 0.35em;
  text-align: center;
}
.code-display {
  display: block; width: 100%; cursor: pointer;
  font-family: var(--mono); font-size: 2rem; letter-spacing: 0.3em;
  text-align: center; padding: 8px; border-radius: 10px;
  background: var(--paper); border: 1px dashed var(--line); color: var(--ink);
}
.code-display:focus-visible { outline: 3px solid var(--brand); }

/* role picker */
.roles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.role {
  border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--card); padding: 14px 12px; text-align: left;
}
.role b { display: block; font-size: 1rem; }
.role small { color: var(--muted); }
.role:focus-visible { outline: 3px solid var(--brand); }

/* --------------------------------------------- bib "number plate"  */
/* Signature element: each rider carries an MTB-style number plate —
   white plate, bold number, two zip-tie holes. */
.plate {
  position: relative; flex: none;
  width: 52px; height: 44px;
  background: #fff; border: 2px solid var(--ink); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 800; font-size: 1.15rem;
}
.plate::before, .plate::after {
  content: ""; position: absolute; top: 4px;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--paper); border: 1px solid var(--ink);
}
.plate::before { left: 6px; }
.plate::after { right: 6px; }

/* ------------------------------------------------------- rider rows */
.rider {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--card); margin-bottom: 8px;
}
.rider .who { flex: 1; min-width: 0; }
.rider .who b { display: block; overflow-wrap: anywhere; line-height: 1.2; }
.rider .who small { color: var(--muted); }
.rider .clock {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 1.2rem; font-weight: 700;
}
.rider.finished .clock { color: var(--go); }

.tapbtn {
  border: none; border-radius: 12px;
  min-width: 78px; min-height: 52px; padding: 0 12px;
  font-weight: 800; font-size: 1rem; color: #fff;
}
.tapbtn:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.tapbtn.start { background: var(--go); }
.tapbtn.stop { background: var(--stop); }

/* countdown board */
.board {
  text-align: center; padding: 18px 12px;
}
.board .big {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 3.4rem; font-weight: 800; line-height: 1;
  color: var(--club-dark);
}
.board .big.hot { color: var(--stop); }
.board .next { font-size: 1.05rem; margin-top: 6px; }

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* results table */
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
td.time, td.rank { font-family: var(--mono); font-variant-numeric: tabular-nums; }
tr.podium td.rank { color: var(--brand); font-weight: 800; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tab {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 5px 14px; font-weight: 600; font-size: 0.85rem;
  color: var(--ink); -webkit-appearance: none;
  min-height: 44px;
}
.tab:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.group-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted); margin: 14px 0 6px;
}
.group-section { border-radius: 12px; }
.group-section.active { outline: 2px dashed var(--brand); outline-offset: 4px; background: #e8eff4; }
.drag-handle {
  touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
  flex: none; padding: 6px 8px; color: var(--muted); font-size: 1.2rem; line-height: 1;
  min-height: 44px; display: flex; align-items: center;
}
.ghost { position: fixed; pointer-events: none; opacity: 0.9; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,0.25); }
.tab.active { background: var(--club-dark); color: #fff; border-color: var(--club-dark); }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px;
  border-radius: 999px; font-weight: 600; z-index: 50;
  display: flex; gap: 12px; align-items: center;
}
.toast button { background: var(--brand); border: none; color: #fff;
  border-radius: 999px; padding: 4px 12px; font-weight: 700; }

.empty { color: var(--muted); text-align: center; padding: 18px 8px; }
.inline-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.inline-edit .wide { grid-column: 1 / -1; }
.danger { color: var(--danger); }
.mut { color: var(--muted); font-size: 0.85rem; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.inline-edit input { padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--card); }
.inline-edit input:focus { outline: 2px solid var(--club-dark); outline-offset: 1px; }
.tabs.wide { grid-column: 1 / -1; margin-bottom: 0; }

/* ------------------------------------------------------- burger menu */
/* The drawer keeps the top bar's colour so the two read as one surface
   dropping down, not as a foreign panel landing on top. */
.menu-toggle {
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
  width: 44px; min-height: 44px; padding: 0 10px;
  background: transparent; border: 1px solid rgba(255,255,255,0.4);
  border-radius: 8px;
}
.menu-toggle span {
  display: block; height: 2px; width: 100%; background: #fff; border-radius: 2px;
  transition: width 120ms ease;
}
/* open: the outer bars pull in, the middle one stays -- a small, honest
   hint that this is a toggle rather than a link */
.menu-toggle[aria-expanded="true"] span:first-child,
.menu-toggle[aria-expanded="true"] span:last-child { width: 60%; }

.menu-scrim {
  position: fixed; inset: 0; z-index: 8;
  background: rgba(17, 28, 34, 0.45);
}
.menu-panel {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 9;
  background: var(--club-dark); padding: 6px 0 10px;
  box-shadow: 0 12px 28px rgba(27, 88, 122, 0.35);
}
.menu-panel a {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 52px; padding: 0 16px; color: #fff; text-decoration: none;
  border-top: 1px solid rgba(255,255,255,0.12);
}
.menu-panel a:focus-visible {
  outline: 3px solid var(--brand-light); outline-offset: -3px;
}
/* label over hint: without the column the two run together into
   "StartseiteRennen anlegen oder beitreten" */
.menu-panel a > span { display: flex; flex-direction: column; min-width: 0; }
.menu-panel b { font-weight: 700; font-size: 0.98rem; }
.menu-panel small { color: rgba(255,255,255,0.6); font-size: 0.78rem; }
.menu-panel .chev { flex: none; color: var(--brand-light); }

/* --------------------------------------------------- content pages */
/* Info, versions and the legal page: reading views, not control views. */
.prose h2 { font-size: 1.02rem; margin: 0 0 6px; }
.prose h3 { font-size: 0.88rem; margin: 14px 0 4px; }
.prose p { margin: 0 0 8px; }
.prose ul { margin: 0 0 8px; padding-left: 18px; }
.prose li { margin-bottom: 5px; }
.prose address { font-style: normal; line-height: 1.6; }
.prose a { color: var(--brand); }
.prose a:hover { color: var(--club-dark); }

.step { display: flex; gap: 12px; align-items: flex-start;
        padding: 10px 0; border-top: 1px solid var(--paper); }
.step:first-of-type { border-top: none; }
.step .who { flex: 1; min-width: 0; }
.step b { display: block; line-height: 1.25; }
.step small { color: var(--muted); }

.feat { display: flex; gap: 12px; align-items: flex-start; }
.feat + .feat { margin-top: 14px; }
.feat b { display: block; font-size: 0.95rem; line-height: 1.3; }
.feat small { color: var(--muted); }
.feat .ico {
  flex: none; display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--paper); border: 1px solid var(--line);
}

.card.limits { border-color: var(--warn); background: #f7f1e6; }
.card.limits .eyebrow { color: var(--warn); }

.vnum { font-family: var(--mono); font-weight: 800; font-size: 1.05rem; }
.vhead { display: flex; align-items: baseline; justify-content: space-between;
         gap: 10px; margin-bottom: 2px; }
.card.current { border-left: 3px solid var(--brand); }
.vpill { border-radius: 999px; padding: 3px 10px; font-weight: 700;
         font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase;
         background: var(--brand); color: #fff; }
.vpill.old { background: var(--paper); color: var(--muted); border: 1px solid var(--line); }

.dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px;
      font-size: 0.9rem; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
