/* =====================================================
   OPEN WHEN... LOVE LETTER VAULT — styles.css
   ===================================================== */

:root {
  --color-bg: #0d0a1a;
  --color-primary: #e8456b;
  --color-primary-light: #ff6b8a;
  --color-primary-dark: #c2364f;
  --color-accent: #f4a0b5;
  --color-gold: #d4a853;
  --color-gold-light: #f0d48a;
  --color-cream: #fdf6ee;
  --color-paper: #fef9f0;
  --color-paper-lines: #e8ddd0;
  --color-ink: #2c1810;
  --color-envelope: #d4885a;
  --color-envelope-dark: #b86f45;
  --color-envelope-flap: #c47a4f;
  --color-seal: #8b1a2b;
  --color-seal-dark: #6b1420;
  --font-script: 'Dancing Script', cursive;
  --font-handwriting: 'Caveat', cursive;
  --font-display: 'Playfair Display', serif;
  --font-body: 'Inter', sans-serif;
}

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

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-cream);
  cursor: none;
  overflow-x: hidden;
  min-height: 100vh;
}

@media (pointer: coarse) {
  body {
    cursor: auto;
  }
}

/* ── Canvas layers ── */
#heartCanvas,
#confettiCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#heartCanvas {
  z-index: 9999;
}

#confettiCanvas {
  z-index: 9998;
}

/* ── Floating notes ── */
#floatingNotes {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.floating-note {
  position: absolute;
  font-family: var(--font-handwriting);
  color: rgba(232, 69, 107, 0.15);
  font-size: 1rem;
  white-space: nowrap;
  animation: floatUp linear forwards;
  pointer-events: none;
}

@keyframes floatUp {
  0% {
    transform: translateY(100vh) rotate(0deg);
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  90% {
    opacity: 1;
  }

  100% {
    transform: translateY(-10vh) rotate(20deg);
    opacity: 0;
  }
}

/* ── Parallax hearts ── */
#parallaxHearts {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.parallax-heart {
  position: absolute;
  color: rgba(232, 69, 107, 0.06);
  transition: transform 0.3s ease-out;
}

/* ── Dynamic background ── */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(232, 69, 107, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(212, 168, 83, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(139, 26, 43, 0.08) 0%, transparent 50%),
    linear-gradient(180deg, #0d0a1a 0%, #1a0f2e 50%, #0d0a1a 100%);
  animation: gradientShift 15s ease-in-out infinite alternate;
}

@keyframes gradientShift {
  0% {
    background-position: 0% 0%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 50% 100%;
  }
}

/* ── Music toggle ── */
.music-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: none;
  color: var(--color-accent);
  transition: all 0.3s ease;
}

.music-toggle:hover {
  background: rgba(232, 69, 107, 0.2);
  border-color: var(--color-primary);
  transform: scale(1.1);
}

.music-icon {
  width: 22px;
  height: 22px;
}

.music-toggle.playing .music-off {
  display: none !important;
}

.music-toggle.playing .music-on {
  display: block !important;
}

.music-toggle:not(.playing) .music-on {
  display: none !important;
}

/* ── HERO ── */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  padding: 2rem;
}

.hero-content {
  max-width: 620px;
  animation: fadeInUp 1.2s ease-out;
}

.hero-heart-icon {
  /* width: 60px;
  height: 60px; */
  margin: 0 auto 2rem;
  color: var(--color-primary);
  animation: heartbeat 1.5s ease-in-out infinite;
  filter: drop-shadow(0 0 24px rgba(232, 69, 107, 0.45));
  cursor: pointer;
}

.hero-heart-icon svg {
  width: 60px;
  height: 60px;
}

@keyframes heartbeat {

  0%,
  100% {
    transform: scale(1);
  }

  15% {
    transform: scale(1.18);
  }

  30% {
    transform: scale(1);
  }

  45% {
    transform: scale(1.12);
  }
}

h1.hero-title {
  font-family: var(--font-script);
  font-size: clamp(3rem, 8vw, 5.5rem);
  font-weight: 700;
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-accent), var(--color-gold-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1.5rem;
  line-height: 1.2;
}

h3.hero-title {
  font-family: var(--font-script);
  font-size: clamp(1rem, 6vw, 3.5rem);
  font-weight: 700;
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-accent), var(--color-gold-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1.5rem;
  line-height: 1.2;
}

.hero-subtitle {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  color: rgba(253, 246, 238, 0.7);
  margin-bottom: 1rem;
  line-height: 1.7;
}

.hero-hint {
  font-size: 0.9rem;
  color: rgba(253, 246, 238, 0.4);
  margin-bottom: 3rem;
}

.scroll-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  animation: fadeInUp 1.2s ease-out 0.5s both;
}

