:root {
  --night: #030308;
  --ink: #f7eee2;
  --dim: rgba(247, 238, 226, .6);
  --faint: rgba(247, 238, 226, .34);
  --blush: #f4b9ca;
  --accent: #f4b9ca;
  --serif: 'Cormorant Garamond', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --breath: 5.5s;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--night);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* ---------- the sky: square pixels, kept square when scaled up ---------- */
#sky, #skyfx {
  position: fixed;
  left: 0; top: 0;
  z-index: 0;
  pointer-events: none;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  animation: dawn 3.2s ease-out both;
}
@keyframes dawn { from { opacity: 0; } to { opacity: 1; } }

/* the corners fall away into dark, so the words stay easy to read */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(130% 96% at 50% 46%, transparent 50%, rgba(3, 2, 7, .74) 100%);
}

.stage {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 2;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  justify-items: center;
  padding:
    calc(env(safe-area-inset-top, 0px) + clamp(20px, 4.6vh, 52px))
    18px
    calc(env(safe-area-inset-bottom, 0px) + clamp(14px, 2.8vh, 34px));
}

/* ---------- words ---------- */
.words, .foot { transition: opacity .9s ease; }
.noting .words, .noting .foot { opacity: 0; }

.words { text-align: center; }

.eyebrow {
  margin: 0 0 clamp(10px, 1.8vh, 18px);
  font: 400 10.5px/1 var(--mono);
  letter-spacing: .44em;
  text-indent: .44em;
  text-transform: lowercase;
  color: var(--dim);
}

