/* Chasse à l'URS — design tokens, dark edition
   Palette: deep spruce night, celeste as primary, KOM red for climbing,
   stage yellow reserved for personal bests. */

@font-face { font-family: 'Barlow Condensed'; font-weight: 400; font-display: swap;
  src: url('fonts/barlow-condensed-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-display: swap;
  src: url('fonts/barlow-condensed-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 700; font-display: swap;
  src: url('fonts/barlow-condensed-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Archivo'; font-weight: 400; font-display: swap;
  src: url('fonts/archivo-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Archivo'; font-weight: 600; font-display: swap;
  src: url('fonts/archivo-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 400; font-display: swap;
  src: url('fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 500; font-display: swap;
  src: url('fonts/ibm-plex-mono-latin-500-normal.woff2') format('woff2'); }

:root {
  color-scheme: dark;
  --paper: #0F1715;
  --card: #17211E;
  --ink: #E8EFEC;
  --ink-soft: #9AB0A9;
  --line: #2B3934;
  --line-soft: #222E2A;
  --celeste: #3CB8A6;
  --celeste-deep: #5BCDBB;
  --kom: #E2664A;
  --best: #E9BE4B;
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Archivo', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --rail: 1060px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
}
:focus-visible { outline: 2px solid var(--celeste-deep); outline-offset: 2px; }

a { color: var(--celeste-deep); }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.05; margin: 0; }

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.topbar {
  border-bottom: 2px solid var(--line);
  background: var(--paper);
  position: sticky; top: 0; z-index: 40;
}
.topbar-inner {
  max-width: var(--rail); margin: 0 auto; padding: 0 20px;
  display: flex; align-items: baseline; gap: 26px; height: 54px;
}
.wordmark {
  font-family: var(--display); font-weight: 700; font-size: 24px;
  letter-spacing: .04em; text-transform: uppercase; align-self: center;
  text-decoration: none; color: var(--ink);
  white-space: nowrap;
}
.wordmark b { color: var(--celeste-deep); font-weight: 700; }
.topnav { display: flex; gap: 18px; align-self: stretch; align-items: stretch; }
.topnav a {
  display: flex; align-items: center;
  font-family: var(--display); font-weight: 600; font-size: 17px;
  letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-soft); text-decoration: none;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.topnav a.active { color: var(--ink); border-bottom-color: var(--kom); }
.langswitch { margin-left: auto; align-self: center; display: flex; gap: 4px; }
.langswitch button {
  font-family: var(--mono); font-size: 11px; letter-spacing: .08em;
  background: transparent; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 4px;
  padding: 3px 8px; cursor: pointer;
}
.langswitch button.active {
  background: var(--celeste-deep); border-color: var(--celeste-deep);
  color: var(--paper); font-weight: 500;
}
.stamp { align-self: center; font-family: var(--mono);
  font-size: 11px; color: var(--ink-soft); }

main { max-width: var(--rail); margin: 0 auto; padding: 26px 20px 70px; }

.eyebrow {
  font-family: var(--display); font-weight: 600; font-size: 14px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--kom);
  margin: 0 0 6px;
}
.section { margin-top: 44px; }
.section > h2 { font-size: 26px; letter-spacing: .02em; text-transform: uppercase; }
.section-sub { color: var(--ink-soft); margin: 4px 0 16px; max-width: 62ch; }

/* ---------- dashboard hero ---------- */
.hero {
  display: grid; grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 34px; align-items: end;
  border-bottom: 1px solid var(--line); padding-bottom: 30px;
}
.odometer { font-family: var(--display); font-weight: 700; }
.odometer .value {
  font-size: clamp(64px, 9vw, 104px); letter-spacing: .01em;
  font-variant-numeric: tabular-nums; display: block; line-height: .95;
}
.odometer .unit { font-size: 22px; color: var(--ink-soft); font-weight: 600;
  letter-spacing: .08em; }
.hero-substats { display: flex; gap: 26px; margin-top: 18px; flex-wrap: wrap; }
.substat .v { font-family: var(--mono); font-weight: 500; font-size: 19px; display: block; }
.substat .l { font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-soft); }

/* ---------- cards & charts ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 6px; padding: 18px 20px;
}
.chart-title { font-family: var(--display); font-weight: 600; font-size: 16px;
  letter-spacing: .07em; text-transform: uppercase; margin: 0 0 2px; }
.chart-note { font-size: 12.5px; color: var(--ink-soft); margin: 0 0 10px; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--ink-soft);
  margin-top: 8px; flex-wrap: wrap; }
.legend .key { display: inline-block; width: 14px; height: 3px; border-radius: 2px;
  margin-right: 6px; vertical-align: middle; }
.zonelegend { font-family: var(--mono); font-size: 11px; }
.zonelegend .key { height: 8px; width: 8px; border-radius: 2px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

svg.chart { display: block; width: 100%; height: auto; }
svg.chart text { font-family: var(--mono); font-size: 10px; fill: var(--ink-soft); }
svg.chart .axis { stroke: var(--line); stroke-width: 1; }
svg.chart .unit-label { font-size: 9.5px; letter-spacing: .04em; }

/* ---------- ride list ---------- */
.ridetable { width: 100%; border-collapse: collapse; }
.ridetable th {
  text-align: left; font-family: var(--display); font-weight: 600; font-size: 13.5px;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft);
  border-bottom: 2px solid var(--ink-soft); padding: 8px 10px 6px;
}
.ridetable th.n, .ridetable td.n { text-align: right; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sortable[title] { text-decoration: underline dotted; text-underline-offset: 3px; }
th.sort-asc::after { content: ' ▲'; font-size: 9px; }
th.sort-desc::after { content: ' ▼'; font-size: 9px; }
.ridetable td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft);
  vertical-align: middle; }
.ridetable tbody tr { cursor: pointer; }
.ridetable tbody tr:hover td { background: #1E2B27; }
.ridetable .date { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
.ridetable .name { font-weight: 600; }
.ridetable td.n { font-family: var(--mono); font-size: 13px; }
.spark { display: block; }
.spark path { fill: none; stroke: var(--kom); stroke-width: 1.4; }
.spark .fill { fill: var(--kom); opacity: .16; stroke: none; }

.filters { display: flex; gap: 10px; margin: 14px 0 10px; flex-wrap: wrap; }
.chip {
  font-family: var(--display); font-weight: 600; font-size: 15px;
  letter-spacing: .05em; text-transform: uppercase;
  border: 1.5px solid var(--ink-soft); background: transparent; color: var(--ink);
  border-radius: 999px; padding: 4px 16px; cursor: pointer;
}
.chip.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---------- ride detail ---------- */
.ride-head { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; }
.ride-head h1 { font-size: clamp(30px, 5vw, 44px); text-transform: uppercase;
  letter-spacing: .02em; }
.ride-head .when { font-family: var(--mono); font-size: 13px; color: var(--ink-soft); }
.backlink { font-family: var(--display); font-weight: 600; font-size: 15px;
  letter-spacing: .06em; text-transform: uppercase; text-decoration: none; }

.statgrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: 6px; overflow: hidden; margin-top: 18px;
}
.stat { background: var(--card); padding: 12px 14px; }
.stat .v { font-family: var(--mono); font-weight: 500; font-size: 21px; display: block; }
.stat .v small { font-size: 12px; color: var(--ink-soft); font-weight: 400; }
.stat .l { font-size: 11px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-soft); }
.stat.best { box-shadow: inset 0 3px 0 var(--best); }
.stat.flagged { cursor: help; }
.stat.flagged .v { color: var(--kom); }

.mapwrap { margin-top: 20px; border: 1px solid var(--line); border-radius: 6px;
  overflow: hidden; background: var(--card); }
.map { height: 420px; }
.map-tall { height: 460px; }
.trackplot { display: block; width: 100%; height: auto; background: var(--card); }
.trackplot text { font-family: var(--mono); font-size: 10px; fill: var(--ink-soft); }
.trackplot .route { fill: none; stroke: var(--celeste-deep); stroke-width: 2.2;
  stroke-linejoin: round; stroke-linecap: round; }
.trackplot .overlay-route { stroke: var(--celeste); stroke-width: 1.4; opacity: .55; }
.trackplot .start { fill: var(--celeste-deep); }
.trackplot .finish { fill: var(--kom); }
.map-caption { font-size: 12px; color: var(--ink-soft); padding: 8px 12px;
  border-top: 1px solid var(--line-soft); display: flex; gap: 14px; flex-wrap: wrap; }
.timeslider { display: flex; align-items: center; gap: 14px; padding: 12px 4px 2px; }
.timeslider input[type=range] { flex: 1; accent-color: var(--celeste); }
.timeslider span { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }

.profile-card { margin-top: 20px; }
svg.profile .alt-fill { fill: var(--kom); opacity: .18; }
svg.profile .alt-line { fill: none; stroke: var(--kom); stroke-width: 1.6; }
svg.profile .hr-line { fill: none; stroke: var(--celeste-deep); stroke-width: 1.3;
  stroke-dasharray: 4 3; }

.splits { width: 100%; border-collapse: collapse; margin-top: 4px; }
.splits th { font-family: var(--display); font-weight: 600; font-size: 12.5px;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft);
  text-align: right; padding: 6px 10px 4px; border-bottom: 2px solid var(--ink-soft); }
