/* VVC — mobile d'abord. On consulte ce site sur un telephone, dehors, juste
   apres la sortie : contrastes francs, cibles tactiles larges, pas de fioriture
   qui ralentit la lecture au soleil. */

:root {
  --bg: #f4f3f0;
  --card: #ffffff;
  --ink: #17181c;
  --muted: #6b6d75;
  --line: #e3e2dd;

  /* Accent brique : proche de l'univers velo sans copier l'orange Strava. */
  --accent: #b23a1c;
  --accent-soft: #f6e5df;
  --ink-inverse: #ffffff;

  --strava: #fc4c02;
  --ok: #226b3c;
  --err: #a32218;
  --gold: #c9962b;

  /* Le panneau d'affichage garde son propre couple de couleurs : il doit rester
     sombre dans les deux themes, sinon --ink s'inverse et le texte disparait. */
  --board-bg: #17181c;
  --board-ink: #f5f4f1;
  --board-muted: rgba(245, 244, 241, 0.6);
  --board-line: rgba(255, 255, 255, 0.12);

  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 1px 2px rgba(20, 20, 25, 0.05), 0 4px 14px rgba(20, 20, 25, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131417;
    --card: #1c1e23;
    --ink: #eceded;
    --muted: #969aa4;
    --line: #2c2f36;

    --accent: #e0713f;
    --accent-soft: #33221b;
    --ink-inverse: #16171a;

    --ok: #64c98a;
    --err: #e4675c;
    --gold: #e0b556;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);

    /* Un cran plus clair que les cartes, pour rester lisible comme un panneau. */
    --board-bg: #23262d;
    --board-ink: #f0f1f2;
    --board-muted: rgba(240, 241, 242, 0.6);
    --board-line: rgba(255, 255, 255, 0.1);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  /* Pas de flash gris au toucher : les etats actifs sont geres explicitement. */
  -webkit-tap-highlight-color: transparent;
  /* Evite le rebond horizontal quand un tableau deborde. */
  overflow-x: hidden;
}

main {
  max-width: 760px;
  margin: 0 auto;
  /* Marges de securite : encoche a gauche/droite en paysage, barre gestuelle
     en bas. Sans ca, le contenu passe sous le materiel sur iPhone. */
  padding: 1rem max(1rem, env(safe-area-inset-left)) calc(4rem + env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-right));
}

/* Les liens et boutons restent confortables au pouce. */
a, button, summary, input, select, textarea {
  touch-action: manipulation;
}

a { color: var(--accent); }

/* Barre du haut */
.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem max(1rem, env(safe-area-inset-left)) 0.6rem
    max(1rem, env(safe-area-inset-right));
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Degrade a droite : indique que les onglets continuent hors ecran. */
.topbar::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 2rem;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--card));
  opacity: 0.9;
}

.brand {
  flex: none;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--ink-inverse);
  background: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.3rem 0.55rem;
  border-radius: 7px;
}

.topbar nav {
  display: flex;
  gap: 0.2rem;
  overflow-x: auto;
  scrollbar-width: none;
  /* Les onglets debordent sur telephone : on laisse filer sans barre visible. */
  margin: -0.6rem -1rem -0.6rem 0;
  padding: 0.6rem 1rem 0.6rem 0;
}

.topbar nav::-webkit-scrollbar { display: none; }

.topbar nav a {
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
}

.topbar nav a.on {
  background: var(--accent);
  color: var(--ink-inverse);
}

/* Tableau d'affichage : l'entete de la page d'accueil */
.board {
  position: relative;
  overflow: hidden;
  background: var(--board-bg);
  color: var(--board-ink);
  border: 1px solid var(--board-line);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.25rem 1.25rem;
  margin-bottom: 1rem;
  /* Trame legere : evoque le papier d'un vrai panneau d'affichage. */
  background-image:
    repeating-linear-gradient(
      -45deg,
      rgba(255, 255, 255, 0.03) 0 2px,
      transparent 2px 9px
    );
}

