/* ==========================================================================
   ROMANTIC VINTAGE LETTER VAULT - DESIGN SYSTEM
   Inspired by Historical 18th/19th Century Folded Parchment & Sealing Wax
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Alex+Brush&family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,400;1,600&family=La+Belle+Aurore&family=Outfit:wght@300;400;500&family=Pinyon+Script&family=UnifrakturMaguntia&display=swap');

:root {
  /* Warm Historical Palette */
  --bg-room-dark: #ede5d3;
  --bg-wood-desk: #e6dcc7;
  
  /* Natural Handmade Parchment Paper */
  --parchment-cream: #fbf7ee;
  --parchment-mid: #f4ecdc;
  --parchment-aged: #e7dac1;
  --parchment-crease: rgba(90, 65, 45, 0.12);
  --parchment-shadow: rgba(18, 9, 4, 0.55);

  /* Historic Iron-Gall Inks */
  --ink-primary: #211510;
  --ink-secondary: #3d2c22;
  --ink-faded: #6c5849;
  --ink-warm-sepia: #4a382d;
  --ink-postal-red: #8f2320;
  --ink-postmark: #2c4465;

  /* Cinnabar Sealing Wax */
  --wax-red: #a42c22;
  --wax-dark: #5e130c;
  --wax-glow: rgba(164, 44, 34, 0.35);

  /* Fonts */
  --font-script: 'Pinyon Script', cursive;
  --font-calligraphy: 'Alex Brush', cursive;
  --font-casual: 'La Belle Aurore', cursive;
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-ui: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Shadows */
  --shadow-packet: 0 24px 50px -12px rgba(10, 5, 2, 0.7), 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-wax: 0 10px 20px rgba(35, 10, 8, 0.55), 0 3px 6px rgba(15, 3, 3, 0.3);
}

/* Base & Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100vh;
  font-family: var(--font-serif);
  color: var(--ink-primary);
  background-color: var(--bg-room-dark);
  background-image: 
    radial-gradient(ellipse at 50% 10%, #f5edd8 0%, #e8ddc5 60%, #dfd3b5 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Ambient Candlelight Background Glow */
.ambient-glow {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  max-width: 120vw;
  height: 550px;
  background: radial-gradient(circle, rgba(200, 165, 110, 0.12) 0%, rgba(180, 150, 100, 0.05) 55%, transparent 75%);
  pointer-events: none;
  z-index: 0;
  animation: candleFlicker 9s ease-in-out infinite alternate;
}

