/* public/letters.css */

.letters-app {
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  padding: 80px 20px 40px;
  overflow-y: auto;
  position: relative;
  z-index: 10;
  background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><rect width="100" height="100" fill="rgba(30,20,10,0.1)"/></svg>');
}

.letters-title {
  text-align: center;
  font-family: var(--font-display);
  color: var(--accent-letters);
  font-size: clamp(2rem, 5vw, 3rem);
  margin-bottom: 40px;
  font-style: italic;
  font-weight: 400;
  text-shadow: 0 2px 10px rgba(255,204,128,0.2);
}

.letters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 40px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* ── Envelope Envelope ── */
.envelope {
  position: relative;
  width: 100%;
  aspect-ratio: 1.5;
  background: #f4e8d4; /* Warm paper color */
  border-radius: 4px;
  box-shadow: 0 10px 20px rgba(0,0,0,0.4), inset 0 0 20px rgba(200,160,120,0.2);
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  transform-style: preserve-3d;
}

.envelope:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 15px 30px rgba(0,0,0,0.5), inset 0 0 20px rgba(200,160,120,0.2);
}

.envelope.is-opened {
  background: #e6d8c3;
  box-shadow: 0 5px 10px rgba(0,0,0,0.3);
}

/* Flap */
.envelope-flap {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 60%;
  background: #ebdcc6;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top;
  transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 4;
  box-shadow: 0 5px 10px rgba(0,0,0,0.1);
}

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

/* Bottom fold (visual only) */
.envelope::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  width: 100%; height: 70%;
  background: linear-gradient(to top, rgba(0,0,0,0.05), transparent);
  clip-path: polygon(0 100%, 100% 100%, 50% 0);
  z-index: 3;
}

/* Wax Seal */
.envelope-seal {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -10%);
  width: 40px; height: 40px;
  background: #8b0000;
  border-radius: 50%;
  z-index: 5;
  box-shadow: 0 2px 5px rgba(0,0,0,0.4), inset 0 2px 4px rgba(255,255,255,0.2);
  transition: opacity 0.3s;
}

.envelope.is-opened .envelope-seal {
  opacity: 0;
}

/* Label text */
.envelope-label {
  position: absolute;
  top: 65%; left: 50%;
  transform: translateX(-50%);
  width: 80%;
  text-align: center;
  font-family: 'Caveat', cursive;
  color: #332b22;
  font-size: 1.4rem;
  z-index: 6;
  line-height: 1.1;
  pointer-events: none;
}

.envelope.is-opened .envelope-label {
  opacity: 0.5;
}

/* Paper sliding out */
.envelope-paper {
  position: absolute;
  bottom: 5%; left: 5%;
  width: 90%; height: 90%;
  background: #fff;
  border-radius: 2px;
  z-index: 2;
  transition: transform 0.6s ease;
}

.envelope.is-opened .envelope-paper {
  transform: translateY(-40px);
}

/* ── Letter Overlay ── */
.letter-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.letter-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.letter-close {
  position: absolute;
  top: 20px; right: 20px;
  background: none; border: none;
  color: rgba(255,255,255,0.6);
  font-size: 2rem;
  cursor: pointer;
  transition: color 0.3s;
}

.letter-close:hover { color: #fff; }

.letter-paper {
  background: #fbf6ec;
  border-radius: 8px;
  width: 100%; max-width: 600px;
  max-height: 85vh;
  padding: clamp(30px, 6vw, 60px);
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  transform: translateY(20px);
  transition: transform 0.4s ease;
  color: #2c251e;
}

.letter-overlay.is-visible .letter-paper {
  transform: translateY(0);
}

.letter-label-title {
  font-family: 'Caveat', cursive;
  font-size: 2rem;
  color: #8b0000;
  text-align: center;
  margin-bottom: 30px;
  border-bottom: 1px solid rgba(0,0,0,0.1);
  padding-bottom: 10px;
}

.letter-content {
  font-family: var(--font-display);
  font-size: 1.15rem;
  line-height: 1.8;
  white-space: pre-wrap;
}

.letter-content p {
  margin-bottom: 1.5em;
}
