/* Piste d'athlétisme : un ovale rouge tartan en ouverture, les distances en couloirs, le reste sur papier. */
:root {
  --papier: #f4f5f1;
  --surface: #ffffff;
  --trait: #dcdfdc;
  --trait-fort: #7f8794;
  --encre: #141a26;
  --encre-2: #565e6d;
  --nuit: #2a3c6f;
  --voile: #e6ebf7;
  --tartan: #c2401a;          /* rouge piste comme texte ou bouton */
  --sur-tartan: #ffffff;
  --piste: #c2401a;           /* revêtement dessiné */
  --sur-piste: #ffffff;
  --ligne: rgba(255, 255, 255, .9);
  --pelouse: #e1e9da;
  --pelouse-trait: #c9d6c0;

  --f-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --f-texte: "Atkinson Hyperlegible Next", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --r-sm: 8px;
  --r-lg: 16px;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --papier: #11151c;
    --surface: #192029;
    --trait: #29303b;
    --trait-fort: #6b7381;
    --encre: #e8ebf0;
    --encre-2: #9ba3b1;
    --nuit: #8fa8f5;
    --voile: #1f2a44;
    --tartan: #ff7f55;
    --sur-tartan: #10141c;
    --piste: #a8391a;
    --sur-piste: #ffffff;
    --ligne: rgba(255, 255, 255, .78);
    --pelouse: #17221a;
    --pelouse-trait: #24352a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --papier: #11151c;
  --surface: #192029;
  --trait: #29303b;
  --trait-fort: #6b7381;
  --encre: #e8ebf0;
  --encre-2: #9ba3b1;
  --nuit: #8fa8f5;
  --voile: #1f2a44;
  --tartan: #ff7f55;
  --sur-tartan: #10141c;
  --piste: #a8391a;
  --sur-piste: #ffffff;
  --ligne: rgba(255, 255, 255, .78);
  --pelouse: #17221a;
  --pelouse-trait: #24352a;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--papier);
  color: var(--encre);
  font: 16px/1.625 var(--f-texte);
  -webkit-font-smoothing: antialiased;
}

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

.wrap {
  width: 100%; max-width: 1040px; margin: 0 auto;
  padding-left: var(--gutter-l); padding-right: var(--gutter-r);
}

h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; margin: 0; }
h1 { font-size: clamp(34px, 7.5vw, 56px); line-height: 1.02; font-weight: 800; letter-spacing: -.03em; max-width: 16ch; }
h2 { font-size: clamp(26px, 5vw, 32px); line-height: 1.1; font-weight: 700; letter-spacing: -.015em; }
h3 { font-size: 21px; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }

.etiquette {
  margin: 0; font: 500 11px/16px var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--encre-2);
}

/* En-tête */
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--encre); text-decoration: none; font: 800 19px var(--f-display); letter-spacing: -.01em; }
.brand-mark { width: 28px; height: 18px; }
.brand-mark rect:first-child { fill: var(--piste); }
.brand-mark rect:last-child { fill: var(--papier); stroke: var(--ligne); stroke-width: 0; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--encre-2); text-decoration: none; font-size: 15px; font-weight: 600; padding: 6px 10px; border-radius: var(--r-sm); white-space: nowrap; }
.nav a:hover { color: var(--encre); background: var(--voile); }

/* Ouverture : la piste */
.hero { display: flex; flex-direction: column; gap: 12px; padding-block: 12px 8px; }
.hero h1 { margin-bottom: 8px; }

