/* =========================================================
   Happy Mother's Day — Styles
   Palette: deep wine/plum -> rose -> blush gold
   ========================================================= */

:root {
  --bg-deep: #150816;
  --bg-mid: #2a0e2a;
  --bg-rose: #5a1a3a;
  --rose: #ff8fb3;
  --rose-deep: #d6447a;
  --gold: #f4cf8a;
  --gold-bright: #ffe6b0;
  --cream: #fff4e6;
  --ink: #2a0712;
  --shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6);
  --shadow-soft: 0 10px 40px -10px rgba(214, 68, 122, 0.35);
  --serif: 'Playfair Display', 'Cormorant Garamond', serif;
  --serif-light: 'Cormorant Garamond', serif;
  --script: 'Dancing Script', cursive;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--serif-light);
  color: var(--cream);
  background: radial-gradient(ellipse at 50% 20%, #3a1335 0%, #1a0817 50%, #0b040c 100%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1800px;
}

/* ----- 3D background canvas ----- */
#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
  pointer-events: none;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 30%, transparent 35%, rgba(0,0,0,0.55) 100%),
    radial-gradient(circle at 50% 50%, transparent 60%, rgba(0,0,0,0.35) 100%);
  mix-blend-mode: multiply;
}

/* ----- Loading curtain ----- */
.curtain {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: radial-gradient(ellipse at 50% 50%, #2a0e2a 0%, #0b040c 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 1.2s ease, visibility 1.2s ease;
}
.curtain.gone {
  opacity: 0;
  visibility: hidden;
}

.curtain-inner {
  text-align: center;
  color: var(--cream);
}

.loading-flower {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  animation: spin 6s linear infinite;
}
.loading-flower .petal {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 38px;
  margin: -19px 0 0 -12px;
  background: linear-gradient(180deg, var(--rose) 0%, var(--rose-deep) 100%);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  transform-origin: 50% 100%;
  filter: drop-shadow(0 0 8px rgba(255, 143, 179, 0.6));
  opacity: 0.9;
}
.loading-flower .petal:nth-child(1) { transform: rotate(0deg) translateY(-22px); }
.loading-flower .petal:nth-child(2) { transform: rotate(72deg) translateY(-22px); }
.loading-flower .petal:nth-child(3) { transform: rotate(144deg) translateY(-22px); }
.loading-flower .petal:nth-child(4) { transform: rotate(216deg) translateY(-22px); }
.loading-flower .petal:nth-child(5) { transform: rotate(288deg) translateY(-22px); }
.loading-core {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  background: radial-gradient(circle, var(--gold-bright) 0%, var(--gold) 60%, var(--rose-deep) 100%);
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(244, 207, 138, 0.7);
}
.loading-text {
  font-family: var(--serif);
  font-style: italic;
  letter-spacing: 0.08em;
  font-size: 14px;
  color: rgba(255, 244, 230, 0.7);
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ----- Stage ----- */
.stage {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-style: preserve-3d;
}

/* ----- Closed card ----- */
.closed-card {
  position: relative;
  width: min(420px, 88vw);
  height: min(620px, 80vh);
  transform-style: preserve-3d;
  animation: floatCard 8s ease-in-out infinite;
  transition: transform 1.4s cubic-bezier(.7,0,.2,1), opacity 0.9s ease;
}

@keyframes floatCard {
  0%, 100% { transform: translateY(0) rotateX(2deg) rotateY(-3deg); }
  50%      { transform: translateY(-10px) rotateX(-2deg) rotateY(3deg); }
}

.closed-card.fly-away {
  animation: none;
  transform: translateY(-60vh) rotateX(40deg) rotateY(15deg) scale(0.4);
  opacity: 0;
  pointer-events: none;
}

.card-front {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 18px;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 230, 176, 0.18) 0%, transparent 50%),
    linear-gradient(160deg, #6c1a40 0%, #3d0d28 50%, #2a071a 100%);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4);
  overflow: hidden;
  transform: translateZ(0);
}

.card-glow {
  position: absolute;
  inset: -50%;
  background: radial-gradient(circle at 50% 50%, rgba(244, 207, 138, 0.18) 0%, transparent 50%);
  animation: glowShift 6s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes glowShift {
  0% { transform: translate(-15%, -10%); }
  100% { transform: translate(15%, 10%); }
}

.card-border {
  position: absolute;
  inset: 14px;
  border-radius: 12px;
  border: 1px solid rgba(244, 207, 138, 0.35);
  pointer-events: none;
}
.card-border::before, .card-border::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 8px;
  border: 1px solid rgba(244, 207, 138, 0.18);
  pointer-events: none;
}

.card-content {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 36px;
  text-align: center;
}

.eyebrow {
  font-family: var(--serif);
  font-style: italic;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  font-size: 10px;
  color: var(--gold);
  margin-bottom: 18px;
  opacity: 0.85;
}

.card-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(38px, 7vw, 56px);
  line-height: 1.05;
  color: var(--cream);
  text-shadow: 0 4px 24px rgba(255, 143, 179, 0.25);
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 24px;
}
.card-title .word { display: block; }
.card-title .script {
  font-family: var(--script);
  font-weight: 600;
  font-size: clamp(54px, 10vw, 84px);
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 50%, #d4a85f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 12px rgba(244, 207, 138, 0.35));
  margin: -4px 0 -2px;
}

