:root {
  color-scheme: dark;
  --fond: #130e08;
  --fond-panneau: #221609;
  --fond-panneau-clair: #2c1d0d;
  --bois: #0c0805;
  --bois-clair: #33220f;
  --cuivre-clair: #e39a5c;
  --cuivre: #b06a34;
  --cuivre-sombre: #6b3d19;
  --patine: #4f7a5c;
  --laiton-clair: #f2cf82;
  --laiton: #c99a44;
  --laiton-sombre: #6e4d1c;
  --texte: #f1e2bd;
  --texte-att: #d8bf8e;
  --bordure: #43301a;
  --accent: #74a860;
  --accent-negatif: #c85a3f;
  --ombre: rgba(0, 0, 0, 0.75);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  padding: 2rem 1rem 3rem;
  background: var(--fond);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(227, 154, 92, 0.06), transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(107, 61, 25, 0.1), transparent 60%),
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.25) 0px,
      rgba(0, 0, 0, 0.25) 1px,
      transparent 1px,
      transparent 3px
    );
  color: var(--texte);
  font-family: 'Special Elite', 'Courier New', monospace;
  max-width: 42rem;
  margin-inline: auto;
  position: relative;
}

/* --- Usure générale : vignette + rayures, appliquée à toute la page --- */

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(112deg, rgba(255, 240, 210, 0.025) 0px, transparent 1.5px, transparent 38px),
    repeating-linear-gradient(64deg, rgba(0, 0, 0, 0.05) 0px, transparent 1px, transparent 52px),
    radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.55) 100%);
  mix-blend-mode: multiply;
}

h1, .poste-nom, .chaine-libelle {
  font-family: 'Cinzel', serif;
}

/* --- Décor de fond : tuyauterie en cuivre --- */

.tuyau {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 1.7rem;
  z-index: 0;
  pointer-events: none;
  opacity: 0.7;
  background:
    /* rivets sur chaque bride */
    radial-gradient(circle at 30% 0.4rem, rgba(255, 235, 200, 0.5) 0 0.06rem, transparent 0.09rem) 0 0/100% 6rem repeat,
    radial-gradient(circle at 70% 0.4rem, rgba(255, 235, 200, 0.5) 0 0.06rem, transparent 0.09rem) 0 0/100% 6rem repeat,
    /* brides (joints) sombres périodiques */
    repeating-linear-gradient(180deg, rgba(0, 0, 0, 0.55) 0 0.35rem, transparent 0.35rem 6rem),
    repeating-linear-gradient(180deg, rgba(255, 220, 180, 0.15) 0.35rem 0.5rem, transparent 0.5rem 6rem),
    /* galbe cylindrique cuivre : ombre / reflet / coeur clair / reflet / ombre */
    linear-gradient(
      90deg,
      var(--bois) 0%,
      var(--cuivre-sombre) 12%,
      var(--cuivre) 30%,
      var(--cuivre-clair) 48%,
      #ffe9c8 54%,
      var(--cuivre-clair) 60%,
      var(--cuivre) 76%,
      var(--cuivre-sombre) 92%,
      var(--bois) 100%
    );
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.75), 2px 0 12px var(--ombre);
}

.tuyau--gauche {
  left: -0.1rem;
}

.tuyau--droite {
  right: -0.1rem;
}

/* --- Coudes/robinets en cuivre, greffés sur la tuyauterie --- */

.coude {
  position: fixed;
  width: 4.5rem;
  z-index: 1;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px var(--ombre));
}

.coude--gauche {
  top: 22rem;
  left: 0.3rem;
}

.coude--droite {
  top: 34rem;
  right: 0.3rem;
  transform: scaleX(-1);
}

/* --- Éclairs électriques occasionnels --- */