.stadium { position: relative; width: 100%; aspect-ratio: 1 / 1.42; max-width: 100%; }
@media (min-width: 620px) { .stadium { aspect-ratio: 2.15 / 1; } }
.track { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.track .apron { fill: var(--piste); }
.track .lane-line { fill: none; stroke: var(--ligne); stroke-width: 1.25; }
.track .grass { fill: var(--pelouse); }
.track .kerb { fill: none; stroke: var(--ligne); stroke-width: 3; }
.track .finish { stroke: var(--ligne); stroke-width: 3; }
.track .lane-num { fill: var(--sur-piste); font: 600 9px var(--f-mono); text-anchor: middle; dominant-baseline: central; }
.track .mark { stroke: var(--ligne); stroke-width: 3; }
.track .mark-label rect { fill: var(--surface); stroke: var(--encre); stroke-width: 1; }
.track .mark-label text { text-anchor: middle; dominant-baseline: central; font-family: var(--f-mono); }
.track .mark-dist { fill: var(--encre-2); font-size: 9px; font-weight: 500; letter-spacing: .04em; }
.track .mark-time { fill: var(--encre); font-size: 11.5px; font-weight: 600; }
.track .runner-halo { fill: var(--sur-piste); opacity: .28; }
.track .runner { fill: var(--sur-piste); stroke: var(--encre); stroke-width: 1.5; }

.infield {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(78%, 420px); max-width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
}
.infield-label { color: var(--encre-2); }
.infield-controls { display: flex; flex-direction: column; align-items: center; gap: 10px; }
@media (min-width: 620px) { .infield-controls { flex-direction: row; align-items: center; gap: 40px; } }
.control { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.stepper-pct .step { width: 36px; height: 36px; font-size: 18px; }
.pct-field { min-width: 5.2ch; text-align: center; font: 600 clamp(26px, 7vw, 34px)/1.15 var(--f-mono); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.pct-field span { font-size: 13px; font-weight: 500; color: var(--encre-2); letter-spacing: 0; }
.step:disabled { opacity: .35; cursor: default; }

.stepper { display: flex; align-items: center; gap: 8px; }
.step {
  width: 44px; height: 44px; flex: none; border-radius: 50%;
  border: 1.5px solid var(--trait-fort); background: var(--surface); color: var(--encre);
  font: 500 22px/1 var(--f-mono); cursor: pointer; touch-action: manipulation;
  transition: transform .12s ease, border-color .12s ease;
}
.step:hover { border-color: var(--encre); }
.step:active { transform: scale(.94); }
.vma-field { display: flex; align-items: baseline; gap: 6px; border-bottom: 2px solid var(--encre); padding: 0 2px; }
.vma-field:focus-within { border-color: var(--tartan); }
.vma-field input {
  width: 4.3ch; border: 0; background: transparent; color: var(--encre); outline: none; padding: 0;
  font: 600 clamp(36px, 9.5vw, 60px)/1.05 var(--f-mono); letter-spacing: -.04em; text-align: right;
  font-variant-numeric: tabular-nums;
}
.vma-field span { color: var(--encre-2); font: 500 14px var(--f-mono); }

.infield-stats { display: flex; gap: 24px; margin: 0; }
@media (max-width: 420px) {
  .infield .step { width: 40px; height: 40px; }
  .infield .stepper { gap: 6px; }
  .infield-stats dd { font-size: 18px; }
}
.infield-stats div { display: flex; flex-direction: column; align-items: center; }
.infield-stats dt, .summary dt { font: 500 11px/16px var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--encre-2); }
.infield-stats dd { margin: 0; font: 600 20px/1.3 var(--f-mono); font-variant-numeric: tabular-nums; }

.track-speed { align-self: center; display: inline-flex; padding: 3px; gap: 2px; border: 1.5px solid var(--trait-fort); border-radius: 999px; }
.seg { height: 36px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent; color: var(--encre-2); font: 600 14px var(--f-texte); cursor: pointer; touch-action: manipulation; }
.seg:hover { color: var(--encre); }
.seg[aria-checked="true"] { background: var(--encre); color: var(--papier); }

/* Barre compacte */
.minibar {
  position: fixed; left: 0; right: 0; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--piste); color: var(--sur-piste);
  transform: translateY(-110%); transition: transform .25s ease;
  box-shadow: 0 2px 0 var(--ligne) inset, 0 -2px 0 var(--ligne) inset;
}
.minibar.on { transform: none; }
.minibar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 60px; }
.minibar-label { font: 500 11px/16px var(--f-mono); letter-spacing: .1em; }
.stepper-sm .step { width: 36px; height: 36px; font-size: 18px; background: transparent; color: var(--sur-piste); border-color: var(--ligne); }
.minibar-value { font: 600 22px var(--f-mono); font-variant-numeric: tabular-nums; min-width: 6.5ch; text-align: center; }
.minibar-value small { font-size: 12px; font-weight: 500; }
.minibar-pct { font: 600 16px var(--f-mono); min-width: 4.5ch; text-align: center; }
.minibar .step:disabled { opacity: .4; }
@media (max-width: 420px) { .minibar-label { display: none; } .minibar-value { min-width: 5ch; font-size: 19px; } }

