/* La Bibliothèque des nues (page /mille-et-une-nues/bibliotheque/, avec bibliotheque.js)
   Lumière d'atelier : murs de chaux, brume chaude. L'interface reste claire, comme le site ; le verre est réservé à ce
   qui flotte au-dessus de la salle (numéro, barre, feuille « Votre mur », fiche d'une nue, bulle d'une porte).
   Verre clair à 78 % (le texte de la salle ne doit pas se lire au travers), flou 24 px, liseré de lumière en haut. */
.biblio {
  --bb-brume: #e7dfd5;
  --bb-chaux: #e2dacf;
  --bb-verre: color-mix(in oklab, var(--paper) 78%, transparent);
  --bb-verre-plein: color-mix(in oklab, var(--paper) 96%, transparent);
  --bb-bord: color-mix(in oklab, #fff 70%, transparent);
  --bb-ombre: 0 1px 1px rgb(40 24 12 / .05), 0 10px 34px rgb(40 24 12 / .12);
  --bb-trait: color-mix(in oklab, var(--ink) 10%, transparent);
  --bb-survol: color-mix(in oklab, var(--ink) 7%, transparent);
  position: relative; height: calc(100svh - var(--header)); min-height: 540px; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 40%, #efe9e1, var(--bb-brume));
  color: var(--ink); isolation: isolate;
}
.bb-scene { position: absolute; inset: 0; }
.biblio [hidden] { display: none !important; }
/* un léger vignettage photographique, gratuit (CSS) */
.bb-3d .bb-scene::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(130% 110% at 50% 45%, transparent 55%, rgb(40 24 12 / .16)); }
.bb-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; outline: none; }
.bb-canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--vif); }
.bb-canvas:active { cursor: grabbing; }
.bb-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* un voile en haut : le titre se lit sur la brume du plafond */
.biblio::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 190px; z-index: 1; pointer-events: none;
  background: linear-gradient(color-mix(in oklab, var(--bb-brume) 78%, transparent), color-mix(in oklab, var(--bb-brume) 36%, transparent) 50%, transparent); }

/* Verre commun */
.bb-salle, .bb-barre, .bb-feuille, .bb-nue, .bb-bulle {
  background: var(--bb-verre); -webkit-backdrop-filter: blur(24px) saturate(170%); backdrop-filter: blur(24px) saturate(170%);
  border: 1px solid var(--bb-bord); box-shadow: inset 0 1px 0 rgb(255 255 255 / .55), var(--bb-ombre);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .bb-salle, .bb-barre, .bb-feuille, .bb-nue, .bb-bulle { background: var(--bb-verre-plein); }
}

/* En-tête : sort de la brume (mise au point) */
.bb-tete { position: absolute; left: var(--gutter); top: 16px; z-index: 2; max-width: min(40ch, 52vw); pointer-events: none; }
.bb-tete a { pointer-events: auto; }
.bb-tete .crumbs { margin-bottom: .45rem; }
.bb-tete h1 { font-size: clamp(1.9rem, 1.3rem + 2vw, 3rem); margin: 0 0 .25em; }
.bb-tete h1 em { color: color-mix(in oklab, var(--ink) 78%, var(--accent)); }
.bb-aide, .bb-statut { font-size: .8125rem; line-height: 1.45; color: var(--ink-soft); margin: 0; max-width: 34ch; }
.bb-aide { transition: opacity var(--d-recit) var(--courbe-sortie), transform var(--d-recit) var(--courbe-sortie); }
.bb-aide-2d, .bb-2d .bb-aide-3d { display: none; }
.bb-2d .bb-aide-2d { display: inline; }
.biblio.bb-calme .bb-aide { opacity: 0; transform: translateY(-4px); }
.bb-statut { color: var(--accent); font-weight: 500; }
.bb-pret .bb-statut { display: none; }
.bb-echec .bb-statut { display: block; color: var(--ink); }
@media (prefers-reduced-motion: no-preference) {
  .js .bb-tete > * { animation: bb-net 900ms var(--courbe-sortie) both; }
  .js .bb-tete > :nth-child(2) { animation-delay: 80ms; }
  .js .bb-tete > :nth-child(3) { animation-delay: 160ms; }
}
@keyframes bb-net { from { opacity: .02; filter: blur(7px); transform: translateY(4px); } }