.splits th:first-child, .splits td:first-child { text-align: left; }
.splits td { font-family: var(--mono); font-size: 12.5px; text-align: right;
  padding: 6px 10px; border-bottom: 1px solid var(--line-soft); }
.splits .bar { height: 5px; background: var(--celeste); border-radius: 2px; }
.splits .above-avg { color: var(--celeste-deep); font-weight: 500; }

/* ---------- bike page ---------- */
.bikephoto { margin: 20px 0 0; border: 1px solid var(--line); border-radius: 6px;
  overflow: hidden; background: var(--card); }
.bikephoto img { display: block; width: 100%; height: auto; }

.spectable { width: 100%; border-collapse: collapse; margin-top: 8px; }
.spectable td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft);
  vertical-align: top; }
.spectable .speclabel { font-family: var(--display); font-weight: 600;
  font-size: 13.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-soft); width: 220px; white-space: nowrap; }
.sensor-name { font-size: 15px !important; line-height: 1.35; }
.sensor-note { display: block; font-size: 11px; color: var(--ink-soft);
  margin-top: 4px; }

/* ---------- upload ---------- */
.uploadcard { max-width: 460px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-family: var(--display); font-weight: 600;
  font-size: 13.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 6px; }
.field input { width: 100%; background: var(--paper); color: var(--ink);
  border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px;
  font-family: var(--mono); font-size: 13px; }
