/* Démonstration publique — La Batisse en coupe (3D) — charte V3. Jetons repris tels quels de
   « La Batisse — Essentiel/2 Marque/Charte/tokens.css ». */
@font-face { font-family: 'Inter'; src: url('fonts/inter-latin.woff2') format('woff2'); font-weight: 100 900; font-display: block; }
@font-face { font-family: 'JetBrains Mono'; src: url('fonts/jetbrainsmono-latin.woff2') format('woff2'); font-weight: 400 800; font-display: block; }

:root {
  --ivoire-papier: #EFE9DD;  --ivoire-encre: #1A3FFF;  --ivoire-texte: #0B0D10;
  --cobalt-papier: #1A3FFF;  --cobalt-encre: #08135E;  --cobalt-texte: #F7F6F0;
  --ambre-papier:  #F4A11E;  --ambre-encre:  #7A2A06;  --ambre-texte:  #1B0E05;
  --rose-papier:   #F4C9D9;  --rose-encre:   #C8155F;  --rose-texte:   #2A0414;
  --nuit-papier:   #1B2236;  --nuit-encre:   #06080D;  --nuit-texte:   #F7F6F0;
  --lueur:         #FFB547;
  --papier: var(--ivoire-papier); --encre: var(--ivoire-encre); --texte: var(--ivoire-texte);
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
  --titre-approche: -0.052em; --titre-interligne: .92; --mono-approche: .12em;
  --rayon-carte: 22px; --rayon-pilule: 999px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --grain: 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='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .45 0 0 0 0 .4 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --gut: 28px;
}
.p-ivoire { --papier: var(--ivoire-papier); --encre: var(--ivoire-encre); --texte: var(--ivoire-texte); --accent: var(--ivoire-encre); }
.p-cobalt { --papier: var(--cobalt-papier); --encre: var(--cobalt-encre); --texte: var(--cobalt-texte); --accent: var(--cobalt-texte); }
.p-ambre  { --papier: var(--ambre-papier);  --encre: var(--ambre-encre);  --texte: var(--ambre-texte);  --accent: var(--ambre-encre); }
.p-rose   { --papier: var(--rose-papier);   --encre: var(--rose-encre);   --texte: var(--rose-texte);   --accent: var(--rose-encre); }
.p-nuit   { --papier: var(--nuit-papier);   --encre: var(--nuit-encre);   --texte: var(--nuit-texte);   --accent: var(--lueur); }
/* La nuit : une seule palette pour toute la composition */
.mode-nuit, .mode-nuit .p-ivoire, .mode-nuit .p-cobalt, .mode-nuit .p-ambre, .mode-nuit .p-rose {
  --papier: var(--nuit-papier); --encre: var(--nuit-encre); --texte: var(--nuit-texte); --accent: var(--lueur);
}
[class*="p-"], .mode-nuit { --filet: color-mix(in srgb, var(--texte) 12%, transparent); }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--ivoire-papier); }
body {
  margin: 0; background: var(--papier); color: var(--texte);
  font: 400 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased;
  transition: background-color .6s var(--ease-out), color .6s var(--ease-out);
}
:focus-visible { outline: 2px solid var(--texte); outline-offset: 3px; }
.mono { font-family: var(--mono); font-weight: 500; font-size: 12px; letter-spacing: var(--mono-approche); text-transform: uppercase; }
.accent { color: var(--accent); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.titre, .sous-titre, .fiche h3 { font-weight: 600; letter-spacing: var(--titre-approche); line-height: var(--titre-interligne); margin: 0; }
body[data-mode="chantier"] .seul-presentation, body[data-mode="presentation"] .seul-chantier { display: none !important; }

/* ---------- Pilules ---------- */
.pilule {
  display: inline-flex; align-items: center; gap: 8px; margin: 0;
  border-radius: var(--rayon-pilule); padding: 9px 16px; border: 1px solid var(--filet);
  background: var(--papier); color: var(--texte); font: 500 14px/1.1 var(--sans); white-space: nowrap;
  transition: background-color .3s var(--ease-out), color .3s var(--ease-out), transform .2s var(--ease-out);
}
button.pilule, select.pilule { cursor: pointer; }
button.pilule:active { transform: scale(.97); }
.pilule.plein { background: var(--encre); color: var(--papier); border-color: transparent; }
.mode-nuit .pilule.plein { background: var(--lueur); color: var(--nuit-papier); }
.pilule.ligne { background: var(--papier); }
select.pilule { appearance: none; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 19px) 52%, calc(100% - 14px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
button:disabled { opacity: .45; cursor: default; }

/* ---------- En-tête : voile de papier sous le texte ---------- */
.tete {
  position: fixed; z-index: 10; top: 0; left: 0; right: 0;
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between;
  padding: 20px var(--gut) 34px; pointer-events: none;
  background: linear-gradient(var(--papier) 58%, color-mix(in srgb, var(--papier) 0%, transparent));
}
.tete > * { pointer-events: auto; }
.marque { display: flex; align-items: center; gap: 20px; }
.symbole { width: 44px; height: 44px; flex: none; display: block; }
.lien-logo { display: block; flex: none; border-radius: 10px; }
.retour { text-decoration: none; align-self: center; border-color: color-mix(in srgb, var(--texte) 40%, transparent); }
.marque { flex-wrap: wrap; }
.repere { margin: 0 0 8px; }
.titre { font-size: 34px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.bascule { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--rayon-pilule); border: 1px solid var(--filet); background: var(--papier); }
.bascule .pilule { border-color: transparent; background: transparent; padding: 7px 14px; }
.bascule .pilule[aria-pressed="true"] { background: var(--texte); color: var(--papier); }
.choix { display: inline-flex; }

/* ---------- La scène ---------- */
.plan { position: fixed; inset: 0; }
.zone { position: absolute; inset: 0; overflow: hidden; }
#scene { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#scene:active { cursor: grabbing; }
.traits { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.traits .voile { fill: none; stroke: var(--ivoire-papier); stroke-width: 8; stroke-linecap: round; opacity: .9; }
.traits .trait { fill: none; stroke: var(--ivoire-texte); stroke-width: 2.4; stroke-linecap: round; }
.traits .trait.rapport { stroke-dasharray: 1 7 !important; stroke-dashoffset: 0 !important; stroke-width: 3; }
.traits .bulle { fill: var(--ivoire-encre); stroke: var(--ivoire-papier); stroke-width: 2.5; }
.mode-nuit .traits .voile { stroke: var(--nuit-papier); }
.mode-nuit .traits .trait { stroke: var(--nuit-texte); }
.mode-nuit .traits .bulle { fill: var(--lueur); stroke: var(--nuit-papier); }

.calque { position: absolute; inset: 0; pointer-events: none; }
.etiquette, .salle { position: absolute; left: 0; top: 0; pointer-events: auto; will-change: transform; }
.etiquette {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 4px 11px 5px; border-radius: var(--rayon-pilule); border: 1px solid var(--filet);
  background: var(--papier); color: var(--texte); font: 500 13px/1.15 var(--sans); white-space: nowrap; cursor: pointer;
}
.etiquette .nom { display: inline-flex; align-items: center; gap: 6px; }
.etiquette .etat { font-size: 9.5px; letter-spacing: .1em; line-height: 1.2; }
.etiquette .nom::before { content: ''; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--texte); flex: none; }
.etiquette[data-etat="travaille"] .nom::before { background: var(--accent); border-color: var(--accent); animation: pouls 1.2s var(--ease-out) infinite; }
.etiquette[data-etat="attend"] .nom::before { border-style: dotted; border-color: var(--accent); }
.etiquette[data-etat="rendu"] .nom::before { content: '✓'; width: auto; height: auto; border: 0; font-size: 12px; line-height: 1; }
.etiquette[data-etat="veille"] { border-style: dashed; }
@keyframes pouls { 50% { transform: scale(.6); } }
.calque.compact .etiquette { padding: 2px 8px; font-size: 11.5px; }
.salle { transform-origin: 0 0; margin-top: 6px; }
.calque.compact .etiquette .etat { display: none; }
.calque.minimal .etiquette { display: none; }
.salle { font-size: 10.5px; padding: 4px 10px; border-radius: var(--rayon-pilule); border: 1px solid var(--filet); background: var(--papier); color: var(--texte); cursor: pointer; white-space: nowrap; }

.mention, .statut { position: absolute; left: var(--gut); font-size: 11px; padding: 7px 13px; }
.mention { top: 112px; }
.statut { bottom: 22px; }
.statut.ok::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--encre); }
.mode-nuit .statut.ok::before { background: var(--lueur); }
.ensemble { position: absolute; left: var(--gut); bottom: 66px; }
.aide { position: absolute; left: 50%; transform: translateX(calc(-50% - 190px)); bottom: 22px; margin: 0; font-size: 10.5px; padding: 6px 12px; border-radius: var(--rayon-pilule); background: var(--papier); }
body[data-mode="presentation"] .statut + .ensemble { bottom: 22px; }
.repli { display: none; }
.sans-3d #scene, .sans-3d .aide, .sans-3d .calque { display: none; }
.sans-3d .repli { display: grid; place-items: center; position: absolute; inset: 0; padding: 120px var(--gut) 40px; }
.repli p { max-width: 520px; padding: 22px 26px; border-radius: var(--rayon-carte); border: 1px solid var(--filet); background: var(--papier); }
.repli a { color: var(--accent); }

