/* Socle : polices, jetons, scène, onglets, île, feuilles, squelettes, mouvement réduit — porté de maquettes/premium-v2/styles.css (rem, contraste, backdrop-filter limité aux onglets et aux feuilles) */
@font-face {
  font-family: "Archivo";
  src: url(../fonts/archivo-latin.woff2) format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url(../fonts/newsreader-italic-latin.woff2) format("woff2");
  font-style: italic;
  font-weight: 400 500;
  font-display: swap;
}

:root {
  /* Couleurs */
  --abysse: #050913;
  --encre: #0A1020;
  --ardoise: #111A2E;
  --ardoise-2: #16213A;
  --ardoise-3: #1E2B48;
  --filet: rgba(157, 176, 224, .11);
  --filet-2: rgba(157, 176, 224, .2);
  --porcelaine: #E8EDF7;
  --porcelaine-2: #C9D2E6;
  --brume: #8F9AB3;
  --brume-2: #7480A0;
  --ambre: #F2B45A;
  --ambre-doux: rgba(242, 180, 90, .13);
  --jade: #4FE0A6;
  --jade-doux: rgba(79, 224, 166, .12);
  --corail: #FF7A86;
  --corail-doux: rgba(255, 122, 134, .12);
  --pervenche: #9DB0FF;
  --pervenche-doux: rgba(157, 176, 255, .13);
  --carte: linear-gradient(180deg, #141E35, #0F182C);

  /* Échelle typographique (Archivo) et espacements (base 4) */
  --t-axe: 0.6875rem;
  --t-meta: 0.7813rem;
  --t-sec: 0.8438rem;
  --t-corps: 0.9375rem;
  --t-h2: 1.0625rem;
  --t-h3: 1.3125rem;
  --t-titre: 1.75rem;
  --t-grand: 2.25rem;
  --t-heros: 3.5rem;

  --r-xl: 28px;
  --r-l: 22px;
  --r-m: 16px;
  --r-s: 11px;
  --gouttiere: 20px;
  --barre: 68px;
  --haut-tg: var(--tg-content-safe-area-inset-top, 0px);

  /* Ressorts (même solveur que ressorts.js) : aucun dépassement, sauf le petit « vif » tactile */
  --sortie: cubic-bezier(.22, 1, .36, 1);
  --ressort: linear(0, 0.0974, 0.2816, 0.4656, 0.6189, 0.7361, 0.821, 0.8806, 0.9213, 0.9487, 0.9668, 0.9787, 0.9864, 0.9914, 0.9945, 0.9966, 0.9978, 0.9987, 1);
  --ressort-d: .87s;
  --ressort-vif: linear(0, 0.0895, 0.2727, 0.4685, 0.6391, 0.7715, 0.8662, 0.9292, 0.9683, 0.9906, 1.002, 1.0067, 1.0077, 1.007, 1.0055, 1.004, 1.0027, 1.0017, 1);
  --ressort-vif-d: .6s;
  --od-lent: 1.2s linear(0, 0.0547, 0.1726, 0.309, 0.4408, 0.5577, 0.656, 0.7361, 0.7997, 0.8493, 0.8874, 0.9164, 0.9383, 0.9547, 0.9668, 0.9758, 0.9824, 0.9872, 0.9908, 0.9934, 0.9952, 0.9966, 0.9975, 0.9982, 0.9987, 1);
  --od-rapide: .38s linear(0, 0.0607, 0.1888, 0.3338, 0.4707, 0.5895, 0.6872, 0.7649, 0.8253, 0.8713, 0.9059, 0.9317, 0.9507, 0.9645, 0.9746, 0.9819, 0.9871, 0.9909, 0.9935, 0.9954, 0.9968, 0.9977, 0.9984, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--abysse); }
body {
  font-family: "Archivo", system-ui, sans-serif;
  font-size: var(--t-corps);
  line-height: 1.45;
  color: var(--porcelaine);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  place-items: center;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
button:disabled { cursor: default; }
a { color: inherit; text-decoration: none; }
input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ambre); outline-offset: 3px; border-radius: 10px; }
svg { display: block; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }

#app {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: var(--tg-viewport-stable-height, 100%);
  background: var(--encre);
  overflow: hidden;
  isolation: isolate;
  --lx: 0;
  --ly: 0;
}
@media (min-width: 520px) and (min-height: 760px) {
  #app { height: min(100%, 880px); border-radius: 40px; box-shadow: 0 0 0 1px var(--filet), 0 50px 140px -50px #000; }
}
#app.geste { user-select: none; -webkit-user-select: none; }

