/* ════════════════════════════════════════════════════════════
   VINTAGE PNG — style.css
   Warm parchment letter paper + PNG envelope crossfade
   ════════════════════════════════════════════════════════════ */

/* ════════════════════════════════════════════════════════════
   CSS VARIABLES
   ════════════════════════════════════════════════════════════ */
:root {
  /* ── Background ──────────────────────────────── */
  --bg-top: #f5f0e8;
  --bg-bottom: #e8e0d0;

  /* ── Paper ─────────────────────────────────────── */
  --paper-bg: #faf6ee;
  --paper-bg2: #f4ede0;
  --paper-border: rgba(180, 158, 120, 0.3);

  /* ── Inks ──────────────────────────────────────── */
  --ink-primary: #3a3020;
  --ink-secondary: #6b5840;
  --ink-faded: rgba(58, 48, 32, 0.4);

  /* ── Accent colors ─────────────────────────────── */
  --seal-red: #9e3b3b;
  --seal-red-light: #c75b4a;
  --ribbon-red: #b8453a;
  --ribbon-mid: #c94f44;
  --ribbon-dark: #a03830;
  --sage: #7a9e7e;
  --blush: #d4b8c8;
  --warm-brown: #8b6b4a;

  /* ── Typography ─────────────────────────────────── */
  --font-hand: 'Caveat', cursive;
  --font-serif: 'Cormorant Garamond', 'Georgia', serif;
  --font-body: 'Caveat', cursive;
  --font-ui: 'DM Sans', system-ui, sans-serif;
  --font-signature: 'Sacramento', cursive;
}

/* ════════════════════════════════════════════════════════════
   BLUE MIDNIGHT COLOR SCHEME
   Applied when config.vintageColor === 'midnight'
   ════════════════════════════════════════════════════════════ */
[data-vintage-color="midnight"] {
  /* ── Background: deep navy ───────────────────────── */
  --bg-top:    #0b1628;
  --bg-bottom: #071020;

  /* ── Paper: stays cream for readability ─────────── */
  --paper-bg:     #f8f3e8;
  --paper-bg2:    #f0e8d8;
  --paper-border: rgba(140, 170, 220, 0.25);

  /* ── Inks: dark on cream paper ───────────────────── */
  --ink-primary:   #2a2418;
  --ink-secondary: #4a3c28;
  --ink-faded:     rgba(42, 36, 24, 0.4);

  /* ── Accent: midnight silver/blue tones ─────────── */
  --seal-red:       #3a5a9e;
  --seal-red-light: #4a72c0;
  --warm-brown:     #5a7aae;
}

/* Midnight: dark starry background */
[data-vintage-color="midnight"] .static-bg {
  background: linear-gradient(160deg, #0b1628 0%, #071020 100%);
}

/* Midnight: subtle stars/particles vibe via box-shadow on body pseudo */
[data-vintage-color="midnight"] body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 15% 25%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 42% 10%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 68% 35%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 88% 18%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 32% 72%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 75% 68%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 20% 82%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 55% 88%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 92% 78%, rgba(255,255,255,0.35) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 5%  50%, rgba(255,255,255,0.45) 0%, transparent 100%);
  pointer-events: none;
  z-index: 1;
}

/* Midnight: corner vines look different (silver/blue tint) */
[data-vintage-color="midnight"] .corner-vine {
  filter: hue-rotate(190deg) saturate(0.6) brightness(0.7);
  opacity: 0.55;
}

/* Midnight: loading text goes light */
[data-vintage-color="midnight"] .loading-title,
[data-vintage-color="midnight"] .loading-sub {
  color: rgba(220, 230, 255, 0.8);
}

/* Midnight: tap hint text goes light */
[data-vintage-color="midnight"] .vintage-tap-hint {
  color: rgba(200, 220, 255, 0.7);
}

/* Midnight: letter paper — add subtle blue border glow */
[data-vintage-color="midnight"] .letter-paper {
  box-shadow:
    0 0 0 1px rgba(100, 140, 220, 0.15),
    0 20px 80px rgba(0, 20, 60, 0.6),
    0 4px 20px rgba(0, 10, 40, 0.4);
}

/* Midnight: recipient tag — light text so it's visible on dark navy envelope */
[data-vintage-color="midnight"] .vintage-tag-for {
  color: rgba(210, 225, 255, 0.6);
}

[data-vintage-color="midnight"] .vintage-tag-name {
  color: rgba(230, 240, 255, 0.85);
  text-shadow: 0 1px 8px rgba(0, 20, 80, 0.5);
}


