/* Bound — feuille de style unique.
   Direction : sportive, cartographique, compétitive, minimaliste.
   Peu de couleurs (vert Bound, anthracite, gris, blanc cassé, or rare),
   bordures légères plutôt qu'ombres. */

:root {
  --brand: #0b6e4f;
  --brand-strong: #08573f;
  --brand-pale: #e9f4ef;
  --ink: #1b2125;
  --fg: var(--ink);
  --muted: #5f6b73;
  --faint: #8a949a;
  --bg: #fbfbf8;
  --card: #fff;
  --line: #e4e6e1;
  --line-strong: #d2d6cf;
  --gold: #a5701a;
  --gold-pale: #fbf3e2;
  --danger: #b3261e;
  --danger-pale: #fdecea;
  --warn-pale: #fff3d6;
  --accent: var(--brand);
  --radius: .65rem;
  --radius-small: .4rem;
  --wrap: 1050px;
  --gutter: 24px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-underline-offset: .15em; }
a:hover { color: var(--brand-strong); }
img, svg { max-width: 100%; }

/* --- Conteneur commun : en-tête, contenu et pied de page sur les mêmes axes */
.wrap, .container { max-width: var(--wrap); margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
.container { padding-top: 1.75rem; padding-bottom: 2rem; }
@media (max-width: 40rem) { :root { --gutter: 16px; } .container { padding-top: 1.25rem; } }

/* Texte courant limité en largeur ; tableaux, cartes et grilles prennent tout. */
.container > p, section > p, .prose { max-width: 44rem; }

/* --- Typographie */
h1 { font-size: 1.85rem; line-height: 1.2; font-weight: 800; letter-spacing: -.01em; margin: 0 0 .5rem; }
h2 { font-size: 1.2rem; line-height: 1.3; font-weight: 750; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
section { margin: 2rem 0; }
.eyebrow { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: .875rem; }
.time, .num { font-variant-numeric: tabular-nums; }
.time { font-weight: 700; }
.lead { font-size: 1.15rem; color: var(--muted); }
.tagline { font-weight: 600; color: var(--brand); }

/* --- En-tête */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: center; justify-content: space-between; min-height: 3.5rem; }
.brand { display: inline-flex; align-items: center; gap: .45rem; font-weight: 800; font-size: 1.1rem; text-decoration: none; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand-mark { flex: none; }
.brand-tagline { font-weight: 500; color: var(--muted); font-size: .85rem; }
.topbar nav { display: flex; gap: .25rem; align-items: center; overflow-x: auto; scrollbar-width: none; }
.topbar nav a, .topbar nav button.link { padding: .4rem .6rem; border-radius: var(--radius-small); color: var(--ink); text-decoration: none; white-space: nowrap; font-weight: 500; }
.topbar nav a:hover, .topbar nav button.link:hover { background: var(--brand-pale); color: var(--brand-strong); }
@media (max-width: 40rem) {
  .brand-tagline { display: none; }
  .topbar .wrap { padding-top: .4rem; padding-bottom: .4rem; }
  .topbar nav { width: 100%; margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter) .2rem; }
}

/* --- Pied de page */
.footer { border-top: 1px solid var(--line); margin-top: 2rem; padding-top: 1.25rem; padding-bottom: 2rem; font-size: .8rem; color: var(--faint); }
.footer a { color: var(--muted); }

/* --- En-tête de page : titre, contexte, actions */
.page-head { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.page-head .meta { color: var(--muted); margin: .35rem 0 0; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* En-tête de section : titre à gauche, action (« Voir tout ») à droite */
.section-head { display: flex; gap: .5rem 1rem; align-items: baseline; justify-content: space-between; flex-wrap: wrap; margin-bottom: .75rem; }
.section-head h2 { margin: 0; }
.section-head > a { font-size: .9rem; font-weight: 600; text-decoration: none; }
.section-head > a:hover { text-decoration: underline; }
.section-head h2 a { color: var(--ink); text-decoration: none; }
.section-head h2 a:hover { color: var(--brand); }

/* --- Cartes et panneaux */
.card, .panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin: 1rem 0; }
.panel > h2:first-child, .card > h2:first-child { margin-top: 0; }
.empty { text-align: center; color: var(--muted); }
.empty h2 { color: var(--ink); }
.subtle { background: transparent; border-style: dashed; }

/* --- Boutons et liens d'action */
.button { display: inline-flex; align-items: center; gap: .4rem; padding: .6rem 1rem; border: 1px solid var(--brand); border-radius: var(--radius-small); background: var(--brand); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.button:hover { background: var(--brand-strong); color: #fff; }
.button.secondary { background: var(--card); color: var(--brand); }
.button.secondary:hover { background: var(--brand-pale); color: var(--brand-strong); }
.button.small { padding: .35rem .7rem; font-size: .9rem; }
.button.danger { background: var(--danger); border-color: var(--danger); }
.danger { color: var(--danger); }
button.link { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; text-decoration: underline; }
form.inline { display: inline; }

/* --- Champs */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; }
.field.checkbox label { display: flex; gap: .5rem; align-items: flex-start; }
input[type=text], input[type=email], input[type=password], input[type=file], input[type=search], input[type=number], select {
  width: 100%; padding: .6rem .75rem; font: inherit; color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius-small); background: #fff;
}
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-pale); }
.error { color: var(--danger); }
div.error { background: var(--danger-pale); padding: .75rem 1rem; border-radius: var(--radius-small); }
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.message { padding: .65rem .9rem; border-radius: var(--radius-small); background: var(--brand-pale); margin-bottom: .5rem; }