/* ——— Scène et écrans ——— */
#scene { position: absolute; inset: 0; }
#app::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--barre) + 54px);
  z-index: 18;
  pointer-events: none;
  background: linear-gradient(rgba(10, 16, 32, 0), rgba(10, 16, 32, .96) 52%);
}
#app[data-route="accueil"]::after { height: calc(var(--barre) + 110px); }
#app[data-route="acces"]::after { display: none; }
.ecran {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(130% 52% at 50% -14%, rgba(96, 124, 220, .17), transparent 62%),
    var(--grain, none),
    var(--encre);
  contain: layout paint;
}
.ecran.ombre { box-shadow: -30px 0 60px -18px rgba(0, 0, 0, .75); }
.defile {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.defile::-webkit-scrollbar { display: none; }
.corps {
  position: relative;
  z-index: 1;
  padding: calc(14px + var(--haut-tg)) var(--gouttiere) calc(var(--barre) + 46px + env(safe-area-inset-bottom));
}
.ecran.accueil .corps { padding-bottom: calc(var(--barre) + 116px + env(safe-area-inset-bottom)); }
.corps:has(> .cta-zone) { padding-bottom: 0; }
.ecran.plein .corps { padding-bottom: calc(30px + env(safe-area-inset-bottom)); }

/* Couche d'aspect pendant le morphing (carte → écran) */
.fond-morph { position: absolute; inset: 0; opacity: 0; pointer-events: none; background: var(--grain, none), var(--carte); }
.fond-morph[data-style="pilote"] { background: radial-gradient(90% 60% at 14% 0%, rgba(242, 180, 90, .14), transparent 60%), var(--grain, none), linear-gradient(180deg, #17223D, #111A30); }
.fond-morph[data-style="bot"] { background: var(--grain, none), var(--ardoise); }
.ecran.en-morph { box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .8); }

/* Entrées échelonnées, une seule fois après le squelette */
.ecran:not(.joue) .e:not(.vu) { opacity: 0; }
.ecran.joue .e { animation: entree var(--ressort-d) var(--ressort) backwards; animation-delay: calc(var(--i, 0) * 42ms + 30ms); }
@keyframes entree { from { opacity: 0; transform: translate3d(0, 14px, 0); } }

/* ——— Typographie ——— */
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.titre {
  font-size: var(--t-titre);
  font-weight: 620;
  font-stretch: 114%;
  letter-spacing: -.026em;
  line-height: 1.06;
  margin: 8px 0 6px;
}
.sous { color: var(--brume); font-size: 0.875rem; margin: 0; max-width: 40ch; }
.petit { font-size: 0.8125rem; color: var(--brume); }
.aide { font-size: var(--t-meta); color: var(--brume); margin: 8px 0 0; line-height: 1.45; }
.section { margin-top: 32px; }
.section-tete { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-tete h2, h2.h { font-size: var(--t-h2); font-weight: 610; font-stretch: 106%; letter-spacing: -.012em; margin: 0; }
.section-tete .petit { font-size: var(--t-meta); text-align: right; }
.voix {
  font-family: "Newsreader", Georgia, serif;
  font-style: italic;
  font-weight: 430;
  font-size: 1.0938rem;
  line-height: 1.38;
  font-variation-settings: "opsz" 18;
  letter-spacing: -.004em;
  color: var(--porcelaine);
  margin: 0;
}
.jade { color: var(--jade); }
.corail { color: var(--corail); }
.ambre { color: var(--ambre); }
.brume { color: var(--brume); }

/* ——— Surfaces ——— */
.carte {
  position: relative;
  border-radius: var(--r-l);
  background: var(--grain, none), var(--carte);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .045), inset 0 0 0 1px var(--filet), 0 22px 40px -30px rgba(0, 0, 0, .95);
}
/* Liseré en dégradé (masque) : net, sans dépasser du rayon */
.lisere::after, .pilote-carte::after, .mode[aria-checked="true"]::after, .reprendre::after, .acces-carte::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  background: linear-gradient(160deg, rgba(242, 180, 90, .62), rgba(242, 180, 90, .06) 38%, rgba(157, 176, 224, .14));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}
/* Reflet spéculaire qui suit l'inclinaison (transform seulement, pas de repeinte) */
.reflet {
  position: absolute;
  inset: -45%;
  pointer-events: none;
  background: radial-gradient(30% 24% at 42% 40%, rgba(255, 238, 210, .11), rgba(255, 238, 210, .03) 55%, transparent 72%);
  transform: translate3d(calc(var(--lx) * 16%), calc(var(--ly) * 12%), 0);
  will-change: transform;
}

/* ——— Éléments pressables ——— */
.p {
  transition: transform var(--ressort-vif-d) var(--ressort-vif), background-color .2s, opacity .2s, color .2s;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.p.presse { transform: scale(.965); transition: transform .14s cubic-bezier(.2, 0, 0, 1); }
.carte.p.presse, .pilote-carte.presse, .ligne-bot.presse, .module.presse { transform: scale(.985); }

/* ——— Barre d'onglets en verre ——— */
.onglets {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 20;
  height: var(--barre);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 6px;
  border-radius: 26px;
  background: rgba(17, 25, 46, .6);
  -webkit-backdrop-filter: blur(26px) saturate(170%);
  backdrop-filter: blur(26px) saturate(170%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .09), inset 0 0 0 1px rgba(157, 176, 224, .1), 0 18px 44px -16px rgba(0, 0, 0, .85);
  overflow: hidden;
  transition: transform .5s var(--sortie), opacity .3s;
}
.onglets::before {
  content: "";
  position: absolute;
  top: 0;
  left: 20%;
  width: 60%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .34), transparent);
  transform: translate3d(calc(var(--lx) * 40%), 0, 0);
  pointer-events: none;
}
.onglets-curseur {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 6px;
  width: calc((100% - 12px) / 5);
  border-radius: 20px;
  background: radial-gradient(120% 130% at 50% 0%, rgba(255, 255, 255, .11), rgba(255, 255, 255, .025));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), inset 0 0 0 1px rgba(255, 255, 255, .045);
  transform: translateX(calc(var(--onglet, 0) * 100%));
  transition: transform var(--ressort-d) var(--ressort);
}
.onglets.suit .onglets-curseur { transition: none; }
.onglet {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  color: var(--brume);
  font-size: 0.6563rem;
  font-weight: 560;
  font-stretch: 96%;
  border-radius: 20px;
}
.onglet-ico { position: relative; width: 24px; height: 24px; }
.onglet-ico svg { position: absolute; inset: 0; width: 24px; height: 24px; transition: opacity .22s, transform var(--ressort-vif-d) var(--ressort-vif); }
.onglet .actif { opacity: 0; transform: scale(.7); }
.onglet[aria-current="page"] { color: var(--porcelaine); }
.onglet[aria-current="page"] .actif { opacity: 1; transform: none; }
.onglet[aria-current="page"] .repos { opacity: 0; transform: scale(1.12); }
.onglet[data-route="pilote"][aria-current="page"] { color: var(--ambre); }
#app[data-route="acces"] .onglets, .intro-ouverte .onglets { transform: translateY(140%); opacity: 0; pointer-events: none; }