/* ════════════════════════════════════════════════════════════
   RESET & BASE
   ════════════════════════════════════════════════════════════ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-ui);
  color: var(--ink-primary);
  min-height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  background: var(--bg-top);
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

.hidden {
  display: none !important;
}

/* ════════════════════════════════════════════════════════════
   STATIC BACKGROUND
   ════════════════════════════════════════════════════════════ */
.static-bg {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  z-index: 0;
}

/* ════════════════════════════════════════════════════════════
   STATE MACHINE
   ════════════════════════════════════════════════════════════ */
.state-screen {
  position: relative;
  z-index: 10;
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.state-screen.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  display: none !important;
}

.state-screen.is-entering {
  opacity: 0;
  transform: translateY(18px);
}

.state-screen.is-exiting {
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
}

/* ════════════════════════════════════════════════════════════
   LOADING STATE
   ════════════════════════════════════════════════════════════ */
.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.6rem;
}

.loading-spinner {
  position: relative;
  width: 64px;
  height: 64px;
}

.spinner-svg {
  animation: spinnerRotate 1.8s linear infinite;
}

.spinner-arc {
  animation: spinnerDash 1.8s ease-in-out infinite;
}

@keyframes spinnerRotate {
  to {
    transform: rotate(360deg);
  }
}

@keyframes spinnerDash {
  0% {
    stroke-dasharray: 10 150;
    stroke-dashoffset: 0;
  }

  50% {
    stroke-dasharray: 80 150;
    stroke-dashoffset: -30;
  }

  100% {
    stroke-dasharray: 10 150;
    stroke-dashoffset: -120;
  }
}

.spinner-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-label {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--warm-brown);
  font-size: 1rem;
  letter-spacing: 0.04em;
  opacity: 0.8;
}

/* ════════════════════════════════════════════════════════════
   MAINTENANCE STATE
   ════════════════════════════════════════════════════════════ */
.maintenance-content {
  text-align: center;
  color: var(--warm-brown);
  padding: 2rem;
}

.maintenance-content h1 {
  font-family: var(--font-hand);
  font-size: 2.2rem;
  margin-bottom: 0.8rem;
}

.maintenance-content p {
  font-family: var(--font-serif);
  font-style: italic;
  opacity: 0.75;
}

.maint-footer {
  margin-top: 2rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  justify-content: center;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  opacity: 0.45;
  text-transform: uppercase;
}

.maint-footer .dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}

/* ════════════════════════════════════════════════════════════
   PASSWORD GATE
   ════════════════════════════════════════════════════════════ */
#password-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(45, 35, 25, 0.35);
  backdrop-filter: blur(12px) saturate(1.1);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
}

.gate-card {
  background: var(--paper-bg);
  border-radius: 4px;
  padding: 4rem 3rem 3.5rem;
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.6);
  border: 1px solid var(--paper-border);
  position: relative;
}

.gate-card::before {
  content: '';
  position: absolute;
  inset: 12px;
  border: 1px solid var(--seal-red-light);
  opacity: 0.3;
  border-radius: 2px;
  pointer-events: none;
}

.gate-icon {
  margin-top: -5.5rem;
  margin-bottom: 1.5rem;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.25));
}

.gate-title {
  font-family: var(--font-hand);
  font-size: 2.8rem;
  font-weight: 400;
  color: var(--ink-primary);
  margin-bottom: 0.5rem;
}

.gate-desc {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-style: italic;
  color: var(--ink-secondary);
  margin-bottom: 2rem;
}

#gate-hint-container {
  margin: 1.5rem auto 2.5rem;
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid var(--paper-border);
  border-radius: 4px;
  padding: 16px 20px;
  max-width: 90%;
}

.hint-label {
  font-family: var(--font-ui);
  font-size: 0.6rem;
  letter-spacing: 0.25em;
  color: var(--seal-red);
  text-transform: uppercase;
  margin-bottom: 6px;
  display: block;
  font-weight: 600;
}

#gate-hint-text {
  font-family: var(--font-hand);
  color: var(--ink-primary);
  font-size: 1.5rem;
  margin: 0;
}

.gate-input-wrapper {
  margin-bottom: 2.5rem;
}

.gate-input-wrapper input {
  width: 80%;
  padding: 0.8rem 0;
  border: none;
  border-bottom: 2px solid color-mix(in srgb, var(--seal-red-light) 60%, transparent);
  background: transparent;
  font-family: var(--font-hand);
  font-size: 1.8rem;
  color: var(--ink-primary);
  text-align: center;
  outline: none;
  transition: border-color 0.3s;
}

