/* ============================================================
   The letter — warm light pink, scroll-revealed.
   ============================================================ */

:root {
  --bg:          #FFF5F0;
  --bg-deep:     #FFEDE5;
  --surface:     #FFFAF7;
  --accent:      #F49AA8;
  --accent-deep: #E87F91;
  --accent-soft: #F7C6C7;
  --text:        #7A3B4A;
  --text-muted:  #A9737F;
  --shadow:      0 18px 46px rgba(200, 120, 130, .22);
  --font-display:'Quicksand', 'Nunito', 'Segoe UI', system-ui, sans-serif;
  --font-body:   'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at 12% 6%,  #FFE8DE 0%, transparent 48%),
    radial-gradient(circle at 88% 30%, #FFEAF0 0%, transparent 46%),
    radial-gradient(circle at 20% 78%, #FFEDE0 0%, transparent 50%),
    var(--bg);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- scroll progress ---------- */
.progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #F7B79E);
  z-index: 50;
  transition: width .12s linear;
}

/* ---------- drifting hearts ---------- */
.petals { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.petal {
  position: absolute;
  color: var(--accent-soft);
  opacity: 0;
  animation: drift linear infinite;
  user-select: none;
}
@keyframes drift {
  0%   { transform: translateY(105vh) rotate(0deg)   scale(.8); opacity: 0; }
  10%  { opacity: .5; }
  90%  { opacity: .3; }
  100% { transform: translateY(-12vh) rotate(320deg) scale(1.1); opacity: 0; }
}

/* ---------- hero ---------- */
.hero {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  position: relative;
  z-index: 1;
}
.hero-inner { animation: rise 1s cubic-bezier(.2, .8, .3, 1) both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(26px); }
  to   { opacity: 1; transform: translateY(0); }
}
.hero-heart {
  font-size: 3rem;
  color: var(--accent);
  animation: beat 2.1s ease-in-out infinite;
  line-height: 1;
}
@keyframes beat {
  0%, 100% { transform: scale(1); }
  14%      { transform: scale(1.16); }
  28%      { transform: scale(1); }
  42%      { transform: scale(1.1); }
}
.hero-kicker {
  font-family: var(--font-display);
  font-size: .95rem;
  letter-spacing: .38em;
  text-transform: lowercase;
  color: var(--text-muted);
  margin: 1.4rem 0 .2rem;
  padding-left: .38em;
}
.hero-name {
  font-family: var(--font-display);
  font-size: clamp(3rem, 14vw, 6rem);
  font-weight: 700;
  margin: 0;
  line-height: 1.05;
  background: linear-gradient(120deg, var(--accent-deep), #F5A77F);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin: 1.1rem auto 0;
  max-width: 30ch;
  line-height: 1.7;
}
.hero-sub:empty { display: none; }

.scroll-cue {
  position: absolute;
  bottom: 30px;
  color: var(--text-muted);
  font-size: .72rem;
  letter-spacing: .22em;
  text-transform: lowercase;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: .8;
}
.scroll-arrow { font-size: 1.1rem; animation: nudge 1.8s ease-in-out infinite; }
@keyframes nudge {
  0%, 100% { transform: translateY(0); opacity: .5; }
  50%      { transform: translateY(7px); opacity: 1; }
}

/* ---------- memories ---------- */
.letter {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 24px 40px;
}

.memory {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(24px, 5vw, 56px);
  align-items: center;
  margin: clamp(70px, 13vh, 130px) 0;
}
/* Alternate sides so the page has a rhythm instead of one long column. */
.memory:nth-child(even) .memory-media { order: 2; }
.memory:nth-child(even) .memory-text  { order: 1; text-align: right; }

.memory-media {
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--bg-deep);
  position: relative;
  line-height: 0;
}
.memory-media img,
.memory-media video {
  width: 100%;
  height: auto;
  display: block;
  max-height: 74dvh;
  object-fit: cover;
}

.memory-index {
  font-family: var(--font-display);
  font-size: 3.4rem;
  font-weight: 700;
  color: var(--accent-soft);
  line-height: 1;
  opacity: .75;
}
.memory-caption {
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 2.6vw, 1.6rem);
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
  margin: .5rem 0 0;
}
.memory-caption:empty { display: none; }

/* sound toggle on videos */
.sound-btn {
  position: absolute;
  bottom: 14px;
  right: 14px;
  background: rgba(255, 255, 255, .92);
  color: var(--accent-deep);
  border: none;
  border-radius: 999px;
  padding: 9px 17px;
  font-size: .8rem;
  font-weight: 700;
  font-family: var(--font-display);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(200, 120, 130, .22);
  line-height: 1;
}
.sound-btn:hover { background: #fff; }

/* missing file placeholder */
.media-fallback {
  aspect-ratio: 4 / 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, #FFE8E0, #FFEEF2);
  color: var(--text-muted);
  font-size: .82rem;
  font-family: var(--font-body);
  text-align: center;
  padding: 20px;
  line-height: 1.5;
}
.media-fallback::before { content: '♡'; font-size: 2.2rem; color: var(--accent-soft); }

/* ---------- scroll reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(34px);
  transition: opacity .85s cubic-bezier(.2, .8, .3, 1),
              transform .85s cubic-bezier(.2, .8, .3, 1);
}
.reveal.visible { opacity: 1; transform: translateY(0); }
/* Media trails its text slightly, so each section arrives rather than snaps. */
.memory .memory-media.reveal { transition-delay: .12s; }

/* ---------- ending ---------- */
.ending {
  position: relative;
  z-index: 1;
  min-height: 82dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px 80px;
}
.ending-heart {
  font-size: 2.6rem;
  color: var(--accent);
  animation: beat 2.1s ease-in-out infinite;
  margin-bottom: 1rem;
}
.ending-note {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 4.5vw, 2.2rem);
  font-weight: 600;
  line-height: 1.6;
  max-width: 22ch;
  margin: 0;
  background: linear-gradient(120deg, var(--accent-deep), #F5A77F);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.ending-note:empty { display: none; }
.ending-sign {
  color: var(--text-muted);
  font-size: 1rem;
  margin-top: 1.4rem;
  letter-spacing: .05em;
}
.ending-sign:empty { display: none; }

.game-link {
  margin-top: 3rem;
  color: var(--text-muted);
  font-size: .82rem;
  text-decoration: none;
  border-bottom: 1px solid var(--accent-soft);
  padding-bottom: 3px;
  transition: color .2s ease, border-color .2s ease;
}
.game-link:hover { color: var(--accent-deep); border-color: var(--accent); }
.game-link[hidden] { display: none; }

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 760px) {
  .letter { padding: 0 18px 20px; }

  .memory {
    grid-template-columns: 1fr;
    gap: 18px;
    margin: 64px 0;
  }
  /* Stacked: always media first, text under, regardless of alternation. */
  .memory .memory-media { order: 1 !important; }
  .memory .memory-text  { order: 2 !important; text-align: left !important; }

  .memory-index { font-size: 2.4rem; }
  .memory-media img, .memory-media video { max-height: 66dvh; }
  .ending { min-height: 70dvh; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .petals, .scroll-arrow { display: none; }
  .hero-heart, .ending-heart { animation: none; }
}
