/* ============================================================
   styles.css, the look. You shouldn't need to touch this,
   but the colours are all in one place at the top if you want to.
   ============================================================ */

:root {
  /* Warm near-black. Reads well on a phone at night. */
  --ink:        #14100f;
  --ink-soft:   #1d1817;
  --cream:      #f3ebe3;
  --cream-dim:  rgba(243, 235, 227, 0.62);
  --cream-faint:rgba(243, 235, 227, 0.28);
  --rose:       #c9836f;
  --rose-soft:  rgba(201, 131, 111, 0.30);

  /* The paper the photos are printed on. */
  --paper:      #ece2d6;
  --tape:       rgba(214, 186, 160, 0.34);

  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --body:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --hand:    "Caveat", "Segoe Script", cursive;

  /* One scroll-height unit that behaves on mobile browsers. */
  --screen: 100vh;
}
@supports (height: 100svh) {
  :root { --screen: 100svh; }
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  /* Clip sideways overflow at the viewport. "clip" is the right tool
     here because, unlike "hidden", it doesn't turn the page into a
     scroll container. The "hidden" line is the fallback for older
     browsers that don't know "clip". */
  overflow-x: hidden;
  overflow-x: clip;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--body);
  font-weight: 300;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* A very faint film grain over everything, so the flat dark
   background doesn't look like a blank div. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}


/* ---------- scroll progress hairline ---------- */

.progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  z-index: 50;
  background: rgba(243, 235, 227, 0.07);
}
.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--rose);
  transition: width 0.1s linear;
}


/* ---------- scenes ---------- */

.scene {
  position: relative;
  z-index: 1;           /* sits above the drifting hearts, but stays transparent */
  isolation: isolate;   /* keeps each scene's background glow inside that scene */
  min-height: var(--screen);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 14vh 24px;
  padding-left:  max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
}

/* Everything starts invisible and settles in as it scrolls up. */
.reveal {
  opacity: 0;
  transform: translateY(26px);
  transition:
    opacity   1.1s cubic-bezier(0.22, 1, 0.36, 1),
    transform 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}
.is-visible .reveal { opacity: 1; transform: none; }

/* Stagger the elements within a scene. */
.is-visible .reveal:nth-child(2) { transition-delay: 0.14s; }
.is-visible .reveal:nth-child(3) { transition-delay: 0.28s; }
.is-visible .reveal:nth-child(4) { transition-delay: 0.42s; }


/* ---------- shared type ---------- */

.eyebrow {
  font-family: var(--body);
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--rose);
  margin: 0 0 1.6rem;
}

/* Dates are handwritten, like a note on the back of a print. */
.date {
  font-family: var(--hand);
  font-size: clamp(1.25rem, 5vw, 1.5rem);
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--rose);
  margin: 0 0 1.3rem;
  transform: rotate(-1.5deg);
}


/* ---------- little drawn doodles ---------- */

.doodle {
  display: block;
  color: var(--rose);
  opacity: 0.55;
}
.doodle svg { display: block; }

.doodle--intro    { margin: 0 0 1.5rem; opacity: 0.8; }
.doodle--line     { margin: 0 0 2rem;   opacity: 0.4; }
.doodle--counter  { margin: 0 0 1.4rem; opacity: 0.6; }
.doodle--letter   { margin: 0 0 1rem;   opacity: 0.6; }
.doodle--finale   { margin: 0 0 2.2rem; opacity: 0.85; }

/* A small drawn heart that beats, very slowly, on the last screen. */
.doodle--finale svg { animation: beat 3.4s ease-in-out infinite; }
@keyframes beat {
  0%, 100% { transform: scale(1); }
  14%      { transform: scale(1.13); }
  28%      { transform: scale(1); }
  42%      { transform: scale(1.08); }
}


/* ---------- hearts drifting up behind everything ---------- */

