/* =====================================================================
   COURONNES PRIME — décorations et animations
   ===================================================================== */
:root { --crown: url(/img/crown-sm.png); }

/* ---------- ciel de couronnes qui montent doucement ---------- */
#crown-sky { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
#shell #crown-sky { z-index: -1; }
.login-container #crown-sky { position: absolute; }
#crown-sky i {
  position: absolute; bottom: -60px; display: block; aspect-ratio: 180 / 117;
  background: var(--crown) center / contain no-repeat;
  animation: c-rise linear infinite; will-change: transform;
}
@keyframes c-rise {
  0%   { transform: translate3d(0, 0, 0) rotate(-12deg); opacity: 0; }
  10%  { opacity: var(--o, .14); }
  50%  { transform: translate3d(var(--sway, 30px), -55vh, 0) rotate(10deg); }
  90%  { opacity: var(--o, .14); }
  100% { transform: translate3d(0, -115vh, 0) rotate(-8deg); opacity: 0; }
}

/* ---------- explosion de couronnes au clic ---------- */
.c-burst {
  position: fixed; z-index: 9999; width: 22px; aspect-ratio: 180 / 117; pointer-events: none;
  background: var(--crown) center / contain no-repeat; filter: drop-shadow(0 2px 6px rgba(255, 61, 154, .6));
  animation: c-burst .8s cubic-bezier(.2, .7, .3, 1) forwards;
}
@keyframes c-burst {
  0%   { transform: translate(-50%, -50%) scale(.3) rotate(0); opacity: 1; }
  70%  { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1) rotate(var(--rot)); opacity: 0; }
}

/* ---------- animations de base ---------- */
@keyframes c-bob { 0%, 100% { transform: translateY(0) rotate(-5deg); } 50% { transform: translateY(-4px) rotate(5deg); } }
@keyframes c-bounce { 0%, 100% { transform: translate(-50%, 0) rotate(-6deg); } 50% { transform: translate(-50%, -4px) rotate(6deg); } }
@keyframes c-wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-14deg); } 90% { transform: rotate(12deg); } 95% { transform: rotate(-6deg); } }
@keyframes c-spin-slow { from { transform: rotate(-8deg) scale(1); } 50% { transform: rotate(8deg) scale(1.06); } to { transform: rotate(-8deg) scale(1); } }
@keyframes c-pulse { 0%, 100% { opacity: .55; transform: scale(1); } 50% { opacity: 1; transform: scale(1.15); } }
@keyframes c-shine { 0%, 70% { left: -60%; } 100% { left: 130%; } }
@keyframes c-drop {
  0% { transform: translateY(-18px) rotate(-30deg) scale(.4); opacity: 0; }
  60% { transform: translateY(3px) rotate(10deg) scale(1.1); opacity: 1; }
  100% { transform: translateY(0) rotate(-6deg) scale(1); opacity: 1; }
}
@keyframes c-title { from { opacity: 0; transform: translateY(10px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes c-pop { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes c-glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 79, 163, 0); } 50% { box-shadow: 0 0 26px 2px rgba(255, 79, 163, .28); } }
@keyframes c-ring { 0% { transform: translate(-50%, -50%) scale(.6); opacity: .5; } 100% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; } }

