/* ==========================================================================
   THIỆP CƯỚI - INDOCHINE MINIMALISM (PERSIAN RED & CREAM)
   ========================================================================== */

:root {
  --bg-cream: #fff7eb;
  --card-ivory: #ece4d8;
  --primary-red: #cc3333;
  --primary-red-light: #dd4b4b;
  --primary-red-dark: #961f1f;
  --accent-rose: #cc3333;
  --accent-gold: #d4a63e;
  --accent-gold-dark: #9f6f18;
  --text-dark: #cc3333;
  --text-muted: rgba(204, 51, 51, 0.76);
  --font-serif: "Cormorant Garamond", "EB Garamond", "Times New Roman", serif;
  --font-display: "Viaoda Libre", "Cormorant Garamond", cursive;
  --font-script: "The Nautigal", "Ms Madi", cursive;
  --font-calligraphy: "Great Vibes", "The Nautigal", cursive;
  --font-body: "EB Garamond", "Cormorant Garamond", serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background-color: #f4ece1;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  color: var(--text-dark);
  background-color: #f4ece1;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Paper Grain Texture Overlay (0 external requests) */
.paper-texture {
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 240 240' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.07'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
  pointer-events: none;
}

/* Realistic Matte / Rough Paper Texture for Persian Red Surfaces */
.paper-texture-dark {
  background-image:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 220 220' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='roughPaper'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='4' seed='11' stitchTiles='stitch' result='noise'/%3E%3CfeDiffuseLighting in='noise' lighting-color='%23ffffff' surfaceScale='1.65' result='lit'%3E%3CfeDistantLight azimuth='45' elevation='60'/%3E%3C/feDiffuseLighting%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23roughPaper)' opacity='0.26'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='fineGrit'%3E%3CfeTurbulence type='turbulence' baseFrequency='1.6' numOctaves='2' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23fineGrit)' opacity='0.14'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
  pointer-events: none;
}

/* Mobile GPU optimization: avoid heavy SVG diffuseLighting filters & continuous repaints on small devices */
@media (max-width: 767px) {
  .paper-texture {
    opacity: 0.45;
    mix-blend-mode: normal;
  }
  .paper-texture-dark {
    background-image: radial-gradient(circle at 25% 20%, rgba(255, 240, 210, 0.12) 0%, transparent 55%),
      radial-gradient(circle at 80% 80%, rgba(90, 10, 10, 0.22) 0%, transparent 60%);
    mix-blend-mode: normal;
  }
  .text-shimmer-gold,
  .text-shimmer-crimson {
    animation: none;
    background-position: 35% center;
  }
  .card-sheen-layer::after,
  .polaroid-sheen::after {
    animation: none;
    opacity: 0;
  }
  .parallax-flower img {
    filter: none !important;
  }
  .flower-edge-left {
    left: -24px !important;
    top: 5px !important;
    width: 25% !important;
  }
  main.invite-shell > section:nth-of-type(3) .flower-edge-left {
    left: -26px !important;
    top: -2px !important;
  }
  .flower-edge-right {
    right: -5% !important;
    width: 18% !important;
  }
  main.invite-shell > section:first-of-type .flower-edge-right {
    width: 22% !important;
    bottom: 22% !important;
  }
  [data-hero="flower"] {
    left: -6% !important;
    width: 48% !important;
  }
}

/* Main Invitation Container */
.invite-shell {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background-color: var(--bg-cream);
  color: var(--primary-red);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(150, 31, 31, 0.14);
}

@media (min-width: 768px) {
  .invite-shell {
    max-width: 820px;
    border-left: 1px solid rgba(204, 51, 51, 0.16);
    border-right: 1px solid rgba(204, 51, 51, 0.16);
  }
}

/* ==========================================================================
   KEYFRAME ANIMATIONS (from sample + enhanced)
   ========================================================================== */
@keyframes drFloat {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-9px);
  }
}

