/* ─────────────────────────────────────────────────────────────
   Happy Mother's Day, Oma — design system
   ───────────────────────────────────────────────────────────── */

:root {
  /* palette */
  --bg:        #f5ede0;
  --bg-deep:   #ebdfca;
  --paper:     #fffaf2;
  --paper-edge:#f3e7d2;
  --ink:       #2c2520;
  --ink-soft:  #5b4f44;
  --ink-faint: #8a7c6e;
  --rose:      #c47a78;
  --rose-deep: #a85a58;
  --terra:     #b8806a;
  --gold:      #a88860;
  --sage:      #8fa089;

  /* type */
  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --body:  "Lora", "Iowan Old Style", Georgia, serif;
  --script:"Pinyon Script", "Snell Roundhand", cursive;

  /* easings */
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
}

/* ── reset ──────────────────────────────────────────────────── */
*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

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

body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;

  /* paper texture — subtle warm grain */
  background-image:
    radial-gradient(at 20% 0%, rgba(255, 230, 200, .55) 0%, transparent 55%),
    radial-gradient(at 80% 100%, rgba(212, 168, 143, .35) 0%, transparent 50%),
    radial-gradient(at 50% 50%, rgba(255, 255, 255, .4) 0%, transparent 70%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  background-attachment: fixed;
  min-height: 100dvh;
}

body::before {
  /* fine grain noise */
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: .55;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.18 0 0 0 0 0.14 0 0 0 0 0.10 0 0 0 0.08 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* lock scroll until card is opened */
body.locked { overflow: hidden; }

/* ── floating petals/hearts background ─────────────────────── */
.petals {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}
.petals::before,
.petals::after {
  content: "";
  position: absolute;
  inset: -10%;
  background-image:
    radial-gradient(circle at 12% 20%, rgba(196,122,120,.18) 0 3px, transparent 4px),
    radial-gradient(circle at 78% 35%, rgba(196,122,120,.12) 0 2px, transparent 3px),
    radial-gradient(circle at 30% 70%, rgba(168,136,96,.16) 0 2.5px, transparent 4px),
    radial-gradient(circle at 85% 80%, rgba(196,122,120,.16) 0 3px, transparent 4px),
    radial-gradient(circle at 55% 50%, rgba(143,160,137,.12) 0 2px, transparent 3px);
  animation: drift 28s linear infinite;
}
.petals::after {
  animation-duration: 42s;
  animation-direction: reverse;
  opacity: .55;
  transform: translateY(-30%);
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(-3%, 8%, 0); }
}

/* ── ENVELOPE / cover ──────────────────────────────────────── */
.screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 3;
}

.envelope {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, var(--bg) 0%, var(--bg-deep) 80%);
  z-index: 50;
  transition: opacity .9s var(--ease-in-out), transform .9s var(--ease-in-out);
}

.envelope.open {
  opacity: 0;
  transform: scale(1.05);
  pointer-events: none;
}

