/* UB Trainer - Calculateur de vitesse critique */

@font-face {
  font-family: 'Heros Cn';
  src: url('assets/fonts/texgyreheroscn-bold.otf') format('opentype');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Heros';
  src: url('assets/fonts/texgyreheros-regular.otf') format('opentype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Heros';
  src: url('assets/fonts/texgyreheros-bold.otf') format('opentype');
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #000000;
  --surface: #272A30;
  --surface-2: #1B1D22;
  --border: #3A3E46;
  --text: #F4F4F5;
  --muted: #A9AEB7;
  --accent: #009BB1;
  --on-accent: #000000;
  --error: #FF8A80;
  --radius: 6px;
  --font: 'Heros', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-cn: 'Heros Cn', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

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.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }

a { color: var(--accent); text-underline-offset: 2px; }

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

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- En-tête ---------- */

.site-header {
  display: flex;
  justify-content: center;
  padding: 28px 16px 8px;
}
.logo { height: 44px; width: auto; display: block; }
.logo-fallback {
  font-family: var(--font-cn);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.04em;
}

.intro { text-align: center; padding: 24px 0 28px; }

.eyebrow {
  font-family: var(--font-cn);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

h1 {
  font-family: var(--font-cn);
  font-weight: 700;
  font-size: clamp(34px, 10vw, 54px);
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}

.lead {
  color: var(--muted);
  margin: 14px auto 0;
  max-width: 34em;
}

/* ---------- Cartes ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
}

.section-title, .card-title {
  font-family: var(--font-cn);
  font-weight: 700;
  font-size: 22px;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--accent);
}

section > .section-title { margin-bottom: 12px; }
.card > .section-title { margin-bottom: 8px; }

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

/* ---------- Formulaire ---------- */

.form { display: grid; gap: 16px; }

fieldset.card { margin: 0; min-width: 0; }

.card-title { float: left; width: 100%; padding: 0; }
.card-title + * { clear: both; }

.hint { color: var(--muted); font-size: 14px; margin: 4px 0 16px; }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.segmented label { position: relative; display: flex; }
.segmented input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}
.segmented span {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 44px;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1.25;
  color: var(--muted);
  border: 1px solid transparent;
}
.segmented input:checked + span {
  color: var(--text);
  background: var(--surface);
  border-color: var(--accent);
  font-weight: 700;
}
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

.field + .field { margin-top: 14px; }

.field-label {
  display: block;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 6px;
}
.optional { font-weight: 400; color: var(--muted); font-size: 14px; }

.input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  font: inherit;
  font-size: 18px; /* >= 16px : pas de zoom auto sur iOS */
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder { color: #7D828C; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.input[aria-invalid='true'] { border-color: var(--error); }

.field-error { color: var(--error); font-size: 14px; margin-top: 6px; }
.field-error:empty { display: none; }

.form-error {
  color: var(--error);
  border: 1px solid var(--error);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-weight: 700;
}

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 12px 20px;
  font-family: var(--font-cn);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  text-decoration: none;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: #00B2CB; }
.btn-outline { background: transparent; color: var(--accent); }
.btn-outline:hover { background: rgba(0, 155, 177, 0.12); }
.btn-block { width: 100%; }

/* ---------- Résultats ---------- */

.results { display: grid; gap: 28px; margin-top: 40px; }
.results:focus { outline: none; }
.results > *, .form > * { min-width: 0; }

.hero { text-align: center; padding: 28px 16px; }
.hero-value {
  font-family: var(--font-cn);
  font-weight: 700;
  line-height: 1;
  margin-top: 8px;
}
.hero-value .accent { font-size: clamp(64px, 20vw, 96px); }
.hero-value .unit { font-size: 26px; color: var(--muted); }
.hero-pace {
  font-family: var(--font-cn);
  font-weight: 700;
  font-size: 30px;
  margin-top: 8px;
}

.big-value {
  font-family: var(--font-cn);
  font-weight: 700;
  font-size: 48px;
  line-height: 1;
}

.gauge { margin: 16px 0 18px; }
.gauge-track {
  position: relative;
  height: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 3px;
}
.gauge-tick {
  position: absolute;
  top: -5px;
  width: 1px;
  height: 14px;
  background: var(--muted);
}
.gauge-marker {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  transform: translate(-50%, -50%);
}
.gauge-labels {
  position: relative;
  height: 18px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.gauge-labels span { position: absolute; transform: translateX(-50%); }
.gauge-labels span:first-child { left: 0; transform: none; }
.gauge-labels span:last-child { right: 0; transform: none; }

.analysis { color: var(--text); }

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

.stat { padding: 16px; }
.stat-label {
  font-family: var(--font-cn);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-size: 15px;
}
.stat-value {
  font-family: var(--font-cn);
  font-weight: 700;
  font-size: 30px;
  line-height: 1.1;
  margin-top: 6px;
}
.stat-value .unit { font-size: 18px; }
.stat-sub { color: var(--muted); font-size: 15px; margin-top: 2px; }

.zones { display: grid; gap: 10px; }

.zone { padding: 14px 16px; }
.zone-head { display: flex; align-items: baseline; gap: 10px; }
.zone-id {
  font-family: var(--font-cn);
  font-weight: 700;
  font-size: 20px;
  color: var(--accent);
}
.zone-name {
  font-family: var(--font-cn);
  font-weight: 700;
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.zone-pct { color: var(--muted); font-size: 13px; }
.zone-values {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin-top: 6px;
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.zone-usage { color: var(--muted); font-size: 14px; margin-top: 4px; }

.table-card { padding: 4px 0; overflow-x: auto; }
.predictions {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
}
.predictions th, .predictions td { padding: 12px 10px; text-align: right; white-space: nowrap; }
.predictions th:first-child, .predictions td:first-child { text-align: left; padding-left: 14px; }
.predictions th:last-child, .predictions td:last-child { padding-right: 14px; }
.predictions th {
  font-family: var(--font-cn);
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.predictions tbody tr { border-top: 1px solid var(--border); }
.predictions td:first-child { font-weight: 700; white-space: normal; }
.predictions .time { color: var(--accent); font-weight: 700; }

.note { color: var(--muted); font-size: 14px; margin-top: 10px; }

.copy-status { color: var(--muted); font-size: 14px; text-align: center; margin-top: 8px; min-height: 1.5em; }

.cta { padding: 24px 16px; text-align: center; }
.cta-title {
  font-family: var(--font-cn);
  font-weight: 700;
  font-size: 26px;
  line-height: 1.1;
  text-transform: uppercase;
}
.cta-text { color: var(--muted); margin-top: 10px; }
.cta-buttons { display: grid; gap: 10px; margin-top: 20px; }

/* ---------- Pied de page ---------- */

.site-footer {
  max-width: 720px;
  margin: 40px auto 0;
  padding: 24px 16px 40px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* ---------- Écrans plus larges ---------- */

@media (min-width: 640px) {
  .form { grid-template-columns: 1fr 1fr; }
  .form .form-error, .form .btn { grid-column: 1 / -1; }
  .card { padding: 24px; }
  .zones { grid-template-columns: 1fr 1fr; }
  .zones > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .cta-buttons { grid-template-columns: 1fr 1fr; }
  .predictions { font-size: 16px; }
}

@media (max-width: 399px) {
  .predictions th, .predictions td { padding: 10px 5px; font-size: 13px; }
  .predictions th { font-size: 12px; letter-spacing: 0.02em; }
  .predictions th:first-child, .predictions td:first-child { padding-left: 10px; }
  .predictions th:last-child, .predictions td:last-child { padding-right: 10px; }
}
