/* ==========================================================================
   Bū tools · base
   La DA reprise de bu-site (DESIGN.md) : noir chaud, papier, un seul orange,
   Unbounded (titres) / Poppins (texte) / mono (repères), pas de capitales forcées.
   Ici : les couleurs, la typo, le fond (grain, lumière) et les boutons communs.
   ========================================================================== */

:root {
  color-scheme: dark;
  --orange: #ff5a1f; --rouge: #c01d0a; --peche: #ffa370;
  --noir: #12100e; --encre: #1e1a17; --papier: #f2f0eb; --blanc: #ffffff;
  --texte2: rgba(242, 240, 235, .6); --filet: rgba(242, 240, 235, .18);
  --courbe: cubic-bezier(.16, 1, .3, 1);
  --gouttiere: 16px;
  --icone: 72px;
  --display: 'Unbounded', sans-serif;
  --corps: 'Poppins', sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (min-width: 768px) { :root { --gouttiere: 24px; --icone: 88px; } }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--noir); color: var(--papier); }
body {
  font: 400 15px/1.6 var(--corps);
  /* Tout tient sur la hauteur de l'écran : la page ne défile jamais (seules certaines zones défilent) */
  height: 100vh; height: 100svh; overflow: hidden; display: flex; flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }

/* Texte lu par les lecteurs d'écran seulement */
.invisible { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; margin: 0; }

/* ---------- Fond ---------- */
/* Grain de pellicule, très léger, au-dessus de la lumière et sous le contenu (pleine définition de l'écran) */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
}
/* Fond calme : petit dégradé fixe, quand l'animation est coupée ou sans WebGL */
.fond-calme { position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 55% at 100% 0%, rgba(255, 90, 31, .13), transparent 70%),
    radial-gradient(ellipse 60% 45% at 0% 100%, rgba(192, 29, 10, .07), transparent 70%); }
/* Lumière orange WebGL (app/lumiere.js) : quand elle tourne, elle remplace le fond calme */
.lumiere { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.lumiere canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity 1.6s var(--courbe); }
html.webgl .lumiere canvas { opacity: 1; }
html.webgl .fond-calme { display: none; }

/* ---------- Boutons communs ---------- */
/* Pastille : le bouton principal de la DA. « discrete » : transparente, à fin contour */
.pastille {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; border: 0; border-radius: 999px;
  background: var(--papier); color: var(--noir); padding: 10px 16px;
  font: 500 11px/1.5 var(--mono); letter-spacing: .1em;
  transition: background .6s var(--courbe), translate .6s var(--courbe), opacity .4s var(--courbe);
}
.pastille:hover { background: var(--blanc); translate: 4px 0; }
.pastille.discrete { background: transparent; color: var(--papier); box-shadow: inset 0 0 0 1px var(--filet); }
.pastille.discrete:hover { box-shadow: inset 0 0 0 1px var(--papier); }
.pastille:disabled { opacity: .4; pointer-events: none; }

/* Rond : petit bouton icône à fin contour (la flèche retour des outils) */
.rond { width: 40px; height: 40px; flex: none; padding: 0; border: 0; border-radius: 50%; background: transparent; display: grid; place-items: center;
  box-shadow: inset 0 0 0 1px var(--filet); color: var(--texte2); transition: color .4s var(--courbe), box-shadow .4s var(--courbe); }
.rond svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rond:hover { color: var(--papier); box-shadow: inset 0 0 0 1px var(--papier); }

/* Lien texte */
.lien { border: 0; background: none; padding: 4px 0; font: 600 12px/1 var(--corps); letter-spacing: .1em; color: var(--papier);
  text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 1px; }
.lien:hover { color: var(--peche); }

/* Repère : micro-texte mono, comme les graduations d'un objectif */
.repere { font: 500 11px/1.5 var(--mono); letter-spacing: .1em; color: var(--texte2); }

/* Focus clavier : contour orange */
.pastille:focus-visible, .rond:focus-visible, .lien:focus-visible,
.tuile:focus-visible, .ligne:focus-visible { outline: 2px solid var(--orange); outline-offset: 3px; }

/* ---------- Message bref (en bas de l'écran) ---------- */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 20; translate: -50% 20px; opacity: 0;
  width: max-content; max-width: calc(100vw - 32px); text-align: center; pointer-events: none;
  background: var(--papier); color: var(--noir); border-radius: 999px; padding: 10px 18px; font: 500 12px/1.4 var(--mono); letter-spacing: .06em;
  transition: opacity .3s var(--courbe), translate .5s var(--courbe); }
.toast.vu { opacity: 1; translate: -50% 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
