/* =============================================================================
   PAGONI — LOADER
   The page builds behind this, so nobody watches it assemble. It is in the HTML
   and in a render-blocking stylesheet, so it is the first thing ever painted.

   The gesture is the site's one idea: a deck riffled open IS a peacock fanning
   its tail. Five slide cards fan from one pivot, close, fan again; the eye at the
   pivot breathes. When the page is ready (js/core/loader.js) the deck folds shut,
   lifts away and the eye closes; then the dark fades into the hero's own
   assembly.

   Exit motion is transform + opacity only: the page is still booting behind it,
   and a main-thread effect (a growing mask) stalled there.
   ============================================================================= */

.loader {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: var(--raw-void-950);
  overflow: hidden;
  transition: opacity 600ms cubic-bezier(0.33, 0, 0.2, 1) 440ms;
}

.loader__fan {
  position: relative;
  width: 3.25rem;
  height: 4.5rem;
}

/* One slide card. Its pivot sits below it, so rotating it swings it out like a
   tail feather; a hairline title and a short rule make it read as a slide. */
.loader__card {
  position: absolute;
  inset: 0;
  border-radius: 0.375rem;
  background: var(--card);
  box-shadow: 0 0.5rem 1.5rem rgb(0 0 0 / 0.35);
  transform-origin: 50% 135%;
  rotate: 0deg;
  animation: loader-riffle 2400ms cubic-bezier(0.65, 0, 0.35, 1) infinite;
  animation-delay: calc(var(--i) * 70ms);
}
.loader__card::before,
.loader__card::after {
  content: '';
  position: absolute;
  left: 18%;
  height: 0.1875rem;
  border-radius: 1px;
  background: var(--raw-ink-050);
  opacity: 0.55;
}
.loader__card::before { top: 22%; width: 52%; }
.loader__card::after  { top: 34%; width: 30%; opacity: 0.3; }

.loader__card:nth-child(1) { --i: 0; --a: -52deg; --card: var(--raw-royal-800); }
.loader__card:nth-child(2) { --i: 1; --a: -26deg; --card: var(--raw-teal-900); }
.loader__card:nth-child(3) { --i: 2; --a:   0deg; --card: var(--raw-jade-700); }
.loader__card:nth-child(4) { --i: 3; --a:  26deg; --card: var(--raw-mint-500); }
.loader__card:nth-child(5) { --i: 4; --a:  52deg; --card: var(--raw-chart-400); }

/* Closed, fanned and held, then closed again: a riffle, not a spin. */
@keyframes loader-riffle {
  0%, 10%   { rotate: 0deg; }
  42%, 68%  { rotate: var(--a); }
  100%      { rotate: 0deg; }
}

/* The eye of the feather, at the pivot. */
.loader__eye {
  position: absolute;
  left: 50%;
  top: 135%;
  width: 1.125rem;
  height: 1.125rem;
  margin: -0.5625rem 0 0 -0.5625rem;
  border-radius: 50%;
  background: radial-gradient(circle,
    var(--raw-chart-400) 0 22%,
    var(--raw-royal-800) 23% 48%,
    var(--raw-jade-700) 49% 72%,
    var(--raw-teal-900) 73%);
  animation: loader-eye 2400ms ease-in-out infinite;
}
@keyframes loader-eye {
  0%, 10%, 100% { scale: 0.8; }
  42%, 68%      { scale: 1.15; }
}

/* LEAVING: the deck folds shut onto the middle card, the closed deck lifts and
   fades, the eye closes, then the ground fades. Nothing grows past 1:1. */
.loader.is-leaving {
  opacity: 0;
  pointer-events: none;
}
.loader.is-leaving .loader__card {
  animation: none;
  rotate: 0deg;
  translate: 0 -0.75rem;
  opacity: 0;
  transition:
    rotate 320ms cubic-bezier(0.65, 0, 0.35, 1),
    translate 380ms cubic-bezier(0.33, 0, 0.2, 1) 280ms,
    opacity 300ms linear 320ms;
}
.loader.is-leaving .loader__eye {
  animation: none;
  scale: 0;
  transition: scale 360ms cubic-bezier(0.65, 0, 0.35, 1) 200ms;
}

@media (prefers-reduced-motion: reduce) {
  .loader { transition: opacity 300ms linear; }
  .loader__card { animation: none; rotate: var(--a); }
  .loader__eye { animation: none; }
  .loader.is-leaving .loader__card { transition: none; }
  .loader.is-leaving .loader__eye { transition: none; }
}
