/* ── Open envelope scene wrapper ────────────────────────────────────────── */

.open-envelope-scene {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100vh;
  /* Top padding reserves space for the risen card above the envelope */
  padding: clamp(60px, 20vmin, 200px) clamp(16px, 4vw, 40px) clamp(24px, 6vmin, 80px);
  box-sizing: border-box;
}

/* ── Open envelope ──────────────────────────────────────────────────────── */

.open-envelope {
  position: relative;
  width: min(840px, 92vw, calc(80vh * 16 / 9));
  aspect-ratio: 16 / 9;
  container-type: inline-size;
  overflow: visible;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.06),
    0 8px 24px rgba(0, 0, 0, 0.14),
    0 28px 70px rgba(0, 0, 0, 0.12);
}

/* Inside of envelope visible through the open top */
.open-env-interior {
  position: absolute;
  inset: 0;
  /*
   * The inside face of the envelope — slightly cooler and darker than the
   * outside, as if seen in the shadow cast by the open flap above.
   */
  background: linear-gradient(175deg, #eae7e0 0%, #dedad2 55%, #d0ccc4 100%);
  z-index: 0;
}

/* ── Invitation card ────────────────────────────────────────────────────── */
/*
   z-index 1 — sits behind the side flaps (z-index 2) so the lower
   portion is naturally masked, leaving only the upper portion visible
   through the triangular opening and above the envelope.
*/

.invitation-card {
  position: absolute;
  left: 50%;
  width: 55cqw;
  aspect-ratio: 1 / 1;
  top: -17cqw;
  /* Starts inside the envelope; JS adds .rising then .emerged to pull it out */
  transform: translateX(-50%) translateY(20cqw);
  transition: transform 0.7s cubic-bezier(0.2, 0, 0.1, 1);
  z-index: 1;
  border-radius: 2.5cqw;
  /* overflow hidden removed — it flattens preserve-3d in most browsers */
  perspective: 1200px;
  perspective-origin: 50% 50%;
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

/* Step 4 — card rises above the envelope flaps */
.invitation-card.rising {
  transform: translateX(-50%) translateY(-5cqw);
}

/* Step 5 — card moves fully out of the envelope, ready for the FLIP to centre */
.invitation-card.emerged {
  transform: translateX(-50%) translateY(-12cqw);
}

/* ── Card flip ──────────────────────────────────────────────────────────── */

.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.65s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: inherit;
}

.card-inner.flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: inherit;
  overflow: hidden;
}

.card-back {
  transform: rotateY(180deg);
}

.card-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Flip hint caption ──────────────────────────────────────────────────── */

.flip-hint {
  position: fixed;
  text-align: center;
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-size: clamp(11px, 1.6vmin, 14px);
  color: rgba(0, 0, 0, 0.38);
  letter-spacing: 0.06em;
  pointer-events: none;
  user-select: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 1001;
  margin: 0;
  padding-top: 10px;
}

.flip-hint.visible {
  opacity: 1;
}

/* ── Three visible back flaps (no top flap) ─────────────────────────────── */

.open-env-flap-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50%;
  /* Faces downward — darkest surface, matches closed envelope bottom flap */
  background: linear-gradient(to top,
    #a09b93 0%,
    #b2ada6 45%,
    #c8c3bb 100%
  );
  clip-path: polygon(0% 100%, 100% 100%, 50% 0%);
  z-index: 2;
  filter: drop-shadow(0 -4px 7px rgba(0, 0, 0, 0.24));
}

.open-env-flap-left {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 50%;
  /* Angled left face — partial light, lighter at outer edge */
  background: linear-gradient(140deg,
    #dedad0 0%,
    #d0cbc1 50%,
    #c4bfb4 100%
  );
  clip-path: polygon(0% 0%, 0% 100%, 100% 50%);
  z-index: 2;
  filter: drop-shadow(5px 0 8px rgba(0, 0, 0, 0.24));
}

.open-env-flap-right {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50%;
  /* Angled right face — slightly more in shadow */
  background: linear-gradient(220deg,
    #d4cfc5 0%,
    #c8c3b9 50%,
    #bcb7ad 100%
  );
  clip-path: polygon(100% 0%, 100% 100%, 0% 50%);
  z-index: 2;
  filter: drop-shadow(-5px 0 8px rgba(0, 0, 0, 0.24));
}

/* ── Crease lines SVG overlay ───────────────────────────────────────────── */

.open-env-creases {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 3;
}
