/* Challenge BCC — couleurs du club Borneurs Toulousains (dégradé violet, point rose). */
:root {
  --brand-dark: #591077;
  --brand: #7b2a9a;
  --brand-light: #9e46be;
  --pink: #ff65d1;
  --header-grad: linear-gradient(120deg, #4a0d63 0%, #6b1f8a 50%, #9e46be 100%);

  --bg: #f6f3fa;
  --surface: #ffffff;
  --surface-2: #faf7fd;
  --text: #1f1430;
  --muted: #6f6680;
  --border: #e6dff0;
  --link: #7b2a9a;
  --brand-soft: #f1e7f8;
  --me: #fff0fa;
  --me-border: #ffb8e9;
  --ok: #1e7a3c;
  --warn: #9a6200;
  --danger: #b3261e;
  --strava: #fc5200;
  --gold: #d6a21e;
  --silver: #9aa5b1;
  --bronze: #c27c48;
  --shadow: 0 1px 2px rgba(40, 10, 60, 0.06), 0 4px 16px rgba(40, 10, 60, 0.06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #120d18;
    --surface: #1c1524;
    --surface-2: #231a2d;
    --text: #f1eaf7;
    --muted: #a99bb8;
    --border: #352a42;
    --link: #d39af0;
    --brand-soft: #2b1d38;
    --me: #35172e;
    --me-border: #7a2f67;
    --ok: #6fcf8e;
    --warn: #e6b452;
    --danger: #f08a80;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

/* --- Base ------------------------------------------------------------------------------------ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
main { width: 100%; max-width: 960px; margin: 0 auto; padding: 24px 16px 8px; flex: 1; display: grid; gap: 20px; align-content: start; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1 { font-size: 1.9rem; line-height: 1.2; font-weight: 800; letter-spacing: -0.01em; margin: 0.2rem 0; }
h2 { font-size: 1.2rem; font-weight: 750; margin: 0 0 12px; }
p { margin: 0.4rem 0; }
.muted { color: var(--muted); }
:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; border-radius: 6px; }
.inline { display: inline; margin: 0; }

/* --- En-tête --------------------------------------------------------------------------------- */
.top { background: var(--header-grad); color: #fff; box-shadow: 0 2px 12px rgba(60, 10, 80, 0.25); position: sticky; top: 0; z-index: 10; }
.top-inner { max-width: 960px; margin: 0 auto; padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand-logo { width: 44px; height: 44px; border-radius: 12px; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35); }
.brand-text { display: grid; line-height: 1.15; }
.brand-text strong { font-size: 1.1rem; letter-spacing: 0.01em; }
.brand-text small { font-size: 0.78rem; opacity: 0.8; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.nav a, .nav-logout {
  color: #fff; text-decoration: none; font-size: 0.95rem; padding: 6px 12px; border-radius: 999px;
  border: 1px solid transparent; background: none; cursor: pointer; font-family: inherit;
}
.nav a:hover { background: rgba(255, 255, 255, 0.12); }
.nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.2); font-weight: 650; }
.nav-logout { border-color: rgba(255, 255, 255, 0.45); }
.nav-logout:hover { background: rgba(255, 255, 255, 0.12); }
@media (max-width: 640px) {
  .top { position: static; }
  .top-inner { padding: 8px 12px; gap: 8px; }
  .brand-logo { width: 36px; height: 36px; border-radius: 10px; }
  .brand-text strong { font-size: 1rem; }
  .nav { width: 100%; gap: 2px; justify-content: space-between; }
  .nav a, .nav-logout { font-size: 0.85rem; padding: 5px 9px; }
}

/* --- Cartes, messages, badges ------------------------------------------------------------------ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.card > h2 { margin: 0; }
.flash { margin: 0; padding: 12px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--brand-light); box-shadow: var(--shadow); }
.flash.error { border-left-color: var(--danger); color: var(--danger); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; border: 1px solid currentColor; }
.badge.auto, .badge.validated, .badge.manual { color: var(--ok); }
.badge.to_review { color: var(--warn); }
.badge.rejected { color: var(--danger); }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--text); font-size: 0.82rem; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip-upcoming { background: transparent; border: 1px solid var(--pink); color: var(--text); }
.chip-empty { background: transparent; border: 1px dashed var(--border); color: var(--muted); font-weight: 500; }
.strava-link { color: var(--strava); font-weight: 700; }
.powered { font-weight: 700; color: var(--strava); }
.powered-logo { vertical-align: middle; display: block; }
.head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; }
.empty { text-align: center; justify-items: center; padding: 40px 20px; }
.empty-logo { border-radius: 18px; }

/* --- Bandeau du défi ----------------------------------------------------------------------------- */
.hero-band {
  background: var(--header-grad); color: #fff; border-radius: 20px; padding: 24px;
  display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: flex-end; justify-content: space-between;
  box-shadow: 0 8px 28px rgba(89, 16, 119, 0.28); position: relative; overflow: hidden;
}
.hero-band::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 101, 209, 0.45), rgba(255, 101, 209, 0) 70%); pointer-events: none;
}
.hero-band-text { position: relative; z-index: 1; }
.hero-band h1 { color: #fff; }
.eyebrow { margin: 0; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--pink); }
.hero-meta { margin: 0; opacity: 0.9; }
.hero-band-side { display: grid; gap: 10px; min-width: 220px; position: relative; z-index: 1; }
.challenge-picker label { display: grid; gap: 4px; font-size: 0.8rem; opacity: 0.9; }
.challenge-picker select { background: rgba(255, 255, 255, 0.15); color: #fff; border-color: rgba(255, 255, 255, 0.4); }
.challenge-picker option { color: #1f1430; }
.period { display: grid; gap: 6px; font-size: 0.85rem; }
.period progress { width: 100%; height: 8px; border: 0; border-radius: 999px; overflow: hidden; background: rgba(255, 255, 255, 0.25); -webkit-appearance: none; appearance: none; }
.period progress::-webkit-progress-bar { background: rgba(255, 255, 255, 0.25); border-radius: 999px; }
.period progress::-webkit-progress-value { background: var(--pink); border-radius: 999px; }
.period progress::-moz-progress-bar { background: var(--pink); border-radius: 999px; }

/* --- Chiffres clés --------------------------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: grid; gap: 2px; }
.stat-value { font-size: 1.7rem; font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-value small { font-size: 1rem; font-weight: 600; color: var(--muted); }
.stat-label { font-size: 0.85rem; color: var(--muted); }
@media (prefers-color-scheme: dark) { .stat-value { color: var(--link); } }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, 1fr); } }

/* --- Tableaux ---------------------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.ranking { width: 100%; border-collapse: separate; border-spacing: 0; }
.ranking th, .ranking td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.ranking thead th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 650; background: var(--surface-2); }
.ranking thead th:first-child { border-top-left-radius: 10px; }
.ranking thead th:last-child { border-top-right-radius: 10px; }
.ranking tbody tr:last-child td { border-bottom: 0; }
.ranking tbody tr:hover td { background: var(--surface-2); }
.ranking .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ranking .strong { font-weight: 750; }
.ranking tr.me td { background: var(--me); }
.ranking tr.me td:first-child { box-shadow: inset 4px 0 0 var(--pink); }
.ranking tr.excluded td { opacity: 0.55; }
.rank-col { width: 56px; }
.rank {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  font-weight: 800; font-size: 0.9rem; background: var(--brand-soft); color: var(--text);
}
.rank-1 { background: linear-gradient(135deg, #f7d774, var(--gold)); color: #4a3200; }
.rank-2 { background: linear-gradient(135deg, #e3e8ee, var(--silver)); color: #2a3038; }
.rank-3 { background: linear-gradient(135deg, #f0bf95, var(--bronze)); color: #3d2210; }
.leaderboard .podium .who { font-weight: 700; }
.you { display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 999px; background: var(--pink); color: #3d0a2f; font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; vertical-align: 2px; }
.actions { white-space: nowrap; }
.actions form + form { margin-left: 4px; }
.nowrap { white-space: nowrap; }
.ranking button { padding: 5px 10px; font-size: 0.85rem; border-radius: 8px; }
.end-form { display: inline-flex; gap: 4px; align-items: center; }
.end-form input[type="time"] { width: auto; padding: 4px 6px; }
.end-form button { padding: 4px 8px; }
@media (max-width: 600px) {
  .card { padding: 14px; }
  .ranking th, .ranking td { padding: 8px 5px; font-size: 0.88rem; }
  .ranking thead th { font-size: 0.68rem; letter-spacing: 0.03em; }
  .rank-col { width: 38px; }
  .rank { width: 26px; height: 26px; font-size: 0.8rem; }
  .you { display: none; }
  .hero-band { padding: 20px; }
  h1 { font-size: 1.6rem; }
}

/* --- Sorties --------------------------------------------------------------------------------------- */
.outing-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.outing-card {
  display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center;
  padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none; box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s;
}
.outing-card:hover { border-color: var(--brand-light); transform: translateY(-1px); }
.outing-card.upcoming { background: var(--surface-2); }
.date-chip { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 12px; background: var(--brand-soft); line-height: 1; }
.date-day { font-size: 1.35rem; font-weight: 800; color: var(--brand); }
.date-month { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
@media (prefers-color-scheme: dark) { .date-day { color: var(--link); } }
.outing-body { display: grid; gap: 2px; min-width: 0; }
.outing-title { font-weight: 700; }
.outing-time { font-size: 0.85rem; color: var(--muted); }
.outing-stats { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
@media (max-width: 640px) {
  .outing-card { grid-template-columns: auto 1fr; }
  .outing-stats { grid-column: 1 / -1; justify-content: flex-start; }
}
ul.outings { list-style: none; padding: 0; margin: 0; }
ul.outings li { padding: 8px 0; border-bottom: 1px solid var(--border); }

/* --- Formulaires ------------------------------------------------------------------------------------- */
.card label { display: grid; gap: 4px; font-size: 0.9rem; }
.card label.check { display: inline-flex; gap: 8px; margin-right: 16px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; }
input, select {
  font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); width: 100%;
}
input:focus, select:focus { border-color: var(--brand-light); outline: none; box-shadow: 0 0 0 3px rgba(158, 70, 190, 0.25); }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--brand); }
button {
  font: inherit; font-weight: 650; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--brand);
  background: var(--brand); color: #fff; cursor: pointer; transition: background 0.15s;
}
button:hover { background: var(--brand-dark); }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.danger:hover { background: var(--danger); color: #fff; }
button.link { background: none; border: 0; padding: 0; color: var(--link); text-decoration: underline; font-weight: 500; }

/* --- Connexion ------------------------------------------------------------------------------------------ */
.login { max-width: 680px; margin: 0 auto; display: grid; gap: 16px; }
.login-intro { text-align: center; display: grid; justify-items: center; gap: 6px; }
.login-logo { width: 96px; height: 96px; border-radius: 24px; box-shadow: 0 10px 30px rgba(89, 16, 119, 0.35); margin-bottom: 8px; }
.lead { font-size: 1.05rem; color: var(--muted); max-width: 560px; }
.consent { margin: 0; }
.consent .check { display: flex; gap: 10px; align-items: flex-start; font-size: 0.92rem; }
.consent .check input { margin-top: 3px; flex: none; }
.connect { display: inline-block; margin: 0; padding: 0; border: 0; background: none; cursor: pointer; justify-self: center; }
.connect:hover { background: none; filter: brightness(1.05); }
.connect-fallback { display: inline-block; padding: 12px 20px; background: var(--strava); color: #fff; font-weight: 700; border-radius: 6px; }
.facts { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.facts li { position: relative; padding-left: 28px; }
.facts li::before {
  content: "✓"; position: absolute; left: 0; top: 1px; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; font-size: 0.75rem; font-weight: 800; background: var(--brand-soft); color: var(--brand);
}
@media (prefers-color-scheme: dark) { .facts li::before { color: var(--link); } }
.hero { max-width: 680px; }

/* --- Pied de page ------------------------------------------------------------------------------------------- */
.footer { margin-top: 32px; border-top: 1px solid var(--border); }
.footer-inner {
  max-width: 960px; margin: 0 auto; padding: 18px 16px 28px; display: flex; flex-wrap: wrap; gap: 8px 18px;
  align-items: center; font-size: 0.85rem; color: var(--muted);
}
.footer-links { display: inline-flex; gap: 14px; }

/* --- Cartes « Ta saison » et « Prochaine sortie » ------------------------------------------------------ */
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .duo { grid-template-columns: 1fr; } }
.card-kicker { margin: 0; font-size: 0.75rem; font-weight: 750; text-transform: uppercase; letter-spacing: 0.08em; color: var(--brand); }
@media (prefers-color-scheme: dark) { .card-kicker { color: var(--link); } }
.season-head { display: flex; align-items: center; gap: 12px; }
.season-rank { width: 44px; height: 44px; font-size: 1.15rem; }
.season-pos { margin: 0; font-size: 1.05rem; }
.season-pos strong { font-size: 1.5rem; font-weight: 800; }
.season-figures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.season-figures > div { display: grid; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.fig { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.fig small { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.fig-label { font-size: 0.78rem; color: var(--muted); }
.season-gap { margin: 0; font-size: 0.92rem; }
.countdown {
  justify-self: start; padding: 3px 12px; border-radius: 999px; font-size: 0.82rem; font-weight: 800;
  background: var(--pink); color: #3d0a2f;
}
.next-title { margin: 0; font-size: 1.25rem; font-weight: 800; }
.next-title a { color: var(--text); text-decoration: none; }
.next-title a:hover { color: var(--link); }
.next-links { margin: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.9rem; }

/* --- Onglets de classement ------------------------------------------------------------------------------- */
#classement { scroll-margin-top: 88px; }
@media (max-width: 640px) { #classement { scroll-margin-top: 12px; } }
.card-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; }
.card-head h2 { margin: 0; }
.tabs { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.tabs a { padding: 5px 12px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; color: var(--muted); text-decoration: none; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="true"] { background: var(--brand); color: #fff; }
.small { font-size: 0.85rem; margin: 0; }
.sorted-km .col-km, .sorted-dplus .col-dplus, .sorted-sorties .col-sorties { font-weight: 800; }
.sorted-km thead .col-km, .sorted-dplus thead .col-dplus, .sorted-sorties thead .col-sorties { color: var(--brand); }
@media (prefers-color-scheme: dark) {
  .sorted-km thead .col-km, .sorted-dplus thead .col-dplus, .sorted-sorties thead .col-sorties { color: var(--link); }
}

.danger-zone { border-color: var(--danger); }
.danger-zone p { margin: 0; }

/* --- Clubs ------------------------------------------------------------------------------------------------ */
.club-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.club-filter a {
  padding: 3px 11px; border-radius: 999px; border: 1px solid var(--border);
  font-size: 0.82rem; font-weight: 600; color: var(--muted); text-decoration: none;
}
.club-filter a:hover { color: var(--text); border-color: var(--brand); }
.club-filter a[aria-current="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--text); }
.col-club { font-size: 0.85rem; white-space: nowrap; }
.next-badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.outing-club { font-size: 0.75rem; font-weight: 750; text-transform: uppercase; letter-spacing: 0.06em; color: var(--brand); }
@media (prefers-color-scheme: dark) { .outing-club { color: var(--link); } }
.season-club { margin: 0; font-size: 0.88rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.inline-form label { flex: 1 1 220px; }
@media (max-width: 600px) {
  .col-club { display: none; }
  .tabs { max-width: 100%; overflow-x: auto; }
}

/* --- Application installée (iPhone) : la barre d'état recouvre l'en-tête ------------------------------- */
.top { padding-top: env(safe-area-inset-top); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
