/* Google Fonts - Playfair Display, Montserrat, Kavivanar, Mukta Malar */
@import url('https://fonts.googleapis.com/css2?family=Kavivanar&family=Montserrat:wght@300;400;500;600&family=Mukta+Malar:wght@300;400;500;600;700;800&family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400;1,600&display=swap');

:root {
  --bg-color: #fffded;
  --gold-primary: #d4af37;
  --gold-secondary: #aa7c11;
  --gold-light: #f3e5ab;
  --text-dark: #3a3224;
  --shadow-color: rgba(58, 50, 36, 0.15);
  --burgundy: #7a0913;
  --burgundy-light: #5c0d24;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  font-family: 'Montserrat', sans-serif;
  color: var(--text-dark);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

/* --- Preloader --- */
#preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-color);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

.loader-logo {
  font-family: 'Playfair Display', serif;
  font-size: 2.2rem;
  color: var(--gold-secondary);
  margin-bottom: 20px;
  letter-spacing: 4px;
  animation: pulseLogo 2s infinite ease-in-out;
  text-align: center;
  font-weight: 600;
}

.loader-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(212, 175, 55, 0.1);
  border-radius: 50%;
  border-top-color: var(--gold-primary);
  animation: spin 1.2s infinite linear;
}

.loader-status {
  margin-top: 15px;
  font-size: 0.85rem;
  color: var(--gold-secondary);
  letter-spacing: 1px;
}

/* --- Music Button and Volume Wrapper --- */
.music-control-wrap {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: rgba(255, 253, 237, 0.9);
  border: 1.5px solid var(--gold-primary);
  border-radius: 22px;
  padding: 2px 12px 2px 2px;
  box-shadow: 0 4px 12px var(--shadow-color);
  transition: all 0.3s ease;
  max-width: 160px;
  overflow: hidden;
}

.music-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: transparent;
  border: none;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: transform 0.3s ease, background-color 0.3s ease;
  outline: none;
  flex-shrink: 0;
}

.music-btn:hover,
.music-btn:focus {
  transform: scale(1.05);
}

.music-icon {
  width: 18px;
  height: 18px;
  fill: var(--gold-secondary);
  transition: fill 0.3s ease;
}

.music-btn.playing .music-icon {
  animation: pulseMusic 1.5s infinite linear;
}

.volume-slider-container {
  display: flex;
  align-items: center;
  opacity: 1;
  transition: opacity 0.3s ease;
  width: 80px;
}

#volume-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: var(--gold-primary);
  border-radius: 2px;
  outline: none;
}

#volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--burgundy);
  cursor: pointer;
  border: 1px solid var(--gold-primary);
  transition: transform 0.1s;
}

#volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* --- Cover and Doors --- */
#cover {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  display: flex;
  overflow: hidden;
  perspective: 1500px;
  background-image: url('images/B.png');
  background-size: cover;
  background-position: center;
  background-color: var(--bg-color);
  transition: opacity 1.2s ease, visibility 1.2s ease;
}

/* --- Lamps --- */
.lamp-container {
  position: absolute;
  top: 0;
  width: 175px;
  height: 360px;
  z-index: 25;
  pointer-events: none;
  display: flex;
  justify-content: center;
  transform-origin: top center;
  transform: translateY(-110%);
  will-change: transform;
}

.lamp-left {
  left: 8%;
}

.lamp-right {
  right: 8%;
}

.lamp-img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* Activated States when Loaded */
body.loaded .lamp-container {
  animation: dropDown 2.2s cubic-bezier(0.19, 1, 0.22, 1) forwards, swing 4s ease-in-out infinite alternate 2.2s;
}

/* Cover Content Container */
.cover-content {
  position: absolute;
  top: 84%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90%;
  max-width: 500px;
  pointer-events: none;
  transition: opacity 1.2s ease, transform 1.2s ease;
  will-change: transform, opacity;
}

@media (min-width: 769px) {
  .cover-content {
    top: 92%;
  }
}

.wedding-title {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-weight: 600;
  font-size: 2.8rem;
  color: #b59437;
  /* Clean gold/bronze matching reference image */
  margin-bottom: 25px;
  text-align: center;
  line-height: 1.2;
  width: 100%;
}

.wedding-title .weds {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 1.8rem;
  display: inline;
  margin: 0 10px;
  color: #b59437;
  font-weight: 400;
}

/* Open Button */
#open-btn {
  pointer-events: auto;
  /* enable clicks since parent has pointer-events: none */
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-secondary) 0%, var(--gold-primary) 50%, var(--gold-light) 100%);
  border: 3px solid var(--bg-color);
  color: var(--text-dark);
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 1px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(170, 124, 17, 0.4);
  transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  animation: pulseButton 2s infinite;
  user-select: none;
}

#open-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 30px rgba(170, 124, 17, 0.6);
}

/* Opened States */
#cover.opened {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 1.2s ease, visibility 0s linear 1.2s;
}

#cover.opened .lamp-container {
  /* Let lamps slide up or stay. We will slide them up out of view on open for a cleaner interior card display. */
  transform: translateY(-110%) !important;
  opacity: 0;
  transition: transform 1.2s ease, opacity 0.8s ease;
  animation: none !important;
}

#cover.opened .cover-content {
  transform: translate(-50%, -50%) scale(0.8);
  opacity: 0;
  pointer-events: none;
}

/* --- Inner Page (Normal Page) --- */
#inner-page {
  display: none;
  width: 100%;
  height: 100%;
  background-color: var(--bg-color);
  overflow: hidden;
  /* Lock overflow to make swipes clean */
  position: relative;
  z-index: 5;
}