.board-mark {
  display: inline-block;
  font-weight: 800;
  letter-spacing: 0.18em;
  font-size: 0.75rem;
  color: var(--ink-inverse);
  background: var(--accent);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
}

.board h1 {
  margin: 0.65rem 0 0.15rem;
  font-size: 1.7rem;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.board-sub {
  margin: 0;
  color: var(--board-muted);
  font-size: 0.9rem;
}

.board-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin: 1.25rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--board-line);
}

.board-stats dt {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--board-muted);
}

.board-stats dd {
  margin: 0.1rem 0 0;
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 380px) {
  .board-stats { grid-template-columns: repeat(2, 1fr); row-gap: 0.9rem; }
}

/* Variante courte, pour les pages autres que l'accueil */
.board.slim { padding: 1.15rem 1.25rem; }
.board.slim h1 { font-size: 1.4rem; margin-bottom: 0.1rem; }

/* Bande de route sous le panneau : deux traits et un pointillé d'axe */
.board::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background:
    repeating-linear-gradient(
      90deg,
      var(--accent) 0 18px,
      transparent 18px 34px
    );
  opacity: 0.85;
}

/* Cartes */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.75rem;
  font-weight: 700;
}

.card.highlight {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

.card-more {
  margin: 0.85rem 0 0;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
}

.card-more a { text-decoration: none; font-weight: 600; }

/* Prochaine sortie */
.next-ride {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-decoration: none;
  color: inherit;
}

.next-ride-title {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.25;
}

.next-ride-when {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 0.15rem;
}

.avatar-sm.placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.75rem;
  flex: none;
}

.card h1 { font-size: 1.4rem; margin: 0 0 0.25rem; letter-spacing: -0.015em; }
.card h2 { font-size: 1.05rem; margin: 0 0 0.75rem; letter-spacing: -0.01em; }
.card h2.card-title { font-size: 0.75rem; }

.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--err); font-size: 0.9rem; }

.profile { display: flex; align-items: center; gap: 1rem; }
.avatar { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; }

/* Statistiques */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0 0;
}

.stats > div {
  background: var(--bg);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
}

.stats dt { color: var(--muted); font-size: 0.78rem; }
.stats dd { margin: 0.15rem 0 0; font-size: 1.3rem; font-weight: 600; }

/* Budget de requetes */
.budget { margin-top: 1rem; }

.bar {
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.4s ease;
}

/* Formulaires et boutons */
label { display: block; font-size: 0.9rem; margin-bottom: 0.3rem; }

label.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

input[type="text"], input:not([type]) {
  width: 100%;
  padding: 0.6rem 0.7rem;
  font: inherit;
  letter-spacing: 0.08em;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 0.75rem;
}

button, .btn-primary, .btn-strava {
  display: inline-block;
  /* Cible tactile confortable : on clique dessus avec des gants de velo. */
  min-height: 44px;
  padding: 0.6rem 1.15rem;
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: var(--ink-inverse);
  text-decoration: none;
  cursor: pointer;
}

