@property --bloom {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}

:root {
  --night: #0c0709;
  --ink: #fff6ec;
  --muted: #e8d2c4;
  --gold: #f0d7a8;
  --rose: #e25776;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--night);
  color: var(--ink);
  font-family: "Cormorant Garamond", Georgia, serif;
}

body {
  min-height: 100dvh;
  overflow: hidden;
  cursor: default;
}

#atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.wash,
.vignette,
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.wash {
  z-index: 1;
  background:
    radial-gradient(ellipse 80% 60% at 50% 18%, rgba(88, 28, 48, 0.22), transparent 55%),
    radial-gradient(ellipse 70% 50% at 80% 0%, rgba(42, 28, 62, 0.2), transparent 50%),
    radial-gradient(ellipse 50% 40% at 12% 88%, rgba(28, 48, 36, 0.14), transparent 55%);
  animation: wash-breathe 16s ease-in-out infinite;
}

.vignette {
  z-index: 8;
  box-shadow: inset 0 0 140px 28px rgba(0, 0, 0, 0.45);
}

.grain {
  z-index: 9;
  opacity: 0.11;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

main {
  position: relative;
  z-index: 3;
  min-height: 100dvh;
}

.letter {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8vh 8vw;
  cursor: pointer;
  transition: opacity 1.8s ease, filter 1.8s ease, transform 1.8s ease;
}

.letter.is-leaving {
  opacity: 0;
  filter: blur(10px);
  transform: scale(0.98);
  pointer-events: none;
}

.letter.is-instant .script,
.letter.is-instant .line,
.letter.is-instant .rule {
  transition: none;
  opacity: 1;
  transform: none;
}

.script,
.line {
  margin: 0;
  opacity: 0;
  transform: translateY(18px);
}

.script.is-in,
.line.is-in {
  opacity: 1;
  transform: none;
  filter: none;
}

.script {
  font-family: "Great Vibes", cursive;
  font-weight: 400;
  font-size: clamp(4.6rem, 12vw, 8.4rem);
  line-height: 1;
  letter-spacing: 0.04em;
  color: #fffdf8;
  text-shadow:
    0 0 22px rgba(255, 220, 180, 0.35),
    0 2px 24px rgba(0, 0, 0, 0.35);
  transition: opacity 1.2s ease, transform 1.2s ease;
}

.rule {
  display: block;
  width: min(220px, 42vw);
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  transform: scaleX(0);
  transform-origin: center;
  opacity: 0;
  margin: 0.35em 0 1.35em;
}

.rule.is-in {
  opacity: 0.7;
  transform: scaleX(1);
  transition: transform 1.3s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.8s ease;
}

.line {
  font-weight: 500;
  font-size: clamp(1.55rem, 3.5vw, 2.25rem);
  line-height: 1.45;
  color: #fff8f0;
  margin-top: 0.32em;
  word-spacing: 0.38em;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
  transition: opacity 1.15s ease, transform 1.15s ease;
}

.line.italic {
  font-style: italic;
  color: #d9c4b4;
}

.line.close {
  font-family: "Italiana", "Cormorant Garamond", serif;
  font-size: 0.92rem;
  letter-spacing: 0.46em;
  text-transform: uppercase;
  color: var(--gold);
  margin-top: 1.4em;
}

.garden {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12vh 0 8vh;
  perspective: 1100px;
  opacity: 0;
  transition: opacity 1.6s ease;
}

.garden.is-on {
  opacity: 1;
}

.garden[hidden] {
  display: none;
}

.moon {
  position: absolute;
  top: 8%;
  left: 50%;
  width: 18vw;
  height: 18vw;
  max-width: 220px;
  max-height: 220px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle at 38% 36%, rgba(255, 236, 214, 0.16), rgba(255, 210, 180, 0.03) 46%, transparent 70%);
  filter: blur(2px);
  opacity: 0;
}

.garden.is-on .moon {
  animation: moon-in 2.4s ease forwards;
}

.ground-glow {
  position: absolute;
  left: 50%;
  top: 42%;
  width: min(640px, 80vw);
  height: 320px;
  margin-left: min(-320px, -40vw);
  border-radius: 50%;
  background:
    radial-gradient(ellipse at center, rgba(226, 87, 118, 0.28), rgba(240, 180, 120, 0.08) 42%, transparent 70%);
  filter: blur(10px);
  opacity: 0;
}

.garden.is-on .ground-glow {
  animation: glow-in 2.8s 0.8s ease forwards;
}