body.content-active #inner-page {
  display: block;
}

/* Intro Overlay Slide Layer */
.intro-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 15;
  background-color: var(--bg-color);
  transition: transform 1.1s cubic-bezier(0.77, 0, 0.175, 1), opacity 0.8s ease;
  will-change: transform, opacity;
  cursor: pointer;
  padding: 20px 15px;
}

.intro-layer.slide-down {
  transform: translateY(110%);
  opacity: 0;
  pointer-events: none;
}

/* Slider Container */
.slider-container {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transform: scale(0.97);
  transition: opacity 1.2s cubic-bezier(0.215, 0.61, 0.355, 1) 0.5s, transform 1.2s cubic-bezier(0.215, 0.61, 0.355, 1) 0.5s;
}

body.content-active .slider-container {
  opacity: 1;
  transform: scale(1);
}

.slides-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
}

.slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px 15px 50px 15px;
  /* bottom padding for indicator dots space */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease-in-out;
  will-change: opacity;
  user-select: none;
}

.slide.active {
  opacity: 1;
  pointer-events: auto;
}

.card-container {
  width: calc(min(90vw, 84vh));
  height: calc(min(90vw, 84vh));
  aspect-ratio: 1 / 1;
  position: relative;
  box-shadow: none !important;
  border-radius: 8px;
  overflow: visible;
  display: flex;
  justify-content: center;
  align-items: center;
  container-type: inline-size;
  /* Enables container-query units (cqw) for all text and elements inside */
  background-color: transparent !important;
  background: transparent !important;
  border: none !important;
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 8px;
  pointer-events: none;
  /* Prevents image dragging from breaking swipe gestures */
}

/* Slide Indicator Dots */
.slider-nav {
  position: absolute;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  z-index: 100;
}

.nav-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: rgba(212, 175, 55, 0.3);
  border: 1px solid rgba(212, 175, 55, 0.1);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.nav-dot.active {
  background-color: var(--gold-primary);
  transform: scale(1.3);
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.5);
}

body.content-active {
  overflow: hidden;
  /* Keep page fixed, only slide container moves */
}

/* --- Keyframe Animations --- */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

@keyframes pulseLogo {

  0%,
  100% {
    opacity: 0.6;
    transform: scale(0.98);
  }

  50% {
    opacity: 1;
    transform: scale(1.02);
  }
}

@keyframes pulseButton {
  0% {
    box-shadow: 0 0 0 0 rgba(170, 124, 17, 0.5);
  }

  70% {
    box-shadow: 0 0 0 18px rgba(170, 124, 17, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(170, 124, 17, 0);
  }
}

@keyframes dropDown {
  0% {
    transform: translateY(-110%);
  }

  60% {
    transform: translateY(5px);
  }

  80% {
    transform: translateY(-3px);
  }

  100% {
    transform: translateY(0);
  }
}

@keyframes swing {
  0% {
    transform: rotate(-3.5deg);
  }

  100% {
    transform: rotate(3.5deg);
  }
}

@keyframes pulseMusic {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.1);
  }
}

/* --- Responsive Adjustments --- */
@media (max-width: 480px) {
  .lamp-container {
    width: 120px;
    height: 250px;
  }

  .lamp-left {
    left: 4%;
  }

  .lamp-right {
    right: 4%;
  }

  .wedding-title {
    font-size: 1.8rem;
    margin-bottom: 15px;
  }

  .wedding-title .weds {
    font-size: 1.2rem;
    margin: 0 6px;
  }

  #open-btn {
    width: 80px;
    height: 80px;
    font-size: 1rem;
  }

  .card-container {
    width: calc(min(92vw, 86vh));
    height: calc(min(92vw, 86vh));
  }

  .card-img {
    height: 100%;
  }
}

/* --- Tamil Invitation Card (Responsive Text) --- */
.tamil-card-container {
  background-color: transparent !important;
  background: transparent !important;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: stretch;
  position: relative;
  border: none !important;
}

/* Pillar Frames */
.card-pillar {
  display: none;
  position: fixed !important;
  top: calc((100vh - min(90vw, 84vh)) / 2);
  bottom: calc((100vh - min(90vw, 84vh)) / 2);
  width: 12%;
  /* Reduced from 15.5% to give more room for text */
  z-index: 2147483647 !important;
  pointer-events: none;
}

body.content-active.intro-slid-down .card-pillar {
  display: block;
}

