/* ═══════════════════════════════════════════
   letter-section.css — Đồng hồ tình yêu, phong bì & thư
   ═══════════════════════════════════════════ */

#letter {
  position: relative;
  background: transparent;
  padding: 5rem 1rem 6rem;
  z-index: 4;
}

/* ─── CLOCK ─── */
.clock-wrap {
  text-align: center;
  margin-bottom: 4rem;
}
.clock-label {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 1.15rem;
  color: var(--rose-gold);
  margin-bottom: 1.4rem;
}
.clock-display {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.clock-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.clock-num {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(2.8rem, 8vw, 5rem);
  font-weight: 300;
  color: var(--mauve);
  line-height: 1;
  min-width: 2ch;
  text-align: center;
}
.clock-lbl {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--rose-gold);
  margin-top: 0.3rem;
}
.clock-sep {
  font-family: 'Cormorant Garamond', serif;
  font-size: 3rem;
  color: var(--petal);
  align-self: flex-start;
  margin-top: 0.1rem;
  line-height: 1.2;
}

/* ─── ENVELOPE SCENE ─── */
.envelope-scene {
  max-width: 620px;
  margin: 0 auto 2rem;
  position: relative;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.envelope-wrap {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.3s ease;
}
.envelope-wrap:hover { transform: translateY(-6px) scale(1.02); }

.env-body {
  position: relative;
  width: 320px;
  height: 220px;
  background: linear-gradient(160deg, #fff5f8, #fff0f5);
  border-radius: 6px 6px 12px 12px;
  box-shadow: 0 10px 48px rgba(201,132,142,0.22), 0 2px 8px rgba(201,132,142,0.12);
  border: 1.5px solid rgba(255,192,203,0.5);
  overflow: visible;
}
html.dark .env-body {
  background: linear-gradient(160deg, #200f15, #180e12);
  border-color: rgba(242,167,187,0.2);
  box-shadow: 0 10px 48px rgba(242,167,187,0.1);
}

/* Triangle flap (top) */
.env-flap {
  position: absolute;
  top: 0; left: 0;
  width: 0; height: 0;
  border-left: 160px solid transparent;
  border-right: 160px solid transparent;
  border-top: 110px solid #f9d0dc;
  transform-origin: top center;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10;
}
html.dark .env-flap {
  border-top-color: #3a1520;
}
.env-body.opened .env-flap {
  transform: rotateX(180deg);
}

/* Side triangles */
.env-left {
  position: absolute;
  bottom: 0; left: 0;
  width: 0; height: 0;
  border-bottom: 110px solid #f0c0ce;
  border-right: 160px solid transparent;
  border-radius: 0 0 0 6px;
}
.env-right {
  position: absolute;
  bottom: 0; right: 0;
  width: 0; height: 0;
  border-bottom: 110px solid #edb8c7;
  border-left: 160px solid transparent;
  border-radius: 0 0 6px 0;
}
html.dark .env-left  { border-bottom-color: #2a1018; }
html.dark .env-right { border-bottom-color: #250e16; }

/* Bottom strip */
.env-bottom {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 30px;
  background: #f5c8d5;
  border-radius: 0 0 10px 10px;
}
html.dark .env-bottom { background: #2e1219; }

/* Heart / emoji seal */
.env-heart {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.8rem;
  z-index: 5;
  animation: heartbeat 1.4s ease-in-out infinite;
  filter: drop-shadow(0 2px 8px rgba(201,132,142,0.4));
}

.env-hint {
  position: absolute;
  bottom: -2rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Be Vietnam Pro', serif;
  font-size: 0.8rem;
  color: var(--rose-gold);
  white-space: nowrap;
  font-style: italic;
  opacity: 0.8;
  letter-spacing: 0.04em;
}

/* ── Letter reveal ── */
.letter-reveal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(30px) scale(0.96);
  transition: opacity 0.5s ease 0.3s, transform 0.5s ease 0.3s;
}
.letter-reveal.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* When scene is open, expand min-height to fit letter */
.envelope-scene.open {
  min-height: auto;
}
.envelope-scene.open .envelope-wrap {
  display: none;
}
.envelope-scene.open .letter-reveal {
  position: relative;
  inset: auto;
}

/* ── Letter card ── */
.letter-card {
  max-width: 620px;
  width: 100%;
  margin: 0 auto;
  background: #FFFDF9;
  border-radius: 24px;
  padding: 3rem 3.5rem 2.5rem;
  box-shadow: 0 8px 48px rgba(201,132,142,0.14), inset 0 0 60px rgba(255,192,203,0.04);
  border: 1px solid rgba(255,192,203,0.25);
  position: relative;
}
.letter-card::before {
  content: '❝';
  position: absolute;
  top: 1.2rem; left: 1.8rem;
  font-size: 3rem;
  color: rgba(255,192,203,0.45);
  font-family: Georgia, serif;
  line-height: 1;
}
.letter-text {
  font-family: 'Be Vietnam Pro', 'Lora', serif;
  font-size: clamp(1rem, 2.2vw, 1.15rem);
  font-weight: 300;
  color: var(--soft-ink);
  line-height: 2;
  position: relative;
  z-index: 1;
}
.letter-text p { margin-bottom: 1.1rem; }
.letter-sig {
  font-family: 'Be Vietnam Pro', 'Lora', serif;
  font-size: 1.1rem;
  font-style: italic;
  font-weight: 400;
  color: var(--mauve);
  text-align: right;
  margin-top: 1.5rem;
}

/* ── Close button ── */
.letter-close-btn {
  display: block;
  margin: 1.8rem auto 0;
  padding: 0.6rem 2rem;
  background: transparent;
  border: 1.5px solid var(--petal);
  border-radius: 50px;
  font-family: 'Be Vietnam Pro', serif;
  font-size: 0.82rem;
  color: var(--rose-gold);
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: background 0.2s, transform 0.2s;
}
.letter-close-btn:hover {
  background: rgba(255,192,203,0.15);
  transform: translateY(-2px);
}

html.dark .letter-card {
  background: var(--bg-letter-card);
  border-color: rgba(242,167,187,0.12);
  box-shadow: 0 8px 48px rgba(242,167,187,0.07);
}
html.dark .letter-close-btn {
  border-color: rgba(242,167,187,0.3);
}

@media (max-width: 480px) {
  .env-body { width: 260px; height: 180px; }
  .env-flap { border-left-width: 130px; border-right-width: 130px; border-top-width: 90px; }
  .env-left { border-bottom-width: 90px; border-right-width: 130px; }
  .env-right { border-bottom-width: 90px; border-left-width: 130px; }
  .letter-card { padding: 2rem 1.5rem; }
}

/* ─── DARK MODE (section itself) ─── */
html.dark #letter {
  background: linear-gradient(160deg, #140A0D, #0D0D0D 60%, #1A0D10);
}

/* ─── Backdrop mờ để chữ dễ đọc trên nền động ─── */
#letter {
  position: relative;
}
#letter::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,250,247,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 0;
  transition: background 0.4s ease;
}
html.dark #letter::before {
  background: rgba(10,6,8,0.62);
}
#letter > * { position: relative; z-index: 1; }