/* Sections */
.section { padding-top: 56px; }
@media (min-width: 900px) { .section { padding-top: 72px; } }
.section-head { display: flex; flex-direction: column; gap: 4px; margin-bottom: 20px; }
.section-head p { margin: 0; color: var(--encre-2); }

/* Allures */
.allures { display: grid; gap: 20px; }
@media (min-width: 860px) {
  .allures { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 40px; align-items: start; }
  .allures-side { position: sticky; top: 24px; }
}
.allures-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.allures-side .section-head { margin-bottom: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1.5px solid var(--trait-fort); background: transparent; color: var(--encre);
  border-radius: var(--r-sm); height: 40px; min-width: 58px; padding: 0 10px;
  font: 500 15px var(--f-mono); cursor: pointer; font-variant-numeric: tabular-nums; touch-action: manipulation;
}
.chip:hover { border-color: var(--encre); }
.chip[aria-checked="true"] { background: var(--encre); border-color: var(--encre); color: var(--papier); font-weight: 600; }

.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; border-top: 2px solid var(--encre); }
.summary div { padding: 10px 0 0; min-width: 0; }
.summary div + div { padding-left: 14px; border-left: 1px solid var(--trait); }
.summary dd { margin: 0; font: 600 clamp(18px, 5vw, 26px)/1.25 var(--f-mono); font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -.02em; }

.back-to-track { align-self: flex-start; font-weight: 700; color: var(--tartan); text-decoration: none; border-bottom: 2px solid currentColor; padding-bottom: 1px; }
.back-to-track::before { content: "↑ "; }

/* Couloirs */
.lanes {
  list-style: none; margin: 0; padding: 0 0 0 0; counter-reset: lane;
  background: var(--piste); color: var(--sur-piste);
  border-radius: var(--r-lg); overflow: hidden;
  box-shadow: inset 0 0 0 6px var(--piste), inset 0 0 0 7.5px var(--ligne);
}
.lanes li {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 12px;
  padding: 11px 20px 11px 14px; border-top: 1.25px solid var(--ligne);
  counter-increment: lane;
}
.lanes li:first-child { border-top: 0; padding-top: 16px; }
.lanes li:last-child { padding-bottom: 16px; }
.lanes li::before {
  content: counter(lane); font: 600 13px var(--f-mono); text-align: center;
  border: 1.25px solid var(--ligne); border-radius: 4px; padding: 1px 0;
}
.lanes .dist { font: 700 19px/1.2 var(--f-display); letter-spacing: -.01em; }
.lanes .time { font: 600 24px/1.2 var(--f-mono); letter-spacing: -.02em; font-variant-numeric: tabular-nums; text-align: right; }
.lanes li.key .dist::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--sur-piste); margin-left: 8px; vertical-align: middle; }

/* Panneaux */
.panel { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--r-lg); margin-top: 16px; }
details.panel > summary { padding: 16px 20px; }
summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; font: 400 22px/1 var(--f-mono); color: var(--encre-2); }
details[open] > summary::after { content: "−"; }
.note { color: var(--encre-2); font-size: 14px; margin: 0; padding: 12px 20px 16px; }

.table-scroll { overflow-x: auto; border-top: 1px solid var(--trait); }
.matrix { border-collapse: collapse; width: 100%; font: 400 14px var(--f-mono); font-variant-numeric: tabular-nums; }
.matrix th, .matrix td { padding: 9px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--trait); }
.matrix thead th { background: var(--papier); font-size: 12px; font-weight: 500; color: var(--encre-2); }
.matrix tbody th { text-align: left; position: sticky; left: 0; background: var(--surface); font-weight: 600; color: var(--encre); }
.matrix .hl { background: var(--voile); color: var(--encre); }
.matrix thead .hl { color: var(--nuit); font-weight: 600; }
.matrix tr:last-child td, .matrix tr:last-child th { border-bottom: 0; }