.btn-strava { background: var(--strava); color: #fff; }

button:disabled { opacity: 0.5; cursor: default; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Progression de la sync */
.sync-status {
  margin-top: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  background: var(--bg);
  font-size: 0.9rem;
}

.sync-status.done { color: var(--ok); }
.sync-status.error { color: var(--err); }
.sync-status.busy { color: var(--accent); }

.queue-note {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.queue-note .spinner {
  flex: none;
  border-color: var(--accent);
  border-right-color: transparent;
  align-self: center;
}

.note {
  border-left: 3px solid var(--line);
  padding-left: 0.7rem;
  margin-top: 0;
}

/* Liste des sorties */
.rides { list-style: none; margin: 0; padding: 0; }

.rides li {
  display: flex;
  flex-direction: column;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}

.rides li:last-child { border-bottom: 0; }
.ride-name { font-weight: 600; }

/* --- Lot 2 : segments, podiums, fil d'actu ------------------------------- */

.segment-list { list-style: none; margin: 0; padding: 0; }

.segment-list li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}

.segment-list a {
  display: block;
  padding: 0.75rem 0.9rem;
  color: inherit;
  text-decoration: none;
}

.segment-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.segment-name { font-weight: 600; }

.badge {
  flex: none;
  background: var(--bg);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  font-size: 0.8rem;
}

.segment-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.segment-list.compact li { margin-bottom: 0.35rem; }

/* Podium */
.podium { list-style: none; margin: 0; padding: 0; counter-reset: rank; }

.podium li {
  display: grid;
  grid-template-columns: 1.6rem auto 1fr auto auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}

.podium li:last-child { border-bottom: 0; }

.podium li.me {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 6px;
  padding-left: 0.4rem;
  padding-right: 0.4rem;
}

.podium .rank,
.points .rank,
.volume .rank {
  font-size: 1rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.podium .who { font-weight: 600; }
.podium .time { font-variant-numeric: tabular-nums; font-weight: 600; }
.podium .gap { font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.podium .when { grid-column: 2 / -1; font-size: 0.8rem; }

.avatar-sm { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }

/* Fil d'actu */
.feed { list-style: none; margin: 0; padding: 0; }

.feed li {
  display: flex;
  gap: 0.6rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}

.feed li:last-child { border-bottom: 0; }

.gain {
  color: var(--ok);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

@media (prefers-color-scheme: dark) {
  .gain { color: #6fd08c; }
}

/* Historique des records et liste des passages */
.records, .efforts { list-style: none; margin: 0; padding: 0; }

.records li, .efforts li {
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}

.records li:last-child, .efforts li:last-child { border-bottom: 0; }

.efforts li {
  display: grid;
  grid-template-columns: 4.5rem 1fr auto;
  gap: 0.5rem;
  align-items: baseline;
}

.efforts .time { font-variant-numeric: tabular-nums; font-weight: 600; }

/* --- Lot 3 : classements ------------------------------------------------- */

.points, .volume { list-style: none; margin: 0; padding: 0; }

.points li, .volume li {
  display: grid;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}

.points li { grid-template-columns: 1.6rem auto 1fr auto; }
.volume li { grid-template-columns: 1.6rem 1fr 5rem auto; }

.points li:last-child, .volume li:last-child { border-bottom: 0; }

.points li.me, .volume li.me {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 6px;
  padding-left: 0.4rem;
  padding-right: 0.4rem;
}

.points .small, .volume .small { grid-column: 2 / -1; font-size: 0.78rem; }

/* Barre de progression horizontale du classement au volume */
.bar-inline {
  height: 7px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.bar-inline span {
  display: block;
  height: 100%;
  /* La largeur vient de --fill, posée en ligne ; la mise à l'échelle sert
     uniquement à l'animation, ce qui évite d'animer une propriété de mise en
     page. */
  width: var(--fill, 0%);
  min-width: 3px;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--accent) 75%, var(--gold)),
    var(--accent)
  );
  border-radius: 999px;
}

.same-ride { margin-top: 0.9rem; }

.same-ride h3 {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 0.3rem;
  font-weight: 600;
}

.member .stats { margin-top: 0.75rem; }

.inline-form { margin-top: 0.5rem; }

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--line);
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

/* Bouton qui se comporte comme un lien : partager, copier un code. */
.btn-link {
  background: none;
  border: 0;
  padding: 0;
  min-height: 0;
  color: var(--accent);
  font: inherit;
  font-size: inherit;
  font-weight: 500;
  text-decoration: underline;
  cursor: pointer;
}

/* --- Lot 4 : sorties ----------------------------------------------------- */

.ride-list { list-style: none; margin: 0; padding: 0; }

.ride-list li {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  background: var(--bg);
}

.ride-list a {
  display: block;
  padding: 0.7rem 0.85rem;
  color: inherit;
  text-decoration: none;
}

.ride-list.compact a { padding: 0.5rem 0.85rem; }

.ride-form { margin-top: 0.75rem; }

.ride-form textarea,
.ride-form select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font: inherit;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 0.75rem;
}

.ride-form input[type="datetime-local"] {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font: inherit;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 0.75rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.small { font-size: 0.8rem; }

details.card summary {
  cursor: pointer;
  list-style: revert;
}

/* Réponses */
.rsvp-form { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.rsvp-btn {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 500;
}

.rsvp-btn.on {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.rsvp-group { margin-bottom: 0.9rem; }

.rsvp-group h3 {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 0.35rem;
}

.rsvp-group.yes h3 { color: var(--ok); }

.people {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.people li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg);
  border-radius: 999px;
  padding: 0.2rem 0.6rem 0.2rem 0.2rem;
  font-size: 0.85rem;
}

.rsvp-group.pending .people li { opacity: 0.6; }

/* Météo */
.weather {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  margin: 0.75rem 0;
}

.weather-icon { font-size: 1.8rem; line-height: 1; }

/* --- Lot 5 : administration et données personnelles ---------------------- */

.ok-msg { color: var(--ok); font-size: 0.9rem; }

@media (prefers-color-scheme: dark) {
  .ok-msg { color: #6fd08c; }
}

h3.sub {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 1rem 0 0.4rem;
}

.invites { list-style: none; margin: 0; padding: 0; }

.invites li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
}

.invites li:last-child { border-bottom: 0; }

.invites code {
  font-size: 1rem;
  letter-spacing: 0.12em;
  background: var(--bg);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.invites code.spent { opacity: 0.5; text-decoration: line-through; }
.invites form { margin-left: auto; }

.admin-members { list-style: none; margin: 0; padding: 0; }

.admin-members li {
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}

.admin-members li:last-child { border-bottom: 0; }
.admin-members li.off { opacity: 0.55; }

.who-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.admin-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.45rem;
  flex-wrap: wrap;
}

/* Zone de suppression : visuellement distincte, on n'y clique pas par erreur */
.danger-zone { border-color: color-mix(in srgb, var(--err) 35%, var(--line)); }

.data-list {
  margin: 0.5rem 0 1rem;
  padding-left: 1.1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.data-list li { margin-bottom: 0.2rem; }

.btn-danger {
  background: var(--err);
  color: #fff;
}

footer {
  max-width: 760px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--line);
}

footer a { color: var(--muted); }

/* Ecrans larges : les cartes respirent, mais on ne passe pas en plusieurs
   colonnes — la lecture reste la meme qu'au telephone. */
@media (min-width: 640px) {
  main { padding: 1.5rem 1.25rem 4rem; }
  .card { padding: 1.15rem 1.25rem; }
  .board { padding: 2rem 1.75rem 1.5rem; }
  .board h1 { font-size: 2.1rem; }
}

/* Page de connexion : le chemin principal est celui des membres déjà inscrits,
   rejoindre le club est l'exception. */
.login { max-width: 420px; margin: 2rem auto 0; }
.login .btn-strava, .login .btn-primary { width: 100%; }

.login .join {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.login .join summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
}

.login .join p { margin-top: 0.6rem; }

/* --- Segments : la pièce maîtresse --------------------------------------- */

.board-stats.three { grid-template-columns: repeat(3, 1fr); }

/* Barre d'outils : recherche + tris */
.toolbar input[type="search"] {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font: inherit;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 9px;
  margin-bottom: 0.6rem;
}

.sorts {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -1rem;
  padding: 0 1rem;
}

.sorts::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink-inverse);
}

.chip.ghost { padding: 0.15rem 0.5rem; font-size: 0.75rem; }

/* Grille de segments */
.segment-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
}

@media (min-width: 560px) {
  .segment-grid { grid-template-columns: 1fr 1fr; }
}

.segment-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  /* Entrée en cascade : --i est posé en ligne, plafonné côté serveur. */
  animation: rise 0.4s cubic-bezier(0.22, 0.8, 0.3, 1) backwards;
  animation-delay: calc(var(--i, 0) * 0.035s);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.segment-card a {
  display: flex;
  gap: 0.75rem;
  padding: 0.7rem 0.8rem;
  color: inherit;
  text-decoration: none;
  align-items: center;
}

@media (hover: hover) {
  .segment-card:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
    box-shadow: 0 4px 18px rgba(20, 20, 25, 0.1);
  }

  .segment-card:hover .route-line { stroke-dashoffset: 0; }
}

