/* ==========================================================================
   hmi.css — Habillage "panneau de controle industriel" Phoenix Contact
   Complete Tailwind : textures, LED, effets d'ecran, animations.
   ========================================================================== */

:root {
  --pxc-green: #8CBE1E;
  --pxc-green-light: #B3E03A;
  --pxc-green-dark: #5E8214;
  --hmi-bg: #0A0E0C;
  --hmi-panel: #121A15;
  --hmi-line: #26332B;
  --amber: #F2A900;
  --red: #E2373B;
  --cyan: #3FB6D8;
}

html, body { height: 100%; }
body {
  background: var(--hmi-bg);
  font-family: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
  color: #D7E2D8;
  overflow: hidden;
}
.font-disp { font-family: 'Oxanium', 'Bahnschrift', sans-serif; }

/* ---------- fond technique ---------- */
.fond-technique::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(140, 190, 30, .10), transparent 60%),
    radial-gradient(80% 60% at 100% 110%, rgba(63, 182, 216, .06), transparent 60%),
    repeating-linear-gradient(0deg, transparent 0 39px, rgba(140, 190, 30, .04) 39px 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(140, 190, 30, .04) 39px 40px);
}
.fond-technique::after {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 60;
  background: repeating-linear-gradient(180deg, rgba(0, 0, 0, .20) 0 1px, transparent 1px 3px);
  opacity: .45; mix-blend-mode: multiply;
}
.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 61;
  box-shadow: inset 0 0 220px 50px rgba(0, 0, 0, .8);
}

/* ---------- LED de diagnostic ---------- */
/* ---------- écran d'introduction ----------
   Un teaser d'escape game : la grille du bâtiment défile, les pistes se
   dessinent, le titre se déchire une fraction de seconde, puis les lignes
   du scénario tombent une à une. Tout est en CSS : aucune minuterie à
   entretenir, et le mouvement s'efface si le poste demande la sobriété. */
@keyframes intro-grille { from { background-position: 0 0; } to { background-position: 0 -120px; } }
@keyframes intro-monte { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes intro-balayage { from { transform: translateY(-40vh); } to { transform: translateY(140vh); } }
@keyframes intro-trace { to { stroke-dashoffset: 0; } }
@keyframes intro-respire { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }
@keyframes intro-glitch {
  /* au repos les copies colorées sont entièrement rognées : seul le titre
     vert se voit. Elles ne réapparaissent qu'en tranches, le temps d'un éclair. */
  0%, 92%, 100% { clip-path: inset(50% 0 50% 0); transform: none; }
  93% { clip-path: inset(12% 0 68% 0); transform: translateX(-6px); }
  95% { clip-path: inset(62% 0 18% 0); transform: translateX(7px); }
  97% { clip-path: inset(34% 0 42% 0); transform: translateX(-3px); }
}

#vue-intro .intro-grille {
  position: absolute; inset: -120px 0 0; opacity: .5;
  background-image:
    linear-gradient(color-mix(in srgb, var(--pxc-green) 9%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--pxc-green) 9%, transparent) 1px, transparent 1px);
  background-size: 120px 120px;
  animation: intro-grille 6s linear infinite;
  mask-image: radial-gradient(ellipse at center, #000 20%, transparent 78%);
}
#vue-intro .intro-balayage {
  position: absolute; left: 0; right: 0; height: 38vh; pointer-events: none;
  background: linear-gradient(transparent,
    color-mix(in srgb, var(--pxc-green) 5%, transparent) 45%,
    color-mix(in srgb, var(--pxc-green) 12%, transparent), transparent);
  animation: intro-balayage 7s linear infinite;
}
#vue-intro.intro-joue .intro-piste { stroke-dasharray: 1400; stroke-dashoffset: 1400;
  animation: intro-trace 3.2s ease-out forwards; }

/* courant qui circule : un éclat court parcourt la piste sans fin, chaque
   piste à son rythme et dans son sens (vitesse négative = sens inverse) */