.scroll-indicator span {
  font-size: 0.75rem;
  color: rgba(253, 246, 238, 0.3);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.scroll-arrow {
  width: 24px;
  height: 24px;
  color: var(--color-primary);
  opacity: 0.5;
  animation: bounceDown 2s ease-in-out infinite;
}

.scroll-arrow svg {
  width: 100%;
  height: 100%;
}

@keyframes bounceDown {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(8px);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Vault section ── */
.vault-section {
  padding: 4rem 2rem 6rem;
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.section-header {
  text-align: center;
  margin-bottom: 4rem;
}

.section-header h2 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  color: var(--color-cream);
  margin-bottom: 0.5rem;
}

.section-header p {
  color: rgba(253, 246, 238, 0.4);
  font-size: 0.95rem;
}

/* ── Grid ── */
.envelope-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 3rem;
  perspective: 1200px;
}

/* ── Envelope wrapper (scroll reveal) ── */
.envelope-wrapper {
  position: relative;
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.envelope-wrapper.visible {
  opacity: 1;
  transform: translateY(0);
}

.envelope-wrapper:nth-child(1) {
  transition-delay: 0.05s;
}

.envelope-wrapper:nth-child(2) {
  transition-delay: 0.15s;
}

.envelope-wrapper:nth-child(3) {
  transition-delay: 0.25s;
}

.envelope-wrapper:nth-child(4) {
  transition-delay: 0.35s;
}

.envelope-wrapper:nth-child(5) {
  transition-delay: 0.45s;
}

.envelope-wrapper:nth-child(6) {
  transition-delay: 0.55s;
}

.envelope-wrapper:nth-child(7) {
  transition-delay: 0.65s;
}

.envelope-wrapper:nth-child(8) {
  transition-delay: 0.75s;
}

.envelope-wrapper:nth-child(9) {
  transition-delay: 0.85s;
}

.envelope-wrapper:nth-child(10) {
  transition-delay: 0.95s;
}

.envelope-wrapper:nth-child(11) {
  transition-delay: 1.05s;
}

.envelope-wrapper:nth-child(12) {
  transition-delay: 1.15s;
}

/* ── Envelope ── */
.envelope {
  position: relative;
  width: 100%;
  aspect-ratio: 1.5 / 1;
  cursor: none;
  transform-style: preserve-3d;
  transition: transform 0.4s ease;
}

.envelope:hover {
  transform: translateY(-8px) rotateX(2deg);
}

/* ── Envelope back ── */
.envelope-back {
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, var(--color-envelope), var(--color-envelope-dark));
  border-radius: 12px;
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.3),
    0 2px 10px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* ── Flap ── */
.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 55%;
  background: linear-gradient(180deg, var(--color-envelope-flap), var(--color-envelope));
  clip-path: polygon(0 0, 50% 65%, 100% 0);
  transform-origin: top center;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 3;
  border-radius: 12px 12px 0 0;
}

.envelope:hover .envelope-flap {
  transform: rotateX(-25deg);
}

.envelope.opened .envelope-flap {
  transform: rotateX(-180deg);
  z-index: 0;
}

/* ── Wax seal ── */
/* Sits at the V-tip of the flap triangle.
   Flap is 55% tall, V-point at 65% of that = 35.75% from the envelope top. */
.wax-seal {
  position: absolute;
  top: 33%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 56px;
  height: 56px;
  background: radial-gradient(circle at 35% 35%, #c4243b, var(--color-seal), var(--color-seal-dark));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 4px 15px rgba(0, 0, 0, 0.4),
    inset 0 2px 4px rgba(255, 255, 255, 0.15),
    inset 0 -2px 4px rgba(0, 0, 0, 0.2);
  cursor: none;
  z-index: 10;
  transition: box-shadow 0.3s ease, transform 0.3s ease;
  user-select: none;
  touch-action: none;
}

.wax-seal::before {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.08);
}

.wax-seal:hover {
  box-shadow:
    0 6px 25px rgba(139, 26, 43, 0.5),
    inset 0 2px 4px rgba(255, 255, 255, 0.15);
  transform: translate(-50%, -50%) scale(1.1);
}

.wax-seal.dragging {
  opacity: 0.85;
  position: fixed !important;
  transition: none !important;
  z-index: 9999;
}

@keyframes sealBreak {
  0% {
    transform: scale(1.2);
    opacity: 1;
  }

  30% {
    transform: scale(1.6);
    opacity: 0.8;
  }

  60% {
    transform: scale(0.5) rotate(180deg);
    opacity: 0.4;
  }

  100% {
    transform: scale(0) rotate(360deg);
    opacity: 0;
  }
}

.wax-seal.breaking {
  animation: sealBreak 0.55s ease-out forwards;
}

.seal-icon {
  font-size: 1.3rem;
  color: rgba(255, 255, 255, 0.6);
}

.seal-locked .seal-icon {
  font-size: 1.1rem;
}

/* ── Envelope front ── */
.envelope-front {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 65%;
  background: linear-gradient(180deg, var(--color-envelope), var(--color-envelope-dark));
  border-radius: 0 0 12px 12px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.envelope-front::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
}

