/* =========================================================================
   Respiration d'accueil : 10 secondes de cohérence cardiaque avant la page
   (5 s pour inspirer, 5 s pour expirer, soit le rythme de 6 respirations par minute).

   Piloté par respiration.js avec data-state sur .breath :
   intro → depart → souffle → fin → sortie
   Sans JavaScript (ou déjà fait dans cet onglet), l'écran ne s'affiche pas.
   ========================================================================= */

.breath { display: none; }
html.has-breath .breath { display: grid; }
html.breath-lock, html.breath-lock body { overflow: hidden; }

.breath {
  --breath-size: min(82vmin, 460px);
  --t: var(--dc-terracotta);
  position: fixed; inset: 0; z-index: 1000;
  place-items: center;
  background: var(--dc-creme);
  color: var(--dc-charbonneux);
  overflow: hidden;
  overscroll-behavior: contain;
  outline: none;
  transition: opacity 1.1s ease .15s, visibility 0s linear 1.3s;
}
.breath > :not(.breath-top) { grid-area: 1 / 1; }

/* Chaleur de fond : monte à l'inspiration, retombe à l'expiration */
.breath::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle closest-side at 50% 50%, color-mix(in srgb, var(--t) 12%, transparent), transparent);
  opacity: .55;
}

/* ---------- Barre du haut : calée sur l'en-tête de la page ---------- */
.breath .breath-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 20px; padding-bottom: 20px;
}
.breath-top .by { font-size: var(--dc-size-sm); color: var(--dc-text-muted); }
.breath-top .by strong { color: var(--dc-charbonneux); }
.breath-skip {
  font: inherit; font-size: var(--dc-size-sm); font-weight: 600;
  color: var(--dc-text-muted);
  background: none; border: 0; padding: 6px 2px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 4px;
  text-decoration-color: color-mix(in srgb, var(--dc-charbonneux) 25%, transparent);
  transition: color .2s ease;
}
.breath-skip:hover { color: var(--dc-charbonneux); }
.breath-skip:focus-visible { outline: 2px solid var(--t); outline-offset: 3px; }

/* ---------- La scène : halo, échos, disque, anneau de progression ---------- */
.breath-stage {
  position: relative;
  width: var(--breath-size); aspect-ratio: 1;
  display: grid; place-items: center;
  pointer-events: none;
}
.breath-stage > * { grid-area: 1 / 1; }

.breath-glow, .breath-ring, .breath-core { border-radius: 50%; aspect-ratio: 1; will-change: transform, opacity; }

.breath-glow {
  width: 100%;
  background: radial-gradient(closest-side,
    color-mix(in srgb, var(--t) 30%, transparent) 0%,
    color-mix(in srgb, var(--t) 9%, transparent) 62%,
    transparent 100%);
  transform: scale(.82); opacity: .55;
  transition: transform 1s cubic-bezier(.2, .7, .2, 1), opacity 1s ease;
}

.breath-ring {
  border: 1px solid color-mix(in srgb, var(--t) 50%, transparent);
  opacity: 0;
}
.breath-ring.r1 { width: 70%; --o: .55; }
.breath-ring.r2 { width: 82%; --o: .35; }
.breath-ring.r3 { width: 94%; --o: .2; }

.breath-core {
  width: 64%;
  background: radial-gradient(circle at 50% 36%,
    color-mix(in srgb, var(--t) 9%, var(--dc-creme)) 0%,
    color-mix(in srgb, var(--t) 24%, var(--dc-creme)) 60%,
    color-mix(in srgb, var(--t) 44%, var(--dc-creme)) 100%);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--t) 28%, transparent),
    0 30px 70px -30px color-mix(in srgb, var(--t) 75%, transparent);
  opacity: 0; transform: scale(.3);
  transition: transform .9s cubic-bezier(.2, .7, .2, 1), opacity .9s ease;
}

.breath-orbit {
  position: relative; width: 90%; aspect-ratio: 1;
  opacity: 0; transition: opacity .8s ease;
}
.breath-orbit svg { display: block; width: 100%; height: 100%; overflow: visible; transform: rotate(-90deg); }
.breath-track { fill: none; stroke: color-mix(in srgb, var(--dc-charbonneux) 14%, transparent); stroke-width: .4; }
.breath-bar {
  fill: none; stroke: var(--t); stroke-width: .8; stroke-linecap: round;
  stroke-dasharray: 100; stroke-dashoffset: 100;
}
.breath-mark { fill: color-mix(in srgb, var(--dc-charbonneux) 35%, var(--dc-creme)); }
.breath-tip { position: absolute; inset: 0; }
.breath-tip::before {
  content: ""; position: absolute; top: -5px; left: 50%;
  width: 10px; height: 10px; margin-left: -5px; border-radius: 50%;
  background: var(--t);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--t) 16%, transparent), 0 0 20px color-mix(in srgb, var(--t) 65%, transparent);
}

