/* ============================================================
   US — CHAPTER ONE
   style.css — core design system, scenes, transitions
   Pastel pink · warm · cute · intimate · elegant · playful
   ============================================================ */

:root {
  /* palette */
  --pink-bg: #fff5f8;
  --pink-soft: #f9dce6;
  --pink: #e9a9bd;
  --pink-deep: #d77f9d;
  --rose: #c95f7d;
  --cream: #fffaf7;
  --warm-white: #fffdfb;
  --blush: #fbe9ef;
  --blush-deep: #f4d3de;
  --text: #4f3841;
  --text-soft: #876c76;
  --text-faint: #a9929c;

  /* typography */
  --font-serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Times New Roman", serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-hand: "Segoe Script", "Bradley Hand", "Snell Roundhand", "Brush Script MT", cursive;

  /* motion */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur-in: 0.62s;
  --dur-chapter: 1s;

  /* layout */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  /* dynamic background */
  --bg: var(--pink-bg);
  --bg-glow: rgba(233, 169, 189, 0.35);
}

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

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

html {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation; /* removes double-tap zoom, keeps pinch zoom */
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  background-color: var(--bg);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 1.1s var(--ease);
}

body * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

img {
  display: block;
  max-width: 100%;
}

/* ---------- pastel background system ---------- */

body[data-bg="night"] { --bg: #f7dde6; --bg-glow: rgba(215, 127, 157, 0.4); }
body[data-bg="cream"] { --bg: var(--cream); --bg-glow: rgba(249, 220, 230, 0.55); }
body[data-bg="warm"]  { --bg: var(--warm-white); --bg-glow: rgba(249, 220, 230, 0.4); }
body[data-bg="blush"] { --bg: var(--blush); --bg-glow: rgba(233, 169, 189, 0.4); }
body[data-bg="rose"]  { --bg: var(--blush-deep); --bg-glow: rgba(201, 95, 125, 0.28); }
body[data-bg="paper"] { --bg: #fff8f4; --bg-glow: rgba(249, 220, 230, 0.5); }

/* ---------- texture layers ---------- */

.grain {
  position: fixed;
  inset: -50%;
  z-index: 2;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    radial-gradient(rgba(79, 56, 65, 0.045) 1px, transparent 1px),
    radial-gradient(rgba(201, 95, 125, 0.035) 1px, transparent 1px);
  background-size: 3px 3px, 7px 7px;
  background-position: 0 0, 2px 3px;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% 0%, var(--bg-glow) 0%, transparent 60%),
    radial-gradient(100% 70% at 50% 100%, rgba(255, 255, 255, 0.5) 0%, transparent 65%);
  transition: background 1.1s var(--ease);
}

.lights {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  overflow: hidden;
}

.lights i {
  position: absolute;
  bottom: -8vh;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pink);
  opacity: 0.35;
  animation: drift linear infinite;
}


/* ---------- stage & scenes ---------- */

.stage {
  position: relative;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  padding:
    calc(24px + var(--safe-top))
    calc(20px + var(--safe-right))
    calc(76px + var(--safe-bottom))
    calc(20px + var(--safe-left));
}

.scene {
  grid-area: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 760px;
  max-height: 100%;
  opacity: 1;
  transform: none;
  filter: none;
  transition:
    opacity var(--dur-in) var(--ease),
    transform var(--dur-in) var(--ease),
    filter var(--dur-in) var(--ease);
  will-change: opacity, transform;
}

.scene--chapter { transition-duration: var(--dur-chapter); }

.scene.is-entering {
  opacity: 0;
  transform: translateY(12px) scale(0.985);
  filter: blur(6px);
}

.scene.is-leaving {
  opacity: 0;
  transform: translateY(-8px) scale(0.992);
  filter: blur(7px);
  pointer-events: none;
}

.scene__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-height: 100%;
  min-height: 0;
  text-align: center;
  gap: 0.55rem;
}

.scene__inner.photo { gap: 1.35rem; }

/* reveal choreography */

.reveal {
  opacity: 0;
  animation: rise 0.95s var(--ease) both;
  animation-delay: var(--d, 0s);
}

/* entrance gating — reveals begin once the scene has settled in */

.scene :is(.reveal, .placeholders li, .finale__end) {
  animation-play-state: paused;
}