.envelope-label {
  text-align: center;
  padding: 0.6rem 1.5rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.label-text {
  font-family: var(--font-handwriting);
  font-size: 1.15rem;
  color: var(--color-cream);
  font-weight: 500;
}

.label-emoji {
  display: block;
  font-size: 1.4rem;
  margin-top: 0.3rem;
}

/* ── Lock info ── */
.lock-info {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.3rem;
  padding: 0.3rem 0.8rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  font-size: 0.75rem;
  color: rgba(253, 246, 238, 0.5);
}

.lock-icon {
  font-size: 0.8rem;
}

.envelope-locked {
  opacity: 0.6;
  filter: grayscale(0.3);
}

.envelope-locked:hover {
  transform: translateY(-4px);
}

.envelope-locked .wax-seal {
  cursor: not-allowed;
}

/* ── Drag hint ── */
.seal-drag-hint {
  position: absolute;
  bottom: -35px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: rgba(253, 246, 238, 0.35);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease;
  font-family: var(--font-body);
  pointer-events: none;
}

.envelope:hover .seal-drag-hint {
  opacity: 1;
}

.envelope.opened .seal-drag-hint {
  display: none;
}

/* ── Letter overlay ── */
.letter-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 10, 26, 0);
  backdrop-filter: blur(0px);
  opacity: 0;
  visibility: hidden;
  transition: all 0.5s ease;
  padding: 2rem;
  cursor: none;
}

.letter-overlay.active {
  opacity: 1;
  visibility: visible;
  background: rgba(13, 10, 26, 0.88);
  backdrop-filter: blur(14px);
}

/* ── Letter paper ── */
.letter-paper {
  position: relative;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--color-paper);
  border-radius: 4px;
  padding: 3rem 2.5rem;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.4);
  transform: scale(0.85) rotateX(8deg);
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  background-image: repeating-linear-gradient(transparent, transparent 31px,
      var(--color-paper-lines) 31px, var(--color-paper-lines) 32px);
  background-position-y: 20px;
  border-left: 3px solid rgba(232, 69, 107, 0.15);
}

.letter-paper::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 40px;
  height: 40px;
  background: linear-gradient(225deg, rgba(0, 0, 0, 0.05) 50%, transparent 50%);
}

.letter-overlay.active .letter-paper {
  transform: scale(1) rotateX(0);
}

.letter-paper::-webkit-scrollbar {
  width: 6px;
}

.letter-paper::-webkit-scrollbar-track {
  background: transparent;
}

.letter-paper::-webkit-scrollbar-thumb {
  background: var(--color-paper-lines);
  border-radius: 3px;
}

/* ── Close button ── */
.letter-close {
  position: sticky;
  top: 0;
  float: right;
  width: 36px;
  height: 36px;
  background: rgba(44, 24, 16, 0.06);
  border: none;
  border-radius: 50%;
  font-size: 1.4rem;
  color: var(--color-ink);
  cursor: none;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  line-height: 1;
}

.letter-close:hover {
  background: rgba(232, 69, 107, 0.15);
  color: var(--color-primary-dark);
  transform: rotate(90deg);
}

/* ── Letter content ── */
.letter-date {
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: rgba(44, 24, 16, 0.35);
  margin-bottom: 1.5rem;
  text-align: right;
}

.letter-content p {
  font-family: var(--font-handwriting);
  font-size: 1.25rem;
  color: var(--color-ink);
  line-height: 2;
  margin-bottom: 0.3rem;
  opacity: 0;
  transform: translateY(10px);
}

.letter-content p.typed {
  animation: typeIn 0.5s ease forwards;
}

@keyframes typeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.letter-signature {
  font-family: var(--font-script) !important;
  font-size: 1.4rem !important;
  color: var(--color-primary-dark) !important;
  margin-top: 1.5rem !important;
  padding-top: 1rem;
}

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 4rem 2rem 2rem;
  position: relative;
  z-index: 2;
}

.footer-hearts {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.footer-hearts span {
  color: var(--color-primary);
  font-size: 1.2rem;
  animation: heartbeat 1.5s ease-in-out infinite;
  opacity: 0.5;
}

.footer-hearts span:nth-child(2) {
  animation-delay: 0.3s;
}

.footer-hearts span:nth-child(3) {
  animation-delay: 0.6s;
}

.footer p {
  font-family: var(--font-handwriting);
  font-size: 1.1rem;
  color: rgba(253, 246, 238, 0.3);
}

.footer-year {
  font-family: var(--font-body) !important;
  font-size: 0.8rem !important;
  margin-top: 0.5rem;
  color: rgba(253, 246, 238, 0.15) !important;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .envelope-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
    max-width: 400px;
    margin: 0 auto;
  }

  .letter-paper {
    padding: 2rem 1.5rem;
  }

  .letter-content p {
    font-size: 1.1rem;
  }
}

@media (max-width: 480px) {
  .letter-overlay {
    padding: 1rem;
  }

  .letter-paper {
    padding: 1.5rem 1.2rem;
  }

  .wax-seal {
    width: 46px;
    height: 46px;
  }

  .seal-icon {
    font-size: 1.1rem;
  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .floating-note,
  .parallax-heart {
    display: none;
  }
}