/* ═══════════════ Djouney v3 — capsule vocale et enregistreur (module M1) ═══════════════
   components/capsule.js : classes .cp-   ·   components/recorder-ui.js : classes .rc-
   (voir ARCHITECTURE.md § 14.2 et § 16). Seule couleur vive : la fleur du duo (--flower, --flower-light). */

/* ─── La capsule : une petite feuille de papier crème qui porte un vrai cachet de cire ─── */
.cp {
  display: grid;
  justify-items: center;
  gap: 2px;
  width: min(100%, 252px);
  padding: 8px 14px 6px;
  border-radius: 20px;
  background-color: var(--milk);
  background-image: radial-gradient(130% 90% at 16% 0%, rgba(var(--light-rgb), calc(.85 * var(--hl-a))), rgba(var(--light-rgb), calc(0 * var(--hl-a))) 62%);
  box-shadow: var(--emboss-sm), inset 1px 1px 0 rgba(var(--light-rgb), calc(.95 * var(--hl-a))), inset -1px -1px 0 rgba(var(--hollow-rgb), .4);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.cp--mine { margin-left: auto; }

.cp-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 176px;
  height: 176px;
  margin: -14px 0 -18px;
}
.cp-stage > * { grid-area: 1 / 1; }

.cp-aura {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Anneau de progression : un trait fin autour du sceau (au-dessus de l'aura). */
.cp-ring {
  position: relative;
  width: 104px;
  height: 104px;
  overflow: visible;
  transform: rotate(-90deg);
  pointer-events: none;
}
.cp-ring__track {
  fill: none;
  stroke: rgba(var(--shadow-rgb), .18);
  stroke-width: 1.2;
}
.cp-ring__fill {
  fill: none;
  stroke: var(--flower);
  stroke-width: 1.8;
  stroke-linecap: butt;
  stroke-dasharray: 0 600;
  opacity: 0;
  transition: opacity 420ms var(--ease);
}

/* Le sceau, qu'on maintient. */
.cp-seal {
  position: relative;
  display: grid;
  place-items: center;
  width: 86px;
  height: 86px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.cp-seal:focus-visible { outline-offset: 2px; border-radius: 50%; }
/* Le cachet de cire (sa fleur est celle du carnet : il garde la transition éclair de `color`, cf. ink.css).
   On l'enfonce lui-même sous le pouce, pas le bouton : rien n'isole son rendu autour de lui. */
.cp-seal .pc-seal {
  pointer-events: none;
  transition: transform 180ms var(--ease), filter 300ms var(--ease), opacity 420ms var(--ease), color 1ms linear;
}
.cp-seal.is-held .pc-seal { transform: scale(.955); filter: saturate(1.08) brightness(.97); }

/* Textes au-dessus de l'aura, qui déborde un peu de la scène. */
.cp-hint,
.cp-meta,
.cp-toggle { position: relative; }

.cp-hint {
  margin: 0;
  min-height: 1.45em;
  max-width: 26ch;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 15px;
  line-height: 1.45;
  text-align: center;
  color: rgba(var(--ink-rgb),.86);
}
.cp[data-state="error"] .cp-hint { color: var(--ink); }

.cp-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 0 6px;
  margin: 0;
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: .3px;
  line-height: 1.6;
  color: rgba(var(--ink-rgb),.84);
}
.cp-time { font-variant-numeric: tabular-nums; }
.cp-amb { font-family: var(--font-serif); font-style: italic; font-weight: 400; font-size: 13.5px; letter-spacing: 0; }
.cp-meta > :not(:first-child)::before { content: "·"; margin-right: 6px; font-style: normal; }
.cp-meta > [hidden] { display: none; }

/* Alternative au geste : discrète, mais une vraie cible de 44 px. */
.cp-toggle {
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: box-shadow .25s var(--ease), background-color .25s var(--ease);
}
.cp-toggle:active { background: var(--porcelain); box-shadow: var(--deboss); }

/* ─── L'enregistreur ─── */
.rc {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 4px 0;
}
.rc-count {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .4px;
  font-variant-numeric: tabular-nums;
  color: rgba(var(--ink-rgb),.86);
}
.rc-wave {
  display: block;
  width: 100%;
  max-width: 320px;
  height: 56px;
}

/* Grand bouton rond en relief ; pendant l'enregistrement, il prend la couleur de la fleur. */
.rc-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 86px;
  height: 86px;
  margin: 2px 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--milk);
  color: var(--stem);
  box-shadow: var(--emboss), inset 1px 1px 0 rgba(var(--light-rgb), calc(.95 * var(--hl-a)));
  transition: background-color 450ms var(--ease), color 450ms var(--ease), box-shadow 450ms var(--ease), transform .15s var(--ease);
}
.rc-btn > span { grid-area: 1 / 1; display: grid; place-items: center; transition: opacity 300ms var(--ease); }
.rc-btn svg { width: 30px; height: 30px; }
.rc-btn:active { transform: translateY(1px); box-shadow: var(--deboss); }
.rc-btn:focus-visible { outline-offset: 4px; border-radius: 50%; }
.rc-btn[aria-disabled="true"] { cursor: progress; }
.rc-btn__stop { opacity: 0; }
.rc[data-state="recording"] .rc-btn,
.rc[data-state="stopping"] .rc-btn {
  background: var(--flower);
  color: var(--flower-ink, #fff);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--flower) 30%, transparent), inset 0 1px 0 rgba(var(--light-rgb), calc(.25 * var(--hl-a)));
}
.rc[data-state="recording"] .rc-btn__mic,
.rc[data-state="stopping"] .rc-btn__mic { opacity: 0; }
.rc[data-state="recording"] .rc-btn__stop,
.rc[data-state="stopping"] .rc-btn__stop { opacity: 1; }
.rc[data-state="starting"] .rc-btn { box-shadow: var(--deboss); }

.rc-hint {
  margin: 0;
  max-width: 32ch;
  min-height: 1.45em;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 15px;
  line-height: 1.45;
  text-align: center;
  color: rgba(var(--ink-rgb),.86);
}

.rc-alert {
  margin: 0;
  max-width: 36ch;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--milk);
  box-shadow: var(--emboss-sm), inset 3px 0 0 var(--thread);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
}

