/* ─────────────────────────────────────────────────────────────
   RÉGLAGES — couleurs, police, tailles
   ───────────────────────────────────────────────────────────── */
:root {
  --fond: #ffffff;
  --texte: #000000;
  --bordure-photo: #cfcfcf; /* bord des images des projets avec « bordure: true » */
  --gris: #5f5c5c;          /* cadres des images + ligne sous la barre */
  --gris-clair: #8a8686;
  --police: "Heiti TC", "STHeiti", "PingFang TC", "Helvetica Neue", Arial, sans-serif;
  --hauteur-barre: 64px;
  --cadre: 10px;            /* épaisseur du cadre gris autour des images */
  --marge: clamp(16px, 3vw, 48px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: var(--hauteur-barre); }
body {
  background: var(--fond);
  color: var(--texte);
  font-family: var(--police);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ── Barre du haut ─────────────────────────────────────────── */
.barre {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  height: var(--hauteur-barre);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--marge);
  background: var(--fond);
  border-bottom: 1px solid var(--texte);
  font-size: clamp(15px, 1.7vw, 24px);
  text-transform: lowercase;
}
.barre nav { display: flex; gap: clamp(14px, 5vw, 90px); }
.barre a:hover, .barre a[aria-current] { text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 1px; }
main { padding-top: var(--hauteur-barre); animation: apparition .5s both; }
.arrivee main { animation: none; }
@keyframes apparition { from { opacity: 0; } }

/* ── Accueil : grande image ────────────────────────────────── */
.hero {
  position: relative;
  height: calc(100svh - var(--hauteur-barre));
  min-height: 420px;
  overflow: hidden;
}
.hero .fond img { width: 100%; height: 100%; object-fit: cover; will-change: transform; }
.hero h1 {
  position: absolute; left: var(--marge); top: 50%; transform: translateY(-40%);
  font-weight: 400;
  font-size: clamp(64px, 13vw, 200px);
  line-height: .9;
  letter-spacing: -.01em;
  text-transform: lowercase;
  pointer-events: none;
  /* le nom prend la couleur inverse de ce qui passe dessous (mettre "normal" + color: #000 pour du noir simple) */
  color: #fff;
  mix-blend-mode: difference;
}
.hero .mot { display: block; }

/* ── Accueil : cube d'images ───────────────────────────────── */
.hero-cube {
  --cote: min(36vw, 46svh);  /* taille du cube */
  touch-action: pan-y;
  background: var(--fond); /* nécessaire pour que le nom (mode différence) apparaisse en noir */
}
.scene-cube {
  position: absolute; left: 50%; top: 50%;
  width: var(--cote); height: var(--cote);
  margin: calc(var(--cote) / -2) 0 0 calc(var(--cote) / -2);
  perspective: 1400px;
  z-index: 1;
}
.cube { position: absolute; inset: 0; transform-style: preserve-3d; }
.face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.face img { width: 100%; height: 100%; object-fit: cover; }
/* faces « à charnières » : chaque face pivote autour d'une arête, ce qui permet au cube de se déplier */
.face { --d: calc(var(--cote) / 2); }
.face.avant   { transform: translateZ(var(--d)); }
.face.droite  { transform: translateZ(var(--d)) translateX(var(--d)) rotateY(90deg) translateX(var(--d)); }
.face.arriere { transform: translateZ(var(--d)) translateX(var(--d)) rotateY(90deg) translateX(var(--cote)) rotateY(90deg) translateX(var(--d)); }
.face.gauche  { transform: translateZ(var(--d)) translateX(calc(var(--d) * -1)) rotateY(-90deg) translateX(calc(var(--d) * -1)); }
.face.haut    { transform: translateZ(var(--d)) translateY(calc(var(--d) * -1)) rotateX(90deg) translateY(calc(var(--d) * -1)); }
.face.bas     { transform: translateZ(var(--d)) translateY(var(--d)) rotateX(-90deg) translateY(var(--d)); }

/* ── Transition liste → projet : le cube grandit jusqu'à la place de l'image ── */
.voile { position: fixed; inset: 0; z-index: 90; background: var(--fond); opacity: 0; transition: opacity .35s; }
.voile.visible { opacity: 1; }
.cube-transition {
  position: fixed; z-index: 91; pointer-events: none;
  perspective: 1400px;
  transform-origin: 0 0;
  transition: transform .9s cubic-bezier(.65, 0, .35, 1);
}
.cube-transition .cube { transition: transform .9s cubic-bezier(.65, 0, .35, 1); }
.cube-transition .face { backface-visibility: visible; -webkit-backface-visibility: visible; transition: transform .8s cubic-bezier(.65, 0, .35, 1), opacity .4s; }

/* arrivée sur la page projet : l'image remplace le cube, s'ouvre à sa taille entière, puis le texte apparaît */
.projet .texte, .projet .indice, .suivant { transition: opacity .7s .6s, transform .7s .6s cubic-bezier(.65, 0, .35, 1); }
.arrivee .projet .ouvrir img { opacity: 0; }
.arrivee .projet .texte, .arrivee .projet .indice, .arrivee .suivant { opacity: 0; transform: translateY(24px); }
.hero-cube h1 { z-index: 2; }
.hero-cube + .liste { padding-top: clamp(40px, 8vh, 90px); }
.hero .lettre { display: inline-block; will-change: transform; }
.hero .fleche-bas {
  position: absolute; left: 50%; bottom: 3vh; transform: translateX(-50%);
  width: clamp(48px, 7vw, 100px);
}

/* ── Carrousel (accueil + lightbox) ────────────────────────── */
.carrousel { position: relative; overflow: hidden; }
.carrousel .piste {
  display: flex; gap: var(--ecart);
  transition: transform .6s cubic-bezier(.65, 0, .35, 1);
  will-change: transform;
}
.carrousel .fleche {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: clamp(48px, 7vw, 110px); padding: 8px;
}
.carrousel .fleche.gauche { left: 0; }
.carrousel .fleche.droite { right: 0; }
.carrousel .fleche svg { width: 100%; display: block; }
.carrousel.seul .fleche { display: none; }

.accueil-carrousel { --ecart: clamp(24px, 4.5vw, 64px); padding: clamp(64px, 12vh, 120px) 0; }
/* l'image au centre grandit, les autres rapetissent (taille réglable ici) */
.carte {
  flex: 0 0 clamp(220px, 28vw, 400px);
  transform: scale(.78);
  transition: transform .6s cubic-bezier(.65, 0, .35, 1);
}
.carte.active { transform: scale(1.12); }
.grille .carte { transform: none; }
.cadre {
  display: block; aspect-ratio: 1;
  border: var(--cadre) solid var(--gris);
  overflow: hidden;
}
.cadre img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
.carte:hover .cadre img { transform: scale(1.03); }
.legende { display: block; margin-top: 12px; font-size: 16px; text-transform: lowercase; }

/* ── Page liste : grille ───────────────────────────────────── */
.grille {
  display: grid; gap: clamp(28px, 4vw, 56px);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  padding: clamp(40px, 8vh, 90px) var(--marge);
}

/* ── Croix de fermeture ────────────────────────────────────── */
.croix {
  position: fixed; top: calc(var(--hauteur-barre) + 20px); right: var(--marge); z-index: 40;
  width: 44px; height: 44px;
}
.croix svg { width: 100%; height: 100%; }
.croix:hover { opacity: .5; }

/* ── Page projet ───────────────────────────────────────────── */
.projet {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: clamp(32px, 5vw, 96px);
  padding: clamp(48px, 10vh, 110px) var(--marge) 64px;
  align-items: start;
}
.projet .ouvrir { display: block; position: relative; text-align: left; width: 100%; }
.projet .ouvrir img {
  width: 100%; height: auto; max-height: calc(100svh - var(--hauteur-barre) - 140px); object-fit: contain; object-position: left top;
}
.projet .ouvrir .indice { display: block; margin-top: 12px; font-size: 15px; color: var(--gris-clair); }
.projet .ouvrir:hover .indice { color: var(--texte); }
.projet .texte { padding-right: 56px; position: sticky; top: calc(var(--hauteur-barre) + 40px); }
.projet h1 {
  font-weight: 400; font-size: clamp(40px, 6vw, 88px); line-height: .95;
  text-transform: lowercase; margin-bottom: 8px;
}
.projet .annee { color: var(--gris-clair); margin-bottom: 32px; }
.paragraphes p { font-size: clamp(16px, 1.25vw, 19px); line-height: 1.6; max-width: 56ch; margin-bottom: 1em; }
.lien-serie { display: inline-block; margin-top: 16px; font-size: 18px; border-bottom: 1px solid; padding-bottom: 2px; }
.suivant { display: flex; justify-content: space-between; padding: 0 var(--marge) 48px; text-transform: lowercase; color: var(--gris-clair); }
.suivant a:hover { color: var(--texte); }

/* ── Lightbox ──────────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: var(--fond);
  display: flex; flex-direction: column; justify-content: center;
  opacity: 0; visibility: hidden;
  transition: opacity .45s, visibility 0s .45s;
}
.lightbox.ouverte { opacity: 1; visibility: visible; transition: opacity .45s; }
/* pendant que l'image vole vers le centre (ou en repart) : le reste de la série attend */
.lightbox .fleche, .lightbox .compteur, .lightbox .croix { transition: opacity .5s; }
.lightbox.en-vol .diapo.active img { visibility: hidden; }
.lightbox.en-vol .diapo:not(.active), .lightbox.en-vol .fleche,
.lightbox.en-vol .compteur, .lightbox.en-vol .croix { opacity: 0; }
.image-volante {
  position: fixed; z-index: 120; object-fit: cover; pointer-events: none;
  transition: left .7s, top .7s, width .7s, height .7s;
  transition-timing-function: cubic-bezier(.65, 0, .35, 1);
}
.lightbox .croix { top: 20px; }
.lightbox .carrousel { --ecart: 4vw; }
.lightbox .fleche { background: var(--fond); }
/* largeur de chaque diapo = largeur réelle de l'image à cette hauteur (--ratio posé en JS) */
.diapo {
  flex: 0 0 auto; height: calc(100svh - 150px);
  width: min(78vw, calc((100svh - 150px) * var(--ratio, 1)));
  opacity: .25; transform: scale(.7);
  transition: opacity .6s, transform .6s cubic-bezier(.65, 0, .35, 1);
}
.diapo.active { opacity: 1; transform: none; }
.diapo img { width: 100%; height: 100%; object-fit: contain; }
.lightbox .compteur { position: absolute; left: var(--marge); top: 30px; font-size: 16px; text-transform: lowercase; }

/* ── Page liste ────────────────────────────────────────────── */
.liste { padding: calc(var(--hauteur-barre) + clamp(48px, 9vh, 100px)) var(--marge) 80px; }
.liste-projets { list-style: none; border-top: 1px solid #dcdcdc; }
.liste-projets li { border-bottom: 1px solid #dcdcdc; transition: color .3s; }
.liste-projets a {
  display: grid; grid-template-columns: auto 1fr auto; gap: 0 2em; align-items: center;
  padding: .45em 0;
  transition: padding .3s cubic-bezier(.65, 0, .25, 1);
}
.liste-projets .titre .lettre { display: inline-block; will-change: transform; }
.liste-projets .fleche-liste { display: block; width: clamp(30px, 3.4vw, 50px); transition: transform .3s cubic-bezier(.65, 0, .25, 1); }
.liste-projets .fleche-liste svg { display: block; width: 100%; height: auto; }
.liste-projets li:hover .fleche-liste { transform: translateX(-.3em); }
.liste-projets .titre { font-size: clamp(30px, 4.8vw, 68px); line-height: 1.05; text-transform: lowercase; }
.liste-projets:hover li { color: var(--gris-clair); }
.liste-projets li:hover { color: var(--texte); }
.liste-projets li:hover a { padding-left: .6em; }

/* petit cube à la place du numéro : tourne lentement, plus vite au survol */
.mini-cube {
  --cote: clamp(34px, 3.6vw, 54px);
  position: relative; display: block;
  width: var(--cote); height: var(--cote);
  margin: 0 calc(var(--cote) * .25);
  perspective: 500px;
}
.mini-cube .cube { animation: tourne 14s linear infinite; }
.liste-projets li:hover .mini-cube .cube { animation-duration: 3s; }
@keyframes tourne {
  from { transform: rotateX(-22deg) rotateY(0deg); }
  to   { transform: rotateX(-22deg) rotateY(360deg); }
}

/* ── Page about ────────────────────────────────────────────── */
.about {
  display: grid; grid-template-columns: 2fr 1fr;
  gap: clamp(32px, 5vw, 72px) clamp(40px, 7vw, 110px);
  padding: calc(var(--hauteur-barre) + clamp(48px, 9vh, 100px)) var(--marge) 80px;
}
.about-texte p { font-size: clamp(17px, 1.45vw, 22px); line-height: 1.4; margin-bottom: 1em; max-width: 40em; }
.about-texte p:first-child { font-size: clamp(28px, 3.4vw, 52px); line-height: 1.1; margin-bottom: .8em; max-width: none; }  /* titre */
.about-infos { align-self: start; display: grid; grid-template-columns: auto 1fr; gap: .5em 1.5em; padding-top: .6em; }
.about-infos dt { color: var(--gris-clair); }
.about-contact { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .4em 2em; }
.grand-lien { font-size: clamp(22px, 2.4vw, 34px); border-bottom: 1px solid; }

/* ── Téléphone ─────────────────────────────────────────────── */
@media (max-width: 760px) {
  :root { --hauteur-barre: 56px; --cadre: 6px; }
  .projet, .about { grid-template-columns: 1fr; }
  .liste-projets a { gap: 0 1em; }
  .projet .texte { position: static; padding-right: 0; }
  .croix { width: 34px; height: 34px; top: calc(var(--hauteur-barre) + 12px); }
  .diapo { width: min(84vw, calc((100svh - 150px) * var(--ratio, 1))); }
  .carte { flex-basis: 68vw; }
}
@media (max-width: 480px) {
  .barre { font-size: 14px; }
  .barre nav { gap: 12px; }
}

/* Projets avec « bordure: true » (js/textes.js) : fin bord pour séparer les pages blanches du fond */
.avec-bordure .projet .ouvrir img,
.avec-bordure .diapo img,
.avec-bordure .image-volante { outline: 1px solid var(--bordure-photo); outline-offset: -1px; }
