@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+KR:wght@400;600;700&family=Noto+Sans+KR:wght@300;400;500&display=swap');

:root {
  --gold: #b8935a;
  --deep-red: #7a2e2e;
  --ink: #2b2320;
  --cream: #faf6ef;
  --cream-dim: #f1e9db;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Noto Sans KR', sans-serif;
  background: var(--cream);
  color: var(--ink);
  overflow-x: hidden;
}

body.envelope-locked { overflow: hidden; height: 100vh; }

/* ambient particle field */
.particle-field {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
}

.particle {
  position: absolute;
  top: -20px;
  border-radius: 0 100% 0 100%;
  background: var(--petal-color, radial-gradient(circle at 30% 30%, #ffd9e6, #f2a8c2 60%, #e08bab));
  animation: petalFall linear infinite;
}

@keyframes petalFall {
  0%   { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0; }
  8%   { opacity: 0.9; }
  25%  { transform: translateY(27vh) translateX(calc(var(--drift, 60px) * 0.6)) rotate(160deg); }
  50%  { transform: translateY(55vh) translateX(calc(var(--drift, 60px) * -0.4)) rotate(320deg); }
  75%  { transform: translateY(82vh) translateX(calc(var(--drift, 60px) * 0.8)) rotate(480deg); }
  92%  { opacity: 0.85; }
  100% { transform: translateY(110vh) translateX(var(--drift, 60px)) rotate(640deg); opacity: 0; }
}

/* ENVELOPE INTRO */
.envelope-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.75rem;
  background: radial-gradient(ellipse at center, var(--cream-dim) 0%, var(--cream) 75%);
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

.envelope-overlay.opened {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.envelope {
  position: relative;
  width: min(320px, 78vw);
  height: 210px;
  perspective: 1000px;
}

.envelope-body {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #fffdf9, var(--cream-dim));
  border: 1px solid rgba(184, 147, 90, 0.5);
  box-shadow: 0 25px 60px -20px rgba(43, 35, 32, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 1.2rem;
}

.envelope-to {
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: var(--ink);
  opacity: 0.7;
}

.envelope-seal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -30%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--deep-red);
  color: var(--cream);
  font-family: 'Noto Serif KR', serif;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(122,46,46,0.4);
}

.envelope-flap {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 110px;
  background: linear-gradient(135deg, var(--cream-dim), #fffdf9);
  clip-path: polygon(0 0, 100% 0, 50% 90%);
  border: 1px solid rgba(184, 147, 90, 0.5);
  transform-origin: top center;
  transition: transform 0.9s cubic-bezier(0.5, 0, 0.2, 1);
  z-index: 2;
}

.envelope.open .envelope-flap {
  transform: rotateX(180deg);
}

.envelope-letter-peek {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 6px;
  height: 0;
  background: #fff;
  border: 1px solid rgba(184, 147, 90, 0.35);
  box-shadow: 0 -6px 16px rgba(0,0,0,0.06);
  transition: height 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.35s, bottom 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.35s;
}

.envelope.open .envelope-letter-peek {
  height: 170px;
  bottom: 60px;
}

.envelope-open-btn {
  background: var(--deep-red);
  color: var(--cream);
  border: none;
  padding: 0.85rem 2.2rem;
  border-radius: 999px;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 0 10px 25px -8px rgba(122,46,46,0.5);
  transition: transform 0.25s ease;
}
.envelope-open-btn:hover { transform: translateY(-2px) scale(1.03); }
.envelope-open-btn.hidden { opacity: 0; pointer-events: none; }

.envelope-hint {
  font-size: 0.75rem;
  color: var(--gold);
  letter-spacing: 0.05em;
  opacity: 0.85;
}

/* progress bar */
.progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--deep-red));
  z-index: 100;
  transition: width 0.1s linear;
}

/* HERO */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  background: radial-gradient(ellipse at center, var(--cream-dim) 0%, var(--cream) 70%);
}

.hero-content { max-width: 700px; position: relative; z-index: 2; }

.hero-parallax {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.hero-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.35;
  transition: transform 0.2s ease-out;
}
.orb-1 { width: 260px; height: 260px; top: 8%; left: 8%; background: radial-gradient(circle, var(--gold), transparent 70%); }
.orb-2 { width: 180px; height: 180px; bottom: 12%; right: 10%; background: radial-gradient(circle, var(--deep-red), transparent 70%); }
.orb-3 { width: 130px; height: 130px; top: 55%; left: 78%; background: radial-gradient(circle, var(--gold), transparent 70%); }