/* Mini-lecteur de réécoute, creusé dans la porcelaine. */
.rc-player {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 320px;
  padding: 6px 16px 6px 6px;
  border-radius: 999px;
  background: var(--porcelain);
  box-shadow: var(--deboss);
}
.rc-play {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--milk);
  color: var(--stem);
  box-shadow: var(--emboss-sm);
  transition: transform .15s var(--ease), box-shadow .25s var(--ease);
}
.rc-play:active { transform: translateY(1px); box-shadow: var(--deboss); }
.rc-play svg { width: 18px; height: 18px; }
.rc-track {
  position: relative;
  flex: 1;
  min-width: 40px;
  height: 3px;
  border-radius: 2px;
  background: rgba(var(--shadow-rgb), .22);
  overflow: hidden;
}
.rc-track__fill {
  position: absolute;
  inset: 0;
  background: var(--ink);
  transform: scaleX(0);
  transform-origin: 0 50%;
}
.rc-ptime {
  flex: none;
  min-width: 8.5ch;
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: rgba(var(--ink-rgb),.86);
}
.rc-redo { min-height: 44px; margin-top: -2px; }

/* ─── Mouvement réduit : pas d'aura animée, une lueur immobile pendant l'écoute ─── */
@media (prefers-reduced-motion: reduce) {
  .cp-aura { display: none; }
  .cp-stage::before {
    content: "";
    grid-area: 1 / 1;
    width: 128px;
    height: 128px;
    border-radius: 50%;
    background: radial-gradient(closest-side,
      color-mix(in srgb, var(--flower-light) 42%, transparent),
      color-mix(in srgb, var(--flower-light) 14%, transparent) 62%,
      transparent);
    opacity: 0;
    transition: opacity 500ms ease !important;
  }
  .cp.is-playing .cp-stage::before { opacity: 1; }
  .cp-seal.is-held .pc-seal { transform: none; }
}
