:root {
  --ink: #221c18;
  --blood: #8a0f16;
  --wax: #7c0d13;
  --parchment: #efe7da;
  --parchment-dim: #b9ab98;
  --night: #0b0807;
  --ember: #d96a2b;
  --ember-dim: #c98a5e;
  --leaf: #2e3a2c;
  --leaf-edge: #4c5c47;
  --serif: 'Cormorant Garamond', 'Cormorant', Georgia, serif;
  --script: 'Pinyon Script', 'Snell Roundhand', cursive;
  --ease-out: cubic-bezier(.16, .8, .2, 1);
  color-scheme: dark;
}

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

html { scroll-behavior: smooth; }

body {
  position: relative;
  margin: 0;
  background: var(--night);
  color: var(--parchment);
  font-family: var(--serif);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 1px solid var(--ember);
  outline-offset: 4px;
}

/* ───────── Atmosphere: blurred artwork, candle glow, ivy, petals ───────── */

.backdrop {
  position: fixed;
  inset: -10%;
  z-index: 0;
  background: var(--night) url('/invite/assets/art-clean.webp') center / cover no-repeat;
  filter: blur(30px) brightness(.14) saturate(.8);
}

.candle {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 28%), rgba(217, 106, 43, .1), transparent 65%);
}

.ivy {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  width: 100%;
  overflow: visible;
  pointer-events: none;
  opacity: .8;
}

.ivy__stem {
  fill: none;
  stroke: #3a4536;
  stroke-width: 2;
  stroke-linecap: round;
}

.ivy__leaf {
  fill: var(--leaf);
  stroke: var(--leaf-edge);
  stroke-width: .8;
  transform: scale(0);
  transition: transform 1s var(--ease-out);
}

.ivy__bloom {
  transform: scale(0) rotate(-40deg);
  transition: transform 1.4s var(--ease-out);
}

