/* ==================================================================
   For Kath ♡ — a soft, romantic, pastel experience
   ================================================================== */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #fdf7f4;
  --paper: #fffdfb;
  --pink: #f6c9d3;
  --pink-soft: #fbe3e8;
  --rose: #c98a96;
  --rose-deep: #b06f7c;
  --peach: #f7e0cd;
  --lavender: #e7e2f1;
  --ink: #5d4b50;
  --ink-soft: #967d84;
  --line: rgba(201, 138, 150, 0.28);
  --shadow: rgba(178, 135, 147, 0.2);
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --script: 'Great Vibes', 'Segoe Script', cursive;
}

html {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--serif);
  color: var(--ink);
  background: #e8dbd8;
  line-height: 1.7;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Phone frame ----------
   The whole story is wrapped so it always follows a phone resolution:
   full-screen on a phone, and a centered phone-sized frame on desktop. */
.phone {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100%;
  max-height: 932px;
  overflow: hidden;
  background: var(--bg);
  container-type: size;
  isolation: isolate;
}

@media (min-width: 481px) {
  body { padding: 26px; }

  .phone {
    border-radius: 38px;
    box-shadow:
      0 0 0 10px #fffdfb,
      0 0 0 12px rgba(201, 138, 150, 0.45),
      0 26px 60px rgba(93, 75, 80, 0.35);
  }
}