@keyframes drFloatSlow {
  0%, 100% {
    transform: translateY(0px) rotate(-1deg);
  }
  50% {
    transform: translateY(-10px) rotate(1.5deg);
  }
}

@keyframes spinCD {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes dance1 {
  0%, 100% { height: 35%; }
  50% { height: 95%; }
}
@keyframes dance2 {
  0%, 100% { height: 90%; }
  50% { height: 30%; }
}
@keyframes dance3 {
  0%, 100% { height: 45%; }
  50% { height: 100%; }
}
@keyframes dance4 {
  0%, 100% { height: 75%; }
  50% { height: 25%; }
}

@keyframes sealPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow:
      0 12px 28px rgba(70, 12, 12, 0.45),
      0 0 0 0 rgba(250, 224, 136, 0.55),
      inset 0 2px 4px rgba(255, 252, 230, 0.9),
      inset 0 -4px 8px rgba(100, 62, 6, 0.65);
  }
  50% {
    transform: scale(1.045);
    box-shadow:
      0 16px 34px rgba(70, 12, 12, 0.5),
      0 0 0 16px rgba(250, 224, 136, 0),
      inset 0 2px 4px rgba(255, 252, 230, 0.95),
      inset 0 -4px 8px rgba(100, 62, 6, 0.65);
  }
}

@keyframes petalFall {
  0% {
    transform: translate3d(0, -10vh, 0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 0.72;
  }
  90% {
    opacity: 0.6;
  }
  100% {
    transform: translate3d(36px, 105vh, 0) rotate(360deg);
    opacity: 0;
  }
}

/* Luxury Gold & Crimson Shimmer Typography */
@keyframes textShimmer {
  0% {
    background-position: 200% center;
  }
  100% {
    background-position: -200% center;
  }
}

/* Gentle Heartbeat for Wedding Calendar Date */
@keyframes heartPulse {
  0%, 100% {
    transform: scale(1);
  }
  18% {
    transform: scale(1.16);
  }
  32% {
    transform: scale(1);
  }
  48% {
    transform: scale(1.1);
  }
  65% {
    transform: scale(1);
  }
}

/* Subtle Diagonal Sheen on Red Cards */
@keyframes cardSheen {
  0% {
    transform: translateX(-140%) skewX(-20deg);
  }
  35%, 100% {
    transform: translateX(240%) skewX(-20deg);
  }
}

.text-shimmer-gold {
  background: linear-gradient(
    110deg,
    #d4a63e 0%,
    #f7df9c 22%,
    #fff8dc 38%,
    #e5bf62 56%,
    #d4a63e 100%
  );
  background-size: 220% auto;
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  animation: textShimmer 9s linear infinite;
}

.text-shimmer-crimson {
  background: linear-gradient(
    110deg,
    #961f1f 0%,
    #cc3333 28%,
    #f08a5d 44%,
    #d4a63e 52%,
    #cc3333 65%,
    #961f1f 100%
  );
  background-size: 220% auto;
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  animation: textShimmer 10s linear infinite;
}

.heart-pulse {
  animation: heartPulse 3.2s ease-in-out infinite;
  transform-origin: center;
}

.card-sheen-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
}

.card-sheen-layer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 45%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 248, 220, 0.08) 50%,
    transparent 100%
  );
  animation: cardSheen 9.5s ease-in-out 2s infinite;
}

.cd-card {
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.25s ease;
  border: 1px solid rgba(247, 223, 156, 0.22);
}

.cd-card:hover {
  transform: translateY(-2px);
  border-color: rgba(247, 223, 156, 0.55);
}