.card-pillar-left {
  left: 0;
  background-image: url('images/L.png');
  background-position: left center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.card-pillar-right {
  right: 0;
  background-image: url('images/R.png');
  background-position: right center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

/* Content Area */
.invite-card-content {
  width: 100%;
  height: 100%;
  padding: 3.2cqw 12.5cqw 2.2cqw 12.5cqw;
  /* Reduced top/bottom and side paddings to maximize space */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
  font-family: 'Mukta Malar', sans-serif;
  color: #a17b20;
  /* Gold/Bronze color for standard text */
  box-sizing: border-box;
  z-index: 1;
  background-color: transparent !important;
  background: transparent !important;
}

/* Top Symbol Group */
.symbol-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
}

.symbol-u {
  font-family: 'Mukta Malar', sans-serif;
  font-weight: 700;
  font-size: 2.1cqw;
  /* Scaled up from 1.8cqw */
  color: #a17b20;
}

.symbol-sivam {
  font-family: 'Mukta Malar', sans-serif;
  font-weight: 500;
  font-size: 1.5cqw;
  /* Scaled up from 1.3cqw */
  letter-spacing: 0.05cqw;
  color: #a17b20;
}

/* Primary Title */
.card-title-main {
  font-family: 'Kavivanar', cursive;
  font-size: 4.8cqw;
  /* Scaled up from 4cqw */
  color: #a17b20;
  margin: 0.5cqw 0 0.2cqw 0;
  /* Tightened margin */
  font-weight: 700;
  letter-spacing: 0.01cqw;
  text-shadow: 0.5px 0.5px 0px rgba(161, 123, 32, 0.1);
}

/* Greetings Header Container */
.card-greeting-container {
  align-self: flex-start;
  text-align: left;
  margin-left: 0.5cqw;
  margin-bottom: 0.2cqw;
}

.card-greeting {
  font-family: 'Mukta Malar', sans-serif;
  font-weight: 700;
  font-size: 2.3cqw;
  /* Scaled up from 1.9cqw */
  color: #a17b20;
}

.guest-name-tamil-container {
  margin-top: 0.2cqw;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.guest-name-tamil-title {
  font-family: 'Kavivanar', cursive;
  font-size: 2.8cqw;
  font-weight: 700;
  font-style: italic;
  color: #7a0913;
  /* Maroon */
  text-shadow: 0.5px 0.5px 0px rgba(122, 9, 19, 0.05);
}

.guest-name-tamil-suffix {
  font-family: 'Mukta Malar', sans-serif;
  font-size: 1.7cqw;
  color: #a17b20;
  margin-top: 0.1cqw;
}

/* timing and details */
.card-intro-text {
  font-family: 'Mukta Malar', sans-serif;
  font-weight: 500;
  font-size: 1.9cqw;
  /* Scaled up from 1.65cqw */
  line-height: 1.45;
  /* Tightened from 1.6 */
  color: #a17b20;
  margin-bottom: 0.8cqw;
  /* Tightened margin */
}

.highlight-date {
  font-weight: 800;
  color: #8c6a23;
}

/* Parents columns */
.card-parents-section {
  display: flex;
  justify-content: space-between;
  width: 100%;
  gap: 1.5cqw;
  margin-bottom: 0.8cqw;
  /* Tightened margin */
}

/* Tamil Column Layout (Grouping Parents & Couple) */
.parents-couple-col {
  width: 48%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.parents-couple-col .parents-col {
  width: 100%;
}

.parents-couple-col .couple-name-container {
  width: 100%;
  margin-top: 0.4cqw;
}

.parents-col {
  width: 48%;
  font-family: 'Mukta Malar', sans-serif;
  font-size: 1.7cqw;
  /* Scaled up from 1.5cqw */
  line-height: 1.4;
  /* Tightened from 1.5 */
  color: #a17b20;
}

.parent-name {
  font-weight: 800;
  color: #8c6a23;
}

.relationship {
  font-weight: 500;
  font-style: italic;
  font-size: 1.5cqw;
  /* Scaled up from 1.3cqw */
  display: block;
  margin-top: 0.1cqw;
}

.title-prefix {
  font-weight: 600;
  font-size: 1.6cqw;
  /* Scaled up from 1.4cqw */
  display: block;
  margin-top: 0.1cqw;
}

/* Groom and Bride Name Layout */
.card-couple-section {
  display: flex;
  justify-content: space-around;
  align-items: center;
  width: 100%;
  margin: 0.4cqw 0 0.8cqw 0;
  /* Tightened margins */
}

.couple-name-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 45%;
}

.couple-name {
  font-family: 'Kavivanar', cursive;
  font-size: 6.8cqw;
  /* Scaled up from 5.6cqw to fill space and prevent layout breaks */
  color: #7a0913;
  /* Deep traditional maroon */
  margin: 0;
  font-weight: 700;
  font-style: italic;
  line-height: 1.1;
  text-shadow: 1px 1px 0px rgba(122, 9, 19, 0.05);
}

.couple-suffix {
  font-family: 'Mukta Malar', sans-serif;
  font-size: 1.6cqw;
  /* Scaled up from 1.4cqw */
  font-weight: 500;
  color: #a17b20;
  margin-top: 0.15cqw;
}

/* Invitation details bottom */
.card-details-text {
  font-family: 'Mukta Malar', sans-serif;
  font-weight: 500;
  font-size: 1.9cqw;
  /* Scaled up from 1.65cqw */
  line-height: 1.45;
  /* Tightened from 1.6 */
  color: #a17b20;
  margin-bottom: 0.8cqw;
  /* Tightened margin */
}

.highlight-venue {
  font-weight: 800;
  color: #8c6a23;
}

/* Footer Group */
.card-footer-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.3;
  /* Removed margin-top: auto to let flexbox space-between distribute layout vertical spacing evenly on desktop */
}

.footer-msg {
  font-family: 'Mukta Malar', sans-serif;
  font-size: 1.7cqw;
  /* Scaled up from 1.5cqw */
  font-weight: 500;
  color: #a17b20;
}

.footer-names {
  font-family: 'Mukta Malar', sans-serif;
  font-size: 2.1cqw;
  /* Scaled up from 1.8cqw */
  font-weight: 800;
  color: #8c6a23;
  margin: 0.1cqw 0;
}

.footer-family {
  font-family: 'Mukta Malar', sans-serif;
  font-size: 1.9cqw;
  /* Scaled up from 1.6cqw */
  font-weight: 700;
  color: #a17b20;
}


/* --- English Invitation Card Styling --- */
.english-card-container {
  background-color: transparent !important;
  background: transparent !important;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: stretch;
  position: relative;
  border: none !important;
}

.english-card-content {
  width: 100%;
  height: 100%;
  padding: 3.2cqw 12.5cqw 2.2cqw 12.5cqw;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
  font-family: 'Montserrat', sans-serif;
  color: #a17b20;
  box-sizing: border-box;
  z-index: 1;
}

.english-sivam {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-weight: 600;
  font-size: 1.8cqw;
  /* Scaled up from 1.6cqw */
  letter-spacing: 0.1cqw;
  color: #a17b20;
  margin-top: 0.2cqw;
}

.english-title-main {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 4.8cqw;
  /* Scaled up from 4cqw */
  color: #a17b20;
  margin: 0.5cqw 0 0.2cqw 0;
  font-weight: 700;
  text-shadow: 0.5px 0.5px 0px rgba(161, 123, 32, 0.1);
}

.english-invite-text {
  font-family: 'Montserrat', sans-serif;
  margin: 0.3cqw 0;
}

.english-invite-text .invite-head {
  font-weight: 600;
  font-size: 2.0cqw;
  /* Scaled up from 1.7cqw */
  color: #a17b20;
}

.english-invite-text .invite-sub {
  font-weight: 400;
  font-size: 1.6cqw;
  /* Scaled up from 1.4cqw */
  font-style: italic;
  color: #a17b20;
  margin-top: 0.1cqw;
}

.guest-name-section {
  width: 100%;
  margin: 0.6cqw 0;
  text-align: center;
}

.guest-name-title {
  font-family: 'Playfair Display', serif;
  font-size: 3.8cqw;
  font-weight: 700;
  font-style: italic;
  color: #7a0913;
  text-shadow: 0.5px 0.5px 0px rgba(122, 9, 19, 0.05);
}

.invite-divider-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin: 0.2cqw 0;
}

