/* Six months: a photo carousel. The look of the treasure in her birthday site: cream polaroids, a strip of tape, his
   hand for the dates, all on the same night sky (sky.css). One screen, nothing scrolls. */
@font-face {
  font-family: 'Caveat';
  src: url('fonts/caveat.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: 'Cormorant Garamond';
  src: url('fonts/cormorant.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Cormorant Garamond';
  src: url('fonts/cormorant-italic.woff2') format('woff2');
  font-weight: 300 700;
  font-style: italic;
  font-display: swap;
}

:root {
  --night: #1b1f3b;
  --paper: #f7f2e8;
  --card: #fffdf7;
  --ink: #1e1a16;
  --pen: #232a52;
  --candle: #f6c667;
  --silver: #c9c4d4;
  --scarlet: #7a1f2b;
  --rose: #d4475d;
  --font-doc: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-hand: 'Caveat', 'Segoe Print', cursive;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html,
body {
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--night);
  color: var(--silver);
  font-family: var(--font-doc);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--candle);
  outline-offset: 3px;
}

/* The night: a warm glow behind the photo, her birthday site's stars and candles over it. */
.stage {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  background: var(--night);
  background: radial-gradient(ellipse 70% 55% at 50% 40%, #33324a 0%, var(--night) 100%);
}

.stage::before,
.stage::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: center / cover no-repeat;
}

.stage::before {
  background-image: var(--sky-stars);
  opacity: 0.9;
}

.stage::after {
  background-image: var(--sky-candles);
  opacity: 0.5;
}

/* The slides. Only the one on show is here, and the one leaving for the length of its exit. */
.track {
  position: absolute;
  inset: 0;
  touch-action: pan-y;
}

.slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(74px + env(safe-area-inset-top)) 16px calc(78px + env(safe-area-inset-bottom));
}

.slide--cover,
.slide--end {
  padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
}

.enter-first {
  animation: in-first 700ms ease-out both;
}