::selection { background: var(--pink); color: #fff; }

[hidden] { display: none !important; }

/* ---------- Ambient background ---------- */
.blobs {
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(44rem 44rem at 12% 15%, rgba(246, 201, 211, 0.4), transparent 65%),
    radial-gradient(38rem 38rem at 88% 10%, rgba(231, 226, 241, 0.45), transparent 65%),
    radial-gradient(40rem 40rem at 85% 88%, rgba(247, 224, 205, 0.45), transparent 65%),
    radial-gradient(34rem 34rem at 6% 84%, rgba(246, 201, 211, 0.3), transparent 65%),
    linear-gradient(180deg, #fdf7f4 0%, #fbf0ec 55%, #faf2f1 100%);
}

.grain {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.045;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

/* ---------- Screens ---------- */
.screen {
  position: relative;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 72px 22px;
}

.screen.fade-out {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.9s ease;
}

/* ---------- Opening ---------- */
.screen-opening { overflow: hidden; }

.opening-inner {
  position: relative;
  z-index: 2;
  animation: openingIn 1.6s ease both;
}

.opening-title {
  margin: 0;
  font-family: var(--script);
  font-weight: 400;
  font-size: clamp(3rem, 10cqw, 5.4rem);
  line-height: 1.15;
  color: var(--rose-deep);
}

.opening-title .heart {
  color: var(--rose);
  font-size: 0.9em;
}

.opening-line {
  margin: 18px 0 0;
  font-style: italic;
  font-size: clamp(1.05rem, 3.6cqw, 1.35rem);
  letter-spacing: 0.02em;
  color: var(--ink-soft);
}

.btn-open {
  margin-top: 44px;
  font-family: var(--serif);
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: #fff;
  background: linear-gradient(135deg, #eab2c0, #c98a96);
  border: none;
  border-radius: 999px;
  padding: 15px 44px 16px 48px;
  cursor: pointer;
  box-shadow: 0 14px 32px rgba(201, 138, 150, 0.35);
  transition: transform 0.4s ease, box-shadow 0.4s ease;
}

.btn-open:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(201, 138, 150, 0.45);
}

.btn-open:active { transform: translateY(0) scale(0.98); }

.btn-open:focus-visible {
  outline: 2px solid var(--rose-deep);
  outline-offset: 3px;
}

.btn-open:disabled { opacity: 0.85; cursor: default; }

@keyframes openingIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Floating particles (opening) ---------- */
.particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 1;
  pointer-events: none;
}

.particle {
  position: absolute;
  bottom: -8%;
  border-radius: 50%;
  opacity: 0;
  animation-name: particleFloat;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

@keyframes particleFloat {
  0%   { transform: translateY(0) translateX(0); opacity: 0; }
  12%  { opacity: 0.7; }
  88%  { opacity: 0.5; }
  100% { transform: translateY(-112cqh) translateX(var(--drift, 12px)); opacity: 0; }
}

/* ---------- Music control ---------- */
.music-control {
  position: absolute;
  right: 14px;
  bottom: 16px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 253, 251, 0.88);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 6px 5px 16px;
  box-shadow: 0 8px 24px rgba(178, 135, 147, 0.22);
  animation: openingIn 1.2s ease both;
}

.music-label {
  font-style: italic;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  white-space: nowrap;
}

.music-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: var(--pink-soft);
  color: var(--rose-deep);
  font-size: 0.82rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease, transform 0.3s ease;
}

.music-btn:hover { background: var(--pink); transform: scale(1.06); }

.music-btn:focus-visible {
  outline: 2px solid var(--rose-deep);
  outline-offset: 2px;
}

.music-btn.muted { text-decoration: line-through; }

/* ---------- Countdown ---------- */
.screen-countdown { overflow: hidden; }

.countdown-inner { position: relative; z-index: 2; }

.countdown-intro {
  margin: 0;
  font-family: var(--script);
  font-size: clamp(2rem, 7cqw, 3rem);
  line-height: 1.3;
  color: var(--rose-deep);
  animation: openingIn 1.4s ease both;
}

.countdown-sub {
  margin: 6px 0 0;
  font-style: italic;
  font-size: clamp(1rem, 3.4cqw, 1.3rem);
  color: var(--ink-soft);
  animation: openingIn 1.4s ease 0.35s both;
}

.count-num {
  margin-top: 48px;
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(5rem, 20cqw, 8.5rem);
  line-height: 1;
  color: var(--rose);
  opacity: 0;
}

.count-num.anim { animation: numIn 1.5s ease both; }

.count-text {
  margin-top: 18px;
  min-height: 2.6rem;
  font-family: var(--script);
  font-size: clamp(1.4rem, 5.5cqw, 2rem);
  color: var(--rose-deep);
  opacity: 0;
}

.count-text.anim { animation: numIn 1.5s ease 0.18s both; }

@keyframes numIn {
  0%   { opacity: 0; transform: scale(1.3); filter: blur(5px); }
  35%  { opacity: 1; filter: blur(0); }
  100% { opacity: 1; transform: scale(1); }
}


/* ---------- Photo sections ---------- */
.photo-section {
  justify-content: center;
  padding: 72px 18px 72px;
  overflow: hidden;
}

.photo-wrap {
  opacity: 0;
  transform: translateY(32px);
  transition: opacity 1.3s ease, transform 1.3s ease;
}

.photo-section.visible .photo-wrap {
  opacity: 1;
  transform: none;
}

.photo-number {
  display: block;
  font-family: var(--script);
  font-size: clamp(1.8rem, 6cqw, 2.6rem);
  line-height: 1;
  color: var(--rose);
  margin-bottom: 18px;
}

.photo-frame {
  position: relative;
  margin: 0 auto;
  background: var(--paper);
  padding: 12px;
  border-radius: 8px;
  box-shadow: 0 22px 50px var(--shadow), 0 3px 10px rgba(178, 135, 147, 0.1);
  overflow: hidden;
  max-width: min(92cqw, 560px);
}

.p1 .photo-frame { transform: rotate(-0.7deg); }
.p2 .photo-frame { transform: rotate(0.6deg); }
.p3 .photo-frame { transform: rotate(-0.5deg); }
.p4 .photo-frame { transform: rotate(0.8deg); }
.p5 .photo-frame { transform: rotate(-0.4deg); }

.photo-frame img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 68cqh;
  object-fit: contain;
  border-radius: 4px;
  will-change: transform;
}

.photo-caption {
  margin: 26px auto 0;
  max-width: 34ch;
  font-style: italic;
  font-size: clamp(1.15rem, 4.4cqw, 1.65rem);
  color: var(--ink);
}

.photo-caption-sub {
  margin: 8px auto 0;
  max-width: 42ch;
  font-style: italic;
  font-size: clamp(0.95rem, 3.4cqw, 1.15rem);
  color: var(--ink-soft);
}

/* Photo 5 — slower, more breathing room */
.p5 { padding-top: 130px; padding-bottom: 130px; }
.p5 .photo-wrap { transition-duration: 2.2s; }