/* Recherche : un seul champ avec loupe, suggestions en liste */
.search { position: relative; max-width: 34rem; }
.search input[type=search] { padding-left: 2.4rem; }
.search::before { content: ""; position: absolute; left: .85rem; top: 50%; width: .8rem; height: .8rem; border: 2px solid var(--faint); border-radius: 50%; transform: translateY(-62%); pointer-events: none; }
.search::after { content: ""; position: absolute; left: 1.55rem; top: 58%; width: .4rem; height: 2px; background: var(--faint); transform: rotate(45deg); pointer-events: none; }
.suggestions { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + .25rem); background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius-small); list-style: none; margin: 0; padding: .25rem 0; max-height: 18rem; overflow-y: auto; }
.suggestions li button { display: flex; width: 100%; justify-content: space-between; gap: 1rem; padding: .5rem .75rem; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; color: var(--ink); }
.suggestions li button:hover, .suggestions li button[aria-selected=true] { background: var(--brand-pale); }
.pair-preview { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; margin-top: .75rem; }
.inline-search { display: flex; gap: .5rem; flex-wrap: wrap; margin: .5rem 0; }
.inline-search input[type=search] { flex: 1 1 14rem; min-width: 0; }

/* --- Onglets */
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin: .75rem 0; }
.tabs a { padding: .3rem .8rem; border: 1px solid var(--line-strong); border-radius: 2rem; text-decoration: none; color: var(--ink); font-size: .9rem; background: var(--card); }
.tabs a:hover { border-color: var(--brand); }
.tabs a[aria-current=page] { background: var(--brand); color: #fff; border-color: var(--brand); }

/* --- Badges : rares et cohérents */
.badge { display: inline-flex; align-items: center; gap: .25rem; font-size: .78rem; font-weight: 600; padding: .12rem .5rem; border-radius: 2rem; background: #eef0ec; color: var(--muted); white-space: nowrap; }
.badge.gold { background: var(--gold-pale); color: var(--gold); }
.badge.brand { background: var(--brand-pale); color: var(--brand-strong); }
.badge.quiet { background: transparent; border: 1px solid var(--line-strong); }
.badge.motif { background: var(--gold-pale); color: var(--gold); }
.status-suspicious, .status-failed, .status-pending, .status-processing { background: var(--warn-pale); color: #7a5300; }
.status-invalid { background: var(--danger-pale); color: var(--danger); }

/* --- Chiffres clés */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: .75rem; margin: 1rem 0 1.5rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; display: flex; flex-direction: column; gap: .1rem; }
.stat strong { font-size: 1.6rem; line-height: 1.1; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .9rem; }
.stat small { color: var(--faint); font-size: .8rem; }
.stat.gold strong { color: var(--gold); }
.stat-strip { display: flex; flex-wrap: wrap; gap: .5rem 2rem; margin: .75rem 0 0; }
.stat-strip div { display: flex; flex-direction: column; }
.stat-strip strong { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-strip span { color: var(--muted); font-size: .85rem; }

/* --- Composant « Résultat Bound » : VILLE A → VILLE B, temps, classement */
.result { display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; align-items: baseline; padding: .85rem 0; border-bottom: 1px solid var(--line); }
.result:last-child { border-bottom: 0; }
.result-route { font-weight: 700; text-decoration: none; color: var(--ink); }
.result-route:hover { color: var(--brand); text-decoration: underline; }
.result-route .arrow, .arrow { color: var(--brand); font-weight: 800; }
.result-time { font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.result-rank { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.result-rank.medal { color: var(--gold); }
.result-meta { color: var(--muted); font-size: .875rem; display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: center; }
.result-meta a { color: var(--muted); }
.result-side { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: .15rem; }
.result-badges { display: flex; flex-wrap: wrap; gap: .3rem; }
.results { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 1.1rem; }

/* Variante compacte : une ligne */
.result.compact { padding: .6rem 0; }
.result.compact .result-time { font-weight: 700; }

/* Variante mise en avant : cartes du top 3 */
.featured { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: .9rem; margin: .5rem 0 1rem; }
.result.featured-card { display: flex; flex-direction: column; gap: .35rem; padding: 1.1rem 1.2rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); border-bottom: 1px solid var(--line); }
.result.featured-card .result-route { font-size: 1.05rem; }
.result.featured-card .result-time { font-size: 1.9rem; line-height: 1.1; text-align: left; }
.result.featured-card .result-rank { font-size: 1rem; }
.result.featured-card.top { border-color: var(--gold); box-shadow: inset 0 3px 0 var(--gold); }

/* Résultat ciblé par l'adresse (#effort-…) */
.result:target, .effort:target, tr:target { background: var(--brand-pale); box-shadow: inset 3px 0 0 var(--brand); }
.result:target { margin: 0 -1.1rem; padding-left: 1.1rem; padding-right: 1.1rem; }

/* --- Listes simples */
.list { list-style: none; padding: 0; margin: .5rem 0; }
.list > li { padding: .65rem 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.effort { display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: baseline; }
.effort-link { flex: 1 1 14rem; font-weight: 600; }
.rank { color: var(--muted); }
.findings { flex-basis: 100%; margin: .25rem 0 0; color: var(--muted); font-size: .9rem; }
.steps li.done { color: var(--brand); }
.steps li.current { font-weight: 600; }

/* Ligne d'activité (tableau de bord) */
.activity-row { display: grid; grid-template-columns: 10rem 1fr auto auto; gap: .5rem 1rem; align-items: center; padding: .65rem 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.activity-row:hover { color: var(--brand); }
.activity-row:last-child { border-bottom: 0; }
.activity-row .chevron { color: var(--faint); }
.activity-row > span:first-child { white-space: nowrap; }
@media (max-width: 40rem) { .activity-row { grid-template-columns: 1fr auto auto; } .activity-row .sport { display: none; } }

/* --- Tableaux (historiques complets) */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.leaderboard { width: 100%; border-collapse: collapse; }
.leaderboard th { text-align: left; padding: .6rem .9rem; font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; }
.leaderboard td { text-align: left; padding: .6rem .9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.leaderboard tr:last-child td { border-bottom: 0; }
.leaderboard tbody tr:hover { background: #fafbf8; }
.leaderboard td.num, .leaderboard td:last-child { font-variant-numeric: tabular-nums; }
.leaderboard .nowrap { white-space: nowrap; }
@media (max-width: 40rem) { .leaderboard th, .leaderboard td { padding: .55rem .6rem; font-size: .92rem; } }

/* --- Cartes géographiques */
.map { width: 100%; height: 28rem; border-radius: var(--radius); border: 1px solid var(--line); background: #f1f2ec; }
@media (max-width: 40rem) { .map { height: 18rem; } }

/* --- Détails dépliables */
details { margin: 1rem 0; }
summary { cursor: pointer; color: var(--brand); font-weight: 600; }
details.help summary { font-weight: 500; font-size: .9rem; }
details.help p { color: var(--muted); font-size: .9rem; }

/* --- Bloc Strava */
.strava-card .strava-block { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); padding: .85rem 1rem; border-radius: var(--radius-small); font-size: .95rem; line-height: 1.6; margin: .5rem 0; }
.strava-card .strava-foot { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; color: var(--muted); font-size: .875rem; }
.strava-block { white-space: pre-wrap; }

/* --- Divers */
.pagination { display: flex; gap: 1rem; align-items: center; margin: 1rem 0; flex-wrap: wrap; }
.inline-filter { margin: .5rem 0; }
.inline-filter label { display: inline-flex; gap: .4rem; align-items: center; font-size: .9rem; }
.hero { padding: 2rem 0 1rem; }
.hero h1 { font-size: 2.4rem; }
.featured + p, .panel .featured { margin-top: 1rem; }
.steps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .9rem; margin: 1.5rem 0; }
.figures { font-weight: 600; }
.personal .big { font-size: 2rem; margin: .25rem 0; font-weight: 800; font-variant-numeric: tabular-nums; }
.liaison-head h1 { margin: 0; }
.commune-head h1 { margin-bottom: .2rem; }
.summary-lines > li { border-bottom: 0; padding: .2rem 0; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--card); padding: .5rem 1rem; z-index: 10; }
.skip-link:focus { left: 1rem; }
:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 40rem) { h1, .hero h1 { font-size: 1.6rem; } }

/* Tableaux de résultats empilés sur téléphone : liaison, puis temps et rang */
@media (max-width: 40rem) {
  .leaderboard.stack thead { display: none; }
  .leaderboard.stack tbody tr { display: grid; grid-template-columns: 1fr auto; gap: .1rem .75rem; padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
  .leaderboard.stack tbody tr:last-child { border-bottom: 0; }
  .leaderboard.stack td { padding: 0; border: 0; font-size: .875rem; color: var(--muted); }
  .leaderboard.stack td.c-route { grid-column: 1 / -1; font-size: 1rem; color: var(--ink); }
  .leaderboard.stack td.c-route a { font-weight: 700; }
  .leaderboard.stack td.c-time { grid-column: 2; grid-row: 2; text-align: right; color: var(--ink); font-size: 1rem; }
  .leaderboard.stack td.c-rank { grid-column: 2; grid-row: 3; text-align: right; }
  .leaderboard.stack td.c-sport, .leaderboard.stack td.c-distance, .leaderboard.stack td.c-date { grid-column: 1; }
  .leaderboard.stack td.c-sport { grid-row: 2; }
  .leaderboard.stack td.c-date { grid-row: 3; }
  .leaderboard.stack td.c-distance { grid-row: 4; }
}
.destination .pair-preview { max-width: 34rem; }
h1 .place-link { color: inherit; text-decoration: none; }
h1 .place-link:hover { color: var(--brand); text-decoration: underline; }
@media (max-width: 40rem) {
  .leaderboard.stack td[data-label]::before { content: attr(data-label) " "; color: var(--faint); }
}

/* --- Accueil public */
.hero-split { display: grid; grid-template-columns: 1.1fr 1fr; gap: 2.5rem; align-items: center; padding: 1.5rem 0 1rem; margin-top: 0; }
.hero-split h1 { font-size: 2.6rem; line-height: 1.1; margin-bottom: 1rem; }
.hero-split .lead { max-width: 34rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1.25rem 0 .5rem; }
.hero-visual svg { width: 100%; height: auto; border-radius: 16px; border: 1px solid var(--line); display: block; }
.steps-grid .panel { margin: 0; }
.steps-grid .panel p:last-child { margin-bottom: 0; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.two-cols section { margin-top: 0; }
.faq details.panel { margin: .6rem 0; padding: .85rem 1.1rem; }
.faq details.panel summary { color: var(--ink); }
.faq details.panel p { color: var(--muted); margin-bottom: 0; }
.cta { text-align: center; padding: 1.75rem; }
.cta h2 { margin-bottom: 1rem; }
@media (max-width: 52rem) {
  .hero-split { grid-template-columns: 1fr; gap: 1.5rem; }
  .hero-split h1 { font-size: 2rem; }
  .two-cols { grid-template-columns: 1fr; }
}
.cta p { max-width: none; }
.map-legend { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem 1rem; }
.legend-item { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
.swatch { display: inline-block; width: .8rem; height: .8rem; border-radius: .2rem; border: 2px solid; vertical-align: middle; }
.swatch.center { background: rgba(27, 33, 37, .3); border-color: #1b2125; }
.swatch.outbound { background: rgba(194, 65, 12, .28); border-color: #c2410c; }
.swatch.inbound { background: rgba(4, 120, 87, .28); border-color: #047857; }
.swatch.both { background: rgba(124, 58, 237, .28); border-color: #7c3aed; }
.swatch.neighbour { background: rgba(138, 148, 154, .15); border: 2px dashed #8a949a; }
.gain { color: var(--brand); font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 40rem) { .leaderboard.stack td.c-progress { grid-column: 2; grid-row: 4; text-align: right; } }

/* --- Carte des traces d'une liaison */
.map-tall { height: 34rem; }
@media (max-width: 40rem) { .map-tall { height: 24rem; } }
.tabs a[aria-disabled=true] { opacity: .45; cursor: not-allowed; }
.trace-info { margin-top: .75rem; display: flex; flex-wrap: wrap; gap: .5rem 2rem; align-items: center; }
.trace-info .trace-title { font-weight: 700; flex-basis: 100%; }
.trace-info .stat-strip { margin: 0; }
.line-swatch { display: inline-block; width: 1.4rem; height: 4px; border-radius: 2px; vertical-align: middle; }
.line-swatch.others { background: rgba(49, 46, 129, .45); }
.line-swatch.mine { background: #1d4ed8; }
.line-swatch.selected { background: #d97706; height: 5px; }