.invite-dots {
  font-size: 1.3cqw;
  /* Scaled up from 1.1cqw */
  letter-spacing: 0.05cqw;
  color: rgba(212, 175, 55, 0.5);
  line-height: 1;
}

.invite-purpose {
  font-size: 1.5cqw;
  /* Scaled up from 1.3cqw */
  font-style: italic;
  color: #a17b20;
  margin-top: 0.1cqw;
}

.english-couple-section {
  display: flex;
  justify-content: space-around;
  align-items: center;
  width: 100%;
  margin: 0.4cqw 0 0.8cqw 0;
}

.english-couple-name {
  font-family: 'Playfair Display', serif;
  font-size: 6.8cqw;
  /* Scaled up from 5.6cqw */
  color: #7a0913;
  /* Deep traditional maroon */
  margin: 0;
  font-weight: 700;
  font-style: italic;
  line-height: 1.1;
  text-shadow: 1px 1px 0px rgba(122, 9, 19, 0.05);
}

.couple-ampersand {
  font-family: 'Playfair Display', serif;
  font-size: 6.2cqw;
  /* Scaled up from 5cqw */
  font-style: italic;
  font-weight: 400;
  color: #a17b20;
  align-self: center;
}

.english-parent-details {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 0.3cqw;
  font-size: 1.5cqw;
  /* Scaled up from 1.3cqw */
  line-height: 1.4;
}

.english-parent-details .parent-name {
  font-weight: 600;
  color: #8c6a23;
}

.english-parent-details .relationship {
  font-style: italic;
  color: #a17b20;
}

.english-details-text {
  font-family: 'Montserrat', sans-serif;
  font-weight: 500;
  font-size: 1.8cqw;
  /* Scaled up from 1.5cqw */
  line-height: 1.5;
  color: #a17b20;
  margin-bottom: 0.8cqw;
}

.english-addresses-section {
  display: flex;
  justify-content: space-between;
  width: 100%;
  gap: 1.5cqw;
  margin-bottom: 0.8cqw;
}

.english-address-col {
  width: 48%;
  font-family: 'Montserrat', sans-serif;
  font-size: 1.5cqw;
  /* Scaled up from 1.3cqw */
  line-height: 1.4;
  color: #a17b20;
}

.english-address-col .family-title {
  font-weight: 700;
  color: #8c6a23;
  display: block;
  margin-bottom: 0.15cqw;
}

.english-address-col .address-lines {
  display: block;
}

.english-footer-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.35;
  /* Removed margin-top: auto to let flexbox space-between distribute layout vertical spacing evenly on desktop */
}

.english-rsvp-contacts {
  font-size: 1.6cqw;
  /* Scaled up from 1.4cqw */
  font-weight: 600;
  color: #8c6a23;
  margin-top: 0.15cqw;
}

