/* Pages projet « dans le tableau » (Meishinji, Sacred Tree) : on vient d'entrer dans la toile.
   En haut, le rendu en plans séparés qui bougent en parallaxe ; en descendant, le making-of
   (sections numérotées dans l'ordre de construction de la scène), repris de l'ancien site validé.
   Le monde du tableau garde ses couleurs (cèdre et or de lanterne) ; la barre du jeu reste la même partout.
   Les colonnes des props se règlent par page avec --props-col (4 par défaut). */

.page-projet {
  --cedar: #0e1812;      /* fond : le vert presque noir de la forêt */
  --cedar-2: #15241b;    /* surfaces */
  --mist: #f0e9dc;       /* texte principal */
  --ash: rgba(240, 233, 220, .68);  /* texte secondaire */
  --lantern: #d1aa5e;    /* accent : l'or des lanternes */
  --higanbana: #a33a2a;
  --line: rgba(209, 170, 94, .2);
  --f-title: var(--ecriture);
  --f-display: "Zen Old Mincho", "Hiragino Mincho ProN", "Yu Mincho", Georgia, serif;
  --f-body: var(--lecture);
  --measure: 62ch;
  background: #0b130e; color: var(--mist);
  font-size: 1.0625rem; line-height: 1.7;
}
.page-projet ::selection { background: rgba(209, 170, 94, .35); }
.page-projet :focus-visible { outline: 2px solid var(--lantern); outline-offset: 3px; }
.wrap {
  max-width: 1240px; margin-inline: auto;
  padding-left: max(1rem, env(safe-area-inset-left, 0px));
  padding-right: max(1rem, env(safe-area-inset-right, 0px));
}
.page-projet img, .page-projet video { display: block; max-width: 100%; height: auto; }
.page-projet :is(h1, h2, h3) { font-family: var(--f-title); font-weight: 400; text-wrap: balance; margin: 0; font-variant-numeric: lining-nums; }
.page-projet p { margin: 0; }
.mono { font-family: var(--f-body); font-weight: 600; font-size: .85rem; letter-spacing: .08em; color: var(--ash); }

