/* Thème Fast Event : jetons de couleur et fonds, pour la plateforme comme pour
   les fiches d'événement. Les modèles d'événement déclarent les mêmes noms de
   variables, cette feuille est chargée après la leur et prend donc le relais.
   Un seul endroit à toucher pour rhabiller toute l'application.

   Les deux fonds sont la même œuvre, en traitement clair et en traitement
   sombre. Pour les remplacer, déposez vos fichiers sous les mêmes noms dans
   frontend/assets/. Le bandeau de tête reste noir dans les deux thèmes. */

:root {
  /* ---------- Thème clair ---------- */
  --bg: #eef1f8;
  --surface: rgba(255, 255, 255, .9);
  --surface-2: rgba(246, 247, 252, .88);
  --ink: #15141c;
  --muted: #5a5670;
  --line: #e0dee9;

  --accent: #c21d58;
  --accent-ink: #ffffff;
  --accent-soft: #fbe7ee;

  /* Bandeau de tête : noir dans les deux thèmes. */
  --band: #0b0a12;
  --band-ink: #f4f2f7;
  --band-muted: #a7a2b6;

  --good: #1d7a45; --good-soft: #e2f3e8;
  --warn: #9a5800; --warn-soft: #fdf0db;
  --crit: #b42318; --crit-soft: #fde8e6;
  --info: #2a5db0; --info-soft: #e6eefb;

  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #9d9aa5;

  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;

  --fond: url("/assets/fond-clair.jpg");
  /* Voile posé sur l'œuvre : opaque là où se lit le contenu, transparent à
     droite où l'illustration a de la place. */
  --voile: linear-gradient(100deg, rgba(238, 241, 248, .94) 0%, rgba(238, 241, 248, .88) 38%, rgba(238, 241, 248, .62) 72%, rgba(238, 241, 248, .38) 100%);
  --ombre-carte: 0 1px 2px rgba(20, 18, 30, .05), 0 8px 24px rgba(20, 18, 30, .06);
  --flou: saturate(120%) blur(10px);
  color-scheme: light;
}

/* ---------- Thème sombre ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #03040d;
    --surface: rgba(23, 22, 36, .82);
    --surface-2: rgba(33, 31, 50, .78);
    --ink: #f2f0f8;
    --muted: #a9a4bb;
    --line: rgba(255, 255, 255, .12);

    --accent: #ff2e74;
    --accent-ink: #1a0410;
    --accent-soft: rgba(255, 46, 116, .18);

    --band: #07070f;
    --band-ink: #f4f2f7;
    --band-muted: #8f8a9a;

    --good: #3ddc97; --good-soft: rgba(61, 220, 151, .15);
    --warn: #ffb648; --warn-soft: rgba(255, 182, 72, .15);
    --crit: #ff6b6b; --crit-soft: rgba(255, 107, 107, .15);
    --info: #4cc9f0; --info-soft: rgba(76, 201, 240, .15);

    --s1: #4cc9f0; --s2: #ff7849; --s3: #3ddc97; --s4: #ffd166;
    --s5: #ff2e74; --s6: #9b5de5; --s7: #7b8cff; --s8: #8a8699;

    --fond: url("/assets/fond-sombre.jpg");
    --voile: linear-gradient(100deg, rgba(3, 4, 13, .94) 0%, rgba(3, 4, 13, .88) 38%, rgba(3, 4, 13, .66) 72%, rgba(3, 4, 13, .42) 100%);
    --ombre-carte: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 30px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #03040d;
  --surface: rgba(23, 22, 36, .82);
  --surface-2: rgba(33, 31, 50, .78);
  --ink: #f2f0f8;
  --muted: #a9a4bb;
  --line: rgba(255, 255, 255, .12);

  --accent: #ff2e74;
  --accent-ink: #1a0410;
  --accent-soft: rgba(255, 46, 116, .18);

  --band: #07070f;
  --band-ink: #f4f2f7;
  --band-muted: #8f8a9a;

  --good: #3ddc97; --good-soft: rgba(61, 220, 151, .15);
  --warn: #ffb648; --warn-soft: rgba(255, 182, 72, .15);
  --crit: #ff6b6b; --crit-soft: rgba(255, 107, 107, .15);
  --info: #4cc9f0; --info-soft: rgba(76, 201, 240, .15);

  --s1: #4cc9f0; --s2: #ff7849; --s3: #3ddc97; --s4: #ffd166;
  --s5: #ff2e74; --s6: #9b5de5; --s7: #7b8cff; --s8: #8a8699;

  --fond: url("/assets/fond-sombre.jpg");
  --voile: linear-gradient(100deg, rgba(3, 4, 13, .94) 0%, rgba(3, 4, 13, .88) 38%, rgba(3, 4, 13, .66) 72%, rgba(3, 4, 13, .42) 100%);
  --ombre-carte: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 30px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

/* ---------- Fond de page ----------
   L'œuvre est ancrée en haut à droite et ne défile pas : le contenu glisse
   par-dessus. Le voile garantit la lisibilité du texte au-dessus des aplats. */