/* --- Slide Navigation Arrows --- */
.slide-arrow {
  position: absolute;
  bottom: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: rgba(255, 253, 237, 0.85);
  border: 1.5px solid var(--gold-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 110;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.3s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  pointer-events: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.slide-arrow svg {
  width: 24px;
  height: 24px;
  fill: var(--gold-secondary);
  transition: fill 0.3s ease;
}

.slide-arrow.prev-arrow {
  left: 20px;
  transform: translateX(-10px);
}

.slide-arrow.next-arrow {
  right: 20px;
  transform: translateX(10px);
}

.slider-container:hover .slide-arrow {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.slide-arrow:hover {
  background-color: #ffffff;
  transform: scale(1.05);
}

.slide-arrow:active {
  transform: scale(0.95);
}

/* --- Mobile Responsiveness for Tamil & English Invitation Cards --- */
@media (max-width: 768px) {

  /* Shared mobile card container fixes */
  .card-container.tamil-card-container,
  .card-container.english-card-container,
  .card-container.events-card-container {
    width: min(94vw, 450px);
    height: 78vh;
    aspect-ratio: auto;
    min-height: 520px;
    max-height: 680px;
    padding: 0;
  }

  .card-pillar {
    top: calc((100vh - clamp(520px, 78vh, 680px)) / 2);
    bottom: calc((100vh - clamp(520px, 78vh, 680px)) / 2);
  }

  .tamil-card-container .invite-card-content,
  .english-card-container .invite-card-content,
  .events-card-container .personal-events-content {
    padding: 24px 20% 75px 20%;
    justify-content: flex-start;
    gap: 12px;
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
  }

  .tamil-card-container .invite-card-content::-webkit-scrollbar,
  .english-card-container .invite-card-content::-webkit-scrollbar,
  .events-card-container .personal-events-content::-webkit-scrollbar {
    display: none;
    /* Hide scrollbar for Chrome, Safari and Opera */
  }

  /* Tamil Specific Mobile Overrides */
  .tamil-card-container .symbol-u {
    font-size: 16px;
  }

  .tamil-card-container .symbol-sivam {
    font-size: 11px;
  }

  .tamil-card-container .card-title-main {
    font-size: 24px;
    margin: 4px 0 2px 0;
  }

  .tamil-card-container .card-greeting-container {
    margin-left: 2px;
    margin-bottom: 2px;
  }

  .tamil-card-container .card-greeting {
    font-size: 16px;
  }

  .tamil-card-container .guest-name-tamil-title {
    font-size: 19px;
  }

  .tamil-card-container .guest-name-tamil-suffix {
    font-size: 13.5px !important;
  }

  .tamil-card-container .card-intro-text {
    font-size: 13.5px;
    line-height: 1.45;
    margin-bottom: 6px;
  }

  .tamil-card-container .card-parents-section.card-tamil-parents-section {
    flex-direction: column;
    gap: 16px;
    margin-bottom: 6px;
  }

  .tamil-card-container .parents-couple-col {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }

  .tamil-card-container .parents-col {
    width: 100%;
    font-size: 13px;
    line-height: 1.35;
  }

  .tamil-card-container .relationship {
    font-size: 11px;
    margin-top: 1px;
  }

  .tamil-card-container .title-prefix {
    font-size: 12px;
    margin-top: 1px;
  }

  .slide-arrow {
    opacity: 0.85;
    pointer-events: auto;
    bottom: auto;
    top: 50%;
    z-index: 250;
  }

  .slide-arrow.prev-arrow {
    left: 12px;
    transform: translateY(-50%);
  }

  .slide-arrow.next-arrow {
    right: 12px;
    transform: translateY(-50%);
  }

  .slide-arrow.prev-arrow:active,
  .slide-arrow.next-arrow:active {
    transform: translateY(-50%) scale(0.92);
  }

  .tamil-card-container .couple-name-container {
    width: 100%;
  }

  .tamil-card-container .couple-name {
    font-size: 26px;
    line-height: 1.15;
  }

  .tamil-card-container .couple-suffix {
    font-size: 11.5px;
    margin-top: 1px;
  }

  .tamil-card-container .card-details-text {
    font-size: 13.5px;
    line-height: 1.45;
    margin-bottom: 6px;
  }

  .tamil-card-container .card-footer-section {
    margin-top: auto;
    padding-top: 8px;
  }

  .tamil-card-container .footer-msg {
    font-size: 12px;
  }

  .tamil-card-container .footer-names {
    font-size: 15px;
    margin: 1px 0;
  }

  .tamil-card-container .footer-family {
    font-size: 13px;
  }

  /* English Specific Mobile Overrides */
  .english-card-container .symbol-u {
    font-size: 16px;
  }

  .english-card-container .english-sivam {
    font-size: 12px;
    margin-top: 2px;
  }

  .english-card-container .english-title-main {
    font-size: 24px;
    margin: 4px 0 2px 0;
  }

  .english-card-container .english-invite-text {
    margin: 2px 0;
  }

  .english-card-container .english-invite-text .invite-head {
    font-size: 14.5px;
  }

  .english-card-container .english-invite-text .invite-sub {
    font-size: 12.5px;
    margin-top: 1px;
  }

  .english-card-container .guest-name-section {
    margin: 4px 0;
  }

  .english-card-container .guest-name-title {
    font-size: 20px;
  }

  .english-card-container .invite-divider-section {
    margin: 2px 0;
  }

  .english-card-container .invite-dots {
    display: none;
    /* Remove dots on mobile to prevent overflow */
  }

  .english-card-container .invite-purpose {
    font-size: 12.5px;
    margin-top: 0;
  }

  .english-card-container .english-couple-section {
    flex-direction: column;
    gap: 8px;
    margin: 4px 0;
  }

  .english-card-container .english-couple-name {
    font-size: 26px;
    line-height: 1.15;
  }

  .english-card-container .couple-ampersand {
    font-size: 22px;
    margin: 2px 0;
  }

  .english-card-container .english-parent-details {
    font-size: 12.5px;
    margin-top: 2px;
    line-height: 1.35;
  }

  .english-card-container .english-details-text {
    font-size: 13.5px;
    line-height: 1.45;
    margin-bottom: 6px;
  }

  .english-card-container .english-addresses-section {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 6px;
  }

  .english-card-container .english-address-col {
    width: 100%;
    font-size: 12.5px;
    line-height: 1.35;
  }

  .english-card-container .english-address-col .family-title {
    font-size: 13px;
    margin-bottom: 1px;
  }

  .english-card-container .english-footer-section {
    margin-top: auto;
    padding-top: 8px;
  }

  .english-card-container .english-rsvp-contacts {
    font-size: 12px;
    margin-top: 2px;
  }
}

/* ==========================================
   Welcome PIN Overlay & RSVP Floating Button
   ========================================== */
.welcome-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  background-color: rgba(58, 50, 36, 0.4);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.77, 0, 0.175, 1);
}

.welcome-overlay.fade-out {
  opacity: 0;
  transform: translateY(-100%);
  pointer-events: none;
}

.welcome-card {
  background: rgba(255, 253, 237, 0.95);
  border: 2.5px solid var(--gold-primary);
  border-radius: 24px;
  padding: 3rem 2.2rem;
  box-shadow: 0 20px 60px rgba(58, 50, 36, 0.35);
  text-align: center;
  max-width: 440px;
  width: 90%;
  animation: scaleUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.welcome-card-header {
  font-size: 2.2rem;
  color: var(--gold-secondary);
  line-height: 1;
  margin-bottom: 0.8rem;
  animation: pulseLogo 2s infinite ease-in-out;
}

.welcome-title-main {
  font-family: 'Playfair Display', serif;
  font-size: 1.8rem;
  font-weight: 700;
  font-style: italic;
  color: #7a0913;
  /* Traditional Deep Crimson */
  margin-bottom: 1rem;
  line-height: 1.3;
}

.welcome-text {
  font-family: 'Montserrat', sans-serif;
  font-size: 1rem;
  color: var(--text-dark);
  line-height: 1.55;
  margin-bottom: 0.8rem;
  font-weight: 500;
}

.welcome-subtext {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.85rem;
  color: var(--gold-secondary);
  font-weight: 600;
  margin-bottom: 1.8rem;
  line-height: 1.4;
}

.pin-input-container {
  display: flex;
  justify-content: center;
  margin-bottom: 0.6rem;
}

#guest-pin {
  width: 100%;
  max-width: 180px;
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  padding: 0.6rem 0;
  border: 2px solid var(--gold-primary);
  border-radius: 12px;
  background-color: #fff;
  color: #7a0913;
  outline: none;
  transition: all 0.3s ease;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

#guest-pin::placeholder {
  color: #e0d9cb;
  letter-spacing: 0.1em;
}

#guest-pin:focus {
  border-color: #7a0913;
  box-shadow: 0 0 12px rgba(122, 9, 19, 0.2), inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.pin-error {
  color: #7a0913;
  font-size: 0.85rem;
  font-weight: 600;
  min-height: 1.25rem;
  margin-bottom: 1rem;
}

.welcome-btn {
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, #7a0913 0%, #5c0d24 100%);
  border: 2px solid var(--gold-primary);
  border-radius: 12px;
  color: #fff;
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(122, 9, 19, 0.35);
  transition: all 0.3s ease;
}

.welcome-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(122, 9, 19, 0.5);
  background: linear-gradient(135deg, #8a1222 0%, #70112c 100%);
}

.welcome-btn:active {
  transform: translateY(0);
}

/* Floating RSVP / Wedding Website Link Button */
.rsvp-floating-container {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 450;
  pointer-events: none;
  width: auto;
  display: flex;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

body.content-active .rsvp-floating-container {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.rsvp-link-btn {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.8rem 1.6rem;
  background: linear-gradient(135deg, #ffeaa7 0%, #d4af37 50%, #b8860b 100%);
  border: 2px solid var(--burgundy);
  border-radius: 30px;
  color: var(--burgundy) !important;
  text-decoration: none;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
  box-shadow: 0 8px 25px rgba(170, 124, 17, 0.45);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  animation: floatBounce 3s infinite ease-in-out;
  text-transform: uppercase;
}

.rsvp-link-btn:hover {
  transform: scale(1.05) translateY(-2px);
  box-shadow: 0 12px 30px rgba(170, 124, 17, 0.65);
}

.rsvp-link-btn .arrow-icon {
  width: 16px;
  height: 16px;
  fill: var(--burgundy);
  transition: transform 0.3s ease;
}

.rsvp-link-btn:hover .arrow-icon {
  transform: translateX(4px);
}

.rsvp-slide-btn-container {
  display: flex !important;
  justify-content: center;
  width: 100%;
}

/* Keyframe Animations */
@keyframes scaleUp {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(20px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes floatBounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

@media (max-width: 480px) {
  .welcome-card {
    padding: 2.2rem 1.5rem;
  }

  .welcome-title-main {
    font-size: 1.5rem;
  }

  .welcome-text {
    font-size: 0.95rem;
  }

  .rsvp-floating-container {
    bottom: 34px;
  }

  .rsvp-link-btn {
    padding: 0.7rem 1.4rem;
    font-size: 0.85rem;
  }
}

/* Slide 3 Card & Button Overlay Styles */
.slide-card-three {
  position: relative;
}

.slide-button-overlay {
  position: absolute;
  bottom: 15%;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  display: flex;
  justify-content: center;
  z-index: 10;
}

.slide-rsvp-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.85rem 1.85rem;
  background: linear-gradient(135deg, #7a0913 0%, #5c0d24 100%);
  border: 2px solid var(--gold-primary);
  border-radius: 30px;
  color: #fff !important;
  text-decoration: none;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  box-shadow: 0 10px 25px rgba(122, 9, 19, 0.45);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  text-transform: uppercase;
  animation: floatBounce 3s infinite ease-in-out;
}

.slide-rsvp-btn:hover {
  transform: scale(1.05) translateY(-2px);
  box-shadow: 0 14px 30px rgba(122, 9, 19, 0.6);
}

.slide-rsvp-gold-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.85rem 3.5rem;
  background: linear-gradient(135deg, #d4af37 0%, #b8860b 100%);
  border: 2px solid var(--gold-primary);
  border-radius: 30px;
  color: #fff !important;
  text-decoration: none;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 1px;
  box-shadow: 0 10px 25px rgba(184, 134, 11, 0.45);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  text-transform: uppercase;
  animation: floatBounce 3s infinite ease-in-out;
}

.slide-rsvp-gold-btn:hover {
  transform: scale(1.05) translateY(-2px);
  box-shadow: 0 14px 30px rgba(184, 134, 11, 0.6);
}

.slide-rsvp-btn .arrow-icon {
  width: 16px;
  height: 16px;
  fill: #fff;
  transition: transform 0.3s ease;
}

.slide-rsvp-btn:hover .arrow-icon {
  transform: translateX(4px);
}

@media (max-width: 480px) {
  .slide-button-overlay {
    bottom: 12%;
  }

  .slide-rsvp-btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.85rem;
  }
}

/* Card 3 Personalized Schedule Styles */
.events-card-container {
  background-color: transparent !important;
  background: transparent !important;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: stretch;
  position: relative;
  border: none !important;
}

.events-card-container .personal-events-content {
  width: 100%;
  height: 100%;
  padding: 3.2cqw 12.5cqw 2.2cqw 12.5cqw;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  text-align: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.events-card-container .personal-events-content::-webkit-scrollbar {
  display: none;
}

.events-card-container .card-pillar {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 12%;
  z-index: 2;
  pointer-events: none;
}

.events-card-container .card-pillar-left {
  left: 0;
  background-image: url('images/Left.png');
  background-position: left center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.events-card-container .card-pillar-right {
  right: 0;
  background-image: url('images/Roght.png');
  background-position: right center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  transform: scaleX(-1);
}

.events-accordion {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.accordion-item {
  border: 1px solid var(--border-gold);
  border-radius: 8px;
  background-color: rgba(255, 253, 237, 0.6);
  overflow: hidden;
  transition: all 0.3s ease;
}

.accordion-header {
  width: 100%;
  padding: 0.85rem 1.2rem;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  outline: none;
}

.accordion-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--burgundy);
}

.accordion-icon {
  font-size: 1.2rem;
  color: var(--gold-secondary);
  transition: transform 0.3s ease;
  line-height: 1;
}

.accordion-item.active .accordion-icon {
  transform: rotate(180deg);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  background-color: rgba(255, 255, 255, 0.5);
}

.accordion-body {
  padding: 1rem 1.2rem;
  border-top: 1px dashed var(--border-gold);
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-dark);
}

.accordion-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-bottom: 0.6rem;
  font-weight: 600;
  color: var(--gold-secondary);
}

.accordion-venue {
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.accordion-desc {
  margin-bottom: 0.8rem;
  color: #555;
}

.accordion-btn-maps {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--gold-primary);
  border-radius: 15px;
  color: var(--gold-secondary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.75rem;
  transition: all 0.3s;
}

.accordion-btn-maps:hover {
  background-color: var(--gold-primary);
  color: #fff;
}

/* ==========================================================================
   TRANSITION ANIMATION SEQUENCE (POST-PIN ENTRY)
   ========================================================================== */

#transition-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 3500;
  background-color: #fffded;
  /* matches cream background */
  display: none;
  /* controlled by JS */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.5s ease;
}

#transition-overlay.active {
  display: flex;
  opacity: 1;
}

/* 1. Entrance State (Emblem, Swinging Lamp, CTA) */
.entrance-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  transition: opacity 0.6s ease, transform 0.6s ease;
  z-index: 30;
}

.entrance-container.fade-out {
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
}

/* Emblem zoom */
.emblem-wrapper {
  margin-top: 15vh;
  /* position it lower to give space for hanging lamp */
  display: flex;
  justify-content: center;
  align-items: center;
}

.emblem-img {
  width: min(220px, 50vw);
  height: auto;
  transform: scale(0);
  opacity: 0;
  animation: zoomInEmblem 1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards 0.3s;
  filter: drop-shadow(0 10px 25px rgba(212, 175, 55, 0.35));
}

@keyframes zoomInEmblem {
  0% {
    transform: scale(0) translateY(-30px);
    opacity: 0;
  }

  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

/* Swinging Lamps (Left & Right) */
.transition-lamp-container {
  position: absolute;
  top: 0;
  width: min(100px, 24vw);
  height: min(220px, 50vh);
  transform-origin: top center;
  z-index: 10;
  pointer-events: none;
}

.transition-lamp-left {
  left: 8%;
  transform: translateY(-100%);
  animation: dropDown 2.2s cubic-bezier(0.19, 1, 0.22, 1) forwards,
    swing 4s ease-in-out infinite alternate 2.2s;
}

.transition-lamp-right {
  right: 8%;
  transform: translateY(-100%);
  animation: dropDown 2.2s cubic-bezier(0.19, 1, 0.22, 1) forwards,
    swing 4s ease-in-out infinite alternate 2.2s;
}

.transition-lamp-img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* CTA "Tap to open" overlay */
.tap-to-open-cta {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.25rem, 4.5vw, 1.7rem);
  font-weight: 600;
  font-style: italic;
  color: #7a0913;
  /* Crimson matching Pillayar/Ganesha and buttons */
  text-shadow: 0 1px 3px rgba(122, 9, 19, 0.1);
  margin-top: 4vh;
  opacity: 0;
  cursor: pointer;
  letter-spacing: 1px;
  animation: fadeInCta 1s ease forwards 1.6s;
  user-select: none;
}

@keyframes fadeInCta {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.tap-to-open-cta.pulse {
  animation: fadeInCta 1s ease forwards 1.6s, ctaPulse 2s infinite ease-in-out 2.6s;
}

@keyframes ctaPulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 0.85;
    text-shadow: 0 0 5px rgba(122, 9, 19, 0.25);
  }

  50% {
    transform: scale(1.05);
    opacity: 1;
    text-shadow: 0 0 15px rgba(122, 9, 19, 0.55);
  }
}


/* 2. Envelope Card & Flipping */
.transition-envelope-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.7);
  width: min(440px, 92vw);
  height: min(440px, 92vw);
  perspective: 1500px;
  opacity: 0;
  pointer-events: none;
  z-index: 20;
  display: none;
  /* controlled by JS */
  transition: opacity 0.5s ease, transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.transition-envelope-wrapper.active {
  display: block;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.envelope-card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 1.1s cubic-bezier(0.65, 0, 0.35, 1);
}