.route-holder {
  flex: none;
  width: 62px;
  height: 62px;
  background: var(--bg);
  border-radius: 10px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.segment-body { min-width: 0; flex: 1; }

.segment-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.25rem 0 0.4rem;
}

.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
}

.type-badge.descente { background: #dfe9f3; color: #2c5f8a; }
.type-badge.plat { background: #e6e9e4; color: #5a6356; }
.type-badge.cote, .type-badge.mur { background: #f6ded9; color: #a3341c; }

@media (prefers-color-scheme: dark) {
  .type-badge.descente { background: #1d2a35; color: #8fbde0; }
  .type-badge.plat { background: #242720; color: #a3ab9c; }
  .type-badge.cote, .type-badge.mur { background: #37201a; color: #e89a80; }
}

.segment-record {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.record-time {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.passages {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Tracé du segment */
.route { width: 100%; height: 100%; display: block; }

.route-shadow {
  fill: none;
  stroke: var(--line);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.route-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  /* Le tracé se dessine à l'ouverture, comme on suivrait la route du doigt. */
  stroke-dasharray: 400;
  stroke-dashoffset: 400;
  animation: draw-route 1.1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  transition: stroke-dashoffset 0.6s ease;
}

@keyframes draw-route {
  to { stroke-dashoffset: 0; }
}

.route-start { fill: var(--ok); }
.route-end { fill: var(--accent); }

.route.placeholder,
.route-holder .placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--muted);
  font-size: 0.9rem;
  opacity: 0.55;
}

/* Carte réelle sous le tracé (fiche d'un segment uniquement) */
.map-card { padding: 1rem 1rem 0.6rem; }

.segment-map {
  position: relative;
  width: 100%;
  /* Rapport verrouillé : tuiles et tracé restent alignés à toute largeur. */
  aspect-ratio: var(--map-ratio, 16 / 9);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
  /* Les tuiles arrivent une à une : un fond neutre évite le clignotement. */
  isolation: isolate;
}

.map-tiles { position: absolute; inset: 0; }

.map-tiles img {
  position: absolute;
  display: block;
  max-width: none;
  /* Les tuiles OSM sont claires : en thème sombre on les assombrit un peu pour
     que le tracé orange ressorte sans éblouir. */
  animation: fade-tile 0.4s ease backwards;
}

@keyframes fade-tile {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (prefers-color-scheme: dark) {
  .map-tiles { filter: brightness(0.78) saturate(0.85) contrast(1.05); }
}

.map-trace {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Deux traits superposés : un liseré sombre dessous pour que l'orange reste
   lisible aussi bien sur une forêt que sur une zone urbaine claire. */
.map-casing {
  fill: none;
  stroke: rgba(20, 16, 10, 0.55);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-line {
  fill: none;
  stroke: #ff8c1a;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 3000;
  stroke-dashoffset: 3000;
  animation: draw-route 1.6s cubic-bezier(0.4, 0, 0.2, 1) 0.25s forwards;
}

.map-start, .map-end {
  stroke: #fff;
  stroke-width: 2.5;
}

.map-start { fill: #2f9e52; }
.map-end { fill: #d63b1f; }

.map-credit, .map-zoom {
  position: absolute;
  bottom: 0;
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  background: rgba(255, 255, 255, 0.82);
  color: #333;
  border-radius: 4px 0 0 0;
}

.map-credit { right: 0; }
.map-zoom { left: 0; border-radius: 0 4px 0 0; }
.map-credit a { color: #333; }

/* En-tête d'un segment */
.segment-hero {
  display: flex;
  gap: 1rem;
  align-items: center;
  background: var(--board-bg);
  color: var(--board-ink);
  border: 1px solid var(--board-line);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
}

.hero-route {
  flex: none;
  width: 96px;
  height: 96px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  overflow: hidden;
}

.hero-route .route-shadow { stroke: rgba(255, 255, 255, 0.14); }

.hero-text { min-width: 0; }

.segment-hero h1 {
  margin: 0.4rem 0 0.2rem;
  font-size: 1.4rem;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.hero-meta {
  margin: 0;
  font-size: 0.85rem;
  color: var(--board-muted);
}

.pin-badge {
  display: inline-block;
  margin-top: 0.4rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--gold);
  color: #2a2000;
  font-size: 0.72rem;
  font-weight: 700;
}

.hero-links { margin-top: 0.75rem; }

.tile.mine {
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
}

/* Podium en marches */
.podium-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 0.5rem;
  margin: 0.5rem 0 1rem;
}

.podium-steps:has(.step:only-child) { grid-template-columns: 1fr; }

.step { text-align: center; }

.step-athlete {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  margin-bottom: 0.4rem;
}

.step .avatar { width: 42px; height: 42px; }

.step .avatar.placeholder {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.step-name { font-weight: 600; font-size: 0.88rem; }

.step-time {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.step-gap { font-size: 0.72rem; }

.step-block {
  display: grid;
  place-items: center;
  /* Borne la largeur : à un seul membre, une marche pleine largeur ressemble à
     une bannière et non à un podium. */
  max-width: 200px;
  margin: 0 auto;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, var(--line), var(--bg));
  transform-origin: bottom;
  animation: rise-step 0.6s cubic-bezier(0.22, 0.9, 0.3, 1) backwards;
}

.place-1 .step-block { height: 72px; animation-delay: 0.1s; }
.place-2 .step-block { height: 52px; animation-delay: 0.2s; }
.place-3 .step-block { height: 38px; animation-delay: 0.3s; }

.place-1 .step-block {
  background: linear-gradient(180deg, var(--gold), color-mix(in srgb, var(--gold) 30%, var(--bg)));
}

.step.me .step-block {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.step-medal {
  font-size: 1.3rem;
  animation: pop 0.5s ease 0.5s backwards;
}

@keyframes rise-step {
  from { transform: scaleY(0); opacity: 0; }
  to   { transform: scaleY(1); opacity: 1; }
}

.podium.rest { border-top: 1px solid var(--line); padding-top: 0.5rem; }

/* Histoire du record */
.timeline { list-style: none; margin: 0; padding: 0 0 0 0.9rem; position: relative; }

.timeline::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 0.6rem;
  bottom: 0.6rem;
  width: 2px;
  background: var(--line);
}

.timeline li {
  position: relative;
  display: grid;
  grid-template-columns: 3.4rem 1fr;
  gap: 0.1rem 0.6rem;
  padding: 0.45rem 0;
  font-size: 0.9rem;
}

.timeline-dot {
  position: absolute;
  left: -0.9rem;
  top: 0.85rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--card);
}

.timeline li:first-child .timeline-dot { background: var(--gold); }

.timeline-time {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.timeline-date { grid-column: 2; font-size: 0.75rem; }

/* --- Analyse : tuiles, graphiques ---------------------------------------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.6rem;
  margin: 0;
}

.tile {
  background: var(--bg);
  border-radius: 9px;
  padding: 0.6rem 0.7rem;
}

.tile dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.tile dd {
  margin: 0.15rem 0 0;
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.tile-hint {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.tile .up { color: var(--ok); font-size: 0.85rem; font-weight: 600; }
.tile .down { color: var(--err); font-size: 0.85rem; font-weight: 600; }

/* Graphiques SVG */
.chart {
  position: relative;
  margin: 0.5rem 0 0;
  padding-top: 1.1rem;
}

.chart svg {
  display: block;
  width: 100%;
  overflow: visible;
}

/* Nom distinct de `.bar` (la jauge de budget) : en CSS moderne `height`
   s'applique aussi aux formes SVG et écraserait l'attribut du rectangle. */
.chart-bar {
  fill: var(--chart-accent, var(--accent));
  opacity: 0.55;
  transform-origin: bottom;
  animation: grow-bar 0.55s cubic-bezier(0.22, 0.8, 0.3, 1) backwards;
}

.chart-bar[data-on="1"] { opacity: 1; }

@media (hover: hover) {
  .chart-bar:hover { opacity: 1; }
}

@keyframes grow-bar {
  from { transform: scaleY(0); }
  to   { transform: scaleY(1); }
}

.chart-max, .chart-min {
  position: absolute;
  right: 0;
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.chart-max { top: 0; }
.chart-min { bottom: 1.3rem; }

.chart-labels {
  position: relative;
  height: 1.1rem;
  margin-top: 0.3rem;
}

.chart-labels.between {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
}

.chart-label {
  position: absolute;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
}

/* Les courbes ne doivent pas s'épaissir avec la mise à l'échelle du viewBox. */
.line-path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* Les points servent de cible pour l'infobulle, mais restent invisibles : le
   repère du SVG étant étiré horizontalement, un cercle s'y affiche en ellipse. */
.line-dots circle {
  fill: var(--accent);
  opacity: 0;
}

@media (hover: hover) {
  .line-dots circle:hover { opacity: 0.35; }
}

/* Nom distinct de `.profile` (la fiche membre, en flex) : sinon le graphique
   se disposerait en ligne au lieu d'empiler svg et legendes. */
.chart-profile { display: block; }

.profile-fill { fill: var(--accent); opacity: 0.18; }

.profile-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

/* Carte de chaleur */
.heatmap {
  display: grid;
  grid-template-columns: 1.2rem repeat(6, 1fr);
  gap: 3px;
  margin-top: 0.5rem;
}

.heat-corner { grid-column: 1; }

.heat-slot, .heat-day {
  font-size: 0.65rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.heat-day { text-align: left; }

.heat-cell {
  aspect-ratio: 1.6;
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent) calc(var(--heat) * 85%), var(--line));
  animation: rise 0.4s ease backwards;
}

/* Records */
.records-list { list-style: none; margin: 0; padding: 0; }

.records-list li {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.15rem 0.7rem;
  align-items: baseline;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}

.records-list li:last-child { border-bottom: 0; }

.record-value {
  grid-row: span 2;
  font-weight: 700;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.records-list .muted { font-size: 0.78rem; }

.analysis-rides { list-style: none; margin: 0; padding: 0; }

.analysis-rides li {
  border-bottom: 1px solid var(--line);
}

.analysis-rides li:last-child { border-bottom: 0; }

.analysis-rides a {
  display: block;
  padding: 0.6rem 0;
  color: inherit;
  text-decoration: none;
}

.coverage { margin-top: -0.4rem; }

/* --- Animations ----------------------------------------------------------
   Discrètes et courtes : le site se consulte au bord de la route, pas au
   cinéma. Rien ne doit retarder la lecture d'un temps.                      */

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

@keyframes fill-bar {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

@keyframes roll {
  to { transform: rotate(360deg); }
}

@keyframes pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.25) rotate(-8deg); }
  100% { transform: scale(1); }
}

/* Entrée en cascade des cartes. Le délai plafonne vite : sur une page longue,
   personne n'attend la douzième carte. */
.reveal {
  animation: rise 0.4s cubic-bezier(0.22, 0.8, 0.3, 1) backwards;
}

.reveal:nth-child(1) { animation-delay: 0s; }
.reveal:nth-child(2) { animation-delay: 0.05s; }
.reveal:nth-child(3) { animation-delay: 0.1s; }
.reveal:nth-child(4) { animation-delay: 0.15s; }
.reveal:nth-child(n + 5) { animation-delay: 0.2s; }

/* Quand le script d'apparition au défilement est actif, il reprend la main :
   la carte reste discrète tant qu'elle n'est pas entrée dans le champ de
   vision. La classe est posée par app.js, donc sans JavaScript rien ne
   disparaît — le contenu s'affiche simplement d'un bloc. */
.js-reveal .reveal,
.js-reveal .segment-card {
  animation: none;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.22, 0.8, 0.3, 1);
}

.js-reveal .reveal.shown,
.js-reveal .segment-card.shown {
  opacity: 1;
  transform: none;
}

/* Le tracé ne se dessine qu'une fois la carte visible. */
.js-reveal .segment-card .route-line { animation-play-state: paused; }
.js-reveal .segment-card.shown .route-line { animation-play-state: running; }

/* Les barres de kilomètres poussent depuis la gauche, comme un compteur. */
.bar-inline span {
  transform-origin: left center;
  animation: fill-bar 0.7s cubic-bezier(0.22, 0.8, 0.3, 1) 0.15s backwards;
}

/* La roue dentée tourne lentement en fond de panneau. */
.chainring {
  position: absolute;
  top: -18px;
  right: -22px;
  width: 150px;
  height: 150px;
  color: var(--accent);
  opacity: 0.16;
  animation: roll 45s linear infinite;
  pointer-events: none;
}

/* Les médailles du podium tressautent à l'arrivée. */
.podium li:nth-child(-n + 3) .rank,
.points li:nth-child(-n + 3) .rank,
.volume li:nth-child(-n + 3) .rank {
  display: inline-block;
  animation: pop 0.5s ease 0.35s backwards;
}

/* Retours au toucher : le doigt masque l'élément, l'enfoncement se voit. */
button:active, .btn-primary:active, .btn-strava:active, .rsvp-btn:active {
  transform: translateY(1px);
}

/* Les cartes cliquables s'enfoncent légèrement : sur téléphone, c'est le seul
   retour possible puisqu'il n'y a pas de survol. */
.segment-card:active,
.ride-list li:active,
.analysis-rides li:active {
  transform: scale(0.985);
}

/* Reflet qui traverse la première marche du podium, une fois. */
.place-1 .step-block {
  position: relative;
  overflow: hidden;
}

.place-1 .step-block::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 30%,
    rgba(255, 255, 255, 0.55) 50%,
    transparent 70%
  );
  transform: translateX(-100%);
  animation: shine 1.4s ease 0.9s;
}

@keyframes shine {
  to { transform: translateX(100%); }
}

/* Le segment du mois se repère dans la liste. */
.segment-card.pinned {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), var(--shadow);
}

button, .btn-primary, .btn-strava, .rsvp-btn,
.segment-list a, .ride-list a, .topbar nav a {
  transition: background-color 0.15s ease, color 0.15s ease,
    border-color 0.15s ease, transform 0.08s ease;
}

.segment-list li, .ride-list li {
  transition: transform 0.15s ease, border-color 0.15s ease;
}

@media (hover: hover) {
  .segment-list li:hover, .ride-list li:hover {
    transform: translateX(3px);
    border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  }

  .topbar nav a:hover:not(.on) { color: var(--ink); }
}

/* Roue qui tourne pendant la synchronisation */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 0.45rem;
  vertical-align: -2px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: roll 0.7s linear infinite;
}

/* Accessibilité : quelqu'un qui a demandé moins d'animation n'en veut aucune. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .bar-inline span { transform: scaleX(1); }
}
