/* Vigie — le monde visuel.
   Verre dépoli iOS 26 posé sur un fond vivant dont la teinte EST la réponse. */

:root {
  color-scheme: dark;

  /* Teintes d'état. Le fond prend celle de l'état général. */
  --h-calme: 190;
  --h-attente: 42;
  --h-alerte: 356;
  --h-aveugle: 232;

  --teinte: var(--h-calme);

  --encre: #05070e;
  --texte: #f3f5fa;
  /* Secondaire teinté depuis la couleur du fond, jamais gris. */
  --texte-doux: hsl(var(--teinte) 22% 74% / 0.72);
  --texte-faible: hsl(var(--teinte) 20% 68% / 0.46);

  --verre: hsl(var(--teinte) 40% 80% / 0.055);
  --verre-haut: hsl(var(--teinte) 40% 86% / 0.085);
  --verre-bord: hsl(var(--teinte) 50% 88% / 0.14);
  --verre-bord-haut: hsl(var(--teinte) 60% 94% / 0.26);

  --vert: #34d399;
  --rouge: #ff5d72;
  --ambre: #fbbf4a;
  --aveugle: #93a9d4;
  --accent: #5ac8fa;

  --r-feuille: 30px;
  --r-bloc: 22px;
  --r-ligne: 16px;
  --r-pilule: 999px;

  --ombre-feuille: 0 24px 60px -18px rgb(0 0 0 / 0.72), 0 2px 8px -2px rgb(0 0 0 / 0.5);
  --ombre-flottant: 0 14px 38px -10px rgb(0 0 0 / 0.66);

  --gouttiere: 16px;
  --sortie: cubic-bezier(0.16, 1, 0.3, 1);

  --police: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI Variable Text',
    'Segoe UI', system-ui, sans-serif;
  --police-chiffres: ui-monospace, 'SF Mono', 'JetBrains Mono', 'Cascadia Mono', monospace;
}

:root[data-theme='clair'] {
  color-scheme: light;
  --encre: #eef1f8;
  --texte: #0b1020;
  --texte-doux: hsl(var(--teinte) 28% 26% / 0.78);
  --texte-faible: hsl(var(--teinte) 24% 32% / 0.52);
  --verre: hsl(var(--teinte) 60% 100% / 0.52);
  --verre-haut: hsl(var(--teinte) 60% 100% / 0.72);
  --verre-bord: hsl(var(--teinte) 40% 30% / 0.1);
  --verre-bord-haut: hsl(var(--teinte) 40% 100% / 0.9);
  --ombre-feuille: 0 24px 60px -22px hsl(var(--teinte) 40% 20% / 0.28);
  --ombre-flottant: 0 14px 34px -12px hsl(var(--teinte) 40% 20% / 0.24);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--police);
  color: var(--texte);
  background: var(--encre);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ─── Le fond vivant ──────────────────────────────────────────────────────
   Trois nappes de lumière qui dérivent lentement. C'est elles que le verre
   réfracte : sans ce fond, le flou ne serait qu'une décoration. */

.ciel {
  position: fixed;
  inset: -20vmax;
  z-index: -1;
  background:
    radial-gradient(44vmax 44vmax at 16% 8%, hsl(var(--teinte) 90% 50% / 0.58), transparent 64%),
    radial-gradient(40vmax 40vmax at 88% 20%, hsl(calc(var(--teinte) + 40) 88% 56% / 0.46), transparent 62%),
    radial-gradient(56vmax 56vmax at 50% 104%, hsl(calc(var(--teinte) - 28) 84% 48% / 0.5), transparent 66%);
  filter: saturate(1.15);
  animation: derive 44s var(--sortie) infinite alternate;
  transition: background 1.4s ease;
}

:root[data-theme='clair'] .ciel {
  filter: saturate(0.9) brightness(1.4);
}

@keyframes derive {
  from {
    transform: translate3d(-2%, -1%, 0) scale(1);
  }
  to {
    transform: translate3d(2%, 2%, 0) scale(1.08);
  }
}

/* ─── Mise en page ───────────────────────────────────────────────────────── */

.page {
  max-width: 1120px;
  margin: 0 auto;
  /* La barre flottante mesure environ 56 px : on dégage de quoi faire défiler
     la dernière ligne au-dessus d'elle, sans quoi elle la mange. */
  padding: 24px var(--gouttiere) calc(136px + env(safe-area-inset-bottom));
}

.entete {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 2px 20px;
}

