/* Desktop cover: a stationery flat-lay. The burgundy envelope lies on linen with the
   invitation card tucked in it; opening flips the flap over and draws the card out.
   The same envelope is used on every screen; portrait screens size it to the width below. */
@media all {
  .pearl-cover {
    /* Envelope: 1.4:1, as wide as the screen allows but never taller than 64vh. */
    --env-w: min(70vw, 960px, 89.6vh);
    --env-h: calc(var(--env-w) / 1.4);
    --tip: 58%;
    --seal: calc(var(--env-w) * .2);
    --card-out: calc(var(--env-h) * .22);
    --caption-space: 66px;
    --tilt: -1.6deg;
    --flap-time: 1.25s;
    --drop: calc(var(--env-h) * .32);
    /* The card starts fully inside the sealed envelope and rises the same distance out of it. */
    --card-in: calc(var(--env-h) * .05);
    --rise: calc(var(--env-h) * .44);
    --env-paper: url("/assets/envelope-pearl-body-v2.webp") 50% 0 / 106% auto no-repeat;
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .28 0 0 0 0 .2 0 0 0 0 .14 0 0 0 .5 -.12'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
    --fibre: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 .86 0 0 0 0 .82 0 0 0 .45 -.18'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
    display: grid;
    place-items: center;
    padding: 0;
    overflow: hidden;
    background: #e6dfd3;
  }
  /* The table: warm linen in soft window light from the upper left. */
  .pearl-cover::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
      radial-gradient(110% 85% at 14% 4%, #fffcf6a6, #fffcf600 58%),
      radial-gradient(85% 75% at 90% 106%, #6e4f3a33, #6e4f3a00 62%),
      var(--grain),
      repeating-linear-gradient(0deg, #6e563f0c 0 1px, #0000 1px 3px),
      repeating-linear-gradient(90deg, #6e563f0a 0 1px, #0000 1px 4px),
      #e6dfd3;
  }
  .pearl-cover.opening,
  .pearl-cover.releasing { background: #e6dfd3; }

  /* The sheet is the envelope's footprint, nudged so card, envelope and caption sit centred. */
  .pearl-cover .intro-sheet {
    z-index: 1;
    width: var(--env-w);
    height: var(--env-h);
    min-height: 0;
    padding: 0;
    margin: 0;
    background: transparent;
    box-shadow: none;
    transform: translateY(calc(var(--caption-space) / -2));
  }
  .pearl-cover.opening .intro-sheet { box-shadow: none; }
  /* Two die-cut begonvil sprigs slipped under opposite corners, like the invitation's own. */
  .pearl-cover .intro-sheet::before,
  .pearl-cover .intro-sheet::after {
    content: "";
    display: block;
    position: absolute;
    width: calc(var(--env-h) * .36);
    height: calc(var(--env-h) * .484);
    border: 0;
    opacity: 1;
    z-index: 0;
    background: url("/assets/begonvil-corners.webp") 100% 98% / 238.8% auto no-repeat;
    filter: saturate(.9) drop-shadow(1px 2px 1.2px #4a2a1a40) drop-shadow(3px 7px 7px #4a2a1a26);
  }
  .pearl-cover .intro-sheet::before {
    inset: calc(var(--env-h) * -.3) calc(var(--env-h) * -.28) auto auto;
    transform: rotate(-80deg);
  }
  .pearl-cover .intro-sheet::after {
    inset: auto auto calc(var(--env-h) * -.1) calc(var(--env-h) * -.12);
    width: calc(var(--env-h) * .27);
    height: calc(var(--env-h) * .363);
    transform: scaleX(-1) rotate(8deg);
  }
  .pearl-cover.opening .intro-sheet::before,
  .pearl-cover.opening .intro-sheet::after { opacity: 1; }

  .pearl-cover .envelope-button {
    inset: 0;
    cursor: pointer;
    transform: rotate(var(--tilt));
    transition: transform .6s cubic-bezier(.2,.7,.2,1);
  }
  .pearl-cover.flap-open .envelope-button {
    /* The envelope settles lower while the flap swings up, so both stay in view. */
    transform: translateY(var(--drop)) rotate(calc(var(--tilt) - .5deg));
    transition: transform 1.5s cubic-bezier(.4,0,.2,1);
  }
  .pearl-cover .envelope-art {
    perspective: 2300px;
    perspective-origin: 50% 50%;
  }

  /* Inside of the envelope, seen through the mouth once the flap is up; it also
     carries the envelope's shadow on the linen. */
  .pearl-cover .cover-pocket {
    z-index: 1;
    background: linear-gradient(#1a0305 0%, #2a0609 20%, #3a0a0e 62%, #300a0c 100%);
    box-shadow:
      0 1px 1px #3a18122e,
      2px 5px 9px -2px #3a181238,
      12px 26px 38px -12px #3a18124d,
      22px 52px 80px -30px #3a181240;
    transition: box-shadow .5s ease;
  }
  .pearl-cover:not(.opening) .envelope-button:hover .cover-pocket {
    box-shadow:
      0 1px 1px #3a18122e,
      3px 8px 12px -2px #3a181238,
      14px 32px 46px -12px #3a18124d,
      26px 60px 90px -30px #3a181240;
  }

  /* The invitation card, hidden inside the sealed envelope until the flap opens. */
  .pearl-cover .cover-card {
    position: absolute;
    display: block;
    z-index: 3;
    left: 7%;
    top: var(--card-in);
    width: 86%;
    height: 86%;
    padding-top: calc(var(--env-h) * .044);
    color: var(--ink);
    font: 400 calc(var(--env-h) * .066)/1.06 var(--serif);
    letter-spacing: -.02em;
    text-align: center;
    background:
      var(--grain),
      radial-gradient(130% 120% at 30% 0%, #fffefb, #fbf8f1 65%, #f5f0e6);
    outline: 1px solid #c6b393;
    outline-offset: calc(var(--env-h) * -.024);
    box-shadow:
      inset 0 0 0 calc(var(--env-h) * .024 + 5px) #fffdf8,
      inset 0 0 0 calc(var(--env-h) * .024 + 6px) #dccfb9,
      0 0 0 .5px #6b4a3a26,
      0 1px 1px #4a2a1a26,
      1px 4px 7px -2px #4a2a1a33;
    transform: rotate(.8deg);
    transform-origin: 50% 100%;
    transition: transform .6s cubic-bezier(.2,.7,.2,1), box-shadow .6s ease;
  }
  .pearl-cover .cover-card::before {
    content: "Nişanımıza davetlisiniz";
    display: block;
    margin-bottom: calc(var(--env-h) * .017);
    color: #957a55;
    font: 500 calc(var(--env-h) * .0175)/1 var(--sans);
    letter-spacing: .3em;
    text-transform: uppercase;
  }
  .pearl-cover .cover-card em {
    padding: 0 .08em;
    color: var(--gold);
    font-size: .6em;
    font-style: italic;
  }
  /* Lines hidden in the envelope until the card slides out. */
  .pearl-cover .cover-card em::before,
  .pearl-cover .cover-card em::after {
    position: absolute;
    left: 0;
    right: 0;
    letter-spacing: 0;
  }
  .pearl-cover .cover-card em::before {
    content: "Cumartesi, saat 19.30";
    top: calc(var(--env-h) * .285);
    padding-top: calc(var(--env-h) * .04);
    color: var(--quiet);
    background: linear-gradient(var(--gold), var(--gold)) 50% 0 / calc(var(--env-h) * .06) 1px no-repeat;
    font: 500 calc(var(--env-h) * .0175)/1 var(--sans);
    letter-spacing: .26em;
    text-transform: uppercase;
  }
  .pearl-cover .cover-card em::after {
    content: "Begonvil Event · Karşıyaka";
    top: calc(var(--env-h) * .36);
    color: var(--ink);
    font: italic 400 calc(var(--env-h) * .032)/1 var(--serif);
  }
  .pearl-cover .cover-card::after {
    content: "7 Kasım 2026";
    display: block;
    margin-top: calc(var(--env-h) * .015);
    color: var(--body);
    font: 400 calc(var(--env-h) * .03)/1 var(--serif);
    letter-spacing: .05em;
  }
  .pearl-cover.flap-open .cover-card {
    transform: translateY(calc(var(--rise) * -1)) rotate(-.2deg);
    box-shadow:
      inset 0 0 0 calc(var(--env-h) * .024 + 5px) #fffdf8,
      inset 0 0 0 calc(var(--env-h) * .024 + 6px) #dccfb9,
      0 0 0 .5px #6b4a3a1f,
      0 2px 2px #4a2a1a1f,
      3px 12px 20px -4px #4a2a1a38,
      10px 30px 44px -16px #4a2a1a33;
    /* It slides out once the flap has passed upright. */
    transition: transform 1.15s cubic-bezier(.45,.05,.2,1) .72s, box-shadow 1.15s ease .72s;
  }
  .pearl-cover.releasing .cover-card {
    transform: translateY(calc(var(--rise) * -1 - var(--env-h) * .03)) rotate(-.2deg) scale(1.012);
    transition: transform .9s cubic-bezier(.2,.6,.3,1), box-shadow .9s ease;
  }

  /* Paper parts share the envelope's box so the texture runs on like one sheet. */
  .pearl-cover .cover-fold-bottom,
  .pearl-cover .cover-front-fold {
    clip-path: none;
    background: none;
  }
  /* Side flaps: the lowest layer of the back, darker where the others overlap them. */
  .pearl-cover .cover-fold-bottom {
    z-index: 4;
    filter: drop-shadow(0 1px .5px #1a030566) drop-shadow(0 4px 6px #1a030540);
  }
  .pearl-cover .cover-fold-bottom::before,
  .pearl-cover .cover-fold-bottom::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
      var(--fibre),
      linear-gradient(160deg, #ffffff08, #0000 40%, #1202042e),
      var(--env-paper);
    filter: brightness(.76) saturate(.9);
  }
  .pearl-cover .cover-fold-bottom::before { clip-path: polygon(0 0, 46% 50%, 0 100%); }
  .pearl-cover .cover-fold-bottom::after { clip-path: polygon(100% 0, 54% 50%, 100% 100%); }

  /* Bottom flap: glued over the side flaps, rising to a soft point under the seal. */
  .pearl-cover .cover-front-fold {
    z-index: 5;
    filter: drop-shadow(0 -1px .6px #1a030570) drop-shadow(0 -3px 5px #1a030540);
  }
  .pearl-cover .cover-front-fold::before {
    content: "";
    position: absolute;
    inset: 0;
    clip-path: polygon(0 100%, 0 99.4%, 43.5% 48.6%, 46.5% 46.4%, 50% 45.6%, 53.5% 46.4%, 56.5% 48.6%, 100% 99.4%, 100% 100%);
    background:
      linear-gradient(to bottom right, #0000 50%, #ffd5c626 50%, #ffd5c600 calc(50% + 2.5px)) 0 100% / 45% 52% no-repeat,
      linear-gradient(to bottom left, #0000 50%, #ffd5c61c 50%, #ffd5c600 calc(50% + 2.5px)) 100% 100% / 45% 52% no-repeat,
      var(--fibre),
      linear-gradient(170deg, #ffffff0a, #0000 45%, #0f020324),
      var(--env-paper);
    filter: brightness(.82) saturate(.92);
  }

  /* The flap: front face carries pearls and seal; the back shows a gold liner when it flips. */
  .pearl-cover .cover-lid {
    z-index: 6;
    transform-style: preserve-3d;
    transform-origin: 50% 0;
    filter: none;
    transition: transform .6s cubic-bezier(.2,.7,.2,1);
    --pearl-start-y: .072;
    --pearl-end-y: .58;
    --pearl-inset-x: .062;
    --pearl-lift: .034;
  }
  .pearl-cover.flap-open .cover-lid {
    z-index: 2;
    filter: none;
    transform: rotateX(178deg);
    /* Pass under the card once the flap stands upright (about 88 degrees). */
    transition: transform var(--flap-time) cubic-bezier(.5,.02,.3,1), z-index 0s linear .52s;
  }
  .pearl-cover .cover-flap {
    clip-path: none;
    background: none;
    backface-visibility: hidden;
    filter: drop-shadow(0 1px .6px #1a030580) drop-shadow(1px 4px 5px #1a030550);
  }
  .pearl-cover .cover-flap::after {
    clip-path: polygon(0 0, 100% 0, 50% var(--tip));
    -webkit-mask-image: none;
    mask-image: none;
    background:
      linear-gradient(to top right, #0000 50%, #ffd9cc40 50%, #ffd9cc00 calc(50% + 3px)) 0 0 / 50% var(--tip) no-repeat,
      linear-gradient(to top left, #0000 50%, #ffd9cc33 50%, #ffd9cc00 calc(50% + 3px)) 100% 0 / 50% var(--tip) no-repeat,
      linear-gradient(#ffdccf2e, #ffdccf00 3px),
      var(--fibre),
      linear-gradient(165deg, #ffffff10, #0000 45%, #1002041f),
      var(--env-paper);
    filter: brightness(.88) saturate(.94);
  }
  .pearl-cover .cover-lid::before,
  .pearl-cover .cover-lid::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    backface-visibility: hidden;
    transform: rotateY(180deg);
  }
  /* Inside of the flap: plain burgundy edge around the liner. */
  .pearl-cover .cover-lid::before {
    clip-path: polygon(0 0, 100% 0, 50% var(--tip));
    background: linear-gradient(#0000, #0c010226), var(--fibre), var(--env-paper);
    filter: brightness(.74) saturate(.9);
  }
  /* Gold liner with a fine woven line. */
  .pearl-cover .cover-lid::after {
    clip-path: polygon(5.5% 0, 94.5% 0, 50% 51.8%);
    transform: rotateY(180deg) translateZ(.5px);
    background:
      repeating-linear-gradient(135deg, #fff8e61f 0 1px, #0000 1px 8px),
      repeating-linear-gradient(45deg, #6e50281a 0 1px, #0000 1px 8px),
      linear-gradient(100deg, #b49a6c 0%, #e6d6b4 28%, #c3a97b 50%, #eee0c2 72%, #b3976a 100%);
  }
  .pearl-cover .cover-pearls {
    backface-visibility: hidden;
    transform: translateZ(.5px);
    filter: drop-shadow(1px 2px 1.5px #1e030673);
  }
  .pearl-cover .cover-seal {
    inset: auto;
    left: calc(50% - var(--seal) / 2);
    top: calc(var(--tip) - var(--seal) * .52);
    width: var(--seal);
    height: var(--seal);
    backface-visibility: hidden;
    transform: translateZ(1px);
    filter: saturate(.6) drop-shadow(1px 3px 2px #23060880) drop-shadow(4px 10px 10px #2306084d);
    transition: transform .35s cubic-bezier(.2,.8,.2,1), filter .35s ease;
  }
  /* A glint of light crosses the wax when the pointer finds the seal. */
  .pearl-cover .cover-seal::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0;
    background: linear-gradient(115deg, #fff0 38%, #fffdf6b3 50%, #fff0 62%) 160% 0 / 260% 100% no-repeat;
    -webkit-mask: url("/assets/envelope-wax-seal-v2.webp") center / contain no-repeat;
    mask: url("/assets/envelope-wax-seal-v2.webp") center / contain no-repeat;
    transition: background-position .9s cubic-bezier(.3,.6,.3,1), opacity .3s ease;
  }
  .pearl-cover:not(.opening) .envelope-button:hover .cover-seal {
    transform: translateZ(1px) translateY(-2px) scale(1.035);
    filter: saturate(.62) brightness(1.03) drop-shadow(2px 6px 4px #23060873) drop-shadow(6px 16px 16px #2306084d);
  }
  .pearl-cover:not(.opening) .envelope-button:hover .cover-seal::before {
    opacity: 1;
    background-position: -60% 0;
  }
  .pearl-cover:not(.opening) .envelope-button:active .cover-seal {
    transform: translateZ(1px) scale(.985);
  }

  /* Keyboard focus keeps the existing ring, moved onto the seal. */
  .pearl-cover .envelope-button:focus-visible::after {
    left: calc(50% - var(--seal) * .47);
    top: calc(var(--tip) - var(--seal) * .46);
    width: calc(var(--seal) * .94);
    height: calc(var(--seal) * .94);
  }

  /* Instruction under the envelope. */
  .pearl-cover .cover-caption {
    position: absolute;
    top: calc(100% + 36px);
    left: -30%;
    right: -30%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 0;
    color: #6f5f55;
    font: 400 14px/1.4 var(--sans);
    letter-spacing: .06em;
    pointer-events: none;
    transition: opacity .35s ease, color .35s ease;
  }
  .pearl-cover .cover-caption::before,
  .pearl-cover .cover-caption::after {
    content: "";
    width: 30px;
    height: 1px;
    background: var(--gold);
    transition: width .45s cubic-bezier(.2,.7,.2,1);
  }
  .pearl-cover .envelope-button:hover ~ .cover-caption { color: var(--ink); }
  .pearl-cover .envelope-button:hover ~ .cover-caption::before,
  .pearl-cover .envelope-button:hover ~ .cover-caption::after { width: 48px; }
  .pearl-cover.opening .cover-caption { opacity: 0; }

  @media (prefers-reduced-motion: reduce) {
    .pearl-cover .cover-seal::before { display: none; }
  }
}

/* Phones and portrait tablets: the same envelope, sized to the screen width. */
@media (max-aspect-ratio: 1/1) {
  .pearl-cover { --env-w: min(88vw, 560px); --caption-space: 52px; }
  .pearl-cover .cover-caption { top: calc(100% + 26px); font-size: 13px; letter-spacing: .04em; gap: 12px; }
}
/* Touch screens are tapped, not clicked. */
.cover-caption .caption-touch { display: none; }
@media (hover: none) {
  .cover-caption .caption-mouse { display: none; }
  .cover-caption .caption-touch { display: inline; }
}
