/* ═══════════════════════════════════════════════════════════════
   runhoratio — feuille de style unique.

   Pensé mobile d'abord : la famille regardera ça sur un téléphone,
   souvent en plein soleil, souvent en marchant. D'où les très gros
   chiffres, le contraste élevé et le très peu de choses à l'écran.
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg:        #0e1116;
  --surface:   #161b23;
  --surface-2: #1d232d;
  --border:    #262f3c;
  --text:      #e9eef5;
  --muted:     #8b98a9;
  --accent:    #ff7a2f;
  --accent-dim:#7a3a15;
  --live:      #35d07f;
  --warn:      #ffc447;
  --radius:    14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  padding-bottom: 3rem;
}

h1, h2 { line-height: 1.2; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; margin: 0 0 .35rem; }

a { color: var(--accent); }

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: .72rem;
  color: var(--muted);
  margin: 0 0 .5rem;
}

.hint { color: var(--muted); font-size: .85rem; margin: .3rem 0 0; }
.lede { color: #c3cddb; margin: .6rem 0 0; max-width: 62ch; }

/* ─────────────── barre du haut ─────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 1rem;
  background: rgba(14, 17, 22, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.brand { font-weight: 600; letter-spacing: -.01em; min-width: 0; }
/* Retour au site principal. Pas de soulignement : dans une barre de
   titre, le lien se devine au survol plutôt qu'à la décoration. */
.brand-name {
  color: var(--accent);
  text-decoration: none;
  border-radius: 4px;
}
.brand-name:hover,
.brand-name:focus-visible { text-decoration: underline; }
.brand-name:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.brand-sep { color: var(--border); margin: 0 .4rem; }
.brand-race { color: var(--muted); font-weight: 500; }

.status {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .8rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
}
.status[data-state="live"]  .status-dot { background: var(--live); animation: pulse 2s infinite; }
.status[data-state="live"]  .status-label { color: var(--live); }
.status[data-state="stale"] .status-dot { background: var(--warn); }
.status[data-state="stale"] .status-label { color: var(--warn); }
.status[data-state="demo"]  .status-dot { background: var(--accent); }

/* Sur un petit téléphone, le nom de la course faisait passer la barre
   sur deux lignes. On tronque plutôt que d'empiler. */
@media (max-width: 480px) {
  .topbar { padding: .6rem .8rem; }
  .brand { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .status { font-size: .72rem; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(53, 208, 127, .5); }
  50%      { opacity: .6; box-shadow: 0 0 0 6px rgba(53, 208, 127, 0); }
}

/* ─────────────── blocs ─────────────── */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
}

.cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 760px) {
  .cols { grid-template-columns: 1.15fr 1fr; }
}

/* ─────────────── les gros chiffres ─────────────── */

.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
@media (min-width: 760px) {
  .hero { grid-template-columns: repeat(4, 1fr); }
}

