/* ==========================================================================
   TRAIL SCIENTIST — BASE (charte v1.2 « filets de mesure »)
   Reset, typographie (Fraunces/Inter/JetBrains Mono), boutons graphite,
   formulaires filets, sliders fins, focus glacier.
   ========================================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font-ui);
  font-size: var(--ts-fs-base);
  background: var(--craie);
  color: var(--graphite);
  min-height: 100vh;
  line-height: 1.45;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  font-variation-settings: 'opsz' auto, 'wght' 600;
  line-height: 1.15;
}

a { color: var(--ink-2); text-decoration-color: var(--glacier); text-underline-offset: 2px; }
a:hover { color: var(--graphite); }

button { font-family: inherit; color: inherit; }

img, svg { max-width: 100%; }

/* TOUS les chiffres, valeurs, unités, dates : JetBrains Mono (L-008) */
.num, .kpi-val, .sval, .sp-val, .charge-stat-val, .sleep-kpi-val, .perf-kpi-val,
.activity-charge, .palm-score, .palm-time, .fcp-rec-bpm, .rec-card-best, .obj-badge-days,
.date-lbl, .activity-meta, .cal-num, .team-metric-val, .gauge-scale, .big-val {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
}

/* Focus visible — outline 2px glacier (charte §6) */
button:focus-visible, a:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--glacier);
  outline-offset: 1px;
  box-shadow: none;
}

/* ---- Boutons — primaire graphite, secondaire filet granite ------------------- */
.btn {
  border-radius: var(--radius);
  padding: 7px 14px;
  font-size: var(--ts-fs-base);
  cursor: pointer;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  letter-spacing: 0.02em;
}
/* primaires (ex btn-green/btn-blue) : graphite, hover = --ts-primary-hover (tokens) */
.btn-green, .btn-blue {
  background: var(--graphite); color: var(--craie); border-color: var(--graphite);
}
.btn-green:hover, .btn-blue:hover { background: var(--ts-primary-hover); }
/* bouton Strava : marque tierce, seule exception colorée (consignée) */
.btn-orange { background: var(--ts-brand-strava); color: var(--carte); border-color: var(--ts-brand-strava); }
.btn-orange:hover { filter: brightness(0.92); }
/* secondaire : bordure granite */
.btn-ghost { background: var(--carte); color: var(--ink-2); border-color: var(--granite); }
.btn-ghost:hover { border-color: var(--granite-fonce); color: var(--graphite); }
/* destructif : filet alert, jamais d'aplat (L-005) */
.btn-danger { background: var(--tint-alert); color: var(--data-alert-text); border-color: var(--data-alert); }
.btn-danger:hover { background: var(--signal-soft); filter: brightness(0.97); }
.btn-sm { padding: 5px 11px; font-size: var(--ts-fs-sm); min-height: 26px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ---- Formulaires — filets ------------------------------------------------------ */
.text-in, input[type="date"], input[type="number"], input[type="url"],
input[type="text"], select, textarea {
  width: 100%;
  border: var(--filet);
  border-radius: var(--radius);
  padding: 7px 11px;
  font-size: var(--ts-fs-base);
  color: var(--graphite);
  background: var(--carte);
  font-family: inherit;
}
input[type="date"], input[type="number"] { font-family: var(--font-data); }
.text-in:focus, input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--graphite);
}

.flbl { font-size: var(--ts-fs-base); color: var(--ink-2); margin-bottom: 4px; display: block; }
.frow { margin-bottom: 11px; }
.fsec {
  font-size: var(--ts-fs-xs); color: var(--granite-fonce);
  text-transform: uppercase; letter-spacing: 0.1em;
  margin: 1.125rem 0 7px; padding-top: 1.125rem;
  border-top: var(--filet-int);
  font-family: var(--font-ui); font-weight: 600;
}
.fsec:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }

/* Sliders fins : piste granite 2px, poignée graphite, valeur mono affichée à côté */
.slider-row { display: flex; align-items: center; gap: 9px; }
.slider-row input[type="range"] {
  flex: 1; min-height: 24px; appearance: none; -webkit-appearance: none;
  background: transparent;
}
.slider-row input[type="range"]::-webkit-slider-runnable-track {
  height: 2px; background: var(--granite); border-radius: 0;
}
.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--graphite); border: 2px solid var(--carte);
  box-shadow: 0 0 0 1px var(--granite-fonce); margin-top: -6px; cursor: pointer;
}
.slider-row input[type="range"]::-moz-range-track { height: 2px; background: var(--granite); }
.slider-row input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%; background: var(--graphite);
  border: 2px solid var(--carte); box-shadow: 0 0 0 1px var(--granite-fonce); cursor: pointer;
}
.sval { font-size: var(--ts-fs-md); font-weight: 600; min-width: 46px; text-align: right; }
.wavg { font-size: var(--ts-fs-xs); color: var(--granite-fonce); margin-top: 3px; font-family: var(--font-data); }

/* ---- Utilitaires ----------------------------------------------------------------- */
.muted { color: var(--granite-fonce); }
.small { font-size: var(--ts-fs-sm); }
.mt-2 { margin-top: var(--ts-sp-2); }
.hidden { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Règle éditoriale épaisse-fine (L-014) : sépare les grandes sections */
.rule-editorial {
  border: none; height: 4px; margin: 18px 0;
  border-top: 3px solid var(--graphite);
  border-bottom: 1px solid var(--granite);
}

.sp-circle {
  width: 20px; height: 20px;
  border: 2px solid var(--granite);
  border-top-color: var(--graphite);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