.envelope-card.flipped {
  transform: rotateY(180deg);
}

.envelope-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 14px;
  box-shadow: 0 15px 45px rgba(58, 50, 36, 0.16);
  background-color: #fffded;
  overflow: hidden;
}

/* Front Face */
.envelope-front-face {
  z-index: 2;
  transform: rotateY(0deg);
}

.envelope-front-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Back Face */
.envelope-back-face {
  transform: rotateY(180deg);
  z-index: 1;
  border-radius: 14px;
  box-shadow: 0 15px 45px rgba(58, 50, 36, 0.16);
  background-color: #fffded;
  overflow: visible;
  /* allow Card B to slide out above the envelope boundary */
  transform-style: preserve-3d;
}

/* Pocket background (always visible, bottom 2/3) */
.env-pocket-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  clip-path: inset(33.333% 0 0 0);
  /* show only bottom 2/3 */
  transition: opacity 1.2s ease;
}

/* Sibling-based Flap Styles with Depth Layering & Opacity Blending */
.env-flap-closed {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 33.333%;
  /* Align exactly to top of envelope and cover the top 1/3 of the envelope */
  transform-origin: top center;
  z-index: 12;
  /* Sits on top of pocket when closed */
  transform: rotateX(0deg) translateZ(2px);
  opacity: 1;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), z-index 0s linear 0.4s, opacity 0.6s ease;
  object-fit: fill;
}