.marque {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.marque svg {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.entete .pousse {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

/* ─── Verre ──────────────────────────────────────────────────────────────── */

.verre {
  position: relative;
  background: var(--verre);
  backdrop-filter: blur(40px) saturate(185%);
  -webkit-backdrop-filter: blur(40px) saturate(185%);
  border: 1px solid var(--verre-bord);
  border-radius: var(--r-bloc);
  box-shadow: var(--ombre-flottant);
}

/* Le liseré spéculaire du haut : c'est lui qui fait lire la matière. */
.verre::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, var(--verre-bord-haut) 22%, var(--verre-bord-haut) 78%, transparent);
  pointer-events: none;
}

/* ─── La réponse en un coup d'œil ────────────────────────────────────────── */

.verdict {
  border-radius: var(--r-feuille);
  box-shadow: var(--ombre-feuille);
  padding: 30px 24px 24px;
  overflow: hidden;
}

.verdict h1 {
  margin: 0;
  font-size: clamp(1.9rem, 7vw, 2.9rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
  font-weight: 650;
  text-wrap: balance;
}

.verdict p {
  margin: 12px 0 0;
  color: var(--texte-doux);
  font-size: 1.0625rem;
  line-height: 1.5;
  max-width: 54ch;
}

.pouls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 7px 14px 7px 11px;
  border-radius: var(--r-pilule);
  background: var(--verre-haut);
  border: 1px solid var(--verre-bord);
  font-size: 0.8125rem;
  color: var(--texte-doux);
  letter-spacing: 0.01em;
}

.pouls .bille {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  animation: battement 2.6s var(--sortie) infinite;
}

@keyframes battement {
  0% { box-shadow: 0 0 0 0 color-mix(in oklab, currentColor 60%, transparent); }
  70% { box-shadow: 0 0 0 9px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.compteurs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.compteur {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 8px 13px;
  border-radius: var(--r-pilule);
  background: var(--verre-haut);
  border: 1px solid var(--verre-bord);
  font-size: 0.8125rem;
  color: var(--texte-doux);
}

.compteur b {
  font-family: var(--police-chiffres);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--texte);
  font-variant-numeric: tabular-nums;
}

.compteur[data-ton='rouge'] b { color: var(--rouge); }
.compteur[data-ton='vert'] b { color: var(--vert); }
.compteur[data-ton='aveugle'] b { color: var(--aveugle); }
.compteur[data-ton='ambre'] b { color: var(--ambre); }

/* ─── Sections ───────────────────────────────────────────────────────────── */

.section {
  margin-top: 32px;
}

.section > h2 {
  margin: 0 0 12px 4px;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--texte-faible);
}

.liste {
  border-radius: var(--r-bloc);
  overflow: hidden;
}

.ligne {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 15px 18px;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--verre-bord);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.18s ease;
}

.ligne:first-child {
  border-top: 0;
}

.ligne:hover,
.ligne:focus-visible {
  background: var(--verre-haut);
}

.ligne:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.pastille {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.pastille[data-verdict='vert'] { background: var(--vert); }
.pastille[data-verdict='rouge'] { background: var(--rouge); }
.pastille[data-verdict='indetermine'] { background: var(--aveugle); }
.pastille[data-verdict='hors_perimetre'] { background: var(--texte-faible); }
.pastille[data-verdict='jamais'] {
  background: transparent;
  border: 1.5px dashed var(--texte-faible);
}

.ligne .corps {
  min-width: 0;
}

.ligne .titre {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-size: 0.9375rem;
  line-height: 1.35;
}

.ligne .code {
  font-family: var(--police-chiffres);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--texte-faible);
  flex: none;
}

.ligne .libelle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ligne .sous {
  margin-top: 3px;
  font-size: 0.8125rem;
  color: var(--texte-faible);
}

.badge {
  flex: none;
  padding: 4px 10px;
  border-radius: var(--r-pilule);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.015em;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge[data-etat='corrige'] {
  color: var(--vert);
  background: color-mix(in oklab, var(--vert) 14%, transparent);
  border-color: color-mix(in oklab, var(--vert) 28%, transparent);
}
.badge[data-etat='risque_accepte'] {
  color: var(--ambre);
  background: color-mix(in oklab, var(--ambre) 14%, transparent);
  border-color: color-mix(in oklab, var(--ambre) 30%, transparent);
}
.badge[data-etat='en_attente'] {
  color: var(--texte-doux);
  background: var(--verre-haut);
  border-color: var(--verre-bord);
}
.badge[data-etat='hors_perimetre'] {
  color: var(--texte-faible);
  background: transparent;
  border-color: var(--verre-bord);
}

/* ─── Alertes ────────────────────────────────────────────────────────────── */

.alerte {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  padding: 17px 18px;
  border-top: 1px solid var(--verre-bord);
}

.alerte:first-child { border-top: 0; }

.alerte svg {
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.alerte[data-niveau='critique'] svg { color: var(--rouge); }
.alerte[data-niveau='important'] svg { color: var(--ambre); }
.alerte[data-niveau='information'] svg { color: var(--aveugle); }

.alerte h3 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
}

.alerte p {
  margin: 5px 0 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--texte-doux);
  overflow-wrap: anywhere;
}

.alerte .pied {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 11px;
}

/* ─── Boutons ────────────────────────────────────────────────────────────── */

.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: var(--r-pilule);
  border: 1px solid var(--verre-bord);
  background: var(--verre-haut);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  color: var(--texte);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 550;
  cursor: pointer;
  transition: transform 0.16s var(--sortie), background 0.16s ease, opacity 0.16s ease;
}