.plant {
  position: relative;
  width: 320px;
  height: 540px;
  transform-origin: 50% 100%;
  transform-style: preserve-3d;
}

.plant.is-alive {
  animation: sway 8s ease-in-out infinite;
}

.stem {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 80px;
  height: 390px;
  margin-left: -40px;
  overflow: visible;
}

.stem-path,
.stem-shine {
  fill: none;
  stroke-linecap: round;
  stroke-dasharray: 520;
  stroke-dashoffset: 520;
}

.stem-path {
  stroke: #3d8a58;
  stroke-width: 4;
}

.stem-shine {
  stroke: rgba(210, 245, 196, 0.7);
  stroke-width: 1.4;
  transform: translateX(-1.1px);
}

.garden.is-growing .stem-path,
.garden.is-growing .stem-shine {
  animation: draw-stem 2.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.leaf {
  position: absolute;
  width: 118px;
  height: 58px;
  transform-origin: var(--origin);
  opacity: 0;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.28));
}

.leaf-a {
  --origin: 8% 72%;
  left: 52px;
  top: 300px;
  transform: rotate(-28deg) scale(0.15);
}

.leaf-b {
  --origin: 92% 72%;
  right: 48px;
  top: 248px;
  transform: rotate(24deg) scale(0.15);
}

.leaf-body {
  fill: url(#none);
  fill: #24563a;
}

.leaf svg .leaf-body {
  fill: #24563a;
}

.leaf-a .leaf-body {
  fill: #3f8d57;
}

.leaf-b .leaf-body {
  fill: #2f7348;
}

.leaf-vein {
  fill: none;
  stroke: rgba(226, 255, 214, 0.55);
  stroke-width: 1.2;
}

.garden.is-leafed .leaf-a {
  animation: unfurl-a 1.5s 0.05s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.garden.is-leafed .leaf-b {
  animation: unfurl-b 1.55s 0.22s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.bloom {
  position: absolute;
  left: 50%;
  top: 8px;
  width: 280px;
  height: 260px;
  margin-left: -140px;
  transform: rotate(-8deg) scaleY(0.94);
}

.head,
.sepals,
.stamens {
  position: absolute;
  inset: 0;
}

.head::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 48%;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(90, 16, 36, 0.22), transparent 70%);
  z-index: 40;
  pointer-events: none;
}

.halo {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 220px;
  height: 180px;
  margin: -90px 0 0 -110px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 170, 188, 0.32), rgba(255, 120, 140, 0.08) 46%, transparent 72%);
  opacity: 0;
}

.garden.is-budding .halo,
.garden.is-settled .halo {
  opacity: 1;
  transition: opacity 1.2s ease;
}

