/* ===== Variables ===== */
:root {
  --bg-deep: #0a0612;
  --bg-mid: #1a0f2e;
  --gold: #d4a853;
  --gold-light: #f0d78c;
  --gold-dark: #a67c2e;
  --rose: #f8b4c8;
  --rose-deep: #e895aa;
  --rose-soft: #ffe4ec;
  --rose-pale: #ffd6e4;
  --cream: #faf6f0;
  --gold-glow: rgba(212, 168, 83, 0.45);
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Montserrat', sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --panel-pad: clamp(1rem, 4vw, 2rem);
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: radial-gradient(ellipse at 50% -10%, var(--bg-mid) 0%, var(--bg-deep) 65%);
  color: var(--cream);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ===== Background ===== */
.stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(1px 1px at 12% 18%, rgba(255,255,255,0.55), transparent),
    radial-gradient(1.5px 1.5px at 78% 12%, rgba(255,255,255,0.45), transparent),
    radial-gradient(1px 1px at 42% 72%, rgba(255,255,255,0.35), transparent),
    radial-gradient(1px 1px at 88% 68%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1.5px 1.5px at 22% 88%, rgba(255,255,255,0.5), transparent);
  animation: twinkle 5s ease-in-out infinite alternate;
}

@keyframes twinkle {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 200;
}

/* ===== Scroll progress ===== */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 100;
  background: rgba(255, 255, 255, 0.08);
}

.scroll-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--rose), var(--gold));
  box-shadow: 0 0 8px var(--gold-glow);
  transition: width 0.1s linear;
}

/* ===== Story scroll container ===== */
.story {
  position: relative;
  z-index: 1;
}

.panel {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding:
    calc(var(--panel-pad) + var(--safe-top))
    var(--panel-pad)
    calc(var(--panel-pad) + 3.5rem + var(--safe-bottom))
    var(--panel-pad);
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

html {
  scroll-snap-type: y proximity;
}

/* ===== Reveal base ===== */
.reveal {
  opacity: 0;
  transform: translateY(40px);
  will-change: transform, opacity;
}

/* ===== Intro ===== */
.panel-intro {
  text-align: center;
}

.intro-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold-light);
  margin-bottom: 1rem;
}

.intro-title {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 10vw, 4rem);
  font-weight: 700;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--gold-light), var(--rose-pale), var(--gold), var(--gold-light));
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
}

.intro-greeting {
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 4.2vw, 1.3rem);
  font-style: italic;
  font-weight: 400;
  color: var(--rose-pale);
  line-height: 1.55;
  max-width: 22rem;
  margin: 0 auto 1.25rem;
}

.intro-sub {
  font-size: clamp(0.85rem, 3.5vw, 1rem);
  font-weight: 300;
  color: rgba(250, 246, 240, 0.65);
  margin-bottom: 2rem;
}

.scroll-cue {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  animation: cueBounce 2s ease-in-out infinite;
}

.scroll-cue-text {
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold-light);
  opacity: 0.8;
}

.scroll-cue-line {
  width: 1px;
  height: 40px;
  background: linear-gradient(180deg, transparent, var(--gold-light));
}

.scroll-cue-arrow {
  font-size: 1.2rem;
  color: var(--gold-light);
  opacity: 0.7;
}

@keyframes cueBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(8px); }
}

/* ===== Gift row (photo + text) ===== */
.gift-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
  max-width: 420px;
}

.gift-visual {
  width: 100%;
  display: flex;
  justify-content: center;
}

.gift-text {
  width: 100%;
  text-align: center;
  padding: 1.25rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.gift-text h2 {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 5vw, 1.75rem);
  font-weight: 600;
  color: var(--rose-pale);
  margin-bottom: 0.6rem;
}

.gift-text p {
  font-size: clamp(0.85rem, 3.5vw, 0.95rem);
  font-weight: 300;
  line-height: 1.7;
  color: rgba(250, 246, 240, 0.82);
}

/* ===== Cutout photos (без фона) ===== */
.cutout-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rose-cutout {
  width: min(280px, 78vw);
  aspect-ratio: 3 / 4;
}

.bag-cutout {
  width: min(320px, 88vw);
  aspect-ratio: 1 / 1;
}

.cutout-glow {
  position: absolute;
  inset: 5%;
  border-radius: 50%;
  filter: blur(28px);
  opacity: 0;
  pointer-events: none;
  z-index: 0;
}

.rose-glow {
  background: radial-gradient(ellipse, rgba(248, 180, 200, 0.55) 0%, rgba(232, 149, 170, 0.2) 45%, transparent 70%);
}

.bag-glow {
  background: radial-gradient(ellipse, rgba(212, 168, 83, 0.35) 0%, rgba(240, 215, 140, 0.15) 50%, transparent 70%);
}

