/* Mandala Theatre — motion
   Three small things, all switched off for people who ask for reduced motion:
   1. the logo intro on the first page of a visit (the curtain),
   2. a soft crossfade between pages,
   3. things rising into place as they scroll into view.
   The classes on <html> (motion, intro, hero-hold) are set by the small script in the layout's <head>. */

/* 1. THE INTRO ------------------------------------------------------------------------------- */
.site-intro { display: none; }
html.intro .site-intro {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center;
  background: var(--ink, #170a0d); color: #fff;
  transition: transform .8s cubic-bezier(.75, 0, .2, 1);
  /* if the script that lifts it never runs, it still goes away on its own */
  animation: intro-failsafe 0s 4s forwards;
}
html.intro-out .site-intro { transform: translateY(-100%); pointer-events: none; }
@keyframes intro-failsafe { to { visibility: hidden; pointer-events: none; } }

.intro-inner { display: grid; justify-items: center; gap: 18px; transition: opacity .3s ease, transform .5s var(--ease); }
html.intro-out .intro-inner { opacity: 0; transform: translateY(-24px); }

.intro-mark { width: clamp(64px, 9vw, 88px); height: auto; overflow: visible; }
.intro-mark polygon { transform-box: fill-box; }
/* the crimson centre grows up from its base, then the two saffron wings rise beside it */
.intro-mark .im-centre { transform-origin: 50% 100%; animation: im-grow .7s cubic-bezier(.2, .7, .1, 1) both; }
.intro-mark .im-left   { animation: im-rise .65s .3s cubic-bezier(.2, .7, .1, 1) both; }
.intro-mark .im-right  { animation: im-rise .65s .42s cubic-bezier(.2, .7, .1, 1) both; }
@keyframes im-grow { from { transform: scaleY(0); opacity: 0; } 40% { opacity: 1; } }
@keyframes im-rise { from { transform: translateY(40%); opacity: 0; } }

.intro-name {
  font-size: clamp(1rem, .9rem + .4vw, 1.25rem); font-weight: 650;
  letter-spacing: .32em; text-transform: uppercase; padding-left: .32em; /* keeps the spaced word centred */
  animation: intro-name .8s .55s cubic-bezier(.2, .7, .1, 1) both;
}
@keyframes intro-name { from { opacity: 0; letter-spacing: .5em; padding-left: .5em; } }

/* a thin saffron line that fills while the page gets ready */
.intro-line { display: block; width: 72px; height: 2px; background: rgba(255, 255, 255, .14); overflow: hidden; }
.intro-line::after {
  content: ""; display: block; height: 100%; background: var(--saffron, #f5a400);
  transform-origin: 0 50%; animation: intro-line 1.1s .15s cubic-bezier(.6, 0, .2, 1) both;
}
@keyframes intro-line { from { transform: scaleX(0); } }

/* the hero words wait behind the curtain (or for the page's first frame), then rise as before */
html.hero-hold .hero .slide.is-active .slide-text > * { opacity: 0; transform: translateY(28px); transition: none; }

/* 2. BETWEEN PAGES -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: .28s; animation-timing-function: ease; }
}

/* 3. ON SCROLL ------------------------------------------------------------------------------ */
/* motion.js adds .rv only to things below the first screen, so nothing on screen ever blinks */
.rv { opacity: 0; transform: translateY(18px); }
.rv.is-in {
  opacity: 1; transform: none;
  transition: opacity .7s var(--ease) var(--rv-delay, 0ms), transform .9s var(--ease) var(--rv-delay, 0ms);
}

@media (prefers-reduced-motion: reduce) {
  html.intro .site-intro { display: none; }
  .rv { opacity: 1; transform: none; }
}