/* ---------- Panneau : carnet ou visite ---------- */
.panneau {
  position: absolute; z-index: 6; right: 20px; top: 108px; bottom: 20px; width: 372px;
  display: flex; flex-direction: column; gap: 18px; overflow: auto;
  padding: 26px 24px; border-radius: var(--rayon-carte); border: 1px solid var(--filet);
  background: var(--papier); color: var(--texte); isolation: isolate;
}
.panneau::before { content: ''; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--grain); opacity: .10; mix-blend-mode: multiply; pointer-events: none; }
.mode-nuit .panneau::before { mix-blend-mode: screen; opacity: .06; }
.sous-titre { font-size: 28px; }
.legende { font-size: 14px; margin: 12px 0 0; }
.journal { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 10px; }
.journal li { font-size: 14px; line-height: 1.4; padding: 10px 0 0; border-top: 1px solid var(--filet); display: grid; grid-template-columns: auto 1fr; column-gap: 10px; }
.journal .type { font-size: 10.5px; padding-top: 2px; }
.journal .qui { font-weight: 600; }
.journal .quand { grid-column: 2; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; }
.journal li.rapport .type::before { content: '··· '; }
.journal li.demande .type::before { content: '— '; }
.vide { font-size: 14px; margin: 14px 0 0; }
.visite { display: flex; flex-direction: column; gap: 14px; }
.visite .repere { margin: 0; }
.visite .sous-titre { font-size: 32px; outline: none; }
.v-corps p { margin: 0 0 12px; font-size: 15.5px; }
.qui-parle { display: block; font-size: 10.5px; margin-bottom: 3px; }
.points { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.points li { padding: 10px 0 0; border-top: 1px solid var(--filet); font-size: 15px; }
.qui-liste { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.qui-liste .pilule { padding: 6px 12px; font-size: 13px; }
.v-nav { display: flex; gap: 10px; justify-content: space-between; margin-top: 4px; }
.indice { font-size: 10.5px; margin: 0; }
.equipe-texte { margin-top: auto; border-top: 1px solid var(--filet); padding-top: 14px; }
.equipe-texte summary { cursor: pointer; font-size: 11px; }
#equipe { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; font-size: 14px; }
#equipe ul { list-style: none; padding: 0; margin: 2px 0 0; }
#equipe .mono { font-size: 10.5px; }

.fiche { position: fixed; z-index: 30; width: 290px; padding: 16px 18px; border-radius: var(--rayon-carte); border: 1px solid var(--filet); background: var(--papier); color: var(--texte); font-size: 14px; line-height: 1.45; pointer-events: none; }
.fiche h3 { font-size: 20px; margin-bottom: 6px; }
.fiche p { margin: 0 0 6px; }
.fiche .mono { font-size: 10.5px; margin: 8px 0 0; }

/* ---------- Mobile : la scène en haut, le panneau dessous ---------- */
@media (max-width: 759px) {
  :root { --gut: 16px; }
  .tete { position: static; padding: 16px var(--gut) 12px; background: var(--papier); }
  .titre { font-size: 26px; }
  .marque { gap: 14px; }
  .plan { position: static; }
  .zone { position: relative; height: 62vh; min-height: 360px; }
  #scene { touch-action: pan-y; }
  .mention { top: 10px; left: 10px; }
  .statut { bottom: 10px; left: 10px; }
  .ensemble { left: 10px; bottom: 52px; }
  body[data-mode="presentation"] .ensemble { bottom: 10px; }
  .aide { display: none; }
  .panneau { position: static; width: auto; margin: 12px var(--gut) 24px; overflow: visible; }
  .visite .sous-titre { font-size: 28px; }
  .sans-3d .repli { padding: 20px var(--gut); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Repli sans WebGL : cartes statiques ---------- */
.sans-3d .tete { position: static; background: var(--papier); }
.sans-3d .plan, .sans-3d .zone { position: static; }
.sans-3d .repli { display: block; position: static; padding: 8px var(--gut) 24px; }
.sans-3d .mention { position: static; margin: 0 var(--gut) 12px; display: inline-flex; }
.sans-3d .panneau { position: static; width: auto; margin: 12px var(--gut) 24px; overflow: visible; }
.repli > p { max-width: 62ch; }
.repli .sous-titre { margin: 28px 0 14px; font-size: 26px; }
.cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.carte { padding: 20px 22px; border-radius: var(--rayon-carte); border: 1px solid var(--filet); background: var(--papier); color: var(--texte); position: relative; isolation: isolate; }
.carte h3 { margin: 0 0 10px; }
.carte p { margin: 0 0 10px; font-size: 14.5px; }
.carte ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 14px; }
.carte li { border-top: 1px solid var(--filet); padding-top: 6px; }

/* Export sans fond (?fond=transparent) : l'image de l'accueil est tirée de la scène seule. */
html.export, html.export body { background: transparent; }
html.export .tete, html.export .panneau, html.export .calque, html.export .traits,
html.export .mention, html.export .aide, html.export .ensemble { display: none !important; }

/* ---------- Zoom depuis / vers l'accueil (View Transitions, même origine) ---------- */
@view-transition { navigation: auto; }
.zone { view-transition-name: batisse; }
/* Fond de page : un fondu court, qui accompagne le zoom au lieu de l'éclair. */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .45s; animation-timing-function: ease; }
::view-transition-group(batisse) { animation-duration: .65s; animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1); }
::view-transition-old(batisse), ::view-transition-new(batisse) { height: 100%; object-fit: cover; }
@keyframes vt-sortie { to { opacity: 0; } }
@keyframes vt-entree { from { opacity: 0; } }
/* Aller : l'ancien visuel (fond transparent) grandit seul ; la scène de la démo (fond plein) ne se révèle qu'une fois posée. */
::view-transition-old(batisse) { animation: vt-sortie .25s ease .4s both; }
::view-transition-new(batisse) { animation: vt-entree .25s ease .4s both; }
/* zoom.js : le groupe est animé en JS (échelle uniforme, point visé sur point visé) ; l'ancienne image est recalée */
html.vt-zoom::view-transition-group(batisse) { animation-name: none; transform-origin: 0 0; }
html.vt-zoom::view-transition-old(batisse) { inset: auto; left: var(--vt-ox); top: var(--vt-oy); width: var(--vt-ow); height: var(--vt-oh); object-fit: fill; }
html.vt-zoom::view-transition-new(batisse) { width: 100%; height: 100%; object-fit: fill; }
@media (prefers-reduced-motion: reduce) {
  .zone { view-transition-name: none; } /* simple fondu de la page entière */
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: .2s; }
}