.bouton:hover { background: var(--verre-bord); }
.bouton:active { transform: scale(0.96); }
.bouton:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bouton[disabled] { opacity: 0.45; cursor: progress; }

.bouton svg { width: 15px; height: 15px; }

.bouton.principal {
  background: var(--accent);
  border-color: transparent;
  color: #04121c;
  font-weight: 650;
}

.bouton.principal:hover { background: color-mix(in oklab, var(--accent) 88%, white); }

.bouton.discret {
  background: transparent;
  border-color: transparent;
  color: var(--texte-doux);
  padding-inline: 9px;
}

.bouton.discret:hover { background: var(--verre-haut); color: var(--texte); }

/* ─── Barre flottante ───────────────────────────────────────────────────── */

.barre {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px;
  border-radius: var(--r-pilule);
  background: var(--verre-haut);
  backdrop-filter: blur(44px) saturate(190%);
  -webkit-backdrop-filter: blur(44px) saturate(190%);
  border: 1px solid var(--verre-bord);
  box-shadow: var(--ombre-feuille);
  max-width: calc(100vw - 2 * var(--gouttiere));
}

/* ─── Feuille modale ─────────────────────────────────────────────────────── */

.voile {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: end center;
  background: rgb(2 4 10 / 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: var(--gouttiere);
  animation: apparait 0.22s ease both;
}

.feuille {
  width: min(560px, 100%);
  max-height: min(84vh, 760px);
  overflow: auto;
  border-radius: var(--r-feuille);
  padding: 24px;
  box-shadow: var(--ombre-feuille);
  animation: monte 0.34s var(--sortie) both;
}

@media (min-width: 720px) {
  .voile { place-items: center; }
  .feuille { animation-name: apparait; }
}

@keyframes apparait {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes monte {
  from { opacity: 0; transform: translateY(26px); }
  to { opacity: 1; transform: none; }
}

.feuille h2 {
  margin: 0 0 4px;
  font-size: 1.3125rem;
  letter-spacing: -0.02em;
}

.feuille .code-grand {
  font-family: var(--police-chiffres);
  font-size: 0.8125rem;
  color: var(--texte-faible);
}

.feuille .critere {
  margin: 16px 0 0;
  padding: 14px 16px;
  border-radius: var(--r-ligne);
  background: var(--verre-haut);
  border: 1px solid var(--verre-bord);
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--texte-doux);
}

.champs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.histo {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.histo .pas {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 9px 2px;
  font-size: 0.8125rem;
  color: var(--texte-doux);
  border-top: 1px solid var(--verre-bord);
}

.histo .pas:first-child { border-top: 0; }

.histo time {
  font-family: var(--police-chiffres);
  font-size: 0.75rem;
  color: var(--texte-faible);
  font-variant-numeric: tabular-nums;
}

/* ─── Connexion ──────────────────────────────────────────────────────────── */

.accueil {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: var(--gouttiere);
}

.accueil .feuille {
  animation: monte 0.5s var(--sortie) both;
  max-width: 400px;
}

.champ {
  display: block;
  margin-top: 14px;
}

.champ span {
  display: block;
  margin-bottom: 7px;
  font-size: 0.8125rem;
  color: var(--texte-doux);
}

.champ input {
  width: 100%;
  padding: 13px 15px;
  border-radius: var(--r-ligne);
  border: 1px solid var(--verre-bord);
  background: var(--verre-haut);
  color: var(--texte);
  font: inherit;
  font-size: 1rem;
}

.champ input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.champ input[inputmode='numeric'] {
  font-family: var(--police-chiffres);
  letter-spacing: 0.3em;
  text-align: center;
}

.erreur {
  margin-top: 14px;
  color: var(--rouge);
  font-size: 0.875rem;
}

/* ─── Divers ─────────────────────────────────────────────────────────────── */

.vide {
  padding: 26px 18px;
  text-align: center;
  color: var(--texte-faible);
  font-size: 0.875rem;
}

.avis {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--r-ligne);
  background: color-mix(in oklab, var(--ambre) 10%, transparent);
  border: 1px solid color-mix(in oklab, var(--ambre) 26%, transparent);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--texte-doux);
}

.avis svg { width: 18px; height: 18px; color: var(--ambre); flex: none; }

/* Le balayage de lumière quand les sondes repartent : l'unique moment animé. */
.balayage {
  position: relative;
  overflow: hidden;
}

.balayage::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 32%, hsl(var(--teinte) 90% 72% / 0.16) 50%, transparent 68%);
  transform: translateX(-120%);
  animation: balaye 1.15s var(--sortie) infinite;
  pointer-events: none;
}

@keyframes balaye {
  to { transform: translateX(120%); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (min-width: 720px) {
  :root { --gouttiere: 32px; }
  .page { padding-top: 40px; }
  .verdict { padding: 40px 36px 32px; }
  .ligne { padding: 16px 22px; }
}