.eclair {
  position: fixed;
  width: 2.2rem;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  filter: drop-shadow(0 0 6px #bfe8ff) drop-shadow(0 0 12px #6fb6e0);
  animation: crepiter 9s ease-in-out infinite;
}

.eclair--1 {
  top: 21rem;
  left: 1.6rem;
  animation-duration: 11s;
  animation-delay: 1.5s;
}

.eclair--2 {
  top: 33.5rem;
  right: 1.6rem;
  transform: scaleX(-1);
  animation-duration: 8s;
  animation-delay: 4s;
}

@keyframes crepiter {
  0%, 92%, 100% { opacity: 0; }
  92.5% { opacity: 1; }
  93% { opacity: 0.2; }
  93.5% { opacity: 0.9; }
  94.5% { opacity: 0; }
  95% { opacity: 0.6; }
  95.5% { opacity: 0; }
}

/* --- Engrenages décoratifs --- */

.engrenage {
  position: fixed;
  width: 6rem;
  height: 6rem;
  filter: drop-shadow(0 3px 4px var(--ombre));
  pointer-events: none;
  z-index: 1;
  animation: tourner 40s linear infinite;
}

.engrenage--gauche {
  top: 1rem;
  left: -1.5rem;
}

.engrenage--droite {
  top: 3rem;
  right: -1.5rem;
  animation-direction: reverse;
  animation-duration: 32s;
}

@keyframes tourner {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.engrenage-mini {
  position: fixed;
  width: 2.6rem;
  height: 2.6rem;
  filter: drop-shadow(0 2px 3px var(--ombre));
  pointer-events: none;
  z-index: 1;
  animation: tourner 22s linear infinite reverse;
}

.engrenage-mini--gauche {
  top: 6.3rem;
  left: 2.9rem;
}

.engrenage-mini--droite {
  top: 8.3rem;
  right: 2.9rem;
  animation-direction: normal;
}

/* --- Éprouvettes en fond de laboratoire --- */

.eprouvettes {
  position: fixed;
  width: 4.5rem;
  bottom: 1rem;
  left: -0.5rem;
  opacity: 0.6;
  filter: drop-shadow(0 3px 5px var(--ombre));
  pointer-events: none;
  z-index: 1;
}

.bulle {
  animation: monter 3.2s ease-in infinite;
}

.bulle-2 {
  animation-delay: 1.1s;
}

.bulle-3 {
  animation-delay: 2.1s;
}

@keyframes monter {
  0% { transform: translateY(0); opacity: 0.8; }
  75% { opacity: 0.3; }
  100% { transform: translateY(-26px); opacity: 0; }
}

@media (max-width: 30rem) {
  .engrenage {
    width: 3.5rem;
    height: 3.5rem;
    opacity: 0.25;
  }
  .tuyau {
    width: 0.8rem;
    opacity: 0.4;
  }
  .engrenage-mini, .eprouvettes, .coude, .eclair {
    display: none;
  }
}

/* --- Panneau total : cadran principal en laiton --- */

header#total {
  position: relative;
  z-index: 2;
  border: 3px solid transparent;
  border-radius: 0.6rem;
  padding: 1.2rem 1.4rem;
  margin-bottom: 1.5rem;
  background-image:
    radial-gradient(circle at 88% 12%, rgba(79, 122, 92, 0.12), transparent 35%),
    linear-gradient(160deg, var(--fond-panneau-clair), var(--fond-panneau) 45%, var(--bois)),
    linear-gradient(135deg, var(--laiton-clair), var(--laiton-sombre) 45%, var(--laiton) 75%, var(--laiton-sombre));
  background-origin: border-box, padding-box, border-box;
  background-clip: border-box, padding-box, border-box;
  box-shadow:
    inset 0 2px 0 rgba(255, 230, 190, 0.12),
    inset 0 -3px 10px rgba(0, 0, 0, 0.65),
    0 5px 16px var(--ombre);
}

header#total h1 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin: 0 0 0.6rem;
  color: var(--laiton-clair);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}

.total-chiffre {
  font-size: 2rem;
  font-weight: 400;
  margin: 0;
  color: var(--laiton-clair);
  letter-spacing: 0.03em;
  text-shadow: 0 0 10px rgba(230, 193, 121, 0.4), 0 2px 0 rgba(0, 0, 0, 0.7);
}

#total-ecart {
  margin: 0.35rem 0 0;
  color: var(--texte);
}

#total-hors {
  margin: 0.35rem 0 0;
  color: var(--texte-att);
  font-size: 0.8rem;
}

/* --- Postes : compartiments du laboratoire --- */

.poste {
  position: relative;
  z-index: 2;
  border: 2px solid var(--bordure);
  border-radius: 0.4rem;
  margin-bottom: 0.7rem;
  overflow: hidden;
  background-image:
    radial-gradient(circle at 90% 90%, rgba(79, 122, 92, 0.08), transparent 40%),
    linear-gradient(180deg, var(--fond-panneau-clair), var(--fond-panneau) 55%, var(--bois));
  box-shadow:
    inset 0 1px 0 rgba(255, 230, 190, 0.06),
    inset 0 0 0 1px rgba(201, 154, 68, 0.18),
    0 3px 8px var(--ombre);
}