.env-stage {
  width: min(86vw, 380px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
}

.env-card {
  position: relative;
  width: 100%;
  aspect-ratio: 1.55 / 1;
  perspective: 1200px;
  filter: drop-shadow(0 16px 28px rgba(70, 40, 25, .28));
}

/* envelope back: the body rectangle (lighter, recessed) */
.env-back {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background: linear-gradient(180deg, #f5e2bc 0%, #e6cf9f 100%);
  box-shadow:
    inset 0 0 0 1px rgba(120, 90, 60, .22),
    inset 0 -2px 8px rgba(120, 90, 60, .15);
  overflow: hidden;
}

/* V-fold lines on the bottom half — diagonals from bottom corners up to center */
.env-back::before,
.env-back::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 50%;
  height: 50%;
  background:
    linear-gradient(to top right,
      transparent calc(50% - 0.6px),
      rgba(120, 80, 40, .35) 50%,
      transparent calc(50% + 0.6px));
}
.env-back::before { left: 0; }
.env-back::after  {
  right: 0;
  background:
    linear-gradient(to top left,
      transparent calc(50% - 0.6px),
      rgba(120, 80, 40, .35) 50%,
      transparent calc(50% + 0.6px));
}

/* the flap (triangle on top half) — darker than the back for clear edge */
.env-flap {
  position: absolute;
  inset: 0 0 50% 0;
  background: linear-gradient(180deg, #ecd49b 0%, #c9a661 100%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform .9s var(--ease-in-out);
  z-index: 3;
  filter:
    drop-shadow(0 1px 0 rgba(255, 240, 200, .55))
    drop-shadow(0 3px 4px rgba(80, 50, 20, .28));
  /* subtle inner highlight along the top edge */
  box-shadow: inset 0 1px 0 rgba(255, 245, 215, .5);
}

/* shading along the diagonal edges of the flap to deepen the fold */
.env-flap::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 30%, rgba(120, 80, 40, .22) 100%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.env-card.opening .env-flap {
  transform: rotateX(-180deg);
}

/* wax seal */
.env-seal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 22%;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #d28b85 0%, #a85a58 45%, #7d3938 100%);
  display: grid;
  place-items: center;
  box-shadow:
    0 2px 4px rgba(80, 30, 30, .35),
    inset 0 -3px 6px rgba(60, 20, 20, .35),
    inset 0 2px 3px rgba(255, 200, 195, .35);
  z-index: 4;
  transition: transform .6s var(--ease-out), opacity .6s var(--ease-out);
}

.env-seal svg {
  width: 55%;
  height: 55%;
  fill: rgba(255, 230, 220, .75);
}

.env-card.opening .env-seal {
  transform: translate(-50%, -50%) scale(1.1) rotate(8deg);
  opacity: 0;
}

/* "For Oma" inscription */
.env-for {
  position: absolute;
  bottom: 14%;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--script);
  font-size: clamp(1.6rem, 6vw, 2rem);
  color: var(--ink-soft);
  z-index: 2;
  letter-spacing: .01em;
  white-space: nowrap;
  text-shadow: 0 1px 0 rgba(255, 250, 240, .5);
}

/* tap to open button */
.open-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--ink-soft);
  font-family: var(--body);
  font-size: .82rem;
  letter-spacing: .25em;
  text-transform: uppercase;
  cursor: pointer;
  padding: .5rem 1rem;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  opacity: .9;
  animation: pulse 2.4s ease-in-out infinite;
  transition: opacity .3s;
  -webkit-tap-highlight-color: transparent;
}
.open-btn:hover { opacity: 1; }
.open-btn-arrow {
  font-size: 1rem;
  letter-spacing: 0;
  opacity: .6;
  animation: bounce 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: .65; }
  50%      { opacity: 1; }
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}

/* ── CARD ──────────────────────────────────────────────────── */
.card {
  position: relative;
  z-index: 3;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 1.25rem 5rem;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1.1s var(--ease-out), transform 1.1s var(--ease-out);
  transition-delay: .2s;
}
.card.visible {
  opacity: 1;
  transform: translateY(0);
}

/* HERO */
.hero {
  padding: 4.5rem 0 2.5rem;
  text-align: center;
}

.kicker {
  font-family: var(--body);
  font-style: italic;
  font-size: .8rem;
  letter-spacing: .35em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 1.5rem;
}

.title {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.05;
  color: var(--ink);
}
.title-pre {
  display: block;
  font-size: clamp(1.6rem, 6.5vw, 2.4rem);
  font-style: italic;
  font-weight: 400;
  color: var(--ink-soft);
  letter-spacing: .005em;
}
.title-name {
  display: block;
  margin-top: .15em;
  font-size: clamp(4.4rem, 22vw, 7rem);
  font-weight: 500;
  letter-spacing: -.02em;
  background: linear-gradient(180deg, var(--ink) 0%, var(--rose-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin-top: 1.4rem;
  font-style: italic;
  font-size: 1rem;
  color: var(--ink-faint);
  letter-spacing: .02em;
}

.hero-rule {
  margin: 2rem auto 0;
  width: 80px;
  height: 12px;
  position: relative;
}
.hero-rule::before,
.hero-rule::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 28px;
  height: 1px;
  background: var(--ink-faint);
  opacity: .4;
}
.hero-rule::before { left: 0; }
.hero-rule::after  { right: 0; }
.hero-rule span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--rose);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 3px rgba(196, 122, 120, .15);
}