.hero-hanja {
  font-family: 'Noto Serif KR', serif;
  font-size: 1.6rem;
  letter-spacing: 0.3em;
  color: var(--deep-red);
  opacity: 0.8;
  margin-bottom: 0.75rem;
}

.hero-eyebrow {
  letter-spacing: 0.3em;
  font-size: 0.75rem;
  color: var(--gold);
  font-weight: 500;
  margin-bottom: 1.5rem;
}

.hero-title {
  font-family: 'Noto Serif KR', serif;
  font-weight: 700;
  font-size: clamp(2rem, 6vw, 3.4rem);
  line-height: 1.35;
  color: var(--deep-red);
  margin-bottom: 1.75rem;
}

.hero-date {
  font-size: 1rem;
  letter-spacing: 0.05em;
  color: var(--ink);
  opacity: 0.75;
  margin-bottom: 2rem;
}

.hero-sub {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--ink);
  opacity: 0.65;
}

.scroll-cue {
  position: absolute;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  color: var(--gold);
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  transition: opacity 0.4s ease;
}

.scroll-cue-line {
  width: 1px;
  height: 40px;
  background: linear-gradient(var(--gold), transparent);
  animation: scrollPulse 1.8s ease-in-out infinite;
}

@keyframes scrollPulse {
  0%   { transform: scaleY(0.4); opacity: 0.3; }
  50%  { transform: scaleY(1);   opacity: 1; }
  100% { transform: scaleY(0.4); opacity: 0.3; }
}

/* CINEMATIC STAGE GALLERY */
.stage-lead {
  text-align: center;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  color: var(--gold);
  opacity: 0.85;
  padding: 3rem 1.5rem 0;
}

.stage-wrap {
  position: relative;
  /* height is set inline by script.js based on photo count */
}

.stage {
  position: sticky;
  top: 0;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: #0e0a08;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage-frame {
  position: absolute;
  inset: 0;
}

.stage-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  will-change: opacity;
}

.stage-slide.active {
  opacity: 1;
}

.stage-slide-bg {
  position: absolute;
  inset: -8%;
  background-size: cover;
  background-position: center;
  filter: blur(45px) brightness(0.55) saturate(1.1);
  transform: scale(1.06);
  animation: kenburnsBg 10s ease-in-out infinite alternate;
}

.stage-slide-img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 20px 60px rgba(0, 0, 0, 0.55));
  animation: kenburnsFg 10s ease-in-out infinite alternate;
}

@keyframes kenburnsBg {
  0%   { transform: scale(1.06) translate(0, 0); }
  100% { transform: scale(1.16) translate(-2%, -2%); }
}

@keyframes kenburnsFg {
  0%   { transform: scale(1); }
  100% { transform: scale(1.025); }
}

.stage-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.55) 100%);
  pointer-events: none;
}

.stage-grain {
  position: absolute;
  inset: -10%;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.stage-click-target {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 3;
}

.stage-hud {
  position: absolute;
  left: 1.5rem;
  bottom: 1.75rem;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  pointer-events: none;
}

.stage-index {
  font-family: 'Noto Serif KR', serif;
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  color: var(--cream);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.stage-progress {
  position: relative;
  width: 140px;
  height: 3px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  pointer-events: auto;
  cursor: pointer;
  padding: 10px 0;
  background-clip: content-box;
  touch-action: none;
}

.stage-progress-fill {
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--cream));
  border-radius: 999px;
  pointer-events: none;
}

