/* Portfolio-jeu de Sarah Fournier : squelette (maquette grise).
   Jetons : nuit d'indigo, laiton, papier lunaire, rouge du sceau, flamme de bougie.
   La police manuscrite de Sarah remplacera --ecriture quand la planche sera numérisée. */

:root {
  --nuit: #1b1830;
  --nuit-profonde: #0f0d1d;
  --laiton: #b8925a;
  --papier: #e9e2d0;
  --papier-doux: #b9b2a3;
  --sceau: #b3121b;
  --bougie: #f2b866;

  --ecriture: "Ecriture Sarah", "Zen Old Mincho", Georgia, serif;
  --lecture: "Zen Old Mincho", Georgia, serif;
  --sous-titres: "DotGothic16", ui-monospace, Menlo, Consolas, monospace;

  --t-titre: clamp(2.2rem, 5vw + 1rem, 4.5rem);
  --t-narrateur: clamp(1.25rem, 1.2vw + 1rem, 1.75rem);
  --t-corps: 1.0625rem;
  --t-petit: 0.875rem;

  --ease-sortie: cubic-bezier(.2, .7, .2, 1);
  --duree-courte: 220ms;
  --duree-scene: 900ms;

  color-scheme: dark;
}

@font-face {
  font-family: "Ecriture Sarah";
  src: url("/fonts/ecriture-sarah.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "Zen Old Mincho";
  src: url("/fonts/zen-old-mincho-400.woff2") format("woff2");
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "Zen Old Mincho";
  src: url("/fonts/zen-old-mincho-600.woff2") format("woff2");
  font-weight: 500 700; font-display: swap;
}
@font-face {
  font-family: "DotGothic16";      /* sous-titres du narrateur : partie latine, OFL (fonts/LICENCE-dotgothic16.txt) */
  src: url("/fonts/dotgothic16-latin.woff2") format("woff2");
  font-weight: 400; font-display: swap;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
/* iPhone : le texte ne grossit pas tout seul quand on tourne le téléphone */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--nuit-profonde);
  color: var(--papier);
  font-family: var(--lecture);
  font-size: var(--t-corps);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
/* aucun soulignement sur le site (Sarah, 2026-11-29) : un lien s'annonce par sa couleur, le survol par une lueur */
a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--bougie);
  outline-offset: 4px;
  border-radius: 4px;
}