.scene.is-ready :is(.reveal, .placeholders li, .finale__end) {
  animation-play-state: running;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- typography ---------- */

.eyebrow {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.34em;
  text-transform: lowercase;
  color: var(--text-faint);
}

.display {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(4.2rem, 20vw, 8.5rem);
  line-height: 0.92;
  letter-spacing: 0.06em;
  color: var(--text);
}

.display--sm {
  font-size: clamp(1.7rem, 7vw, 2.8rem);
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.chapter-tag {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0;
  font-family: var(--font-sans);
  font-size: 0.68rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.chapter-tag__sep {
  display: block;
  width: 26px;
  height: 1px;
  background: var(--pink);
}

.date {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  letter-spacing: 0.3em;
  color: var(--text-soft);
}

.date--big {
  font-size: clamp(2.1rem, 12vw, 3.6rem);
  letter-spacing: 0.18em;
  color: var(--text);
}

.line {
  margin: 0;
  max-width: 22ch;
  font-family: var(--font-serif);
  font-size: clamp(1.25rem, 5.6vw, 1.85rem);
  line-height: 1.5;
  color: var(--text);
}

.line--soft { color: var(--text-soft); }

.line--big {
  font-size: clamp(1.6rem, 8vw, 2.6rem);
  letter-spacing: 0.01em;
}

.note {
  margin: 0;
  max-width: 30ch;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-soft);
}

.hand-title {
  margin: 0;
  font-family: var(--font-hand);
  font-size: clamp(1.8rem, 8vw, 2.6rem);
  color: var(--rose);
}

.signature {
  margin: 0;
  font-family: var(--font-hand);
  font-size: 1.15rem;
  color: var(--text-soft);
}

.rule {
  width: 44px;
  height: 1px;
  margin: 0.5rem 0;
  background: var(--pink);
  border: 0;
}

/* ---------- cta ---------- */

.cta {
  margin-top: 1.4rem;
  padding: 0.85rem 1.6rem;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  letter-spacing: 0.3em;
  text-transform: lowercase;
  color: var(--rose);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--pink);
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.35s var(--ease), background-color 0.35s var(--ease), box-shadow 0.35s var(--ease);
}

.cta::before { content: "[ "; }
.cta::after  { content: " ]"; }

.cta:hover,
.cta:focus-visible {
  background: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(201, 95, 125, 0.18);
}

.cta--small {
  margin-top: 1.6rem;
  font-size: 0.66rem;
}

:where(button, a):focus-visible {
  outline: 2px solid var(--rose);
  outline-offset: 3px;
}

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

.frame {
  position: relative;
  margin: 0;
  overflow: hidden;
  border-radius: 4px;
  background: var(--blush);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 18px 40px -22px rgba(79, 56, 65, 0.45),
    0 4px 14px -6px rgba(201, 95, 125, 0.25);
}

.frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--pos, center 40%);
  transform: scale(1.045);
  animation: breathe 14s var(--ease) infinite alternate;
}

@keyframes breathe {
  from { transform: scale(1.028) translate3d(0, 0, 0); }
  to   { transform: scale(1.07) translate3d(0, -6px, 0); }
}

/* one visual language, a few quiet variations */

.frame--tall {
  width: min(60vw, 300px);
  aspect-ratio: 9 / 15.4;
}

.frame--portrait {
  width: min(74vw, 340px);
  aspect-ratio: 3 / 4;
}

.frame--wide {
  width: min(92vw, 620px);
  aspect-ratio: 4 / 3;
}

.frame--polaroid {
  width: min(70vw, 320px);
  padding: 12px 12px 54px;
  background: #fffdfc;
  border-radius: 2px;
}

.frame--polaroid img { aspect-ratio: 1 / 1.18; }

.frame--offset {
  width: min(74vw, 340px);
  aspect-ratio: 3 / 4;
  transform: translateX(-4%);
}

.photo__date {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 0.3rem 0.55rem;
  font-family: var(--font-sans);
  font-size: 0.56rem;
  letter-spacing: 0.22em;
  color: var(--rose);
  background: rgba(255, 255, 255, 0.82);
  border-radius: 999px;
}

.frame--polaroid .photo__date { bottom: 16px; }

/* ---------- things i love about you ---------- */

.love__num {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 0.78rem;
  letter-spacing: 0.4em;
  color: var(--pink-deep);
}

.progress {
  display: flex;
  gap: 7px;
  margin-top: 1.2rem;
}

.progress span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--pink);
  opacity: 0.32;
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}

.progress span.is-on {
  opacity: 1;
  transform: scale(1.35);
}

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

