/* Ride Joburg portal — race-day design lab.
   Tokens and atoms follow ~/Documents/ride-joburg-portal/README.md (v3, PSD-matched).
   Every size is in points on the comps' 402pt phone, multiplied by --u. */

@font-face {
  font-family: 'RJ Avantgarde';
  src: url('fonts/Avantgarde-Bold.otf') format('opentype');
  font-weight: 700;
  font-display: block;
}
@font-face {
  font-family: 'RJ Titillium';
  src: url('fonts/TitilliumWeb-SemiBoldItalic.ttf') format('truetype');
  font-weight: 600;
  font-style: italic;
  font-display: block;
}

:root {
  --gold: #FFEC3E;
  --gold-text: #FFEE50;
  --orange: #F15A24;
  --danger: #E92014;
  --white: #FFFFFF;
  --floor: #090D0C;
  --tile: #424242;
  --tile-icon: #808080;
  --panel: rgba(0, 0, 0, 0.40);
  --card: rgba(255, 255, 255, 0.05);
  --card-border: rgba(255, 255, 255, 0.10);
  --stat-box: rgba(255, 255, 255, 0.06);
  --muted: rgba(255, 255, 255, 0.72);
  --faint: rgba(255, 255, 255, 0.55);
  --caption: rgba(255, 255, 255, 0.60);

  --w: min(100vw, 440px);
  --u: calc(var(--w) / 402);
  --gutter: calc(var(--u) * 24);

  --display: 'RJ Avantgarde', 'Avenir Next Condensed', 'Arial Narrow', sans-serif;
  --title: 'RJ Titillium', 'Titillium Web', 'Avenir Next', sans-serif;
  --system: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  /* Header placement (Calendar comp); pages override. */
  --hx: 38.5;
  --eyebrow-top: 150.9;
  --title-top: 172.4;
  --title-size: 34;
  --content-top: 233;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: #000;
  color: var(--white);
  font-family: var(--system);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
a { color: inherit; }

.page {
  position: relative;
  width: var(--w);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--floor);
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

@media (min-width: 441px) {
  body { background: radial-gradient(circle at 50% 0%, #1a1a1a 0%, #000 60%); }
  .page { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 30px 80px rgba(0, 0, 0, 0.6); }
}

/* ---------- Page shell ---------- */

.backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: auto;
  aspect-ratio: 1206 / 2479;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}

/* Logo artwork is 332.8pt wide; its disk centre (54.3% / 48.7%) sits at (201, 87.3). */
.logo {
  position: absolute;
  width: calc(var(--u) * 332.8);
  left: calc(var(--u) * 20.29);
  top: calc(var(--u) * -34.83);
  pointer-events: none;
  user-select: none;
}

.badge {
  position: absolute;
  width: calc(var(--u) * 103.8);
  height: calc(var(--u) * 103.8);
  left: calc(var(--u) * 149.1);
  top: calc(var(--u) * 35.4);
  border-radius: 50%;
  z-index: 2;
}

.chrome {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: var(--w);
  height: 0;
  z-index: 60;
}

.status-scrim {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: var(--w);
  height: env(safe-area-inset-top);
  background: rgba(0, 0, 0, 0.22);
  z-index: 59;
  pointer-events: none;
}

.menu-btn,
.back-btn {
  position: absolute;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  top: calc(var(--u) * 83.25 - 22px);
}

.menu-btn { left: calc(var(--u) * 40.4 - 22px); }
.menu-btn img { width: calc(var(--u) * 23.4); height: calc(var(--u) * 17.3); display: block; }

.back-btn {
  right: var(--gutter);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.22);
  text-decoration: none;
}
.back-btn svg { width: 22px; height: 22px; }

/* Text is placed by cap-top. The subtracted constants convert a cap-top into
   a line-box top using each font's ascent / descent / cap-height ratios. */
.hdr {
  position: relative;
  height: calc(var(--u) * var(--content-top));
  flex: 0 0 auto;
}

.eyebrow {
  position: absolute;
  left: calc(var(--u) * var(--hx));
  right: var(--gutter);
  top: calc(var(--u) * var(--eyebrow-top) - 1.35px);
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  line-height: 18px;
  letter-spacing: 0.8px;
  color: var(--gold);
  text-transform: uppercase;
  white-space: nowrap;
}

.title {
  position: absolute;
  left: calc(var(--u) * var(--hx));
  right: var(--gutter);
  top: calc(var(--u) * (var(--title-top) - var(--title-size) * 0.2625));
  margin: 0;
  font-family: var(--title);
  font-style: italic;
  font-weight: 600;
  font-size: calc(var(--u) * var(--title-size));
  line-height: 1.15;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subtitle {
  position: absolute;
  left: calc(var(--u) * var(--hx));
  right: var(--gutter);
  top: calc(var(--u) * var(--subtitle-top) - 4.76px);
  margin: 0;
  font-size: 15px;
  line-height: 20px;
  color: rgba(255, 255, 255, 0.62);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.body {
  position: relative;
  padding: 0 var(--gutter);
  flex: 1 0 auto;
}

.footer {
  position: relative;
  display: block;
  width: calc(var(--u) * 288);
  height: auto;
  aspect-ratio: 1575 / 537;
  margin: calc(var(--u) * 32) auto calc(env(safe-area-inset-bottom) + 12px);
  pointer-events: none;
  /* The export trims the X's legs flush with its bottom edge; fade them out
     the way the stripes already fade at the sides. */
  -webkit-mask-image: linear-gradient(to bottom, #000 58%, rgba(0, 0, 0, 0.55) 80%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 58%, rgba(0, 0, 0, 0.55) 80%, transparent 100%);
}

/* ---------- Atoms ---------- */

.panel {
  background: var(--panel);
  border-radius: 6px;
  padding: 8px;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 14px;
}

.card-title {
  margin: 0;
  font-size: 17px;
  line-height: 21px;
  font-weight: 800;
  color: var(--gold-text);
}

.label {
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  line-height: 18px;
  letter-spacing: 2px;
  color: var(--gold);
  text-transform: uppercase;
  margin: 0;
}

.oblique {
  display: inline-block;
  transform: skewX(-10deg);
  padding: 0 3px;
}

.stat { text-align: center; min-width: 0; }
.stat .v {
  display: inline-block;
  font-family: var(--display);
  font-weight: 700;
  font-size: var(--stat-size, 28px);
  line-height: 1.05;
  color: var(--gold);
  transform: skewX(-10deg);
  padding: 0 3px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.stat .c {
  display: block;
  font-size: 11px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--caption);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-row { display: flex; gap: 8px; }
.stat-box {
  flex: 1;
  min-width: 0;
  background: var(--stat-box);
  border-radius: 8px;
  padding: 6px 4px;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 calc(var(--gutter) * -1);
  padding: 0 var(--gutter);
  scroll-padding: 0 var(--gutter);
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  height: 30px;
  padding: 0 12px;
  border-radius: 15px;
  border: 1.5px solid rgba(255, 255, 255, 0.30);
  background: rgba(0, 0, 0, 0.25);
  color: var(--muted);
  font-size: 14px;
  line-height: 27px;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease;
}
.chip.on {
  border-color: var(--gold);
  background: rgba(255, 236, 62, 0.12);
  color: var(--gold);
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 21px;
  padding: 0 9px;
  border-radius: 5px;
  background: var(--gold);
  color: #000;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 50px;
  border-radius: 10px;
  font-size: 19px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  border: 0;
}
.btn.solid { background: var(--gold); color: #000; }
.btn.outline { border: 1.5px solid var(--gold); background: rgba(0, 0, 0, 0.25); color: var(--gold); }
.btn.small { height: 40px; font-size: 16px; border-radius: 9px; }

.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 35.6px;
  padding: 0 14px 0 17px;
  font-size: 16px;
  color: var(--muted);
  text-decoration: none;
}
.menu-row .chev { color: var(--faint); font-size: 14px; }

.search {
  position: relative;
  display: block;
}
.search input {
  width: 100%;
  height: 44px;
  padding: 0 14px 0 40px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--white);
  font: 16px var(--system);
  outline: none;
  -webkit-appearance: none;
}
.search input::placeholder { color: var(--faint); }
.search input:focus { border-color: rgba(255, 236, 62, 0.6); }
.search svg {
  position: absolute;
  left: 13px;
  top: 50%;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0 10px;
}
.section-head .meta { font-size: 13px; color: var(--faint); white-space: nowrap; }

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--white);
}
.live-dot::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(233, 32, 20, 0.25);
}
.live-dot.idle::before { background: var(--faint); box-shadow: none; }
.live-dot.final::before { background: var(--gold); box-shadow: none; }

/* ---------- Result / standing rows ---------- */

.rows { display: flex; flex-direction: column; }

.row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px 10px 12px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: none;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.row:last-child { border-bottom: 0; }
.row-wrap { border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.row-wrap:last-child { border-bottom: 0; }
.row-wrap > .row { border-bottom: 0; }
.row.me { background: linear-gradient(90deg, rgba(255, 236, 62, 0.14), rgba(255, 236, 62, 0) 75%); border-radius: 8px; }
.row.out { opacity: 0.45; }

.row .pos {
  justify-self: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 22px;
  line-height: 1;
  color: var(--gold);
  transform: skewX(-10deg);
  padding: 0 3px;
  font-variant-numeric: tabular-nums;
}
.row .pos.small { font-size: 15px; letter-spacing: 1px; }

.row .who { display: block; min-width: 0; }
.row .name {
  display: block;
  font-size: 16px;
  line-height: 20px;
  font-weight: 700;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row .meta {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  line-height: 16px;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row .meta b { color: var(--muted); font-weight: 600; }
.row .meta .fin { color: var(--gold); font-weight: 700; }
.row .meta .dnf { color: var(--danger); font-weight: 700; }

.row .time { display: block; text-align: right; white-space: nowrap; }

.you-tag { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 4px; background: var(--gold); color: #000; font-size: 11px; line-height: 15px; font-weight: 800; vertical-align: 2px; }
.row .time .t {
  display: inline-block;
  font-family: var(--display);
  font-weight: 700;
  font-size: 19px;
  line-height: 1;
  color: var(--white);
  transform: skewX(-10deg);
  padding: 0 3px;
  font-variant-numeric: tabular-nums;
}
.row .time .gap {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.row-detail {
  overflow: hidden;
  height: 0;
}
.row-detail.open { height: auto; }
.row-detail .inner { padding: 4px 6px 14px 6px; }

.splits {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  column-gap: 12px;
  row-gap: 7px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.splits .tp { color: var(--gold); font-family: var(--display); font-weight: 700; letter-spacing: 1px; }
.splits .bar { align-self: center; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.splits .bar i { display: block; height: 100%; background: var(--gold); border-radius: 2px; }
.splits .ahead { color: var(--faint); }

/* ---------- Podium ---------- */

.podium {
  display: grid;
  grid-template-columns: 1fr 1.12fr 1fr;
  align-items: end;
  gap: 8px;
}
.podium .step {
  background: var(--stat-box);
  border-radius: 8px;
  padding: 10px 6px 9px;
  text-align: center;
  min-width: 0;
}
.podium .step.first {
  background: linear-gradient(180deg, rgba(255, 236, 62, 0.18), rgba(255, 236, 62, 0.04));
  border: 1px solid rgba(255, 236, 62, 0.35);
  padding-top: 16px;
}
.podium .place {
  display: inline-block;
  font-family: var(--display);
  font-weight: 700;
  font-size: 30px;
  line-height: 1;
  color: var(--gold);
  transform: skewX(-10deg);
  padding: 0 3px;
}
.podium .first .place { font-size: 40px; }
.podium .pname {
  margin-top: 6px;
  font-size: 13px;
  line-height: 16px;
  font-weight: 700;
  color: var(--white);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 32px;
}
.podium .ptime {
  display: inline-block;
  margin-top: 4px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  color: var(--white);
  transform: skewX(-10deg);
  font-variant-numeric: tabular-nums;
}
.podium .pcat { display: block; margin-top: 2px; font-size: 11px; letter-spacing: 0.4px; text-transform: uppercase; color: var(--caption); }

/* ---------- States ---------- */

.banner {
  text-align: center;
  padding: 34px 18px 30px;
}
.banner .glyph {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid rgba(255, 236, 62, 0.5);
  background: rgba(255, 236, 62, 0.08);
  color: var(--gold);
}
.banner .glyph svg { width: 26px; height: 26px; }
.banner h2 { margin: 0 0 8px; font-size: 18px; line-height: 23px; font-weight: 800; }
.banner p { margin: 0 auto; max-width: 300px; font-size: 14px; line-height: 20px; color: var(--muted); }
.banner .when { margin-top: 16px; }

.skeleton {
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.11) 50%, rgba(255,255,255,0.05) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

.empty-note { padding: 22px 10px; text-align: center; font-size: 14px; color: var(--faint); }

.flash { background: rgba(255, 236, 62, 0.16); }

/* ---------- Menu drawer (not designed — kept plain) ---------- */

.drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}
.drawer-scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: max(0px, calc(50vw - 220px));
  width: min(78vw, 320px);
  background: #0d1110;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 91;
  padding: calc(env(safe-area-inset-top) + 28px) 16px 24px;
  transform: translateX(-105%);
  transition: transform 220ms ease;
}
.drawer.open { transform: none; }
.drawer .label { margin: 0 0 12px 4px; }
.drawer nav { display: flex; flex-direction: column; gap: 2px; }
.drawer a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 16px;
}
.drawer a.on { color: var(--gold); background: rgba(255, 236, 62, 0.08); }
.drawer .note { margin: 22px 4px 0; font-size: 12px; line-height: 17px; color: var(--faint); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

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