.gate-input-wrapper input::placeholder {
  color: var(--ink-faded);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.2rem;
}

.gate-input-wrapper input:focus {
  border-bottom-color: var(--seal-red);
}

#btn-gate-verify {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 14px 44px;
  background: var(--seal-red);
  color: #fff;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--seal-red) 40%, transparent);
  transition: all 0.3s ease;
}

#btn-gate-verify:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--seal-red) 50%, transparent);
  background: var(--ribbon-dark);
}

#gate-error {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--seal-red);
  margin-top: 1.2rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ════════════════════════════════════════════════════════════
   VINTAGE PNG ENVELOPE
   ════════════════════════════════════════════════════════════ */
.vintage-envelope-scene {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 2rem;
}

.vintage-envelope-wrap {
  position: relative;
  cursor: pointer;
  width: clamp(300px, 70vw, 620px);
  /* Gentle floating animation */
  animation: vintageFloat 5s ease-in-out infinite;
  filter: drop-shadow(0 20px 50px rgba(80, 50, 20, 0.35));
  outline: none;
}

@keyframes vintageFloat {

  0%,
  100% {
    transform: translateY(0) rotate(-0.5deg);
  }

  50% {
    transform: translateY(-10px) rotate(0.5deg);
  }
}

.vintage-envelope-wrap:hover {
  animation: none;
  filter: drop-shadow(0 28px 60px rgba(80, 50, 20, 0.45));
  transform: translateY(-14px) scale(1.01);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.4s ease;
}

/* Both images are stacked on top of each other */
.env-closed,
.env-open {
  width: 100%;
  display: block;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}

.env-open {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  transition: opacity 0.55s ease;
}

.env-closed {
  transition: opacity 0.55s ease;
}

/* Crossfade: when .is-opening is added by JS */
.vintage-envelope-wrap.is-opening .env-closed {
  opacity: 0;
}

.vintage-envelope-wrap.is-opening .env-open {
  opacity: 1;
}

/* Shake animation on click */
@keyframes _vintage-shake {
  0% {
    transform: rotate(0deg) translateX(0);
  }

  15% {
    transform: rotate(-1.8deg) translateX(-4px);
  }

  30% {
    transform: rotate(1.8deg) translateX(4px);
  }

  45% {
    transform: rotate(-1.2deg) translateX(-3px);
  }

  60% {
    transform: rotate(1.2deg) translateX(3px);
  }

  75% {
    transform: rotate(-0.6deg) translateX(-2px);
  }

  90% {
    transform: rotate(0.4deg) translateX(1px);
  }

  100% {
    transform: rotate(0deg) translateX(0);
  }
}

.vintage-envelope-wrap.is-shaking {
  animation: _vintage-shake 0.5s ease !important;
}

/* ── Recipient Tag ──────────────────────────────────────── */
.vintage-recipient-tag {
  position: absolute;
  bottom: 12%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 4;
  pointer-events: none;
}

.vintage-tag-for {
  display: block;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.7rem;
  color: rgba(58, 48, 32, 0.5);
  letter-spacing: 0.1em;
}

.vintage-tag-name {
  font-family: var(--font-hand);
  font-size: 1.5rem;
  font-weight: 600;
  color: rgba(58, 48, 32, 0.65);
  line-height: 1.1;
}

/* ── Tap Hint ─────────────────────────────────────────── */
.vintage-tap-hint {
  position: absolute;
  bottom: -2.8rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  opacity: 0;
  animation: hintFadeIn 0.8s ease 2s forwards;
  white-space: nowrap;
}

@keyframes hintFadeIn {
  to {
    opacity: 0.65;
  }
}

.tap-hint-text {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.78rem;
  color: var(--warm-brown);
  letter-spacing: 0.06em;
}

/* ════════════════════════════════════════════════════════════
   LETTER STATE
   ════════════════════════════════════════════════════════════ */
#state-letter {
  align-items: flex-start;
  justify-content: center;
}

