/* base.css — reset, typographie (3 rôles), coquille et mise en page. Tout passe par les tokens. */

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

html {
  font-family: var(--police);
  font-size: 16px;
  line-height: var(--i-corps);
  background: var(--fond);
  color: var(--texte);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: anywhere;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--fond);
  color: var(--texte);
  font-size: var(--t-corps);
  font-weight: var(--p-corps);
  font-variation-settings: "opsz" var(--o-corps);
  overscroll-behavior-y: contain;
}

html.has-sheet body {
  overflow: hidden;
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
figure {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

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

:focus {
  outline: none;
}

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

::selection {
  background: var(--accent);
  color: var(--sur-accent);
}

/* ---------- Rôles typographiques ---------- */

.t-hero {
  font-size: var(--t-hero);
  font-weight: var(--p-hero);
  line-height: var(--i-hero);
  letter-spacing: var(--s-hero);
  font-variation-settings: "opsz" var(--o-hero);
  font-variant-numeric: var(--chiffres);
}

.t-titre {
  font-size: var(--t-titre);
  font-weight: var(--p-titre);
  line-height: var(--i-titre);
  letter-spacing: var(--s-titre);
  font-variation-settings: "opsz" var(--o-titre);
}

.t-sous-titre {
  font-size: var(--t-sous-titre);
  font-weight: var(--p-sous-titre);
  line-height: var(--i-sous-titre);
  letter-spacing: var(--s-sous-titre);
  font-variation-settings: "opsz" var(--o-sous-titre);
}

.t-corps-fort {
  font-size: var(--t-corps-fort);
  font-weight: var(--p-corps-fort);
  line-height: var(--i-corps-fort);
  font-variation-settings: "opsz" var(--o-corps-fort);
}

.t-corps {
  font-size: var(--t-corps);
  font-weight: var(--p-corps);
  line-height: var(--i-corps);
}

.t-secondaire,
.muted {
  font-size: var(--t-secondaire);
  font-weight: var(--p-secondaire);
  line-height: var(--i-secondaire);
  font-variation-settings: "opsz" var(--o-secondaire);
  color: var(--texte-2);
}

.t-legende {
  font-size: var(--t-legende);
  font-weight: var(--p-legende);
  line-height: var(--i-legende);
  letter-spacing: var(--s-legende);
  font-variation-settings: "opsz" var(--o-legende);
}

/* Chiffres : toujours tabulaires */
.num,
.numflow,
.t-chiffre,
.t-chiffre-l,
.t-chiffre-s,
input[type="number"],
input[inputmode="decimal"],
input[inputmode="numeric"] {
  font-variant-numeric: var(--chiffres);
}

.t-chiffre {
  font-size: var(--t-chiffre);
  font-weight: var(--p-chiffre);
  line-height: var(--i-chiffre);
}

.t-chiffre-l {
  font-size: var(--t-chiffre-l);
  font-weight: var(--p-chiffre-l);
  line-height: var(--i-chiffre-l);
  letter-spacing: var(--s-chiffre-l);
  font-variation-settings: "opsz" var(--o-chiffre-l);
}

.t-chiffre-s {
  font-size: var(--t-chiffre-s);
  font-weight: var(--p-chiffre-s);
  line-height: var(--i-chiffre-s);
}

/* Unité après un chiffre : plus petite, secondaire (règle des unités) */
.unit {
  font-size: var(--t-secondaire);
  font-weight: var(--p-secondaire);
  color: var(--texte-2);
}

/* ---------- Coquille ---------- */

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app__main {
  flex: 1;
  width: 100%;
  padding: 0 var(--marge-ecran) calc(var(--h-nav) + env(safe-area-inset-bottom, 0px) + var(--e-8));
  padding-top: env(safe-area-inset-top, 0px);
}

.screen {
  max-width: 100%;
  margin: 0 auto;
}

/* Colonne unique centrée entre 640 et 1023 px */
@media (min-width: 640px) {
  .screen {
    max-width: var(--l-colonne);
  }
}

/* Bureau : nav en colonne de 72 px à gauche, contenu en deux colonnes */
@media (min-width: 1024px) {
  .app {
    flex-direction: row;
  }

  .app__main {
    padding-left: calc(var(--l-nav-bureau) + var(--marge-ecran));
    padding-bottom: var(--e-12);
  }

  .screen {
    max-width: var(--l-max);
  }

  .screen--split {
    display: grid;
    grid-template-columns: var(--l-gauche) minmax(0, var(--l-droite));
    column-gap: var(--l-gouttiere);
    align-items: start;
  }

  .screen__aside {
    position: sticky;
    top: var(--e-6);
  }
}

/* ---------- Utilitaires ---------- */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  width: 22px;
  height: 22px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stack > * + * {
  margin-top: var(--e-4);
}

.row-flex {
  display: flex;
  align-items: center;
  gap: var(--e-3);
}

.grow {
  flex: 1;
  min-width: 0;
}

.right {
  text-align: right;
}

.hidden {
  display: none !important;
}

.sep {
  height: 1px;
  background: var(--bordure);
  border: 0;
  margin: 0;
}

/* Section = titre à gauche, valeur à droite, délimitée par l'espace (pas une carte) */
.section {
  margin-top: var(--e-8);
}

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--e-3);
  min-height: var(--h-cible);
}

.section__title {
  font-size: var(--t-sous-titre);
  font-weight: var(--p-sous-titre);
  line-height: var(--i-sous-titre);
  letter-spacing: var(--s-sous-titre);
  font-variation-settings: "opsz" var(--o-sous-titre);
}

.section__value {
  font-size: var(--t-chiffre-l);
  font-weight: var(--p-chiffre-l);
  line-height: var(--i-chiffre-l);
  font-variant-numeric: var(--chiffres);
  white-space: nowrap;
}

.section__value .unit {
  margin-left: 0.15em;
}

/* Ligne de section compacte (Fasting / Lanja / Vidiny) */
.line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--e-3);
  min-height: var(--h-cible);
  padding: var(--e-2) 0;
  border-top: 1px solid var(--bordure);
}

.line:first-of-type {
  border-top: 0;
}

.line__label {
  font-size: var(--t-corps-fort);
  font-weight: var(--p-corps-fort);
}

.line__value {
  font-variant-numeric: var(--chiffres);
  font-weight: var(--p-chiffre);
  text-align: right;
  white-space: nowrap;
}

.line__hint {
  color: var(--texte-2);
  font-size: var(--t-secondaire);
}

/* L'attribut hidden l'emporte sur tout display de classe. */
[hidden] {
  display: none !important;
}

/* Pendant l'onboarding, pas de nav ni de marge de nav. */
.app[data-screen="onboarding"] .nav {
  display: none;
}

.app[data-screen="onboarding"] .app__main {
  padding-bottom: var(--e-8);
}