/* Missing-photo placeholder (during development only) */
.photo-frame.missing {
  min-width: 240px;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-frame.missing::after {
  content: 'photo coming soon ♡';
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink-soft);
}

/* Tap-to-continue hint */
.tap-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 24px;
  z-index: 35;
  text-align: center;
  font-style: italic;
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: lowercase;
  color: var(--ink-soft);
  pointer-events: none;
  animation: openingIn 0.9s ease both;
}

.tap-hint .arrow {
  display: inline-block;
  margin-left: 4px;
  animation: hintBob 2.4s ease-in-out infinite;
}

@keyframes hintBob {
  0%, 100% { transform: translateY(0); opacity: 0.6; }
  50%      { transform: translateY(5px); opacity: 1; }
}

/* ---------- Transition to letter ---------- */
.transition-line {
  margin: 0;
  font-family: var(--script);
  font-size: clamp(1.8rem, 6.5cqw, 3rem);
  line-height: 1.4;
  color: var(--rose-deep);
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 1.6s ease, transform 1.6s ease;
}

.screen-transition.visible .transition-line {
  opacity: 1;
  transform: none;
}

/* ---------- Final message ---------- */
.screen-letter {
  height: 100%;
  justify-content: flex-start;
  overflow: hidden;
  padding-top: 96px;
  padding-bottom: 120px;
}

.letter-body {
  flex: none;
  max-width: 44rem;
  margin: 0 auto;
}

.letter-block {
  margin: 0 0 1.7em;
  font-size: clamp(1.08rem, 3.6cqw, 1.32rem);
  line-height: 1.9;
  color: var(--ink);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1.1s ease, transform 1.1s ease;
}

.letter-block.visible {
  opacity: 1;
  transform: none;
}

.letter-center {
  text-align: center;
  font-style: italic;
  color: var(--rose-deep);
}

.letter-sign {
  margin-top: 2.2em;
  font-family: var(--script);
  font-size: clamp(1.7rem, 6cqw, 2.4rem);
  text-align: center;
  color: var(--rose-deep);
}

/* ---------- Closing ---------- */
.screen-closing {
  padding-top: 120px;
  padding-bottom: 120px;
  overflow: hidden;
}

.closing-inner {
  position: relative;
  z-index: 2;
  max-width: 40rem;
}

.closing-line {
  margin: 0;
  font-weight: 500;
  font-size: clamp(1.5rem, 5.4cqw, 2.3rem);
  line-height: 1.5;
  color: var(--ink);
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 1.6s ease, transform 1.6s ease;
}

.screen-closing.visible .closing-line {
  opacity: 1;
  transform: none;
}

.closing-sig {
  margin: 34px 0 0;
  font-family: var(--script);
  font-size: clamp(1.5rem, 5cqw, 2.1rem);
  color: var(--rose-deep);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 1.6s ease 0.5s, transform 1.6s ease 0.5s;
}

.screen-closing.visible .closing-sig {
  opacity: 1;
  transform: none;
}

/* Floating hearts (closing) */
.hearts {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 1;
  pointer-events: none;
}

.heart-bit {
  position: absolute;
  bottom: -6%;
  color: var(--rose);
  opacity: 0;
  animation-name: heartRise;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

@keyframes heartRise {
  0%   { transform: translateY(0) translateX(0) rotate(-8deg); opacity: 0; }
  15%  { opacity: 0.55; }
  85%  { opacity: 0.4; }
  100% { transform: translateY(-108cqh) translateX(var(--drift, 16px)) rotate(10deg); opacity: 0; }
}


/* ---------- Responsive ---------- */
@container (max-width: 640px) {
  .screen { padding: 56px 16px; }

  .photo-section { padding: 72px 14px 72px; }

  .photo-frame { padding: 8px; border-radius: 6px; }

  .p1 .photo-frame,
  .p2 .photo-frame,
  .p3 .photo-frame,
  .p4 .photo-frame,
  .p5 .photo-frame { transform: none; }

  .music-control {
    right: 10px;
    bottom: 12px;
  }

  .music-label {
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .tap-hint { bottom: 66px; }
}

@container (max-height: 520px) and (orientation: landscape) {
  .photo-section { padding-top: 54px; padding-bottom: 54px; }
  .photo-frame img { max-height: 62cqh; }
  .photo-caption { margin-top: 16px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.2s !important;
  }
}