/* PHOTO */
.photo {
  margin: 2rem auto 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  user-select: none;
}

.photo-mat {
  background: var(--paper);
  padding: 1rem 1rem 1.25rem;
  border-radius: 2px;
  box-shadow:
    0 1px 1px rgba(60, 40, 25, .08),
    0 12px 26px -8px rgba(60, 40, 25, .25),
    0 30px 60px -20px rgba(60, 40, 25, .25),
    inset 0 0 0 1px rgba(120, 90, 60, .07);
  position: relative;
  max-width: 92%;
  width: 100%;
}

.photo-mat::before {
  /* deckled edge / inner mat */
  content: "";
  position: absolute;
  inset: .55rem .55rem 1.85rem .55rem;
  border: 1px solid rgba(120, 90, 60, .12);
  pointer-events: none;
}

.photo-frame {
  position: relative;
  overflow: hidden;
  border-radius: 1px;
  background: #ddd1bb;
  cursor: pointer;
  transition: transform .35s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.photo-frame:active { transform: scale(.99); }

.photo-frame img {
  display: block;
  width: 100%;
  height: auto;
  filter: contrast(1.02) saturate(1.04);
}

/* placeholder shown only when family.jpg fails to load */
.photo-placeholder {
  display: none;
  aspect-ratio: 4 / 3;
  background:
    repeating-linear-gradient(
      135deg,
      rgba(120, 90, 60, .04) 0 14px,
      rgba(120, 90, 60, .08) 14px 28px
    ),
    var(--paper-edge);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  color: var(--ink-faint);
  text-align: center;
  padding: 2rem;
}
.photo-frame.photo-missing .photo-placeholder { display: flex; }
.ph-icon { font-size: 2rem; opacity: .5; }
.ph-line {
  font-size: .72rem;
  letter-spacing: .3em;
  text-transform: uppercase;
}
.ph-path {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .8rem;
  background: rgba(120, 90, 60, .08);
  padding: .25rem .55rem;
  border-radius: 3px;
  color: var(--ink-soft);
}

.photo-shine {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0) 40%, rgba(255, 255, 255, .22) 50%, rgba(255, 255, 255, 0) 60%);
  background-size: 250% 100%;
  background-position: 100% 0;
  opacity: 0;
  transition: opacity .3s;
}
.photo-frame:hover .photo-shine { opacity: 1; animation: shine 1.6s ease-out; }
@keyframes shine {
  to { background-position: -150% 0; }
}

.caption {
  display: block;
  margin-top: 1rem;
  font-family: var(--script);
  font-size: 1.4rem;
  line-height: 1.3;
  text-align: center;
  color: var(--ink-soft);
}
.cap-line { display: block; }

.photo-hint {
  margin-top: 1rem;
  font-size: .68rem;
  letter-spacing: .35em;
  text-transform: uppercase;
  color: var(--ink-faint);
  opacity: .55;
  animation: fadepulse 3s ease-in-out infinite;
}
@keyframes fadepulse {
  0%, 100% { opacity: .35; }
  50%      { opacity: .8; }
}
.photo.tapped .photo-hint { opacity: 0; transition: opacity .5s; }

/* heart burst from photo */
.burst-heart {
  position: fixed;
  pointer-events: none;
  font-size: 1.5rem;
  z-index: 40;
  will-change: transform, opacity;
  user-select: none;
}

/* LETTER */
.letter {
  margin: 4rem auto 3rem;
  max-width: 32rem;
  padding: 0 1rem;
  text-align: center;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.15rem, 4.4vw, 1.35rem);
  line-height: 1.65;
  color: var(--ink);
}