.env-flap-open {
  position: absolute;
  top: -33.333%;
  /* Bottom edge is exactly at Y = 0% (hinge line at top of envelope) */
  left: 0;
  width: 100%;
  height: 33.333%;
  /* Align exactly to top of envelope (extends upwards from Y=0% to Y=-33.333%) */
  transform-origin: bottom center;
  z-index: 2;
  /* Behind card when open */
  transform: rotateX(180deg) translateZ(1px);
  opacity: 0;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), z-index 0s linear 0.4s, opacity 0.6s ease;
  object-fit: fill;
}

.transition-envelope-wrapper.opening .env-flap-closed {
  transform: rotateX(-180deg) translateZ(1px);
  opacity: 0;
  z-index: 2;
}

.transition-envelope-wrapper.opening .env-flap-open {
  transform: rotateX(0deg) translateZ(1px);
  opacity: 1;
  z-index: 2;
}

/* Card overlay.png sliding out and zooming in front of envelope */
.reveal-card-b {
  position: absolute;
  left: 10%;
  width: 80%;
  height: 80%;
  bottom: 8%;
  z-index: 5;
  transform: translateY(-90%) translateZ(0) scale(0.9);
  /* Start at the top of the envelope for a top-to-bottom open envelope reveal */
  opacity: 0;
  transition: transform 1.6s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.8s ease, z-index 0s linear;
  transform-style: preserve-3d;
}