.visuellement-cache {
  position: absolute !important;
  width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Lien d'évitement + version simple : toujours accessibles au clavier */
.lien-evitement {
  position: fixed; left: 1rem; top: 1rem; z-index: 50;
  padding: .6rem 1rem; background: var(--papier); color: var(--nuit);
  border-radius: 6px; transform: translateY(-200%);
  transition: transform var(--duree-courte) var(--ease-sortie);
}
.lien-evitement:focus { transform: none; }

/* Barre discrète : retour au cabinet, son, version simple */
.barre {
  position: fixed; inset: auto 0 0 0; z-index: 40;
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; padding: .75rem max(1rem, env(safe-area-inset-left));
  padding-bottom: max(.75rem, env(safe-area-inset-bottom));
  pointer-events: none;
  font-size: var(--t-petit);
}
.barre > * { pointer-events: auto; }
.barre a, .barre button {
  font: inherit; color: var(--papier-doux);
  background: none; border: 0; cursor: pointer;
  min-height: 44px; min-width: 44px; padding: .5rem .75rem;
  text-decoration: none;
}
.barre a:hover, .barre button:hover { color: var(--papier); }
.barre .sceau { width: 28px; height: auto; }

/* ---------- Ses textes écrits à la main ----------
   outils/lire-planche-titres.py vectorise sa planche des titres (images/titres/main/*.svg) et
   outils/poser-titres-manuscrits.py les pose à la place des textes tapés. L'image prend la couleur du texte (masque)
   et sa taille : --x est la hauteur de ses minuscules rapportée à la taille du texte ; --l (largeur), --h (hauteur)
   et --d (ce qui descend sous sa ligne d'écriture) sont comptés en hauteurs de minuscules.
   Le vrai texte reste juste à côté, caché à l'œil : lecteur d'écran, recherche dans la page, Google. */
.ecrit {
  --x: max(.55em, 10.5px);                     /* l'écriture se lit moins bien petite que le texte tapé */
  display: inline-block; vertical-align: calc(var(--d) * var(--x) * -1);
  /* jamais plus large que l'écran : une image ne revient pas à la ligne comme un texte, et sa largeur ne doit pas
     élargir la colonne qui la porte (le titre de Meishin-ji sur téléphone poussait tout le paragraphe hors de l'écran) */
  width: min(calc(var(--l) * var(--x)), calc(100vw - 2.5rem)); max-width: 100%; height: auto; aspect-ratio: var(--ratio);
  background: currentColor;
  -webkit-mask: var(--src) no-repeat center / contain; mask: var(--src) no-repeat center / contain;
}
/* posés sur les rendus : un peu plus grands, et une ombre pour se détacher du décor (text-shadow ne s'applique pas
   à une image : drop-shadow sur le parent, qui ombre l'écriture découpée) */
:is(.etiquette, .recul, .indice-glisser) > .ecrit { --x: .62em; }
:is(.etiquette, .recul, .indice-glisser):has(> .ecrit) { filter: drop-shadow(0 1px 4px rgba(10, 8, 20, .95)); }
/* ---------- Les flèches, tracées à la main ----------
   Sarah, 2026-11-29 : plus de chevrons ni de flèches typographiques. Deux tracés au feutre (images/fleches/) : une
   flèche vers la droite, une vers le bas ; la gauche et le haut sont les mêmes, retournées. Comme .ecrit, l'image
   est un masque : la flèche prend la couleur et la taille du texte. Ses propres flèches, quand elle les aura
   dessinées, remplaceront ces deux fichiers sans rien changer d'autre. */
.fleche {
  display: inline-block; flex: none; width: 1.5em; height: .94em; vertical-align: -.2em;
  background: currentColor;
  -webkit-mask: url(/images/fleches/fleche.svg) no-repeat center / contain; mask: url(/images/fleches/fleche.svg) no-repeat center / contain;
}
.fleche.gauche { scale: -1 1; }
.fleche.bas, .fleche.haut {
  width: .94em; height: 1.5em; vertical-align: -.42em;
  -webkit-mask-image: url(/images/fleches/fleche-bas.svg); mask-image: url(/images/fleches/fleche-bas.svg);
}
.fleche.haut { scale: 1 -1; }
.entrer:has(> .ecrit) { filter: drop-shadow(0 0 10px rgba(242, 184, 102, .5)) drop-shadow(0 1px 2px rgba(4, 4, 10, .9)); }
.entrer > .ecrit { --x: .62em; }
.indice-scroll > .ecrit { --x: max(.62em, 10px); }

/* ses mots japonais écrits à la main (outils/poser-japonais-manuscrit.py) : un mot = une image de --n cases de sa
   planche, plus une marge de --m case autour (rendue au texte par une marge négative) ; couleur du texte */
.ecrit-ja {
  --case: max(1.2em, 17px);
  --m: .1;
  display: inline-block; vertical-align: middle;
  width: calc((var(--n, 1) + 2 * var(--m)) * var(--case)); height: calc((1 + 2 * var(--m)) * var(--case));
  margin: calc(var(--m) * var(--case) * -1);
  background: currentColor;
  -webkit-mask: var(--src) no-repeat center / 100% 100%; mask: var(--src) no-repeat center / 100% 100%;
}
.ecrit-ja.v { width: calc((1 + 2 * var(--m)) * var(--case)); height: calc((var(--n, 1) + 2 * var(--m)) * var(--case)); }
.ecrit-ja-pile { display: inline-flex; flex-direction: column; }

/* ---------- Scène point-and-click ---------- */
.scene {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  background: var(--nuit);
}
.scene-cadre {
  /* Le décor garde son format (16:9, ou 9:16 en portrait) et couvre l'écran :
     plaque et points cliquables partagent ce même repère, donc restent alignés. */
  --ratio: 16 / 9;
  position: absolute; left: 50%; top: 50%; translate: -50% -50%;
  width: max(100vw, 100svh * 16 / 9); height: max(100svh, 100vw * 9 / 16);
}
@media (orientation: portrait) {
  .scene-cadre { width: max(100vw, 100svh * 9 / 16); height: max(100svh, 100vw * 16 / 9); }
}
.plaque {
  position: absolute; inset: 0;
}
.plaque > .calque {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  /* légère surcouverture (3 %) pour que la parallaxe ne montre jamais les bords */
  transform: translate3d(calc(var(--px, 0) * var(--profondeur, 0) * 1px),
                         calc(var(--py, 0) * var(--profondeur, 0) * 1px), 0) scale(1.03);
  will-change: transform;
}

/* Points cliquables : de vrais liens, placés en % de la plaque */
.points { position: absolute; inset: 0; }
.point {
  position: absolute;
  left: var(--x); top: var(--y); width: var(--w); height: var(--h);
  display: grid; place-items: end center;
  text-decoration: none;
  border-radius: 12px;
}
@media (orientation: portrait) {
  .point { left: var(--mx, var(--x)); top: var(--my, var(--y));
           width: var(--mw, var(--w)); height: var(--mh, var(--h)); }
}
.point .etiquette {
  font-family: var(--ecriture);
  /* la taille suit aussi la largeur du décor (max(100vw, 100svh × 16/9), comme les coins) : sur un portable ou un
     téléphone en paysage, le décor est plus petit et « Character Design » mordait sur « Contact » */
  font-size: clamp(13px, min(1vw + .9rem, max(1.6vw, 2.844svh)), 1.6rem);
  padding: .2rem .6rem .5rem;
  white-space: nowrap;
  opacity: .9;                          /* toujours affichées : on voit tout de suite où aller */
  transition: opacity var(--duree-courte) var(--ease-sortie), color var(--duree-courte) var(--ease-sortie), filter var(--duree-courte) var(--ease-sortie);
  text-shadow: 0 1px 12px rgba(15, 13, 29, .9);
}
/* au survol et au clavier : l'étiquette s'éclaire comme à la bougie (plus de trait dessous, Sarah, 2026-11-29).
   L'étiquette écrite à la main est une image découpée : la lueur est une ombre portée chaude autour de l'écriture. */
.point:hover .etiquette, .point:focus-visible .etiquette {
  opacity: 1; color: #ffe2b0;
  text-shadow: 0 0 14px rgba(242, 184, 102, .9), 0 1px 12px rgba(15, 13, 29, .9);
}
.point:is(:hover, :focus-visible) .etiquette:has(> .ecrit) {
  filter: drop-shadow(0 0 7px rgba(242, 184, 102, .85)) drop-shadow(0 0 16px rgba(242, 184, 102, .45)) drop-shadow(0 1px 4px rgba(10, 8, 20, .95));
}
.point:hover, .point:focus-visible {
  background: radial-gradient(closest-side, rgba(242, 184, 102, .14), transparent);
}
.point:focus-visible { outline: none; }
/* après un clic ou un toucher, le focus qui revient (une fiche fermée à Échap) reste éteint (js/scene.js) */
.au-pointeur :focus-visible:not(input, textarea, select) { outline: none; }
.au-pointeur .point:focus-visible:not(:hover) { background: none; }
.au-pointeur .point:focus-visible:not(:hover) .etiquette { opacity: .9; color: inherit; text-shadow: 0 1px 12px rgba(15, 13, 29, .9); }
.au-pointeur .point:focus-visible:not(:hover) .etiquette:has(> .ecrit) { filter: drop-shadow(0 1px 4px rgba(10, 8, 20, .95)); }
.au-pointeur .barre .recul:focus-visible:not(:hover) { opacity: .9; color: var(--papier); text-shadow: 0 1px 12px rgba(15, 13, 29, .9); }   /* au clavier : la lueur, pas un grand cadre */
.au-pointeur .barre .recul:focus-visible:not(:hover):has(> .ecrit) { filter: drop-shadow(0 1px 4px rgba(10, 8, 20, .95)); }

/* ---------- Scènes rendues dans Blender (16:9) ----------
   En paysage, l'image couvre l'écran. En portrait, on garde tout le décor en 16:9 et on le parcourt
   du doigt (défilement horizontal), comme on tourne la tête : rien n'est coupé, les zones restent justes. */
.scene-rendu .scene-defile { position: absolute; inset: 0; }
.scene-rendu .plaque > .calque { background: var(--nuit-profonde); }
@media (orientation: portrait) {
  .scene-rendu .scene-defile {
    overflow-x: auto; overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .scene-rendu .scene-defile::-webkit-scrollbar { display: none; }
  .scene-rendu .scene-cadre {
    position: relative; left: 0; top: 0; translate: none;
    height: 100svh; width: calc(100svh * 16 / 9);
  }
  .scene-rendu .point { left: var(--x); top: var(--y); width: var(--w); height: var(--h); }
}
.indice-glisser {
  position: absolute; left: 50%; top: max(1rem, env(safe-area-inset-top)); z-index: 30;
  transform: translateX(-50%); margin: 0;
  font-family: var(--ecriture); font-size: var(--t-petit); color: var(--papier-doux);
  letter-spacing: .04em; pointer-events: none;
  transition: opacity var(--duree-scene) var(--ease-sortie);
}
@media (orientation: landscape) { .indice-glisser { display: none; } }
.indice-glisser.vu { opacity: 0; }

/* Le narrateur parle en sous-titres, comme dans une série (js/narrateur.js) : un cartouche noir en bas
   de l'écran, des majuscules blanches en police pixel, une réplique à la fois. Le paragraphe .narrateur
   reste dans la page pour le lecteur d'écran ; sans JavaScript, c'est lui qui s'affiche en sous-titre. */
.narrateur {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; margin: 0;
}
.voix-sous-titre {
  position: fixed; left: 50%; z-index: 35;
  bottom: var(--sous-titre-bas, max(9vh, calc(env(safe-area-inset-bottom) + 4.25rem)));
  transform: translateX(-50%);
  width: max-content; max-width: min(78vw, 47.5rem);
  margin: 0; padding: .55em 1.1em .6em;
  font-family: var(--sous-titres); font-size: clamp(16px, 2.1vw, 24px); line-height: 1.38;
  letter-spacing: .09em; text-transform: uppercase; text-align: center; text-wrap: balance;
  /* noir à 99,6 % et pas 100 % : un cartouche tout à fait opaque posé sur la lune (canvas WebGL) faisait
     sauter un rectangle du ciel à la position miroir, en haut de l'écran (bug d'occlusion du compositeur) */
  color: #fff; background: rgba(0, 0, 0, .996);
  cursor: pointer;
  opacity: 0; transition: opacity .18s linear;
}
.voix-sous-titre.visible { opacity: 1; }
/* la dernière réplique reste affichée : elle ne prend plus les clics, les points dessous restent cliquables */
.voix-sous-titre.tenue { cursor: default; pointer-events: none; }
/* pages projet : quand on lit plus bas, la voix se tait (elle cacherait les images), elle revient en haut (js/scene.js) */
.page-lue .voix-sous-titre { opacity: 0; pointer-events: none; transition-duration: .4s; }
.voix-sous-titre[hidden] { display: none; }
/* une fiche ouverte (lettre, bestiaire, objet) : le narrateur se tait derrière */
body:has(dialog[open]) .voix-sous-titre { visibility: hidden; }
/* chaque lettre a sa place dès le début ; elle se montre quand la voix y arrive (aucune remise en page pendant la frappe) */
.voix-sous-titre i { font-style: normal; visibility: hidden; }
.voix-sous-titre i.dit { visibility: visible; }
@media (max-width: 520px) { .voix-sous-titre { max-width: calc(100vw - 2rem); font-size: 16px; } }
/* téléphone en paysage : l'écran est bas, un cartouche sur deux lignes couvrait l'enveloppe et la lettre du contact ;
   en plus petit, la réplique tient sur une ligne */
@media (orientation: landscape) and (max-height: 500px) {
  .voix-sous-titre { font-size: 14px; line-height: 1.3; max-width: min(86vw, 47.5rem); }
  /* et sur le plus petit (iPhone SE couché), les étiquettes peuvent descendre un peu plus bas que 13 px */
  .point .etiquette { font-size: clamp(11.5px, max(1.6vw, 2.844svh), 1.6rem); }
}
@media (prefers-reduced-motion: reduce) { .voix-sous-titre { transition: none; } }
@media (scripting: none) {
  .narrateur {
    position: fixed; left: 50%; bottom: max(9vh, 4.25rem); z-index: 35; transform: translateX(-50%);
    width: max-content; max-width: min(78vw, 47.5rem); height: auto; overflow: visible; clip: auto; white-space: normal;
    padding: .55em 1.1em .6em;
    font-family: var(--sous-titres); font-size: clamp(16px, 2.1vw, 24px); line-height: 1.38;
    letter-spacing: .09em; text-transform: uppercase; text-align: center; color: #fff; background: #000;
  }
}
/* L'étiquette d'un point se place en haut de sa zone quand le bas est près du bord ou caché */
.point.etiquette-haut { place-items: start center; }

/* La vitrine : la lampe d'une vitre s'allume quand on survole son objet, au clavier, ou au toucher (js/scene.js).
   Elle hésite une fraction de seconde, comme une vraie ampoule, et s'éteint doucement. */
.scene-rendu .plaque > .lumieres { background: none; pointer-events: none; }
.lumiere {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 700ms var(--ease-sortie);
}
.lumiere.allumee { opacity: 1; transition: none; animation: allumer 460ms linear both; }
@keyframes allumer { 0% { opacity: 0; } 14% { opacity: .8; } 26% { opacity: .28; } 44% { opacity: .92; } 58% { opacity: .7; } 100% { opacity: 1; } }
/* la lampe suffit : pas de lueur ronde en plus sur l'objet */
.scene:has(.lumieres) .point:is(:hover, :focus-visible) { background: none; }
/* Tableaux vivants : la toile s'anime au survol (boucle tirée des rendus), fondue sur la lumière du rendu */
.scene-rendu .plaque > .vivants { background: none; pointer-events: none; }
.vivant {
  position: absolute; left: var(--x); top: var(--y); width: var(--w); height: var(--h);
  overflow: hidden; opacity: 0; transition: opacity 700ms var(--ease-sortie);
}
.vivant.actif { opacity: 1; }
.vivant > video, .vivant > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.vivant > img { transform-origin: 58% 42%; }
.vivant.actif > img { animation: respirer 11s ease-in-out infinite alternate; }
@keyframes respirer { to { transform: scale(1.07) translate(-1%, .6%); } }
/* la lampe du tableau éclaire le haut de la toile, le bas reste dans l'ombre, comme dans le rendu */
.vivant::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(255, 210, 150, .07), transparent 35%, rgba(12, 7, 4, .38));
  box-shadow: inset 0 0 2.5vw rgba(12, 7, 4, .55);
}