/* Le numéro de la salle : un instrument en mono, en haut à droite */
.bb-salle { position: absolute; right: var(--gutter); top: 18px; z-index: 3; display: flex; align-items: center; gap: 8px; padding: 5px 5px 5px 16px; border-radius: 999px;
  font: 500 .75rem/1 var(--mono); letter-spacing: .06em; font-variant-numeric: tabular-nums; opacity: 0; transition: opacity var(--d-recit) var(--courbe-sortie); }
.bb-pret .bb-salle { opacity: 1; }
.bb-salle-t { white-space: nowrap; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-soft); }
.bb-num { font-size: .9375rem; letter-spacing: .02em; color: var(--ink); white-space: nowrap; }
.bb-chiffres { color: var(--ink-soft); white-space: nowrap; }
.bb-chiffres:empty { display: none; }
.bb-copier { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px 0 10px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--bb-survol); color: var(--ink); font: 500 .75rem/1 var(--sans); letter-spacing: 0;
  transition: background var(--d-court) var(--courbe-sortie), color var(--d-court) var(--courbe-sortie); }
.bb-copier:hover { background: var(--ink); color: var(--paper); }
.bb-copier.bb-copie { background: var(--accent); color: #fff; }
.bb-copier svg { width: 16px; height: 16px; flex: none; }

/* La barre : portes, face au mur, au hasard, votre mur */
.bb-barre { position: absolute; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); translate: -50% 0; z-index: 3; display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: 28px;
  opacity: 0; transition: opacity var(--d-recit) var(--courbe-sortie); max-width: calc(100% - 24px); }
.bb-pret .bb-barre { opacity: 1; }
.bb-portes { display: flex; gap: 2px; padding-right: 6px; margin-right: 2px; border-right: 1px solid var(--bb-trait); }
.bb-barre button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 15px; border: 0; border-radius: 22px; cursor: pointer;
  background: transparent; color: var(--ink); font: 500 .8125rem/1 var(--sans); letter-spacing: 0; white-space: nowrap;
  transition: background var(--d-court) var(--courbe-sortie), color var(--d-court) var(--courbe-sortie), transform var(--d-instant) var(--courbe-sortie); }
.bb-barre button:hover { background: var(--bb-survol); }
.bb-barre button:active { transform: scale(.96); }
.bb-barre svg { width: 18px; height: 18px; flex: none; }
.bb-portes button:first-child { padding-left: 10px; }
.bb-portes button:last-child { padding-right: 10px; }
.bb-recentrer { width: 44px; padding: 0 !important; }
.bb-barre .bb-chercher { background: var(--ink); color: var(--paper); padding: 0 18px; margin-left: 2px; }
.bb-barre .bb-chercher:hover, .bb-barre .bb-chercher[aria-expanded="true"] { background: color-mix(in oklab, var(--ink) 85%, var(--accent)); }

/* La feuille « Votre mur » */
.bb-feuille { position: absolute; z-index: 4; right: var(--gutter); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 64px); width: min(400px, calc(100% - 24px));
  padding: 20px 20px 16px; border-radius: 24px; display: grid; gap: 16px; transform-origin: 80% 100%; }
