/* ═══════════════ Djouney v3 — l'Effleurement et les consentements (module F) ═══════════════
   components/effleurement.js : classes .ef-   ·   components/consent.js : classes .cs-
   Le calque de l'Effleurement vit dans <body> (position fixe calée sur la surface du carnet),
   au-dessus des lettres, sous les feuilles modales (60) et les messages (100). */

/* ─── Surface du carnet ─── */
.ef-surface { -webkit-touch-callout: none; }

/* Pendant l'appui et la session : ni sélection de texte, ni loupe. */
.ef-holding,
.ef-holding * {
  -webkit-user-select: none;
  user-select: none;
}
.ef-holding input,
.ef-holding textarea,
.ef-holding [contenteditable]:not([contenteditable="false"]) {
  -webkit-user-select: text;
  user-select: text;
}

/* ─── Calque ─── */
.ef-layer {
  position: fixed;
  z-index: 45;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  contain: strict;
}
.ef-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
}
.ef-layer.is-live .ef-canvas { display: block; }

/* ─── Anneau d'attente : un cercle fin qui se trace autour du doigt ─── */
.ef-ring {
  position: absolute;
  left: 0;
  top: 0;
  width: 76px;
  height: 76px;
  margin: -38px 0 0 -38px;
  opacity: 0;
  transition: opacity .25s var(--ease), transform .45s var(--ease);
}
.ef-ring svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: rotate(-90deg);
}
.ef-ring-trace {
  fill: none;
  stroke: var(--stem);
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  opacity: .72;
}
.ef-ring.is-on { opacity: 1; }
.ef-ring.is-on .ef-ring-trace { animation: ef-trace var(--ef-ring-ms, 750ms) linear forwards; }
.ef-ring.is-done { opacity: 0; transform: scale(1.3); }
.ef-ring.is-done .ef-ring-trace { stroke-dashoffset: 0; }
@keyframes ef-trace { to { stroke-dashoffset: 0; } }

/* ─── Phrase d'accompagnement, en haut de la surface ─── */
.ef-hint {
  position: absolute;
  /* Sous l'encoche si la surface commence tout en haut de l'écran. */
  top: max(14px, calc(var(--safe-top) + 10px - var(--ef-y, 0px)));
  left: 50%;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(var(--milk-rgb), .88); /* repli si color-mix n'est pas pris en charge */
  background: color-mix(in srgb, var(--milk) 88%, transparent);
  box-shadow: var(--emboss-sm);
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transform: translate(-50%, -4px);
  transition: opacity var(--mid) var(--ease), transform var(--mid) var(--ease);
}
.ef-hint.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ─── Alternative au clavier : invisible, sauf quand elle a le focus ─── */
.ef-alt:focus-visible {
  position: fixed;
  z-index: 46;
  left: 50%;
  top: calc(var(--ef-alt-top, 0px) + max(58px, calc(var(--safe-top) + 54px)));
  width: auto;
  height: auto;
  min-height: 44px;
  margin: 0;
  padding: 0 18px;
  overflow: visible;
  clip: auto;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  border: 0;
  border-radius: 999px;
  background: var(--milk);
  box-shadow: var(--emboss-sm);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
}
.ef-alt[aria-pressed="true"]:focus-visible { box-shadow: var(--deboss); }
.ef-alt[aria-pressed="true"]::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--flower);
}

/* ═════════════════════════ Cartes de consentement ═════════════════════════ */
.cs-card {
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--milk);
  box-shadow: var(--emboss-sm);
  color: var(--ink);
  animation: cs-in var(--slow) var(--ease);
}
@keyframes cs-in { from { opacity: 0; transform: translateY(6px); } }

.cs-body {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.cs-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--porcelain);
  box-shadow: var(--deboss);
  color: var(--stem);
}
.cs-icon svg { width: 22px; height: 22px; }

.cs-text {
  margin: 0;
  padding-top: 5px;
  min-width: 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.cs-name {
  font-family: var(--font-hand);
  font-style: normal;
  font-weight: 500;
  font-size: 1.32em;
  line-height: 1;
  /* La manuscrite déborde à droite et mange l'espace qui suit : on lui rend un peu d'air. */
  padding-right: .12em;
}

.cs-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 14px;
  padding-left: 48px;
}
.cs-actions .btn { min-height: 44px; }
.cs-actions .btn:not(.btn--quiet) { padding: 0 20px; }

/* Proposition envoyée : la phrase est gravée dans la porcelaine, en creux, sans bouton. */
.cs-card--mine {
  padding: 12px 16px;
  background: var(--porcelain);
  box-shadow: var(--deboss);
}
.cs-card--mine .cs-icon {
  background: transparent;
  box-shadow: none;
}
.cs-card--mine .cs-text {
  font-size: 15px;
  color: rgba(var(--ink-rgb),.86);
}

@media (max-width: 380px) {
  .cs-actions { padding-left: 0; }
}

/* ─── Mouvement réduit : rien ne se trace ni ne glisse, tout apparaît en fondu ─── */
@media (prefers-reduced-motion: reduce) {
  .ef-ring.is-on .ef-ring-trace { animation: none; stroke-dashoffset: 0; }
  .ef-ring.is-done { transform: none; }
  .ef-hint,
  .ef-hint.is-on { transform: translate(-50%, 0); }
  .cs-card { animation: none; }
}