/* « Step back » dans les gros plans : écrit à la main dans le coin, comme les étiquettes des points,
   pas un bouton. C'est le seul lien de la barre : sans lui, au doigt, on ne pourrait plus revenir dans la pièce. */
.barre .recul {
  display: inline-flex; align-items: center; gap: .55rem;
  font-family: var(--ecriture); font-size: 1.4rem; line-height: 1; color: var(--papier);
  text-shadow: 0 1px 12px rgba(15, 13, 29, .9);
  opacity: .9; transition: opacity var(--duree-courte) var(--ease-sortie), color var(--duree-courte) var(--ease-sortie), filter var(--duree-courte) var(--ease-sortie);
}
.barre .recul:hover, .barre .recul:focus-visible {
  opacity: 1; color: #ffe2b0; outline: none;
  text-shadow: 0 0 14px rgba(242, 184, 102, .9), 0 1px 12px rgba(15, 13, 29, .9);
}
.barre .recul:is(:hover, :focus-visible):has(> .ecrit) {
  filter: drop-shadow(0 0 7px rgba(242, 184, 102, .85)) drop-shadow(0 0 16px rgba(242, 184, 102, .45)) drop-shadow(0 1px 4px rgba(10, 8, 20, .95));
}
.barre .recul::before {
  /* une flèche vers la gauche, tracée à la main : on revient sur ses pas (css/jeu.css, .fleche) */
  content: ""; flex: none; width: 1.6em; height: 1em; scale: -1 1;
  background: currentColor;
  -webkit-mask: url(/images/fleches/fleche.svg) no-repeat center / contain; mask: url(/images/fleches/fleche.svg) no-repeat center / contain;
}
@media (max-width: 420px) {
  .barre { gap: 0; padding-inline: .25rem; }
  .barre a, .barre button { padding-inline: .5rem; }
}

