/* OKU · Creation prelude. Only the fresh entrance is affected. */
#okuCosmosPrelude {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  z-index: 2147483646;
  isolation: isolate;
  overflow: hidden;
  background: #000;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  opacity: 1;
}

html.oku-cosmos-pending #okuCosmosPrelude,
#okuCosmosPrelude.is-started {
  display: block;
}

/* The existing intro stays intact and ready underneath the new prelude. */
html.oku-cosmos-pending #screen-intro {
  opacity: 0 !important;
  pointer-events: none !important;
}

#okuCosmosPrelude .oku-cosmos-command,
#okuCosmosPrelude .oku-cosmos-frame {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
  backface-visibility: hidden;
}

#okuCosmosPrelude .oku-cosmos-command {
  z-index: 2;
  opacity: 1;
  /* Entry-01-20261025.png already contains the exact approved small-size
     multilingual composition and the lower 'Click to continue…' line. */
  transform: scale(1);
  transition:
    opacity 310ms cubic-bezier(.24,.64,.2,1),
    transform 400ms cubic-bezier(.18,.78,.2,1);
}

#okuCosmosPrelude.is-started .oku-cosmos-command {
  opacity: 0;
  transform: scale(.985);
}

#okuCosmosPrelude .oku-cosmos-film {
  position: absolute;
  inset: -2%;
  z-index: 1;
  pointer-events: none;
  transform: scale(1);
  transform-origin: 50% 52%;
  backface-visibility: hidden;
}

#okuCosmosPrelude.is-started .oku-cosmos-film {
  animation: oku-cosmic-camera var(--oku-cosmos-flight-duration, 3800ms) cubic-bezier(.13,.28,.68,1) both;
}

@keyframes oku-cosmic-camera {
  0%   { transform: scale(1) translate3d(0, 0, 0); }
  25%  { transform: scale(1.045) translate3d(-.12%, .10%, 0); }
  54%  { transform: scale(1.12) translate3d(-.16%, .13%, 0); }
  100% { transform: scale(1.19) translate3d(.19%, -.24%, 0); }
}

#okuCosmosPrelude .oku-cosmos-frame {
  z-index: 1;
  opacity: 0;
  transform: scale(1);
  mix-blend-mode: normal;
  filter: saturate(1.055);
  transition:
    opacity var(--oku-cosmos-dissolve, 420ms) cubic-bezier(.12,.48,.18,1),
    transform var(--oku-cosmos-dissolve, 420ms) cubic-bezier(.14,.71,.21,1);
  transform-origin: 50% 50%;
  will-change: opacity, transform;
}

#okuCosmosPrelude .oku-cosmos-flare {
  position: absolute;
  z-index: 3;
  inset: -22%;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%,
    rgba(255,247,224,.26) 0%,
    rgba(254,200,105,.12) 9%,
    rgba(126,166,255,.045) 23%,
    transparent 46%);
}

#okuCosmosPrelude.is-flashing .oku-cosmos-flare {
  animation: oku-cosmic-flare 400ms ease-out both;
}

@keyframes oku-cosmic-flare {
  0%   { opacity: 0; transform: scale(.38); }
  26%  { opacity: .73; transform: scale(.9); }
  100% { opacity: 0; transform: scale(1.85); }
}

/* The moment of creation punches through the early frames, then instantly
   releases the light instead of washing out the emerging galaxies. */
#okuCosmosPrelude.is-bursting.is-flashing .oku-cosmos-flare {
  animation: oku-cosmos-big-bang-flash 420ms ease-out both;
}

@keyframes oku-cosmos-big-bang-flash {
  0%   { opacity: 0; transform: scale(.14); filter: brightness(1); }
  17%  { opacity: 1; transform: scale(.53); filter: brightness(2.1); }
  46%  { opacity: .78; transform: scale(1.12); filter: brightness(1.25); }
  100% { opacity: 0; transform: scale(2.2); filter: brightness(1); }
}

#okuCosmosPrelude.is-finishing .oku-cosmos-frame.oku-cosmos-current {
  opacity: .19 !important;
  transition: opacity 1180ms cubic-bezier(.2,.62,.2,1);
}

#okuCosmosPrelude.is-revealing {
  opacity: 0;
  pointer-events: none;
  transition: opacity 1620ms cubic-bezier(.28,.13,.15,1);
}

/* Same Entry-09 photograph, crop, film bounds and captured camera transform
   on both sides of the crossfade. The central star never changes coordinates. */
#screen-intro .oku-cosmos-settled-backdrop {
  position: absolute;
  inset: 0;
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  background: rgba(0,0,0,.86);
  /* Prepared behind the still-opaque prelude while Entry-09 becomes dim. */
  transition: opacity 900ms cubic-bezier(.28,.13,.15,1);
}

#screen-intro .oku-cosmos-settled-backdrop::after {
  content: "";
  position: absolute;
  inset: -2%;
  background: url("assets/intro-cosmos/Entry-09.png") center / cover no-repeat;
  opacity: .19;
  filter: saturate(1.055);
  transform-origin: 50% 52%;
  transform: var(--oku-cosmos-handoff-transform, scale(1.13) translate3d(.25%, -.35%, 0));
  backface-visibility: hidden;
  will-change: transform;
}

html.oku-cosmos-complete #screen-intro .oku-cosmos-settled-backdrop {
  opacity: 1;
}

/* Only after the crossfade, a barely perceptible breathing zoom gives the
   static universe depth: original size -> +2.7% -> original, endlessly. */
