/* =========================================================
   InviteUtsav — Curtain Opening (SHARED across every "letter" theme —
   AashirwadNama, AnandChitthi, GraceLetter, NoorNama, RajsiPatrika,
   SereneScroll, ShubhPatrika — see inc/template-letter-theme.php).
   All 7 source themes shipped a byte-identical copy of this file, so it
   is enqueued once here rather than duplicated per theme. The two things
   that vary per theme are pulled out as CSS custom properties, defined
   in that theme's own assets/css/templates/{slug}.css (loaded before
   this file):
     - --curtain-bg-url / --curtain-front-url: this theme's own 9:16
       front art + tiled backdrop (was a hardcoded url() per theme
       before this became shared)
     - --curtain-text and the .open-button colors, tied to this
       template's own --color-primary/--color-primary-dk tokens
       (defined in css/style.css, loaded before this file) so the
       curtain reads as part of this template's palette rather than a
       generic universal color.
   ========================================================= */

:root {
  --opening-duration: 2200ms;
  --ease-curtain: cubic-bezier(.72,.02,.19,1);
  --curtain-text: var(--color-primary);
}

/* ---------- SCROLL LOCK (while the curtain is up) ---------- */
body.curtain-lock {
  overflow: hidden;
}

/* ---------- CURTAIN GATE ---------- */
.curtain-gate {
  position: fixed;
  inset: 0;
  z-index: 99999;
  overflow: hidden;
  perspective: 1400px;
  opacity: 1;
  visibility: visible;
  transition: opacity 550ms ease, visibility 550ms ease;
  background-image: var(--curtain-bg-url);
  background-size: 500px;
  background-repeat: repeat;
}

.curtain-gate.is-finished {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.curtain-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.curtain-panel {
  position: absolute;
  top: 0;
  width: 50.2%;
  height: 100%;
  overflow: hidden;
  will-change: transform, filter;
  transition:
    transform var(--opening-duration) var(--ease-curtain),
    filter var(--opening-duration) ease;
  backface-visibility: hidden;
}

.curtain-left {
  left: 0;
  transform-origin: 0% 50%;
}

.curtain-right {
  right: 0;
  transform-origin: 100% 50%;
}

/*
  Both panels use the SAME full artwork; each half shows only its own
  side, so the full 9:16 artwork stays perfectly aligned when closed.
*/
.curtain-image {
  position: absolute;
  top: 0;
  width: 200%;
  height: 100%;
  background-image: var(--curtain-front-url);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center center;
  transform: translateZ(0);
}

.curtain-left .curtain-image {
  left: 0;
}

.curtain-right .curtain-image {
  right: 0;
}

/* Soft simulated fabric depth */
.fabric-shade {
  position: absolute;
  inset: 0;
  opacity: .16;
  pointer-events: none;
  mix-blend-mode: soft-light;
  transition: opacity 800ms ease;
}

.opening-content {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(0%, env(safe-area-inset-top))    28px    max(25%, env(safe-area-inset-bottom));
  text-align: center;
  pointer-events: none;
  justify-content: center;
}

.opening-copy {
  color: var(--curtain-text);
  text-shadow: 0 2px 18px rgba(255,255,255,.7);
  transition: opacity 420ms ease, transform 600ms ease;
  /* Was a flat 25% each side (50% of the frame gone to padding on every
     screen) — the single biggest cause of cramped/overlapping text on
     phones, since the same absolute squeeze applies however narrow the
     curtain gets. "25% minus a fixed px amount" (not "25% minus Nvw" —
     vw and % are the same unit against this full-width container, so a
     vw-based middle term never actually varies by screen size) shrinks
     the percentage sharply on narrow screens while barely denting it on
     laptop widths, where it still lands close to the original 25%. */
  padding: 0 clamp(8%, 25% - 40px, 25%);
  width: 100%;
  box-sizing: border-box;
}

.curtain-asset {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: clamp(14px, 3.2vw, 25px);
}

.curtain-asset img {
  width: clamp(86px, 11vw, 100px);
  height: auto;
}

.curtain-eyebrow {
  display: inline-block;
  margin-bottom: clamp(6px, 1.6vw, 10px);
  font-size: clamp(8.5px, 1.9vw, 11px);
  font-weight: 600;
  letter-spacing: .28em;
  text-transform: uppercase;
}

.opening-copy h1 {
  margin: 0;
  font-family: var(--font-script);
  font-size: clamp(28px, 8.2vw, 38px);
  line-height: 1.22;
  font-weight: normal;
  /* design-system.css's global h1,h2,h3,h4 rule declares color directly on
     the element (color:var(--plum-800)), which beats inheritance from the
     .opening-copy ancestor above (color:var(--curtain-text)) regardless of
     specificity, since nothing here was overriding color — the couple's
     curtain-gate names were silently rendering in the generic global plum
     ink instead of this template's own --curtain-text (--color-primary)
     brand color. */
  color: inherit;
  /* Same story for letter-spacing (-.01em globally); this template's
     script/display heading wants normal tracking. */
  letter-spacing: normal;
}

.curtain-ampersand {
  display: block;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-size: .42em;
  line-height: 1.4;
}

.curtain-message {
  margin: clamp(10px, 2.4vw, 15px) 0 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(12.5px, 2.9vw, 16px);
  line-height: 1.4;
  font-style: italic;
  padding: 0 clamp(0px, 10% - 30px, 10%);
}

.open-button {
  position: absolute;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  pointer-events: auto;
  appearance: none;
  border: 1px solid rgba(255,255,255,.78);
  min-width: 170px;
  min-height: 56px;
  padding: 0 28px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, var(--color-primary), var(--color-primary-dk));
  color: white;
  font-family: "Montserrat", "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 12px 35px rgba(0,0,0,.28),
    inset 0 1px 0 rgba(255,255,255,.28);
  transition:
    transform 250ms ease,
    box-shadow 250ms ease,
    opacity 350ms ease;
  overflow: visible;
}