.letter p {
  margin: .35rem 0;
}

.letter em {
  font-style: italic;
  color: var(--rose-deep);
  font-weight: 500;
}

.letter .pause {
  margin-top: 2.2rem;
}

.letter .lead {
  font-style: italic;
  color: var(--ink-soft);
  margin-bottom: 1.4rem;
}

.letter .big {
  margin-top: 2.6rem;
  font-size: clamp(1.4rem, 5.5vw, 1.75rem);
  font-weight: 500;
  line-height: 1.4;
}

.letter-mark {
  display: flex;
  justify-content: center;
  gap: .5rem;
  margin: 0 auto 2rem;
}
.letter-mark.end { margin: 2.5rem auto 0; }
.letter-mark span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--rose);
  opacity: .55;
}
.letter-mark span:nth-child(2) { background: var(--gold); opacity: .75; }
.letter-mark span:nth-child(3) { background: var(--sage); }

/* scroll-reveal */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 1s var(--ease-out), transform 1s var(--ease-out);
}
.reveal.in {
  opacity: 1;
  transform: translateY(0);
}

/* HEART SECTION */
.heart-section {
  margin: 4rem auto 3rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.heart-prompt {
  font-family: var(--body);
  font-style: italic;
  font-size: .95rem;
  color: var(--ink-faint);
  letter-spacing: .03em;
}

.heart-btn {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  width: 88px;
  height: 88px;
  position: relative;
  display: grid;
  place-items: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.heart-btn svg {
  width: 64px;
  height: 64px;
  fill: var(--rose);
  filter: drop-shadow(0 6px 12px rgba(168, 90, 88, .3));
  transition: transform .15s var(--ease-out), fill .25s;
  animation: heartIdle 2.6s ease-in-out infinite;
}

@keyframes heartIdle {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

.heart-btn.holding svg {
  animation: heartBeat .55s ease-in-out infinite;
  fill: var(--rose-deep);
}

@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  20%      { transform: scale(1.18); }
  40%      { transform: scale(1.02); }
  60%      { transform: scale(1.22); }
}

.heart-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--rose);
  opacity: 0;
  transform: scale(.7);
  pointer-events: none;
}

.heart-btn.holding .heart-ring {
  animation: ring 1s ease-out infinite;
}

@keyframes ring {
  0%   { opacity: .55; transform: scale(.7); }
  100% { opacity: 0;   transform: scale(1.5); }
}

.heart-count {
  font-family: var(--body);
  font-style: italic;
  font-size: .85rem;
  color: var(--rose-deep);
  min-height: 1.2em;
  letter-spacing: .02em;
  opacity: 0;
  transition: opacity .4s;
}
.heart-count.visible { opacity: 1; }

/* SIGNOFF */
.signoff {
  margin: 5rem auto 2rem;
  text-align: center;
  color: var(--ink-soft);
}

.signoff-line {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--ink-soft);
}

.signoff-name {
  font-family: var(--script);
  font-size: clamp(2rem, 8vw, 2.8rem);
  color: var(--ink);
  line-height: 1.25;
  margin-top: .35rem;
}

.signoff-name .amp {
  color: var(--rose);
  font-style: italic;
}

.signoff-date {
  margin-top: 1rem;
  font-size: .72rem;
  letter-spacing: .35em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.signoff-rule {
  width: 40px;
  height: 1px;
  background: var(--ink-faint);
  opacity: .3;
  margin: 1.75rem auto 1rem;
}

.signoff-tiny {
  font-size: .7rem;
  letter-spacing: .25em;
  text-transform: uppercase;
  color: var(--ink-faint);
  opacity: .55;
}

/* desktop polish */
@media (min-width: 720px) {
  .card { padding: 0 2rem 6rem; }
  .hero { padding: 6rem 0 3rem; }
  .photo-mat { padding: 1.5rem 1.5rem 1.75rem; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  .petals { display: none; }
}
