/* Sentinelle — « centre de commandement de défense ».
   Fond nuit, accents vert/cyan « bouclier », touche or Le Roi, grilles holographiques, lignes de balayage discrètes.
   Trois niveaux d'effets posés par JS sur <html data-mouvement> : plein / leger / reduit (voir js/noyau/mouvement.js). */

@font-face { font-family: "Space Grotesk"; src: url("/fonts/space-grotesk-latin-wght-normal.woff2") format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }

:root {
  --fond: #04070D;
  --fond-2: #071019;
  --surface: rgba(13, 24, 34, 0.78);
  --surface-2: rgba(18, 34, 46, 0.86);
  --surface-pleine: #0C1720;
  --bord: rgba(130, 255, 214, 0.14);
  --bord-fort: rgba(130, 255, 214, 0.32);
  --texte: #E9F4F1;
  --texte-doux: #A3B7BC;   /* 8,9:1 sur la surface */
  --vert: #3CF5B0;
  --vert-fonce: #16A877;
  --cyan: #38D9F5;
  --or: #E8C26A;
  --corail: #FF8577;
  --encre: #03140D;        /* texte sur les boutons verts */
  --rayon: 18px;
  --rayon-petit: 12px;
  --ressort: cubic-bezier(.34, 1.56, .64, 1);
  --sortie: cubic-bezier(.2, .8, .2, 1);
  --police: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  /* zones sûres : iPhone (env) et Telegram (Bot API 8.0 : variables posées par telegram-web-app.js) */
  --haut: calc(max(env(safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px)) + var(--tg-content-safe-area-inset-top, 0px));
  --bas: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --dock-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--fond); -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--fond);
  color: var(--texte);
  font-family: var(--police);
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#app {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
  padding: calc(var(--haut) + 14px) 16px calc(var(--bas) + var(--dock-h) + 40px);
}

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; font-weight: 650; }
h1 { font-size: clamp(28px, 7.4vw, 36px); margin: 4px 0 10px; }
h2 { font-size: 20px; margin: 6px 0 8px; }
h3 { font-size: 17px; margin: 4px 0; }
p { margin: 8px 0; }
a { color: var(--cyan); text-underline-offset: 3px; }
strong { color: #fff; font-weight: 650; }
.mono { font-family: var(--mono); letter-spacing: 0.04em; }
.doux { color: var(--texte-doux); }
.visuellement-cache { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* focus visible partout (clavier), anneau vert net */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--vert); outline-offset: 3px; border-radius: 10px; }
h1:focus-visible { outline: none; }

/* ——— Décor fixe : halo, grille holographique en perspective, lignes de balayage ——— */
.decor { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; background: var(--fond); }
.decor-halo {
  position: absolute; inset: -20% -30% auto -30%; height: 90vh;
  background:
    radial-gradient(50% 45% at 50% 30%, rgba(60, 245, 176, 0.16), transparent 70%),
    radial-gradient(40% 40% at 85% 10%, rgba(56, 217, 245, 0.12), transparent 70%),
    radial-gradient(30% 30% at 10% 20%, rgba(232, 194, 106, 0.07), transparent 70%);
}
.decor-grille {
  position: absolute; left: -50%; right: -50%; bottom: -10%; height: 60vh;
  background-image:
    linear-gradient(rgba(56, 217, 245, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 217, 245, 0.16) 1px, transparent 1px);
  background-size: 44px 44px;
  transform: perspective(380px) rotateX(62deg);
  transform-origin: 50% 100%;
  -webkit-mask-image: linear-gradient(to top, #000 0%, transparent 85%);
  mask-image: linear-gradient(to top, #000 0%, transparent 85%);
  opacity: 0.55;
}
.decor-lignes {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.022) 0 1px, transparent 1px 3px);
}
.decor-lignes::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 22vh;
  background: linear-gradient(to bottom, transparent, rgba(60, 245, 176, 0.05), transparent);
  transform: translateY(-30vh);
  animation: balayage-decor 9s linear infinite;
}
@keyframes balayage-decor { to { transform: translateY(130vh); } }

/* barre de chargement fine pendant les appels à l'API */
html.charge body::before {
  content: ""; position: fixed; z-index: 60; left: 0; right: 0; top: var(--haut); height: 2px;
  background: linear-gradient(90deg, transparent, var(--vert), var(--cyan), transparent);
  background-size: 50% 100%; background-repeat: no-repeat;
  animation: charge 1s linear infinite;
}
@keyframes charge { from { background-position: -50% 0; } to { background-position: 150% 0; } }

/* ——— Entrée des écrans : les blocs montent en cascade ——— */
#app > * { animation: monter 0.55s var(--sortie) both; }
#app > :nth-child(2) { animation-delay: 0.05s; }
#app > :nth-child(3) { animation-delay: 0.1s; }
#app > :nth-child(4) { animation-delay: 0.15s; }
#app > :nth-child(5) { animation-delay: 0.2s; }
#app > :nth-child(6) { animation-delay: 0.25s; }
#app > :nth-child(n+7) { animation-delay: 0.3s; }
html.intro #app > * { animation-play-state: paused; }
@keyframes monter { from { opacity: 0; transform: translateY(14px); } }

/* ——— Modes d'effets ——— */
/* léger : pas de flou d'arrière-plan, pas d'animations décoratives continues */
html[data-mouvement="leger"] .decor-lignes::after,
html[data-mouvement="leger"] .decor-grille { animation: none; }
html[data-mouvement="leger"] .dock,
html[data-mouvement="leger"] .hud .pastille-etat { -webkit-backdrop-filter: none; backdrop-filter: none; }
html[data-mouvement="leger"] .dock { background: rgba(7, 14, 21, 0.97); }

/* réduit : prefers-reduced-motion (ou mode réduit) — aucun mouvement superflu, l'information reste */
html[data-mouvement="reduit"] *,
html[data-mouvement="reduit"] *::before,
html[data-mouvement="reduit"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  animation-delay: 0s !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}
html[data-mouvement="reduit"] .decor-lignes::after { display: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .decor-lignes::after { display: none; }
}