/* ---------- Le mot guide, au centre du disque ---------- */
.breath-say {
  position: relative; z-index: 1;
  text-align: center; pointer-events: none;
  opacity: 0; transition: opacity .5s ease;
}
.breath-word {
  display: block;
  font-family: var(--dc-font-title); font-style: italic; font-weight: 400;
  font-size: clamp(2.4rem, 1.7rem + 2.6vw, 3.5rem); line-height: 1;
}
.breath-hint {
  display: block; margin-top: 12px;
  font-size: var(--dc-size-xs); font-weight: 700;
  letter-spacing: var(--dc-tracking-label); text-transform: uppercase;
  color: color-mix(in srgb, var(--t) 78%, var(--dc-charbonneux));
}
.breath-hint:empty { display: none; }
.breath-say.is-new .breath-word { animation: breath-word-in 1.1s cubic-bezier(.2, .7, .2, 1) both; }
.breath-say.is-new .breath-hint { animation: breath-hint-in 1.1s cubic-bezier(.2, .7, .2, 1) .18s both; }

/* ---------- L'écran d'accueil ---------- */
.breath-intro {
  position: relative; z-index: 2;
  max-width: 32rem; padding: 0 24px;
  text-align: center;
  transition: opacity .6s ease, transform .9s cubic-bezier(.2, .7, .2, 1), filter .6s ease, visibility 0s linear .9s;
}
.breath-intro .dc-label { color: var(--t); margin-bottom: 16px; }
.breath-intro h2 { font-size: var(--dc-title-md); margin-bottom: 16px; }
.breath-intro h2 em { color: var(--t); }
.breath-lede { color: var(--dc-text-muted); max-width: 25em; margin: 0 auto; text-wrap: pretty; }
.breath .breath-start { margin-top: 28px; padding: 17px 30px; font-size: 1.0625rem; gap: .7em; }
.breath-start-dot {
  width: 8px; height: 8px; border-radius: 50%; background: currentColor;
  animation: breath-dot 4s ease-in-out infinite;
}

/* =========================================================================
   États
   ========================================================================= */

/* intro : le halo respire lentement, des ondes invitent à commencer */
.breath[data-state="intro"] .breath-intro > * { animation: breath-rise .9s cubic-bezier(.2, .7, .2, 1) both; }
.breath[data-state="intro"] .breath-intro > :nth-child(2) { animation-delay: .1s; }
.breath[data-state="intro"] .breath-intro > :nth-child(3) { animation-delay: .2s; }
.breath[data-state="intro"] .breath-intro > :nth-child(4) { animation-delay: .32s; }
.breath[data-state="intro"] .breath-glow { animation: breath-idle 8s cubic-bezier(.45, 0, .55, 1) infinite; }
.breath[data-state="intro"] .breath-ring { animation: breath-ripple 8s cubic-bezier(.2, .6, .3, 1) infinite; }
.breath[data-state="intro"] .breath-ring.r2 { animation-delay: 2.66s; }
.breath[data-state="intro"] .breath-ring.r3 { animation-delay: 5.33s; }

/* L'accueil s'efface dès qu'on quitte l'intro */
.breath:not([data-state="intro"]) .breath-intro {
  opacity: 0; transform: translateY(-14px) scale(.98); filter: blur(6px);
  visibility: hidden; pointer-events: none;
}

/* depart : le disque se pose au centre, prêt à inspirer */
.breath[data-state="depart"] .breath-core,
.breath[data-state="souffle"] .breath-core { opacity: 1; transform: scale(.5); }
.breath[data-state="depart"] .breath-glow,
.breath[data-state="souffle"] .breath-glow { opacity: .5; transform: scale(.55); }
.breath[data-state="depart"] .breath-orbit,
.breath[data-state="souffle"] .breath-orbit { opacity: 1; }
.breath[data-state="souffle"] .breath-say,
.breath[data-state="fin"] .breath-say { opacity: 1; }

/* souffle : 10 s, une inspiration de 5 s puis une expiration de 5 s */
.breath[data-state="souffle"]::before { animation: breath-warm 10s both; }
.breath[data-state="souffle"] .breath-core { animation: breath-core 10s both; }
.breath[data-state="souffle"] .breath-glow { animation: breath-glow 10s .12s both; }
.breath[data-state="souffle"] .breath-ring { animation: breath-echo 10s both; }
.breath[data-state="souffle"] .breath-ring.r1 { animation-delay: .16s; }
.breath[data-state="souffle"] .breath-ring.r2 { animation-delay: .32s; }
.breath[data-state="souffle"] .breath-ring.r3 { animation-delay: .48s; }
.breath[data-state="souffle"] .breath-bar { animation: breath-fill 10s linear both; }
.breath[data-state="souffle"] .breath-tip { animation: breath-turn 10s linear both; }

/* fin : le disque se pose, l'anneau complet s'efface */
.breath[data-state="fin"] .breath-core { opacity: 1; transform: scale(.7); transition-duration: 1.4s; }
.breath[data-state="fin"] .breath-glow { opacity: .85; transform: scale(.9); transition-duration: 1.4s; }
.breath[data-state="fin"] .breath-bar { stroke-dashoffset: 0; }
.breath[data-state="fin"] .breath-orbit { opacity: 0; transition-duration: 1.2s; }