@keyframes intro-courant { to { stroke-dashoffset: -1400; } }
#vue-intro .intro-courant {
  stroke-dasharray: 34 1366; stroke-width: 2.6; stroke-linecap: round;
  filter: drop-shadow(0 0 7px color-mix(in srgb, var(--pxc-green) 85%, transparent));
  animation: intro-courant var(--vitesse, 7s) linear infinite;
  animation-direction: var(--sens, normal);
  animation-delay: var(--retard-courant, 0s);
}

/* pastilles de connexion : elles respirent au passage du courant */
@keyframes intro-pastille {
  0%, 100% { r: 5; opacity: .3; }
  50% { r: 7.5; opacity: .95; }
}
#vue-intro .intro-pastille {
  animation: intro-pastille 2.8s ease-in-out infinite;
  animation-delay: calc(var(--rang, 0) * .45s);
}
#vue-intro.intro-joue .intro-monte { opacity: 0;
  animation: intro-monte .9s cubic-bezier(.2,.7,.3,1) forwards; animation-delay: var(--retard, 0s); }
#vue-intro .intro-titre { position: relative; }
#vue-intro .intro-titre::before,
#vue-intro .intro-titre::after {
  content: attr(data-texte); position: absolute; inset: 0; pointer-events: none;
  /* état de repos porté par la règle elle-même, et non par l'animation : sans
     cela, un poste qui refuse les animations affiche les copies colorées en
     permanence par-dessus le titre blanc. */
  clip-path: inset(50% 0 50% 0);
}
/* le déchirement reste dans les verts de la marque : pas de rouge sur le titre */
#vue-intro .intro-titre::before { color: var(--pxc-green-light); animation: intro-glitch 5.5s steps(1) infinite; }
#vue-intro .intro-titre::after { color: var(--pxc-green); animation: intro-glitch 5.5s steps(1) .12s infinite; }
#vue-intro .intro-respire { animation: intro-respire 2.4s ease-in-out infinite; }

/* La boucle de trente secondes est pilotée par app.js : il fait respirer
   l'opacité du contenu puis relance le cycle. Rien n'est confié à une
   animation CSS ici, pour que le teaser tourne même sur un poste réglé en
   sobriété de mouvement. */
#vue-intro .intro-contenu,
#vue-intro .intro-decor { transition: opacity .8s ease; }

/* ---------- logo et titres : ce qui leur donne vie ----------
   Le logo s'allume comme un néon qu'on met sous tension, un reflet le
   traverse régulièrement, et le titre respire dans son halo. */
@keyframes intro-neon {
  0% { opacity: 0; filter: brightness(2.4) blur(6px); transform: scale(1.03); }
  18% { opacity: 1; filter: brightness(2.4) blur(0); }
  24% { opacity: .35; filter: brightness(1) blur(1px); }
  30% { opacity: 1; filter: brightness(1.8) blur(0); }
  38% { opacity: .6; }
  46%, 100% { opacity: 1; filter: none; transform: none; }
}
@keyframes intro-reflet { 0% { transform: translateX(-140%) skewX(-18deg); }
                          38%, 100% { transform: translateX(240%) skewX(-18deg); } }
@keyframes intro-vibre {
  0%, 96%, 100% { transform: none; }
  97% { transform: translate(-1px, 1px); }
  98% { transform: translate(2px, -1px); }
  99% { transform: translate(-1px, 0); }
}
/* halo de néon : le titre reste blanc, c'est son halo vert qui respire */
@keyframes intro-lueur {
  0%, 100% {
    text-shadow: 0 0 8px rgba(255, 255, 255, .45),
                 0 0 30px color-mix(in srgb, var(--pxc-green-light) 70%, transparent),
                 0 0 80px color-mix(in srgb, var(--pxc-green) 45%, transparent);
  }
  50% {
    text-shadow: 0 0 14px rgba(255, 255, 255, .8),
                 0 0 50px color-mix(in srgb, var(--pxc-green-light) 95%, transparent),
                 0 0 130px color-mix(in srgb, var(--pxc-green) 70%, transparent);
  }
}

