:root {
  --bg: #fdf3f4;
  --bg-2: #fbe4e8;
  --pink: #f2a7b6;
  --pink-deep: #e0788f;
  --rose: #c9506d;
  --leaf: #8fbf6a;
  --ink: #4a2d35;
  --ink-soft: #7d5a63;
  --paper: #fffaf8;
  --shadow: 0 10px 30px rgba(201, 80, 109, .15);
  --radius: 22px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Nunito", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
em { font-style: italic; color: var(--rose); }
.hand { font-family: "Caveat", cursive; }

/* latar tetap (aman untuk iOS Safari, tanpa background-attachment: fixed) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse at 15% 0%, #ffe9ee 0%, transparent 55%),
    radial-gradient(ellipse at 100% 40%, #fde2e8 0%, transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}

/* ---------- hati melayang ---------- */
.petals { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; contain: strict; }
.petal {
  position: absolute;
  top: -40px;
  opacity: .7;
  animation: fall linear forwards;
  will-change: transform;
  backface-visibility: hidden;
}
@keyframes fall {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg); }
  100% { transform: translate3d(var(--drift, 40px), 110vh, 0) rotate(var(--spin, 360deg)); }
}

/* ---------- pembuka ---------- */
.opening {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: calc(24px + var(--safe-t)) 24px calc(24px + var(--safe-b));
  text-align: center;
  transition: opacity .8s ease, visibility .8s;
}
.opening.gone { opacity: 0; visibility: hidden; }

.envelope {
  position: relative;
  width: min(78vw, 320px);
  aspect-ratio: 3 / 2;
  cursor: pointer;
  animation: bob 3s ease-in-out infinite;
  will-change: transform;
  outline: none;
  perspective: 800px;
}
.envelope:focus-visible { outline: 3px dashed var(--pink-deep); outline-offset: 8px; border-radius: 8px; }
@keyframes bob { 50% { transform: translateY(-8px); } }

.env-back, .env-front, .env-flap { position: absolute; inset: 0; border-radius: 10px; }
.env-back { background: #f6c3cd; box-shadow: 0 18px 30px rgba(201, 80, 109, .25); }
.env-letter {
  position: absolute;
  left: 8%; right: 8%; top: 10%; bottom: 8%;
  background: var(--paper);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 8%;
  font-size: clamp(22px, 6vw, 30px);
  color: var(--rose);
  transition: transform .9s cubic-bezier(.2, .8, .2, 1) .35s;
  z-index: 1;
}
.env-front {
  background: linear-gradient(160deg, #f9d3db 0%, #f5c2cd 100%);
  clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%);
  z-index: 2;
}
.env-flap {
  background: linear-gradient(to bottom, #eeaab8 0%, #f0b3c0 100%);
  clip-path: polygon(0 0, 100% 0, 50% 58%);
  transform-origin: top center;
  transition: transform .6s ease;
  z-index: 3;
}
.env-seal {
  position: absolute;
  left: 50%; top: 52%;
  transform: translate(-50%, -50%);
  font-size: clamp(30px, 9vw, 40px);
  z-index: 4;
  transition: opacity .3s;
}
.envelope.open { animation: none; }
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 0; }
.envelope.open .env-seal { opacity: 0; }
.envelope.open .env-letter { transform: translateY(-55%); }

.opening-text {
  font-family: "Fraunces", serif;
  font-size: clamp(20px, 5.5vw, 28px);
  margin: 18px 0 0;
}
.opening-text b { color: var(--rose); font-weight: 600; }
.opening-hint {
  margin: 0;
  font-size: 14px;
  color: var(--ink-soft);
  letter-spacing: .08em;
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .4; } }

/* ---------- utama ---------- */
.main {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: calc(28px + var(--safe-t)) calc(20px + var(--safe-r)) calc(40px + var(--safe-b)) calc(20px + var(--safe-l));
}
.main.show { animation: rise 1s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(20px); } }