.bb-feuille:not([hidden]) { animation: bb-ouvre 220ms var(--courbe-sortie) both; }
@keyframes bb-ouvre { from { opacity: 0; transform: translateY(6px) scale(.97); } }
.bb-feuille form { display: grid; gap: 8px; margin: 0; }
.bb-feuille label { font: 500 .75rem/1.3 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }
.bb-feuille .bb-form-mur label { font: 340 1.5rem/1.1 var(--serif); letter-spacing: -.01em; text-transform: none; color: var(--ink); }
.bb-feuille p { margin: 0; font-size: .875rem; line-height: 1.45; color: var(--ink-soft); }
.bb-champ { display: flex; gap: 6px; align-items: stretch; }
.bb-champ input, .bb-champ textarea { flex: 1; min-width: 0; min-height: 44px; padding: 11px 16px; border: 0; border-radius: 22px; resize: none;
  background: color-mix(in oklab, var(--paper) 70%, #fff); color: var(--ink); font: 400 1rem/1.35 var(--sans); box-shadow: inset 0 0 0 1px var(--bb-trait); }
.bb-champ textarea { font-family: var(--mono); font-size: .875rem; overflow: hidden; white-space: nowrap; }
.bb-champ input:focus, .bb-champ textarea:focus { outline: none; box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 4px var(--accent-doux); }
.bb-champ button, .bb-un { min-height: 44px; padding: 0 18px; border: 0; border-radius: 22px; cursor: pointer; background: var(--ink); color: var(--paper); font: 500 .8125rem/1 var(--sans); white-space: nowrap; }
.bb-champ button:hover { background: color-mix(in oklab, var(--ink) 85%, var(--accent)); }
.bb-trouve { font-family: var(--mono); font-size: .75rem !important; }
.bb-trouve:empty { display: none; }
.bb-un { justify-self: start; background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--bb-trait); display: inline-flex; gap: 8px; align-items: center; }
.bb-un span { color: var(--ink-soft); font-weight: 400; }
.bb-un:hover:not(:disabled) { background: var(--ink); color: var(--paper); box-shadow: none; }
.bb-un:hover:not(:disabled) span { color: inherit; }
.bb-un:disabled { opacity: .5; cursor: default; }
.bb-fermer-feuille, .bb-fermer { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--bb-survol); color: var(--ink); font: 400 1.25rem/1 var(--sans); }
.bb-fermer-feuille:hover, .bb-fermer:hover { background: var(--ink); color: var(--paper); }

/* La bulle d'une porte survolée */
.bb-bulle { position: absolute; left: 0; top: 0; z-index: 3; max-width: 260px; padding: 10px 14px; border-radius: 16px; pointer-events: none; display: grid; gap: 3px;
  font-size: .8125rem; line-height: 1.35; }
.bb-bulle b { font: 500 .6875rem/1.2 var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.bb-bulle span { color: var(--ink-soft); }

/* La fiche d'une nue */
.bb-nue { position: absolute; z-index: 4; right: var(--gutter); top: 72px; width: min(360px, calc(100% - 24px)); padding: 14px; border-radius: 24px; display: grid; gap: 12px; }
.bb-nue:not([hidden]) { animation: bb-ouvre 260ms var(--courbe-sortie) both; }
.bb-nue img { width: 100%; height: auto; max-height: 42vh; object-fit: contain; background: var(--wall); }
.bb-nue.bb-debout img { width: auto; margin: 0 auto; height: 42vh; }
.bb-nue h2 { font-size: 1.6rem; margin: 0 40px .2em 0; }
.bb-nue p { margin: 0 0 .4em; font-size: .875rem; color: var(--ink-soft); }
.bb-place { font-family: var(--mono); font-size: .75rem !important; letter-spacing: .04em; }
.bb-nue .btn { display: inline-flex; align-items: center; margin-top: 6px; }
.bb-nue > div { padding: 0 4px 4px; }
.bb-nue .bb-fermer { z-index: 1; background: color-mix(in oklab, var(--paper) 80%, transparent); }

/* Sans JavaScript */
.bb-sans-js { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 24px; z-index: 5; }
.n2-biblio a { color: var(--ink-soft); }

/* Téléphone */
@media (max-width: 720px) {
  .bb-tete { max-width: calc(100% - 2 * var(--gutter)); top: 12px; }
  .bb-tete .crumbs { display: none; }
  .bb-tete h1 { font-size: 1.75rem; }
  .bb-aide { max-width: 30ch; font-size: .75rem; }
  .bb-salle { top: auto; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 62px); left: 50%; right: auto; translate: -50% 0; padding-left: 12px; gap: 6px; max-width: calc(100% - 24px); }
  .bb-chiffres { display: none; }
  .bb-copier span { display: none; }
  .bb-copier { width: 36px; padding: 0; justify-content: center; }
  .bb-barre { bottom: max(12px, env(safe-area-inset-bottom)); gap: 2px; padding: 3px; }
  .bb-barre button { padding: 0 10px; }
  .bb-portes { padding-right: 3px; margin-right: 0; }
  .bb-portes button span, .bb-hasard span { display: none; }
  .bb-portes button { width: 42px; padding: 0 !important; }
  .bb-hasard { width: 44px; padding: 0 !important; }
  .bb-barre .bb-chercher { padding: 0 14px; }
  .bb-feuille { right: 12px; left: 12px; width: auto; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 112px); }
  .bb-nue { left: 12px; right: 12px; width: auto; top: auto; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 112px); grid-template-columns: 112px 1fr; align-items: start; }
  .bb-nue img, .bb-nue.bb-debout img { width: 112px; height: auto; max-height: 30vh; }
  .bb-nue h2 { font-size: 1.3rem; }
  .bb-bulle { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .bb-feuille:not([hidden]), .bb-nue:not([hidden]) { animation: none; }
}

