:root {
  --night:  #0E0820;
  --rose:   #FF6B8B;
  --blush:  #FFC2D1;
  --candle: #FFD9A0;
  --cream:  #FFF4E6;
}

* { box-sizing: border-box; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;   /* stop iOS inflating the type */
  text-size-adjust: 100%;
}

/* Pinned to the viewport on every device: no rubber-band scroll on iPhone,
   no jump when Safari's toolbar collapses. */
body {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  margin: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  padding:
    calc(4vh + env(safe-area-inset-top)) calc(5vw + env(safe-area-inset-right))
    calc(4vh + env(safe-area-inset-bottom)) calc(5vw + env(safe-area-inset-left));

  background:
    radial-gradient(120% 90% at 50% 110%, #3A1B45 0%, transparent 60%),
    radial-gradient(90% 70% at 20% 0%, #241141 0%, transparent 55%),
    var(--night);
  color: var(--cream);

  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;        /* kills iOS double-tap zoom delay */
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- ambient glow ---------- */

.glow {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(140vmin, 1100px);
  height: min(140vmin, 1100px);
  margin: 0;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle,
    rgba(255, 217, 160, 0.16) 0%,
    rgba(255, 107, 139, 0.10) 35%,
    transparent 68%);
  animation: breathe 7s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes breathe {
  0%, 100% { opacity: 0.75; transform: translate(-50%, -50%) scale(1); }
  50%      { opacity: 1;    transform: translate(-50%, -50%) scale(1.08); }
}

/* ---------- the card ---------- */

.card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 34rem;
  padding: clamp(1rem, 5vw, 2.5rem);
  text-align: center;
  will-change: transform;
  animation: drift 9s ease-in-out infinite;
}

@keyframes drift {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50%      { transform: translate3d(0, -10px, 0); }
}

.message {
  margin: 0;
  font-family: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.6rem, 5.6vw, 3rem);
  line-height: 1.35;
  letter-spacing: 0.01em;
  text-wrap: balance;
  text-shadow: 0 0 34px rgba(255, 194, 209, 0.35);
}

.line { display: block; }

.line + .line {
  margin-top: 0.4em;
  font-size: 0.72em;
  color: var(--blush);
}

/* each word is wrapped by script.js, then revealed one at a time */
.word {
  display: inline-block;
  opacity: 0;
  transform: translate3d(0, 16px, 0);
  filter: blur(8px);
  animation: word-in 1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes word-in {
  to { opacity: 1; transform: translate3d(0, 0, 0); filter: blur(0); }
}

.hint {
  margin: clamp(1.75rem, 5vw, 3rem) 0 0;
  font-family: "Karla", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: clamp(0.6rem, 2.2vw, 0.68rem);
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: rgba(255, 194, 209, 0.45);
  opacity: 0;
  animation: word-in 1.4s ease forwards;
}

/* ---------- hearts ---------- */

.hearts {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
  contain: strict;
}

.heart {
  position: absolute;
  will-change: transform, opacity;
  animation: rise var(--dur) linear forwards;
}

.heart i {
  display: block;
  animation: sway calc(var(--dur) / 2) ease-in-out infinite alternate;
}

.heart svg {
  display: block;
  width: var(--size);
  height: auto;
  filter: drop-shadow(0 0 6px rgba(255, 107, 139, 0.55));
}

/* --dist is set in pixels by script.js, so travel is identical everywhere */
@keyframes rise {
  0%   { transform: translate3d(0, 0, 0);                     opacity: 0; }
  12%  {                                                      opacity: var(--peak); }
  75%  {                                                      opacity: var(--peak); }
  100% { transform: translate3d(0, calc(-1 * var(--dist)), 0); opacity: 0; }
}

@keyframes sway {
  from { transform: translate3d(calc(-1 * var(--sway)), 0, 0) rotate(-14deg) scale(0.85); }
  to   { transform: translate3d(var(--sway), 0, 0)            rotate(12deg)  scale(1); }
}

/* ---------- short/landscape screens (iPhone on its side) ---------- */

@media (max-height: 520px) {
  .message { font-size: clamp(1.25rem, 4.6vh, 2rem); }
  .hint    { margin-top: 1.25rem; }
  .card    { padding: 0.5rem; }
}

/* ---------- accessibility ---------- */

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

@media (prefers-reduced-motion: reduce) {
  .glow, .card, .heart, .heart i { animation: none; }
  .word, .hint { animation-duration: 0.01ms; }
  .word { opacity: 1; transform: none; filter: none; }
  .hint { opacity: 1; }
}
