/* Jetons du design system. Mode clair uniquement : color-scheme le declare,
   donc les controles natifs (sliders, barres de defilement) restent clairs
   meme si le systeme est en sombre. */
body {
  color-scheme: light only;
  --page:           #f9f9f7;
  --surface-1:      #fcfcfb;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --bordure:        rgba(11, 11, 11, 0.10);
  --accent:         #2a78d6;   /* meme famille que la rampe du champ */
  --piste:          #e1e0d9;
  --avertissement:  #fab219;
}
* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 20px;
  /* Hauteur fixee a l'ecran : c'est la colonne de droite qui defile, pas la
     page. Sinon la carte 3D grandit avec elle et sort du cadre visible. */
  height: 100vh;
  overflow: hidden;
  background: var(--page);
  color: var(--text-primary);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* --- en-tete --------------------------------------------------------- */
.entete {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  flex-wrap: wrap;
}
h1 { font-size: 19px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.trace, .sous-titre {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}
.sous-titre { max-width: 40ch; text-align: right; }

.alerte {
  margin: 0;
  padding: 10px 14px 10px 12px;
  border-left: 3px solid var(--avertissement);
  border-radius: 6px;
  background: var(--surface-1);
  font-size: 13px;
  color: var(--text-secondary);
}
.alerte::before { content: "⚠ "; color: var(--avertissement); }

/* --- structure ------------------------------------------------------- */
main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
}
.colonne {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.carte {
  background: var(--surface-1);
  border: 1px solid var(--bordure);
  border-radius: 14px;
  padding: 18px 20px;
}
.carte-vue { padding: 8px; position: relative; display: flex; }
#vue { flex: 1; min-height: 420px; }
.chargement {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  margin: 0; color: var(--text-muted);
}
/* display:flex ci-dessus l'emporte sur l'attribut hidden : sans cette regle,
   le message reste affiche par-dessus le maillage une fois charge. */
.chargement[hidden] { display: none; }

h2 {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.bascule {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}
.bascule input { accent-color: var(--accent); margin: 0; }

/* Les indices (Q120, Tmax, cp...) ne doivent pas ecarter les lignes. */
sub { font-size: 0.72em; line-height: 0; }

.note {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
}

/* --- tuile de resultat ----------------------------------------------- */
/* Figures proportionnelles sur le grand nombre : tabular-nums donne a
   chaque chiffre la largeur d'un 0, ce qui delave un nombre a cette taille. */
.hero {
  margin: 0;
  font-size: 52px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
}
.hero-unite {
  font-size: 20px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 6px;
}
.valeurs {
  width: 100%;
  margin-top: 16px;
  border-collapse: collapse;
  font-size: 13px;
}
.valeurs caption {
  caption-side: top;
  text-align: left;
  padding-bottom: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.valeurs th {
  text-align: left;
  font-weight: 400;
  color: var(--text-secondary);
  padding: 3px 0;
}
.valeurs td {
  text-align: right;
  font-variant-numeric: tabular-nums;   /* colonne : les chiffres s'alignent */
  padding: 3px 0;
}
.valeurs td:last-child {
  width: 3ch;
  padding-left: 6px;
  color: var(--text-muted);
}

/* --- selecteur de vue ------------------------------------------------ */
.segmente {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--page);
  border-radius: 9px;
}
.segment {
  flex: 1;
  padding: 7px 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.segment:hover { color: var(--text-primary); }
.segment.actif {
  background: var(--surface-1);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.10);
}

/* --- parametres ------------------------------------------------------ */
.param + .param { margin-top: 18px; }
.tete { display: flex; align-items: center; gap: 6px; }
.nom { font-weight: 600; font-size: 13px; }
.unite { margin-left: auto; font-size: 12px; color: var(--text-muted); }
.aide {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1px solid var(--text-muted);
  color: var(--text-muted);
  font-size: 9px;
  font-style: italic;
  line-height: 12px;
  text-align: center;
  cursor: help;
}
.rangee { display: flex; align-items: center; gap: 10px; margin-top: 7px; }
.chip {
  flex: none;
  width: 72px;
  padding: 5px 0;
  border-radius: 7px;
  background: var(--page);
  color: var(--text-primary);
  font-size: 13px;
  font-variant-numeric: tabular-nums;   /* colonne de valeurs alignees */
  text-align: center;
}
.bornes {
  display: flex;
  justify-content: space-between;
  margin: 4px 0 0 82px;
  font-size: 11px;
  color: var(--text-muted);
}

input[type=range] {
  flex: 1;
  min-width: 0;
  height: 18px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(90deg,
    var(--accent) 0 var(--p, 50%), var(--piste) var(--p, 50%) 100%);
}
input[type=range]::-moz-range-track {
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(90deg,
    var(--accent) 0 var(--p, 50%), var(--piste) var(--p, 50%) 100%);
}
input[type=range]::-webkit-slider-thumb {
  appearance: none;
  width: 16px; height: 16px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--surface-1);
  border: 2px solid var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.20);
}
input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--surface-1);
  border: 2px solid var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.20);
}
input[type=range]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
  .sous-titre { text-align: left; }
}
