/* =====================================================================
   NET1C · SUPERVISION
   Terminal phosphore. Dense, sobre, lisible en pleine panne à trois heures
   du matin. Les animations sont rares et brèves : dans un outil d'astreinte,
   le mouvement permanent fatigue et masque le mouvement qui compte.
   ===================================================================== */

@font-face {
  font-family: 'Plex Mono';
  src: url('/fonts/plexmono-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Plex Mono';
  src: url('/fonts/plexmono-500.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Plex Mono';
  src: url('/fonts/plexmono-600.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}

:root {
  /* Le fond n'est pas noir : un noir absolu écrase le relief et fait
     scintiller le texte clair. Bleu-vert très sombre, presque imperceptible. */
  --vide:        #04070a;
  --vide-haut:   #070c10;
  --surface:     #0a1116;
  --surface-eco: #0d161c;
  --trait:       #16232b;
  --trait-vif:   #1f333d;

  /* Phosphore décalé vers le cyan : plus moderne que le vert pur, et surtout
     plus lisible sur fond sombre à faible luminosité d'écran. */
  --phosphore:      #24ffa5;
  --phosphore-doux: #14c47e;
  --phosphore-mat:  #0d5f45;
  --phosphore-voile: rgba(36, 255, 165, .09);

  --ambre:  #ffb340;
  --rouge:  #ff4d5e;
  --os:     #cfdbd5;   /* corps de texte : jamais du blanc pur */
  --os-mat: #6f8078;

  --pas: 4px;
  --rayon: 3px;

  --police: 'Plex Mono', ui-monospace, 'SF Mono', 'Cascadia Mono',
            'Roboto Mono', Menlo, monospace;

  /* Hauteur de fenêtre : dvh suit la barre d'adresse mobile, contrairement
     à vh qui provoque un saut au défilement sur iOS. */
  --hauteur: 100dvh;
}

@supports not (height: 100dvh) { :root { --hauteur: 100vh; } }

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

html {
  /* Empêche Safari d'agrandir le texte tout seul en paysage. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: var(--hauteur);
  background: var(--vide);
  color: var(--os);
  font: 400 14px/1.55 var(--police);
  font-variant-ligatures: none;
  letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
  /* Supprime le flash gris au toucher sur iOS. */
  -webkit-tap-highlight-color: transparent;
  /* Coupe le rebond élastique qui laisse croire à un bug d'affichage. */
  overscroll-behavior-y: none;
  padding:
    env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Toute cible tactile : pas de délai de 300 ms, pas de sélection parasite. */
button, .filtre, .carte, .ligne {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

/* Le texte technique, lui, doit rester copiable. */
pre, code, .ligne__sortie, .feuille pre { -webkit-user-select: text; user-select: text; }

::selection { background: var(--phosphore); color: var(--vide); }

/* ---------------------------------------------------------------- ATMOSPHÈRE */

.atmosphere {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  /* Halo phosphore : donne du volume sans éclaircir le fond. */
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(36,255,165,.055), transparent 60%),
    radial-gradient(90% 60% at 100% 100%, rgba(36,255,165,.03), transparent 55%);
}

.grain {
  position: absolute; inset: -50%;
  opacity: .16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E");
  animation: derive 9s steps(6) infinite;
}

/* Un unique balayage lent. Une trame permanente serait insupportable
   sur la durée d'une astreinte. */
.sweep {
  position: absolute; left: 0; right: 0; height: 34vh;
  background: linear-gradient(180deg, transparent, rgba(36,255,165,.028) 45%, transparent);
  animation: balayer 14s cubic-bezier(.4,0,.6,1) infinite;
}

@keyframes derive {
  0%,100% { transform: translate(0,0) }
  20% { transform: translate(-2%, 1%) }
  40% { transform: translate(1%, -2%) }
  60% { transform: translate(-1%, -1%) }
  80% { transform: translate(2%, 1%) }
}
@keyframes balayer {
  0%   { transform: translateY(-40vh); opacity: 0 }
  12%  { opacity: 1 }
  70%  { opacity: 1 }
  100% { transform: translateY(115vh); opacity: 0 }
}

/* ------------------------------------------------------------------- ENTÊTE */

.entete {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: calc(var(--pas) * 3);
  padding: calc(var(--pas) * 3) calc(var(--pas) * 4);
  padding-top: max(calc(var(--pas) * 3), env(safe-area-inset-top));
  background: color-mix(in srgb, var(--vide) 88%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--trait);
}

.entete__marque { display: flex; align-items: center; gap: calc(var(--pas) * 2); min-width: 0; }

.glyphe {
  color: var(--phosphore); font-size: 17px; line-height: 1;
  text-shadow: 0 0 12px rgba(36,255,165,.55);
  animation: respirer 3.4s ease-in-out infinite;
}
@keyframes respirer { 0%,100% { opacity: .85 } 50% { opacity: 1 } }

.entete h1 {
  margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .16em;
  color: var(--os); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.entete__sep { color: var(--phosphore-mat); margin: 0 2px; }

.entete__pouls { display: flex; align-items: center; gap: calc(var(--pas) * 2); flex-shrink: 0; }

.entete__horloge {
  font-size: 12px; font-variant-numeric: tabular-nums;
  color: var(--os-mat); letter-spacing: .06em;
}

/* Le pouls dit d'un regard si le moteur respire encore. */
.pouls {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--phosphore);
  box-shadow: 0 0 0 0 rgba(36,255,165,.6);
  animation: pulser 2.4s ease-out infinite;
}
.pouls--froid { background: var(--os-mat); animation: none; box-shadow: none; }
.pouls--alerte { background: var(--rouge); }
@keyframes pulser {
  0%   { box-shadow: 0 0 0 0 rgba(36,255,165,.55) }
  70%  { box-shadow: 0 0 0 9px rgba(36,255,165,0) }
  100% { box-shadow: 0 0 0 0 rgba(36,255,165,0) }
}

/* ------------------------------------------------------------------ GRILLE */

.grille {
  position: relative; z-index: 1;
  display: grid; gap: calc(var(--pas) * 3);
  padding: calc(var(--pas) * 3) calc(var(--pas) * 3) calc(var(--pas) * 12);
  max-width: 1400px; margin: 0 auto;
}

@media (min-width: 900px) {
  .grille {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: calc(var(--pas) * 4);
    padding: calc(var(--pas) * 5);
  }
  .panneau--large { grid-column: 1 / -1; }
}
@media (min-width: 1300px) {
  .grille { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .panneau--alerte { grid-column: span 2; }
}

/* ---------------------------------------------------------------- PANNEAUX */

.panneau {
  position: relative;
  background: linear-gradient(170deg, var(--surface), var(--surface-eco));
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  padding: calc(var(--pas) * 4);
  min-width: 0;
  /* Révélation échelonnée : le tableau de bord se dessine, il n'apparaît pas
     d'un bloc. Une seule fois, au chargement. */
  opacity: 0;
  animation: monter .5s cubic-bezier(.16,1,.3,1) forwards;
  animation-delay: calc(var(--rang, 1) * 65ms);
}

/* Filet phosphore en tête de panneau : structure la page sans une ligne de plus. */
.panneau::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 1px;
  background: linear-gradient(90deg, var(--phosphore-mat), transparent 55%);
}

.panneau--alerte { border-color: color-mix(in srgb, var(--ambre) 26%, var(--trait)); }
.panneau--alerte::before { background: linear-gradient(90deg, var(--ambre), transparent 55%); }

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

.panneau__titre {
  display: flex; align-items: center; gap: calc(var(--pas) * 2);
  margin: 0 0 calc(var(--pas) * 4);
  font-size: 11px; font-weight: 600;
  letter-spacing: .19em; text-transform: uppercase;
  color: var(--os-mat);
}

.panneau__puce {
  width: 5px; height: 5px; flex-shrink: 0;
  background: var(--phosphore); box-shadow: 0 0 8px rgba(36,255,165,.6);
}
.panneau__puce--ambre { background: var(--ambre); box-shadow: 0 0 8px rgba(255,179,64,.6); }
.panneau__puce--rouge { background: var(--rouge); box-shadow: 0 0 8px rgba(255,77,94,.6); }

.panneau__age, .panneau__note {
  margin-left: auto; font-size: 10px; font-weight: 400;
  letter-spacing: .05em; text-transform: none; color: var(--os-mat); opacity: .75;
}

.compteur {
  margin-left: auto;
  padding: 1px 7px;
  font-size: 11px; font-variant-numeric: tabular-nums;
  color: var(--vide); background: var(--os-mat);
  border-radius: 2px;
}
.compteur--vif  { background: var(--ambre); }
.compteur--rouge { background: var(--rouge); color: #fff; }

/* ---------------------------------------------------------------- CADRANS */

.cadrans {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: calc(var(--pas) * 2);
}
@media (min-width: 620px) { .cadrans { grid-template-columns: repeat(4, 1fr); } }

.cadran {
  padding: calc(var(--pas) * 3);
  background: var(--vide-haut);
  border: 1px solid var(--trait);
  border-radius: 2px;
  min-height: 76px;
  display: flex; flex-direction: column; justify-content: space-between;
}

.cadran--squelette { animation: attendre 1.4s ease-in-out infinite; }
@keyframes attendre { 0%,100% { opacity: .35 } 50% { opacity: .6 } }

.cadran__valeur {
  font-size: 27px; font-weight: 600; line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--phosphore);
  text-shadow: 0 0 18px rgba(36,255,165,.3);
}
.cadran__valeur--ambre { color: var(--ambre); text-shadow: 0 0 18px rgba(255,179,64,.3); }
.cadran__valeur--rouge { color: var(--rouge); text-shadow: 0 0 18px rgba(255,77,94,.35); }
.cadran__valeur--calme { color: var(--os); text-shadow: none; }

.cadran__etiquette {
  margin-top: calc(var(--pas) * 2);
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--os-mat);
}

/* Bref éclat quand une valeur change : on voit le mouvement du réseau. */
.cadran__valeur--change { animation: eclat .55s ease-out; }
@keyframes eclat {
  0%   { filter: brightness(2.1); transform: translateX(-1px) }
  35%  { transform: translateX(1px) }
  100% { filter: none; transform: none }
}

/* ------------------------------------------------------------ RÉPARTITION */

.repartition { margin-top: calc(var(--pas) * 4); }

.repartition__barre {
  display: flex; height: 6px; border-radius: 999px; overflow: hidden;
  background: var(--vide-haut); border: 1px solid var(--trait);
}
.repartition__barre span {
  height: 100%;
  transition: width .8s cubic-bezier(.16,1,.3,1);
}

.repartition__legende {
  display: flex; flex-wrap: wrap; gap: calc(var(--pas) * 4);
  margin-top: calc(var(--pas) * 3);
  font-size: 11px; color: var(--os-mat);
}
.repartition__legende i {
  display: inline-block; width: 7px; height: 7px; margin-right: 6px;
  border-radius: 1px; vertical-align: baseline;
}
.repartition__legende b {
  color: var(--os); font-weight: 500; font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- ALERTES */

.alertes { display: grid; gap: calc(var(--pas) * 2); }

.carte {
  display: block; width: 100%; text-align: left;
  padding: calc(var(--pas) * 3);
  background: var(--vide-haut);
  border: 1px solid var(--trait);
  border-left: 2px solid var(--ambre);
  border-radius: 2px;
  color: inherit; font: inherit;
  cursor: pointer;
  transition: border-color .18s, background .18s, transform .18s;
}
.carte:hover, .carte:focus-visible {
  background: var(--surface);
  border-left-color: var(--phosphore);
  transform: translateX(2px);
}
.carte:focus-visible { outline: 1px solid var(--phosphore); outline-offset: 2px; }
.carte:active { transform: translateX(1px) scale(.996); }

.carte__haut {
  display: flex; align-items: baseline; gap: calc(var(--pas) * 2);
  margin-bottom: calc(var(--pas) * 1);
}
.carte__titre { font-size: 13px; font-weight: 500; color: var(--os); }
.carte__age {
  margin-left: auto; flex-shrink: 0;
  font-size: 10px; color: var(--ambre); letter-spacing: .04em;
}
.carte__bas { font-size: 11px; color: var(--os-mat); }
.carte__cible { color: var(--phosphore-doux); }

.vide {
  margin: 0; padding: calc(var(--pas) * 4) 0;
  text-align: center; font-size: 12px; color: var(--os-mat);
}
.vide--bien { color: var(--phosphore-doux); }

/* ---------------------------------------------------------------- DORSALE */

.dorsale {
  /* Le schéma déborde sur mobile : il défile seul, la page ne bouge pas. */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 calc(var(--pas) * -1);
  padding: 0 var(--pas) calc(var(--pas) * 2);
  scrollbar-width: thin;
  scrollbar-color: var(--trait-vif) transparent;
}
.dorsale::-webkit-scrollbar { height: 4px; }
.dorsale::-webkit-scrollbar-thumb { background: var(--trait-vif); border-radius: 2px; }

.dorsale__schema {
  margin: 0; font-size: 11px; line-height: 1.5;
  color: var(--phosphore-doux); white-space: pre;
  text-shadow: 0 0 14px rgba(36,255,165,.18);
}
.dorsale__schema b { color: var(--phosphore); font-weight: 600; }
.dorsale__schema i { color: var(--rouge); font-style: normal; }
.dorsale__schema u { color: var(--os-mat); text-decoration: none; }

.avertissement {
  margin: calc(var(--pas) * 3) 0 0;
  padding: calc(var(--pas) * 2) calc(var(--pas) * 3);
  font-size: 11px; line-height: 1.5;
  color: var(--ambre);
  background: rgba(255,179,64,.06);
  border-left: 2px solid var(--ambre);
  border-radius: 0 2px 2px 0;
}

/* ---------------------------------------------------------------- FILTRES */

.filtres { display: flex; gap: var(--pas); margin-bottom: calc(var(--pas) * 3); }

.filtre {
  padding: calc(var(--pas) * 1.5) calc(var(--pas) * 3);
  /* 16px minimum sur tout élément focusable : en dessous, Safari iOS zoome
     automatiquement à la mise au point. */
  font: 500 12px/1 var(--police);
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--os-mat);
  background: transparent;
  border: 1px solid var(--trait);
  border-radius: 2px;
  cursor: pointer;
  transition: color .16s, border-color .16s, background .16s;
}
.filtre:hover { color: var(--os); border-color: var(--trait-vif); }
.filtre:focus-visible { outline: 1px solid var(--phosphore); outline-offset: 2px; }
.filtre--actif {
  color: var(--vide); background: var(--phosphore); border-color: var(--phosphore);
}

/* ----------------------------------------------------------------- LISTES */

.liste { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }

.ligne {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--pas) calc(var(--pas) * 2);
  padding: calc(var(--pas) * 2.5) calc(var(--pas) * 2);
  background: var(--vide-haut);
  border-left: 2px solid var(--trait-vif);
  transition: background .16s, border-color .16s;
}
.ligne:hover { background: var(--surface); }
.ligne--reel  { border-left-color: var(--rouge); }
.ligne--bruit { border-left-color: var(--os-mat); opacity: .62; }
.ligne--derive { border-left-color: var(--trait-vif); opacity: .5; }

.ligne__cible {
  font-size: 12px; font-weight: 500; color: var(--os);
  overflow-wrap: anywhere;
}
.ligne__service { color: var(--phosphore-doux); }
.ligne__age {
  font-size: 10px; color: var(--os-mat); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ligne__sortie {
  grid-column: 1 / -1;
  font-size: 11px; line-height: 1.45; color: var(--os-mat);
  overflow-wrap: anywhere;
}
.ligne__etiq {
  display: inline-block; margin-right: 6px; padding: 0 5px;
  font-size: 9px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--vide); background: var(--os-mat); border-radius: 2px;
}
.ligne__etiq--bruit { background: var(--os-mat); }
.ligne__etiq--reel  { background: var(--rouge); color: #fff; }

/* ------------------------------------------------------------------ VAULT */

.vault { display: grid; gap: calc(var(--pas) * 2); }

.vault__famille {
  display: flex; align-items: baseline; gap: calc(var(--pas) * 2);
  font-size: 11px;
}
.vault__nom { color: var(--os-mat); letter-spacing: .1em; text-transform: uppercase; }
.vault__jauge {
  flex: 1; height: 1px; background: var(--trait);
  position: relative; overflow: hidden;
}
.vault__jauge::after {
  content: ''; position: absolute; inset: 0 auto 0 0;
  width: var(--taux, 0%); background: var(--phosphore-mat);
  transition: width .9s cubic-bezier(.16,1,.3,1);
}
.vault__nb { color: var(--phosphore); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------- PIED */

.pied {
  position: relative; z-index: 1;
  padding: calc(var(--pas) * 3) calc(var(--pas) * 4);
  padding-bottom: max(calc(var(--pas) * 3), env(safe-area-inset-bottom));
  border-top: 1px solid var(--trait);
  font-size: 10px; letter-spacing: .08em; color: var(--os-mat);
  text-align: center;
}

/* --------------------------------------------------------------- FEUILLE */

.feuille { position: fixed; inset: 0; z-index: 60; }
.feuille[hidden] { display: none; }

.feuille__voile {
  position: absolute; inset: 0;
  background: rgba(2,4,6,.72);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: paraitre .2s ease-out;
}
@keyframes paraitre { from { opacity: 0 } to { opacity: 1 } }

.feuille__corps {
  position: absolute; inset: auto 0 0 0;
  max-height: 82vh; max-height: 82dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: calc(var(--pas) * 3) calc(var(--pas) * 5) calc(var(--pas) * 8);
  padding-bottom: max(calc(var(--pas) * 8), env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--phosphore-mat);
  border-radius: 10px 10px 0 0;
  animation: glisser .3s cubic-bezier(.16,1,.3,1);
}
@keyframes glisser { from { transform: translateY(100%) } to { transform: none } }

@media (min-width: 720px) {
  .feuille__corps {
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    width: min(680px, 92vw);
    max-height: 80dvh;
    border: 1px solid var(--phosphore-mat);
    border-radius: var(--rayon);
    animation: paraitre .22s ease-out;
  }
}

.feuille__poignee {
  display: block; width: 34px; height: 3px; margin: 0 auto calc(var(--pas) * 4);
  padding: 0; border: 0; border-radius: 999px;
  background: var(--trait-vif); cursor: pointer;
}
@media (min-width: 720px) { .feuille__poignee { display: none; } }

.feuille h3 {
  margin: 0 0 calc(var(--pas) * 3);
  font-size: 14px; font-weight: 600; color: var(--os);
  line-height: 1.4;
}
.feuille pre {
  margin: 0;
  font: 400 12px/1.65 var(--police);
  color: var(--os-mat);
  white-space: pre-wrap; overflow-wrap: anywhere;
}

/* --------------------------------------------------------- ACCESSIBILITÉ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .panneau { opacity: 1; }
  .sweep, .grain { display: none; }
}

@media (prefers-contrast: more) {
  :root { --os-mat: #9fb0a8; --trait: #2a3d47; }
}