.floaties {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.floaty {
  position: absolute;
  bottom: -40px;
  color: var(--rose);
  opacity: 0;
  animation-name: float-up;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
/* the inline SVG scales to whatever width app.js gives each one */
.floaty svg { display: block; width: 100%; height: auto; }
@keyframes float-up {
  0%        { transform: translateY(0) rotate(0deg) scale(0.9); opacity: 0; }
  12%       { opacity: 0.16; }
  88%       { opacity: 0.16; }
  100%      { transform: translateY(-112vh) rotate(26deg) scale(1.1); opacity: 0; }
}


/* ---------- intro ---------- */

.scene--intro .title {
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(3.4rem, 19vw, 7rem);
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 0;
}
.scene--intro .subtitle {
  font-family: var(--hand);
  font-size: clamp(1.5rem, 6vw, 1.9rem);
  color: var(--rose);
  margin: 1.2rem 0 0;
  max-width: 22ch;
  transform: rotate(-1.8deg);
}

/* Soft warm bloom behind the opening title. */
.scene--intro::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  /* Sized against the scene, not the viewport. vw units include the
     desktop scrollbar, which pushes the page sideways. */
  width: min(90%, 620px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201, 131, 111, 0.16), transparent 68%);
  filter: blur(20px);
}

.scroll-hint {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 34px);
  width: 1px;
  height: 46px;
  background: linear-gradient(var(--cream-faint), transparent);
  animation: drift 2.6s ease-in-out infinite;
}
@keyframes drift {
  0%, 100% { opacity: 0.2; transform: translateY(-6px); }
  50%      { opacity: 0.8; transform: translateY(0); }
}


/* ---------- a single line, alone ---------- */

.scene--line .line {
  font-family: var(--display);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(1.7rem, 7.4vw, 2.6rem);
  line-height: 1.35;
  letter-spacing: -0.01em;
  max-width: 17ch;
  margin: 0;
  text-wrap: balance;
}

.scene--line .sub {
  font-size: 0.98rem;
  line-height: 1.7;
  color: var(--cream-dim);
  max-width: 30ch;
  margin: 2rem 0 0;
  text-wrap: pretty;
}


/* ---------- photo ---------- */

/* Photos are printed on paper and taped to the page. */
.scene--photo .frame {
  --rot: -1.3deg;
  position: relative;
  /* A tilted box is wider than its own width, so leave a few pixels
     each side for the corners to swing into. */
  width: calc(100% - 14px);
  max-width: 430px;
  padding: 11px 11px 13px;
  border-radius: 2px;
  background: var(--paper);
  box-shadow:
    0 30px 70px -30px rgba(0, 0, 0, 0.95),
    0 1px 0 rgba(255, 255, 255, 0.12) inset;
}
.scene--photo:nth-child(even) .frame { --rot: 1.1deg; }

/* Keep the tilt through the fade-in, which otherwise clears transforms. */
.scene--photo .frame            { transform: translateY(26px) rotate(var(--rot)); }
.is-visible .scene--photo .frame { transform: translateY(0)   rotate(var(--rot)); }

.scene--photo img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 1px;
}

/* A strip of washi tape across the top edge. */
.frame::before {
  content: "";
  position: absolute;
  top: -11px;
  left: 50%;
  width: 92px;
  height: 23px;
  transform: translateX(-50%) rotate(-2.5deg);
  background: var(--tape);
  border-left:  1px dashed rgba(255, 255, 255, 0.16);
  border-right: 1px dashed rgba(255, 255, 255, 0.16);
}

.scene--photo .caption {
  font-size: 1rem;
  line-height: 1.65;
  color: var(--cream-dim);
  max-width: 30ch;
  margin: 1.8rem 0 0;
  text-wrap: pretty;
}

/* ---------- gallery: a few photos from one day ---------- */

.gallery {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: clamp(18px, 4vw, 30px);
}

.gallery .frame {
  --rot: 0deg;
  position: relative;
  width: 76%;
  max-width: 310px;
  padding: 9px 9px 11px;
  border-radius: 2px;
  background: var(--paper);
  box-shadow:
    0 22px 50px -24px rgba(0, 0, 0, 0.95),
    0 1px 0 rgba(255, 255, 255, 0.12) inset;

  opacity: 0;
  transform: translateY(26px) rotate(var(--rot));
  transition:
    opacity   1.1s cubic-bezier(0.22, 1, 0.36, 1),
    transform 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}
.gallery .frame img { display: block; width: 100%; height: auto; border-radius: 1px; }

/* Tape each print down on a different corner, so they look dropped
   onto the page rather than laid out. */
.gallery .frame:nth-child(1)::before { left: 22%; transform: translateX(-50%) rotate(-8deg);  width: 78px; }
.gallery .frame:nth-child(2)::before { left: 78%; transform: translateX(-50%) rotate(7deg);   width: 78px; }
.gallery .frame:nth-child(3)::before { left: 30%; transform: translateX(-50%) rotate(-5deg);  width: 78px; }
.gallery .frame:nth-child(4)::before { left: 70%; transform: translateX(-50%) rotate(6deg);   width: 78px; }