/* sortie : le disque s'ouvre en grand et laisse place à la page */
.breath[data-state="sortie"] { opacity: 0; visibility: hidden; pointer-events: none; }
.breath[data-state="sortie"] .breath-core { opacity: 0; transform: scale(2.4); transition: transform 1.4s cubic-bezier(.6, 0, .3, 1), opacity 1.2s ease; }
.breath[data-state="sortie"] .breath-glow { opacity: 0; transform: scale(2); transition: transform 1.4s cubic-bezier(.6, 0, .3, 1), opacity 1.2s ease; }
.breath[data-state="sortie"] .breath-say,
.breath[data-state="sortie"] .breath-orbit { opacity: 0; transition: opacity .4s ease; }

/* La page arrive en douceur derrière */
body.breath-reveal .hero { animation: breath-page-in 1.3s cubic-bezier(.2, .7, .2, 1) .2s both; }

/* =========================================================================
   Animations
   ========================================================================= */
@keyframes breath-core {
  0%   { transform: scale(.5); animation-timing-function: cubic-bezier(.45, 0, .55, 1); }
  50%  { transform: scale(1);  animation-timing-function: cubic-bezier(.45, 0, .55, 1); }
  100% { transform: scale(.5); }
}
@keyframes breath-glow {
  0%   { transform: scale(.55); opacity: .5; animation-timing-function: cubic-bezier(.45, 0, .55, 1); }
  50%  { transform: scale(1.08); opacity: 1; animation-timing-function: cubic-bezier(.45, 0, .55, 1); }
  100% { transform: scale(.55); opacity: .5; }
}
@keyframes breath-echo {
  0%   { transform: scale(.5); opacity: 0; animation-timing-function: cubic-bezier(.45, 0, .55, 1); }
  50%  { transform: scale(1); opacity: var(--o); animation-timing-function: cubic-bezier(.45, 0, .55, 1); }
  100% { transform: scale(.5); opacity: 0; }
}
@keyframes breath-warm {
  0%, 100% { opacity: .55; }
  50%      { opacity: 1; }
}
@keyframes breath-fill { to { stroke-dashoffset: 0; } }
@keyframes breath-turn { from { transform: rotate(0); } to { transform: rotate(1turn); } }

@keyframes breath-idle {
  0%, 100% { transform: scale(.82); opacity: .55; }
  50%      { transform: scale(.96); opacity: .9; }
}
@keyframes breath-ripple {
  0%   { transform: scale(.6); opacity: 0; }
  30%  { opacity: var(--o); }
  100% { transform: scale(1.35); opacity: 0; }
}
@keyframes breath-dot {
  0%, 100% { transform: scale(.7); opacity: .6; }
  50%      { transform: scale(1.3); opacity: 1; }
}
@keyframes breath-rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes breath-word-in {
  from { opacity: 0; transform: translateY(10px); filter: blur(8px); letter-spacing: .08em; }
  to   { opacity: 1; transform: none; filter: none; letter-spacing: normal; }
}
@keyframes breath-hint-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
@keyframes breath-page-in { from { opacity: 0; transform: translateY(16px); } }

/* Petits écrans en paysage : on resserre l'accueil */
@media (max-height: 560px) {
  .breath-intro h2 { font-size: var(--dc-title-sm); margin-bottom: 10px; }
  .breath .breath-start { margin-top: 18px; padding: 14px 26px; }
}

/* Mouvements réduits : le disque ne grossit plus, il s'éclaire et s'atténue */
@media (prefers-reduced-motion: reduce) {
  .breath[data-state="intro"] .breath-intro > *,
  .breath[data-state="intro"] .breath-ring,
  .breath[data-state="intro"] .breath-glow,
  .breath-start-dot,
  .breath[data-state="souffle"] .breath-ring,
  body.breath-reveal .hero { animation: none; }
  .breath-tip { display: none; }
  .breath-core, .breath[data-state="depart"] .breath-core, .breath[data-state="souffle"] .breath-core,
  .breath[data-state="fin"] .breath-core, .breath[data-state="sortie"] .breath-core { transform: scale(.8); }
  .breath-glow, .breath[data-state="depart"] .breath-glow, .breath[data-state="souffle"] .breath-glow,
  .breath[data-state="fin"] .breath-glow, .breath[data-state="sortie"] .breath-glow { transform: scale(.9); }
  .breath[data-state="souffle"] .breath-core,
  .breath[data-state="souffle"] .breath-glow { animation: breath-calm 10s both; }
  .breath:not([data-state="intro"]) .breath-intro { transform: none; filter: none; }
  .breath-say.is-new .breath-word, .breath-say.is-new .breath-hint { animation-name: breath-hint-in; }
}
@keyframes breath-calm {
  0%, 100% { opacity: .4; }
  50%      { opacity: 1; }
}