.hero {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-bottom: 20px;
}
.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: .22em;
  font-size: clamp(11px, 2.8vw, 13px);
  color: var(--ink-soft);
  font-weight: 700;
}
.name {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: clamp(42px, 12vw, 84px);
  line-height: 1.02;
  margin: 10px 0 6px;
}
.nim {
  margin: 0 0 clamp(24px, 6vw, 40px);
  font-size: 13px;
  letter-spacing: .3em;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, .6);
  padding: 4px 12px;
  border-radius: 99px;
}

.polaroids {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  max-width: 640px;
}
.polaroid {
  margin: 0;
  background: #fff;
  padding: 10px 10px 0;
  border-radius: 6px;
  box-shadow: var(--shadow), 0 2px 6px rgba(0, 0, 0, .06);
  width: 52%;
  transition: transform .4s ease;
}
.polaroid img { width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 3px; }
.polaroid figcaption {
  font-size: clamp(17px, 4.4vw, 22px);
  color: var(--ink);
  padding: 8px 4px 10px;
  line-height: 1.1;
}
.p1 { transform: rotate(-6deg) translateX(8%); z-index: 1; }
.p2 { transform: rotate(5deg) translate(-8%, 18px); z-index: 2; }
.p1 img { object-position: 60% 40%; }
.p2 img { object-position: 60% 40%; }
@media (hover: hover) {
  .polaroid:hover { transform: rotate(0) scale(1.04); z-index: 3; }
}

.typed-wrap {
  min-height: 3.2em;
  max-width: 520px;
  margin: clamp(36px, 8vw, 56px) auto 0;
  font-family: "Fraunces", serif;
  font-style: italic;
  font-size: clamp(17px, 4.4vw, 22px);
  line-height: 1.5;
  color: var(--ink);
  padding: 0 6px;
}
.caret { color: var(--pink-deep); animation: blink 1s steps(1) infinite; font-style: normal; }
@keyframes blink { 50% { opacity: 0; } }

.scroll-cue {
  margin-top: 22px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--ink-soft);
  font-size: 12px;
  letter-spacing: .2em;
  text-decoration: none;
  animation: bob 2.4s ease-in-out infinite;
}

/* ---------- section ---------- */
.section {
  padding: clamp(48px, 10vw, 80px) 0;
  text-align: center;
}
.title {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: clamp(28px, 7vw, 44px);
  line-height: 1.15;
  margin: 0 0 10px;
}
.sub { margin: 0 auto 28px; color: var(--ink-soft); max-width: 440px; font-size: clamp(15px, 3.8vw, 17px); }

.reveal { opacity: 0; transform: translateY(24px); transition: opacity .8s ease, transform .8s ease; }
.reveal.in { opacity: 1; transform: none; }
.section { content-visibility: auto; contain-intrinsic-size: auto 600px; }

/* kartu semangat */
.flower-card {
  background: rgba(255, 255, 255, .88);
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 560px;
  margin: 0 auto;
  padding: clamp(28px, 6vw, 44px) clamp(20px, 5vw, 40px);
}
.flower-btn {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0%, #fde3e8 70%);
  box-shadow: 0 8px 20px rgba(224, 120, 143, .3), inset 0 -4px 10px rgba(242, 167, 182, .35);
  display: grid; place-items: center;
  margin: 0 auto 20px;
  transition: transform .15s ease;
}
.flower-btn:active { transform: scale(.92); }
.flower { font-size: 48px; display: inline-block; }
.flower.spin { animation: wiggle .6s ease; }
@keyframes wiggle {
  25% { transform: rotate(-18deg) scale(1.15); }
  60% { transform: rotate(14deg) scale(1.05); }
}
.quote {
  font-family: "Fraunces", serif;
  font-size: clamp(19px, 5vw, 26px);
  line-height: 1.45;
  margin: 0;
  min-height: 3em;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .3s ease;
}
.quote.fade { opacity: 0; }
.quote-count { margin: 14px 0 0; font-size: 13px; color: var(--ink-soft); min-height: 1.2em; }