.is-visible .gallery .frame {
  opacity: 1;
  transform: translateY(0) rotate(var(--rot));
}

/* Scattered slightly, and staggered, so it reads as a handful of prints. */
.gallery .frame:nth-child(1) { --rot: -2.4deg; margin-right: 11%; }
.gallery .frame:nth-child(2) { --rot:  1.9deg; margin-left:  11%; }
.gallery .frame:nth-child(3) { --rot: -1.2deg; margin-right:  6%; }
.gallery .frame:nth-child(4) { --rot:  2.2deg; margin-left:   6%; }

.is-visible .gallery .frame:nth-child(2) { transition-delay: 0.16s; }
.is-visible .gallery .frame:nth-child(3) { transition-delay: 0.32s; }
.is-visible .gallery .frame:nth-child(4) { transition-delay: 0.48s; }

.scene--gallery .caption {
  font-size: 1rem;
  line-height: 1.65;
  color: var(--cream-dim);
  max-width: 30ch;
  margin: 2.2rem 0 0;
  text-wrap: pretty;
}


/* Shown instead of a photo when the file is missing. */
.frame--missing {
  aspect-ratio: 4 / 5;
  display: grid;
  place-items: center;
  padding: 24px;
  background: transparent;
  border: 1px dashed var(--cream-faint);
  box-shadow: none;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--cream-faint);
  text-align: center;
}
.frame--missing::before { display: none; }


/* ---------- live counter ---------- */

.scene--counter .label {
  font-family: var(--display);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.25rem, 5.4vw, 1.7rem);
  color: var(--cream-dim);
  margin: 0 0 2.4rem;
}

.ticker {
  display: flex;
  gap: clamp(14px, 5vw, 32px);
  align-items: baseline;
  justify-content: center;
}
.ticker .unit { min-width: 3.2rem; }
.ticker .num {
  display: block;
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(2.1rem, 10vw, 3.4rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--cream);
}
.ticker .word {
  display: block;
  margin-top: 0.7rem;
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--cream-faint);
}

/* On the narrowest phones the four units plus their labels come to
   almost exactly the available width, so give them some room back. */
@media (max-width: 380px) {
  .ticker { gap: 10px; }
  .ticker .unit { min-width: 0; }
  .ticker .word { font-size: 0.55rem; letter-spacing: 0.12em; }
}

.scene--counter .note {
  font-size: 0.95rem;
  color: var(--cream-dim);
  margin: 2.8rem 0 0;
  max-width: 26ch;
}


/* ---------- letter ---------- */

.scene--letter {
  text-align: left;
  align-items: flex-start;
}
.scene--letter .inner { width: 100%; max-width: 34rem; margin: 0 auto; }
.scene--letter .heading {
  font-family: var(--hand);
  font-weight: 600;
  font-size: clamp(2rem, 8vw, 2.6rem);
  color: var(--rose);
  margin: 0 0 1.6rem;
  transform: rotate(-1.2deg);
}
.scene--letter p {
  font-size: 1.02rem;
  line-height: 1.85;
  color: var(--cream-dim);
  margin: 0 0 1.3rem;
  text-wrap: pretty;
}
.scene--letter p:last-child { margin-bottom: 0; }


/* ---------- finale ---------- */

.scene--finale { min-height: calc(var(--screen) * 1.1); }
.scene--finale::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  /* Was 120vw, which hung 10% of the screen width off each side. */
  width: min(100%, 800px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201, 131, 111, 0.2), transparent 65%);
  filter: blur(30px);
}
.scene--finale .final {
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(2rem, 9vw, 3.2rem);
  line-height: 1.3;
  letter-spacing: -0.015em;
  max-width: 16ch;
  margin: 0;
  text-wrap: balance;
}
.scene--finale .signoff {
  font-family: var(--hand);
  font-size: clamp(1.6rem, 6.5vw, 2rem);
  color: var(--rose);
  margin: 3.2rem 0 0;
  transform: rotate(-2.2deg);
}


/* ---------- respect reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .scene--photo .frame,
  .is-visible .scene--photo .frame { transform: rotate(var(--rot)); transition: none; }
  .gallery .frame { opacity: 1; transform: rotate(var(--rot)); transition: none; }
  .scroll-hint, .doodle--finale svg { animation: none; }
  .floaties { display: none; }
}