/* Global App Container */
.app-container {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Utility Bar (Sound Toggle) */
.utility-bar {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  z-index: 100;
}

.icon-btn {
  background: rgba(200, 185, 160, 0.55);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(160, 135, 100, 0.4);
  color: #5a3e2b;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.icon-btn:hover {
  background: rgba(185, 165, 135, 0.75);
  border-color: rgba(130, 100, 65, 0.7);
  box-shadow: 0 0 10px rgba(160, 130, 90, 0.2);
  transform: translateY(-2px);
}

/* ==========================================================================
   1. AUTHENTIC HANDWRITTEN LETTER PACKET (LOCK SCREEN)
   ========================================================================== */
.lock-screen-section {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.25rem;
  transition: opacity 0.85s cubic-bezier(0.4, 0, 0.2, 1), transform 0.85s ease;
}

.lock-screen-section.hidden {
  display: none !important;
}

.lock-envelope-wrapper {
  perspective: 1200px;
  width: 100%;
  max-width: 440px;
}

/* Folded Parchment Letter Packet (Historical Style) */
.sealed-letter-packet {
  position: relative;
  background: var(--parchment-cream);
  background-image: 
    radial-gradient(ellipse at 50% 30%, #fffef8 0%, #f6edd9 60%, #e9ddc3 100%);
  border-radius: 4px;
  border: 1px solid #dccbb0;
  box-shadow: var(--shadow-packet);
  padding: 4.5rem 2.2rem 3.5rem;
  text-align: center;
  transition: transform 0.75s ease, box-shadow 0.75s ease;
}

/* Handmade Linen Paper Rough Texture Overlay */
.sealed-letter-packet::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 20% 80%, rgba(130, 95, 60, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 85% 15%, rgba(130, 95, 60, 0.04) 0%, transparent 35%);
  pointer-events: none;
  border-radius: 4px;
}

/* Realistic 3D Paper Crease Folds */
.parchment-crease-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 110px;
  background: linear-gradient(180deg, rgba(235, 222, 198, 0.85) 0%, rgba(225, 210, 185, 0.3) 85%, rgba(130, 95, 60, 0.15) 100%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  pointer-events: none;
  border-bottom: 1px solid rgba(140, 110, 80, 0.25);
  box-shadow: 0 4px 10px rgba(70, 45, 25, 0.08);
}

.parchment-crease-diagonal {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(0deg, rgba(220, 205, 178, 0.4) 0%, transparent 100%);
  pointer-events: none;
  border-top: 1px dashed rgba(160, 135, 105, 0.2);
}

/* ==========================================================================
   AUTHENTIC RED CINNABAR WAX SEAL
   ========================================================================== */
.wax-seal-container {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.natural-wax-seal-btn {
  width: 115px;
  height: 110px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.4s ease;
  filter: drop-shadow(0 10px 18px rgba(35, 8, 6, 0.55)) drop-shadow(0 3px 6px rgba(0, 0, 0, 0.3));
}

.natural-wax-seal-btn:hover {
  transform: scale(1.07) rotate(-2deg);
  filter: drop-shadow(0 14px 24px rgba(45, 10, 8, 0.65)) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
}

.natural-wax-seal-btn:active {
  transform: scale(0.96);
}

.natural-wax-seal-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Authentic wax droplets beside the seal */
.wax-droplet-1 {
  position: absolute;
  right: -14px;
  top: 28px;
  width: 9px;
  height: 9px;
  background: #98261c;
  border-radius: 50% 60% 45% 55%;
  box-shadow: inset 1px 1px 2px rgba(255, 200, 180, 0.6), 0 2px 4px rgba(30, 8, 6, 0.4);
}

.wax-droplet-2 {
  position: absolute;
  left: -10px;
  bottom: 12px;
  width: 6px;
  height: 6px;
  background: #8b2017;
  border-radius: 45% 55% 50% 60%;
  box-shadow: inset 1px 1px 2px rgba(255, 200, 180, 0.5), 0 2px 3px rgba(30, 8, 6, 0.35);
}

/* ==========================================================================
   HANDWRITTEN PACKET TYPOGRAPHY & INTERACTION
   ========================================================================== */
.letter-packet-content {
  margin-top: 7.5rem;
  position: relative;
  z-index: 5;
}

.packet-recipient-script {
  font-family: var(--font-script);
  font-size: 2.2rem;
  color: var(--ink-faded);
  line-height: 1;
  margin-bottom: -0.3rem;
  font-style: italic;
}

.packet-name-script {
  font-family: var(--font-script);
  font-size: clamp(3.2rem, 8vw, 4.4rem);
  color: var(--ink-primary);
  font-weight: normal;
  line-height: 1.05;
  letter-spacing: 0.02em;
  margin-bottom: 0.4rem;
}

.packet-intimate-script {
  font-family: var(--font-calligraphy);
  font-size: 1.45rem;
  color: var(--ink-secondary);
  line-height: 1.3;
  margin-bottom: 2rem;
}

/* Minimalist Handwritten Form */
.minimal-lock-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  margin-top: 0.5rem;
}

.handwritten-input-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

.handwritten-ink-input {
  width: 100%;
  max-width: 320px;
  background: transparent;
  border: none;
  border-bottom: 1.5px dashed rgba(110, 85, 65, 0.45);
  font-family: var(--font-script);
  font-size: 2.3rem;
  color: var(--ink-primary);
  text-align: center;
  padding: 0.4rem 0.5rem;
  outline: none;
  letter-spacing: 0.04em;
  transition: border-color 0.3s ease;
}

.handwritten-ink-input:focus {
  border-bottom: 1.5px solid var(--wax-red);
}

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

/* Error message in italic ink */
.script-error {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--wax-red);
  min-height: 1.4rem;
}