.cutout-photo {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  mix-blend-mode: screen;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.45));
}

/* ===== Photo frames (portrait) ===== */
.photo-frame {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  background: #fff;
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.1);
}

.portrait-frame {
  width: min(280px, 78vw);
  aspect-ratio: 3 / 4;
}

.gift-photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.portrait-photo {
  object-fit: cover;
  object-position: center top;
}

  position: absolute;
  inset: -20%;
  background: radial-gradient(ellipse at 50% 60%, rgba(248, 180, 200, 0.3), transparent 65%);
  pointer-events: none;
  z-index: -1;
  opacity: 0;
}

/* ===== Certificate ===== */
.panel-cert {
  justify-content: center;
}

.cert-wrap {
  position: relative;
  width: 100%;
  max-width: min(360px, 92vw);
  min-height: min(480px, 72dvh);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cert-envelope {
  position: absolute;
  width: 100%;
  max-width: 300px;
  height: 200px;
  z-index: 3;
  transform-origin: center center;
}

.envelope-back {
  position: absolute;
  inset: 0;
  background: linear-gradient(165deg, #f0e4d6, #dcc8b0);
  border-radius: 6px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.envelope-front {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 65%;
  background: linear-gradient(180deg, #e8d8c8, #dcc8b0);
  clip-path: polygon(0 0, 50% 45%, 100% 0, 100% 100%, 0 100%);
  border-radius: 0 0 6px 6px;
  z-index: 2;
}

.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 55%;
  background: linear-gradient(180deg, #ede0d0, #e0cdb8);
  clip-path: polygon(0 0, 50% 100%, 100% 0);
  transform-origin: top center;
  z-index: 4;
  border-radius: 6px 6px 0 0;
}

.envelope-seal {
  position: absolute;
  top: 52%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  background: radial-gradient(circle, var(--rose) 0%, var(--rose-deep) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #fff;
  box-shadow: 0 4px 16px rgba(232, 149, 170, 0.5);
  z-index: 5;
}

.certificate {
  position: absolute;
  width: 100%;
  z-index: 2;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(50px) scale(0.88);
}

.cert-unfold {
  position: relative;
  transform-style: preserve-3d;
  perspective: 1000px;
}

.cert-fold-left,
.cert-fold-right {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  background: linear-gradient(135deg, #f0e6d8, #e5d5c0);
  z-index: 3;
  pointer-events: none;
  border-radius: 10px;
  opacity: 0;
}

.cert-fold-left {
  left: 0;
  transform-origin: left center;
}

.cert-fold-right {
  right: 0;
  transform-origin: right center;
}

.cert-paper {
  position: relative;
  z-index: 1;
  background: linear-gradient(165deg, #fffef9 0%, #faf3e8 55%, #f3ebe0 100%);
  border-radius: 10px;
  padding: 1rem;
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.38),
    0 0 0 1px rgba(212, 168, 83, 0.25);
  transform-origin: center center;
}

.cert-border {
  position: relative;
  border: 1.5px solid var(--gold);
  border-radius: 6px;
  padding: 0.9rem 0.8rem;
}

.cert-corner {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--gold-dark);
}

.cert-corner.tl { top: 4px; left: 4px; border-right: none; border-bottom: none; }
.cert-corner.tr { top: 4px; right: 4px; border-left: none; border-bottom: none; }
.cert-corner.bl { bottom: 4px; left: 4px; border-right: none; border-top: none; }
.cert-corner.br { bottom: 4px; right: 4px; border-left: none; border-top: none; }

.cert-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.cert-header h1 {
  font-family: var(--font-display);
  font-size: clamp(1rem, 4.2vw, 1.3rem);
  font-weight: 600;
  color: #3d2c1e;
  text-align: center;
  line-height: 1.2;
}

.cert-ornament {
  color: var(--gold);
  font-size: 0.7rem;
  flex-shrink: 0;
}

.cert-divider {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.5rem 0;
}

.cert-divider span:first-child,
.cert-divider span:last-child {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.cert-divider span:nth-child(2) {
  color: var(--gold-dark);
  font-size: 0.45rem;
}

.cert-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: #8a7560;
  text-align: center;
}

.cert-service {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 5vw, 1.5rem);
  font-weight: 700;
  color: var(--rose-deep);
  text-align: center;
  margin: 0.1rem 0;
}

.cert-amount {
  text-align: center;
  margin: 0.6rem 0;
  padding: 0.55rem;
  background: linear-gradient(135deg, rgba(212,168,83,0.12), rgba(212,168,83,0.04));
  border-radius: 8px;
  border: 1px dashed var(--gold);
}

.amount-label {
  display: block;
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: #8a7560;
  margin-bottom: 0.1rem;
}

.amount-value {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 6.5vw, 2rem);
  font-weight: 700;
  color: var(--gold-dark);
}

.cert-datetime {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin: 0.55rem 0;
}

.datetime-item {
  text-align: center;
  padding: 0.45rem 0.3rem;
  background: rgba(232, 149, 170, 0.08);
  border-radius: 6px;
  border: 1px solid rgba(232, 149, 170, 0.2);
}

.dt-label {
  display: block;
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #8a7560;
  margin-bottom: 0.05rem;
}

.dt-value {
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 3.8vw, 1.1rem);
  font-weight: 600;
  color: #3d2c1e;
}

.cert-note {
  font-size: 0.68rem;
  color: #8a7560;
  text-align: center;
  margin-top: 0.4rem;
}

.cert-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(212, 168, 83, 0.2);
}

.cert-sign {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.8rem;
  color: #6b5a48;
}

.cert-num {
  font-size: 0.55rem;
  color: #a09080;
  letter-spacing: 0.08em;
}

/* ===== Greeting ===== */
.panel-greeting {
  justify-content: flex-start;
  padding-top: calc(1rem + var(--safe-top));
}

.greeting-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  width: 100%;
  max-width: 420px;
}

