/* ==========================================================================
   intro.css — "Royal Doors" opening overlay
   Hidden unless <html> has BOTH `js` and `intro-active` (set by an inline
   script in <head>), so no-JS visitors and returning visitors never see it.
   Only transform / opacity are animated.
   ========================================================================== */

#intro {
  --door-base: var(--color-maroon);
  --door-dark: #36101A;
  --m: min(86vh, 92vw);   /* diameter of the full mandala */

  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  overflow: hidden;
  perspective: 1600px;
  opacity: 1;
}

.intro-active #intro {
  display: block;
  cursor: pointer; /* a tap anywhere opens the doors */
}

#intro.is-opening {
  cursor: default;
}

/* Lock page scroll while the doors are closed */
.intro-active body {
  overflow: hidden;
}

/* ---------- Doors ---------- */
.intro__door {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  /* Gentler in-out curve than --ease-elegant so the swing stays visible for most of its 1.2s */
  transition: transform 1.2s cubic-bezier(0.45, 0.05, 0.25, 1) 0.35s;
}

.intro__door--left {
  left: 0;
  transform-origin: left center;
  background: linear-gradient(90deg, var(--door-base) 0%, #4A1723 70%, var(--door-dark) 100%);
}

.intro__door--right {
  right: 0;
  transform-origin: right center;
  background: linear-gradient(270deg, var(--door-base) 0%, #4A1723 70%, var(--door-dark) 100%);
}

/* Half mandala: full mandala centred on the seam, each door clips its half */
.intro__mandala {
  position: absolute;
  top: 50%;
  width: var(--m);
  height: var(--m);
  color: var(--color-gold);
  opacity: 0.5;
  transform: translate(-50%, -50%);
}

.intro__door--left .intro__mandala  { left: 100%; }
.intro__door--right .intro__mandala { left: 0; }

/* Double gold border, 12px and 20px from the edges */
.intro__frame {
  position: absolute;
  inset: 12px;
  border: 1px solid var(--color-gold);
  opacity: 0.85;
  pointer-events: none;
}

.intro__frame--inner {
  inset: 20px;
  opacity: 0.55;
}

/* Corner flourishes inside the inner border */
.intro__corner {
  position: absolute;
  width: 34px;
  height: 34px;
  color: var(--color-gold);
}

.intro__corner--tl { top: 24px; left: 24px; }
.intro__corner--tr { top: 24px; right: 24px; transform: scaleX(-1); }
.intro__corner--bl { bottom: 24px; left: 24px; transform: scaleY(-1); }
.intro__corner--br { bottom: 24px; right: 24px; transform: scale(-1, -1); }

/* Shadow that deepens as the door swings */
.intro__shade {
  position: absolute;
  inset: 0;
  background: #12040A;
  opacity: 0;
  transition: opacity 1.2s cubic-bezier(0.45, 0.05, 0.25, 1) 0.35s;
  pointer-events: none;
}

/* Thin gold seam */
.intro__seam {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  margin-left: -0.5px;
  background: linear-gradient(to bottom, transparent, var(--color-gold) 15%, var(--color-gold) 85%, transparent);
  opacity: 0.8;
  transition: opacity 0.3s var(--ease-elegant);
  pointer-events: none;
}

/* ---------- Centre column: names, seal, hint ---------- */
/* Soft maroon scrim keeps the mandala lines from running through the text */
.intro__center::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(680px, 100vw);
  height: min(430px, 68vh);
  transform: translate(-50%, -50%);
  background: radial-gradient(ellipse closest-side, rgba(54, 16, 26, 0.94) 0%, rgba(54, 16, 26, 0.94) 72%, rgba(54, 16, 26, 0) 100%);
  pointer-events: none;
}

.intro__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 3vh, 1.75rem);
  padding: 0 var(--space-sm);
  text-align: center;
  pointer-events: none;
}

.intro__names,
.intro__hint {
  margin: 0;
  color: var(--color-ivory);
  /* Hidden until the script font is ready (no fallback-font flash) */
  opacity: 0;
  transition: opacity 0.5s var(--ease-elegant);
}

.intro__names {
  --amp-color: var(--color-gold-light);
  font-family: var(--font-script);
  font-size: clamp(2rem, 5vw, 3.1rem);
  line-height: 1.1;
}

.intro__hint {
  text-wrap: balance; /* two even lines instead of an orphaned last word on narrow screens */
  font-family: var(--font-heading);
  font-size: var(--fs-md);
  font-style: italic;
  letter-spacing: 0.2em;
}

