/* RaceSense "race-day cockpit" design system — dark, data-forward.
   Tokens + Bootstrap overrides (themes every page) + cockpit components. */
:root {
  --bg: #0A0D12;
  --s1: #14181F;   /* card */
  --s2: #1C212B;   /* raised */
  --s3: #222A36;   /* overlay */
  --line: rgba(255,255,255,.10);
  --line-2: rgba(255,255,255,.16);
  --hi: #F2F5F9;
  --mid: #AEB6C2;
  --low: #8B93A1;
  --effort: #FF6B1A;   /* primary / you */
  --effort-ink: #220E02;
  --data: #34D1E0;     /* metrics */
  --good: #3FD17A;
  --warn: #F5B642;
  --bad: #F2545B;
  --gold: #F5B642; --silver: #C2C6D2; --bronze: #CD7F46;
  --r-md: 10px; --r-lg: 14px;
}

html, body {
  background: var(--bg);
  color: var(--hi);
  font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
.num { font-variant-numeric: tabular-nums; }
h1, h2, h3, h4, h5 { color: var(--hi); font-weight: 500; letter-spacing: -.01em; }
/* Unified paragraph typography — every <p> shares one compact, consistent size/leading
   (p.small beats Bootstrap's .small so helper paragraphs don't render a size larger). */
p, p.small { font-size: 12px; line-height: 1.5; }
a { color: var(--data); text-decoration: none; }
a:hover { color: #6fe3ee; }
.text-secondary { color: var(--mid) !important; }
.text-muted { color: var(--low) !important; }
.text-success { color: var(--good) !important; }
.text-danger { color: var(--bad) !important; }
.text-warning { color: var(--warn) !important; }
.small, .form-text { color: var(--mid); }

/* Series "race cards" on the standings landing */
.rs-series-card { display: flex; flex-direction: column; gap: 10px; height: 100%; padding: 16px; background: var(--s1); border: 1px solid var(--line); border-radius: var(--r-lg); color: var(--hi); text-decoration: none; transition: border-color .15s, transform .15s, box-shadow .15s; }
.rs-series-card:hover { border-color: var(--data); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.rs-series-top { display: flex; justify-content: space-between; align-items: center; color: var(--data); }
.rs-series-year { font-size: 30px; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.rs-series-top .bi { font-size: 22px; opacity: .45; }
.rs-series-logo { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; display: block; }
.rs-series-card.past .rs-series-logo { opacity: .72; }
/* Past seasons read as secondary so the current (latest) season's cards stand out. */
.rs-series-card.past { opacity: .82; }
.rs-series-card.past .rs-series-top { color: var(--mid); }
.rs-series-card.past .rs-series-year { color: var(--mid); font-weight: 700; }
.rs-series-card.past:hover { opacity: 1; }
.rs-series-name { font-size: 17px; font-weight: 600; line-height: 1.25; color: var(--hi); }
.rs-series-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.rs-series-chips span { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 12px; background: rgba(52,209,224,.12); color: var(--data); }
.rs-series-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--low); border-top: 1px solid var(--line); padding-top: 10px; }
.rs-series-body { display: flex; flex-direction: column; gap: 10px; flex: 1; color: var(--hi); text-decoration: none; }
.rs-series-go { color: var(--low); white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.rs-series-go:hover { color: var(--data); }
.rs-series-linked { display: inline-flex; align-items: center; gap: 4px; color: var(--good); font-weight: 700; }
.rs-series-link { display: inline-flex; align-items: center; gap: 4px; color: var(--data); font-weight: 600; }
.rs-series-link:hover { color: #6fe3ee; }
.rs-series-foot-left { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.rs-series-dep { display: inline-flex; align-items: center; gap: 4px; color: var(--low); font-weight: 600; }

/* Ride-map overlay controls (gradient / speed / elevation + direction) */
.rf-map-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 8px; font-size: 13px; color: var(--low); }
.rf-map-controls label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.rf-map-controls input[type=checkbox] { accent-color: var(--data); margin: 0; }
.rf-legend { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--low); }
.rf-legend-bar { width: 110px; height: 8px; border-radius: 4px; border: 1px solid var(--line); }
.rf-arrow { background: transparent !important; border: 0 !important; }

/* Collapsible whose summary is styled as a button (hide the default disclosure marker) */
.rf-collapse > summary { list-style: none; cursor: pointer; }
.rf-collapse > summary::-webkit-details-marker { display: none; }
.rf-collapse > summary::marker { content: ""; }
.rf-chev { transition: transform .15s; }
.rf-collapse[open] > summary .rf-chev { transform: rotate(90deg); }
/* "Series participated" toggle: show a divider above it only once the list is expanded. */
.rf-collapse[open] > .rf-series-sum { border-top: 1px solid var(--line); padding-top: 10px; }

/* Row of action collapses (Add New Rider / Link an existing rider) sitting side by side;
   an open one spans the full width so its form isn't cramped, pushing the other to the next line. */
.rf-actionrow > details[open] { flex-basis: 100%; }

/* Surfaces */
.card, .rs-card { background: var(--s1); border: 1px solid var(--line); border-radius: var(--r-lg); color: var(--hi); }
.list-group-item { background: var(--s1); border-color: var(--line); color: var(--hi); }
.list-group-item-action:hover { background: var(--s2); }

/* Tables */
.table { color: var(--hi); --bs-table-bg: transparent; --bs-table-color: var(--hi); }
.table > :not(caption) > * > * { background: transparent; color: var(--hi); border-bottom-color: var(--line); }
.table thead th { color: var(--low); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; border-bottom-color: var(--line-2); }
/* Compact variant — fits the Race Results 5 columns comfortably on narrow phones. */
.table.rs-tight { font-size: 14px; }
.table.rs-tight > :not(caption) > * > * { padding: .35rem .4rem; }
.table.rs-tight thead th { font-size: 12px; }

/* Forms */
.form-control, .form-select {
  background: var(--s1); color: var(--hi);
  border: 1px solid var(--line-2); border-radius: var(--r-md);
}
.form-control::placeholder { color: var(--low); }
.form-control:focus, .form-select:focus {
  background: var(--s1); color: var(--hi); border-color: var(--effort);
  box-shadow: 0 0 0 3px rgba(255,107,26,.25);
}
.form-select option { background: var(--s2); color: var(--hi); }
.form-label, .form-check-label { color: var(--mid); }
.form-check-input { background: var(--s2); border-color: var(--line-2); }
.form-check-input:checked { background: var(--effort); border-color: var(--effort); }

/* Buttons */
.btn-primary { background: var(--effort); border-color: var(--effort); color: var(--effort-ink); font-weight: 500; }
.btn-primary:hover { background: #ff7e36; border-color: #ff7e36; color: var(--effort-ink); }
.btn-outline-primary { color: var(--effort); border-color: var(--effort); }
.btn-outline-primary:hover { background: var(--effort); color: var(--effort-ink); }
.btn-link { color: var(--data); }

/* Badges */
.badge.text-bg-primary { background: var(--effort) !important; color: var(--effort-ink) !important; }
.badge.text-bg-light { background: var(--s2) !important; color: var(--mid) !important; }

/* ---- Cockpit components ---- */
.rs-label { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--low); }

.rs-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.rs-chip { font-size: 12px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--mid); background: transparent; }
.rs-chip.on { background: var(--effort); border-color: var(--effort); color: var(--effort-ink); }

.rs-row { display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: var(--r-md); }
.rs-row + .rs-row { border-top: 1px solid var(--line); }
.rs-rank { width: 22px; text-align: center; font-weight: 500; color: var(--low); }
.rs-row.r1 .rs-rank { color: var(--gold); } .rs-row.r2 .rs-rank { color: var(--silver); } .rs-row.r3 .rs-rank { color: var(--bronze); }
.rs-av { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--effort-ink); background: var(--s3); flex: 0 0 32px; }
.rs-row.r1 .rs-av { background: var(--gold); } .rs-row.r2 .rs-av { background: var(--silver); } .rs-row.r3 .rs-av { background: var(--bronze); }
.rs-pts { text-align: right; font-size: 16px; font-weight: 500; color: var(--data); }
.rs-you { border: 1px solid rgba(255,107,26,.55); background: rgba(255,107,26,.10); }
.rs-you .rs-rank, .rs-you .rs-av { color: var(--effort); }
.rs-you .rs-av { background: var(--effort); color: var(--effort-ink); }
/* "Mine" — a row that is the signed-in user or one of their riders (standings). */
.rs-row.rs-mine { border: 1px solid rgba(63,209,122,.55); background: rgba(63,209,122,.10); }
.rs-row.rs-mine .rs-rank { color: var(--good); }
.rs-row.rs-mine .rs-av { background: var(--good); color: #06210f; }
.rs-mine-tag { display: inline-block; margin-left: 6px; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--good); background: rgba(63,209,122,.16); border-radius: 8px; padding: 1px 7px; vertical-align: middle; }
.rs-tag { font-size: 9px; color: var(--effort); border: 1px solid var(--effort); border-radius: 4px; padding: 0 4px; }

.rs-hero { background: var(--s1); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; display: flex; align-items: flex-end; justify-content: space-between; }
.rs-hero-num { font-size: 38px; font-weight: 500; line-height: 1; }
.rs-tile { background: var(--s1); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; }
.rs-tile-num { font-size: 17px; font-weight: 500; }

/* App shell + bottom tab bar */
.rs-shell { min-height: 100vh; padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
.rs-topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(10,13,18,.92); backdrop-filter: blur(8px); z-index: 10; }
.rs-brand { font-weight: 500; letter-spacing: .02em; }
.rs-brand .dot { color: var(--effort); }
.rs-main { max-width: 880px; margin: 0 auto; padding: 16px; }
/* Persistent "your profile" bar under the top bar, on every screen. */
.rs-profilebar { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 880px; margin: 0 auto; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.rs-profilebar-id { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--hi); min-width: 0; }
.rs-profilebar-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.rs-profilebar-name { font-size: 15px; font-weight: 600; color: var(--hi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rs-profilebar-sub { font-size: 12px; color: var(--mid); }
.rs-profilebar-gear { flex: 0 0 auto; color: var(--data); font-size: 22px; line-height: 1; padding: 6px; text-decoration: none; }
.rs-profilebar-gear:hover { color: var(--hi); }
/* "Verify your email" nudge bar (unverified accounts) */
.rs-verifybar { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 16px; background: rgba(245,182,66,.12); border-bottom: 1px solid rgba(245,182,66,.30); color: var(--warn); font-size: 13px; text-decoration: none; }
.rs-verifybar:hover { background: rgba(245,182,66,.18); color: var(--warn); }
/* Full-screen "generating avatar" loading overlay */
.rf-genoverlay { position: fixed; inset: 0; background: rgba(10,13,18,.82); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 100; }
.rf-genbox { display: flex; flex-direction: column; align-items: center; gap: 16px; color: var(--hi); text-align: center; max-width: 320px; padding: 24px; }
.rf-gentext { font-size: 15px; color: var(--mid); }
.rf-spinner { width: 44px; height: 44px; border-radius: 50%; border: 3px solid rgba(255,255,255,.15); border-top-color: var(--effort); animation: rf-spin .8s linear infinite; }
@keyframes rf-spin { to { transform: rotate(360deg); } }
/* Uploaded profile photo (falls back to the identicon when none is set). */
.rs-avatar-img { border-radius: 50%; object-fit: cover; flex: 0 0 auto; display: block; }
.rs-avatar-edit { position: relative; display: inline-block; line-height: 0; }
.rs-avatar-click { position: relative; display: inline-block; cursor: pointer; line-height: 0; }
.rs-avatar-cam { position: absolute; right: -2px; bottom: -2px; width: 20px; height: 20px; border-radius: 50%; background: var(--data); color: #06121a; display: flex; align-items: center; justify-content: center; font-size: 11px; border: 2px solid #0b0e13; }
/* Race Face card social-share buttons */
.rf-share { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; border: none; color: #fff; font-size: 20px; cursor: pointer; transition: transform .12s, filter .12s; }
.rf-share:hover { transform: translateY(-1px); filter: brightness(1.08); }
.rf-wa { background: #25D366; }
.rf-fb { background: #1877F2; }
.rf-ig { background: linear-gradient(45deg, #feda75, #fa7e1e, #d62976, #962fbf, #4f5bd5); }
.rf-dl { background: var(--effort); }
.rf-vid { background: linear-gradient(45deg, #f43f5e, #a855f7); }
.rf-spin { display: inline-block; animation: rf-rot .8s linear infinite; }
@keyframes rf-rot { to { transform: rotate(360deg); } }

/* ---- Auth (sign in / create account) — split card: brand panel + form ---- */
.auth-split { display: flex; max-width: 860px; margin: 6vh auto; border: 1px solid var(--line); border-radius: 22px; overflow: hidden; box-shadow: 0 24px 70px rgba(0,0,0,.45); }
.auth-brandpanel { flex: 1 1 0; min-width: 0; padding: 44px 38px; position: relative; display: flex; flex-direction: column; justify-content: center; background: linear-gradient(155deg, var(--s2), var(--bg)); }
.auth-brandpanel::after { content: ""; position: absolute; inset: 0; background: radial-gradient(110% 75% at 85% -5%, rgba(52,209,224,.16), transparent 60%); pointer-events: none; }
.auth-brand { font-size: 26px; font-weight: 600; letter-spacing: .02em; color: var(--hi); margin-bottom: 22px; position: relative; }
.auth-brand .dot { color: var(--effort); }
.auth-tagline { font-size: 36px; font-weight: 800; line-height: 1.08; color: var(--hi); margin: 0 0 14px; letter-spacing: -.02em; position: relative; }
.auth-tagline em { color: var(--data); font-style: normal; }
.auth-blurb { color: var(--mid); font-size: 15px; line-height: 1.5; position: relative; margin: 0 0 20px; }
.auth-feats { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; position: relative; }
.auth-feats li { color: var(--hi); font-size: 14px; display: flex; align-items: center; gap: 10px; }
.auth-feats i { color: var(--data); font-size: 16px; }
.auth-formpanel { flex: 1 1 0; min-width: 0; padding: 44px 38px; background: var(--s1); }
.auth-title { font-size: 26px; font-weight: 700; margin: 0 0 4px; color: var(--hi); }
.auth-sub { color: var(--mid); font-size: 14px; margin: 0 0 22px; }
.auth-form label { display: block; margin: 0 0 6px; font-size: 13px; font-weight: 500; color: var(--mid); }
.auth-form .auth-field { margin-bottom: 14px; }
.auth-error { background: rgba(242,84,91,.12); border: 1px solid rgba(242,84,91,.32); color: #f7a6aa; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 16px; }
.auth-alt { margin-top: 20px; font-size: 14px; color: var(--mid); }
.auth-foot { text-align: center; color: var(--low); font-size: 12px; margin-top: 10px; }
@media (max-width: 680px) {
  .auth-split { flex-direction: column; margin: 0 auto; border: none; border-radius: 0; box-shadow: none; }
  .auth-brandpanel { padding: 26px 24px 20px; }
  .auth-tagline { font-size: 28px; }
  .auth-blurb, .auth-feats { display: none; }
  .auth-formpanel { padding: 26px 24px; }
}
.rs-tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: #0C0F15; border-top: 1px solid var(--line); padding: 4px 0 calc(6px + env(safe-area-inset-bottom)); z-index: 20; }
.rs-tab { flex: 1; min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--low); font-size: 11px; font-weight: 500; text-decoration: none; }
.rs-tab .ico { font-size: 22px; }
.rs-tab.active { color: var(--effort); }