.letter-scroll {
  position: relative;
  z-index: 5;
  width: 100%;
  max-width: 820px;
  padding: 2.5rem 1rem 1rem;
  margin: 0 auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.letter-scroll::-webkit-scrollbar {
  width: 4px;
}

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

.letter-scroll::-webkit-scrollbar-thumb {
  background: rgba(139, 107, 74, 0.2);
  border-radius: 2px;
}

/* ── Letter Paper ─────────────────────────────────────── */
.letter-paper {
  position: relative;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  border-radius: 3px;
  padding: clamp(2rem, 5vw, 3.2rem) clamp(1.6rem, 5vw, 3rem);

  /* Parchment: multi-layer uneven gradient, tidak flat */
  background:
    radial-gradient(ellipse at 7% 5%, rgba(175, 143, 90, 0.13) 0%, transparent 42%),
    radial-gradient(ellipse at 93% 4%, rgba(158, 128, 80, 0.10) 0%, transparent 38%),
    radial-gradient(ellipse at 12% 96%, rgba(168, 136, 88, 0.11) 0%, transparent 36%),
    radial-gradient(ellipse at 88% 93%, rgba(152, 122, 76, 0.09) 0%, transparent 34%),
    radial-gradient(ellipse at 50% 50%, rgba(235, 220, 195, 0.00) 0%, rgba(225, 208, 180, 0.07) 100%),
    linear-gradient(172deg, #f8f1e2 0%, #f4ecda 32%, #f1e7d2 62%, #eee0c8 100%);

  border: 1px solid rgba(175, 148, 108, 0.52);
  box-shadow:
    0 0 0 1px rgba(200, 175, 130, 0.18),
    inset 0 0 90px rgba(165, 135, 85, 0.055),
    0 2px 0 rgba(200, 170, 120, 0.45),
    0 6px 24px rgba(70, 50, 20, 0.18),
    0 20px 60px rgba(70, 50, 20, 0.20),
    0 40px 80px rgba(60, 40, 15, 0.10);

  /* Reveal animation */
  opacity: 0;
  transform: translateY(35px) scale(0.97);
  transition: opacity 1.2s ease, transform 1.2s cubic-bezier(0.34, 1.15, 0.64, 1);
}

/* Paper grain — lebih kuat, pakai multiply agar menyatu */
.letter-paper::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 3px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.72' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
  pointer-events: none;
  opacity: 1;
  z-index: 10;
}

/* Corner stains + aged yellowing di sudut */
.letter-paper::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 3px;
  background:
    radial-gradient(ellipse 80px 65px at 0% 0%, rgba(158, 122, 65, 0.13) 0%, transparent 100%),
    radial-gradient(ellipse 62px 50px at 100% 0%, rgba(148, 114, 60, 0.10) 0%, transparent 100%),
    radial-gradient(ellipse 72px 58px at 0% 100%, rgba(153, 118, 63, 0.11) 0%, transparent 100%),
    radial-gradient(ellipse 66px 52px at 100% 100%, rgba(145, 110, 58, 0.09) 0%, transparent 100%);
  pointer-events: none;
  z-index: 1;
}

.letter-paper.is-revealing {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ── Fold Creases ─────────────────────────────────────── */
.fold-crease {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
      transparent 0%,
      rgba(148, 118, 72, 0.16) 8%,
      rgba(160, 128, 80, 0.22) 50%,
      rgba(148, 118, 72, 0.16) 92%,
      transparent 100%);
  pointer-events: none;
  z-index: 2;
}

.fold-crease-1 {
  top: 33.3%;
}

.fold-crease-2 {
  top: 66.6%;
}

/* ── Ruled Lines ──────────────────────────────────────── */
.ruled-lines {
  position: absolute;
  inset: clamp(2rem, 5vw, 3.2rem) clamp(1.6rem, 5vw, 3rem);
  pointer-events: none;
  z-index: 0;
  background-image: repeating-linear-gradient(to bottom,
      transparent,
      transparent calc(1.7em * 1.45 - 1px),
      rgba(135, 105, 65, 0.07) calc(1.7em * 1.45 - 1px),
      rgba(135, 105, 65, 0.07) calc(1.7em * 1.45));
  background-size: 100% calc(1.45rem * 1.7);
  background-position: 0 calc(1.45rem * 1.7 * 2.1);
}

/* ── Watercolor Edge ───────────────────────────────────── */
.watercolor-edge {
  position: absolute;
  left: 0;
  right: 0;
  height: 60px;
  pointer-events: none;
  z-index: 0;
}

.watercolor-edge-top {
  top: 0;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, rgba(200, 219, 200, 0.15) 0%, rgba(212, 184, 200, 0.08) 40%, transparent 100%);
}

.watercolor-edge-bottom {
  bottom: 0;
  border-radius: 0 0 3px 3px;
  background: linear-gradient(0deg, rgba(200, 219, 200, 0.12) 0%, rgba(212, 184, 200, 0.06) 40%, transparent 100%);
}