/* le logo respire lui aussi, en continu */
@keyframes intro-logo-respire {
  0%, 100% { filter: drop-shadow(0 0 18px rgba(255, 255, 255, .18)); }
  50% { filter: drop-shadow(0 0 42px rgba(255, 255, 255, .42))
                drop-shadow(0 0 90px color-mix(in srgb, var(--pxc-green) 45%, transparent)); }
}
@keyframes intro-soulignement { from { transform: scaleX(0); } to { transform: scaleX(1); } }

#vue-intro .intro-logo { position: relative; display: inline-block; }
#vue-intro .intro-logo img { animation: intro-logo-respire 4.5s ease-in-out infinite; }
#vue-intro.intro-joue .intro-logo img {
  animation: intro-neon 2.4s ease-out both,
             intro-logo-respire 4.5s ease-in-out 2.4s infinite;
}
#vue-intro .intro-logo::after {          /* reflet qui traverse le logo */
  content: ''; position: absolute; inset: -10% -20%; pointer-events: none;
  /* bande fine et franche : sur fond noir, un dégradé large se verrait comme
     un rectangle gris autour du logo */
  background: linear-gradient(105deg, transparent 46%,
    rgba(255, 255, 255, .75) 50%, transparent 54%);
  mix-blend-mode: screen; opacity: 0;
}
#vue-intro.intro-joue .intro-logo::after { opacity: .55; animation: intro-reflet 7s ease-in-out 2.4s infinite; }

/* le titre cumule son arrivée en zoom, sa lueur et sa vibration : le
   sélecteur nomme l'élément pour passer devant la règle générique .intro-zoom */
#vue-intro h1.intro-titre { color: #FFFFFF; animation: intro-lueur 4s ease-in-out infinite; }
#vue-intro.intro-joue h1.intro-titre {
  opacity: 0;
  animation: intro-zoom 1.1s cubic-bezier(.18,.8,.24,1) var(--retard, 0s) both,
             intro-lueur 4s ease-in-out .8s infinite,
             intro-vibre 6.5s steps(1) 2.4s infinite;
}
#vue-intro .intro-soulignement { transform-origin: center; transform: scaleX(0); }
#vue-intro.intro-joue .intro-soulignement { animation: intro-soulignement 1.1s cubic-bezier(.2,.8,.2,1) 1.1s forwards; }

/* mise sous tension : un éclair blanc, puis le décor s'installe */
@keyframes intro-eclair {
  0% { opacity: 0; } 4% { opacity: .85; } 10% { opacity: .08; }
  14% { opacity: .55; } 22% { opacity: 0; } 100% { opacity: 0; }
}
@keyframes intro-zoom { from { opacity: 0; transform: scale(1.14); filter: blur(10px); }
                        to { opacity: 1; transform: none; filter: none; } }
@keyframes intro-halo { 0%, 100% { opacity: .25; transform: scale(1); }
                        50% { opacity: .5; transform: scale(1.06); } }
@keyframes intro-clignote-doux { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

#vue-intro .intro-eclair {
  position: absolute; inset: 0; background: var(--pxc-green-light); pointer-events: none; opacity: 0;
}
#vue-intro.intro-joue .intro-eclair { animation: intro-eclair 1.6s ease-out forwards; }
#vue-intro.intro-joue .intro-zoom { opacity: 0;
  animation: intro-zoom 1.1s cubic-bezier(.18,.8,.24,1) forwards; animation-delay: var(--retard, 0s); }
#vue-intro .intro-halo {
  position: absolute; left: 50%; top: 50%; width: 120vw; height: 60vh;
  transform: translate(-50%, -50%); pointer-events: none;
  background: radial-gradient(ellipse at center,
    color-mix(in srgb, var(--pxc-green) 20%, transparent), transparent 62%);
  animation: intro-halo 4.5s ease-in-out infinite;
}
/* chenillard : huit balises qui s'allument l'une après l'autre, comme un
   diagnostic qui parcourt la tour. Elles ne disent rien du jeu. */
@keyframes intro-balise {
  0%, 62%, 100% { background: transparent; border-color: var(--hmi-line); box-shadow: none; }
  8%, 30% { background: color-mix(in srgb, var(--pxc-green) 65%, transparent);
            border-color: var(--pxc-green);
            box-shadow: 0 0 22px color-mix(in srgb, var(--pxc-green) 55%, transparent); }
}
#vue-intro .intro-balise {
  border: 1px solid var(--hmi-line);
  animation: intro-balise 2.2s ease-in-out infinite;
  animation-delay: calc(var(--rang) * .14s);
}

