/* ==========================================================================
   Premium Indian wedding invitation — envelope + ivory card
   ========================================================================== */

.page-invitation .site-header.is-scrolled {
  background: rgba(250, 246, 239, 0.94);
}

.page-invitation .site-header:not(.is-scrolled) .brand,
.page-invitation .site-header:not(.is-scrolled) .nav-list a {
  color: var(--color-maroon);
}

.page-invitation .site-header:not(.is-scrolled) .nav-toggle-bar {
  background: var(--color-maroon);
}

.page-invitation .site-header:not(.is-scrolled) .nav-list a.nav-cta {
  border-color: var(--color-gold);
  color: var(--color-maroon);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.invite-theatre {
  position: relative;
  min-height: calc(100vh - var(--header-h));
  min-height: calc(100dvh - var(--header-h));
  margin-top: var(--header-h);
  padding: clamp(1.5rem, 4vw, 3rem) 1rem 4.5rem;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 60% at 50% 20%, rgba(201, 168, 76, 0.12), transparent 55%),
    linear-gradient(165deg, #f7f1e6 0%, #ebe1d0 45%, #e4d5c0 100%);
}

.invite-ambiance {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 80%, rgba(92, 10, 26, 0.06), transparent 35%),
    radial-gradient(circle at 85% 75%, rgba(13, 79, 60, 0.06), transparent 35%);
  opacity: 0.9;
}

.invite-stage {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  min-height: min(72vh, 640px);
  display: grid;
  place-items: center;
  perspective: 1600px;
  perspective-origin: 50% 45%;
}

.envelope-scene {
  position: relative;
  width: 100%;
  display: grid;
  place-items: center;
  gap: 1.25rem;
}

.envelope-prompt {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--color-muted);
  text-align: center;
  transition: opacity 0.4s ease;
}

/* Envelope --------------------------------------------------------------- */
.envelope {
  position: relative;
  width: min(100%, 420px);
  aspect-ratio: 1.45 / 1;
  transform-style: preserve-3d;
  filter: drop-shadow(0 28px 40px rgba(61, 6, 17, 0.22));
  overflow: hidden;
}

.envelope-shadow {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -8%;
  height: 18%;
  background: radial-gradient(ellipse at center, rgba(40, 20, 10, 0.35), transparent 70%);
  filter: blur(8px);
  z-index: 0;
  pointer-events: none;
}