/* ---------- logo du haut ---------- */
.brand img { animation: c-bob 3.6s ease-in-out infinite; }
.brand-t b { background-size: 200% 100%; animation: c-text 6s linear infinite; }
@keyframes c-text { 0% { background-position: 0 0; } 100% { background-position: 200% 0; } }
.brand-t b { background-image: linear-gradient(90deg, #ff6cb5 0%, #ffe3f1 25%, #ff6cb5 50%, #ffe3f1 75%, #ff6cb5 100%); }

/* ---------- onglet actif : petite couronne qui saute au-dessus ---------- */
#shell .nav > a, .ngroup > .ng-btn { position: relative; }
#shell .nav > a.on::after, .ngroup.on > .ng-btn::after {
  content: ""; position: absolute; left: 50%; top: -11px; width: 18px; aspect-ratio: 180 / 117;
  background: var(--crown) center / contain no-repeat; filter: drop-shadow(0 2px 6px rgba(255, 61, 154, .7));
  animation: c-bounce 1.8s ease-in-out infinite;
}

/* ---------- en-tête de page ---------- */
.page-head .eyebrow::before { background-image: var(--crown); animation: c-wiggle 4s ease-in-out infinite; transform-origin: 50% 80%; }
.page-head.anim h1 { animation: c-title .5s ease-out both; }
.page-head.anim .eyebrow { animation: c-title .5s .05s ease-out both; }
.page-head h1 { position: relative; }
.ph-txt { position: relative; }
.ph-txt::after {
  content: ""; position: absolute; right: -34px; top: 22px; width: 26px; aspect-ratio: 180 / 117;
  background: var(--crown) center / contain no-repeat; filter: drop-shadow(0 4px 10px rgba(255, 61, 154, .6));
  animation: c-bob 3s ease-in-out infinite;
}
.page-head.anim .ph-txt::after { animation: c-drop .7s .25s cubic-bezier(.3, 1.4, .5, 1) both, c-bob 3s 1s ease-in-out infinite; }

/* ---------- contenu qui apparaît en douceur ---------- */
#view.anim > * { animation: c-pop .45s ease-out both; }
#view.anim > *:nth-child(2) { animation-delay: .05s; }
#view.anim > *:nth-child(3) { animation-delay: .1s; }
#view.anim > *:nth-child(4) { animation-delay: .15s; }
#view.anim > *:nth-child(n+5) { animation-delay: .2s; }

/* ---------- chiffres clés ---------- */
.kpi { position: relative; transition: transform .2s, border-color .2s; }
.kpi::before {
  content: ""; position: absolute; right: -10px; bottom: -8px; width: 86px; aspect-ratio: 180 / 117; pointer-events: none;
  background: var(--crown) center / contain no-repeat; opacity: .07; transform: rotate(-14deg);
  transition: opacity .3s, transform .4s;
}
.kpi:hover { transform: translateY(-3px); border-color: var(--p-pline); }
.kpi:hover::before { opacity: .2; transform: rotate(4deg) scale(1.12); }
.kpi.hot::before { opacity: .18; animation: c-spin-slow 5s ease-in-out infinite; }

/* ---------- titres des cadres ---------- */
.panel-h h2 { display: inline-flex; align-items: center; gap: 9px; }
.panel-h h2::before {
  content: ""; width: 17px; flex: none; aspect-ratio: 180 / 117; background: var(--crown) center / contain no-repeat; opacity: .85;
}
.panel:hover .panel-h h2::before { animation: c-wiggle 1.2s ease-in-out; }
.panel, .announce { transition: border-color .2s; }
.panel:hover { border-color: rgba(255, 79, 163, .16); }

/* ---------- annonces ---------- */
.announce { position: relative; overflow: visible; }
.announce::after {
  content: ""; position: absolute; right: 18px; top: -14px; width: 34px; aspect-ratio: 180 / 117;
  background: var(--crown) center / contain no-repeat; filter: drop-shadow(0 4px 10px rgba(255, 61, 154, .6));
  transform-origin: 50% 100%; animation: c-wiggle 3.5s ease-in-out infinite;
}

/* ---------- boutons rose : reflet qui passe ---------- */
.bt.primary, .login-btn { position: relative; overflow: hidden; }
.bt.primary::after, .login-btn::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .38), transparent); transform: skewX(-20deg);
  animation: c-shine 4.5s ease-in-out infinite;
}

/* ---------- états vides / chargement ---------- */
.empty::before { background-image: var(--crown) !important; animation: c-bob 3s ease-in-out infinite; opacity: .3 !important; filter: none !important; }

/* ---------- calendrier : couronne sur aujourd'hui ---------- */
.cal .d.today, .pcal-big .pd.today { position: relative; overflow: visible; }
.cal .d.today::after, .pcal-big .pd.today::after {
  content: ""; position: absolute; left: 50%; top: -9px; width: 16px; aspect-ratio: 180 / 117; z-index: 2;
  background: var(--crown) center / contain no-repeat; animation: c-bounce 2s ease-in-out infinite;
}

/* ---------- fenêtres et messages ---------- */
.dlg.open .dlg-box { animation: c-pop .3s ease-out both; }
.dlg-h h2 { display: inline-flex; align-items: center; gap: 10px; }
.dlg-h h2::before { content: ""; width: 22px; aspect-ratio: 180 / 117; background: var(--crown) center / contain no-repeat; animation: c-wiggle 3s ease-in-out infinite; }
.toast { display: flex; align-items: center; gap: 10px; animation: c-pop .3s ease-out both; }
.toast::before { content: ""; width: 20px; flex: none; aspect-ratio: 180 / 117; background: var(--crown) center / contain no-repeat; }
.toast.bad::before { filter: grayscale(1) brightness(1.4); }

