/* Yoshuko "Bloom" loader — the one loading animation for /app/.
   Splash (cold load), .yl-bloom (inline block loader), and a restyle of Bootstrap's
   .spinner-border so the 50+ existing "Loading…" spots match without template churn.
   Classes only: the enforced CSP sets style-src-attr 'none', so nothing here may rely
   on a style="" attribute. */

.yl-bloom {
  --yl-size: 5.5rem;
  --yl-a: var(--color-primary, #7B5F5F);
  --yl-b: var(--color-accent, #D97706);
  position: relative;
  display: inline-block;
  width: var(--yl-size);
  height: var(--yl-size);
  animation: yl-turn 14s linear infinite;
}
.yl-bloom--sm { --yl-size: 2.5rem; }

/* Six petals that unfurl in a travelling wave. */
.yl-bloom > i {
  position: absolute;
  left: 50%;
  bottom: 50%;
  width: 24%;
  height: 40%;
  margin-left: -12%;
  border-radius: 50% 50% 50% 50% / 70% 70% 30% 30%;
  background: linear-gradient(to top, var(--yl-a), color-mix(in srgb, var(--yl-a) 35%, #fff));
  transform-origin: 50% 100%;
  transform: rotate(var(--yl-r)) scale(.3);
  opacity: .25;
  animation: yl-unfurl 2.4s cubic-bezier(.45, 0, .25, 1) infinite;
  animation-delay: var(--yl-d);
}
.yl-bloom > i:nth-child(1) { --yl-r:   0deg; --yl-d: 0s; }
.yl-bloom > i:nth-child(2) { --yl-r:  60deg; --yl-d: .2s; }
.yl-bloom > i:nth-child(3) { --yl-r: 120deg; --yl-d: .4s; }
.yl-bloom > i:nth-child(4) { --yl-r: 180deg; --yl-d: .6s; }
.yl-bloom > i:nth-child(5) { --yl-r: 240deg; --yl-d: .8s; }
.yl-bloom > i:nth-child(6) { --yl-r: 300deg; --yl-d: 1s; }
.yl-bloom > i:nth-child(even) {
  background: linear-gradient(to top, var(--yl-b), color-mix(in srgb, var(--yl-b) 40%, #fff));
}

/* A bright core that breathes, inside a thin orbit that sweeps round it. */
.yl-bloom > b {
  position: absolute;
  inset: 41%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, var(--yl-b) 70%);
  box-shadow: 0 0 .9em color-mix(in srgb, var(--yl-b) 60%, transparent);
  animation: yl-core 2.4s ease-in-out infinite;
}
.yl-bloom > u {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 55%, var(--yl-a) 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1px));
  opacity: .55;
  animation: yl-turn 2.4s linear infinite reverse;
}

@keyframes yl-unfurl {
  0%, 100% { transform: rotate(var(--yl-r)) scale(.3);  opacity: .25; }
  45%      { transform: rotate(var(--yl-r)) scale(1);   opacity: 1; }
}
@keyframes yl-core { 0%, 100% { transform: scale(.8); } 50% { transform: scale(1.15); } }
@keyframes yl-turn { to { transform: rotate(360deg); } }

/* ── Cold-load splash ─────────────────────────────────────────────────────── */
.yl-splash {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  background: var(--color-bg, #FBFAF9);
  /* Invisible for the first 200 ms so a warm, fast load never flashes it; then it
     fades in. The last animation is the no-JavaScript failsafe: if the dismiss script
     never runs, the splash still leaves by itself after 15 s rather than blocking the app. */
  opacity: 0;
  animation: yl-in .4s ease .2s forwards, yl-failsafe .01s linear 15s forwards;
  transition: opacity .35s ease, visibility .35s;
}
.yl-splash.is-done { opacity: 0 !important; visibility: hidden; animation: none; pointer-events: none; }
.yl-splash .yl-bloom { --yl-size: 7rem; }
.yl-splash-text {
  margin: 0;
  font-size: .95rem;
  letter-spacing: .04em;
  color: var(--color-primary, #7B5F5F);
}
/* An indeterminate shimmer line: reassures that work is moving without faking a percentage. */
.yl-splash-bar {
  width: 9rem;
  height: 3px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--color-surface-sunken, #EDE7E4);
}
.yl-splash-bar::before {
  content: "";
  display: block;
  width: 40%;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, transparent, var(--color-accent, #D97706), var(--color-primary, #7B5F5F), transparent);
  animation: yl-slide 1.6s ease-in-out infinite;
}
@keyframes yl-in { to { opacity: 1; } }
@keyframes yl-failsafe { to { opacity: 0; visibility: hidden; pointer-events: none; } }
@keyframes yl-slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
html[dir="rtl"] .yl-splash-bar::before { animation-direction: reverse; }

/* ── Block loader: bloom + caption, for areas that fill in after an API call ── */
.yl-loader { display: flex; align-items: center; justify-content: center; gap: .75rem; padding: 2rem 1rem; color: var(--color-primary, #7B5F5F); }

/* ── Every Bootstrap spinner becomes the Bloom orbit ──────────────────────── */
.spinner-border {
  border: 0;
  background: conic-gradient(from 0deg, transparent 0 30%, currentColor 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - var(--bs-spinner-border-width, .25em)), #000 calc(100% - var(--bs-spinner-border-width, .25em) + 1px));
          mask: radial-gradient(farthest-side, transparent calc(100% - var(--bs-spinner-border-width, .25em)), #000 calc(100% - var(--bs-spinner-border-width, .25em) + 1px));
  animation: yl-turn 1s cubic-bezier(.5, .15, .5, .85) infinite;
}
.spinner-border:not(.spinner-border-sm) {
  background: conic-gradient(from 0deg, transparent 0 20%, var(--color-accent, #D97706) 60%, var(--color-primary, #7B5F5F) 100%);
}

@media (prefers-reduced-motion: reduce) {
  .yl-bloom, .yl-bloom > u, .yl-splash-bar::before, .spinner-border { animation-duration: 6s; }
  .yl-bloom > i { animation: yl-calm 3s ease-in-out infinite; transform: rotate(var(--yl-r)) scale(.8); opacity: .8; }
  .yl-bloom > b { animation: none; }
  .yl-splash-bar::before { animation: none; width: 100%; opacity: .5; }
  .spinner-border { animation: yl-calm 1.6s ease-in-out infinite; }
}
@keyframes yl-calm { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