.envelope-pocket {
  position: absolute;
  inset: 0;
  border-radius: 3px 3px 6px 6px;
  background:
    linear-gradient(160deg, #6e1528 0%, #4a0c18 55%, #3a0a14 100%);
  box-shadow: inset 0 0 0 1px rgba(201, 168, 76, 0.25);
  overflow: hidden;
  z-index: 1;
}

.envelope-lining {
  position: absolute;
  inset: 6% 6% 28%;
  background:
    radial-gradient(circle at 50% 20%, rgba(201, 168, 76, 0.15), transparent 55%),
    linear-gradient(180deg, #7a1f33, #5c0a1a);
  opacity: 0.85;
}

.envelope-body {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.envelope-front {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.35rem;
  border-radius: 3px 3px 6px 6px;
  background:
    linear-gradient(145deg, #8a2034 0%, #5c0a1a 42%, #3d0611 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 230, 180, 0.18),
    inset 0 -8px 24px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(201, 168, 76, 0.28);
  clip-path: polygon(0 38%, 50% 68%, 100% 38%, 100% 100%, 0 100%);
}

.envelope-motif {
  width: 72px;
  height: 72px;
  opacity: 0.35;
  margin-top: 18%;
}

.envelope-motif .motif-stroke {
  stroke: var(--color-gold-light);
  fill: none;
  stroke-width: 1.2;
}

.envelope-motif .motif-dot {
  fill: var(--color-gold-light);
}

.envelope-names {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 1.9rem);
  color: var(--color-champagne);
  line-height: 1;
}

.envelope-label {
  margin: 0;
  font-size: 0.62rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(232, 213, 163, 0.75);
}

.envelope-flap {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 58%;
  z-index: 4;
  transform-origin: center top;
  transform-style: preserve-3d;
  pointer-events: none;
}

.envelope-flap-face {
  width: 100%;
  height: 100%;
  background:
    linear-gradient(180deg, #9a2a40 0%, #6b1224 55%, #4e0c1a 100%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 230, 180, 0.16),
    0 8px 18px rgba(0, 0, 0, 0.18);
  backface-visibility: hidden;
}

.envelope-flap-face::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(201, 168, 76, 0.12), transparent 45%);
  clip-path: inherit;
}

/* Wax seal --------------------------------------------------------------- */
.envelope-seal {
  position: absolute;
  left: 50%;
  top: 46%;
  z-index: 20;
  width: 74px;
  height: 74px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
  background: transparent;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
}

.seal-ring,
.seal-inner {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.seal-ring {
  background:
    radial-gradient(circle at 35% 30%, #d4a85a, #a68632 45%, #7a5c18 100%);
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.28),
    inset 0 2px 3px rgba(255, 240, 200, 0.45),
    inset 0 -3px 6px rgba(60, 30, 0, 0.35);
}

.seal-inner {
  inset: 8px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 40% 35%, #c0392b, #7a121f 70%, #4a0a12 100%);
  box-shadow:
    inset 0 0 0 1px rgba(201, 168, 76, 0.45),
    inset 0 3px 6px rgba(255, 255, 255, 0.12);
}

.seal-initials {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--color-champagne);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.envelope-seal:hover .seal-ring,
.envelope-seal:focus-visible .seal-ring {
  filter: brightness(1.06);
}

.envelope-seal:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 4px;
}

/* Invitation card -------------------------------------------------------- */
.invite-card {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 22%;
  bottom: 12%;
  z-index: 2;
  height: auto;
  max-height: none;
  aspect-ratio: auto;
  transform-origin: center bottom;
  transform-style: preserve-3d;
  pointer-events: none;
  overflow: hidden;
  visibility: hidden;
}

.envelope.is-opening .invite-card,
.invite-theatre.is-opening .invite-card {
  visibility: visible;
}

.invite-card-inner {
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform-origin: center top;
}

.invite-card-face {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100%;
  padding: clamp(1.1rem, 3vw, 1.6rem) clamp(0.95rem, 3vw, 1.4rem);
  border-radius: 3px;
  overflow: hidden;
  color: var(--color-maroon-deep);
  background-color: #f7f0e4;
  background-image:
    linear-gradient(180deg, rgba(255, 252, 245, 0.65), rgba(240, 228, 208, 0.35)),
    repeating-linear-gradient(
      0deg,
      rgba(120, 90, 50, 0.018) 0 1px,
      transparent 1px 3px
    ),
    radial-gradient(ellipse at 30% 20%, rgba(201, 168, 76, 0.08), transparent 45%),
    radial-gradient(ellipse at 70% 80%, rgba(92, 10, 26, 0.04), transparent 40%);
  box-shadow:
    0 20px 50px rgba(40, 18, 12, 0.28),
    0 2px 0 rgba(255, 255, 255, 0.55) inset,
    0 0 0 1px rgba(166, 134, 50, 0.35);
}

.card-paisley {
  position: absolute;
  inset: 0;
  opacity: 0.07;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cpath fill='%23a68632' d='M40 8c10 4 18 16 14 28-3 10-12 16-20 14 8 2 12 10 8 18-8-6-14-18-10-30 3-8 10-14 18-16z'/%3E%3C/svg%3E");
  background-size: 72px 72px;
}

.card-border {
  position: absolute;
  inset: 10px;
  border: 1.5px solid rgba(166, 134, 50, 0.55);
  box-shadow:
    inset 0 0 0 1px rgba(232, 213, 163, 0.45),
    0 0 0 1px rgba(201, 168, 76, 0.2);
  pointer-events: none;
}

.card-border--inner {
  inset: 16px;
  border-width: 1px;
  border-color: rgba(166, 134, 50, 0.28);
  box-shadow: none;
  opacity: 0.9;
}

.card-corner {
  position: absolute;
  width: clamp(56px, 18%, 88px);
  height: clamp(56px, 18%, 88px);
  opacity: 0.8;
  z-index: 1;
  pointer-events: none;
}

.card-corner--tl { top: 14px; left: 14px; }
.card-corner--tr { top: 14px; right: 14px; transform: scaleX(-1); }
.card-corner--bl { bottom: 14px; left: 14px; transform: scaleY(-1); }
.card-corner--br { bottom: 14px; right: 14px; transform: scale(-1); }

.card-mandala {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(78%, 260px);
  transform: translate(-50%, -50%);
  opacity: 0.1;
  pointer-events: none;
}

.motif-stroke {
  fill: none;
  stroke: #a68632;
  stroke-width: 1.15;
}

.motif-leaf {
  fill: rgba(166, 134, 50, 0.35);
  stroke: #a68632;
  stroke-width: 0.7;
}

.motif-paisley {
  fill: rgba(92, 10, 26, 0.12);
  stroke: #a68632;
  stroke-width: 0.8;
}

.motif-dot {
  fill: #a68632;
}

.card-copy {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.65rem;
}

.card-line {
  margin: 0;
  max-width: 18rem;
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 2.4vw, 1.15rem);
  font-weight: 500;
  line-height: 1.45;
  color: #4a2a22;
}

.card-names {
  margin: 0.15rem 0;
  font-size: clamp(2.4rem, 8vw, 3.4rem);
  color: var(--color-maroon);
  line-height: 1.05;
}

.card-invite-text {
  font-style: italic;
  font-weight: 400;
  color: #5a3a30;
}

.card-date {
  margin-top: 0.25rem;
  font-family: var(--font-body);
  font-size: clamp(0.72rem, 1.8vw, 0.85rem);
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-maroon-deep);
}

