/* ==========================================================================
   Le ciel se dégage : socle commun (accueil et technique)
   ========================================================================== */

/* ---------- Polices (OFL, hébergées localement, sous-ensemble latin) ---------- */
@font-face {
  font-family: "Radio Canada Big";
  src: url("../fonts/radio-canada-big.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Radio Canada";
  src: url("../fonts/radio-canada.woff2") format("woff2");
  font-weight: 300 700;
  font-stretch: 75% 100%;
  font-style: normal;
  font-display: swap;
}
/* Replis calés sur les métriques de Radio Canada : pas de saut au chargement */
@font-face {
  font-family: "RC Repli";
  src: local("Arial"), local("ArialMT"), local("Helvetica Neue"), local("Roboto");
  size-adjust: 103.6%;
  ascent-override: 91.3%;
  descent-override: 24.6%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "RCB Repli";
  src: local("Arial Bold"), local("Arial-BoldMT"), local("Helvetica Neue Bold"), local("Roboto Bold");
  font-weight: 500 700;
  size-adjust: 93.7%;
  ascent-override: 106.2%;
  descent-override: 32.6%;
  line-gap-override: 0%;
}

/* ---------- Le ciel : seul grand champ de couleur ----------
   Trois états fixes (couvert, éclaircie, dégagé). Le récit de l'accueil ne règle
   que l'opacité des calques .sky-b et .sky-c : aucun recalcul de style.
   Les deux seuls éléments calés sur le ciel (barre collante, fond de la scène)
   reçoivent leurs couleurs par --bg-a et --bg-b, non héritées. */
@property --bg-a {
  syntax: "<color>";
  inherits: false;
  initial-value: #a3a6aa;
}
@property --bg-b {
  syntax: "<color>";
  inherits: false;
  initial-value: #cbc8c1;
}

:root {
  /* ciel : couvert (a), éclaircie (b), dégagé (c), du haut (0) vers le bas (1) */
  --sky-a0: #a3a6aa;
  --sky-a1: #cbc8c1;
  --sky-b0: #b4c6d3;
  --sky-b1: #dce3e6;
  --sky-c0: #7fb8e6;
  --sky-c1: #e9f3fa;

  /* encres */
  --ink: #16171a;          /* carbone : texte, boutons */
  --ink-2: #33363c;        /* secondaire, AA sur le ciel le plus sombre */
  --ink-3: rgba(22, 23, 26, 0.56); /* filets, axes ; jamais du texte courant */
  --hair: rgba(22, 23, 26, 0.22);
  --paper: #f3f3ef;        /* texte clair sur encre */

  /* atomes et matières : réservés aux illustrations */
  --atom-c: #1e1f23;
  --atom-h: #f3f3ef;
  --atom-o: #e2412f;
  --bond: #c9cbcf;
  --bact: #f28ca8;
  --bact-2: #e7799a;
  --kelp: #9c6a2c;
  --kelp-2: #c99a47;
  --ember: #ff7a1f;

  /* typographie */
  --f-big: "Radio Canada Big", "RCB Repli", "Radio Canada", system-ui, sans-serif;
  --f-text: "Radio Canada", "RC Repli", system-ui, sans-serif;

  --step--1: clamp(0.875rem, 0.84rem + 0.15vw, 0.95rem);
  --step-0: clamp(1.0625rem, 1.02rem + 0.2vw, 1.15rem);
  --step-1: clamp(1.25rem, 1.12rem + 0.55vw, 1.55rem);
  --step-2: clamp(1.45rem, 1.18rem + 1.15vw, 2.15rem);
  --step-3: clamp(1.8rem, 1.3rem + 2.1vw, 3rem);
  --step-4: clamp(2.35rem, 1rem + 5.4vw, 5.6rem);
  --step-big: clamp(4.75rem, 1.6rem + 13.5vw, 13rem);

  /* espace */
  --gutter: clamp(16px, 5.2vw, 96px);
  --measure: 36rem;
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: 4.5rem;
  --s-9: 7rem;
  --s-10: 10rem;

  /* mouvement : ressorts amortis critiques, traduits en courbes */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-io: cubic-bezier(0.65, 0, 0.35, 1);
  --t-press: 100ms;

  --bar-h: 56px;

  color-scheme: light;
  accent-color: var(--ink);
}

/* ---------- Remise à zéro mesurée ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--bar-h) + 16px);
  scrollbar-color: rgba(22, 23, 26, 0.45) transparent;
}
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}
body {
  margin: 0;
  min-height: 100svh;
  font-family: var(--f-text);
  font-size: var(--step-0);
  font-weight: 400;
  line-height: 1.55;
  color: var(--ink);
  /* repli solide : le ciel fixe le recouvre (il suit l'état du ciel, voir home.js) */
  background: var(--sky-a1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
  overflow-x: clip;
}
img,
svg,
canvas {
  display: block;
  max-width: 100%;
}
p,
h1,
h2,
h3,
h4,
ul,
ol,
figure,
blockquote {
  margin: 0;
}
ul,
ol {
  padding: 0;
  list-style: none;
}
button {
  font: inherit;
  color: inherit;
}
strong,
b {
  font-weight: 650;
}
sub,
sup {
  font-size: 0.64em;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}
sub {
  bottom: -0.22em;
}
sup {
  top: -0.5em;
}
::selection {
  background: var(--ink);
  color: var(--paper);
}
:focus-visible {
  outline: 2.5px solid var(--ink);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ---------- iOS : numéros détectés comme téléphones (les deux couches sont nécessaires) ---------- */
a[x-apple-data-detectors] {
  color: inherit !important;
  text-decoration: none !important;
  font-size: inherit !important;
  font-weight: inherit !important;
  font-family: inherit !important;
  line-height: inherit !important;
  pointer-events: none;
}
a[href^="tel"] {
  color: inherit !important;
  text-decoration: none !important;
  pointer-events: none;
}

/* ---------- Utilitaires ---------- */
[hidden] {
  display: none !important;
}
.vh {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.nb {
  white-space: nowrap;
}
/* lien d'évitement : invisible hors focus (le rebond d'iOS ne le révèle plus) */
.skip {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 100;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  opacity: 0;
  pointer-events: none;
  clip-path: inset(50%);
  transform: translateY(-6px);
  transition: opacity 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}
.skip:focus-visible {
  opacity: 1;
  pointer-events: auto;
  clip-path: none;
  transform: none;
}

/* ---------- Ciel fixe et champ moléculaire ---------- */
/* Calques fixes à hauteur stable (100lvh, sans bottom) : la barre d'outils d'iOS
   qui apparaît ou disparaît ne les redimensionne pas. */
.sky {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 100vh;
  height: 100lvh;
  z-index: -2;
  pointer-events: none;
}
.sky-l {
  position: absolute;
  inset: 0;
}
.sky-a {
  /* une trouée de ciel bleu dans le couvert, en bas à droite : la promesse du ciel dégagé
     (même calcul dans le brouillard de field.js) */
  background:
    radial-gradient(120% 90% at 92% 112%, rgba(127, 184, 230, 0.55) 0%, rgba(127, 184, 230, 0) 62%),
    linear-gradient(180deg, var(--sky-a0) 0%, var(--sky-a1) 100%);
}
.sky-b {
  background: linear-gradient(180deg, var(--sky-b0) 0%, var(--sky-b1) 100%);
  opacity: 0;
  will-change: opacity;
}
.sky-c {
  background: linear-gradient(180deg, var(--sky-c0) 0%, var(--sky-c1) 100%);
  opacity: 0;
  will-change: opacity;
}
.field {
  position: fixed;
  top: 0;
  left: 0;
  z-index: -1;
  width: 100%;
  height: 100vh;
  height: 100lvh;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.9s var(--ease-out);
}
.field.is-on {
  opacity: 1;
}
.field-still {
  position: fixed;
  top: 0;
  left: 0;
  z-index: -1;
  display: none;
  width: 100%;
  height: 100vh;
  height: 100lvh;
  object-fit: cover;
  object-position: 70% 50%;
  pointer-events: none;
}
.no-webgl .field-still {
  display: block;
}

/* ---------- Icônes dessinées ---------- */
.ic {
  width: 1.5rem;
  height: 1.5rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Liens et boutons ---------- */
a {
  color: inherit;
}
.lnk {
  color: var(--ink);
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor), linear-gradient(var(--hair), var(--hair));
  background-size: 0% 1.5px, 100% 1.5px;
  background-position: 0 100%, 0 100%;
  background-repeat: no-repeat;
  padding-bottom: 2px;
  transition: background-size 0.45s var(--ease-out);
}
.lnk:hover,
.lnk:focus-visible {
  background-size: 100% 1.5px, 100% 1.5px;
}

.btn {
  --btn-bg: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  min-height: 52px;
  padding: 0.8rem 1.5rem 0.8rem 1.6rem;
  border: 0;
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--paper);
  font-family: var(--f-text);
  font-size: var(--step-0);
  font-weight: 560;
  letter-spacing: -0.005em;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 1px 1px rgba(22, 23, 26, 0.18), 0 10px 24px -12px rgba(22, 23, 26, 0.55);
  transition: transform var(--t-press) ease-out, box-shadow 0.3s var(--ease-out), background-color 0.3s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn .ic {
  width: 1.25rem;
  height: 1.25rem;
  stroke-width: 2;
  transition: transform 0.4s var(--ease-out);
}
.btn:hover {
  --btn-bg: #24262b;
  box-shadow: 0 1px 1px rgba(22, 23, 26, 0.18), 0 14px 30px -12px rgba(22, 23, 26, 0.6);
}
.btn:active,
.btn.is-pressed {
  transform: scale(0.97);
}
.btn:focus-visible {
  outline-offset: 4px;
  border-radius: 999px;
}

/* bouton rond discret (pause des molécules) */
.round {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1.5px solid rgba(22, 23, 26, 0.32);
  border-radius: 50%;
  background: rgba(243, 243, 239, 0.42);
  color: var(--ink);
  cursor: pointer;
  transition: transform var(--t-press) ease-out, background-color 0.3s var(--ease-out), border-color 0.3s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.round:hover {
  background: rgba(243, 243, 239, 0.72);
  border-color: rgba(22, 23, 26, 0.55);
}
.round:active {
  transform: scale(0.97);
}
.round .ic {
  width: 20px;
  height: 20px;
  stroke-width: 2.1;
}
.round:focus-visible {
  border-radius: 50%;
}

/* ---------- Repli « Lire l'explication » ---------- */
.fold {
  max-width: var(--measure);
  margin-top: var(--s-5);
}
.fold > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.35rem 0.25rem 0.35rem 0;
  font-weight: 560;
  cursor: pointer;
  list-style: none;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
.fold > summary::-webkit-details-marker {
  display: none;
}
.fold > summary .ic {
  width: 1.15rem;
  height: 1.15rem;
  stroke-width: 2;
  transition: transform 0.35s var(--ease-out);
}
.fold > summary .when-open {
  display: none;
}
.fold[open] > summary .when-open {
  display: inline;
}
.fold[open] > summary .when-closed {
  display: none;
}
.fold[open] > summary .ic {
  transform: rotate(180deg);
}
.fold > summary span {
  background-image: linear-gradient(currentColor, currentColor), linear-gradient(var(--hair), var(--hair));
  background-size: 0% 1.5px, 100% 1.5px;
  background-position: 0 100%, 0 100%;
  background-repeat: no-repeat;
  padding-bottom: 2px;
  transition: background-size 0.45s var(--ease-out);
}
.fold > summary:hover span {
  background-size: 100% 1.5px, 100% 1.5px;
}
.fold-body {
  padding-top: var(--s-3);
}
.fold-body > * + * {
  margin-top: 1em;
}

/* ---------- Typographie de base ---------- */
h1,
h2,
h3,
.display {
  font-family: var(--f-big);
  font-weight: 620;
  text-wrap: balance;
  font-kerning: normal;
}
p,
li,
dd,
dt,
figcaption,
summary {
  text-wrap: pretty;
}
.key,
.tag,
.lane-t,
.g-l,
.l6-t,
.pan dt,
.net-l,
.thermo-l,
.curve-ax,
.map-cap,
.m150-txt,
.m150-detail,
.zt p,
.tl-a,
.tl-b,
.tl-c,
.end-kick,
.cta-sub,
.lbl,
.note-q {
  text-wrap: balance;
}
.tnum {
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Le kit plat : les mêmes atomes que la 3D, en 2D
   ========================================================================== */
.atom .a-body {
  stroke-width: 0;
}
.a-C .a-body {
  fill: var(--atom-c);
}
.a-H .a-body {
  fill: var(--atom-h);
  stroke: rgba(22, 23, 26, 0.55);
  stroke-width: 1.3;
}
.a-O .a-body {
  fill: var(--atom-o);
}
.a-hi {
  fill: rgba(255, 255, 255, 0.42);
}
.a-H .a-hi {
  fill: rgba(255, 255, 255, 0.9);
}
.bond {
  stroke: #8d9097;
  stroke-width: 3.4;
  stroke-linecap: round;
}
.bond-thin {
  stroke-width: 2.1;
}

/* ---------- Gravité : 1 à 3 points dessinés, toujours avec leur libellé ---------- */
.grav {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.grav-dots {
  display: inline-flex;
  gap: 4px;
}
.grav-dots i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.75px var(--ink);
}
[data-g="1"] .grav-dots i:nth-child(-n + 1),
[data-g="2"] .grav-dots i:nth-child(-n + 2),
[data-g="3"] .grav-dots i:nth-child(-n + 3) {
  background: var(--atom-c);
}
.grav-t {
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--ink-2);
}

/* ---------- Mouvement réduit : rien ne reste caché ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
  /* le ciel change par paliers, en fondu */
  .sky-b,
  .sky-c {
    transition: opacity 1.2s ease;
  }
}
@media (prefers-reduced-transparency: reduce) {
  .round {
    background: var(--paper);
  }
}