.reveal-card-b img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 15px 35px rgba(58, 50, 36, 0.25));
}

.transition-envelope-wrapper.revealed {
  transform: translate(-50%, -82%) scale(0.75);
}

.transition-envelope-wrapper.revealed .reveal-card-b {
  transform: translateY(80%) translateZ(40px) scale(1.5);
  /* slide out and zoom large to cover screen, slightly overlapping the envelope bottom */
  opacity: 1;
  z-index: 25;
  /* render in front of open envelope */
}

.transition-envelope-wrapper.exited .reveal-card-b {
  opacity: 0;
  transform: translateY(95%) translateZ(50px) scale(1.6);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

/* Front Pocket Overlay to sandwich the card */
.env-front-pocket-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  clip-path: inset(33.333% 0 0 0);
  /* show only the pocket body */
  border-radius: 14px;
  pointer-events: none;
  object-fit: cover;
  transition: opacity 1.2s ease;
}

/* Fade out closed flap, but keep open envelope visible when revealed */
.transition-envelope-wrapper.revealed .env-flap-closed {
  opacity: 0;
}

.transition-envelope-wrapper.revealed .env-pocket-bg,
.transition-envelope-wrapper.revealed .env-front-pocket-overlay,
.transition-envelope-wrapper.revealed .env-flap-open {
  opacity: 1;
}

/* Mobile responsive scaling overrides for revealed card */
@media (max-width: 768px) {
  .transition-envelope-wrapper.revealed {
    transform: translate(-50%, -82%) scale(0.6);
  }

  .transition-envelope-wrapper.revealed .reveal-card-b {
    transform: translateY(72%) translateZ(40px) scale(1.15);
    /* overlap envelope bottom slightly on mobile */
  }

  .transition-envelope-wrapper.exited .reveal-card-b {
    opacity: 0;
    transform: translateY(87%) translateZ(50px) scale(1.2);
  }
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .emblem-img {
    width: min(180px, 48vw);
  }

  .transition-lamp-container {
    width: min(90px, 24vw);
    height: min(200px, 50vh);
  }

  .tap-to-open-cta {
    margin-top: 3vh;
  }
}

/* Styling for temple drawing canvas */
#drawing-canvas {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  /* Let clicks bubble up to slide down the overlay */
}