/* =====================================================================
   base.css — variables du design system, reset, typographie
   Ambiance sombre, un seul accent orange. Thème clair prévu (non activé).
   ===================================================================== */

:root {
  color-scheme: dark;

  /* Fonds */
  --bg: #08080A;             /* noir légèrement gris, texturé par le grain */
  --surface-1: rgba(13, 13, 14, 0.82);   /* sidebar (laisse deviner le fond) */
  --surface-2: rgba(22, 22, 24, 0.78);   /* cartes */
  --surface-3: #1C1C1E;      /* champs, survol */
  --surface-4: #2C2C2E;      /* survol des champs, pistes */
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  /* Texte */
  --text: #FFFFFF;
  --text-2: #A1A1A6;
  --text-3: #6E6E73;
  --text-on-accent: #FFFFFF;

  /* Accent + états */
  --accent: #DF633A;         /* orange Promethee */
  --accent-hover: #E8774F;
  --accent-soft: rgba(223, 99, 58, 0.12);
  --success: #30D158;
  --warning: #FFD60A;
  --danger: #FF453A;
  --info: #0A84FF;
  --violet: #BF5AF2;

  /* Grain façon crépi (bruit SVG, tuilé sur tout le fond) */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");

  /* Verre (barre mobile, modales, toasts) */
  --glass: rgba(20, 20, 20, 0.72);
  --overlay: rgba(0, 0, 0, 0.6);

  /* Forme */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 20px;
  --radius-full: 999px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);

  /* Typo */
  --font: "DM Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --fs-xs: 12px;
  --fs-sm: 14px;
  --fs-md: 16px;
  --fs-lg: 20px;
  --fs-xl: 28px;
  --fs-2xl: 36px;

  /* Espacements (multiples de 4) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;

  /* Mouvement */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 150ms;
  --t: 200ms;
  --t-slow: 250ms;

  /* Dimensions du layout */
  --sidebar: 240px;
  --sidebar-repliee: 72px;
  --barre-mobile: 64px;
  --contenu-max: 1200px;
}

/* ---------------------------------------------------------------------
   Reset léger
   --------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

html { background: var(--bg); }

body {
  position: relative;
  isolation: isolate;          /* les calques du fond restent derrière le contenu */
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------------------------------------------------------------------
   Fond « vivant » : noir-gris texturé façon crépi
   Calque 1 (body::before) : halos lumineux qui dérivent très lentement
   Calque 2 (body::after)  : grain fin + vignette sur les bords
   --------------------------------------------------------------------- */
body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -1;
  pointer-events: none;
}

body::before {
  inset: -20%;
  background:
    radial-gradient(40% 35% at 18% 12%, rgba(223, 99, 58, 0.10), transparent 70%),
    radial-gradient(45% 40% at 85% 25%, rgba(140, 150, 170, 0.07), transparent 70%),
    radial-gradient(50% 45% at 60% 95%, rgba(223, 99, 58, 0.05), transparent 70%),
    radial-gradient(70% 60% at 50% 50%, #121214, transparent 100%);
  animation: derive 40s ease-in-out infinite alternate;
}

body::after {
  inset: 0;
  background:
    radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(0, 0, 0, 0.55) 100%),
    var(--grain);
  background-size: auto, 220px 220px;
  opacity: 0.9;
}

@keyframes derive {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg); }
  50%  { transform: translate3d(3%, -2%, 0) rotate(4deg); }
  100% { transform: translate3d(-3%, 2%, 0) rotate(-3deg); }
}

/* L'attribut hidden l'emporte toujours (même sur display: flex des composants) */
[hidden] { display: none !important; }

img, svg { display: block; max-width: 100%; }
svg.icone { flex-shrink: 0; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

a { color: var(--accent); text-decoration: none; transition: color var(--t-fast) var(--ease); }
a:hover { color: var(--accent-hover); }

hr { border: 0; border-top: 1px solid var(--border); margin: var(--s5) 0; }

/* Focus clavier visible, discret à la souris */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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

/* ---------------------------------------------------------------------
   Typographie
   --------------------------------------------------------------------- */
h1, h2, h3, h4 {
  margin: 0;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
h4 { font-size: var(--fs-sm); }

p { margin: 0; }

.texte-2 { color: var(--text-2); }
.texte-3 { color: var(--text-3); }
.texte-sm { font-size: var(--fs-sm); }
.texte-xs { font-size: var(--fs-xs); }
.texte-succes { color: var(--success); }
.texte-danger { color: var(--danger); }
.texte-accent { color: var(--accent); }

/* Libellé discret au-dessus d'une section ou d'un chiffre */
.surtitre {
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* Chiffres alignés (montants, tableaux) */
.chiffres { font-variant-numeric: tabular-nums; }

/* Mention « prévision » : valeurs non définitives en gris */
.prevision { color: var(--text-3); }

/* Masqué visuellement mais lu par les lecteurs d'écran */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------------
   Apparition douce (fade + translateY 4px)
   --------------------------------------------------------------------- */
@keyframes apparition {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

.apparait {
  animation: apparition var(--t-slow) var(--ease) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}

/* ---------------------------------------------------------------------
   Transition douce entre les pages (navigateurs compatibles)
   La sidebar et la barre mobile restent fixes, seul le contenu change.
   --------------------------------------------------------------------- */
@view-transition { navigation: auto; }

::view-transition-old(root) { animation: 120ms ease-in both sortie-page; }
::view-transition-new(root) { animation: 200ms var(--ease) both entree-page; }
@keyframes sortie-page { to { opacity: 0; } }
@keyframes entree-page { from { opacity: 0; transform: translateY(4px); } }

/* Respect des préférences d'accessibilité : pas d'animation */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