.wish-item-enter {
  animation: wishPopIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes wishPopIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Slow Sacred Mandala / Lotus Rotation */
@keyframes slowSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Floating Gold Dust Sparkles */
@keyframes goldSparkle {
  0%, 100% {
    opacity: 0.15;
    transform: translate3d(0, 0, 0) scale(0.7);
  }
  50% {
    opacity: 0.85;
    transform: translate3d(6px, -14px, 0) scale(1.2);
  }
}

/* Polaroid Glossy Light Sweep */
@keyframes polaroidSweep {
  0% {
    transform: translateX(-140%) skewX(-22deg);
  }
  30%, 100% {
    transform: translateX(240%) skewX(-22deg);
  }
}

/* Wax Seal Opening Ripple */
@keyframes sealRipple {
  0% {
    transform: scale(0.95);
    opacity: 0.85;
  }
  100% {
    transform: scale(2.8);
    opacity: 0;
  }
}

.animate-slow-spin {
  animation: slowSpin 75s linear infinite;
  will-change: transform;
}

.sparkle-dot {
  position: absolute;
  border-radius: 9999px;
  background: radial-gradient(circle, #fffbe6 0%, #f7df9c 45%, transparent 75%);
  pointer-events: none;
  animation: goldSparkle ease-in-out infinite;
  will-change: transform, opacity;
}

.polaroid-sheen {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 5;
}

.polaroid-sheen::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 48%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 250, 230, 0.28) 50%,
    transparent 100%
  );
  animation: polaroidSweep 7s ease-in-out 2.5s infinite;
}

.seal-ripple-ring {
  position: absolute;
  inset: -6px;
  border-radius: 9999px;
  border: 2px solid rgba(250, 224, 136, 0.85);
  pointer-events: none;
  opacity: 0;
}

.is-bursting .seal-ripple-ring {
  animation: sealRipple 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.hero-perspective {
  perspective: 1200px;
}

.animate-dr-float {
  animation: drFloat 6s ease-in-out infinite;
  will-change: transform;
}

.animate-dr-float-delayed {
  animation: drFloat 6.5s ease-in-out 0.4s infinite;
  will-change: transform;
}

.animate-dr-float-flower {
  animation: drFloatSlow 5.2s ease-in-out infinite;
  will-change: transform;
}

.animate-spin-cd {
  animation: spinCD 8s linear infinite;
}
.paused .animate-spin-cd {
  animation-play-state: paused;
}

.animate-dance-1 { animation: dance1 0.8s ease-in-out infinite; }
.animate-dance-2 { animation: dance2 0.7s ease-in-out 0.1s infinite; }
.animate-dance-3 { animation: dance3 0.9s ease-in-out 0.2s infinite; }
.animate-dance-4 { animation: dance4 0.75s ease-in-out 0.15s infinite; }
.paused .eq-bar {
  animation: none !important;
  height: 30% !important;
}

/* ==========================================================================
   SCROLL REVEAL ANIMATIONS
   ========================================================================== */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 1.15s cubic-bezier(0.22, 1, 0.36, 1),
              transform 1.15s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.text-balance {
  text-wrap: balance;
}

/* ==========================================================================
   OPENING WAX SEAL CURTAIN
   ========================================================================== */
.intro-curtain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  min-height: 100vh;
  padding: env(safe-area-inset-top, 16px) 16px env(safe-area-inset-bottom, 16px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #dc4545 0%, #cc3333 58%, #8f1d1d 100%);
  color: var(--card-ivory);
  transition: opacity 0.85s cubic-bezier(0.22, 1, 0.36, 1),
              visibility 0.85s ease,
              transform 0.95s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (max-height: 640px) {
  .wax-seal-btn {
    width: 96px;
    height: 96px;
  }
}

.intro-curtain.is-opened {
  opacity: 0;
  visibility: hidden;
  transform: scale(1.08);
  pointer-events: none;
}

.wax-seal-btn {
  position: relative;
  overflow: hidden;
  width: 116px;
  height: 116px;
  border-radius: 9999px;
  background: radial-gradient(circle at 28% 24%, #fffbe6 0%, #fae088 20%, #d8a93e 54%, #a67215 84%, #754b07 100%);
  border: 2.5px solid #f7df9c;
  color: #5a3806;
  text-shadow: 0 1px 0 rgba(255, 250, 220, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  animation: sealPulse 2.4s ease-in-out infinite;
  transition: transform 0.25s ease, filter 0.25s ease;
}

.wax-seal-btn::before {
  content: "";
  position: absolute;
  top: 5%;
  left: 10%;
  width: 80%;
  height: 46%;
  border-radius: 9999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.65) 0%, rgba(255, 255, 255, 0.08) 70%, transparent 100%);
  pointer-events: none;
}

.wax-seal-btn::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 250, 224, 0.65);
  box-shadow: inset 0 1px 3px rgba(110, 68, 8, 0.35);
  pointer-events: none;
}