.stat {
  background: var(--surface);
  padding: 1rem 1.1rem 1.1rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 108px;
}
.stat-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin-bottom: .25rem;
}
.stat-value {
  font-size: clamp(1.9rem, 8vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.stat-unit { font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.stat-sub  { font-size: .78rem; color: var(--muted); margin-top: .35rem; }

.stat-lg .stat-value { color: var(--accent); }
.stat-eta { background: var(--surface-2); }
.stat-eta .stat-value { color: #fff; }

/* Trois chiffres dans une grille à deux colonnes laissaient une case
   vide sur téléphone. Le temps final prend toute la largeur — c'est de
   toute façon celui qu'on regarde en premier. */
.hero-recap { grid-template-columns: 1fr 1fr; }
.hero-recap .stat-lg { grid-column: 1 / -1; }
@media (min-width: 760px) {
  .hero-recap { grid-template-columns: repeat(3, 1fr); }
  .hero-recap .stat-lg { grid-column: auto; }
}

/* ─────────────── progression ─────────────── */

.progress {
  position: relative;
  height: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width .8s ease;
}
.progress-marks { position: absolute; inset: 0; pointer-events: none; }
.progress-marks i {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, .22);
}
.progress-legend {
  margin: .45rem 0 0;
  font-size: .8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ─────────────── carte ─────────────── */

.map {
  height: 380px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  z-index: 1;
}
@media (min-width: 760px) { .map { height: 460px; } }

.leaflet-container { background: #0b0e12; font-family: var(--font); }

/* Les tuiles OSM sont claires : on les inverse pour rester dans le
   thème sombre. Le filtre ne s'applique qu'au calque des tuiles, donc
   le tracé, le coureur et les bornes gardent leurs vraies couleurs. */
.leaflet-tile-pane {
  filter: invert(1) hue-rotate(180deg) brightness(.86) contrast(.92) saturate(.55);
}
.leaflet-control-attribution {
  background: rgba(14, 17, 22, .8) !important;
  color: var(--muted) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--muted) !important; }

/* En mode « après », le récapitulatif chiffré passe devant la carte.
   `main` est une colonne flex : un simple `order` suffit, sans toucher
   à l'ordre du document ni déplacer la carte (ce que Leaflet déteste). */
body[data-mode="apres"] #carte-wrap { order: 1; }
body[data-mode="apres"] #spotify,
body[data-mode="apres"] .cheers { order: 2; }

/* Invite tactile : visible tant que le déplacement de la carte n'a pas
   été activé par un appui volontaire. */
.carte-aide {
  position: absolute;
  left: 50%;
  bottom: .9rem;
  transform: translateX(-50%);
  z-index: 500;
  pointer-events: none;
  background: rgba(14, 17, 22, .92);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: .4rem .9rem;
  font-size: .78rem;
  color: var(--muted);
  white-space: nowrap;
}

.runner-icon { position: relative; }
.runner-dot {
  position: absolute; inset: 4px;
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(255, 122, 47, .9);
}
.runner-pulse {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: rgba(255, 122, 47, .35);
  animation: ping 1.8s cubic-bezier(0, 0, .2, 1) infinite;
}
@keyframes ping { 0% { transform: scale(.4); opacity: .9; } 100% { transform: scale(2.2); opacity: 0; } }

.km-icon {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  text-shadow: 0 0 4px #000, 0 0 4px #000;
}
.spot-icon {
  background: var(--warn);
  border: 2px solid #0e1116;
  border-radius: 50%;
}
.spot-icon.spot-passe { background: var(--muted); opacity: .55; }

/* Départ et arrivée, affichés une fois la course terminée. */
.depart-icon, .arrivee-icon {
  border-radius: 50%;
  border: 2px solid #0e1116;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .35);
}
.depart-icon  { background: #6ee7a8; }
.arrivee-icon {
  background: var(--accent);
  box-shadow: 0 0 0 1px #fff, 0 0 12px rgba(255, 122, 47, .8);
}

/* ─────────────── points spectateurs ─────────────── */

.spots { list-style: none; margin: .8rem 0 0; padding: 0; }
.spot {
  display: grid;
  grid-template-columns: 4.2rem 1fr auto;
  align-items: baseline;
  gap: .5rem;
  padding: .55rem 0;
  border-top: 1px solid var(--border);
  font-size: .92rem;
}
.spot:first-child { border-top: 0; }
.spot-km {
  color: var(--muted);
  font-size: .78rem;
  font-variant-numeric: tabular-nums;
}
.spot-nom em { display: block; font-style: normal; font-size: .76rem; color: var(--muted); }
.spot-heure {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  white-space: nowrap;
}
.spot.passe { opacity: .45; }
.spot.passe .spot-heure { color: var(--muted); font-weight: 500; }

/* ─────────────── listes de faits ─────────────── */

.facts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .9rem 1rem;
  margin: 1rem 0 0;
}
@media (min-width: 620px) { .facts { grid-template-columns: repeat(4, 1fr); } }
.facts-2 { grid-template-columns: repeat(2, 1fr) !important; }
.facts div { min-width: 0; }
.facts dt {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
}
.facts dd {
  margin: .15rem 0 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ─────────────── compte à rebours ─────────────── */

.countdown { display: flex; gap: .6rem; margin: .3rem 0 .8rem; }
.cd-unit {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .6rem .5rem;
  text-align: center;
  flex: 1;
  max-width: 90px;
}
.cd-unit b {
  display: block;
  font-size: clamp(1.4rem, 6vw, 1.9rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.03em;
  color: var(--accent);
}
.cd-unit span {
  font-size: .66rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

/* Renseignements pratiques, avant la course. Détaché du reste par un
   filet : c'est de l'information de terrain, pas du suivi. */
.pratique {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.pratique h3 {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin: 0 0 .5rem;
  font-weight: 600;
}
.pratique p { margin: .35rem 0; color: #c3cddb; font-size: .92rem; max-width: 62ch; }

.finish-title { font-size: 1.5rem; margin: 0 0 1rem; }

/* ─────────────── Spotify ─────────────── */

.np { display: flex; gap: .85rem; align-items: center; margin: .8rem 0; }
.np-art { border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.np-meta { min-width: 0; flex: 1; }
.np-title {
  display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.np-artist { color: var(--muted); font-size: .88rem; }
.np-bar {
  height: 3px;
  background: var(--surface-2);
  border-radius: 99px;
  margin-top: .55rem;
  overflow: hidden;
}
.np-bar i { display: block; height: 100%; width: 0; background: var(--live); transition: width 1s linear; }
.np-embed iframe { display: block; border: 0; }

/* ─────────────── mur d'encouragements ─────────────── */

.cheer-form { display: grid; gap: .5rem; margin: .9rem 0 1.2rem; }
@media (min-width: 620px) {
  /* Placement explicite : sans ça, le placement automatique met le
     message dans la colonne étroite prévue pour le prénom. */
  .cheer-form { grid-template-columns: 200px 1fr auto; align-items: start; }
  #cheer-name    { grid-column: 1; grid-row: 1; }
  #cheer-msg     { grid-column: 2; grid-row: 1; }
  #cheer-submit  { grid-column: 3; grid-row: 1; }
  .form-msg      { grid-column: 1 / -1; grid-row: 2; }
}

.cheer-form input[type=text],
.cheer-form textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: .6rem .7rem;
  font: inherit;
  font-size: .95rem;
  width: 100%;
  resize: vertical;
}
.cheer-form input:focus, .cheer-form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}
.cheer-form button {
  background: var(--accent);
  color: #17120c;
  border: 0;
  border-radius: 10px;
  padding: .65rem 1.2rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.cheer-form button:disabled { opacity: .5; cursor: default; }
.form-msg { font-size: .85rem; color: var(--muted); align-self: center; }

/* le pot de miel : invisible pour un humain, rempli par les robots */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.cheer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.cheer {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .65rem .85rem;
}
.cheer-head { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.cheer-head b { font-size: .9rem; }
.cheer-head time { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.cheer p { margin: .2rem 0 0; font-size: .95rem; color: #cfd8e4; overflow-wrap: anywhere; }
.cheer-vide { color: var(--muted); font-size: .9rem; }

/* ─────────────── pied de page ─────────────── */

.footer {
  max-width: 980px;
  margin: 2rem auto 0;
  padding: 1.5rem 1rem 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .82rem;
}
.footer p { margin: .2rem 0; }

/* ─────────────── accessibilité ─────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