/* ── Corner Vines ─────────────────────────────────────── */
.corner-vine {
  position: absolute;
  width: 90px;
  height: 90px;
  pointer-events: none;
  z-index: 1;
}

.corner-vine-tl {
  top: 0;
  left: 0;
}

.corner-vine-tr {
  top: 0;
  right: 0;
}

/* ── Letter Header ────────────────────────────────────── */
.letter-header {
  position: relative;
  z-index: 2;
  margin-bottom: 1.5rem;
}

.header-ornament {
  margin-bottom: 1rem;
  opacity: 0.8;
}

.letter-title {
  font-family: var(--font-serif);
  font-size: clamp(2.8rem, 8vw, 3.4rem);
  font-style: italic;
  color: var(--ink-primary);
  font-weight: 500;
  text-align: center;
  margin-bottom: 0.2rem;
  line-height: 1;
}

.title-underline {
  width: 100%;
  max-width: 300px;
  margin: -0.5rem auto 0.5rem auto;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.title-underline.is-visible {
  opacity: 1;
}

.meta-date {
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink-faded);
  letter-spacing: 0.05em;
  text-align: center;
  display: block;
  margin: 0.45rem auto 1.5rem auto;
}

.header-divider,
.footer-divider {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.6rem 0;
}

.divider-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(180, 158, 120, 0.4), transparent);
}

.divider-leaf {
  flex-shrink: 0;
}

/* ── Letter Salutation ────────────────────────────────── */
.letter-salutation {
  margin-bottom: 1.2rem;
}

.meta-to-name {
  font-family: var(--font-signature);
  font-size: clamp(2.6rem, 7vw, 3.2rem);
  color: var(--ink-primary);
  font-weight: 400;
  line-height: 0.8;
  position: relative;
  display: inline-block;
  margin-bottom: 1.2rem;
}

.meta-to-name::after,
.meta-to-name::before {
  content: '';
  position: absolute;
  left: 0;
  height: 2px;
  background: var(--ink-primary);
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.meta-to-name.has-content::after,
.meta-to-name.has-content::before {
  opacity: 1;
}

.meta-to-name.has-content::after {
  bottom: -5px;
  width: 100%;
  opacity: 0.5;
  transform: rotate(0.5deg);
}

.meta-to-name.has-content::before {
  bottom: -10px;
  width: 78%;
  opacity: 0.28;
  transform: rotate(-0.4deg);
}

/* ── Letter Body ──────────────────────────────────────── */
.letter-body {
  position: relative;
  z-index: 2;
  font-family: var(--font-body);
  font-size: clamp(1.25rem, 3.2vw, 1.45rem);
  font-weight: 500;
  line-height: 1.7;
  color: var(--ink-primary);
  min-height: 3rem;
  letter-spacing: 0.01em;
}

.letter-body p {
  margin-bottom: 1.1em;
}

.letter-body .tw-cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--warm-brown);
  border-radius: 1px;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: cursorBlink 0.8s step-end infinite;
}

@keyframes cursorBlink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }
}

/* ── Letter Footer ────────────────────────────────────── */
.letter-footer {
  position: relative;
  z-index: 2;
  margin-top: 1.5rem;
}

.letter-from-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  margin-top: 0.5rem;
}

.letter-from {
  font-family: var(--font-signature);
  font-size: clamp(2.2rem, 6vw, 2.8rem);
  color: var(--ink-primary);
  font-weight: 400;
  line-height: 1;
  position: relative;
  display: inline-block;
  margin-bottom: 0.5rem;
}

.letter-from::after,
.letter-from::before {
  content: '';
  position: absolute;
  right: 0;
  height: 2px;
  background: var(--ink-primary);
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.letter-from.has-content::after,
.letter-from.has-content::before {
  opacity: 1;
}

.letter-from.has-content::after {
  bottom: -5px;
  width: 100%;
  opacity: 0.5;
  transform: rotate(-0.5deg);
}

.letter-from.has-content::before {
  bottom: -10px;
  width: 78%;
  opacity: 0.28;
  transform: rotate(0.4deg);
}


/* ════════════════════════════════════════════════════════════
   ACTION BUTTONS
   ════════════════════════════════════════════════════════════ */
.btn-ribbon-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.5rem;
  border-radius: 22px;
  font-family: var(--font-serif);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.btn-primary-action {
  background: linear-gradient(135deg, var(--ribbon-red), var(--ribbon-dark));
  color: white;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  margin-bottom: 0.8rem;
}

.btn-primary-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.btn-secondary-action {
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink-secondary);
  border: 1px solid rgba(180, 158, 120, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 2px 10px rgba(80, 60, 30, 0.08);
}

.btn-secondary-action:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.9);
}

