/* Gardeo — onboarding : carrousel (A), célébration (B), checklist (C). Voir design/ONBOARDING.md et MOTION.md */

/* ================= A. Carrousel d’introduction (palette fixe, indépendante du thème) ================= */
.ob-intro {
  --oi-bg: #1C0916;
  --oi-fg: #FBF4D9;
  position: fixed;
  inset: 0;
  z-index: 150;
  overflow: hidden;
  color: var(--oi-fg);
  background: var(--oi-bg);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.oi-slide {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  max-width: 100%;
  padding: calc(env(safe-area-inset-top, 0px) + 68px) 28px calc(env(safe-area-inset-bottom, 0px) + 124px);
  color: var(--s-fg);
  background: var(--s-bg);
}

.oi-slide[hidden] { display: none; }

.oi-art {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
}

.oi-art svg {
  width: 100%;
  height: 100%;
  max-width: 340px;
  max-height: 310px;
  overflow: visible;
}

.oi-art text { font-family: inherit; }

.oi-title {
  margin: 14px 0 10px;
  font-size: clamp(32px, 9.6vw, 42px);
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.oi-l { display: block; overflow: hidden; padding-bottom: 0.08em; }
.oi-l > span { display: block; transform: translateY(110%); }

.oi-sub {
  max-width: 30ch;
  margin: 0;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(10px);
}

.oi-slide.is-in .oi-l > span {
  transform: none;
  transition: transform 0.72s var(--ease-out) calc(0.3s + var(--n) * 0.1s);
}

.oi-slide.is-in .oi-sub {
  opacity: 0.82;
  transform: none;
  transition: opacity 0.5s var(--ease-out) 0.6s, transform 0.6s var(--ease-out) 0.6s;
}

/* chrome (haut, bas) : la couleur suit la diapositive courante */
.oi-brand, .oi-skip, .oi-dots, .oi-next {
  position: absolute;
  z-index: 10;
  color: var(--oi-fg);
  transition: color 0.35s var(--ease-in-out) 0.2s, background-color 0.35s var(--ease-in-out) 0.2s, opacity 0.3s var(--ease-out), transform 0.3s var(--ease-out);
}

.oi-brand {
  top: calc(env(safe-area-inset-top, 0px) + 20px);
  left: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.oi-logo { width: 26px; height: 26px; }

.oi-skip {
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  right: 16px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 16px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  background: color-mix(in srgb, var(--oi-fg) 14%, transparent);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.ob-intro.is-last .oi-skip { opacity: 0; pointer-events: none; }

.oi-dots {
  left: 28px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 52px);
  display: flex;
  gap: 6px;
}

.oi-dots i {
  width: 8px;
  height: 8px;
  background: color-mix(in srgb, var(--oi-fg) 30%, transparent);
  border-radius: 4px;
  transition: width 0.4s var(--ease-out), background-color 0.35s var(--ease-in-out);
}

.oi-dots i.is-on { width: 24px; background: var(--oi-fg); }
.ob-intro.is-last .oi-dots { opacity: 0; }

/* bouton Suivant rond + anneau de progression */
.oi-next {
  right: 24px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 28px);
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.oi-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.oi-ring circle { fill: none; stroke-width: 3; }
.oi-ring-t { stroke: color-mix(in srgb, var(--oi-fg) 28%, transparent); transition: stroke 0.35s var(--ease-in-out) 0.2s; }
.oi-ring-p { stroke: var(--oi-fg); stroke-linecap: round; stroke-dasharray: 1; transition: stroke-dashoffset 0.78s var(--ease-in-out), stroke 0.35s var(--ease-in-out) 0.2s; }

.oi-next-i {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  color: var(--oi-bg);
  background: var(--oi-fg);
  border-radius: 50%;
  transition: color 0.35s var(--ease-in-out) 0.2s, background-color 0.35s var(--ease-in-out) 0.2s, transform 0.2s var(--ease-out);
}

.oi-next-i svg { width: 24px; height: 24px; }
.oi-next:active .oi-next-i { transform: scale(0.94); }
.ob-intro.is-last .oi-next { opacity: 0; transform: scale(0.6); pointer-events: none; transition-delay: 0.7s, 0.7s, 0.7s, 0.7s; }

/* dernière diapositive : choix du rôle */
.oi-cta {
  position: absolute;
  left: 28px;
  right: 28px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  display: grid;
  gap: 10px;
  opacity: 0;
  transform: translateY(16px);
}

.oi-slide.is-in .oi-cta { opacity: 1; transform: none; transition: opacity 0.5s var(--ease-out) 0.9s, transform 0.6s var(--ease-out) 0.9s; }
.oi-slide:has(.oi-cta) { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 216px); }

.oi-primary, .oi-secondary, .oi-link {
  min-height: 52px;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.16s var(--ease-out);
}

.oi-primary { color: #F3E7A6; background: #1C0916; border: 2px solid #1C0916; border-radius: 999px; }
.oi-secondary { color: #1C0916; background: transparent; border: 2px solid #1C0916; border-radius: 999px; }
.oi-link { min-height: 44px; color: #1C0916; background: none; border: 0; font-size: 15px; font-weight: 700; text-decoration: underline; text-underline-offset: 4px; }
.oi-primary:active, .oi-secondary:active { transform: scale(0.97); }

/* illustrations */
.oi-art svg [style*="--i"], .oi-card, .oi-day, .oi-cal { transform-box: fill-box; transform-origin: center; }
.oi-card { opacity: 0; }
.oi-slide.is-in .oi-card {
  animation:
    oiDrop 0.9s var(--ease-spring) calc(0.35s + var(--i) * 0.14s) both,
    oiFloat 3.6s ease-in-out calc(1.7s + var(--i) * 0.45s) infinite alternate;
}

@keyframes oiDrop { from { opacity: 0; transform: translateY(-70px) scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes oiFloat { from { transform: translateY(0); } to { transform: translateY(-9px); } }

.oi-cal { opacity: 0; }
.oi-slide.is-in .oi-cal { animation: oiRise 0.7s var(--ease-out) 0.2s both; }
@keyframes oiRise { from { opacity: 0; transform: translateY(26px) scale(0.97); } to { opacity: 1; transform: none; } }

.oi-dc { opacity: 0; transform-box: fill-box; transform-origin: center; transform: scale(0); }
.oi-dk { stroke-dasharray: 1; stroke-dashoffset: 1; }
.oi-slide.is-in .oi-dc { animation: oiPop 0.45s var(--ease-spring) calc(0.9s + var(--k) * 0.36s) both; }
.oi-slide.is-in .oi-dk { animation: oiDraw 0.35s var(--ease-out) calc(1.05s + var(--k) * 0.36s) both; }
.oi-slide.is-in .oi-dn { animation: oiHide 0.2s linear calc(0.95s + var(--k) * 0.36s) both; }

@keyframes oiPop { from { opacity: 1; transform: scale(0); } to { opacity: 1; transform: scale(1); } }
@keyframes oiDraw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes oiHide { to { opacity: 0; } }

.oi-ringc { stroke-dasharray: 1; stroke-dashoffset: 1; }
.oi-seal { opacity: 0; transform-box: fill-box; transform-origin: center; transform: scale(0); }
.oi-seal-ck { stroke-dasharray: 1; stroke-dashoffset: 1; }
.oi-amount, .oi-unit { opacity: 0; }
.oi-track-fill { stroke-dasharray: 1; stroke-dashoffset: 1; }
.oi-tdot { transform-box: fill-box; transform-origin: center; transform: scale(0); }
.oi-slide.is-in .oi-ringc { animation: oiDraw 0.7s var(--ease-in-out) 0.3s both; }
.oi-slide.is-in .oi-seal { animation: oiPop 0.5s var(--ease-spring) 0.7s both; }
.oi-slide.is-in .oi-seal-ck { animation: oiDraw 0.45s var(--ease-out) 1s both; }
.oi-slide.is-in .oi-amount { animation: oiFade 0.5s var(--ease-out) 0.7s both; }
.oi-slide.is-in .oi-unit { animation: oiFade 0.5s var(--ease-out) 1s both; }
.oi-slide.is-in .oi-track-fill { animation: oiDraw 1.3s var(--ease-in-out) 1.5s both; }
.oi-slide.is-in .oi-tdot { animation: oiPop 0.4s var(--ease-spring) calc(1.5s + var(--k) * 0.65s) both; }
@keyframes oiFade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.oi-slide .oi-amount { transform-box: fill-box; }

@media (max-height: 700px) {
  .oi-slide { padding-top: calc(env(safe-area-inset-top, 0px) + 60px); }
  .oi-title { font-size: 30px; margin-top: 8px; }
  .oi-sub { font-size: 15px; line-height: 22px; }
  .oi-slide:has(.oi-cta) { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 200px); }
  .oi-primary, .oi-secondary { min-height: 48px; }
  .oi-cta { gap: 8px; }
}

/* ================= B. Célébration ================= */
.ob-cele {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  color: var(--tx);
  background:
    radial-gradient(90% 50% at 85% 0%, var(--glow-a), transparent 62%) top / 100% 380px no-repeat,
    linear-gradient(180deg, var(--glow-top) 0%, rgba(var(--bg-rgb), 0) 100%) top / 100% 380px no-repeat,
    var(--bg);
}

.oc-canvas { position: fixed; inset: 0; z-index: 2; width: 100%; height: 100%; pointer-events: none; }

.oc-wrap {
  flex: 1;
  display: grid;
  align-content: center;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 24px) 24px 16px;
  text-align: center;
}

.oc-mark { display: grid; place-items: center; width: 148px; height: 148px; margin: 0 auto 28px; color: var(--acc); }
.oc-logo { width: 100%; height: 100%; }
.oc-logo path { stroke-dasharray: 1; stroke-dashoffset: 1; opacity: 0; }
.is-play .oc-logo path { animation: ocDraw 0.62s var(--ease-out) calc(0.12s + var(--i) * 0.07s) forwards; }
@keyframes ocDraw { 0% { stroke-dashoffset: 1; opacity: 0; } 8% { opacity: 1; } 100% { stroke-dashoffset: 0; opacity: 1; } }
.is-play .oc-mark { animation: ocBeat 0.5s var(--ease-spring) 0.8s both; }
@keyframes ocBeat { from { transform: scale(0.94); } to { transform: none; } }

.oc-title { margin: 0 0 12px; font-size: 34px; line-height: 40px; font-weight: 800; letter-spacing: -0.025em; }
.oc-title.sm { margin-bottom: 16px; font-size: 26px; line-height: 32px; }
.oc-text { margin: 0 auto; max-width: 34ch; color: var(--tx2); font-size: 16px; line-height: 24px; }
.oc-text b { color: var(--tx); overflow-wrap: anywhere; }
.oc-note { margin: 12px auto 0; max-width: 34ch; color: var(--warn); font-size: 14px; line-height: 20px; font-weight: 600; }

.is-play .oc-title, .is-play .oc-text, .is-play .oc-note { opacity: 0; animation: ocUp 0.6s var(--ease-out) 0.55s forwards; }
.is-play .oc-text { animation-delay: 0.68s; }
.is-play .oc-note { animation-delay: 0.8s; }
@keyframes ocUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.oc-next { text-align: left; }
.oc-next[hidden] { display: none; }
.oc-next .oc-title.sm { text-align: center; }

.oc-foot {
  position: sticky;
  bottom: 0;
  z-index: 3;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 24px calc(env(safe-area-inset-bottom, 0px) + 20px);
}

.oc-cta {
  width: 100%;
  min-height: 56px;
  color: var(--on-acc);
  font: inherit;
  font-size: 17px;
  font-weight: 800;
  background: var(--acc);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.16s var(--ease-out);
}

.oc-cta:active { transform: scale(0.97); }
.is-play .oc-foot { opacity: 0; animation: ocUp 0.5s var(--ease-out) 1.1s forwards; }

/* ================= C. Checklist (.ob-card) ================= */
.ob-card {
  display: block;
  margin: 0 0 16px;
  padding: 18px 20px 20px;
  color: var(--tx);
  background: var(--s1);
  border: 1px solid var(--line2);
  border-radius: var(--r-card);
}

.ob-card[hidden] { display: none; }
.ob-card.is-bad { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.ob-card.is-ready { display: grid; place-items: center; min-height: 112px; }
.ob-card.is-ready .ob-main { display: none; }

.ob-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.ob-head strong { font-size: 18px; line-height: 24px; font-weight: 800; letter-spacing: -0.01em; }
.ob-count { flex: none; color: var(--mut); font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ob-body { margin: 8px 0 0; color: var(--tx2); font-size: 15px; line-height: 22px; }

.ob-bar { height: 6px; margin: 12px 0 16px; overflow: hidden; background: var(--line2); border-radius: 3px; }
.ob-bar i { display: block; height: 100%; background: var(--acc); border-radius: 3px; transform-origin: left; transition: transform 0.7s var(--ease-in-out) 0.25s; }

.ob-steps { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }

.ob-steps li {
  display: grid;
  grid-template-columns: 26px 1fr;
  column-gap: 12px;
  row-gap: 8px;
  align-items: start;
  color: var(--mut);
}

.ob-txt { display: grid; gap: 1px; min-width: 0; padding-top: 2px; font-size: 15px; line-height: 21px; }
.ob-txt b { font-weight: 700; }
.ob-txt small { color: var(--mut); font-size: 13px; line-height: 18px; font-weight: 600; }
.ob-steps li.is-current .ob-txt b, .ob-steps li.is-done .ob-txt b { color: var(--tx); }
.ob-steps li > :not(.ob-dot):not(.ob-txt) { grid-column: 2; justify-self: start; }

.ob-dot {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid var(--line2);
  border-radius: 50%;
  color: var(--on-acc);
  transition: background-color 0.3s var(--ease-in-out), border-color 0.3s var(--ease-in-out);
}

.ob-dot svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.ob-dot path { stroke-dasharray: 1; stroke-dashoffset: 1; }
.is-done .ob-dot { background: var(--acc); border-color: var(--acc); }
.is-done .ob-dot path { stroke-dashoffset: 0; }
.is-current .ob-dot { border-color: var(--acc); box-shadow: inset 0 0 0 5px var(--s1), inset 0 0 0 20px var(--acc); }

/* transition en « fait » : le rond se remplit en rebondissant, puis la coche se dessine */
.is-just .ob-dot { animation: obPop 0.5s var(--ease-spring) 0.15s both; }
.is-just .ob-dot path { animation: obDraw 0.4s var(--ease-out) 0.4s both; }
@keyframes obPop { 0% { transform: scale(0.7); background: transparent; } 100% { transform: scale(1); background: var(--acc); } }
@keyframes obDraw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }

.ob-btn {
  min-height: 44px;
  padding: 0 18px;
  color: var(--on-acc);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  background: var(--acc);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.16s var(--ease-out), opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.ob-btn:active { transform: scale(0.97); }
.ob-btn:disabled { color: var(--mut); background: var(--s2); cursor: default; }
.ob-btn.ghost { color: var(--tx); background: transparent; border: 1px solid var(--line2); }
.ob-foot { margin-top: 16px; }

.ob-ready { display: none; align-items: center; gap: 14px; }
.ob-card.is-ready .ob-ready { display: flex; flex-direction: column; text-align: center; }
.ob-ready strong { font-size: 20px; font-weight: 800; }
.ob-ready .ob-dot { width: 44px; height: 44px; background: var(--acc); border-color: var(--acc); }
.ob-ready .ob-dot svg { width: 32px; height: 32px; }
.ob-ready .ob-dot path { stroke-dashoffset: 0; animation: obDraw 0.45s var(--ease-out) 0.15s both; }

/* ================= Réduction des animations : fondus seulement ================= */
@media (prefers-reduced-motion: reduce) {
  .oi-l > span, .oi-sub, .oi-cta { transform: none !important; transition: opacity 0.2s ease-out !important; }
  .oi-l > span { opacity: 0; }
  .oi-slide.is-in .oi-l > span { opacity: 1; }
  .oi-slide.is-in .oi-card, .oi-slide.is-in .oi-cal { animation: oiFade2 0.2s ease-out both; }
  .oi-slide.is-in .oi-dc, .oi-slide.is-in .oi-seal, .oi-slide.is-in .oi-tdot { animation: none; transform: none; opacity: 1; }
  .oi-slide.is-in .oi-dk, .oi-slide.is-in .oi-seal-ck, .oi-slide.is-in .oi-ringc, .oi-slide.is-in .oi-track-fill { animation: none; stroke-dashoffset: 0; }
  .oi-slide.is-in .oi-dn { animation: none; opacity: 0; }
  .oi-slide.is-in .oi-amount, .oi-slide.is-in .oi-unit { animation: none; opacity: 1; }
  .oi-ring-p { transition: none; }
  .oc-logo path, .is-play .oc-logo path { animation: none; stroke-dashoffset: 0; opacity: 1; }
  .is-play .oc-mark { animation: none; }
  .is-play .oc-title, .is-play .oc-text, .is-play .oc-note, .is-play .oc-foot { animation: ocFade 0.2s ease-out 0.1s forwards; }
  .is-just .ob-dot, .is-just .ob-dot path, .ob-ready .ob-dot path { animation: none; stroke-dashoffset: 0; }
  .ob-bar i { transition: none; }
}

@keyframes oiFade2 { from { opacity: 0; } to { opacity: 1; } }
@keyframes ocFade { from { opacity: 0; } to { opacity: 1; } }