.ivy__petal { fill: #efe3d6; stroke: #cf958b; stroke-width: .6; }
.ivy__heart { fill: var(--blood); }
.ivy__leaf.is-grown, .ivy__bloom.is-grown { transform: none; }

.petals {
  position: fixed;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

main, .hero, .footer { position: relative; z-index: 3; }

/* ───────── Shared type & controls ───────── */

.eyebrow {
  margin: 0 0 1rem;
  font-size: .78rem;
  letter-spacing: .45em;
  padding-left: .45em;
  text-transform: uppercase;
  color: var(--ember-dim);
}

.section-title {
  margin: 0 0 1.4rem;
  font-weight: 500;
  font-size: clamp(1.7rem, 6.2vw, 3.6rem);
  line-height: 1.15;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.lede {
  max-width: 32rem;
  margin: 0 auto 2rem;
  font-size: clamp(1.15rem, 3.6vw, 1.4rem);
  font-style: italic;
  line-height: 1.5;
  color: var(--parchment-dim);
}

.actions { display: flex; flex-wrap: wrap; gap: .8rem; justify-content: center; }

.btn {
  display: inline-block;
  padding: .95rem 1.6rem;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: .9rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .3s ease, background-color .3s ease;
}

.btn:active { transform: scale(.97); }

.btn--wax {
  color: #f7e9e2;
  background: radial-gradient(120% 140% at 30% 20%, #b3222a, var(--wax) 55%, #45050a);
  box-shadow: 0 10px 30px rgba(120, 10, 16, .45), inset 0 1px 0 rgba(255, 190, 190, .25);
}

.btn--wax:hover { box-shadow: 0 12px 40px rgba(160, 20, 26, .65), inset 0 1px 0 rgba(255, 190, 190, .3); }

.btn--ghost {
  color: var(--parchment);
  border: 1px solid rgba(185, 171, 152, .35);
  background: rgba(11, 8, 7, .35);
}

.btn--ghost:hover { background-color: rgba(239, 231, 218, .08); }

.wax {
  position: relative;
  display: grid;
  place-items: center;
  width: 4.2rem;
  aspect-ratio: 1;
  border-radius: 47% 53% 50% 50% / 52% 48% 52% 48%;
  background: radial-gradient(circle at 35% 30%, #c3262d, #8b1016 45%, #4a0508 100%);
  box-shadow: 0 6px 14px rgba(0, 0, 0, .45), inset 0 0 0 .35rem rgba(58, 2, 6, .35);
  color: #4d0408;
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 600;
  text-shadow: .6px .8px 0 rgba(214, 84, 91, .55);
}

.wax--large { width: 5.4rem; font-size: 1.6rem; }

/* ───────── Reveals ───────── */

[data-reveal] {
  opacity: 0;
  transform: translateY(28px);
  filter: blur(6px);
  transition: opacity 1.2s ease, transform 1.4s var(--ease-out), filter 1.2s ease;
  transition-delay: calc(var(--i, 0) * 120ms);
}

[data-reveal].is-visible { opacity: 1; transform: none; filter: none; }

[data-split][data-reveal] { opacity: 1; transform: none; filter: none; }

.split-word { display: inline-block; white-space: nowrap; }

.split-char {
  display: inline-block;
  opacity: 0;
  filter: blur(8px);
  transform: translateY(.6em) rotate(8deg);
  transition: opacity .8s ease, filter .9s ease, transform 1.1s var(--ease-out);
  transition-delay: calc(var(--i) * 38ms);
}

.is-visible .split-char { opacity: 1; filter: none; transform: none; }

/* ───────── Hero ───────── */

.hero {
  height: 100vh;
  height: 100svh;
  min-height: 520px;
  overflow: hidden;
  touch-action: pan-y;
}

.hero__canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

.hero__kicker,
.hero__date {
  position: absolute;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 1.6s ease, transform 1.6s var(--ease-out);
}

.hero__kicker {
  top: calc(var(--title-top, 32svh) - 3.4rem);
  padding: 0 1.5rem;
  font-size: clamp(.66rem, 2.9vw, .8rem);
  letter-spacing: .38em;
  text-transform: uppercase;
  color: var(--parchment-dim);
  transition-delay: 2.2s;
}

.hero__date {
  top: calc(var(--title-bottom, 62svh) + 2rem);
  display: grid;
  gap: .6rem;
  transition-delay: 2.7s;
}

.hero__date-main {
  font-size: clamp(1.3rem, 5vw, 2rem);
  letter-spacing: .35em;
  padding-left: .35em;
}

.hero__date-place {
  font-size: .8rem;
  letter-spacing: .4em;
  padding-left: .4em;
  text-transform: uppercase;
  color: var(--parchment-dim);
}

.is-loaded .hero__kicker, .is-loaded .hero__date { opacity: 1; transform: none; }

.scroll-cue {
  position: absolute;
  bottom: max(1.2rem, env(safe-area-inset-bottom));
  left: 50%;
  display: grid;
  justify-items: center;
  gap: .5rem;
  color: var(--parchment-dim);
  font-size: .75rem;
  letter-spacing: .35em;
  text-transform: uppercase;
  text-decoration: none;
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 1.5s ease 4s;
}

.scroll-cue i {
  position: relative;
  width: 1px;
  height: 42px;
  overflow: hidden;
  background: linear-gradient(var(--parchment-dim), transparent);
}

.scroll-cue i::after {
  content: '';
  position: absolute;
  left: -2px;
  top: -8px;
  width: 5px;
  height: 8px;
  border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%;
  background: var(--blood);
  animation: drip 2.4s ease-in infinite;
}

.is-loaded .scroll-cue { opacity: .85; }

@keyframes drip {
  0%, 20% { transform: translateY(0); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translateY(54px); opacity: 0; }
}

/* ───────── Sections ───────── */

.section {
  max-width: 60rem;
  margin: 0 auto;
  padding: clamp(5rem, 16vh, 9rem) 2rem;
  text-align: center;
}

/* Flip clock */

.flip-clock {
  display: grid;
  grid-template-columns: repeat(4, auto);
  justify-content: center;
  gap: clamp(.55rem, 2.6vw, 2.4rem);
  margin-top: 1rem;
}

.flip-unit { display: grid; justify-items: center; gap: .9rem; }

.flip-unit__digits {
  display: flex;
  gap: .1em;
  font-size: clamp(1.6rem, 7.2vw, 4.6rem);
}

.flip-unit__label {
  font-size: clamp(.58rem, 2.4vw, .72rem);
  letter-spacing: clamp(.14em, .9vw, .35em);
  text-transform: uppercase;
  color: var(--parchment-dim);
}

.flip {
  position: relative;
  width: .9em;
  height: 1.36em;
  perspective: 5em;
  font-weight: 500;
  box-shadow: 0 .15em .4em rgba(0, 0, 0, .55);
  border-radius: .1em;
}

.flip > span {
  position: absolute;
  left: 0;
  right: 0;
  height: 50%;
  overflow: hidden;
  background: linear-gradient(#2a1f1b, #1c1512);
  color: var(--parchment);
}

.flip i {
  display: block;
  height: 1.36em;
  line-height: 1.36em;
  font-style: normal;
  text-align: center;
  font-variant-numeric: lining-nums tabular-nums;
}

.flip__top, .flip__flap--top { top: 0; border-radius: .1em .1em 0 0; transform-origin: 50% 100%; }
.flip__bottom, .flip__flap--bottom { bottom: 0; border-radius: 0 0 .1em .1em; transform-origin: 50% 0; background: linear-gradient(#1c1512, #140f0d); }
.flip__bottom i, .flip__flap--bottom i { margin-top: -.68em; }
.flip__flap { z-index: 2; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flip__flap--bottom { transform: rotateX(90deg); }

.flip::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  z-index: 3;
  height: 1px;
  background: rgba(0, 0, 0, .7);
}

.flip.is-flipping .flip__flap--top { animation: flap-top .3s ease-in forwards; }
.flip.is-flipping .flip__flap--bottom { animation: flap-bottom .3s ease-out .3s forwards; }

@keyframes flap-top { to { transform: rotateX(-90deg); } }
@keyframes flap-bottom { from { transform: rotateX(90deg); } to { transform: rotateX(0deg); } }

/* The day: clock hands spin and settle at eleven */

.day { display: grid; gap: 3rem; justify-items: center; }

.clock { display: block; width: min(68vw, 300px); overflow: visible; }
.clock__rim { fill: none; stroke: rgba(185, 171, 152, .5); stroke-width: 1; }
.clock__face { fill: rgba(239, 231, 218, .04); stroke: rgba(185, 171, 152, .25); stroke-width: .6; }
.clock__tick { stroke: rgba(185, 171, 152, .45); stroke-width: .6; }
.clock__tick--hour { stroke: var(--parchment); stroke-width: 1.2; }

.clock__numeral {
  fill: var(--parchment);
  font-family: var(--serif);
  font-size: 11px;
  font-weight: 500;
  text-anchor: middle;
  dominant-baseline: central;
}

.clock__hand {
  stroke: var(--parchment);
  stroke-linecap: round;
  transform-box: view-box;
  transform-origin: 100px 100px;
  transition: transform 3.6s cubic-bezier(.12, .8, .2, 1) .3s;
}

.clock__hand--hour { stroke-width: 4; transform: rotate(240deg); }
.clock__hand--minute { stroke-width: 2.2; transform: rotate(-1080deg); }
.clock__pin { fill: var(--blood); }
.is-visible .clock__hand--hour { transform: rotate(330deg); }
.is-visible .clock__hand--minute { transform: rotate(0deg); }

@media (min-width: 820px) {
  .day { grid-template-columns: 1fr 1.25fr; align-items: center; text-align: left; }
  .day .lede { margin-left: 0; }
  .day .actions { justify-content: flex-start; }
}

/* The place: a pinned scene that zooms through the arch into Danson House */

.passage { position: relative; z-index: 3; height: 320vh; }

.passage__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}

.passage__art {
  position: absolute;
  inset: 0;
  background: url('/invite/assets/art-clean.webp') 50% 60% / cover no-repeat;
  transform: scale(calc(1 + var(--p, 0) * 1.6));
  transform-origin: 50% 64%;
  will-change: transform;
}

.passage__veil::before,
.passage__veil::after {
  content: '';
  position: absolute;
  inset: 0;
}

.passage__veil::before {
  background: radial-gradient(ellipse at 50% 55%, transparent 35%, rgba(11, 8, 7, .9) 85%);
  opacity: calc(1 - var(--p, 0) * .7);
}

.passage__veil::after {
  background: linear-gradient(transparent 22%, rgba(11, 8, 7, .78) 55%, rgba(11, 8, 7, .96) 80%);
  opacity: calc(var(--p, 0) * 1.6 - .5);
}

.passage__hint {
  position: absolute;
  top: 38%;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  padding: 0 1rem;
  font-size: clamp(.72rem, 3.2vw, .9rem);
  font-weight: 600;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: calc(1 - var(--p, 0) * 5);
}

.passage__copy {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(3rem, 8svh);
  padding: 0 1.5rem;
  text-align: center;
  opacity: clamp(0, calc((var(--p, 0) - .55) * 3.5), 1);
  transform: translateY(calc((1 - var(--p, 0)) * 60px));
  pointer-events: none;
}

.passage.is-arrived .passage__copy { pointer-events: auto; }

.passage__title {
  margin: 0;
  font-size: clamp(2.6rem, 11vw, 6rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-shadow: 0 4px 30px rgba(0, 0, 0, .7);
}

.passage__town {
  margin: .8rem 0 1.4rem;
  font-size: .85rem;
  letter-spacing: .5em;
  padding-left: .5em;
  text-transform: uppercase;
  color: var(--parchment-dim);
}

.passage .lede { color: var(--parchment); }
.passage .eyebrow { text-shadow: 0 2px 10px rgba(0, 0, 0, .8); }

/* The finer details: wax-sealed envelopes that flip open */

.sealed__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(.9rem, 3vw, 1.6rem);
  max-width: 40rem;
  margin: 1rem auto 0;
}

@media (min-width: 900px) {
  .sealed__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 58rem; }
}

.envelope {
  aspect-ratio: 3 / 4;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  perspective: 900px;
}

.envelope__inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 1s var(--ease-out);
}

.envelope:not(.is-open):hover .envelope__inner { transform: translateY(-5px) rotate(-1.2deg); }
.envelope.is-open .envelope__inner { transform: rotateY(180deg); }

.envelope__front,
.envelope__back {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1rem;
  padding: 1rem;
  border-radius: 6px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.envelope__front {
  overflow: hidden;
  background: linear-gradient(160deg, #efe6d6, #d6c7ad);
  color: var(--ink);
  box-shadow: 0 20px 40px rgba(0, 0, 0, .45);
}

.envelope__front::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 58%;
  background: linear-gradient(170deg, #e4d7c1, #cdbd9f);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .15));
}

.envelope__front .wax { margin-top: -18%; }

.envelope__back {
  transform: rotateY(180deg);
  border: 1px solid rgba(185, 171, 152, .25);
  background: #1a1311;
  color: var(--parchment);
}

.envelope__title {
  position: relative;
  font-size: clamp(.8rem, 2.6vw, 1rem);
  font-weight: 500;
  letter-spacing: .2em;
  text-transform: uppercase;
}

.envelope__note { font-size: 1.05rem; font-style: italic; color: var(--parchment-dim); }

/* Photos: a stack of polaroids that fans out */

.polaroids {
  position: relative;
  max-width: 30rem;
  height: clamp(210px, 48vw, 300px);
  margin: 0 auto 2.5rem;
}

.polaroid {
  position: absolute;
  top: 50%;
  left: 50%;
  width: clamp(120px, 30vw, 180px);
  aspect-ratio: .82;
  padding: 8px 8px 30px;
  background: #f3ede2;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .55);
  transform: translate(-50%, -50%);
  transition: transform 1.5s var(--ease-out) .3s;
}

.polaroid::before {
  content: '';
  display: block;
  width: 100%;
  height: 100%;
  background: url('/invite/assets/art-clean.webp') var(--crop) / 420% no-repeat;
  filter: sepia(.2) contrast(1.05);
}

.polaroids.is-visible .polaroid { transform: translate(calc(-50% + var(--x)), -50%) rotate(var(--r)); }

/* Footer */

.footer {
  display: grid;
  justify-items: center;
  gap: .6rem;
  padding: 4rem 1.5rem max(4rem, env(safe-area-inset-bottom));
  text-align: center;
}

.footer__names { margin: .8rem 0 0; font-family: var(--script); font-size: 2.6rem; }
.footer__date { margin: 0; letter-spacing: .35em; padding-left: .35em; color: var(--parchment-dim); }

.footer__link {
  margin-top: 1rem;
  color: var(--parchment);
  font-size: 1.05rem;
  text-decoration: none;
  border-bottom: 1px solid rgba(185, 171, 152, .4);
}

/* ───────── Reduced motion: keep the content, drop the theatrics ───────── */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition-duration: .01s !important; transition-delay: 0s !important; }
  .passage { height: auto; }
  .passage__sticky { position: relative; }
}