/* Delicate Handwritten Unlock Button */
.break-seal-script-btn {
  background: none;
  border: none;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.25rem;
  letter-spacing: 0.15em;
  color: var(--wax-red);
  cursor: pointer;
  padding: 0.5rem 1rem;
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.break-seal-script-btn:hover {
  color: var(--wax-dark);
  transform: scale(1.05);
}

.break-seal-script-btn:active {
  transform: scale(0.97);
}

/* Hint Toggle */
.hint-container {
  margin-top: 0.2rem;
}

.script-hint-toggle {
  background: none;
  border: none;
  font-family: var(--font-calligraphy);
  font-size: 1.25rem;
  color: var(--ink-faded);
  cursor: pointer;
  transition: color 0.2s ease;
}

.script-hint-toggle:hover {
  color: var(--ink-primary);
}

.script-hint-text {
  font-family: var(--font-calligraphy);
  font-size: 1.35rem;
  color: var(--ink-warm-sepia);
  background: rgba(220, 185, 130, 0.18);
  border: 1px dashed rgba(160, 130, 90, 0.4);
  border-radius: 4px;
  padding: 0.4rem 0.9rem;
  margin-top: 0.4rem;
}

/* ==========================================================================
   2. VAULT INTERIOR (UNLOCKED GALLERY)
   ========================================================================== */
.vault-section {
  display: none;
  flex: 1;
  padding: 3.5rem 1.5rem 5rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  animation: fadeInUp 0.85s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.vault-section.active {
  display: block;
}

/* Vault Header */
.vault-header {
  text-align: center;
  margin-bottom: 3.5rem;
  position: relative;
}

.natural-seal-crest {
  width: 64px;
  height: 62px;
  margin: 0 auto 0.8rem;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
}

.vault-subtitle {
  font-family: var(--font-serif);
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  font-style: italic;
  color: var(--ink-postal-red);
  margin-bottom: 0.4rem;
}

.script-vault-title {
  font-family: var(--font-script);
  font-size: clamp(3rem, 6vw, 4.4rem);
  color: var(--ink-primary);
  font-weight: normal;
  text-shadow: none;
  line-height: 1.1;
}

.script-vault-tagline {
  font-family: var(--font-calligraphy);
  font-size: clamp(1.4rem, 3vw, 1.85rem);
  color: var(--ink-faded);
  margin-top: 0.2rem;
}

/* Filter Ribbon by Tag */
.vault-filter-bar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 2.8rem;
}

.filter-chip {
  background: rgba(38, 24, 18, 0.65);
  border: 1px solid rgba(220, 175, 115, 0.25);
  color: #d6c2ab;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  padding: 0.45rem 1.1rem;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.25s ease;
}

.filter-chip:hover, .filter-chip.active {
  background: #dfb76c;
  color: #1a100b;
  border-color: #dfb76c;
  box-shadow: 0 0 12px rgba(223, 183, 108, 0.35);
  font-weight: 600;
}

/* Letters Grid */
.letters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 2.2rem;
}

/* Letter Envelope Card */
.envelope-card {
  background: var(--parchment-cream);
  background-image: 
    radial-gradient(ellipse at 50% 30%, #fffef8 0%, #f6edd9 65%, #e9ddc3 100%);
  border-radius: 4px;
  border: 1px solid #dccbb0;
  box-shadow: 0 12px 28px -6px rgba(15, 8, 4, 0.35);
  padding: 1.8rem 1.6rem 1.5rem;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 230px;
  transition: all 0.35s cubic-bezier(0.25, 1, 0.5, 1);
  overflow: hidden;
}

.envelope-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 18px 36px -8px rgba(15, 8, 4, 0.5), 0 0 16px rgba(223, 183, 108, 0.18);
  border-color: #c9b08a;
}

.envelope-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.8rem;
}

.envelope-number {
  font-family: var(--font-serif);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-postal-red);
  letter-spacing: 0.12em;
}

.stamp-miniature {
  width: 42px;
  height: 50px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.envelope-open-when {
  font-family: var(--font-calligraphy);
  font-size: 1.25rem;
  color: var(--ink-faded);
  margin-bottom: 0.2rem;
}

.envelope-title {
  font-family: var(--font-script);
  font-size: 2rem;
  font-weight: normal;
  color: var(--ink-primary);
  line-height: 1.15;
  margin-bottom: 0.5rem;
}

.envelope-excerpt {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--ink-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 1.2rem;
}

.envelope-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px dashed rgba(160, 135, 105, 0.3);
  padding-top: 0.75rem;
  margin-top: auto;
}

.envelope-date {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.85rem;
  color: var(--ink-faded);
}

.envelope-tag {
  background: rgba(143, 35, 32, 0.08);
  color: var(--ink-postal-red);
  border: 1px solid rgba(143, 35, 32, 0.2);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
}