/* ════════════════════════════════════════════════════════════
   SECRET MEMORY MODAL
   ════════════════════════════════════════════════════════════ */
.memory-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(50, 40, 25, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.memory-modal[aria-hidden="false"] {
  opacity: 1;
  pointer-events: auto;
}

.memory-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  font-size: 1.4rem;
  color: rgba(240, 230, 210, 0.7);
  background: rgba(255, 255, 255, 0.08);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.memory-close:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.memory-counter {
  position: absolute;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.8rem;
  color: rgba(240, 230, 210, 0.55);
  letter-spacing: 0.08em;
}

.memory-carousel {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1rem;
  max-width: 100vw;
}

.memory-arrow {
  font-size: 2.2rem;
  color: rgba(240, 230, 210, 0.65);
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: background 0.2s, color 0.2s, transform 0.2s;
  flex-shrink: 0;
}

.memory-arrow:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  transform: scale(1.08);
}

.memory-arrow:disabled {
  opacity: 0.2;
  pointer-events: none;
}

.polaroid-frame {
  position: relative;
  background: var(--paper-bg);
  border-radius: 3px;
  padding: 0.8rem 0.8rem 1.5rem;
  box-shadow: 0 8px 30px rgba(40, 30, 15, 0.45), 0 1px 0 rgba(220, 200, 170, 0.7);
  max-width: min(320px, 78vw);
  width: 100%;
  border: 1px solid rgba(200, 185, 155, 0.4);
}

.polaroid-media {
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--paper-bg2);
  overflow: hidden;
  border-radius: 2px;
  border: 1px solid rgba(200, 185, 155, 0.25);
}

.polaroid-media img,
.polaroid-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.polaroid-caption {
  margin-top: 0.6rem;
  font-family: var(--font-hand);
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--ink-secondary);
  text-align: center;
  min-height: 1.4rem;
  padding: 0 0.4rem;
}

/* ════════════════════════════════════════════════════════════
   MUSIC PLAYER FAB
   ════════════════════════════════════════════════════════════ */
#music-player-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  background: rgba(250, 246, 238, 0.88);
  border: 1px solid rgba(200, 185, 155, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 50%;
  color: var(--warm-brown);
  transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.3s ease;
  box-shadow: 0 4px 16px rgba(80, 60, 30, 0.15);
  cursor: pointer;
  opacity: 0;
}

#music-player-fab.visible {
  opacity: 1;
}

#music-player-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 24px rgba(80, 60, 30, 0.22);
}

#music-fab-icon {
  font-size: 1rem;
  line-height: 1;
  transition: opacity 0.3s ease;
  display: inline-block;
}

@keyframes musicPulse {
  0% {
    transform: scale(1) rotate(-8deg);
  }

  50% {
    transform: scale(1.2) rotate(8deg);
  }

  100% {
    transform: scale(1) rotate(-8deg);
  }
}

#music-player-fab:not(.muted) #music-fab-icon {
  animation: musicPulse 1.5s infinite ease-in-out;
}

#music-player-fab.muted #music-fab-icon {
  opacity: 0.5;
  animation: none;
}

.music-slash {
  position: absolute;
  width: 18px;
  height: 2px;
  background: var(--warm-brown);
  transform: rotate(-45deg) scaleX(0);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 2px;
  transform-origin: center;
}

#music-player-fab.muted .music-slash {
  transform: rotate(-45deg) scaleX(1);
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 500px) {
  .letter-scroll {
    padding: 1.5rem 0.6rem 0.6rem;
  }

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

  .meta-to-name {
    font-size: 3.2rem;
    margin-bottom: 1rem;
  }

  .letter-from {
    font-size: 2.8rem;
  }

  .letter-salutation {
    margin-bottom: 1rem;
  }

  .memory-carousel {
    gap: 0.5rem;
  }

  .memory-arrow {
    width: 38px;
    height: 38px;
    font-size: 1.8rem;
  }

  .polaroid-frame {
    max-width: min(280px, 76vw);
  }

  .corner-vine {
    width: 65px;
    height: 65px;
  }

  .vintage-envelope-scene {
    padding: 0.5rem;
  }
  
  .vintage-envelope-wrap {
    width: clamp(340px, 115vw, 480px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .vintage-envelope-wrap {
    animation: none;
  }
}