/* Feuille de résultats */
.results { border-top: 2px solid var(--encre); border-bottom: 2px solid var(--encre); }
.results-head, .race { display: grid; grid-template-columns: minmax(0, 1.2fr) auto minmax(0, 1.4fr); gap: 4px 16px; align-items: baseline; padding: 12px 0; }
.results-head { font: 500 11px/16px var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--encre-2); padding: 8px 0; border-bottom: 1px solid var(--encre); }
.results-head span:last-child, .race .chrono { text-align: right; }
.race + .race { border-top: 1px solid var(--trait); }
.race .name { font: 700 18px/1.3 var(--f-display); }
.race .pct { font: 400 14px var(--f-mono); color: var(--encre-2); white-space: nowrap; }
.race .chrono { font: 600 17px/1.35 var(--f-mono); font-variant-numeric: tabular-nums; }
.race .chrono small { display: block; font-size: 12px; font-weight: 400; color: var(--encre-2); }

/* Séances */
.cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@media (min-width: 640px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 960px) { .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.card { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--r-lg); padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.card p { margin: 0; color: var(--encre-2); font-size: 15px; line-height: 1.55; }

/* Dossard : rectangle blanc, numéro, quatre épingles */
.bib {
  flex: none; position: relative; padding: 5px 14px 4px; border-radius: 3px;
  background: var(--papier); border: 1px solid var(--trait-fort);
  font: 600 14px/1.2 var(--f-mono); color: var(--tartan); white-space: nowrap; letter-spacing: -.01em;
}
.bib::before, .bib::after {
  content: ""; position: absolute; top: 3px; bottom: 3px; width: 3px;
  background: radial-gradient(circle, var(--trait-fort) 1.2px, transparent 1.6px) top / 3px 3px no-repeat,
              radial-gradient(circle, var(--trait-fort) 1.2px, transparent 1.6px) bottom / 3px 3px no-repeat;
}
.bib::before { left: 3px; }
.bib::after { right: 3px; }

.targets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 4px; }
.target { border: 1px solid var(--trait); border-radius: var(--r-sm); padding: 5px 10px; font: 400 14px var(--f-mono); font-variant-numeric: tabular-nums; }
.target b { font-weight: 600; }

/* Tests */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; height: 40px; padding: 0 14px; border-radius: var(--r-sm); border: 1.5px solid var(--trait-fort); background: transparent; color: var(--encre); font: 600 15px var(--f-texte); cursor: pointer; }
.tab[aria-selected="true"] { background: var(--encre); color: var(--papier); border-color: var(--encre); }
.test-panel { padding: 20px; display: flex; flex-direction: column; gap: 16px; margin-top: 10px; }
.test-panel p { margin: 0; color: var(--encre-2); max-width: 62ch; }
.fields { display: flex; flex-wrap: wrap; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 160px; min-width: 0; }
.field label { font-size: 14px; font-weight: 600; color: var(--encre-2); }
.field input, .field select {
  height: 48px; border-radius: var(--r-sm); border: 1.5px solid var(--trait-fort); background: var(--papier); color: var(--encre);
  font: 500 18px var(--f-mono); padding: 0 12px; width: 100%; font-variant-numeric: tabular-nums;
}
.field select { font-family: var(--f-texte); font-size: 16px; }
.field input:focus, .field select:focus { outline: none; border-color: var(--nuit); box-shadow: 0 0 0 3px var(--voile); }
.result { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; border-top: 1px solid var(--trait); padding-top: 16px; }
.result-value { font: 600 30px var(--f-mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.result-value small { font-size: 14px; color: var(--encre-2); font-weight: 400; letter-spacing: 0; }
.btn { height: 46px; padding: 0 18px; border-radius: var(--r-sm); border: 0; background: var(--tartan); color: var(--sur-tartan); font: 700 16px var(--f-texte); cursor: pointer; }
.btn:disabled { opacity: .4; cursor: default; }

/* Conseils */
.faq { border-top: 2px solid var(--encre); }
.faq details { border-bottom: 1px solid var(--trait); }
.faq summary { padding: 16px 0; font: 700 18px/1.35 var(--f-display); }
.faq details p { margin: 0 0 18px; color: var(--encre-2); max-width: 65ch; }

.footer { padding-block: 64px calc(40px + env(safe-area-inset-bottom, 0px)); color: var(--encre-2); font-size: 14px; }
.footer p { margin: 0; max-width: 65ch; }

:focus-visible { outline: 2px solid var(--nuit); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .minibar { transition: none; }
}