.card-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 60%;
  margin: 6px 0 20px;
}
.card-divider span {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(244, 207, 138, 0.6), transparent);
}
.divider-heart {
  width: 14px;
  height: 14px;
  fill: var(--gold);
  filter: drop-shadow(0 0 6px rgba(244, 207, 138, 0.7));
}

.card-sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: rgba(255, 244, 230, 0.7);
  margin-bottom: 28px;
  letter-spacing: 0.04em;
}

.open-btn {
  position: relative;
  padding: 14px 32px;
  border: 1px solid rgba(244, 207, 138, 0.5);
  background: linear-gradient(180deg, rgba(244, 207, 138, 0.08), rgba(244, 207, 138, 0.02));
  color: var(--cream);
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  border-radius: 999px;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.3s ease;
  backdrop-filter: blur(4px);
}
.open-btn:hover {
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(244, 207, 138, 0.18), rgba(244, 207, 138, 0.06));
  color: var(--gold-bright);
  transform: translateY(-2px);
  box-shadow: 0 12px 30px -10px rgba(244, 207, 138, 0.4);
}
.open-btn:active { transform: translateY(0); }
.btn-shimmer {
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 244, 230, 0.25), transparent);
  animation: shimmer 3.5s ease-in-out infinite;
}
@keyframes shimmer {
  0% { left: -100%; }
  60%, 100% { left: 200%; }
}
.btn-text { position: relative; z-index: 1; }

/* ----- Opened card ----- */
.opened-card {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease 0.4s;
}
.opened-card.hidden { display: none; }
.opened-card.shown {
  pointer-events: auto;
  opacity: 1;
}

.opened-inner {
  position: relative;
  width: min(720px, 92vw);
  max-height: 88vh;
  padding: 56px 48px;
  text-align: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(255, 230, 176, 0.08) 0%, transparent 60%);
  border-radius: 24px;
  overflow-y: auto;
}
.opened-inner::-webkit-scrollbar { width: 0; }

.opened-header {
  margin-bottom: 36px;
}

.overline {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--gold);
  margin-bottom: 18px;
}

.opened-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(32px, 6vw, 48px);
  line-height: 1.1;
  color: var(--cream);
}
.opened-title .script-big {
  display: block;
  font-family: var(--script);
  font-weight: 600;
  font-size: clamp(56px, 10vw, 92px);
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 50%, #d4a85f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 16px rgba(244, 207, 138, 0.35));
  line-height: 1;
  margin-top: 6px;
}