.stage-hint {
  position: absolute;
  right: 1.5rem;
  bottom: 1.75rem;
  z-index: 4;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.7);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.stage-swipe-hint {
  position: absolute;
  left: 50%;
  bottom: 6.5rem;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.stage-swipe-hint.hidden {
  opacity: 0;
}

.stage-swipe-hint p {
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.stage-swipe-chevron {
  width: 16px;
  height: 16px;
  border-right: 2px solid rgba(255, 255, 255, 0.85);
  border-bottom: 2px solid rgba(255, 255, 255, 0.85);
  transform: rotate(45deg);
  margin-top: -10px;
  animation: chevronBounce 1.6s ease-in-out infinite;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.stage-swipe-chevron:nth-child(2) {
  animation-delay: 0.25s;
}

@keyframes chevronBounce {
  0%, 100% { opacity: 0.3; transform: rotate(45deg) translate(0, 0); }
  50%      { opacity: 1;   transform: rotate(45deg) translate(6px, 6px); }
}

/* LETTER */
.letter {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6rem 2rem;
  background: linear-gradient(180deg, var(--cream) 0%, var(--cream-dim) 100%);
}

.letter-content {
  max-width: 620px;
  text-align: left;
  background: #fffdf9;
  border: 1px solid rgba(184, 147, 90, 0.3);
  box-shadow: 0 30px 70px -30px rgba(43, 35, 32, 0.3);
  padding: clamp(2rem, 6vw, 4rem);
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 1s ease, transform 1s ease;
}

.letter-content.in-view {
  opacity: 1;
  transform: translateY(0);
}

.letter-eyebrow {
  letter-spacing: 0.3em;
  font-size: 0.7rem;
  color: var(--gold);
  font-weight: 500;
  margin-bottom: 1.75rem;
  text-align: center;
}

.letter-content .salutation {
  font-family: 'Noto Serif KR', serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--deep-red);
  margin-bottom: 1.5rem;
}

.letter-content p {
  font-size: 0.95rem;
  line-height: 2;
  color: var(--ink);
  opacity: 0.85;
  margin-bottom: 1.4rem;
}

.letter-content .valediction {
  margin-top: 2rem;
  font-size: 1rem;
  opacity: 1;
}

.letter-content .valediction strong {
  font-family: 'Noto Serif KR', serif;
  color: var(--deep-red);
  font-size: 1.1rem;
}

.letter-date {
  text-align: center;
  font-size: 0.85rem;
  opacity: 0.55;
  margin-bottom: 2rem !important;
}

.letter-content .back-top { display: block; margin: 0 auto; }

.back-top {
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 0.7rem 1.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background 0.3s ease, color 0.3s ease;
}
.back-top:hover { background: var(--gold); color: #fff; }

/* MUSIC PLAYER */
.music-player {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  z-index: 50;
}

.music-toggle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--deep-red);
  color: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(122, 46, 46, 0.4);
  transition: transform 0.2s ease;
}
.music-toggle:hover { transform: scale(1.06); }
.music-toggle .icon-note { width: 20px; height: 20px; }

.music-bars {
  display: none;
  gap: 3px;
  position: absolute;
}
.music-toggle.playing .icon-note { display: none; }
.music-toggle.playing .music-bars { display: flex; align-items: flex-end; height: 16px; }
.music-bars i {
  width: 3px;
  background: var(--cream);
  animation: bar 1s ease-in-out infinite;
}
.music-bars i:nth-child(1) { height: 60%; animation-delay: 0s; }
.music-bars i:nth-child(2) { height: 100%; animation-delay: 0.2s; }
.music-bars i:nth-child(3) { height: 40%; animation-delay: 0.4s; }

@keyframes bar {
  0%, 100% { transform: scaleY(0.4); }
  50% { transform: scaleY(1); }
}

.music-label {
  font-size: 0.7rem;
  color: var(--ink);
  background: rgba(255,255,255,0.85);
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  opacity: 0;
  transform: translateX(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  white-space: nowrap;
}
.music-player:hover .music-label { opacity: 1; transform: translateX(0); }

@media (max-width: 640px) {
  .music-label { display: none; }
  .hero-orb { display: none; }
  .letter-content { padding: 1.75rem; }
  .stage-hint { display: none; }
  .stage-progress { width: 90px; }
}

/* LIGHTBOX */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 14, 10, 0.92);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.lightbox.open { opacity: 1; visibility: visible; }

.lightbox-img {
  max-width: 90vw;
  max-height: 85vh;
  border: 6px solid #fff;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  transform: scale(0.85);
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.lightbox.open .lightbox-img { transform: scale(1); }

.lightbox-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}

.lightbox-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

.lightbox-flash.flash {
  animation: flashPop 0.4s ease-out;
}

@keyframes flashPop {
  0% { opacity: 0.9; }
  100% { opacity: 0; }
}