.enter-next {
  animation: in-next 460ms cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

.enter-prev {
  animation: in-prev 460ms cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

.leave-next {
  animation: out-next 360ms ease-in both;
  pointer-events: none;
}

.leave-prev {
  animation: out-prev 360ms ease-in both;
  pointer-events: none;
}

/* A swipe let go short of the mark: back to the middle. */
.snap {
  transition: transform 280ms var(--spring);
}

@keyframes in-first {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes in-next {
  from {
    opacity: 0;
    transform: translateX(46vw) rotate(5deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes in-prev {
  from {
    opacity: 0;
    transform: translateX(-46vw) rotate(-5deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* --from is where her finger left it, so a swipe carries on from there. */
@keyframes out-next {
  from {
    opacity: 1;
    transform: translateX(var(--from, 0px));
  }
  to {
    opacity: 0;
    transform: translateX(-52vw) rotate(-6deg);
  }
}

@keyframes out-prev {
  from {
    opacity: 1;
    transform: translateX(var(--from, 0px));
  }
  to {
    opacity: 0;
    transform: translateX(52vw) rotate(6deg);
  }
}

/* A photograph: a cream card a little off square, a strip of tape, the day in his hand under it. */
.polaroid {
  position: relative;
  margin: 0;
  padding: 12px 12px 8px;
  border-radius: 4px;
  background: var(--card);
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.45),
    0 2px 6px rgba(0, 0, 0, 0.25);
  rotate: var(--tilt, 0deg);
}

.polaroid img {
  display: block;
  border-radius: 2px;
  background: #e9e2d2;
}

.polaroid figcaption {
  margin-top: 6px;
  min-height: 32px;
  font-family: var(--font-hand);
  font-size: 27px;
  font-weight: 500;
  line-height: 1.15;
  text-align: center;
  color: var(--pen);
}

.tape {
  position: absolute;
  top: -11px;
  left: 50%;
  width: 84px;
  height: 24px;
  margin-left: -42px;
  background: rgba(246, 198, 103, 0.62);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  rotate: -4deg;
}

/* A month's card, and the closing card: the same cream, words in place of a photograph. */
.card {
  position: relative;
  width: min(100%, 440px);
  padding: 36px 26px 30px;
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  text-align: center;
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.45),
    0 2px 6px rgba(0, 0, 0, 0.25);
  rotate: -1deg;
}

.card-kicker {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--scarlet);
}

.card-title {
  margin: 8px 0 4px;
  font-size: 46px;
  font-weight: 600;
  line-height: 1.05;
}

.card-range {
  margin: 0;
  font-family: var(--font-hand);
  font-size: 29px;
  line-height: 1.15;
  color: var(--pen);
}

.card .mini-heart {
  display: block;
  width: 26px;
  height: 26px;
  margin: 14px auto 0;
  fill: var(--rose);
}

.end-line {
  margin: 0 0 6px;
  font-family: var(--font-hand);
  font-size: 31px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--pen);
}

.end-signoff {
  margin: 16px 0 0;
  font-family: var(--font-hand);
  font-size: 27px;
  text-align: right;
  color: var(--pen);
}

.end-signature {
  margin: 0;
  padding-right: 4px;
  font-family: var(--font-hand);
  font-size: 44px;
  font-weight: 700;
  line-height: 1.1;
  text-align: right;
  color: var(--pen);
  rotate: -3deg;
}

.again {
  min-height: 44px;
  margin-top: 16px;
  padding: 0 22px;
  border-radius: 22px;
  background: var(--scarlet);
  color: var(--paper);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: transform 260ms var(--spring);
}

.again:active {
  transform: scale(1.05, 0.94);
}

/* The cover. */
.slide--cover {
  flex-direction: column;
  gap: 8px;
  text-align: center;
  color: var(--paper);
}

.cover-title {
  margin: 0;
  font-size: clamp(60px, 15vw, 128px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.01em;
}

.cover-range {
  margin: 0;
  font-family: var(--font-hand);
  font-size: clamp(27px, 5.4vw, 42px);
  color: var(--candle);
}

.heart-btn {
  width: 104px;
  height: 104px;
  margin-top: 26px;
  padding: 8px;
  border-radius: 50%;
  transition: transform 260ms var(--spring);
}

.heart-btn:active {
  transform: scale(0.9);
}

.heart-btn svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.45));
}

.cover-hint {
  margin: 4px 0 0;
  font-size: 17px;
  font-style: italic;
  letter-spacing: 0.06em;
  opacity: 0.82;
}

/* Above the photo: six hearts and the month's name. */
.top {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.months {
  display: flex;
  gap: 11px;
}

.months svg {
  width: 19px;
  height: 19px;
  overflow: visible;
  fill: none;
  stroke: var(--candle);
  stroke-width: 7;
  opacity: 0.55;
  transition:
    fill 300ms ease,
    stroke 300ms ease,
    opacity 300ms ease,
    transform 300ms var(--spring);
}

.months svg.is-on {
  fill: var(--rose);
  stroke: var(--rose);
  opacity: 1;
}

.months svg.is-now {
  transform: scale(1.32);
}

.where {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--paper);
  opacity: 0.88;
}

/* Under the photo: the slideshow button and how far she is. */
.foot {
  position: absolute;
  right: 0;
  bottom: calc(14px + env(safe-area-inset-bottom));
  left: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.play {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(247, 242, 232, 0.13);
  color: var(--paper);
}

.play svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.play .icon-pause,
.play.is-playing .icon-play {
  display: none;
}

.play.is-playing .icon-pause {
  display: block;
}

.play.is-playing {
  background: rgba(246, 198, 103, 0.28);
}

.count {
  min-width: 5.5em;
  font-size: 17px;
  letter-spacing: 0.1em;
  color: var(--paper);
  opacity: 0.85;
}

/* The note in the top corner: the music, on or off. Struck through when it is off. */
.sound {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  right: 12px;
  z-index: 7;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(247, 242, 232, 0.13);
  color: var(--candle);
}

.sound svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sound circle {
  fill: currentColor;
  stroke: none;
}

.sound .slash {
  display: none;
}

.sound.is-off {
  color: var(--silver);
}

.sound.is-off .slash {
  display: block;
}

/* Arrows at the sides, with a mouse only: a phone swipes or taps a side. */
.nav {
  position: absolute;
  top: 50%;
  z-index: 6;
  display: none;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-top: -27px;
  border-radius: 50%;
  background: rgba(247, 242, 232, 0.13);
  color: var(--paper);
}

.nav svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav--prev {
  left: max(18px, 4vw);
}

.nav--next {
  right: max(18px, 4vw);
}

@media (hover: hover) and (pointer: fine) {
  .nav {
    display: grid;
  }

  .nav:hover,
  .sound:hover,
  .play:hover {
    background: rgba(247, 242, 232, 0.24);
  }
}

/* A laptop: a little more of everything. */
@media (min-width: 900px) and (min-height: 600px) {
  .polaroid {
    padding: 15px 15px 10px;
  }

  .polaroid figcaption {
    font-size: 31px;
  }

  .card {
    width: min(100%, 520px);
    padding: 46px 36px 38px;
  }

  .card-title {
    font-size: 58px;
  }

  .card-range,
  .end-line {
    font-size: 35px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .heart-btn svg {
    animation: beat 1.8s ease-in-out infinite;
  }

  /* Lub, dub, rest. */
  @keyframes beat {
    0%,
    100% {
      transform: scale(1);
    }
    14% {
      transform: scale(1.12);
    }
    26% {
      transform: scale(1);
    }
    38% {
      transform: scale(1.07);
    }
    56% {
      transform: scale(1);
    }
  }
}

/* Reduced motion: photos fade in place; nothing slides, tilts in or beats. */
@media (prefers-reduced-motion: reduce) {
  .enter-first,
  .enter-next,
  .enter-prev {
    animation: fade-in 180ms ease both;
  }

  .leave-next,
  .leave-prev {
    animation: fade-out 180ms ease both;
  }

  .snap {
    transition: none;
  }

  @keyframes fade-in {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }

  @keyframes fade-out {
    from {
      opacity: 1;
    }
    to {
      opacity: 0;
    }
  }
}