.card-place {
  font-family: var(--font-body);
  font-size: clamp(0.78rem, 1.9vw, 0.92rem);
  letter-spacing: 0.08em;
  color: var(--color-emerald);
}

.card-divider {
  width: min(220px, 80%);
  line-height: 0;
}

.card-divider svg {
  width: 100%;
  height: auto;
}

.card-line,
.card-divider {
  opacity: 0;
  transform: translateY(10px);
}

/* After open ------------------------------------------------------------- */
.invite-after {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1.5rem;
  width: 100%;
  pointer-events: none;
}

/* Critical: CSS display:grid must not override the hidden attribute */
.invite-after[hidden] {
  display: none !important;
}

.invite-theatre.is-open .invite-after {
  pointer-events: auto;
}

.invite-card-dock {
  width: min(100%, 380px);
  min-height: 1px;
}

.invite-card.is-revealed {
  position: relative;
  left: auto;
  right: auto;
  top: auto;
  width: 100%;
  max-height: none;
  aspect-ratio: 0.72 / 1;
  pointer-events: auto;
  z-index: 5;
}

.invite-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  opacity: 0;
  pointer-events: none;
}

.invite-theatre.is-open .invite-actions {
  pointer-events: auto;
}

/* Audio control ---------------------------------------------------------- */
.invite-audio-bar {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 60;
}

.audio-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.5rem;
  padding: 0.45rem 0.95rem;
  border: 1px solid rgba(201, 168, 76, 0.55);
  background: rgba(250, 246, 239, 0.92);
  color: var(--color-maroon-deep);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(40, 18, 12, 0.12);
  touch-action: manipulation;
}

.audio-toggle[aria-pressed="true"] {
  background: rgba(92, 10, 26, 0.08);
}

/* Theatre states --------------------------------------------------------- */
.invite-theatre.is-opening .envelope-prompt {
  opacity: 0;
}

.invite-theatre.is-open .envelope-scene {
  pointer-events: none;
}

/* Mobile ----------------------------------------------------------------- */
@media (max-width: 640px) {
  .invite-theatre {
    padding-inline: 0.75rem;
    padding-bottom: 5rem;
  }

  .invite-stage {
    width: min(100%, 360px);
    min-height: 70vh;
  }

  .envelope {
    width: min(100%, 320px);
  }

  .envelope-seal {
    width: 68px;
    height: 68px;
  }

  .invite-card-dock {
    width: min(100%, 300px);
  }

  .card-line {
    max-width: 15rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .invite-card .card-line,
  .invite-card .card-divider {
    opacity: 1 !important;
    transform: none !important;
  }
}