/* Le réglage de l'artiste (touche A, ou ?angle= dans l'adresse) : l'angle entre le sol et le plafond */
.bb-angle { position: absolute; z-index: 3; left: var(--gutter); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 4px); display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 16px; border-radius: 999px; background: var(--bb-verre); -webkit-backdrop-filter: blur(24px) saturate(170%); backdrop-filter: blur(24px) saturate(170%);
  border: 1px solid var(--bb-bord); box-shadow: inset 0 1px 0 rgb(255 255 255 / .55), var(--bb-ombre); }
.bb-angle label { font: 500 .6875rem/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); white-space: nowrap; }
.bb-angle input { width: 150px; accent-color: var(--ink); }
.bb-angle output { font: 500 .875rem/1 var(--mono); min-width: 3.4em; font-variant-numeric: tabular-nums; }
.bb-angle button { min-height: 36px; padding: 0 12px; border: 0; border-radius: 999px; cursor: pointer; background: var(--bb-survol); color: var(--ink); font: 500 .75rem/1 var(--sans); white-space: nowrap; }
.bb-angle button:hover { background: var(--ink); color: var(--paper); }
.bb-angle .bb-angle-fermer { width: 36px; padding: 0; font-size: 1.1rem; }
@media (max-width: 1100px) { .bb-angle { left: 50%; translate: -50% 0; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 124px); } }
@media (max-width: 720px) { .bb-angle input { width: 96px; } .bb-angle-salle { display: none; } }

/* Le mur du nombre : le bouton discret ; en 2D, le nombre en HTML */
.bb-nombre-btn { position: absolute; z-index: 3; right: var(--gutter); top: 74px; min-height: 36px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--bb-bord); background: var(--bb-verre); -webkit-backdrop-filter: blur(24px) saturate(170%); backdrop-filter: blur(24px) saturate(170%);
  color: var(--ink); font: 500 .75rem/1 var(--sans); box-shadow: inset 0 1px 0 rgb(255 255 255 / .55), var(--bb-ombre); opacity: 0; transition: opacity var(--d-recit) var(--courbe-sortie), background var(--d-court); }
.bb-pret .bb-nombre-btn { opacity: 1; }
.bb-nombre-btn:hover { background: var(--ink); color: var(--paper); }
.bb-mode-nombre .bb-portes, .bb-mode-nombre .bb-angle { display: none !important; }
.bb-nombre:not(.bb-sr) { position: absolute; z-index: 5; inset: 12px; overflow: auto; padding: 28px clamp(18px, 4vw, 48px); border-radius: 24px; background: var(--bb-verre-plein);
  border: 1px solid var(--bb-bord); box-shadow: var(--bb-ombre); overscroll-behavior: contain; }
.bb-nombre h2 { font-size: clamp(2rem, 1.4rem + 2vw, 3rem); margin: 0; }
.bb-nb-sous, .bb-nb-salle-t { font: 500 .75rem/1.4 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); margin: .4em 0 1em; }
.bb-nb-grand, .bb-nb-salle { font: 300 clamp(.95rem, .85rem + .3vw, 1.15rem)/1.6 var(--serif); font-variant-numeric: tabular-nums; letter-spacing: .02em; overflow-wrap: anywhere; margin: 0 0 1.4em; max-width: 120ch; }
.bb-nb-zero { opacity: .42; }
.bb-nb-texte { max-width: 52ch; font-size: .9375rem; color: var(--ink-soft); }
.bb-nb-fermer { position: sticky; float: right; top: 0; width: 40px; height: 40px; border: 0; border-radius: 50%; cursor: pointer; background: var(--bb-survol); color: var(--ink); font: 400 1.25rem/1 var(--sans); }
.bb-nb-fermer:hover { background: var(--ink); color: var(--paper); }
@media (max-width: 720px) { .bb-nombre-btn { top: 58px; right: 12px; min-height: 32px; padding: 0 12px; font-size: .6875rem; } .bb-tete h1 { max-width: 62%; } }