body {
  background-color: var(--bg);
  background-image: var(--voile), var(--fond);
  background-position: center top, right top;
  background-size: cover, cover;
  background-repeat: no-repeat, no-repeat;
  background-attachment: fixed, fixed;
}

/* Les surfaces laissent transparaître l'œuvre sans gêner la lecture. */
.card,
.tile,
.modal,
.acard,
.kpi,
.auth-card {
  -webkit-backdrop-filter: var(--flou);
  backdrop-filter: var(--flou);
  box-shadow: var(--ombre-carte);
}

/* Filet dégradé sous le bandeau, du cyan au rose, comme sur la maquette. */
.top {
  border-width: 0 0 2px;
  border-style: solid;
  border-image: linear-gradient(90deg, var(--info), var(--accent)) 1;
}

@media (prefers-reduced-motion: reduce) {
  body { background-attachment: scroll, scroll; }
}

/* Sur mobile, un fond fixe coûte cher au défilement et l'œuvre n'a pas la
   place de s'exprimer : on garde la couleur de fond seule. */
@media (max-width: 760px) {
  body {
    background-image: var(--voile);
    background-attachment: scroll;
  }
  .card, .tile, .modal, .acard, .kpi, .auth-card {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* ---------- Interrupteur de thème ----------
   Piste à deux positions, soleil et lune visibles en permanence : on voit d'un
   coup d'œil l'état courant et ce que fera le clic. flex: none, sinon le
   bouton se fait écraser par ses voisins dans le bandeau. */
.theme-switch {
  flex: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  width: 58px;
  height: 30px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  vertical-align: middle;
}
.theme-switch .ic { width: 15px; height: 15px; position: relative; z-index: 1; transition: color .15s, opacity .15s; }
.theme-switch .ic.on { color: var(--accent); opacity: 1; }
.theme-switch .ic:not(.on) { opacity: .5; }
.theme-switch .knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .18s ease;
}
.theme-switch[aria-checked="true"] .knob { transform: translateX(28px); }
.theme-switch:hover { border-color: var(--accent); }
.theme-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Dans le bandeau noir, les couleurs de surface n'auraient pas le contraste
   nécessaire : on force une piste claire sur fond sombre. */
.theme-switch.on-band {
  background: rgba(255, 255, 255, .14);
  border-color: rgba(255, 255, 255, .34);
  color: var(--band-ink);
}
.theme-switch.on-band .knob {
  background: var(--band-ink);
  border-color: transparent;
}
.theme-switch.on-band .ic.on { color: var(--accent); }
.theme-switch.on-band:hover { border-color: var(--band-ink); }

/* Sur les pages d'accès, qui n'ont pas de bandeau. */
.theme-corner { position: fixed; top: 16px; right: 16px; z-index: 30; }

@media (prefers-reduced-motion: reduce) {
  .theme-switch .knob { transition: none; }
}