/* ——— Avertissement épinglé (accueil) ——— */
.risque {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: calc(var(--barre) + 20px + env(safe-area-inset-bottom));
  z-index: 19;
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin: 0;
  padding: 9px 12px;
  font-size: 0.7188rem;
  font-stretch: 94%;
  line-height: 1.32;
  color: #EDCB96;
  background: rgba(34, 27, 19, .95);
  border-radius: 15px;
  box-shadow: inset 0 0 0 1px rgba(242, 180, 90, .22), inset 0 1px 0 rgba(255, 220, 160, .08);
  transition: opacity .3s, transform .5s var(--sortie);
}
.risque svg { flex: none; width: 15px; height: 15px; margin-top: 1px; }
#app:not([data-route="accueil"]) .risque, .intro-ouverte .risque { opacity: 0; transform: translateY(12px); pointer-events: none; }


/* ——— Squelettes : un seul miroitement qui traverse tout l'écran ——— */
.sq {
  background: linear-gradient(100deg, rgba(157, 176, 224, .06) 30%, rgba(157, 176, 224, .14) 50%, rgba(157, 176, 224, .06) 70%) fixed;
  background-size: 300% 100%;
  animation: miroite 1.5s ease-in-out infinite;
}
@keyframes miroite { from { background-position: 100% 0; } to { background-position: 0% 0; } }
.sq-pile { display: grid; gap: 12px; }