/* ---------- profil ---------- */
.me-chip .avatar { position: relative; overflow: visible; }
.me-chip .avatar::after {
  content: ""; position: absolute; left: 50%; top: -10px; width: 16px; aspect-ratio: 180 / 117;
  background: var(--crown) center / contain no-repeat; transform: translateX(-50%) rotate(-12deg);
}

/* ---------- pied de page ---------- */
.foot img { animation: c-bob 2.6s ease-in-out infinite; }
.foot img:last-child { animation-delay: -1.3s; }

/* ---------- page de connexion / candidature ---------- */
.login-wrap { position: relative; z-index: 1; }
.login-brand { position: relative; }
.login-brand::before {
  content: ""; position: absolute; left: 50%; top: 52px; width: 210px; height: 210px; border-radius: 50%; pointer-events: none;
  border: 2px solid rgba(255, 79, 163, .35); animation: c-ring 2.8s ease-out infinite;
}
.login-card { animation: c-pop .6s .1s ease-out both; }
.login-foot::before, .login-foot::after { background-image: var(--crown); animation: c-bob 2.6s ease-in-out infinite; }
.login-foot::after { animation-delay: -1.3s; }

/* ---------- appli : bandeau d'installation ---------- */
.instbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 60;
  display: flex; align-items: center; gap: 12px; max-width: 520px; margin: 0 auto; padding: 12px 14px; border-radius: 18px;
  background: rgba(22, 12, 19, .97); border: 1px solid var(--p-pline);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .6), 0 0 40px rgba(255, 79, 163, .15);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); animation: c-pop .4s ease-out both;
  font-family: var(--font);
}
@media (max-width: 760px) { body:has(#shell:not([hidden])) .instbar { bottom: calc(80px + env(safe-area-inset-bottom)); } }
.instbar img { width: 46px; height: 46px; border-radius: 12px; flex: none; }
.instbar .t { flex: 1; min-width: 0; font-size: 12px; color: var(--p-muted); line-height: 1.35; }
.instbar .t b { display: block; color: #fff; font-size: 14px; font-weight: 800; margin-bottom: 1px; }
.instbar .go {
  border: 0; border-radius: 11px; padding: 10px 14px; color: #fff; font: 800 13px var(--font); cursor: pointer;
  background: var(--p-btn); box-shadow: var(--p-glow); white-space: nowrap;
}
.instbar .x { border: 0; background: none; color: var(--p-muted); font-size: 22px; line-height: 1; padding: 4px; cursor: pointer; }

.ios-sheet { position: fixed; inset: 0; z-index: 9000; display: grid; place-items: end center; background: rgba(4, 2, 4, .7); backdrop-filter: blur(6px); font-family: var(--font); }
.ios-sheet .box {
  width: 100%; max-width: 440px; margin: 0 10px calc(10px + env(safe-area-inset-bottom)); padding: 24px 20px 18px; text-align: center;
  border-radius: 24px; background: rgba(22, 12, 19, .98); border: 1px solid var(--p-pline); animation: c-pop .3s ease-out both; color: var(--p-text);
}
.ios-sheet .box > img { width: 74px; border-radius: 18px; box-shadow: 0 10px 30px rgba(255, 61, 154, .35); }
.ios-sheet h2 { margin: 14px 0 4px; font-size: 20px; font-weight: 900; }
.ios-sheet .sub { color: var(--p-muted); font-size: 13px; }
.ios-steps { display: grid; gap: 10px; margin: 18px 0; text-align: left; }
.ios-steps > div { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: rgba(255, 255, 255, .04); border: 1px solid var(--p-line); font-size: 14px; }
.ios-steps span { width: 28px; height: 28px; border-radius: 9px; flex: none; display: grid; place-items: center; font-weight: 900; color: #fff; background: var(--p-btn); }
.ios-steps svg { width: 18px; height: 18px; vertical-align: -3px; stroke: #4aa3ff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ios-sheet .ok { width: 100%; border: 0; border-radius: 14px; padding: 14px; color: #fff; font: 800 15px var(--font); background: var(--p-btn); cursor: pointer; }

/* ---------- moins d'animations si l'appareil le demande ---------- */
@media (prefers-reduced-motion: reduce) {
  #crown-sky, .c-burst { display: none; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