/* ==========================================================================
   3. IMMERSIVE LETTER READER MODAL
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(8, 4, 2, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.letter-modal-dialog {
  position: relative;
  width: 100%;
  max-width: 780px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: translateY(30px) scale(0.95);
  transition: transform 0.45s cubic-bezier(0.2, 1, 0.3, 1);
}

.modal-overlay.active .letter-modal-dialog {
  transform: translateY(0) scale(1);
}

/* Unfolding Parchment Sheet */
.parchment-sheet {
  background: #fbf7ee;
  background-image: 
    radial-gradient(ellipse at 50% 20%, #fffef8 0%, #f6edd9 70%, #eadaba 100%);
  border-radius: 4px;
  border: 1px solid #dccbb0;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.65);
  padding: 3.8rem 3.2rem;
  overflow-y: auto;
  position: relative;
}

@media (max-width: 640px) {
  .parchment-sheet {
    padding: 2.4rem 1.6rem;
  }
}

.modal-close-btn {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
  background: rgba(220, 200, 170, 0.4);
  border: 1px solid rgba(180, 160, 130, 0.5);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--ink-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10;
}

.modal-close-btn:hover {
  background: var(--wax-red);
  color: #ffffff;
  border-color: var(--wax-red);
}

.letter-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid rgba(180, 155, 125, 0.3);
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
  gap: 1.5rem;
}

.letter-prompt-chip {
  display: inline-block;
  font-family: var(--font-calligraphy);
  font-size: 1.45rem;
  color: var(--ink-postal-red);
  margin-bottom: 0.2rem;
}

.letter-dialog-title {
  font-family: var(--font-script);
  font-size: clamp(2.4rem, 4.5vw, 3.4rem);
  color: var(--ink-primary);
  font-weight: normal;
  line-height: 1.15;
}

.letter-dialog-date {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--ink-faded);
  margin-top: 0.3rem;
}

.postmark-graphic {
  width: 110px;
  height: 55px;
  opacity: 0.65;
}

/* Letter Prose Content */
.letter-prose {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  line-height: 1.85;
  color: var(--ink-secondary);
}

.letter-prose p {
  margin-bottom: 1.4rem;
  text-indent: 1.5rem;
}

.letter-prose p:first-of-type {
  text-indent: 0;
  font-size: 1.55rem;
  font-family: var(--font-script);
  font-style: italic;
  color: var(--ink-primary);
  margin-bottom: 1.8rem;
}

/* Attached Polaroid Photo */
.polaroid-frame {
  background: #ffffff;
  padding: 14px 14px 28px 14px;
  box-shadow: 0 10px 24px rgba(35, 20, 10, 0.22);
  border-radius: 2px;
  width: fit-content;
  max-width: 320px;
  margin: 2.2rem auto;
  transform: rotate(-1.5deg);
  transition: transform 0.3s ease;
}

.polaroid-frame:hover {
  transform: rotate(0deg) scale(1.03);
}

.polaroid-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}

.polaroid-caption {
  font-family: var(--font-calligraphy);
  font-size: 1.5rem;
  text-align: center;
  color: var(--ink-secondary);
  margin-top: 14px;
  line-height: 1.2;
}

/* Handwritten Signature */
.letter-signature-block {
  margin-top: 2.8rem;
  text-align: right;
  padding-right: 1.5rem;
}

.letter-signoff {
  display: none;
}

.letter-handwriting-name {
  font-family: 'UnifrakturMaguntia', cursive;
  font-size: 4.2rem;
  color: var(--ink-postal-red);
  line-height: 1.1;
  margin-top: 0;
}

/* Navigation Controls */
.modal-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px dashed rgba(170, 145, 115, 0.35);
}

.nav-text-btn {
  background: none;
  border: none;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--ink-postal-red);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.2s, color 0.2s;
}

.nav-text-btn:hover:not(:disabled) {
  color: var(--wax-dark);
  transform: translateX(-3px);
}

.nav-text-btn.next:hover:not(:disabled) {
  transform: translateX(3px);
}

.nav-text-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Site Footer */
.site-footer {
  text-align: center;
  padding: 2.5rem 1rem;
  color: #8c7866;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.95rem;
  position: relative;
  z-index: 10;
}

.studio-link {
  color: #dfb76c;
  text-decoration: none;
  border-bottom: 1px dotted #dfb76c;
  margin-left: 0.5rem;
  transition: color 0.2s;
}

.studio-link:hover {
  color: #ffffff;
  border-bottom-style: solid;
}