/* ——— Feuille (bottom sheet), voile ——— */
.voile { position: absolute; inset: 0; z-index: 30; background: rgba(3, 6, 14, .62); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.feuille {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 31;
  padding: 14px 22px 20px;
  border-radius: 34px;
  background: var(--grain, none), linear-gradient(180deg, #18233F, #121B31);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), inset 0 0 0 1px var(--filet-2), 0 -20px 60px -20px rgba(0, 0, 0, .8);
  text-align: center;
  touch-action: none;
}
.poignee { width: 38px; height: 5px; margin: 0 auto 16px; border-radius: 99px; background: rgba(232, 237, 247, .22); cursor: grab; }
.feuille .f-ico { width: 64px; height: 64px; margin: 0 auto 14px; }
.feuille h3 { font-size: var(--t-h3); font-weight: 640; font-stretch: 110%; letter-spacing: -.015em; margin: 0 0 8px; }
.feuille p { margin: 0 auto 20px; color: #C3CBDD; font-size: 0.9063rem; max-width: 30ch; }
.trace { stroke-dasharray: 1; stroke-dashoffset: 1; animation: trace .7s var(--sortie) .3s forwards; }
@keyframes trace { to { stroke-dashoffset: 0; } }

/* ——— L'île : toasts façon Dynamic Island ——— */
.ile { position: absolute; top: calc(10px + var(--haut-tg)); left: 50%; z-index: 90; transform: translate(-50%, 0); display: none; pointer-events: none; max-width: calc(100% - 24px); }
.ile.visible { display: block; }
.ile-fond { position: absolute; inset: 0; border-radius: 999px; background: #000; box-shadow: 0 0 0 1px rgba(255, 255, 255, .07), 0 18px 40px -12px rgba(0, 0, 0, .9); }
.ile-contenu { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 18px 8px 8px; min-height: 42px; color: #F2F4F9; }
.ile-texte { display: grid; line-height: 1.2; }
.ile-texte b { font-size: 0.8438rem; font-weight: 620; white-space: nowrap; }
.ile-texte small { font-size: 0.7188rem; color: #9AA3B8; white-space: nowrap; margin-top: 1px; }
.ile-ico { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.ile-ico svg { width: 15px; height: 15px; }
.ile-ico.info { background: rgba(157, 176, 224, .16); color: var(--pervenche); }
.ile-ico.succes { background: rgba(79, 224, 166, .16); color: var(--jade); }
.ile-ico.alerte { background: rgba(255, 122, 134, .16); color: var(--corail); }
.ile-ico.pilote i { width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle, #0A1020 0 18%, #F6C267 22%, #C97B22 75%); }


/* ——— Mouvement réduit ——— */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    transition-delay: 0ms !important;
  }
  .ecran .e { opacity: 1 !important; }
  .spark-halo, .point-vivant::after { display: none; }
  .reflet { transform: none; }
  .sq { animation: none; }
}
.mode > .radio { position: absolute; }
.intro:focus { outline: none; }
.spark-hote, .bougies-hote, .courbes-hote, .urgence, .pilote-carte { user-select: none; -webkit-user-select: none; }

/* ——— Ajouts de l'app (refonte) ——— */
/* champs en 16 px au moins : sinon iOS zoome quand on les touche */
input, select, textarea { font-size: 16px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
/* défilement vertical laissé au compositeur ; les glissements horizontaux passent par les Pointer Events */
#scene, .ecran { touch-action: pan-y; }
/* écrans plein écran (accès expiré, activation, licence) : ni onglets, ni dégradé de pied */
#app[data-plein] .onglets { transform: translateY(140%); opacity: 0; pointer-events: none; }
#app[data-plein]::after { display: none; }
/* clavier ouvert : la barre d'onglets se masque pour ne rien cacher */
#app.clavier .onglets, #app.clavier .risque { transform: translateY(140%); opacity: 0; pointer-events: none; }
/* longues listes : rendu à la demande */
.journal > div, .chrono > li, .lecon > *, .liste > div { content-visibility: auto; contain-intrinsic-size: auto 56px; }
.titre:focus { outline: none; }
/* session invalide, erreur au démarrage */
.plein-message { position: absolute; inset: 0; display: grid; place-content: center; gap: 14px; padding: 32px; text-align: center; }
.plein-message h1 { font-size: var(--t-h3); margin: 0; }
.plein-message p { margin: 0; color: var(--brume); }

/* Mode économie (automatique sur un appareil lent, ou forcé dans les réglages) : fonds opaques, ni grain ni reflets */
.eco .onglets { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(17, 25, 46, .97); }
.eco .voile { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(3, 6, 14, .82); }
.eco .reflet, .eco .onglets::before { display: none; }

/* Animations réduites (réglage de l'app, en plus de la préférence du système) */
.reduit *, .reduit *::before, .reduit *::after {
  animation-duration: .001ms !important;
  animation-delay: 0ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
  transition-delay: 0ms !important;
}
.reduit .ecran .e { opacity: 1 !important; }
.reduit .spark-halo, .reduit .point-vivant::after { display: none; }
.reduit .reflet { transform: none; }
.reduit .sq { animation: none; }
