/* Keep the approved sealed silhouette and photographic wax untouched.
   A flat stacking context makes the pocket an invariant occluder: rotating a
   preserve-3d ancestor must never bring the insert through its front face. */
[data-edition="4"] .envelope {
  isolation: isolate;
  transform-style: flat;
  background: #e9d7b4 url("media/orbit-stationery-scan.avif") center / 100% 100% no-repeat;
}
[data-edition="4"] .envelope::before {
  z-index: 0;
  background: none;
  box-shadow: inset 0 1px 1px #fff3, inset 0 -2px 3px #36221566;
}
[data-edition="4"] .insert {
  z-index: 2;
  background: #f0e2c6 url("media/orbit-stationery-scan.avif") center / 100% 100% no-repeat;
  border: 1px solid #b99d7277;
  box-shadow: inset 1px 1px 0 #fff7eab3, inset -1px -2px 1px #9d805759, 0 2px 5px #26140844;
  box-sizing: border-box;
}
[data-edition="4"] .pocket {
  z-index: 3;
  background: #e5d0a9 url("media/orbit-envelope-scan.avif") center / 100% 100% no-repeat;
  box-shadow: inset 0 -1px 0 #f6dcb288;
}
[data-final-invitation] .insert img {
  position: absolute;
  top: 16%;
  left: 37%;
  width: 26%;
  height: 37%;
  object-fit: contain;
  filter: brightness(.18) sepia(1);
  opacity: .78;
}
[data-edition="4"] .pocket::after {
  opacity: 1;
  background: none;
  box-shadow: inset 1px 0 1px #fff3, inset -1px 0 1px #3c291b66;
}
[data-edition="4"] .flap {
  z-index: 4;
  background: #ecddbf url("media/orbit-stationery-scan.avif") center top / 100% 148% no-repeat;
  /* Planar hinge projection avoids intersecting the insert's depth plane. */
  transform-origin: 50% 0;
  box-shadow: inset 0 1px 0 #ffe5bb99;
}
[data-edition="4"] .flap::before { background: none; }
/* Cast the contact shadow onto the pocket, outside the clipped flap. The SVG
   is only a soft edge mask; the photographic paper remains the surface. */
[data-edition="4"] .envelope::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 68%;
  z-index: 3;
  pointer-events: none;
  transform-origin: 50% 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 680' preserveAspectRatio='none'%3E%3Cdefs%3E%3Cfilter id='s' x='-20%25' y='-20%25' width='140%25' height='150%25'%3E%3CfeGaussianBlur stdDeviation='4'/%3E%3C/filter%3E%3C/defs%3E%3Cg fill='none'%3E%3Cpath d='M0 5L490 658L500 665L510 658L1000 5' stroke='%23483220' stroke-opacity='.27' stroke-width='9' filter='url(%23s)'/%3E%3Cpath d='M0 2L490 655L500 662L510 655L1000 2' stroke='%236a5038' stroke-opacity='.24' stroke-width='3'/%3E%3C/g%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
[data-edition="4"] .flap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* Upper-left light catches the left cut edge; the right edge is warmer. */
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 680' preserveAspectRatio='none'%3E%3Cg fill='none'%3E%3Cpath d='M0 0L490 651L500 658' stroke='%23fff4dc' stroke-opacity='.86' stroke-width='1.15' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M500 658L510 651L1000 0' stroke='%239b7955' stroke-opacity='.52' stroke-width='.65' vector-effect='non-scaling-stroke'/%3E%3C/g%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
[data-edition="4"] [data-state="unsealing"] .envelope::after {
  animation: orbit-contact-release 325ms 950ms ease-out both;
}
@keyframes orbit-contact-release {
  from { opacity: 1; transform: scaleY(1); }
  to { opacity: 0; transform: scaleY(0); }
}
[data-edition="4"] .wax { z-index: 6; }
[data-edition="4"] .stockmark,
[data-edition="4"] .postmark { z-index: 5; }
[data-edition="4"] [data-state="unsealing"] .envelope {
  animation: none;
  transform: rotate(7deg);
}
[data-edition="4"] [data-state="unsealing"] .flap {
  animation: orbit-paper-hinge 650ms 950ms ease-in-out both;
}
[data-edition="4"] [data-state="unsealing"] .insert {
  animation: orbit-paper-draw 850ms 1650ms cubic-bezier(.3,.05,.25,1) both;
}
@keyframes orbit-paper-hinge {
  0% { transform: scaleY(1); z-index: 4; filter: brightness(1); }
  49% { z-index: 4; }
  50% { transform: scaleY(0); z-index: 1; filter: brightness(.7); }
  100% { transform: scaleY(-.96); z-index: 1; filter: brightness(.82); }
}
@keyframes orbit-paper-draw {
  from { transform: translateY(0); }
  to { transform: translateY(-118%); }
}
[data-edition="4"] .paper {
  background:
    linear-gradient(179.8deg, transparent 48%, #76572f12 49.88%, #fff7e185 50%, #a9875b19 50.16%, transparent 51.7%),
    url("media/laid-paper.svg") 0 0 / 210px,
    linear-gradient(90deg, #9d7e3526, transparent 3%, transparent 96%, #9d7e3522),
    url("media/grain.svg") 0 0 / 120px,
    linear-gradient(118deg, #f4e7cd, #eee0c3 55%, #e6d4b2);
  border: 1px solid #e9d8b8;
  box-shadow: inset 0 1px 0 #fff9, inset 0 -1px 0 #ab8b5555, 0 16px 40px #0003;
}
@media (prefers-reduced-motion: reduce) {
  [data-edition="4"] [data-state="unsealing"] .flap,
  [data-edition="4"] [data-state="unsealing"] .envelope::after,
  [data-edition="4"] [data-state="unsealing"] .insert { animation-duration: .001ms; animation-delay: 0ms; }
}
