:root {
  --texte: #111;
  --gris: #8a8a8a;
  --gris-clair: #c8c8c8;
  --marge-v: max(6vh, 56px);   /* marge haut et bas autour de la toile */
  --marge-d: 5vw;              /* marge à droite de la zone de la toile */
  --bord: 24px;                /* marge gauche, alignée sur le nom */
  --mini: 34px;                /* côté d'une miniature au repos (ajusté en JS sur les petits écrans) */
  --mini-ecart: 8px;           /* espace entre deux miniatures */
  --loupe: 2.5;                /* grossissement max des miniatures, même valeur que LOUPE_MAX dans script.js */
  --cartel-gauche: calc(var(--bord) + var(--mini) * var(--loupe) + 14px); /* cartel à droite des miniatures, même agrandies */
  --courbe: cubic-bezier(.25, .1, .25, 1);
}

html {
  background: #fff;
  scroll-snap-type: y mandatory;
}

body {
  margin: 0;
  background: #fff;
  color: var(--gris);
  font: 12.5px/1.55 -apple-system, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
p { margin: 0; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

/* En-tête */
.entete {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  padding: 20px 24px;
  pointer-events: none;
}
.entete a { color: var(--texte); pointer-events: auto; }

/* Un écran par toile */
.ecran {
  height: 100vh;
  height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
}

.rangee {
  position: relative;
  display: flex;
  justify-content: flex-end; /* zone de la toile à droite */
  align-items: flex-end;
  width: 100%;
}

.gauche {
  /* cartel collé à gauche de l'écran, aligné sur le bas de la toile */
  position: absolute;
  left: 0;
  bottom: 0;
  padding-left: var(--cartel-gauche);
  text-align: left;
}
.ecran-info .gauche { position: static; }

.droite {
  flex: 0 0 55%;
  box-sizing: border-box;
  padding-right: var(--marge-d);
  display: flex;
  justify-content: center; /* toile centrée dans sa zone */
}

.droite picture { display: block; }

.toile {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100dvh - 2 * var(--marge-v));
  object-fit: contain;
  cursor: zoom-in;
}

/* Miniatures : colonne à gauche, effet loupe en JS */
.miniatures {
  position: fixed;
  left: var(--bord);
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: var(--mini-ecart);
  pointer-events: none; /* seules les miniatures captent la souris */
}
.mini {
  display: flex;
  align-items: center;
  width: var(--mini);
  height: var(--mini);
  pointer-events: auto;
  transform-origin: left center;
  will-change: transform;
}
.mini picture {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
}
.miniatures[hidden] { display: none; }
.mini img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
}

/* Écran Info masqué tant que les toiles ne sont pas en place (sinon le snap s'y accroche) */
.js:not(.pret) .ecran-info { display: none; }

/* Cartel */
.cartel { position: relative; margin-bottom: var(--m, 0px); }
.cartel .titre { color: var(--texte); }
.compteur { margin-bottom: 1.6em; }
.plus {
  /* sous le cartel, hors alignement : ce sont les lignes de texte qui s'alignent sur le bas de la toile */
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: .7em;
  color: var(--gris-clair);
  font-size: 14px;
  line-height: 1;
}

/* Apparition */
.js .toile,
.js .ecran-toile .cartel {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .8s var(--courbe), transform .8s var(--courbe);
}
.js .ecran-toile .cartel { transition-delay: .25s; }
.js .vu .toile,
.js .vu .cartel {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .js .toile,
  .js .ecran-toile .cartel {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* Mobile */
@media (max-width: 767px) {
  .rangee {
    flex-direction: column;
    align-items: stretch;
    padding: 0 20px;
    box-sizing: border-box;
  }
  .droite { order: -1; flex: none; padding: 0; display: block; }
  .miniatures { display: none; }
  .gauche {
    position: static;
    flex: none;
    text-align: left;
    padding: 0 0 0 var(--m, 0px);
    margin-top: calc(14px - var(--m, 0px));
  }
  .toile { max-width: 100%; max-height: calc(100dvh - 230px); }
  .cartel { margin-bottom: 0; }
  .compteur { margin-bottom: .8em; }
  .ecran-info .gauche { margin-top: 0; }
}

/* Zoom */
.zoom {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: #fff;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.zoom[hidden] { display: none; }
.zoom-img {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  transform-origin: 0 0;
  cursor: grab;
}
.zoom-img.glisse { cursor: grabbing; }
.zoom-charge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--gris-clair);
  font-size: 11px;
}
.zoom-fermer {
  position: absolute;
  top: 14px;
  right: 18px;
  color: var(--gris);
  font-size: 20px;
  line-height: 1;
  padding: 4px;
}
