/* ═══════════════ Djouney v3 — le Battement (module B2) ═══════════════
   components/heartbeat.js : classes .hb-
   Le calque du Battement vit dans <body> (position fixe, z-index 43) : au-dessus du carnet et du
   médaillon du Salon (40), sous la buée du souffle (44), l'Effleurement (45-46), la vue pleine du
   Salon (48), les feuilles (60) et les messages (100). Il ne capte jamais le doigt.
   Les battements eux-mêmes sont joués en Web Animations (heartbeat.js) : en mouvement réduit,
   ils restent de simples fondus au lieu de disparaître. */

/* ─── Surface : pendant les deux doigts et la séance, ni sélection ni loupe ─── */
.hb-holding,
.hb-holding * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.hb-holding input,
.hb-holding textarea,
.hb-holding [contenteditable]:not([contenteditable="false"]) {
  -webkit-user-select: text;
  user-select: text;
}

/* ─── Calque ─── */
.hb-layer {
  position: fixed;
  z-index: 43;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  contain: strict;
}
.hb-scenery {
  position: absolute;
  inset: 0;
}

/* Voile de la fleur qui respire aux bords de l'écran (opacité 0,18 au plus, posée par le script). */
.hb-pulse {
  position: absolute;
  inset: 0;
  opacity: 0;
  box-shadow: inset 0 0 clamp(48px, 14vmin, 120px) clamp(8px, 2.4vmin, 22px) var(--flower);
}

/* ─── Le fil rouge qui bat ─── */
/* Le fil du carnet pendant que le cœur de l'autre bat : un halo à peine plus chaud. */
.hb-thread { box-shadow: 0 0 4px 0 rgba(var(--thread-rgb), .35); }

/* Le rail se cale sur la partie visible du fil ; la lueur y descend. */
.hb-rail {
  position: absolute;
  left: 0;
  top: 0;
  width: 18px;
  height: 0;
  margin-left: -9px;
  overflow: hidden;
}
.hb-rail-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--thread);
  box-shadow: 0 0 6px 1px rgba(var(--thread-rgb), .5);
  opacity: 0;
}
.hb-spark {
  position: absolute;
  left: 50%;
  top: 0;
  width: 8px;
  height: 88px;
  margin-left: -4px;
  border-radius: 4px;
  background: radial-gradient(ellipse 50% 50% at 50% 62%, rgba(255, 255, 255, .95) 0%, rgba(var(--thread-rgb), .9) 34%, rgba(var(--thread-rgb), 0) 100%);
  opacity: 0;
}
.hb-spark.is-strong {
  width: 12px;
  margin-left: -6px;
}

/* ─── Mes deux halos, sous mes doigts ─── */
.hb-halo {
  position: absolute;
  left: 0;
  top: 0;
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;
  opacity: 0;
  transition: opacity var(--mid) var(--ease);
}
.hb-halo.is-on { opacity: 1; }
.hb-halo-glow {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  /* Sans color-mix : une déclaration avec var() invalide au calcul n'aurait pas de repli. */
  background: radial-gradient(circle closest-side, var(--flower-light) 0%, var(--flower-light) 16%, transparent 100%);
  opacity: .6;
}

/* ─── « Vos cœurs battent ensemble » : sérif italique, au centre du carnet ─── */
.hb-note {
  position: absolute;
  left: 50%;
  top: 50%;
  width: max-content;
  max-width: min(320px, calc(100vw - 32px));
  margin: 0;
  padding: 8px 18px;
  border-radius: 22px;
  background: rgba(var(--milk-rgb), .92); /* le lait (--milk), à peine translucide */
  box-shadow: var(--emboss-sm);
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 17px;
  line-height: 1.4;
  color: var(--ink);
  text-align: center;
  overflow-wrap: anywhere;
  opacity: 0;
  transform: translate(-50%, -50%);
}

/* ─── Alternative au clavier : invisible, sauf quand elle a le focus ─── */
.hb-alt:focus-visible {
  position: fixed;
  z-index: 46;
  left: 50%;
  top: calc(var(--hb-alt-top, 0px) + max(58px, calc(var(--safe-top) + 54px)));
  /* Sa largeur propre, plafonnée : un prénom long passe à la ligne au lieu d'être coupé à 360 px. */
  width: max-content;
  height: auto;
  max-width: calc(100vw - 32px);
  min-height: 44px;
  margin: 0;
  padding: 10px 18px;
  overflow: visible;
  clip: auto;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
  line-height: 1.35;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  border: 0;
  border-radius: 22px;
  background: var(--milk);
  box-shadow: var(--emboss-sm);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
}
.hb-alt[aria-pressed="true"]:focus-visible { box-shadow: var(--deboss); }
.hb-alt[aria-pressed="true"]::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--flower);
}

/* ─── Mouvement réduit : aucune lueur ne voyage (le script n'en crée pas ; garde-fou) ─── */
@media (prefers-reduced-motion: reduce) {
  .hb-spark { display: none; }
}