/* alasan */
.reasons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  text-align: left;
}
.reason {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: 0 6px 18px rgba(201, 80, 109, .08);
  border: 1px solid #f8dde3;
}
.r-icon { font-size: 28px; }
.reason h3 { font-family: "Fraunces", serif; font-size: 19px; margin: 10px 0 6px; font-weight: 600; }
.reason p { margin: 0; color: var(--ink-soft); line-height: 1.6; font-size: 15px; }

/* pelukan */
.hug-btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 16px 30px;
  min-height: 54px;
  border-radius: 99px;
  font-weight: 700;
  font-size: 17px;
  color: #fff;
  background: linear-gradient(135deg, var(--pink-deep), var(--rose));
  box-shadow: 0 10px 24px rgba(201, 80, 109, .35);
  transition: transform .15s ease, box-shadow .15s ease;
}
.hug-btn:active { transform: scale(.95); box-shadow: 0 4px 12px rgba(201, 80, 109, .35); }
.doa-text {
  font-family: "Fraunces", serif;
  font-style: italic;
  font-size: clamp(17px, 4.4vw, 21px);
  color: var(--rose);
  max-width: 440px;
  margin: 20px auto 0;
  min-height: 1.5em;
  line-height: 1.45;
  transition: opacity .25s ease;
}
.doa-text.fade { opacity: 0; }
.hug-count { margin: 12px 0 0; color: var(--ink-soft); font-size: 14px; }

.burst {
  position: fixed;
  pointer-events: none;
  z-index: 50;
  font-size: 24px;
  animation: burst 1.1s ease-out forwards;
}
@keyframes burst {
  0%   { transform: translate(-50%, -50%) scale(.4); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1.2); opacity: 0; }
}

/* foto favorit */
.feature {
  margin: 8px auto 0;
  max-width: 380px;
  width: 86%;
  background: #fff;
  padding: 12px 12px 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  rotate: -2deg;
}
.feature img { width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 4px; }
.feature figcaption { font-size: clamp(19px, 5vw, 24px); padding: 10px 4px 14px; color: var(--ink); }

/* surat */
.letter {
  max-width: 620px;
  margin: 0 auto;
  text-align: left;
  background:
    repeating-linear-gradient(to bottom, transparent 0 31px, #f6dce2 31px 32px),
    var(--paper);
  border-radius: 6px;
  padding: clamp(28px, 6vw, 48px) clamp(22px, 6vw, 48px);
  box-shadow: var(--shadow);
  position: relative;
  line-height: 32px;
  font-size: clamp(15px, 3.9vw, 17px);
}
.letter::before {
  content: "🌷";
  position: absolute;
  top: -18px; right: 22px;
  font-size: 34px;
  transform: rotate(14deg);
}
.letter p { margin: 0 0 16px; }
.letter-greet { font-size: 30px; color: var(--rose); margin-bottom: 8px !important; }
.letter-sign { font-size: 24px; text-align: right; color: var(--rose); margin: 20px 0 0 !important; }

/* footer */
.footer { text-align: center; padding: 30px 0 10px; color: var(--ink-soft); font-size: 14px; }
.footer p { margin: 0 0 10px; }
.replay { font-size: 14px; color: var(--rose); text-decoration: underline; text-underline-offset: 4px; padding: 10px; }

/* musik */
.music-btn {
  position: fixed;
  right: calc(16px + var(--safe-r));
  bottom: calc(16px + var(--safe-b));
  z-index: 20;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: #fff;
  color: var(--rose);
  font-size: 22px;
  box-shadow: var(--shadow);
  display: grid; place-items: center;
}
.music-btn.on { background: var(--pink); color: #fff; }
@keyframes spinSlow { to { transform: rotate(360deg); } }

/* ---------- responsif ---------- */
@media (max-width: 600px) {
  .reasons { grid-template-columns: 1fr; }
  .polaroid { width: 56%; padding: 7px 7px 0; }
}

/* iPad / tablet */
@media (min-width: 700px) {
  .polaroid { width: 46%; }
  .p2 { transform: rotate(5deg) translate(-8%, 30px); }
}

/* HP landscape (layar pendek) */
@media (orientation: landscape) and (max-height: 500px) {
  .hero { min-height: auto; padding-top: 20px; }
  .polaroids { max-width: 420px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}