/* fond « brume vivante » (choix du 2026-11-20) : trois halos très lents et un grain */
.fond-brume { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.fond-brume i { position: absolute; width: 95vmax; height: 95vmax; border-radius: 50%; will-change: transform; }
.fond-brume i:nth-child(1) { left: -30vmax; top: -40vmax; background: radial-gradient(circle, rgba(47, 98, 68, .85) 0%, rgba(47, 98, 68, 0) 62%); animation: fond-a 46s ease-in-out infinite alternate; }
.fond-brume i:nth-child(2) { right: -35vmax; top: 5vmax; background: radial-gradient(circle, rgba(20, 66, 60, .9) 0%, rgba(20, 66, 60, 0) 60%); animation: fond-b 58s ease-in-out infinite alternate; }
.fond-brume i:nth-child(3) { left: 5vmax; bottom: -55vmax; background: radial-gradient(circle, rgba(209, 170, 94, .2) 0%, rgba(209, 170, 94, 0) 58%); animation: fond-c 52s ease-in-out infinite alternate; }
@keyframes fond-a { to { transform: translate3d(34vmax, 22vmax, 0) scale(1.15); } }
@keyframes fond-b { to { transform: translate3d(-38vmax, 18vmax, 0) scale(.9); } }
@keyframes fond-c { to { transform: translate3d(26vmax, -30vmax, 0) scale(1.2); } }
.fond-brume b {
  position: absolute; inset: 0; opacity: .5; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.fond-brume[hidden] { display: none; }
/* fond choisi le 2026-11-29 (js/fond-lucioles.js) : le rendu du projet, très sombre et très flou, dans un canevas,
   et de vraies lucioles filmées par-dessus, fondues en « écran » : leur noir laisse voir le rendu.
   Sans WebGL, la brume ci-dessus reste, avec les lucioles. */
.fond-rendu, .page-projet .fond-lucioles {
  position: fixed; inset: 0; z-index: -1; display: block; width: 100%; height: 100%; max-width: none; pointer-events: none;
}
.fond-rendu { opacity: 0; transition: opacity 1.2s ease; }
.page-projet .fond-lucioles {
  object-fit: cover; background: none center / cover no-repeat; mix-blend-mode: screen;
  opacity: 0; transition: opacity 2.4s ease;
}
.fond-rendu.pret, .page-projet .fond-lucioles.pret { opacity: 1; }
/* écran en hauteur : la boucle est couchée, pour garder toutes les lucioles au lieu d'une bande du milieu */
@media (orientation: portrait) {
  .page-projet .fond-lucioles {
    inset: auto; left: 50%; top: 50%; width: 100vh; width: 100lvh; height: 100vw;
    transform: translate(-50%, -50%) rotate(90deg);
  }
}
/* l'en-tête se fond dans le fond au lieu de s'arrêter net */
.hero-tableau {
  -webkit-mask-image: linear-gradient(#000 calc(100% - 16vh), transparent); mask-image: linear-gradient(#000 calc(100% - 16vh), transparent);
}

/* ---------- En-tête : dans le tableau ---------- */
.hero-tableau {
  position: relative; height: 100svh; min-height: 30rem; overflow: hidden; isolation: isolate;
  background: var(--cedar);
  --px: 0; --py: 0; --defile: 0;
}
/* les plans de la scène, du fond vers l'avant ; --profondeur règle la parallaxe (souris et défilement) */
.hero-plans { position: absolute; inset: 0; }
.hero-plans .plan {
  position: absolute; inset: -4%; width: 108%; height: 108%; max-width: none; object-fit: cover;
  transform:
    translate3d(calc(var(--px) * var(--profondeur, 1) * 9px),
                calc(var(--py) * var(--profondeur, 1) * 6px + var(--defile) * var(--profondeur, 1) * 9vh), 0)
    scale(calc(1 + var(--defile) * .04));
  will-change: transform;
}
/* une brume qui passe devant, en attendant (et en plus) des vrais plans séparés */
.hero-plans .brume {
  inset: -10%; width: 120%; height: 120%; pointer-events: none; mix-blend-mode: screen; opacity: .55;
  background:
    radial-gradient(40% 22% at 22% 78%, rgba(220, 230, 215, .22), transparent 70%),
    radial-gradient(35% 18% at 78% 70%, rgba(220, 230, 215, .16), transparent 70%),
    radial-gradient(60% 25% at 50% 96%, rgba(200, 215, 200, .2), transparent 70%);
  animation: brume-passe 26s ease-in-out infinite alternate;
}
@keyframes brume-passe { from { translate: -3% 0; } to { translate: 3% -1%; } }
/* voile pour lire le titre, en bas à gauche */
.hero-tableau::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    linear-gradient(to top, rgba(8, 14, 10, .92) 0%, rgba(8, 14, 10, .55) 28%, rgba(8, 14, 10, 0) 58%),
    linear-gradient(to right, rgba(8, 14, 10, .55), rgba(8, 14, 10, 0) 55%);
}
.hero-texte {
  position: absolute; inset: auto 0 0; z-index: 2;
  display: grid; gap: .6rem;
  /* au-dessus du sous-titre du narrateur (même calcul que .voix-sous-titre), même sur deux lignes */
  padding-bottom: calc(var(--sous-titre-bas, max(9vh, calc(env(safe-area-inset-bottom) + 4.25rem))) + 7rem);
  opacity: calc(1 - var(--defile) * 1.6);
  transform: translateY(calc(var(--defile) * -6vh));
}
.hero-texte .jp { font-family: var(--f-display); color: var(--lantern); font-size: .95rem; letter-spacing: .3em; }
.hero-tableau h1 { font-size: clamp(2.6rem, 7vw, 6rem); line-height: 1; color: var(--mist); text-shadow: 0 2px 24px rgba(0, 0, 0, .45); }
.hero-tableau .lede { max-width: 46ch; color: rgba(240, 233, 220, .86); font-size: clamp(1.05rem, 1vw + .8rem, 1.25rem); }
/* le cadre doré du tableau, qu'on traverse en entrant (seulement quand on arrive du mur aux tableaux) */
.cadre-dore { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .entree-tableau .cadre-dore {
    display: block; position: absolute; inset: 9% 11%; z-index: 3; pointer-events: none;
    border: clamp(14px, 2.4vw, 34px) solid transparent;
    border-image: linear-gradient(135deg, #f3d28d, #a3782f 30%, #e8c172 52%, #7d5a22 78%, #d9b062) 1;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .4), 0 0 60px rgba(0, 0, 0, .6), inset 0 0 40px rgba(0, 0, 0, .55);
    animation: traverser-cadre 1400ms cubic-bezier(.55, 0, .25, 1) both;
  }
  .entree-tableau .hero-plans { animation: poser-regard 1800ms cubic-bezier(.2, .7, .2, 1) both; }
  .entree-tableau .hero-texte > * { animation: monter 900ms var(--ease-sortie) both; }
  .entree-tableau .hero-texte > :nth-child(2) { animation-delay: 650ms; }
  .entree-tableau .hero-texte > :nth-child(1) { animation-delay: 550ms; }
  .entree-tableau .hero-texte > :nth-child(3) { animation-delay: 750ms; }
  .entree-tableau .hero-texte > :nth-child(4) { animation-delay: 850ms; }
}
@keyframes traverser-cadre { 0% { inset: 9% 11%; opacity: 1; } 70% { opacity: 1; } to { inset: -18% -20%; opacity: 0; } }
@keyframes poser-regard { from { scale: 1.12; } }
@keyframes monter { from { opacity: 0; transform: translateY(14px); } }

.descendre {
  position: absolute; left: 50%; bottom: 4.6rem; z-index: 2; translate: -50% 0;
  display: grid; place-items: center; width: 44px; height: 44px; color: var(--mist);
  opacity: calc(.8 - var(--defile) * 3);
}
.descendre::before {
  content: ""; width: 1px; height: 26px; background: linear-gradient(var(--mist), transparent);
  animation: descendre 2.4s ease-in-out infinite;
}
@keyframes descendre { 0% { transform: scaleY(0); transform-origin: top; } 45% { transform: scaleY(1); transform-origin: top; } 55% { transform: scaleY(1); transform-origin: bottom; } 100% { transform: scaleY(0); transform-origin: bottom; } }


/* fiche technique sous l'en-tête */
.specs {
  display: flex; flex-wrap: wrap; gap: 14px 40px; padding-block: 1.75rem .25rem;
  font-variant-numeric: tabular-nums;
}
.specs div { display: grid; gap: 2px; }
.specs b { font-family: var(--f-body); font-weight: 600; color: var(--mist); font-size: 1rem; letter-spacing: 0; }
.vers-tr {
  justify-self: start; display: inline-flex; align-items: center; gap: 10px; margin-top: .25rem; padding: 10px 0; min-height: 44px;
  color: var(--lantern); text-decoration: none; font-family: var(--f-body); font-weight: 600; font-size: .95rem; letter-spacing: .06em;
}
.vers-tr .fl { display: inline-block; transition: transform .45s cubic-bezier(.22, .61, .36, 1); }
.vers-tr:hover .fl { transform: translateY(4px); }

/* ---------- Sections ---------- */
.page-projet main.wrap { padding-bottom: 2rem; }
.page-projet section { padding-block: clamp(56px, 8vw, 96px) 0; scroll-margin-top: 1.5rem; }
/* plus de numéro devant le titre (Sarah, 2026-11-29) : une seule colonne */
.sec-head { display: grid; grid-template-columns: 1fr; gap: 6px 20px; align-items: baseline; margin-bottom: 28px; }
.sec-head h2 { font-size: clamp(1.9rem, 3.6vw, 2.9rem); line-height: 1.1; color: var(--mist); }
.sec-head .jp { font-family: var(--f-display); color: var(--ash); font-size: .9rem; letter-spacing: .2em; }
.sec-head p { max-width: var(--measure); color: var(--ash); margin-top: 6px; }
.page-projet figure { margin: 0; display: grid; gap: 10px; min-width: 0; align-content: start; }
.page-projet figcaption { display: grid; gap: 2px; }
.page-projet figcaption .t { font-family: var(--f-title); font-size: 1.25rem; line-height: 1.25; }
.page-projet figcaption .t span { font-family: var(--f-display); color: var(--ash); margin-left: .6em; font-size: .8rem; }
.page-projet figcaption .n { color: var(--ash); font-weight: 400; font-size: .95rem; line-height: 1.55; letter-spacing: 0; }

/* avant / après */
.compare { position: relative; overflow: hidden; aspect-ratio: 16 / 9; max-width: 100%; -webkit-user-select: none; user-select: none; touch-action: pan-y; cursor: ew-resize; background: var(--cedar-2); }
.compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.compare .top { clip-path: inset(0 calc(100% - var(--pos, 50%)) 0 0); }
.compare .handle { position: absolute; top: 0; bottom: 0; left: var(--pos, 50%); width: 2px; background: var(--mist); transform: translateX(-1px); pointer-events: none; }
.compare .handle::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: 34px; height: 34px; border-radius: 50%;
  transform: translate(-50%, -50%); border: 2px solid var(--lantern); background: rgba(14, 24, 18, .6);
}
.compare .tag { position: absolute; bottom: 12px; padding: 3px 8px; pointer-events: none; color: var(--mist); background: rgba(14, 24, 18, .72); }
.compare .tag.l { left: 12px; } .compare .tag.r { right: 12px; }
.compare input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: ew-resize; margin: 0; }
.compare:focus-within .handle::after { outline: 2px solid var(--lantern); outline-offset: 3px; }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
.page-projet video { width: 100%; background: #000; }

.arch { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.arch figure:first-child { grid-column: 1 / -1; }
/* chaque prop prend deux demi-colonnes : une dernière rangée incomplète peut ainsi se placer au milieu
   (.rang-centre et --depart sont posés par outils/pages-projet.py sur le premier de cette rangée) */
.props { display: grid; grid-template-columns: repeat(calc(var(--props-col, 4) * 2), 1fr); gap: 14px; }
.props figure { grid-column: span 2; }
.props figure.rang-centre { grid-column: var(--depart) / span 2; }
.mats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.props img, .mats img { aspect-ratio: 1; object-fit: cover; width: 100%; }

/* agrandir une image : un vrai <dialog> */
/* au survol l'image s'éclaire un peu. Avant elle passait à 90 % d'opacité : on voyait le fond et ses lucioles au travers
   (Lewkia, 2026-11-29). Une image reste toujours opaque. */
.agrandir { display: block; width: 100%; padding: 0; border: 0; background: var(--cedar); cursor: zoom-in; }
.agrandir img { transition: filter .3s; }
@media (hover: hover) { .agrandir:hover img { filter: brightness(1.07); } }
.visionneuse {
  width: 100%; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 3vmin; border: 0;
  background: transparent; color: var(--ash); cursor: zoom-out;
}
.visionneuse[open] { display: grid; place-items: center; gap: .75rem; align-content: center; }
.visionneuse::backdrop { background: rgba(8, 14, 10, .94); }
.visionneuse img { max-width: 100%; max-height: 86dvh; width: auto; box-shadow: 0 30px 60px rgba(0, 0, 0, .6); }
.visionneuse p { text-align: center; font-family: var(--f-title); font-size: 1.2rem; color: var(--mist); }

/* fin : continuer la visite */
.fin { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 18px; padding-top: clamp(64px, 9vw, 110px); }
.fin a {
  display: inline-flex; align-items: center; gap: 12px; min-height: 48px; padding: 12px 22px; text-decoration: none;
  font-family: var(--f-title); font-size: 1.2rem; color: var(--mist); border: 1px solid rgba(209, 170, 94, .55);
  transition: background .3s, color .3s, border-color .3s;
}
.fin a:hover { background: var(--lantern); border-color: var(--lantern); color: var(--cedar); }
.fin a.suivant { background: rgba(209, 170, 94, .12); }

.page-projet footer { padding-block: 64px calc(5.5rem + env(safe-area-inset-bottom)); color: var(--ash); }
.page-projet footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }
.page-projet footer .credits { flex-basis: 100%; font-size: .8rem; letter-spacing: .02em; font-weight: 400; }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--higanbana); margin-right: 8px; vertical-align: middle; }