.message {
  font-family: var(--serif-light);
  font-size: clamp(17px, 2.2vw, 22px);
  font-weight: 300;
  line-height: 1.7;
  color: rgba(255, 244, 230, 0.92);
  letter-spacing: 0.01em;
  max-width: 540px;
  margin: 0 auto 36px;
}
.message p { font-style: italic; }
.message p.spacer { font-size: 0.4em; }

.opened-footer {
  margin-top: 24px;
}

.signoff {
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  color: rgba(255, 244, 230, 0.85);
  margin-bottom: 6px;
}
.signature {
  font-family: var(--script);
  font-size: clamp(36px, 5vw, 52px);
  font-weight: 600;
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 28px;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: transparent;
  border: 1px solid rgba(244, 207, 138, 0.35);
  color: rgba(255, 244, 230, 0.75);
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.ghost-btn:hover {
  color: var(--gold-bright);
  border-color: var(--gold);
}

/* ----- Reveal animations ----- */
.reveal-line {
  display: block;
  overflow: hidden;
}
.reveal-line > span {
  display: inline-block;
  transform: translateY(110%);
  opacity: 0;
  transition: transform 1.1s cubic-bezier(.2, .8, .2, 1), opacity 0.8s ease;
}
.opened-card.shown .reveal-line > span {
  transform: translateY(0);
  opacity: 1;
}

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.9s ease, transform 0.9s ease;
}
.opened-card.shown .reveal {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger delays */
.opened-card.shown .overline.reveal           { transition-delay: 0.15s; }
.opened-card.shown .opened-title .reveal-line:nth-child(1) > span { transition-delay: 0.30s; }
.opened-card.shown .opened-title .reveal-line:nth-child(2) > span { transition-delay: 0.55s; }
.opened-card.shown .message .reveal-line:nth-child(1) > span { transition-delay: 0.95s; }
.opened-card.shown .message .reveal-line:nth-child(2) > span { transition-delay: 1.10s; }
.opened-card.shown .message .reveal-line:nth-child(3) > span { transition-delay: 1.25s; }
.opened-card.shown .message .reveal-line:nth-child(4) > span { transition-delay: 1.40s; }
.opened-card.shown .message .reveal-line:nth-child(5) > span { transition-delay: 1.55s; }
.opened-card.shown .message .reveal-line:nth-child(6) > span { transition-delay: 1.70s; }
.opened-card.shown .message .reveal-line:nth-child(8) > span { transition-delay: 1.95s; }
.opened-card.shown .message .reveal-line:nth-child(9) > span { transition-delay: 2.10s; }
.opened-card.shown .signoff.reveal            { transition-delay: 2.45s; }
.opened-card.shown .signature.reveal          { transition-delay: 2.65s; }

/* ----- Audio toggle ----- */
.audio-toggle {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 50;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 8, 22, 0.5);
  border: 1px solid rgba(244, 207, 138, 0.3);
  color: rgba(255, 244, 230, 0.75);
  border-radius: 50%;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.25s ease;
}
.audio-toggle:hover {
  color: var(--gold-bright);
  border-color: var(--gold);
  background: rgba(244, 207, 138, 0.1);
}
.audio-toggle .hidden { display: none; }

.hidden { display: none !important; }

/* ----- Reduced motion ----- */
@media (prefers-reduced-motion: reduce) {
  .closed-card { animation: none; }
  .loading-flower { animation: none; }
  .card-glow { animation: none; }
  .btn-shimmer { animation: none; }
  .reveal-line > span { transition-duration: 0.4s; }
}

/* ----- Mobile tweaks ----- */
@media (max-width: 600px) {
  .card-content { padding: 48px 24px; }
  .opened-inner { padding: 40px 24px; }
  .audio-toggle { top: 14px; right: 14px; }
}