html.oku-cosmos-breathing #screen-intro .oku-cosmos-settled-backdrop::after {
  animation: oku-cosmos-depth-breath 13.6s ease-in-out infinite;
}

@keyframes oku-cosmos-depth-breath {
  0%, 100% {
    transform: var(--oku-cosmos-handoff-transform, scale(1.13) translate3d(.25%, -.35%, 0)) scale(1);
  }
  50% {
    transform: var(--oku-cosmos-handoff-transform, scale(1.13) translate3d(.25%, -.35%, 0)) scale(1.027);
  }
}

html.oku-cosmos-breathing #screen-intro:not(.active) .oku-cosmos-settled-backdrop::after,
html.oku-cosmos-breathing #screen-intro[hidden] .oku-cosmos-settled-backdrop::after {
  animation-play-state: paused;
}

/* Every original object remains in its exact designed location. We reveal
   visibility only; no extra transform is applied to its layout or GIF sway. */
html.oku-cosmos-choreographing #screen-intro#screen-intro :is(
  .intro-calligraphy--allah,
  .intro-calligraphy--muhammad,
  .intro-oku-mark,
  .intro-bulbul-gif,
  .intro-flower,
  .intro-semazen-picture,
  .intro-quote-art.intro-verse-block,
  .intro-verse-block__meta,
  .intro-verse-block__arabic,
  .intro-verse-block__translation,
  .intro-language-option,
  .intro-footer-copyright
) {
  opacity: 0 !important;
  transition: opacity var(--oku-reveal-speed, 1100ms) cubic-bezier(.22,.64,.28,1) !important;
}

html.oku-cosmos-choreographing #screen-intro#screen-intro :is(
  .intro-calligraphy--allah,
  .intro-calligraphy--muhammad,
  .intro-oku-mark,
  .intro-bulbul-gif,
  .intro-flower,
  .intro-semazen-picture,
  .intro-quote-art.intro-verse-block,
  .intro-verse-block__meta,
  .intro-verse-block__arabic,
  .intro-verse-block__translation,
  .intro-language-option,
  .intro-footer-copyright
).oku-cosmos-shown {
  opacity: 1 !important;
}

html.oku-cosmos-choreographing #screen-intro#screen-intro :is(
  .intro-calligraphy--allah,
  .intro-calligraphy--muhammad,
  .intro-oku-mark,
  .intro-bulbul-gif,
  .intro-quote-art.intro-verse-block,
  .intro-verse-block__meta,
  .intro-verse-block__arabic,
  .intro-verse-block__translation,
  .intro-language-option,
  .intro-footer-copyright
) {
  filter: blur(5px) !important;
  transition: opacity var(--oku-reveal-speed, 1100ms) cubic-bezier(.22,.64,.28,1),
    filter var(--oku-reveal-speed, 1100ms) cubic-bezier(.22,.64,.28,1) !important;
}

html.oku-cosmos-choreographing #screen-intro#screen-intro :is(
  .intro-calligraphy--allah,
  .intro-calligraphy--muhammad,
  .intro-oku-mark,
  .intro-bulbul-gif,
  .intro-quote-art.intro-verse-block,
  .intro-verse-block__meta,
  .intro-verse-block__arabic,
  .intro-verse-block__translation,
  .intro-language-option,
  .intro-footer-copyright
).oku-cosmos-shown {
  filter: none !important;
}

/* The legacy cinematic controller can finish behind the prelude. It must not
   fade out the containers of objects being revealed one at a time. */
html.oku-cosmos-choreographing #screen-intro#screen-intro .intro-animated-hero,
html.oku-cosmos-choreographing #screen-intro#screen-intro .intro-language-grid {
  opacity: 1 !important;
  filter: none !important;
}

html.oku-cosmos-choreographing #screen-intro#screen-intro .intro-language-grid {
  transform: translateX(-50%) translateY(0) !important;
}

html.oku-cosmos-choreographing #screen-intro#screen-intro :is(
  .intro-language-option,
  .intro-footer-copyright
):not(.oku-cosmos-shown) {
  pointer-events: none !important;
}

html.oku-cosmos-choreographing #rosePetalLayer {
  opacity: 0 !important;
  transition: opacity 1250ms ease-in-out !important;
}

html.oku-cosmos-choreographing #rosePetalLayer.oku-cosmos-shown {
  opacity: 1 !important;
}

@media (prefers-reduced-motion: reduce) {
  #okuCosmosPrelude .oku-cosmos-command,
  #okuCosmosPrelude .oku-cosmos-frame {
    transition-duration: 85ms;
    transform: scale(1) !important;
  }
  #okuCosmosPrelude.is-flashing .oku-cosmos-flare,
  #okuCosmosPrelude.is-bursting.is-flashing .oku-cosmos-flare { animation: none; }
  #okuCosmosPrelude.is-started .oku-cosmos-film { animation: none; }
  #okuCosmosPrelude.is-revealing { transition-duration: 400ms; }
  #screen-intro .oku-cosmos-settled-backdrop { transition-duration: 400ms; }
  html.oku-cosmos-breathing #screen-intro .oku-cosmos-settled-backdrop::after { animation: none; }
  html.oku-cosmos-choreographing #screen-intro#screen-intro :is(
    .intro-calligraphy, .intro-oku-mark, .intro-bulbul-gif, .intro-flower,
    .intro-semazen-picture, .intro-verse-block, .intro-verse-block__meta,
    .intro-verse-block__arabic, .intro-verse-block__translation,
    .intro-language-option, .intro-footer-copyright
  ) { transition-duration: 125ms !important; }
}