.open-button:hover {
  transform: translateX(-50%) translateY(-2px) scale(1.02);
  box-shadow:
    0 16px 40px rgba(0,0,0,.34),
    inset 0 1px 0 rgba(255,255,255,.28);
}

.open-button:active {
  transform: translateX(-50%) translateY(0) scale(.98);
}

.open-button:disabled {
  cursor: default;
}

.open-button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 4px;
}

.button-ring {
  position: absolute;
  inset: -8px;
  border: 1px solid rgba(255,255,255,.55);
  border-radius: inherit;
  animation: curtainRingPulse 2.1s ease-out infinite;
}

@keyframes curtainRingPulse {
  0%   { transform: scale(.94); opacity: 0; }
  25%  { opacity: .65; }
  100% { transform: scale(1.13); opacity: 0; }
}

.opening-glow {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 50%;
  width: 12vw;
  min-width: 60px;
  height: 100%;
  transform: translateX(-50%) scaleX(.25);
  opacity: 0;
  background: radial-gradient(
    ellipse at center,
    rgba(255,255,255,.92) 0%,
    rgba(255,248,220,.45) 38%,
    rgba(255,255,255,0) 72%
  );
  filter: blur(12px);
  pointer-events: none;
  transition:
    transform 1350ms ease 150ms,
    opacity 800ms ease 80ms;
}

/* ---------- OPENING STATE ---------- */

.curtain-gate.is-opening .curtain-left {
  transform:
    translateX(-91%)
    scaleX(.74)
    rotateY(12deg)
    skewY(-.35deg);
  filter: brightness(.92);
}

.curtain-gate.is-opening .curtain-right {
  transform:
    translateX(91%)
    scaleX(.74)
    rotateY(-12deg)
    skewY(.35deg);
  filter: brightness(.92);
}

.curtain-gate.is-opening .fabric-shade {
  opacity: .28;
}

.curtain-gate.is-opening .opening-copy {
  opacity: 0;
  transform: translateY(-12px) scale(.98);
}

.curtain-gate.is-opening .open-button {
  opacity: 0;
  transform: translateX(-50%) translateY(12px) scale(.94);
  pointer-events: none;
}

.curtain-gate.is-opening .opening-glow {
  opacity: 1;
  transform: translateX(-50%) scaleX(7);
}

/* ---------- RESPONSIVE / DESKTOP ---------- */

/*
  On wide desktop/tablet, keep the curtain artwork in a centered 9:16
  viewport instead of stretching it across the whole screen.
*/
@media (min-aspect-ratio: 9/16) {
  .curtain-stage {
    left: 50%;
    width: min(100vw, 56.25vh);
    transform: translateX(-50%);
  }

  .opening-content {
    left: 50%;
    width: min(100vw, 56.25vh);
    transform: translateX(-50%);
  }

  .opening-glow {
    left: 50%;
  }
}

/* Tablet — the clamp()s above already ease the padding/sizing down from
   the laptop numbers; this just tightens the eyebrow's wide tracking a
   little so "TOGETHER WITH THEIR FAMILIES" sits comfortably inside the
   narrower column instead of wrapping awkwardly. */
@media (max-width: 900px) {
  .curtain-eyebrow {
    letter-spacing: .2em;
  }
}

@media (max-width: 520px) {
  .curtain-eyebrow {
    letter-spacing: .14em;
  }

  .curtain-message {
    font-size: 13px;
  }

  .open-button {
    min-width: 160px;
    min-height: 54px;
  }

  .opening-content {
    padding-left: 20%;
    padding-right: 20%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .curtain-panel,
  .fabric-shade,
  .opening-copy,
  .open-button,
  .opening-glow,
  .curtain-gate {
    transition-duration: .001ms !important;
  }
  .button-ring {
    animation: none !important;
  }
}