.wax-seal-btn:hover {
  transform: scale(1.08);
  filter: brightness(1.06);
}

/* ==========================================================================
   3D COVERFLOW CAROUSEL (Responsive & Centered on All Mobile Widths)
   ========================================================================== */
.carousel-stage {
  perspective: 1100px;
  position: relative;
  width: 100%;
  height: 310px;
  touch-action: pan-y;
  user-select: none;
  contain: layout style;
}

@media (min-width: 380px) {
  .carousel-stage {
    height: 350px;
  }
}

@media (min-width: 768px) {
  .carousel-stage {
    height: 490px;
  }
}

.carousel-slide {
  position: absolute;
  top: 4%;
  left: 0;
  right: 0;
  margin-inline: auto;
  height: 92%;
  width: fit-content;
  aspect-ratio: 2 / 3;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 18px 35px rgba(150, 31, 31, 0.22);
  cursor: pointer;
  transition: transform 0.85s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.85s ease;
  will-change: transform, opacity;
  -webkit-tap-highlight-color: transparent;
}

.carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ==========================================================================
   FALLING PETALS CONTAINER
   ========================================================================== */
.petals-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 35;
  overflow: hidden;
}

.petal {
  position: absolute;
  top: -10vh;
  animation: petalFall linear infinite;
  will-change: transform, opacity;
}

/* ==========================================================================
   MODALS & LIGHTBOX
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(20, 5, 7, 0.72);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  transform: translateY(16px) scale(0.97);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-overlay.is-open .modal-card {
  transform: translateY(0) scale(1);
}

/* Custom Scrollbar for Guestbook */
.guestbook-scroll {
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}
.guestbook-scroll::-webkit-scrollbar {
  width: 5px;
}
.guestbook-scroll::-webkit-scrollbar-track {
  background: rgba(204, 51, 51, 0.06);
  border-radius: 99px;
}
.guestbook-scroll::-webkit-scrollbar-thumb {
  background: rgba(204, 51, 51, 0.32);
  border-radius: 99px;
}

/* Toast Notification */
.toast-msg {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--primary-red);
  color: var(--card-ivory);
  padding: 10px 20px;
  border-radius: 9999px;
  font-size: 14px;
  max-width: calc(100vw - 32px);
  text-align: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast-msg.is-shown {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   MOBILE UX & ACCESSIBILITY BEST PRACTICES
   ========================================================================== */
#music-player {
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  right: calc(16px + env(safe-area-inset-right, 0px));
}

#lightbox-modal {
  padding-top: max(12px, env(safe-area-inset-top, 12px));
  padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
}

/* Prevent iOS Safari auto-zoom when focusing inputs */
@media (max-width: 767px) {
  #wish-form input,
  #wish-form select,
  #wish-form textarea {
    font-size: 16px;
  }
}

/* Respect user's reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .animate-dr-float,
  .animate-dr-float-delayed,
  .animate-dr-float-flower,
  .animate-spin-cd,
  .eq-bar,
  .wax-seal-btn,
  .petal,
  .text-shimmer-gold,
  .text-shimmer-crimson,
  .heart-pulse,
  .card-sheen-layer::after,
  .animate-slow-spin,
  .sparkle-dot,
  .polaroid-sheen::after {
    animation: none !important;
  }
  .text-shimmer-gold {
    color: var(--accent-gold);
    -webkit-text-fill-color: var(--accent-gold);
  }
  .text-shimmer-crimson {
    color: var(--primary-red);
    -webkit-text-fill-color: var(--primary-red);
  }
  .reveal {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}
