/* envelope.css — the original envelope (pretty-printed, spaces restored) + the letter card. */

.env-stage { display: grid; place-items: center; width: 100%; }
.env-stage > * { grid-area: 1 / 1; }
.env-intro { display: flex; flex-direction: column; align-items: center; text-align: center; }
.env-heading {
  margin-bottom: 24px;
  font-size: clamp(20px, 6vw, 30px);
  font-weight: 600;
  color: #fff;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .1)) drop-shadow(0 1px 1px rgba(0, 0, 0, .06));
  animation: slideDown .8s var(--ease-out) both;
}
.env-hint { margin-top: 24px; font-size: 15px; font-weight: 500; color: rgba(255, 255, 255, .9); animation: pulse 2s var(--ease-pulse) infinite; }
.env-countdown { margin-top: 10px; font-size: 16px; font-weight: 600; color: #fff; text-shadow: var(--text-shadow); }
.env-from { margin-top: 4px; font-size: 13px; color: rgba(255, 255, 255, .7); }
.env-sound { margin-top: 14px; font-size: 13px; font-weight: 500; color: rgba(255, 255, 255, .8); }
.env-startover { margin-top: 8px; }
.env-intro.is-opening .env-heading,
.env-intro.is-opening .env-hint,
.env-intro.is-opening .env-countdown,
.env-intro.is-opening .env-from,
.env-intro.is-opening .env-sound,
.env-intro.is-opening .env-startover { opacity: 0; transition: opacity .4s ease; animation: none; }

/* ----- the envelope (from the saved page) ----- */
.env-wrap { perspective: 1200px; display: flex; justify-content: center; animation: scaleIn .8s var(--ease-out) .15s both; }
.env {
  position: relative;
  width: min(300px, 78vw);
  aspect-ratio: 3 / 2;
  cursor: pointer;
  border: none;
  background: transparent;
  padding: 0;
  animation: envBob 3s ease-in-out infinite;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
@supports not (aspect-ratio: 3 / 2) { .env { height: min(200px, 52vw); } }
.env-base {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 16px;
  background: linear-gradient(#fff8f2, #ffe9d9);
  box-shadow: 0 24px 55px rgba(120, 0, 40, .4);
}
.env-letter {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 7%;
  bottom: 9%;
  z-index: 1;
  border-radius: 10px;
  background: linear-gradient(#fffdf9, #fff3ea);
  box-shadow: 0 2px 8px rgba(120, 0, 40, .14);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 9%;
  padding: 12% 14% 0;
}
.env-letter i { display: block; height: 3px; border-radius: 2px; background: rgba(161, 15, 28, .16); }
.env-letter i:nth-child(2) { width: 82%; }
.env-letter i:nth-child(3) { width: 64%; }
.env-pocket {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  background: linear-gradient(#ffe9d9, #ffd9c2);
  clip-path: polygon(0 30%, 50% 80%, 100% 30%, 100% 100%, 0 100%);
  z-index: 2;
}
.env-flap {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 66%;
  background: linear-gradient(#ffe4d1, #ffd2b8);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform .75s cubic-bezier(.6, -.1, .3, 1.2);
  z-index: 4;
  border-radius: 16px 16px 0 0;
}
.env-seal {
  position: absolute;
  left: 50%;
  top: 54%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #ef3b52, #a10f1c);
  box-shadow: 0 5px 12px rgba(0, 0, 0, .35), inset 0 -2px 4px rgba(0, 0, 0, .25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: opacity .3s, transform .4s;
}
.env-seal-heart { font-size: 22px; line-height: 1; }
.env.open { animation: none; }
.env.open .env-flap { transform: rotateX(-172deg); z-index: 0; }
.env.open .env-seal { opacity: 0; transform: scale(.6); }
.env.peek .env-letter { animation: letterPeek .7s var(--ease-out) forwards; }
.env.lift { animation: envLift .8s ease forwards; }
@keyframes envBob { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-8px) rotate(1deg); } }
@keyframes envLift {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  60% { transform: translateY(-6px) scale(1.03); opacity: 1; }
  100% { transform: translateY(-30px) scale(1.08); opacity: 0; }
}
@keyframes letterPeek { to { transform: translateY(-55%); } }

/* ----- the midnight lock: a ribbon-tied envelope + countdown ----- */
.env-nudge { display: flex; justify-content: center; }
.env-nudge.is-nudge { animation: wiggle .4s ease-out; }
.env.is-locked { cursor: default; }
.env-ribbon { position: absolute; inset: 0; z-index: 6; pointer-events: none; transition: opacity .5s ease, transform .6s var(--ease-back); }
.env-ribbon::before, .env-ribbon::after { content: ""; position: absolute; box-shadow: 0 1px 4px rgba(90, 40, 0, .25); }
.env-ribbon::before { top: 0; bottom: 0; left: 50%; width: 12%; margin-left: -6%;
  background: linear-gradient(90deg, #c99a3b, var(--gold) 30%, var(--gold-hi) 50%, var(--gold) 70%, #c99a3b); }
.env-ribbon::after { left: 0; right: 0; top: 54%; height: 12%; margin-top: -6%;
  background: linear-gradient(#c99a3b, var(--gold) 30%, var(--gold-hi) 50%, var(--gold) 70%, #c99a3b); }
.env-bow { position: absolute; left: 50%; top: 54%; width: 70px; height: 40px; margin: -20px 0 0 -35px; z-index: 7; pointer-events: none; transition: opacity .4s ease, transform .5s var(--ease-back); }
.env-bow::before, .env-bow::after { content: ""; position: absolute; top: 4px; width: 30px; height: 24px; border: 6px solid var(--gold); border-radius: 50%; box-shadow: 0 2px 6px rgba(90, 40, 0, .25); }
.env-bow::before { left: 2px; transform: rotate(-18deg); }
.env-bow::after { right: 2px; transform: rotate(18deg); }
.env-bow i { position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 5px; background: radial-gradient(circle at 35% 30%, var(--gold-hi), var(--gold-deep)); z-index: 1; }
.env.is-untie .env-ribbon { opacity: 0; transform: scale(1.12); }
.env.is-untie .env-bow { opacity: 0; transform: translateY(-30px) scale(1.4) rotate(12deg); }
.env-lock-tiles { display: flex; gap: 8px; margin-top: 26px; }
.env-lock-tile { min-width: 66px; padding: 10px 8px 8px; border-radius: 14px; background: var(--glass); border: 1px solid var(--glass-bd); display: flex; flex-direction: column; align-items: center; }
.env-lock-num { display: block; font-family: var(--font-love); font-size: 30px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; text-shadow: var(--text-shadow); }
.env-lock-num.is-tick { animation: fadeIn .35s ease; }
.env-lock-unit { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; opacity: .9; }
.env-lock-tiles.is-zero .env-lock-tile { animation: pulse 1s var(--ease-pulse) 2; }
.env-lock-days { margin-top: 24px; font-size: 18px; font-weight: 600; text-shadow: var(--text-shadow); }
.env-lock-line { margin-top: 18px; font-family: var(--font-love); font-size: 20px; font-style: italic; text-shadow: var(--text-shadow); }
.env-lock-sub { margin-top: 6px; min-height: 22px; font-size: 15px; font-weight: 500; text-shadow: var(--text-shadow); }
.env-lock-phones { margin-top: 10px; font-size: 15px; font-weight: 500; text-shadow: var(--text-shadow); }
.env-locked .env-from { margin-top: 10px; }

/* ----- the letter card ----- */
.lt-card { width: min(92vw, 420px); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 36px 26px 30px; }
.lt-seal {
  position: absolute;
  top: -16px;
  left: 50%;
  width: 32px;
  height: 32px;
  margin-left: -16px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #ef3b52, #a10f1c);
  box-shadow: 0 4px 10px rgba(0, 0, 0, .3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffd6e0;
  font-size: 14px;
  animation: sealStamp .45s var(--ease-back) .5s both;
}
.lt-greeting { font-size: 24px; font-weight: 600; color: var(--ink); }
.lt-line { font-size: 17px; line-height: 1.55; color: var(--ink); animation: fadeIn .8s var(--ease-out) both; }
.lt-sign { font-size: 18px; font-style: italic; color: var(--ink); animation: fadeIn .8s var(--ease-out) .6s both; }
.lt-play { margin-top: 6px; background: linear-gradient(135deg, #ff5a82, #E91E63 60%, #C2185B); color: #fff; animation: yesGlow 2.2s ease-in-out infinite; }

/* ----- ?og: a 1200×630-friendly frame for the link-preview screenshot ----- */
.env-og { padding: 0 !important; justify-content: center; }
.env-og .env-heading { font-size: 44px; margin-bottom: 36px; }
.env-og .env { width: 360px; animation: none; cursor: default; }
html.og-mode .music-toggle, html.og-mode .test-badge, html.og-mode .next-btn { display: none !important; }

@media (max-height: 560px) {
  .env-lock-tiles { margin-top: 14px; }
  .env-lock-num { font-size: 24px; }
  .env-heading { margin-bottom: 14px; }
  .env { width: min(240px, 60vw); }
  .env-hint { margin-top: 14px; }
  .lt-card { gap: 10px; padding: 28px 20px 22px; }
  .lt-line { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .env, .env-wrap, .env-heading, .env-hint { animation: none !important; }
  .env-flap { transition-duration: .15s !important; }
  .env.peek .env-letter { animation: none !important; }
  .env.lift { animation: fadeOut .2s ease forwards !important; animation-duration: .2s !important; }
  .lt-line, .lt-sign, .lt-seal { animation: fadeIn .3s ease both !important; animation-duration: .3s !important; }
}