.intro-text-ready .intro__names {
  opacity: 1;
}

.intro-text-ready .intro__hint {
  opacity: 1;
  animation: introShimmer 3s ease-in-out infinite;
}

@keyframes introShimmer {
  0%, 100% { opacity: 0.72; }
  50%      { opacity: 1; }
}

/* ---------- Wax seal ---------- */
.intro__seal {
  cursor: inherit; /* buttons default to an arrow: follow the overlay (pointer, then default once opening) */
  position: relative;
  width: 120px;
  height: 120px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--color-ivory);
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

/* Breathing glow: a pseudo-element whose opacity/scale pulse (no box-shadow animation) */
.intro__seal::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  box-shadow: 0 0 34px 10px rgba(201, 164, 92, 0.55);
  opacity: 0.35;
  animation: sealGlow 2.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes sealGlow {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50%      { opacity: 0.95; transform: scale(1.07); }
}

.intro__seal-art,
.intro__seal-art svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45));
}

.intro__seal-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-script);
  font-size: 2.7rem; /* Pinyon Script has a small x-height and hairline strokes */
  line-height: 1;
  white-space: nowrap;
  color: #FFF8E6;
  /* Embossed look: light edge below, dark edge above */
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3), 0 1px 3px rgba(0, 0, 0, 0.75);
  opacity: 0;
  transition: opacity 0.5s var(--ease-elegant);
}

.intro-text-ready .intro__seal-text {
  opacity: 1;
}

.intro__seal-heart {
  font-family: var(--font-body);
  font-size: 0.5em;
  margin-inline: 0.45em;
}

.intro__seal:focus,
.intro__seal:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 8px;
  border-radius: 50%;
}

@media (max-width: 599.98px) {
  .intro__seal { width: 96px; height: 96px; }
  .intro__hint { letter-spacing: 0.12em; }
  .intro__seal-text { font-size: 2.2rem; }
  .intro__corner { width: 26px; height: 26px; }
}

/* ---------- Opening sequence (JS adds .is-opening, then .is-fading) ---------- */
#intro.is-opening .intro__door,
#intro.is-opening .intro__seal {
  will-change: transform, opacity;
}

#intro.is-opening .intro__door--left  { transform: rotateY(-105deg); }
#intro.is-opening .intro__door--right { transform: rotateY(105deg); }
#intro.is-opening .intro__shade { opacity: 0.7; }
#intro.is-opening .intro__seam { opacity: 0; }

/* 1. seal swells + glows, then fades/scales to 0 (0.4s) */
#intro.is-opening .intro__seal {
  animation: sealOpen 0.4s var(--ease-elegant) forwards;
  pointer-events: none;
}

#intro.is-opening .intro__seal::before {
  animation: none;
  opacity: 1;
}

@keyframes sealOpen {
  0%   { transform: scale(1);    opacity: 1; }
  40%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0);    opacity: 0; }
}

/* 2. text + scrim fade out */
.intro__center::before {
  transition: opacity 0.3s var(--ease-elegant);
}

#intro.is-opening .intro__center::before {
  opacity: 0;
}

#intro.is-opening .intro__names,
#intro.is-opening .intro__hint {
  opacity: 0;
  animation: none;
  transition: opacity 0.3s var(--ease-elegant);
}

/* 4. whole overlay fades out */
#intro.is-fading {
  opacity: 0;
  transition: opacity 0.4s var(--ease-elegant);
}

/* ---------- Reduced motion: no 3D, simple 300ms cross-fade ---------- */
@media (prefers-reduced-motion: reduce) {
  .intro__door,
  .intro__shade,
  .intro__seam {
    transition: none !important;
  }

  .intro__seal::before,
  .intro-text-ready .intro__hint {
    animation: none !important;
  }

  .intro-text-ready .intro__hint {
    opacity: 1;
  }

  #intro.is-opening .intro__door--left,
  #intro.is-opening .intro__door--right {
    transform: none;
  }

  #intro.is-opening .intro__seal {
    animation: none !important;
  }

  /* Beats the global reduced-motion `transition-duration: 0.01ms` rule (higher specificity) */
  #intro.is-opening {
    opacity: 0;
    transition: opacity 300ms linear !important;
  }
}

/* Text must paint above the protective scrim; the mandala must not shrink to a half-door width. */
.intro__names, .intro__hint { position: relative; z-index: 1; }
.intro__names { opacity: 1; }
.intro__mandala { max-width: none; }
