@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Playfair+Display:ital,wght@0,500;0,600;1,500&display=swap');

:root {
  --ink: #45152a;
  --wine: #6a1e3d;
  --cream: #fff4f6;
  --pink: #f8cbd9;
  --display: 'Playfair Display', Georgia, serif;
  --sans: 'DM Sans', Arial, sans-serif;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --edge: clamp(1.3rem, 5.5vw, 6.5rem);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; }
body { margin: 0; color: var(--ink); background: var(--cream); font-family: var(--sans); }
body:has(dialog[open]) { overflow: hidden; }
img { display: block; max-width: 100%; }
a { color: inherit; }
button, summary { cursor: pointer; }
button { color: inherit; font: inherit; }
:focus-visible { outline: 3px solid #ae3464; outline-offset: 5px; }

.topbar {
  position: fixed; z-index: 5; top: 0; inset-inline: 0;
  display: flex; align-items: center; justify-content: space-between;
  min-height: 4rem; padding: .55rem var(--edge);
  border-bottom: 1px solid #6a1e3d21; background: #fff2f5f5;
}
.wordmark { font: italic 500 1.38rem var(--display); text-decoration: none; }
.menu { position: relative; }
.menu summary { list-style: none; font-size: .88rem; font-weight: 700; padding: .65rem 0 .65rem .7rem; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary span { margin-left: .28rem; }
.menu nav {
  position: absolute; right: 0; top: calc(100% + .45rem); width: min(20rem, calc(100vw - 2.6rem));
  max-height: 75vh; overflow: auto; padding: .55rem; border: 1px solid #e5b0c4; background: var(--cream);
  box-shadow: 0 14px 40px #45152a22;
}
.menu nav a { display: flex; align-items: center; gap: .6rem; padding: .35rem .6rem; min-height: 40px; text-decoration: none; font-size: .9rem; }
.menu nav img { width: 27px; height: 27px; object-fit: contain; }
.menu nav a:hover { background: #f8d7e3; }
.menu .gallery-link { margin-top: .4rem; border-top: 1px solid #e5b0c4; padding-top: .65rem; }

.hero { overflow: hidden; background: var(--pink); }
.hero-inner {
  display: grid; grid-template-columns: .9fr 1.1fr; align-items: center;
  width: min(100%, 100rem); margin: auto; min-height: 100svh;
  padding: 6.5rem var(--edge) 3rem;
}
.hero-copy { position: relative; z-index: 2; }
.hero h1, h2 { margin: 0; font-family: var(--display); font-weight: 500; letter-spacing: -.055em; }
.hero h1 { font-size: clamp(4.6rem, 8.1vw, 9.6rem); line-height: .95; }
em { font-weight: 500; }
.hero h1 em { color: var(--wine); }
.date { margin: 0 0 1.4rem; font-size: .75rem; font-weight: 700; letter-spacing: .23em; text-transform: uppercase; }
.dedication { margin: 1.7rem 0 1.5rem; font-size: clamp(1rem, 1.6vw, 1.35rem); }
.pill {
  min-height: 44px; display: inline-flex; align-items: center; gap: 1rem; padding: .75rem 1rem;
  border: 1px solid currentColor; border-radius: 50px; text-decoration: none; font-size: .88rem; font-weight: 700;
  transition: transform 150ms var(--ease-out), background 150ms ease, color 150ms ease;
}
.pill:active { transform: scale(.97); }
.hero-art { position: relative; height: min(54vw, 41rem); isolation: isolate; }
.hero-photo {
  position: absolute; inset: 15% 22% 12%; border-radius: 49% 49% 45% 45%;
  overflow: hidden; box-shadow: 0 20px 65px #6a1e3d39; background: #e4a9bd;
  animation: portrait-in 1.25s var(--ease-out) both;
}
.hero-photo img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 45%; }
.orbit {
  position: absolute; inset: 6% 4%; border: 1px solid #a83c6466; border-radius: 50%;
  animation: orbit-in 1.7s var(--ease-out) both;
}
.orbit-one { --tilt: -30deg; transform: rotate(var(--tilt)); }
.orbit-two { --tilt: 33deg; inset: 15% 1%; transform: rotate(var(--tilt)); border-color: #fff8fa; }
.blooms { position: absolute; inset: 0; pointer-events: none; }
.blooms img {
  position: absolute; left: var(--x); top: var(--y); width: clamp(4.4rem, 12vw, 11.5rem); height: auto;
  transform: translate(-50%, -50%) rotate(var(--r)); filter: drop-shadow(0 10px 12px #691b3b2a);
  animation: bloom-in 1.55s var(--ease-out) both; animation-delay: calc(var(--i) * 72ms);
}
.hero-copy > * { animation: copy-in 800ms var(--ease-out) both; }
.hero-copy > :nth-child(2) { animation-delay: 90ms; }
.hero-copy > :nth-child(3) { animation-delay: 180ms; }
.hero-copy > :nth-child(4) { animation-delay: 260ms; }
@keyframes bloom-in {
  from { opacity: 0; transform: translate(calc(-50% + var(--sx)), calc(-50% + var(--sy))) rotate(calc(var(--r) - 80deg)) scale(.9); }
  to { opacity: 1; transform: translate(-50%, -50%) rotate(var(--r)); }
}
@keyframes orbit-in { from { opacity: 0; transform: rotate(calc(var(--tilt) - 65deg)) scale(.9); } }
@keyframes portrait-in { from { opacity: 0; transform: translateY(2rem) scale(.94); } }
@keyframes copy-in { from { opacity: 0; transform: translateY(1.25rem); } }

.memory { background: var(--cream); }
.memory:nth-of-type(odd) { background: #f9dce6; }
.memory-3, .memory-7 { --cream: #f4c1d3; }
.memory-inner {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr); align-items: center;
  gap: clamp(2rem, 6.5vw, 7rem); width: min(100%, 95rem); min-height: min(48rem, 90svh);
  margin: auto; padding: clamp(4rem, 9vw, 9rem) var(--edge);
}
.memory:nth-of-type(odd) .story { grid-column: 2; grid-row: 1; }
.memory:nth-of-type(odd) .chapter-media { grid-column: 1; grid-row: 1; }
.chapter-flower { width: 4.25rem; height: 4.25rem; object-fit: contain; margin: 0 0 1rem; }
.story h2 { font-size: clamp(3rem, 5.3vw, 6rem); line-height: .99; }
.letter { margin-top: 1.55rem; max-width: 37ch; font-size: clamp(1rem, 1.45vw, 1.24rem); line-height: 1.58; }
.letter p { margin: .75em 0 0; }
.chapter-media { position: relative; padding-bottom: .3rem; }
.tile {
  display: block; position: relative; width: 100%; padding: 0; border: 0;
  background: #edb5c9; overflow: hidden; isolation: isolate;
}
.tile img { width: 100%; height: 100%; object-fit: cover; transition: transform 360ms var(--ease-out); }
.chapter-media > .tile:first-child { aspect-ratio: 1.16; }
.chapter-media:has(> :nth-child(2)) { padding: 0 10% 8% 0; }
.chapter-media > .tile:nth-child(2) {
  width: 36%; aspect-ratio: 1; position: absolute; right: 0; bottom: 0; z-index: 1;
  border: 5px solid var(--cream); box-shadow: 0 10px 28px #46112a29;
}
.memory-3 .tile img { object-position: 50% 35%; }
.memory-4 .tile img { object-position: 50% 40%; }
.memory-5 .tile img { object-position: 50% 58%; }
.play {
  position: absolute; bottom: .75rem; right: .75rem; width: 2.7rem; height: 2.7rem;
  display: grid; place-items: center; padding-left: .1rem; border-radius: 50%; background: var(--cream); color: var(--wine);
}
[data-reveal].waiting { opacity: 0; transform: translateY(1.75rem); }
[data-reveal] { transition: opacity 650ms var(--ease-out), transform 650ms var(--ease-out); }
.chapter-media[data-reveal] { transition-delay: 85ms; }

.gallery { padding: clamp(5rem, 10vw, 10rem) var(--edge); background: #f6c6d7; }
.gallery h2, .closing h2 { font-size: clamp(3.45rem, 8vw, 8.25rem); line-height: .96; }
.gallery h2 { max-width: 82rem; margin: 0 auto clamp(2.5rem, 5vw, 5.5rem); }
.gallery-grid {
  max-width: 82rem; margin: auto; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(.45rem, 1.35vw, 1.2rem);
}
.gallery-grid .tile { aspect-ratio: 1; }
.gallery-grid .tile:nth-child(9n + 1) { grid-column: span 2; grid-row: span 2; }
.closing {
  display: grid; justify-items: center; align-content: center; gap: 2rem; min-height: 67svh;
  background: var(--wine); color: var(--cream); text-align: center; padding: 4rem var(--edge);
}

.viewer {
  width: min(64rem, calc(100% - 1rem)); max-height: calc(100% - 1rem); margin: auto;
  border: 0; padding: 0; color: var(--cream); background: #2e101e;
}
.viewer::backdrop { background: #220b18da; }
.viewer-bar, .viewer-nav { display: flex; align-items: center; gap: 1rem; padding: .3rem .75rem; }
.viewer-bar { justify-content: space-between; }
.viewer-bar p { margin: 0; }
.viewer-nav { justify-content: center; }
.viewer-position { min-width: 4rem; text-align: center; }
.viewer button { min-width: 44px; min-height: 44px; border: 0; background: transparent; color: inherit; font-size: 1.4rem; }
.viewer-media { display: grid; place-items: center; }
.viewer-media > * { display: block; max-width: 100%; max-height: min(72svh, calc(100svh - 8rem)); object-fit: contain; }
.viewer-media video { width: 100%; }
.viewer-media p { padding: 1.5rem; }

@media (hover: hover) and (pointer: fine) {
  .pill:hover { transform: translateY(-2px); background: var(--ink); color: var(--cream); }
  .closing .pill:hover { background: var(--cream); color: var(--wine); }
  .tile:hover img { transform: scale(1.035); }
}
@media (max-width: 850px) {
  .hero h1 { font-size: clamp(3.7rem, 9.8vw, 6rem); }
  .hero-art { height: 56vw; }
  .memory-inner { gap: 2.25rem; min-height: auto; }
}
@media (max-width: 620px) {
  .hero-inner { grid-template-columns: 1fr; gap: 1.1rem; min-height: 100svh; padding-top: 5.8rem; padding-bottom: 1.75rem; text-align: center; }
  .hero h1 { font-size: clamp(3.55rem, 12.2vw, 5.45rem); }
  .date { margin-bottom: .9rem; }
  .dedication { margin: 1.1rem 0 .9rem; }
  .hero-art { width: min(100%, 26rem); height: clamp(15rem, 75vw, 24rem); margin: auto; }
  .blooms img { width: clamp(4rem, 19vw, 6rem); }
  .memory-inner { display: flex; flex-direction: column; align-items: stretch; gap: 1.75rem; }
  .story h2 { font-size: clamp(2.9rem, 12vw, 4.15rem); }
  .chapter-flower { width: 3.5rem; height: 3.5rem; }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .closing { min-height: 60svh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  [data-reveal].waiting { opacity: 1; transform: none; }
}
.viewer-nav[hidden] { display: none; }
[data-reveal].waiting:focus-within { opacity: 1; transform: none; }

.top-actions { display: flex; align-items: center; gap: clamp(.5rem, 2vw, 1.5rem); }
.music-toggle {
  min-height: 44px; padding: 0 .3rem; border: 0; background: transparent;
  font-size: .82rem; font-weight: 700; white-space: nowrap;
}
.music-note { margin-right: .15rem; }
.tile img { object-fit: contain; }
.tile { background: #f1cfdb; }
.chapter-media > .tile:first-child { aspect-ratio: auto; }
.chapter-media > .tile:first-child img { height: clamp(16rem, 36vw, 31rem); }
.chapter-media > .tile:nth-child(2) { width: 40%; }
.gallery-grid .tile { background: #f7dbe4; }
.gallery-grid .tile img { padding: .2rem; }
@media (hover: hover) and (pointer: fine) {
  .tile:hover img { transform: scale(.985); }
}

.memory { position: relative; isolation: isolate; overflow: clip; }
.memory-inner { position: relative; z-index: 1; }
.depth-flowers {
  position: absolute; inset: 0; pointer-events: none; perspective: 650px;
  display: none;
}
.scroll-motion .depth-flowers { display: block; }
.depth-flower { position: absolute; height: auto; opacity: 0; }
.flower-far { width: clamp(3.8rem, 9vw, 9rem); left: 4%; top: 35%; opacity: .48; }
.flower-near {
  width: clamp(6.75rem, 16vw, 17rem); right: -5%; top: 29%;
  filter: drop-shadow(0 13px 13px #691b3b32);
}
.memory:nth-of-type(odd) .flower-far { left: auto; right: 4%; }
.memory:nth-of-type(odd) .flower-near { right: auto; left: -5%; }
@media (max-width: 620px) {
  .chapter-media > .tile:first-child img { height: clamp(16rem, 86vw, 25rem); }
  .flower-near { right: -13%; }
  .memory:nth-of-type(odd) .flower-near { left: -13%; }
  .flower-far { left: -4%; }
  .memory:nth-of-type(odd) .flower-far { right: -4%; }
}
@media (prefers-reduced-motion: reduce) {
  .scroll-motion .depth-flowers { display: none; }
}