.envelope {
  position: relative;
  width: min(64vw, 270px);
  aspect-ratio: 3 / 2;
  margin-top: 0.6rem;
  padding: 0;
  background: linear-gradient(180deg, #fdeef3, #f8dde7);
  border: 1px solid var(--pink);
  border-radius: 6px;
  box-shadow: 0 20px 40px -24px rgba(79, 56, 65, 0.5);
  cursor: pointer;
  transition: transform 0.5s var(--ease), box-shadow 0.5s var(--ease);
}

.envelope:hover,
.envelope:focus-visible { transform: translateY(-3px); }

.envelope__flap {
  position: absolute;
  inset: 0 0 auto 0;
  height: 58%;
  background: linear-gradient(180deg, #fff6f9, #f9dee8);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform 0.75s var(--ease);
}

.envelope__seal {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 15px;
  height: 15px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--rose);
  opacity: 0.85;
  transition: opacity 0.4s var(--ease);
}

.envelope.is-open .envelope__flap { transform: rotateX(180deg); }
.envelope.is-open .envelope__seal { opacity: 0; }

.letter-scene { width: 100%; }

.letter {
  width: min(96vw, 560px);
  max-height: min(64vh, 520px);
  max-height: min(64dvh, 520px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: clamp(1.5rem, 6vw, 2.6rem);
  text-align: left;
  background: linear-gradient(180deg, #fffdfb, #fff7f4);
  border: 1px solid rgba(233, 169, 189, 0.6);
  border-radius: 6px;
  box-shadow: 0 26px 60px -34px rgba(79, 56, 65, 0.55);
}

.letter p {
  margin: 0 0 0.95rem;
  font-family: var(--font-serif);
  font-size: clamp(0.95rem, 3.7vw, 1.05rem);
  line-height: 1.75;
  color: var(--text);
}

.letter__hand {
  font-family: var(--font-hand) !important;
  font-size: clamp(1.3rem, 5.6vw, 1.7rem) !important;
  color: var(--rose) !important;
}

.letter__sign {
  font-family: var(--font-hand) !important;
  font-size: 1.2rem !important;
  color: var(--text-soft) !important;
}

.letter .cta { display: block; margin: 1.6rem auto 0; }

/* ---------- opening ---------- */

.scene--opening .scene__inner { gap: 0.9rem; }
.scene--opening .cta { margin-top: 1.9rem; }

/* ---------- became us ---------- */

.chapter-title {
  margin: 0;
  font-family: var(--font-sans);
  font-size: clamp(0.78rem, 3.4vw, 1rem);
  font-weight: 500;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--text);
}

.chapter-title--soft { color: var(--text-soft); }

.names {
  display: flex;
  gap: 1.6rem;
  margin: 0.6rem 0 0;
}

.names span {
  font-family: var(--font-hand);
  font-size: clamp(1.15rem, 5vw, 1.55rem);
  color: var(--rose);
}

/* ---------- chapter two ---------- */

.placeholders {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 1.1rem 0 0;
  padding: 0;
  list-style: none;
}

.placeholders li {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.92rem;
  color: var(--text-faint);
  opacity: 0;
  animation: rise 0.9s var(--ease) both;
  animation-delay: var(--d, 0s);
}

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

.scene--finale .scene__inner { gap: 1.5rem; }

.finale__end {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  opacity: 0;
  animation: rise 1.6s var(--ease) both;
  animation-delay: var(--d, 0s);
}

/* ---------- music ui ---------- */

.music {
  position: fixed;
  z-index: 6;
  left: calc(14px + var(--safe-left));
  bottom: calc(14px + var(--safe-bottom));
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.34rem 0.5rem 0.34rem 0.75rem;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(233, 169, 189, 0.55);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}

.music.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.music__label {
  font-family: var(--font-sans);
  font-size: 0.6rem;
  letter-spacing: 0.22em;
  color: var(--text-soft);
}

.music__btn {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  color: var(--rose);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(233, 169, 189, 0.7);
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.3s var(--ease), transform 0.3s var(--ease);
}

.music__btn:hover { transform: translateY(-1px); }
.music__btn:active { transform: scale(0.94); }

.music__icon {
  width: 13px;
  height: 13px;
  fill: currentColor;
}

.music__icon--play,
.music__icon--muted { display: none; }

.music__btn.is-paused .music__icon--pause { display: none; }
.music__btn.is-paused .music__icon--play { display: block; }
.music__btn.is-muted .music__icon--sound { display: none; }
.music__btn.is-muted .music__icon--muted { display: block; }

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

@media (prefers-reduced-motion: reduce) {
  .reveal,
  .placeholders li,
  .finale__end {
    animation-duration: 0.01s;
    animation-delay: 0s;
  }

  .frame img { animation: none; transform: none; }
  .lights { display: none; }

  .scene,
  .envelope__flap,
  .music { transition-duration: 0.2s; }

  .scene.is-entering { filter: none; transform: none; }
  .scene.is-leaving { filter: none; transform: none; }
}