/* la barre du jeu, lisible au-dessus d'une page qui défile */
.page-projet .barre { background: linear-gradient(to top, rgba(8, 14, 10, .94), rgba(8, 14, 10, .7) 60%, rgba(8, 14, 10, 0)); }

@media (max-width: 860px) {
  .props { grid-template-columns: repeat(4, 1fr); }
  .props figure.rang-centre { grid-column: span 2; }
  .props figure:last-child:nth-child(odd) { grid-column: 2 / span 2; }   /* un nombre impair : le dernier, seul, au milieu */
  .mats { grid-template-columns: repeat(2, 1fr); }
  .duo, .arch { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .sec-head { grid-template-columns: 1fr; }
  .sec-head .jp, .sec-head p { grid-column: 1; }
  .specs { gap: 12px 28px; }
}
/* ---------- Téléphone : l'interface d'un jeu mobile (Sarah, 2026-11-29) ----------
   Le retour est en haut à gauche (css/jeu.css) : un voile léger vient d'en haut, et le bas de l'écran reste à l'image
   et à la voix. Les liens de fin sont écrits l'un sous l'autre, sans cadre. */
@media (max-width: 760px), (orientation: landscape) and (max-height: 500px) {
  /* en haut de la page, sur le tableau : rien qu'une ombre légère. Quand on lit plus bas (.page-lue, js/scene.js),
     le texte qui remonte se fond dans le noir avant d'arriver sous « Step back ». */
  .page-projet .barre { padding-bottom: 0; background: linear-gradient(to bottom, rgba(8, 14, 10, .5), rgba(8, 14, 10, 0)); }
  .page-projet .barre::before {
    content: ""; position: absolute; inset: 0 0 -1.6rem; z-index: -1; pointer-events: none;
    background: linear-gradient(to bottom, rgba(8, 14, 10, .98), rgba(8, 14, 10, .94) 58%, rgba(8, 14, 10, 0));
    opacity: 0; transition: opacity .4s ease;
  }
  .page-lue .page-projet .barre::before { opacity: 1; }
  .page-projet footer { padding-block: 40px calc(1.5rem + env(safe-area-inset-bottom)); }
  .page-projet section { scroll-margin-top: 3.25rem; }
  .hero-texte { padding-bottom: 8.6rem; }
  .descendre { bottom: 5.3rem; }
  /* « See the real-time version… » et sa flèche tiennent dans l'écran */
  .page-projet .vers-tr > .ecrit { width: min(calc(var(--l) * var(--x)), calc(100vw - 4.6rem)); }
  .fin { flex-direction: column; align-items: center; gap: 2px; }
  .fin a, .fin a.suivant, .fin a:hover { padding: 10px 6px; border: 0; background: none; color: var(--mist); }
  .fin a.suivant, .fin a.suivant:hover { color: var(--lantern); }
  .fin a > .ecrit { width: min(calc(var(--l) * var(--x)), calc(100vw - 5.4rem)); }
}
@media (max-width: 760px) {
  /* minmax(0, …) : un nom écrit à la main, plus large que sa colonne, ne l'élargit plus (les deux images restent égales) */
  .props { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .mats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-projet :is(.props, .mats) :is(figure, figcaption) { grid-template-columns: minmax(0, 1fr); }   /* ni l'image qui le porte */
  .props, .mats { gap: 24px 12px; }
  .page-projet :is(.props, .mats) figcaption .t { font-size: 1.12rem; }
  .page-projet :is(.props, .mats) figcaption .n { font-size: .84rem; line-height: 1.45; }
}
@media (prefers-reduced-motion: reduce) {
  .fond-brume i, .hero-plans .brume, .descendre::before { animation: none; }
  .fond-rendu, .page-projet .fond-lucioles { transition: none; }
  .hero-plans .plan { transform: none; }
  .hero-texte { opacity: 1; transform: none; }
}