.field input[type=file] { padding: 7px; }
.upload-status { font-size: 13px; margin: 12px 0 0; min-height: 1.2em; }
.upload-status.good { color: var(--celeste-deep); }
.upload-status.err { color: var(--kom); }

/* ---------- photos ---------- */
.photogrid { display: grid; gap: 10px; margin-top: 20px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.photogrid button { padding: 0; border: 1px solid var(--line); border-radius: 6px;
  overflow: hidden; cursor: zoom-in; background: var(--card); }
.photogrid img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.lightbox { position: fixed; inset: 0; background: rgba(8, 12, 11, .93);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 4px;
  cursor: default; }
.lb-btn { position: absolute; background: none; border: none; color: var(--ink);
  font-family: var(--mono); font-size: 36px; line-height: 1; cursor: pointer;
  padding: 14px; opacity: .8; }
.lb-btn:hover { opacity: 1; }
.lb-prev { left: 6px; } .lb-next { right: 6px; }
.lb-close { top: 6px; right: 10px; }
.lb-counter { position: absolute; bottom: 14px; left: 50%;
  transform: translateX(-50%); font-size: 12px; color: var(--ink-soft); }

.empty { border: 1.5px dashed var(--line); border-radius: 6px; padding: 40px;
  text-align: center; color: var(--ink-soft); margin-top: 24px; }
.empty code { font-family: var(--mono); font-size: 12.5px; color: var(--ink); }

/* maplibre chrome on a dark page */
.maplibregl-ctrl-attrib { background: rgba(15, 23, 21, .7) !important; }
.maplibregl-ctrl-attrib, .maplibregl-ctrl-attrib a { color: var(--ink-soft) !important; }

/* ---------- motion & responsive ---------- */
@media (prefers-reduced-motion: no-preference) {
  .odometer .value { transition: none; }
}
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; align-items: start; }
  .grid-2 { grid-template-columns: 1fr; }
  .ridetable .hide-sm { display: none; }
  .map { height: 320px; }
  .map-tall { height: 340px; }
  .topbar-inner { gap: 14px; }
  .stamp { display: none; }
}