h1 {
  margin: 0;
  font-weight: 300;
  font-size: clamp(27px, min(7.6vw, 5.8vh), 52px);
  line-height: 1.04;
  letter-spacing: -.012em;
  text-wrap: balance;
  text-shadow: 0 0 18px rgba(5, 4, 10, .9);
}
h1 span { display: block; }
h1 em { font-style: italic; font-weight: 400; color: #fbd0dc; }

/* everything arrives the same way: out of a soft blur */
.rise {
  opacity: 0;
  animation: rise 2.6s cubic-bezier(.2, .6, .2, 1) var(--d, 0s) forwards;
}
@keyframes rise {
  from { opacity: 0; filter: blur(9px); transform: translateY(7px); }
  to   { opacity: 1; filter: blur(0);   transform: none; }
}

/* ---------- bouquet ---------- */
.bouquet {
  position: relative;
  width: min(100% + 36px, 780px);   /* runs edge to edge on a phone, so the lilies can be big */
  margin-inline: -18px;
  min-height: 0;
  margin-top: clamp(4px, 1.4vh, 16px);
  animation: arrive 3.8s ease-out both;
}
@keyframes arrive {
  0%   { opacity: 0; filter: blur(14px); }
  55%  { opacity: 1; }
  100% { opacity: 1; filter: blur(0); }
}

.halo {
  position: absolute;
  left: 50%; top: 40%;
  width: min(92%, 560px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
  background: radial-gradient(closest-side, rgba(246, 156, 186, .1), rgba(246, 156, 186, .03) 55%, transparent 74%);
  animation: breathe var(--breath) ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { opacity: .6; transform: translate(-50%, -50%) scale(.97); }
  50%      { opacity: 1;  transform: translate(-50%, -50%) scale(1.04); }
}

.bouquet canvas { position: absolute; left: 0; top: 0; display: block; }

/* a dark cut-out of the bouquet, so no star shines through a petal */
#shade { pointer-events: none; opacity: .92; }

/* the same picture, out of focus, sitting under the letters as a glow */
#under {
  pointer-events: none;
  opacity: .62;
  filter: blur(calc(var(--cell, 5px) * .7));
}
#ink { touch-action: manipulation; }

/* ---------- foot: the ask, and the clock ---------- */
.foot {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: clamp(10px, 1.8vh, 20px);
  padding-top: clamp(4px, 1vh, 12px);
}

.hint {
  all: unset;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font: 400 10.5px/1 var(--mono);
  letter-spacing: .38em;
  text-transform: lowercase;
  color: var(--ink);
  opacity: 0;
  transition: opacity 1.8s ease;
}
.hint.on { opacity: .85; }
.hint.quiet { opacity: .42; }
.hint:focus-visible { outline: 1px solid var(--faint); outline-offset: 8px; }
.hint i {
  width: 6px; height: 6px;
  background: var(--blush);
  animation: ping 2.75s ease-out infinite;
}
@keyframes ping {
  0%   { box-shadow: 0 0 0 0 rgba(244, 185, 202, .55); }
  70%  { box-shadow: 0 0 0 9px rgba(244, 185, 202, 0); }
  100% { box-shadow: 0 0 0 0 rgba(244, 185, 202, 0); }
}

.since {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: clamp(9px, 1.5vh, 14px);
}
.lead, .tail {
  margin: 0;
  font: italic 300 clamp(16px, 4.4vw, 19px)/1 var(--serif);
  text-shadow: 0 0 14px rgba(5, 4, 10, .9);
}
.lead { color: rgba(247, 238, 226, .86); }
.tail { color: var(--dim); }

.clock {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: min(100%, 344px);
  font-family: var(--mono);
}
.clock div { display: grid; justify-items: center; gap: 8px; }
.clock b {
  font-weight: 300;
  font-size: clamp(20px, 5.6vw, 30px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.clock span {
  font-size: 8.5px;
  letter-spacing: .26em;
  text-indent: .26em;
  text-transform: lowercase;
  color: var(--faint);
}

/* ---------- a note, opened from a petal ---------- */
.veil {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 26px;
  cursor: pointer;
  background: rgba(7, 5, 13, .8);          /* one flat tone: the stars stay faintly there behind it */
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .8s ease, visibility 0s linear .8s;
}
.veil.open { opacity: 1; visibility: visible; transition: opacity .8s ease; }

.note {
  margin: 0;
  display: grid;
  justify-items: center;
  gap: clamp(18px, 3.4vh, 30px);
  width: min(100%, 440px);
}

/* the card: just the picture, large and plain, with a hairline around it.
   it is written in letters first (the canvas), then the real photo fades in over them */
.print {
  position: relative;
  width: min(76vw, 330px);
  height: min(95vw, 412px);
  overflow: hidden;
  background: #07060d;
  border: 1px solid rgba(247, 238, 226, .26);
  border-radius: 14px;
  box-shadow: 0 26px 70px rgba(0, 0, 0, .6);
  opacity: 0;
  transform: translateY(14px) scale(.96);
  transition: transform .9s cubic-bezier(.2, .7, .2, 1), opacity .7s ease;
}
.veil.open .print.ready { opacity: 1; transform: none; transition-delay: .1s; }
.words-only blockquote { font-size: clamp(27px, 7.6vw, 42px); line-height: 1.14; }
#screen, #photo {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  display: block;
}
#screen { clip-path: inset(0 0 100% 0); }
#screen.write { animation: write 1.3s steps(52, end) forwards; }
@keyframes write {
  from { clip-path: inset(0 0 100% 0); }
  to   { clip-path: inset(0 0 0 0); }
}
#photo { object-fit: cover; object-position: 50% 38%; opacity: 0; transition: opacity 1.4s ease; }
#photo.in { opacity: 1; }
.tag {
  position: absolute;
  left: 0; right: 0; bottom: 14px;
  text-align: center;
  font: 400 9px/1 var(--mono);
  letter-spacing: .16em;
  color: rgba(40, 20, 34, .7);
}

blockquote {
  margin: 0;
  font: italic 300 clamp(22px, 5.9vw, 31px)/1.2 var(--serif);
  text-align: center;
  text-wrap: balance;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 1.1s ease, transform 1.1s ease;
}
.veil.open blockquote { opacity: 1; transform: none; transition-delay: .5s; }

.under-note {
  display: grid;
  justify-items: center;
  gap: 16px;
  opacity: 0;
  transition: opacity 1s ease;
}
.veil.open .under-note { opacity: 1; transition-delay: 1s; }
.count { font: 400 9.5px/1 var(--mono); letter-spacing: .42em; text-indent: .42em; color: var(--faint); }
.back {
  all: unset;
  cursor: pointer;
  padding: 8px 4px;
  font: 400 10px/1 var(--mono);
  letter-spacing: .32em;
  text-transform: lowercase;
  color: var(--dim);
  border-bottom: 1px solid var(--accent);
}
.back:focus-visible { outline: 1px solid var(--faint); outline-offset: 6px; }

/* ---------- short screens ---------- */
@media (max-height: 700px) {
  .tail { display: none; }
}
@media (max-height: 560px) {
  .eyebrow { display: none; }
  h1 { font-size: clamp(20px, 5vh, 30px); }
  h1 span { display: inline; }
  .clock b { font-size: 18px; }
  .foot { gap: 9px; }
}

/* ---------- for anyone who has asked their device for less motion ---------- */
.instant .rise, .instant .bouquet, .instant #sky, .instant #skyfx { animation-duration: .01s; animation-delay: 0s; }
@media (prefers-reduced-motion: reduce) {
  .rise, .bouquet, #sky, #skyfx { animation-duration: .01s; animation-delay: 0s; }
  .halo, .hint i { animation: none; }
  .print, blockquote, .under-note, .veil { transition-duration: .2s; transition-delay: 0s; }
  #screen.write { animation-duration: .01s; }
}