.poste-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  padding: 0.85rem 1rem;
  cursor: pointer;
  text-align: left;
}

.poste-header:hover {
  background: rgba(227, 154, 92, 0.08);
}

.poste-chevron {
  width: 1em;
  color: var(--laiton);
}

.poste-nom {
  flex: 1;
  letter-spacing: 0.02em;
  color: var(--texte);
}

/* --- Indicateurs de poste : part actuelle (neutre) + écart simulé (coloré) --- */

.poste-indicateurs {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex: 0 0 auto;
}

.poste-part, .poste-delta {
  font-variant-numeric: tabular-nums;
  color: var(--texte-att);
  background: linear-gradient(180deg, var(--bois-clair), var(--bois));
  border: 1px solid var(--laiton-sombre);
  border-radius: 0.25rem;
  padding: 0.15rem 0.45rem;
  font-size: 0.78rem;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
}

.poste-delta {
  min-width: 3.6rem;
  text-align: center;
}

.poste-delta--hausse {
  color: #f7e2da;
  border-color: color-mix(in srgb, var(--accent-negatif) 55%, black);
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent-negatif) 45%, var(--bois)), var(--bois));
}

.poste-delta--baisse {
  color: #e3f0da;
  border-color: color-mix(in srgb, var(--accent) 55%, black);
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 45%, var(--bois)), var(--bois));
}

.chaines {
  padding: 0.2rem 1rem 0.6rem;
}

.chaine {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--bordure);
  flex-wrap: wrap;
}

.chaine-libelle {
  flex: 0 0 9rem;
  font-size: 0.85rem;
  color: var(--texte-att);
}

/* --- Curseur façon manomètre en laiton --- */

.chaine-slider {
  flex: 1;
  min-width: 6rem;
  --valeur-pct: 0%;
  -webkit-appearance: none;
  appearance: none;
  height: 1.1rem;
  background: transparent;
  cursor: pointer;
}

.chaine-slider:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.chaine-slider::-webkit-slider-runnable-track {
  height: 0.6rem;
  border-radius: 0.3rem;
  background:
    linear-gradient(90deg, var(--cuivre-clair) 0%, var(--cuivre) var(--valeur-pct), transparent var(--valeur-pct)),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 5px),
    linear-gradient(180deg, var(--bois-clair), var(--bois));
  border: 1px solid var(--laiton-sombre);
  box-shadow: inset 0 2px 4px var(--ombre), inset 0 -1px 0 rgba(255, 220, 180, 0.08);
}

.chaine-slider::-moz-range-track {
  height: 0.6rem;
  border-radius: 0.3rem;
  background: linear-gradient(180deg, var(--bois-clair), var(--bois));
  border: 1px solid var(--laiton-sombre);
  box-shadow: inset 0 2px 4px var(--ombre);
}

.chaine-slider::-moz-range-progress {
  height: 0.6rem;
  border-radius: 0.3rem 0 0 0.3rem;
  background: linear-gradient(90deg, var(--cuivre-sombre), var(--cuivre-clair));
}

.chaine-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  margin-top: -0.45rem;
  background: radial-gradient(circle at 32% 26%, #fff3d6 0%, var(--laiton-clair) 22%, var(--laiton) 55%, var(--laiton-sombre) 90%, var(--bois) 100%);
  border: 1px solid var(--bois);
  box-shadow:
    inset 0.08rem 0.08rem 0.18rem rgba(255, 250, 230, 0.7),
    inset -0.1rem -0.1rem 0.2rem rgba(0, 0, 0, 0.55),
    0 2px 5px var(--ombre);
}