.sepal {
  position: absolute;
  left: 50%;
  top: 62%;
  width: 16px;
  height: 26px;
  margin: 0 0 0 -8px;
  transform-origin: 50% 100%;
  background: linear-gradient(180deg, #62b36f 0%, #2f7a46 70%, #1b4d2e 100%);
  clip-path: polygon(50% 0, 86% 42%, 70% 100%, 30% 100%, 14% 42%);
  opacity: 0;
}

.garden.is-budding .sepal {
  animation: sepal-open 1.1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.petal {
  position: absolute;
  left: 50%;
  top: 54%;
  width: var(--w);
  height: var(--h);
  margin-left: calc(var(--w) / -2);
  margin-top: calc(var(--h) * -0.78);
  z-index: var(--z);
  transform-origin: 50% 84%;
  pointer-events: none;
  --bloom: 0;
  will-change: transform;
  transition: --bloom 2.4s cubic-bezier(0.16, 1, 0.3, 1);
  transition-delay: var(--delay, 0s);
  transform:
    translate(
      calc((var(--cx) + (var(--ox) - var(--cx)) * var(--bloom)) * 1px),
      calc((var(--cy) + (var(--oy) - var(--cy)) * var(--bloom)) * 1px)
    )
    rotate(calc((var(--cr) + (var(--or) - var(--cr)) * var(--bloom)) * 1deg))
    scale(calc(var(--cs) + (var(--os) - var(--cs)) * var(--bloom)));
}

.petal svg {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 8px 10px rgba(40, 4, 16, 0.28));
}

.garden.is-open .petal {
  --bloom: 1;
}

.garden.is-settled .stem-path,
.garden.is-settled .stem-shine {
  stroke-dashoffset: 0;
  animation: none;
}

.garden.is-settled .leaf-a,
.garden.is-settled .leaf-b,
.garden.is-settled .sepal,
.garden.is-settled .stamens,
.garden.is-settled .dedication,
.garden.is-settled .moon,
.garden.is-settled .ground-glow {
  animation: none;
  opacity: 1;
}

.garden.is-settled .leaf-a {
  transform: rotate(-28deg) scale(1);
}

.garden.is-settled .leaf-b {
  transform: rotate(24deg) scale(1);
}

.garden.is-settled .sepal {
  transform: rotateZ(var(--rot)) rotateX(58deg) translateY(-16px) scale(1);
}

.garden.is-settled .petal,
.garden.is-settled .halo {
  transition: none;
  --bloom: 1;
  opacity: 1;
}

.garden.is-settled .dedication {
  transform: none;
}

.stamens {
  display: flex;
  align-items: center;
  justify-content: center;
  top: 8%;
  opacity: 0;
  z-index: 12;
}

.garden.is-open .stamens {
  animation: stamens-in 1.2s 0.4s ease forwards;
}

.stamen {
  position: absolute;
  width: 2px;
  height: 10px;
  background: linear-gradient(180deg, #f0d48a, #c48a3a);
  border-radius: 99px;
  transform-origin: 50% 100%;
  box-shadow: 0 0 8px rgba(240, 196, 110, 0.45);
}

.stamen::after {
  content: "";
  position: absolute;
  top: -4px;
  left: 50%;
  width: 6px;
  height: 6px;
  margin-left: -3px;
  border-radius: 50%;
  background: #f6e3a4;
  box-shadow: 0 0 10px rgba(255, 220, 140, 0.8);
}

.heart-glow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 214, 160, 0.55), rgba(196, 59, 92, 0.18) 45%, transparent 70%);
  transform: translateZ(20px);
  animation: heart 2.8s ease-in-out infinite;
  pointer-events: none;
}

.dedication {
  margin: 28px 0 0;
  font-family: "Italiana", serif;
  font-size: 0.78rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0;
  transform: translateY(10px);
}

.garden.is-dedicated .dedication {
  animation: dedicate 1.8s ease forwards;
}

.skip {
  position: fixed;
  right: 28px;
  bottom: 24px;
  z-index: 12;
  border: 0;
  background: transparent;
  color: rgba(244, 232, 220, 0.38);
  font-family: "Italiana", serif;
  font-size: 0.68rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: color 0.3s ease, opacity 0.6s ease;
}

.skip.is-shown {
  opacity: 1;
  pointer-events: auto;
}

.skip:hover {
  color: var(--gold);
}

@keyframes wash-breathe {
  0%,
  100% { opacity: 1; }
  50% { opacity: 0.78; }
}

@keyframes moon-in {
  from { opacity: 0; transform: translateX(-50%) scale(0.92); }
  to { opacity: 1; transform: translateX(-50%) scale(1); }
}

@keyframes glow-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes draw-stem {
  to { stroke-dashoffset: 0; }
}

@keyframes unfurl-a {
  to {
    opacity: 1;
    transform: rotate(-28deg) scale(1);
  }
}

@keyframes unfurl-b {
  to {
    opacity: 1;
    transform: rotate(24deg) scale(1);
  }
}

@keyframes sepal-open {
  from {
    opacity: 0;
    transform: rotateZ(var(--rot)) rotateX(80deg) scale(0.4);
  }
  to {
    opacity: 1;
    transform: rotateZ(var(--rot)) rotateX(58deg) translateY(-16px) scale(1);
  }
}

@keyframes stamens-in {
  from { opacity: 0; transform: translateZ(28px) scale(0.4); }
  to { opacity: 1; transform: translateZ(28px) scale(1); }
}

@keyframes heart {
  0%,
  100% { opacity: 0.55; transform: translateZ(20px) scale(0.92); }
  50% { opacity: 0.95; transform: translateZ(20px) scale(1.08); }
}

@keyframes dedicate {
  to { opacity: 0.82; transform: none; }
}

@keyframes sway {
  0%,
  100% { transform: rotate(-1.15deg); }
  50% { transform: rotate(1.35deg); }
}

@media (max-width: 720px) {
  .plant {
    transform: scale(0.78);
    margin-bottom: -40px;
  }

  .plant.is-alive {
    animation-name: sway-sm;
  }
}

@keyframes sway-sm {
  0%,
  100% { transform: scale(0.78) rotate(-1.15deg); }
  50% { transform: scale(0.78) rotate(1.35deg); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