/* Sobriété de mouvement : on ne coupe que ce qui secoue — le déchirement du
   titre et sa vibration. L'écran reste vivant : c'est une vitrine. */
@media (prefers-reduced-motion: reduce) {
  #vue-intro .intro-titre::before, #vue-intro .intro-titre::after { animation: none; }
}

/* façade de routeur : embase RJ45 et clignotement d'activité décalé */
.embase {
  width: 26px; height: 19px; border: 1px solid var(--hmi-line2);
  background: linear-gradient(#1B2320, #101613); position: relative;
}
.embase::before {            /* languette du connecteur */
  content: ""; position: absolute; left: 50%; top: 2px; transform: translateX(-50%);
  width: 11px; height: 5px; background: #0A0E0C; border: 1px solid var(--hmi-line);
}
.embase::after {             /* contacts */
  content: ""; position: absolute; left: 50%; bottom: 3px; transform: translateX(-50%);
  width: 16px; height: 7px;
  background: repeating-linear-gradient(90deg, #8CBE1E 0 1.5px, transparent 1.5px 4px);
  opacity: .5;
}
.embase.embase-libre::after { opacity: .16; }
.embase.embase-wan { border-color: rgba(140,190,30,.55); }

/* LED de trafic : pilotée au coup par coup, sans transition molle */
.led-trafic { transition: none; }
.led-trafic.repos { opacity: .16; box-shadow: none; }

@keyframes activite { 0%, 42% { opacity: 1; } 50%, 92% { opacity: .2; } 100% { opacity: 1; } }
.led-activite { animation: activite 1.4s steps(1, end) infinite; }
#routeur [data-port="LAN1"] .led-activite { animation-duration: 1.05s; }
#routeur [data-port="LAN2"] .led-activite { animation-duration: 1.85s; }
#routeur [data-port="LAN4"] .led-activite { animation-duration: .75s; }
@media (prefers-reduced-motion: reduce) { .led-activite { animation: none; } }

/* barre de charge d'une phase, à côté de son courant */
.barre-charge {
  display: block; width: 46px; height: 7px; background: rgba(0,0,0,.55);
  border: 1px solid var(--hmi-line);
}
.barre-charge i {
  display: block; height: 100%; background: var(--pxc-green); opacity: .8;
  transition: width .6s ease, background .3s;
}
.barre-charge.charge-haute i { background: var(--amber); }
.barre-charge.charge-critique i { background: var(--red); }

/* courbes de mesure : le tracé défile lentement, comme un enregistreur */
@keyframes defilement-courbe { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.courbe-defilante { animation: defilement-courbe 18s linear infinite; }
@media (prefers-reduced-motion: reduce) { .courbe-defilante { animation: none; } }

/* plots du jeu de correspondance : le point où vient se brancher le fil
   (à ne pas confondre avec .borne, le bornier de l'atelier logiciel) */
.plot {
  width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto;
  border: 2px solid var(--line2); background: #0A0E0C;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.plot-actif {
  border-color: var(--pxc-green); background: var(--pxc-green);
  box-shadow: 0 0 10px rgba(140,190,30,.7);
}

.led {
  width: 9px; height: 9px; border-radius: 50%;
  background: #2A332C; box-shadow: inset 0 0 3px rgba(0, 0, 0, .9);
  flex: 0 0 auto; transition: .2s;
}
.led-vert   { background: var(--pxc-green); box-shadow: 0 0 10px var(--pxc-green), inset 0 0 2px rgba(255,255,255,.6); }
.led-rouge  { background: var(--red);       box-shadow: 0 0 10px var(--red); }
.led-jaune  { background: var(--amber);     box-shadow: 0 0 10px var(--amber); }
.led-bleu   { background: var(--cyan);      box-shadow: 0 0 10px var(--cyan); }
.led-clignote { animation: clignote 1.05s steps(1) infinite; }
@keyframes clignote { 50% { opacity: .15; box-shadow: none; } }

/* ---------- bandes de danger ---------- */
.hazard {
  background: repeating-linear-gradient(45deg, var(--red) 0 8px, #2A0E0F 8px 16px);
  animation: defile 1.6s linear infinite;
}
.hazard-vert {
  background: repeating-linear-gradient(45deg, var(--pxc-green) 0 8px, #16210A 8px 16px);
  animation: defile 1.6s linear infinite;
}
@keyframes defile { to { background-position: 0 -32px; } }

/* ---------- rail DIN ---------- */
.rail-din {
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.03) 0 2px, transparent 2px 9px),
    linear-gradient(180deg, #1B241D, #121A15);
  border: 1px solid var(--hmi-line);
}

/* ---------- animations d'apparition ---------- */
.apparait { animation: apparait .35s cubic-bezier(.2,.8,.3,1) both; }
@keyframes apparait { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.surgit { animation: surgit .5s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes surgit { from { opacity: 0; transform: scale(.5); } to { opacity: 1; transform: none; } }
.secousse { animation: secousse .4s; }
@keyframes secousse {
  0%,100% { transform: none; } 20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}
.pulse-alarme { animation: pulseAlarme 1.1s ease-in-out infinite; }
@keyframes pulseAlarme { 50% { box-shadow: 0 0 0 3px rgba(226,55,59,.18); } }
.pulse-vert { animation: pulseVert 1.6s ease-in-out infinite; }
@keyframes pulseVert { 50% { box-shadow: 0 0 26px -4px rgba(140,190,30,.55); } }

/* ---------- valeur mesuree ---------- */
.valeur { font-variant-numeric: tabular-nums; transition: color .3s; }
.valeur-alarme { color: var(--red); text-shadow: 0 0 14px rgba(226,55,59,.4); }
.valeur-maj { animation: majValeur .5s ease-out; }
@keyframes majValeur { 0% { color: var(--pxc-green-light); } 100% { color: inherit; } }

/* ---------- barres ---------- */
.jauge { height: 8px; background: #080C09; border: 1px solid var(--hmi-line); overflow: hidden; }
.jauge > i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--pxc-green-dark), var(--pxc-green));
  transition: width .6s cubic-bezier(.3,1,.4,1);
}
.jauge.depassement > i { background: linear-gradient(90deg, var(--amber), var(--red)); }

/* ---------- bornier / cablage ---------- */
.borne {
  width: 100%; padding: 10px 12px; border: 1px solid var(--hmi-line);
  background: linear-gradient(180deg, #1C251E, #141C17);
  cursor: pointer; transition: .15s; position: relative;
}
.borne:hover { border-color: var(--pxc-green); background: #1F2A20; }
.borne.active { border-color: var(--pxc-green); box-shadow: 0 0 0 1px rgba(140,190,30,.4); }
.borne.reliee { border-color: var(--pxc-green-dark); }
.borne .vis {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #6E7A70, #2A322C);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.6);
}
.borne .vis::after {
  content: ''; position: absolute; inset: 4px 2px; background: #171D19; border-radius: 1px;
}
#cablage-svg path { stroke-linecap: round; filter: drop-shadow(0 0 4px rgba(140,190,30,.35)); }
#cablage-svg path.phase { stroke: #C9772E; }
#cablage-svg path.neutre { stroke: #6C8FD6; }
#cablage-svg path.dc-plus { stroke: #C6373B; }
#cablage-svg path.dc-moins { stroke: #7E8B82; }

/* ---------- clavier ---------- */
.touche {
  font-family: 'Oxanium', sans-serif; font-weight: 700; font-size: 26px;
  border: 1px solid var(--hmi-line);
  background: linear-gradient(180deg, #1E2820, #141C17);
  box-shadow: 0 3px 0 #0A0F0C, inset 0 1px 0 rgba(255,255,255,.05);
  transition: .08s; user-select: none;
}
.touche:active, .touche.enfoncee {
  transform: translateY(3px); box-shadow: 0 0 0 #0A0F0C, inset 0 1px 0 rgba(255,255,255,.05);
  border-color: var(--pxc-green); color: var(--pxc-green-light);
}
.case-code {
  width: 100%; aspect-ratio: 3/4; display: flex; align-items: center; justify-content: center;
  font-family: 'Oxanium', sans-serif; font-weight: 800; font-size: clamp(26px, 4vw, 48px);
  border: 1px solid var(--hmi-line); background: #0B120D; color: var(--pxc-green);
  text-shadow: 0 0 22px rgba(140,190,30,.5);
}
.case-code.active { border-color: var(--pxc-green); box-shadow: inset 0 0 26px -8px rgba(140,190,30,.6); }

/* ---------- journal ---------- */
.journal-ligne { border-left: 2px solid var(--hmi-line); }
.journal-ligne.niveau-alarme { border-color: var(--red); }
.journal-ligne.niveau-avertissement { border-color: var(--amber); }
.journal-ligne.niveau-succes { border-color: var(--pxc-green); }
.journal-ligne.niveau-info { border-color: #3C4A40; }

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: #0B0F0D; }
::-webkit-scrollbar-thumb { background: #24302A; border: 1px solid #0B0F0D; }
::-webkit-scrollbar-thumb:hover { background: var(--pxc-green-dark); }

/* ---------- curseur de consigne ---------- */
input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; }
input[type=range]::-webkit-slider-runnable-track {
  height: 6px; background: #0A0F0C; border: 1px solid var(--hmi-line);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 26px; margin-top: -11px;
  background: linear-gradient(180deg, #C9D9BE, #7C8C7E); border: 1px solid #0A0F0C;
  box-shadow: 0 0 10px rgba(140,190,30,.45); cursor: grab;
}
input[type=range]:active::-webkit-slider-thumb { cursor: grabbing; }

/* ---------- terminal ---------- */
.curseur-terminal {
  display: inline-block; width: 9px; height: 16px; background: var(--pxc-green);
  vertical-align: -3px; animation: clignote .9s steps(1) infinite;
}

/* ---------- flux energetique ---------- */
.flux { stroke-dasharray: 6 10; animation: fluxDefile 1.1s linear infinite; }
@keyframes fluxDefile { to { stroke-dashoffset: -32; } }

/* ---------- ecran final ---------- */
.compte-rebours {
  font-family: 'Oxanium', sans-serif; font-weight: 800;
  font-size: clamp(90px, 22vw, 260px); line-height: 1; color: var(--pxc-green);
  text-shadow: 0 0 80px rgba(140,190,30,.6);
  animation: rebours 1s ease-out both;
}
@keyframes rebours {
  0% { opacity: 0; transform: scale(1.6); filter: blur(10px); }
  18% { opacity: 1; transform: scale(1); filter: blur(0); }
  80% { opacity: 1; transform: scale(.99); }
  100% { opacity: .55; transform: scale(.96); }
}
.revele-aes { animation: reveleAes 1.4s cubic-bezier(.2,.9,.2,1) both; }
@keyframes reveleAes {
  from { opacity: 0; letter-spacing: .6em; filter: blur(14px); }
  to { opacity: 1; letter-spacing: .06em; filter: blur(0); }
}
.balayage {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(140,190,30,.10), transparent);
  height: 30%; animation: balayage 3.5s linear infinite;
}
@keyframes balayage { from { transform: translateY(-100%); } to { transform: translateY(400%); } }

/* ---------- utilitaires ---------- */
.masque { display: none !important; }
.grille-fine { background-image: linear-gradient(rgba(140,190,30,.05) 1px, transparent 1px),
  linear-gradient(90deg, rgba(140,190,30,.05) 1px, transparent 1px); background-size: 22px 22px; }

/* ---------- afficheur 7 segments ---------- */
.afficheur-7seg {
  display: flex; gap: calc(4px * var(--taille, 1)); align-items: center;
  justify-content: space-between;              /* digits répartis sur toute la largeur */
  padding: calc(10px * var(--taille, 1)) calc(16px * var(--taille, 1));
  max-width: calc(430px * var(--taille, 1)); margin: 0 auto;
  background: linear-gradient(180deg, #050A06, #0A1109);
  border: 1px solid var(--hmi-line);
  box-shadow: inset 0 2px 18px rgba(0, 0, 0, .9), 0 0 40px -18px rgba(140, 190, 30, .5);
}
.digit-7seg { flex: 1 1 0; max-width: calc(44px * var(--taille, 1)); }
.digit-7seg svg { display: block; width: 100%; height: auto; }
.digit-7seg polygon {
  fill: #1B2417;                       /* segment eteint, faiblement visible */
  transition: fill .06s linear, filter .06s linear;
}
.digit-7seg polygon.on {
  fill: var(--pxc-green-light, #B3E03A);
  filter: drop-shadow(0 0 6px rgba(140, 190, 30, .85));
}
.digit-7seg.verrouille polygon.on {
  fill: #EAFFB0;
  filter: drop-shadow(0 0 16px rgba(179, 224, 58, 1));
}
.afficheur-7seg.alarme .digit-7seg polygon.on {
  fill: #FF7B7E; filter: drop-shadow(0 0 6px rgba(226, 55, 59, .9));
}

/* ---------- flash de prise de vue ---------- */
.flash-plein-ecran {
  position: fixed; inset: 0; z-index: 95; pointer-events: none;
  background: #FFFFFF;
  animation: flashPhoto .42s ease-out forwards;
}
@keyframes flashPhoto {
  0% { opacity: 0; }
  12% { opacity: .96; }
  30% { opacity: .82; }
  100% { opacity: 0; }
}

/* ---------- zones défilantes sans barre visible (écran de briefing) ---------- */
.sans-barre { scrollbar-width: none; -ms-overflow-style: none; }
.sans-barre::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* ---------- fiche d'intervention : barre de défilement discrète ---------- */
.zone-fiche { scrollbar-width: none; }
.zone-fiche::-webkit-scrollbar { width: 0; display: none; }

/* ==========================================================================
   Compaction des modules selon la hauteur réelle de l'écran.

   En 1920 × 1080 plein écran, tout tient sans défilement. Mais une mise à
   l'échelle Windows à 125 % ramène la fenêtre à 864 px de haut en pixels CSS,
   et une fenêtre non maximisée en retire encore. Ces paliers resserrent
   l'affichage pour que les modules restent jouables sans défilement.
   ========================================================================== */

@media (max-height: 960px) {
  /* analyseur de réseau : l'en-tête des colonnes s'efface, les lignes se serrent */
  #analyseur [data-entete] { display: none; }
  #routeur .embase { width: 21px; height: 15px; }
  #routeur .embase::before { width: 9px; height: 4px; }
  #routeur .embase::after { width: 13px; height: 5px; }
  #analyseur .valeur { font-size: 11.5px !important; }
  #analyseur > div { padding-top: 3px !important; padding-bottom: 3px !important; }

  #vue-module #module-corps { padding: 11px !important; }
  #vue-module #module-corps > * + * { margin-top: 9px !important; }

  /* en-tête du module */
  #vue-module > div:first-child { padding-top: 7px; padding-bottom: 7px; }
  #module-numero, #module-nom { font-size: 21px !important; }
  #module-icone svg { width: 28px; height: 28px; }

  /* description et alarme */
  #vue-module .hazard-vert, #vue-module .hazard { width: 3px; }

  /* fiche d'intervention */
  #etapes-intervention { padding: 12px !important; }
  #etapes-intervention > li + li { margin-top: 10px !important; }
  #etapes-intervention span:last-child { font-size: 13.5px !important; line-height: 1.45 !important; }
  #etapes-intervention span:first-child { font-size: 13px !important; }

  /* questionnaire et équation */
  #questionnaire { padding: 12px !important; }
  #questionnaire > * + * { margin-top: 7px !important; }
  #questionnaire [data-question] { padding-top: 6px !important; padding-bottom: 6px !important; }
  #questionnaire input { padding-top: 5px !important; padding-bottom: 5px !important; font-size: 19px !important; }
  #vue-module [data-valeur-terme], #vue-module #champ-equation {
    padding-top: 5px !important; padding-bottom: 5px !important; font-size: 20px !important;
  }

  /* pupitre de mesures */
  #mesures-equipement > div { padding-top: 8px !important; padding-bottom: 8px !important; }
}

@media (max-height: 900px) {
  /* textes de la fiche et des questions : un cran plus bas */
  #etapes-intervention span:last-child { font-size: 15px !important; }
  #etapes-intervention { padding: 14px !important; }
  #questionnaire label { font-size: 14px !important; }

  .zone-titre-jeu { font-size: 19px !important; padding-top: 8px !important; }

  /* analyseur de réseau et courbes : bandeaux resserrés */
  #analyseur > div { padding-top: 4px !important; padding-bottom: 4px !important; }
  #analyseur .barre-charge { display: none; }
  #routeur .embase { display: none; }
  #analyseur .valeur { font-size: 11px !important; }
  #onde-reseau { display: none !important; }
  #module-corps .courbe-defilante { height: 24px; }
  #module-corps [class*="h-[30px]"] { height: 24px !important; }
  /* toutes les voies restent affichées : ce sont les lignes qui se serrent */
  .voie-mesure { padding-top: 1px !important; padding-bottom: 1px !important; }
  .voie-mesure .valeur { font-size: 12.5px !important; }
  #etapes-intervention span:last-child { line-height: 1.35 !important; }
  #questionnaire { padding: 10px !important; }
  #questionnaire > * + * { margin-top: 6px !important; }

  /* énigme et jeu de correspondance : l'espace se resserre avant de défiler */
  #vue-module .zone-enigme { padding: 10px 12px !important; }
  #vue-module .zone-enigme h3 { font-size: 21px !important; }
  #vue-module .zone-enigme p { font-size: 12.5px !important; line-height: 1.45 !important; }
  #questionnaire [data-question] { padding-top: 4px !important; padding-bottom: 4px !important; }
  #correspondance { padding: 10px !important; }
  #correspondance button { padding-top: 4px !important; padding-bottom: 4px !important; }
}

@media (max-height: 820px) {
  #vue-module #module-corps { padding: 8px !important; }
  #vue-module #module-corps > * + * { margin-top: 7px !important; }
  #module-numero, #module-nom { font-size: 18px !important; }

  #etapes-intervention { padding: 11px !important; }
  #etapes-intervention > li + li { margin-top: 7px !important; }
  #etapes-intervention span:last-child { font-size: 14.5px !important; line-height: 1.4 !important; }

  #questionnaire { padding: 9px !important; }
  #questionnaire > * + * { margin-top: 5px !important; }
  #questionnaire [data-question] { padding-top: 4px !important; padding-bottom: 4px !important; }
  #questionnaire label { font-size: 13.5px !important; }
  #questionnaire input { font-size: 17px !important; }

  /* les textes d'accompagnement s'effacent avant le contenu utile */
  #vue-module .compact-masquable { display: none !important; }
}

@media (max-height: 960px) {
  /* check-list de conformité, relevés et pupitre : lignes resserrées */
  #conditions > div { padding-top: 7px !important; padding-bottom: 7px !important; }
  #vue-module #champ-releve { padding-top: 6px !important; padding-bottom: 6px !important; font-size: 19px !important; }
  #vue-module .jauge { height: 6px; }
  #mesures-equipement > div { padding-top: 6px !important; padding-bottom: 6px !important; }
  #mesures-equipement .font-disp { font-size: 16px !important; }
}

@media (max-height: 780px) {
  /* dernier palier : l'essentiel reste, le décoratif s'efface */
  #vue-module #module-corps { padding: 6px !important; }
  #vue-module #module-corps > * + * { margin-top: 5px !important; }
  #etapes-intervention { padding: 9px !important; }
  #etapes-intervention > li + li { margin-top: 5px !important; }
  #etapes-intervention span:last-child { font-size: 13px !important; }
  #conditions > div { padding-top: 5px !important; padding-bottom: 5px !important; }
  #mesures-equipement > div { padding-top: 4px !important; padding-bottom: 4px !important; }
  #mesures-equipement .font-disp { font-size: 14px !important; }
  #vue-module svg[viewBox="0 0 600 420"] { display: none; }   /* décor de fiche */
}
