/* Tool Manager — schéma électrique sur papier : le bus CAN traverse la page et
   chaque outil s'y branche comme un calculateur. Aucun JavaScript : voir ../CLAUDE.md. */

@font-face {
  font-family: "Archivo";
  src: url("fontes/archivo-latin-wdth-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
@font-face {
  font-family: "Martian Mono";
  src: url("fontes/martian-mono-latin-wdth-normal.woff2") format("woff2");
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  font-display: swap;
}

:root {
  --papier: #efede4;
  --papier-clair: #f8f7f1;
  --encre: #121310;
  --doux: #55564e;
  --doux-clair: #b4b5aa;
  --quadrillage: #12131010;
  --largeur: 1200px;
  --marge: clamp(16px, 3.2vw, 32px);
  --ecart: 56px;
  --raccord: 32px;
  --fond-carte: var(--papier-clair);
  --texte-carte: var(--encre);
  --texte-doux: var(--doux);
  --jeu: paused;
  --titre: "Archivo", "Arial Black", "Segoe UI", system-ui, sans-serif;
  --mono: "Martian Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

/* Sur écran tactile, pas de survol : les visuels tournent d'eux-mêmes. */
@media (hover: none) {
  :root { --jeu: running; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

/* Sur un grand écran, le pied reste en bas et la dorsale s'allonge jusqu'à lui. */
body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100dvh;
  margin: 0;
  font-family: var(--titre);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--encre);
  background-color: var(--papier);
  background-image:
    linear-gradient(var(--quadrillage) 1px, transparent 1px),
    linear-gradient(90deg, var(--quadrillage) 1px, transparent 1px);
  background-size: 32px 32px;
  overflow-x: clip;
}

.meta,
.adr,
.etat,
.requis,
.terminaison {
  font-family: var(--mono);
  font-stretch: 75%;
  font-size: .6875rem;
  line-height: 1.4;
  letter-spacing: .02em;
  text-transform: uppercase;
}

/* ---------- En-tête ---------- */

.tete {
  width: 100%;
  max-width: var(--largeur);
  margin-inline: auto;
  padding: 10px var(--marge) 0;
}

.barre {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding-bottom: 5px;
  border-bottom: 2px solid var(--encre);
}

.marque {
  font-weight: 900;
  font-stretch: 125%;
  font-size: 1rem;
  letter-spacing: .02em;
}

/* Le titre tient sur une ligne : le filin et le hub passent après « Manager ».
   Pourquoi ce format : voir ../CLAUDE.md, « Décisions ». */
h1 {
  display: flex;
  align-items: center;
  gap: .24em;
  margin: 10px 0 0;
  font-weight: 800;
  font-stretch: 125%;
  font-size: min(6.4vw, 40px);
  line-height: 1;
  letter-spacing: -.02em;
  text-transform: uppercase;
}

.ligne-1 { display: contents; }
.ligne-2 { order: 1; }
.filin { order: 2; }
.hub { order: 3; }

.filin {
  flex: 1;
  height: .09em;
  min-height: 8px;
  margin-right: -.08em;
  border-block: max(2px, .018em) solid var(--encre);
}

.hub {
  flex: none;
  width: .92em;
  height: .92em;
  margin-block: -.04em;
  overflow: visible;
}

.hub-iso {
  font-family: var(--titre);
  font-weight: 900;
  font-stretch: 100%;
  font-size: 10.4px;
  letter-spacing: 0;
  fill: #000;
}

.onde {
  fill: none;
  stroke-width: 1.2;
  transform-box: fill-box;
  transform-origin: center;
  animation: onde 3.6s ease-out infinite;
}
.o-vert { stroke: #009900; }
.o-rouge { stroke: #ff0000; animation-delay: 1.2s; }
.o-bleu { stroke: #0000ff; animation-delay: 2.4s; }

@keyframes onde {
  from { transform: scale(1); opacity: .9; }
  70%, to { transform: scale(2.3); opacity: 0; }
}

.accroche {
  margin: 4px 0 0;
  font-size: .9375rem;
  font-weight: 500;
  font-stretch: 100%;
  line-height: 1.3;
  text-wrap: balance;
}

/* ---------- Le bus et ses modules ---------- */

.bus {
  position: relative;
  width: 100%;
  max-width: var(--largeur);
  margin-inline: auto;
  padding: 12px var(--marge) 36px;
}

/* Une famille : son bandeau coupe la dorsale, ses cartes s'y branchent dessous. */
.famille + .famille { margin-top: 14px; }

.famille-tete {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 2px 16px;
  padding: 3px 12px 4px;
  color: var(--papier);
  background: var(--encre);
  border-radius: 3px;
}
.famille-tete h2 {
  margin: 0;
  font-weight: 800;
  font-stretch: 125%;
  font-size: .9375rem;
  line-height: 1.2;
  letter-spacing: .01em;
  text-transform: uppercase;
}
.famille-tete .meta { margin: 0; color: var(--doux-clair); }

.cartes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: var(--ecart);
  row-gap: 10px;
  margin-top: 10px;
}

.dorsale {
  position: absolute;
  top: 0;
  bottom: 26px;
  left: 50%;
  width: 12px;
  margin-left: -6px;
  border-inline: 2px solid var(--encre);
}

.trame {
  position: absolute;
  left: -2px;
  width: 12px;
  height: 30px;
  animation: trame 15s linear infinite;
}
.t1 { background: #009900; }
.t2 { background: #ff0000; animation-delay: -5s; }
.t3 { background: #0000ff; animation-delay: -10s; }

@keyframes trame {
  from { top: 0; opacity: 0; }
  2% { opacity: 1; }
  98% { opacity: 1; }
  to { top: calc(100% - 30px); opacity: 0; }
}

.terminaison {
  position: absolute;
  top: 100%;
  left: 50%;
  padding: 3px 7px 2px;
  translate: -50% 0;
  color: var(--papier);
  background: var(--encre);
  border-radius: 2px;
}

/* Une carte tient sur quatre lignes, son visuel en vignette à gauche : toute la
   page doit tenir à l'écran. Pourquoi : voir ../CLAUDE.md, « Décisions ». */
.module {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 34% minmax(0, 1fr);
  grid-template-rows: auto auto auto 1fr;
  column-gap: 12px;
  min-width: 0;
  padding: 9px 12px;
  color: var(--texte-carte);
  background: var(--fond-carte);
  border: 2px solid var(--encre);
  border-radius: 3px;
  text-decoration: none;
  transition: background-color .16s ease, color .16s ease;
}

.module:nth-child(odd) { grid-column: 1; }
.module:nth-child(even) { grid-column: 2; }

/* La dérivation : deux fils du module à la dorsale, et son point de raccord. */
.module::before {
  content: "";
  position: absolute;
  top: calc(var(--raccord) - 6px);
  height: 12px;
  width: calc(var(--ecart) / 2 - 2px);
  border-block: 2px solid var(--encre);
}
.module::after {
  content: "";
  position: absolute;
  top: calc(var(--raccord) - 10px);
  width: 20px;
  height: 20px;
  background: var(--encre);
  border: 2px solid var(--encre);
  border-radius: 50%;
  transition: background-color .16s ease;
}
.module:nth-child(odd)::before { left: calc(100% + 2px); }
.module:nth-child(odd)::after { left: calc(100% + var(--ecart) / 2 - 8px); }
.module:nth-child(even)::before { right: calc(100% + 2px); }
.module:nth-child(even)::after { right: calc(100% + var(--ecart) / 2 - 8px); }

.m-vert { --sig-sombre: #009900; --sig-vif: #2bd14a; --sig: var(--sig-sombre); }
.m-bleu { --sig-sombre: #0000ff; --sig-vif: #7c8cff; --sig: var(--sig-sombre); }
.m-rouge { --sig-sombre: #e01b0c; --sig-vif: #ff5a4a; --sig: var(--sig-sombre); }

a.module:hover,
a.module:focus-visible {
  --fond-carte: var(--encre);
  --texte-carte: var(--papier);
  --texte-doux: var(--doux-clair);
  --sig: var(--sig-vif);
}
a.module:hover::after,
a.module:focus-visible::after { background: var(--sig-sombre); }

.module:hover,
.module:focus-visible { --jeu: running; }

a.module:focus-visible {
  outline: 3px solid var(--sig-sombre);
  outline-offset: 3px;
}

.module-tete {
  grid-column: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 16px;
}

.adr { white-space: nowrap; }

.etat {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-align: right;
}
.etat::before {
  content: "";
  flex: none;
  width: 9px;
  height: 9px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}
.etat.en-ligne::before { background: #009900; border-color: #009900; }
.etat.local::before { border-radius: 0; }

.visuel {
  grid-column: 1;
  grid-row: 1 / -1;
  align-self: center;
  display: block;
  width: 100%;
  height: auto;
  overflow: hidden;
}
/* Trop petit à cette échelle pour se lire : la vignette montre sans écrire. */
.visuel text { display: none; }

.module h3 {
  grid-column: 2;
  margin: 3px 0 0;
  font-weight: 750;
  font-stretch: 125%;
  font-size: 1.125rem;
  line-height: 1.1;
  letter-spacing: -.015em;
}

.module p {
  grid-column: 2;
  margin: 2px 0 0;
  font-size: .8125rem;
  line-height: 1.3;
  color: var(--texte-doux);
  transition: color .16s ease;
}
.module em { font-style: normal; font-weight: 600; color: var(--texte-carte); }

.module-pied {
  grid-column: 2;
  align-self: end;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 3px;
}

.fleche {
  flex: none;
  width: 24px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  transition: transform .2s cubic-bezier(.2, .7, .2, 1);
}
a.module:hover .fleche,
a.module:focus-visible .fleche { transform: translateX(6px); }

.attente { background: transparent; }

/* La prise libre ne dit qu'une chose : une seule ligne, sans vignette. */
.prise {
  --raccord: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 10px;
  background: transparent;
  border-style: dashed;
}
.prise .visuel { display: none; }
.prise h3, .prise p { margin: 0; }
.prise::before { border-block-style: dashed; }
.prise::after { background: var(--papier); }

/* ---------- Visuels : à l'arrêt, chacun montre une image parlante ;
   le survol lance le mouvement (--jeu). ---------- */

.anim { animation-play-state: var(--jeu); }

.v-mono {
  font-family: var(--mono);
  font-stretch: 75%;
  font-size: 15px;
  letter-spacing: .02em;
  fill: currentColor;
  white-space: pre;
}
.v-mono.centre { text-anchor: middle; }

.v-onde {
  animation: defile 3.2s linear infinite;
  animation-play-state: var(--jeu);
}
@keyframes defile { to { transform: translateX(-160px); } }

.v-boutons rect {
  fill: var(--sig);
  fill-opacity: 0;
  stroke: currentColor;
  stroke-width: 2.5;
  animation: bouton 5.4s linear infinite var(--jeu);
  animation-delay: var(--d, -2.2s);
}
.v-boutons text {
  font-family: var(--mono);
  font-stretch: 75%;
  font-size: 13px;
  text-anchor: middle;
  fill: currentColor;
  animation: bouton-texte 5.4s linear infinite var(--jeu);
  animation-delay: var(--d, -2.2s);
}
.bt:nth-child(3n) { --d: -1.2s; }
.bt:nth-child(3n+1) { --d: -3.3s; }
.bt:nth-child(5n) { --d: -.2s; }
.bt:nth-child(7n) { --d: -4.4s; }
@keyframes bouton {
  0%, 16%, 100% { fill-opacity: 0; }
  17%, 34% { fill-opacity: 1; }
  35% { fill-opacity: 0; }
}
@keyframes bouton-texte {
  0%, 16%, 100% { fill: currentColor; }
  17%, 34% { fill: #fff; }
  35% { fill: currentColor; }
}

/* Plantation : les pieds plantés et le viseur avancent ensemble.
   Le délai négatif fixe l'image à l'arrêt à 60 % du trajet. */
.v-plantes {
  clip-path: inset(0 40% 0 0);
  animation: plante 8s linear -4.8s infinite;
  animation-play-state: var(--jeu);
}
@keyframes plante {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}
.v-viseur {
  animation: viseur 8s linear -4.8s infinite;
  animation-play-state: var(--jeu);
}
@keyframes viseur {
  from { transform: translateX(-288px); }
  to { transform: translateX(192px); }
}

.v-manquants circle {
  transform-box: fill-box;
  transform-origin: center;
  animation: manquant 2.4s ease-in-out infinite;
  animation-play-state: var(--jeu);
}
.v-manquants circle:nth-child(2n) { animation-delay: -.8s; }
.v-manquants circle:nth-child(3n) { animation-delay: -1.6s; }
@keyframes manquant {
  50% { transform: scale(1.35); }
}

/* Alerte : deux ondes partent de l'obstacle que le tracteur approche.
   Les délais négatifs les figent à mi-course à l'arrêt. */
.v-alerte circle {
  transform-box: fill-box;
  transform-origin: center;
  animation: alerte 2s ease-out -1.2s infinite;
  animation-play-state: var(--jeu);
}
.v-alerte circle:nth-child(2) { animation-delay: -.2s; }
@keyframes alerte {
  from { transform: scale(.25); opacity: 1; }
  to { transform: scale(1); opacity: 0; }
}

.v-passes {
  stroke-dasharray: 100;
  stroke-dashoffset: 0;
}
.module:hover .v-passes,
.module:focus-visible .v-passes { animation: trace 3.6s cubic-bezier(.4, 0, .4, 1) both; }
@keyframes trace {
  from { stroke-dashoffset: 100; }
  to { stroke-dashoffset: 0; }
}

.aiguille {
  transform-origin: 100px 118px;
  animation: aiguille-1 3.4s ease-in-out -1.1s infinite alternate;
  animation-play-state: var(--jeu);
}
.a2 {
  transform-origin: 270px 118px;
  animation-name: aiguille-2;
  animation-duration: 4.6s;
}
@keyframes aiguille-1 {
  from { transform: rotate(-58deg); }
  to { transform: rotate(38deg); }
}
@keyframes aiguille-2 {
  from { transform: rotate(-20deg); }
  to { transform: rotate(62deg); }
}

.v-relevage {
  transform-box: fill-box;
  transform-origin: bottom;
  animation: relevage 3s ease-in-out -.9s infinite alternate;
  animation-play-state: var(--jeu);
}
@keyframes relevage {
  from { transform: scaleY(.18); }
  to { transform: scaleY(.94); }
}

/* Les modules se posent au fil du défilement, là où le navigateur sait le faire. */
@supports (animation-timeline: view()) {
  .bus .module {
    animation: pose linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 26%;
  }
  @keyframes pose {
    from { opacity: 0; translate: 0 28px; }
    to { opacity: 1; translate: 0 0; }
  }
}

/* ---------- Pied ---------- */

.pied {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  align-items: center;
  gap: 2px 32px;
  padding-block: 8px;
  padding-inline: max(var(--marge), calc((100% - var(--largeur)) / 2 + var(--marge)));
  color: var(--papier);
  background: var(--encre);
}
.pied-phrase {
  margin: 0;
  font-size: .8125rem;
  font-weight: 500;
  line-height: 1.3;
}
.pied .meta { margin: 0; color: var(--doux-clair); }

/* ---------- Une colonne : la dorsale passe à gauche, tout se branche à droite ---------- */

@media (max-width: 860px) {
  :root { --ecart: 34px; }

  .bus {
    padding-left: calc(var(--marge) + var(--ecart));
  }
  .cartes {
    grid-template-columns: 1fr;
    row-gap: 8px;
    margin-top: 8px;
  }
  .dorsale {
    left: calc(var(--marge) + 8px);
  }
  .terminaison { padding-inline: 5px; }

  .module:nth-child(n) {
    grid-column: 1;
  }
  .module:nth-child(n)::before {
    left: auto;
    right: calc(100% + 2px);
    width: calc(var(--ecart) - 7px);
  }
  .module:nth-child(n)::after {
    left: auto;
    right: calc(100% + var(--ecart) - 15px);
    width: 18px;
    height: 18px;
    top: calc(var(--raccord) - 9px);
  }
  .meta { font-size: .625rem; }
}

/* Téléphone : le titre repasse sur deux lignes, le filin mène au hub sur la première. */
@media (max-width: 560px) {
  h1 {
    display: block;
    font-size: 11vw;
  }
  .module { grid-template-columns: minmax(0, 1fr); }
  .visuel { display: none; }
  .module-tete, .module h3, .module p, .module-pied { grid-column: 1; }
  .ligne-1 {
    display: flex;
    align-items: center;
    gap: .12em;
  }
  .ligne-2 { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  .onde, .trame { display: none; }
  .anim,
  .v-boutons rect,
  .v-boutons text { animation-play-state: paused !important; }
  .module:hover .v-passes,
  .module:focus-visible .v-passes { animation: none; }
  .bus .module { animation: none; }
  .module, .fleche, .module p { transition: none; }
}