.chaine-slider::-moz-range-thumb {
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  border: 1px solid var(--bois);
  background: radial-gradient(circle at 32% 26%, #fff3d6 0%, var(--laiton-clair) 22%, var(--laiton) 55%, var(--laiton-sombre) 90%, var(--bois) 100%);
  box-shadow:
    inset 0.08rem 0.08rem 0.18rem rgba(255, 250, 230, 0.7),
    inset -0.1rem -0.1rem 0.2rem rgba(0, 0, 0, 0.55),
    0 2px 5px var(--ombre);
}

.chaine-slider:disabled::-webkit-slider-thumb {
  background: radial-gradient(circle at 32% 26%, #b9b9b9, #7c7c7c 55%, #494949 100%);
}

.chaine-slider:disabled::-moz-range-thumb {
  background: radial-gradient(circle at 32% 26%, #b9b9b9, #7c7c7c 55%, #494949 100%);
}

.chaine-pct {
  flex: 0 0 3.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  color: var(--laiton-clair);
}

/* --- Bouton de verrou : cadenas en laiton --- */

.chaine-verrou {
  flex: 0 0 auto;
  width: 1.9rem;
  height: 1.9rem;
  padding: 0.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--laiton-sombre);
  border-radius: 0.3rem;
  background: linear-gradient(180deg, var(--fond-panneau-clair), var(--bois));
  color: var(--texte-att);
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 230, 190, 0.1), 0 1px 3px var(--ombre);
}

.chaine-verrou .icone-cadenas {
  width: 1.1rem;
  height: 1.1rem;
}

.chaine-verrou:hover {
  border-color: var(--laiton);
  color: var(--laiton-clair);
}

.chaine-verrou[aria-pressed='true'] {
  background: linear-gradient(180deg, var(--cuivre-clair), var(--cuivre-sombre));
  color: var(--bois);
  border-color: var(--laiton);
  text-shadow: 0 1px 0 rgba(255, 240, 210, 0.3);
}

.chaine-verrouillee {
  opacity: 0.88;
}

.chaine-plafond {
  flex: 0 0 auto;
  font-size: 0.7rem;
  color: var(--texte-att);
}

/* --- Icône d'alerte discrète : seulement pour les chiffres à prendre avec des pincettes --- */

.chaine-alerte {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  color: var(--accent-negatif);
  cursor: help;
}

.chaine-alerte .icone-alerte {
  width: 1rem;
  height: 1rem;
}

/* --- Bouton réinitialiser (global) --- */

.reset-global {
  position: relative;
  z-index: 2;
  display: block;
  margin: 0 auto 1rem;
  padding: 0.5rem 1.1rem;
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--laiton-sombre);
  border-radius: 0.3rem;
  background: linear-gradient(180deg, var(--fond-panneau-clair), var(--bois));
  color: var(--laiton-clair);
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 230, 190, 0.1), 0 1px 3px var(--ombre);
}

.reset-global:hover {
  background: linear-gradient(180deg, var(--cuivre-clair), var(--cuivre-sombre));
  color: var(--bois);
}

/* --- Onglets --- */

.onglets {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.2rem;
}

.onglet {
  flex: 1;
  font-family: 'Cinzel', serif;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.65rem 0.5rem;
  border: 1px solid var(--laiton-sombre);
  border-radius: 0.4rem 0.4rem 0 0;
  background: linear-gradient(180deg, var(--fond-panneau-clair), var(--bois));
  color: var(--texte-att);
  cursor: pointer;
}

.onglet[aria-selected='true'] {
  background: linear-gradient(180deg, var(--cuivre-clair), var(--cuivre-sombre));
  color: var(--bois);
  border-color: var(--laiton);
}

/* --- Onglet d'explication --- */

.explication {
  position: relative;
  z-index: 2;
  background-image:
    radial-gradient(circle at 90% 90%, rgba(79, 122, 92, 0.08), transparent 40%),
    linear-gradient(180deg, var(--fond-panneau-clair), var(--fond-panneau) 55%, var(--bois));
  border: 2px solid var(--bordure);
  border-radius: 0.4rem;
  padding: 1.2rem 1.4rem;
  box-shadow:
    inset 0 1px 0 rgba(255, 230, 190, 0.06),
    inset 0 0 0 1px rgba(201, 154, 68, 0.18),
    0 3px 8px var(--ombre);
}

.explication h2 {
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  color: var(--laiton-clair);
  margin: 1.3rem 0 0.5rem;
}

.explication h2:first-child {
  margin-top: 0;
}

.explication h3 {
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  color: var(--texte);
  margin: 1rem 0 0.4rem;
}

.explication p, .explication li {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--texte-att);
}

.explication strong {
  color: var(--laiton-clair);
}

.explication ul {
  padding-left: 1.2rem;
  margin: 0.4rem 0;
}