.birthday-photo-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

.greeting-card {
  position: relative;
  width: 100%;
  background: linear-gradient(165deg, rgba(255,255,255,0.09), rgba(255,255,255,0.03));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  padding: 1.5rem 1.2rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
}

.greeting-sparkle {
  position: absolute;
  color: var(--gold);
  font-size: 0.85rem;
  animation: sparkleRotate 3s ease-in-out infinite;
}

.greeting-sparkle.s1 { top: 10px; left: 14px; }
.greeting-sparkle.s2 { top: 14px; right: 16px; animation-delay: 1.5s; }

@keyframes sparkleRotate {
  0%, 100% { opacity: 0.35; transform: rotate(0deg) scale(1); }
  50% { opacity: 1; transform: rotate(180deg) scale(1.15); }
}

.greeting-title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 6.5vw, 2.2rem);
  font-weight: 700;
  text-align: center;
  background: linear-gradient(135deg, var(--gold-light), var(--rose-pale), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
  line-height: 1.15;
  opacity: 0;
}

.greeting-text {
  font-size: clamp(0.84rem, 3.4vw, 0.94rem);
  font-weight: 300;
  line-height: 1.75;
  color: rgba(250, 246, 240, 0.88);
}

.greeting-text p {
  margin-bottom: 0.75rem;
  opacity: 0;
}

.greeting-text p:last-child {
  margin-bottom: 0;
}

.replay-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.85rem 1.5rem;
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold-light);
  font-family: var(--font-body);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  border-radius: 50px;
  cursor: pointer;
  transition: background 0.35s, color 0.35s;
  -webkit-tap-highlight-color: transparent;
}

.replay-btn:active {
  background: var(--gold);
  color: var(--bg-deep);
}

.replay-icon {
  font-size: 1.1rem;
}

/* ===== Progress dots ===== */
.progress-dots {
  position: fixed;
  bottom: calc(1rem + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  z-index: 50;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  transition: all 0.45s var(--ease-out);
}

.dot.active {
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold-glow);
  transform: scale(1.35);
}

.dot.done {
  background: var(--rose);
}

/* ===== Tablet+ layout ===== */
@media (min-width: 600px) {
  .gift-row {
    flex-direction: row;
    max-width: 680px;
    gap: 2rem;
    align-items: center;
  }

  .gift-row-reverse {
    flex-direction: row-reverse;
  }

  .gift-visual,
  .gift-text {
    flex: 1;
  }

  .gift-text {
    text-align: left;
  }

  .rose-cutout {
    width: 240px;
  }

  .bag-cutout {
    width: 280px;
  }

  .greeting-layout {
    max-width: 680px;
    flex-direction: row;
    align-items: flex-start;
    gap: 2rem;
  }

  .birthday-photo-wrap {
    flex: 0 0 auto;
  }

  .greeting-card {
    flex: 1;
  }
}

/* ===== Small phones ===== */
@media (max-width: 360px) {
  .cert-datetime {
    grid-template-columns: 1fr;
  }

  .cert-wrap {
    min-height: 380px;
  }
}

/* ===== Landscape ===== */
@media (max-height: 500px) and (orientation: landscape) {
  .panel {
    min-height: auto;
    padding-top: 1rem;
    padding-bottom: 3.5rem;
  }

  .intro-title {
    font-size: 2rem;
  }

  .rose-cutout,
  .bag-cutout {
    width: min(200px, 40vw);
  }

  .portrait-frame {
    width: min(160px, 30vw);
  }

  .greeting-layout {
    flex-direction: row;
    gap: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}