/* ---------- Fiches : ce qu'on prend en main dans un gros plan (vrais <dialog>) ---------- */
.fiche {
  /* plein écran transparent : un clic hors du papier repose l'objet */
  width: 100%; max-width: none; height: 100dvh; max-height: none;
  margin: 0; padding: 1rem 1rem max(4.75rem, calc(env(safe-area-inset-bottom) + 4rem));
  border: 0; background: transparent; color: inherit;
  place-items: center; overflow: auto; overscroll-behavior: contain;
}
.fiche[open] { display: grid; }
.fiche::backdrop { background: rgba(15, 13, 29, .74); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.fiche[open]::backdrop { animation: voile var(--duree-courte) var(--ease-sortie) both; }
@keyframes voile { from { opacity: 0; } }
/* Sans JavaScript, le lien #id ouvre quand même la fiche */
html:not(.js) .fiche:target { display: grid; position: fixed; inset: 0; z-index: 45; background: rgba(15, 13, 29, .86); }

.papier {
  --encre: #2b2238;
  --encre-douce: #5f5361;
  position: relative;
  width: min(34rem, 100%);
  padding: clamp(1.5rem, 4vw, 2.25rem) clamp(1.25rem, 4vw, 2.25rem) 1.25rem;
  color: var(--encre);
  background:
    radial-gradient(120% 70% at 8% 0%, rgba(255, 255, 255, .4), transparent 60%),
    radial-gradient(80% 60% at 100% 100%, rgba(140, 104, 58, .2), transparent 70%),
    radial-gradient(40% 30% at 85% 12%, rgba(140, 104, 58, .08), transparent 70%),
    var(--papier);
  border-radius: 2px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset, 0 28px 60px -18px rgba(0, 0, 0, .75);
  transform-origin: 50% 85%;
}
/* centré dans l'écran ; plus haut que l'écran (lettre sur un téléphone couché), il part du haut et on le fait défiler :
   avec un simple centrage, le haut de la feuille restait hors d'atteinte */
.fiche > .papier { margin-block: auto; }
.fiche[open] .papier { animation: prendre 460ms var(--ease-sortie) both; }
@keyframes prendre { from { opacity: 0; transform: translateY(28px) rotate(-1.5deg) scale(.95); } }
.papier h2 {
  margin: 0; font-family: var(--ecriture); font-weight: 400;
  font-size: clamp(1.9rem, 2.2vw + 1.2rem, 2.6rem); line-height: 1.05;
}
/* le titre de la lettre reçoit le focus à l'ouverture (tabindex="-1") : sans lui, c'était le champ piège caché, et sur
   téléphone le clavier s'ouvrait pour un champ qu'on ne voit pas */
.papier h2:focus { outline: none; }
.papier .ja { margin: .35rem 0 1.1rem; font-size: var(--t-petit); letter-spacing: .12em; color: var(--encre-douce); }
.papier p { margin: 0 0 .9rem; max-width: 60ch; }
.papier .outils { font-size: var(--t-petit); color: var(--encre-douce); }
.papier a { color: var(--sceau); transition: color var(--duree-courte) var(--ease-sortie); }   /* sans soulignement : le rouge du sceau dit que c'est un lien */
.papier a:hover { color: #7d0b12; }
.papier :focus-visible { outline-color: var(--sceau); }
.reposer {
  display: flex; justify-content: flex-end; margin-top: 1rem;
}
.reposer button, .reposer a {
  min-height: 44px; padding: .5rem .25rem; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: var(--t-petit); color: var(--encre-douce);
  transition: color var(--duree-courte) var(--ease-sortie);
}
.reposer button:hover, .reposer a:hover { color: var(--sceau); }

/* ---------- Fiche d'un objet 3D : l'objet qu'on tient, en grand, et son cartel sur papier ---------- */
.fiche-objet[open] {
  grid-template-columns: minmax(0, 1fr) minmax(17rem, 24rem);
  grid-template-rows: minmax(0, 1fr);
  gap: clamp(1rem, 3vw, 3.5rem);
  padding-inline: clamp(1rem, 4vw, 4.5rem);
}
.fiche-objet .papier { width: 100%; align-self: center; align-self: safe center; }
.objet-scene { position: relative; place-self: stretch; min-height: 16rem; isolation: isolate; }
html:not(.js) .objet-scene, html:not(.js) .fiche-objet .vues { display: none; }
/* la lueur de la bougie derrière l'objet */
.objet-scene::before {
  content: ""; position: absolute; inset: 4% 6%; z-index: -1; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(242, 184, 102, .17), rgba(242, 184, 102, .05) 62%, transparent);
}
.objet-scene canvas {
  position: absolute; inset: 0; display: block; width: 100%; height: 100%;
  touch-action: pan-y; cursor: grab; outline: none;
  opacity: 0; transition: opacity 700ms var(--ease-sortie);
  /* bords fondus : quand on regarde de près, l'objet sort doucement du cadre */
  -webkit-mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent), linear-gradient(to bottom, transparent, #000 6%, #000 94%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent), linear-gradient(to bottom, transparent, #000 6%, #000 94%, transparent);
  mask-composite: intersect;
}
.objet-scene.pret canvas { opacity: 1; }
.objet-scene.tenu canvas { cursor: grabbing; }
/* le contour du focus, hors du masque */
.objet-scene:has(canvas:focus-visible)::after {
  content: ""; position: absolute; inset: 0; border: 2px solid var(--bougie); border-radius: 6px; pointer-events: none;
}

.objet-etat {
  position: absolute; inset: 0; margin: 0; display: grid; place-content: center; text-align: center; pointer-events: none;
  font-family: var(--ecriture); font-size: 1.2rem; color: var(--papier-doux);
  transition: opacity 500ms var(--ease-sortie);
}
.objet-etat .rate { display: none; }
.objet-scene.erreur .objet-etat .charge { display: none; }
.objet-scene.erreur .objet-etat .rate { display: block; }
.objet-scene.pret .objet-etat { opacity: 0; }
/* un fil de laiton qui se remplit pendant le téléchargement */
.objet-etat .charge::after {
  content: ""; display: block; width: 9rem; height: 1px; margin: .85rem auto 0;
  background: linear-gradient(to right, var(--laiton) calc(var(--progres, 0) * 100%), rgba(184, 146, 90, .22) 0);
}

.objet-aide {
  position: absolute; left: 50%; bottom: .6rem; translate: -50% 0; margin: 0;
  width: max-content; max-width: calc(100% - 8rem); text-align: center; pointer-events: none;
  font-family: var(--ecriture); font-size: var(--t-petit); line-height: 1.3; color: var(--papier-doux);
  opacity: 0; transition: opacity 600ms var(--ease-sortie);
}
.objet-scene.pret .objet-aide { opacity: .9; transition-delay: 1s; }
.objet-scene.touche .objet-aide { opacity: 0; transition-delay: 0s; }
@media (hover: none) { .objet-aide .souris { display: none; } }
@media (hover: hover) { .objet-aide .doigt { display: none; } }

.objet-zoom {
  position: absolute; right: .25rem; bottom: .25rem; display: flex; gap: .4rem;
  opacity: 0; pointer-events: none; transition: opacity 600ms var(--ease-sortie);
}
.objet-scene.pret .objet-zoom { opacity: 1; pointer-events: auto; }
.objet-zoom button {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0; cursor: pointer;
  font: inherit; font-size: 1.35rem; line-height: 1; color: var(--papier);
  background: rgba(15, 13, 29, .55); border: 1px solid rgba(184, 146, 90, .55); border-radius: 50%;
  transition: background var(--duree-courte), border-color var(--duree-courte);
}
.objet-zoom button:hover { background: rgba(184, 146, 90, .18); border-color: var(--laiton); }

.vues { display: flex; flex-wrap: wrap; gap: .4rem; margin: 1.1rem 0 .55rem; }
.vues button {
  min-height: 2.75rem; padding: 0 .85rem; cursor: pointer;
  font: inherit; font-size: var(--t-petit); line-height: 1; color: var(--encre);
  background: transparent; border: 1px solid rgba(43, 34, 56, .28); border-radius: 999px;
  transition: background var(--duree-courte), color var(--duree-courte), border-color var(--duree-courte);
}
.vues button:hover { border-color: var(--encre); }
.vues button[aria-pressed="true"] { background: var(--encre); border-color: var(--encre); color: var(--papier); }
.vues button:disabled { opacity: .45; cursor: default; }
.papier .stats {
  min-height: 1.5em; margin: 0; font-size: .78rem; letter-spacing: .02em;
  color: var(--encre-douce); font-variant-numeric: tabular-nums;
}

@media (max-width: 760px), (orientation: portrait) {
  .objet-aide { left: .5rem; right: 7rem; translate: none; width: auto; max-width: none; text-align: left; }
  .fiche-objet[open] {
    grid-template-columns: minmax(0, 1fr); grid-template-rows: min(56svh, 34rem) auto;
    align-content: start; gap: .5rem;
  }
  .fiche-objet .papier { justify-self: center; width: min(34rem, 100%); }
}
@media (prefers-reduced-motion: reduce) {
  .objet-scene canvas, .objet-etat, .objet-aide, .objet-zoom { transition: none; }
}

/* Planches du bestiaire (en attendant le vrai livre) */
.planches { display: grid; gap: 1.25rem; margin: 0 0 .5rem; padding: 0; list-style: none; }
@media (min-width: 560px) { .planches { grid-template-columns: 1fr 1fr; } }
.planches img { width: 100%; height: auto; border-radius: 1px; box-shadow: 0 0 0 1px rgba(43, 34, 56, .18); }
.planches figcaption { margin-top: .4rem; font-family: var(--ecriture); font-size: 1.2rem; line-height: 1.2; }

/* La lettre : le formulaire de contact écrit sur la feuille */
.lettre { width: min(38rem, 100%); }
.lettre .tampon { position: absolute; top: 1.25rem; right: 1.25rem; width: 34px; height: auto; opacity: .85; mix-blend-mode: multiply; }
.lettre label { display: block; margin-top: 1rem; font-size: var(--t-petit); color: var(--encre-douce); }
.lettre input, .lettre textarea {
  display: block; width: 100%; margin-top: .15rem; padding: .3rem 0;
  font-family: var(--ecriture); font-size: 1.25rem; line-height: 2rem; color: var(--encre);
  background: transparent; border: 0; border-bottom: 1px solid rgba(43, 34, 56, .35); border-radius: 0;
}
.lettre textarea {
  min-height: 10rem; resize: vertical; padding-top: 0;
  background: repeating-linear-gradient(to bottom, transparent 0 calc(2rem - 1px), rgba(43, 34, 56, .22) calc(2rem - 1px) 2rem);
  border-bottom: 0;
}
.lettre input:focus-visible, .lettre textarea:focus-visible { outline: 2px solid var(--sceau); outline-offset: 3px; }
.lettre .envoi { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1rem; margin-top: 1.25rem; }
/* « Seal and send » : écrit en bas de la lettre comme une signature, pas un bouton (et plus de trait dessous) */
.cachet {
  margin-left: auto; min-height: 48px; padding: .35rem .2rem;
  font: inherit; font-family: var(--ecriture); font-size: 1.55rem; line-height: 1.1; color: var(--sceau);
  background: none; border: 0; cursor: pointer;
  transition: color var(--duree-courte) var(--ease-sortie), filter var(--duree-courte) var(--ease-sortie);
}
.cachet:hover, .cachet:focus-visible { color: #7d0b12; filter: drop-shadow(0 0 5px rgba(179, 18, 27, .45)); }
.cachet:focus-visible { outline: none; filter: drop-shadow(0 0 2px rgba(179, 18, 27, .8)) drop-shadow(0 0 9px rgba(179, 18, 27, .55)); }
.cachet[disabled] { opacity: .6; cursor: progress; }
.lettre .retour { flex: 1 1 14rem; margin: 0; font-size: var(--t-petit); color: var(--encre-douce); }
.miel { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* L'adresse dans l'enveloppe */
.coordonnees { margin: 0; padding: 0; list-style: none; }
.coordonnees li { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; padding: .6rem 0; }
.coordonnees .copier {
  min-height: 44px; padding: .4rem .6rem; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: var(--t-petit); color: var(--encre-douce); transition: color var(--duree-courte) var(--ease-sortie);
}
.coordonnees .copier:hover { color: var(--sceau); }

/* ---------- Téléphone : l'interface d'un jeu mobile (Sarah, 2026-11-29) ----------
   Trois repères, toujours au même endroit : le retour en haut à gauche, la voix tout en bas, et dans les pièces deux
   flèches tracées à la main sur les bords pour tourner le regard. Une fiche ouverte se referme avec une croix, en haut
   à droite. Toujours son écriture, aucun cadre, aucun trait : rien ne ressemble à un bouton de site. */

/* Tourner le regard (en portrait, le décor 16:9 dépasse de l'écran) : js/scene.js pose les arrêts et les flèches */
@media (orientation: portrait) {
  .scene-rendu .scene-defile { scroll-snap-type: x mandatory; }
}
.arret { position: absolute; top: 0; width: 2px; height: 2px; margin-left: -1px; pointer-events: none; scroll-snap-align: center; }
.regard {
  position: absolute; top: 46%; z-index: 30; translate: 0 -50%;
  display: grid; place-items: center; width: 3.5rem; height: 5rem; padding: 0;
  font-size: 1.7rem; color: var(--papier); background: none; border: 0; cursor: pointer;
  filter: drop-shadow(0 1px 4px rgba(10, 8, 20, .95)) drop-shadow(0 0 12px rgba(10, 8, 20, .7));
  -webkit-tap-highlight-color: transparent;
  transition: color var(--duree-courte) var(--ease-sortie), filter var(--duree-courte) var(--ease-sortie);
}
.regard[hidden] { display: none; }
.regard.gauche { left: max(.15rem, env(safe-area-inset-left)); }
.regard.droite { right: max(.15rem, env(safe-area-inset-right)); }
.regard:is(:hover, :focus-visible, :active) {
  color: #ffe2b0; outline: none;
  filter: drop-shadow(0 0 7px rgba(242, 184, 102, .85)) drop-shadow(0 0 16px rgba(242, 184, 102, .45)) drop-shadow(0 1px 4px rgba(10, 8, 20, .95));
}
.au-pointeur .regard:focus-visible:not(:hover, :active) { color: var(--papier); filter: drop-shadow(0 1px 4px rgba(10, 8, 20, .95)) drop-shadow(0 0 12px rgba(10, 8, 20, .7)); }
/* la flèche avance d'un rien, de temps en temps : on comprend qu'il y a quelque chose de ce côté */
.regard .fleche { animation: regard-droite 2.6s ease-in-out infinite; }
.regard.gauche .fleche { animation-name: regard-gauche; }
@keyframes regard-droite { 0%, 55%, 100% { translate: 0 0; } 75% { translate: 6px 0; } }
@keyframes regard-gauche { 0%, 55%, 100% { translate: 0 0; } 75% { translate: -6px 0; } }
/* les flèches remplacent la consigne « swipe to look around » */
.a-arrets .indice-glisser { display: none; }
/* derrière une fiche ouverte, les flèches se cachent */
body:has(dialog[open]) .regard { visibility: hidden; }
/* une étiquette coupée par le bord de l'écran s'efface jusqu'à ce qu'on soit en face */
.point.hors-champ .etiquette { opacity: 0; }

/* Au doigt il n'y a pas de survol : la lueur de bougie du survol respire doucement autour de chaque étiquette, pour
   qu'on voie ce qui se touche (une ombre portée chaude autour de son écriture, comme au survol à la souris) */
@media (hover: none) {
  .point .etiquette:has(> .ecrit) { animation: souffle 3.4s ease-in-out infinite alternate; }
  .point:nth-child(2n) .etiquette:has(> .ecrit) { animation-delay: -1.9s; }
  @keyframes souffle {
    from { filter: drop-shadow(0 0 1px rgba(242, 184, 102, 0)) drop-shadow(0 0 1px rgba(242, 184, 102, 0)) drop-shadow(0 1px 4px rgba(10, 8, 20, .95)); }
    to { filter: drop-shadow(0 0 6px rgba(255, 200, 120, .95)) drop-shadow(0 0 16px rgba(242, 184, 102, .6)) drop-shadow(0 1px 4px rgba(10, 8, 20, .95)); }
  }
}

/* La croix d'une fiche : posée par js/scene.js, montrée sur téléphone seulement */
.fiche-fermer { display: none; }

@media (max-width: 760px), (orientation: landscape) and (max-height: 500px) {
  /* le retour : en haut à gauche, petit, là où le pouce ne passe pas par hasard */
  .barre {
    inset: 0 0 auto 0; justify-content: flex-start; gap: 0;
    padding: max(.3rem, env(safe-area-inset-top)) max(.3rem, env(safe-area-inset-right)) 0 max(.3rem, env(safe-area-inset-left));
  }
  .barre .recul { font-size: 1.1rem; gap: .4rem; padding: .5rem .6rem; }
  .barre .recul::before { width: 1.45em; height: .9em; }
  /* la voix : tout en bas, plus rien dessous */
  .voix-sous-titre { bottom: var(--sous-titre-bas, max(.9rem, calc(env(safe-area-inset-bottom) + .55rem))); }
  /* (la consigne, quand il n'y a pas de flèches, passe sous le retour) */
  .indice-glisser { top: calc(max(.3rem, env(safe-area-inset-top)) + 3rem); }

  /* une fiche se referme toujours au même coin */
  .fiche-fermer {
    display: block; position: fixed; z-index: 5;
    top: max(.3rem, env(safe-area-inset-top)); right: max(.3rem, env(safe-area-inset-right));
    width: 48px; height: 48px; padding: 0; color: var(--papier); background: none; border: 0; cursor: pointer;
    filter: drop-shadow(0 1px 4px rgba(10, 8, 20, .95));
    -webkit-tap-highlight-color: transparent;
    transition: color var(--duree-courte) var(--ease-sortie), filter var(--duree-courte) var(--ease-sortie);
  }
  .fiche-fermer::before {
    content: ""; position: absolute; inset: 13px; background: currentColor;
    -webkit-mask: url(/images/fleches/croix.svg) no-repeat center / contain; mask: url(/images/fleches/croix.svg) no-repeat center / contain;
  }
  .fiche-fermer:is(:hover, :focus-visible, :active) {
    color: #ffe2b0; outline: none;
    filter: drop-shadow(0 0 7px rgba(242, 184, 102, .85)) drop-shadow(0 1px 4px rgba(10, 8, 20, .95));
  }
  .js .fiche .reposer { display: none; }
  /* la croix suffit : derrière la fiche, le retour ne se devine plus à travers le voile */
  body:has(dialog.fiche[open]) .barre { visibility: hidden; }
  .objet-zoom button { width: 40px; height: 40px; }
}

/* téléphone tenu droit : la fiche commence sous la croix, et tout ce qu'on tient tient dans l'écran */
@media (max-width: 760px) and (orientation: portrait) {
  .fiche { padding: calc(max(.3rem, env(safe-area-inset-top)) + 3.1rem) .75rem max(.9rem, env(safe-area-inset-bottom)); }
  .papier { padding: 1.25rem 1.15rem 1rem; }
  .papier .ja { margin-bottom: .75rem; }
  /* l'objet prend toute la place que son cartel laisse : plus besoin de faire défiler la fiche */
  .fiche-objet[open] { grid-template-rows: minmax(10rem, 1fr) auto; align-content: stretch; gap: .35rem; padding-inline: .75rem; }
  .objet-aide { left: 0; right: 0; text-align: center; }
  .vues { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .3rem; margin: .8rem 0 .5rem; }
  .vues button { min-height: 2.5rem; padding: 0; font-size: .8rem; }
  /* la lettre tient dans l'écran, « Seal and send » compris : les lignes à écrire prennent la hauteur qui reste */
  .lettre h2 > .ecrit { width: min(calc(var(--l) * var(--x)), calc(100vw - 7.5rem)); }   /* son « Dear Sarah, » ne passe plus sous le timbre */
  .lettre textarea { min-height: clamp(4rem, calc(100dvh - 33rem), 8rem); }
  .lettre label { margin-top: .7rem; }
  .lettre .envoi { margin-top: .6rem; }
}
/* au doigt on pince pour regarder de près : les deux ronds + et − s'en vont */
@media (max-width: 760px) and (hover: none) and (pointer: coarse), (orientation: landscape) and (max-height: 500px) and (hover: none) and (pointer: coarse) {
  .objet-zoom { display: none; }
}
/* téléphone couché : la croix a sa marge, à droite */
@media (max-width: 760px) and (orientation: landscape), (orientation: landscape) and (max-height: 500px) {
  .fiche { padding: .6rem calc(max(.3rem, env(safe-area-inset-right)) + 3.1rem) max(.6rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); }
  .fiche-objet[open] { padding-inline: max(1rem, env(safe-area-inset-left)) calc(max(.3rem, env(safe-area-inset-right)) + 3.1rem); }
  .papier { padding: 1rem 1.15rem .85rem; }
  .papier .ja { margin-bottom: .6rem; }
  .vues { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .3rem; margin: .6rem 0 .4rem; }
  .vues button { min-height: 2.4rem; padding: 0; font-size: .8rem; }
}
@media (prefers-reduced-motion: reduce) {
  .regard .fleche, .point .etiquette:has(> .ecrit) { animation: none; }
}

/* Maquette grise : remplacée par les rendus Blender */
.maquette { background: #2a2738; }
.maquette-trait { fill: none; stroke: #5d5872; stroke-width: 2; }
.maquette-texte { fill: #8e88a6; font: 14px system-ui, sans-serif; }

/* ---------- Transitions entre pages (View Transitions entre documents) ---------- */
@media (prefers-reduced-motion: no-preference) { @view-transition { navigation: auto; } }
::view-transition-old(root) { animation: sortie var(--duree-scene) var(--ease-sortie) both; }
::view-transition-new(root) { animation: entree var(--duree-scene) var(--ease-sortie) both; }
@keyframes sortie { to { opacity: 0; transform: scale(1.08); filter: blur(6px); } }
@keyframes entree { from { opacity: 0; transform: scale(.97); } }

/* Caméra : on s'approche de l'objet cliqué, on recule vers la pièce en se recomposant autour de lui.
   Le point visé (--zx, --zy) est posé par js/transition.js à l'arrivée sur la nouvelle page. */
@media (prefers-reduced-motion: no-preference) {
  html:active-view-transition-type(avance)::view-transition-old(root) {
    transform-origin: var(--zx, 50%) var(--zy, 50%);
    animation: plonge-sortie 900ms cubic-bezier(.5, 0, .35, 1) both;
  }
  html:active-view-transition-type(avance)::view-transition-new(root) {
    animation: plonge-entree 900ms cubic-bezier(.2, .7, .2, 1) both;
  }
  html:active-view-transition-type(recul)::view-transition-old(root) {
    animation: recul-sortie 900ms cubic-bezier(.2, .7, .2, 1) both;
  }
  html:active-view-transition-type(recul)::view-transition-new(root) {
    transform-origin: var(--zx, 50%) var(--zy, 50%);
    animation: recul-entree 900ms cubic-bezier(.25, .8, .25, 1) both;
  }
}
@keyframes plonge-sortie { 55% { opacity: 1; } to { opacity: 0; transform: scale(2.6); filter: blur(5px); } }
@keyframes plonge-entree { 0%, 30% { opacity: 0; transform: scale(1.14); } to { opacity: 1; transform: none; } }
@keyframes recul-sortie { to { opacity: 0; transform: scale(.9); filter: blur(3px); } }
@keyframes recul-entree { from { opacity: 0; transform: scale(2.6); filter: blur(5px); } 45% { opacity: 1; } to { transform: none; filter: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
  .plaque > .calque { transform: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}
