/* Wide screens: an open card of two arches, and a landscape envelope.
   Phones never match this, apart from the two small rules that hide the wide-only parts. */
.panel > .frame, .env-duo, .foot-wide { display: none; }

@media (min-width: 1000px) {
  /* Keeps the page the same width before and after the envelope opens. */
  html { scrollbar-gutter: stable; }
  html:has(.card.split) body { padding-block: 0; }
  /* The space above the arches plus the credit below them, so both still fit on one screen. */
  :root { --around: 4.25rem; }
  .card.split + .built-by { height: 2.75rem; padding-bottom: .25rem; }

  /* ---- Two arches side by side ---- */
  .card.split, .env-duo {
    /* Each arch keeps the printed card's tall shape: limited by the window's width and height. */
    /* Never narrower than 28rem: in a very short window the page scrolls rather than
       shrinking the arches until the text spills over their curve. */
    --panel: max(28rem, min(37.5rem, calc(50vw - 3rem), calc((100vh - var(--around)) * .74)));
    --gap: min(3.5rem, 4vw);
  }
  .card.split { width: calc(var(--panel) * 2 + var(--gap)); padding-block: 1.5rem 0; container-type: normal; }
  .card.split > .frame { display: none; }
  .card.split > .content { padding: 0; }
  .split .duo, .env-duo { display: grid; grid-template-columns: var(--panel) var(--panel); gap: var(--gap); align-items: stretch; }
  .split .panel, .env-duo .panel { position: relative; container-type: inline-size; min-height: calc(100vh - var(--around)); }
  .split .panel > .frame, .env-duo .panel > .frame { display: flex; }
  .split .panel-body { position: relative; display: flex; flex-direction: column; justify-content: center; min-height: 100%; padding: 17cqw 10cqw 15cqw; }
  .split .panel-body > * { flex: none; }

  /* Invitation arch */
  /* The first line sits at the same height on the invitation and the confirmation: centred
     for the invitation, and never so high that it meets the curve. */
  .split .duo > .panel:first-child .panel-body,
  .split .keepsake .panel-body {
    justify-content: flex-start;
    padding-top: max(23.5cqw, calc((100vh - var(--around) - 69cqw) / 2 - .875rem));
    padding-bottom: 16cqw; /* clear of the bottom ornament */
  }
  /* Short windows: start as high as the curve allows, so the details stay on one screen. */
  @media (max-height: 830px) {
    .split .duo > .panel:first-child .panel-body,
    .split .keepsake .panel-body { padding-top: 23.5cqw; }
  }
  .card.split.solo { width: var(--panel); }
  .split.solo .duo { grid-template-columns: var(--panel); }
  .split .card-title { font-size: 3.2cqw; }
  .split .name { font-size: 13cqw; margin-top: 3cqw; }
  .split .and { width: 35cqw; margin-top: 2cqw; }
  .split .panel-body > .reception { margin-top: calc(2rem - 2.75cqw); }
  .split .panel-body > .reception::before { margin-bottom: 1.25rem; }
  /* The details tile is as wide as the Submit button opposite. */
  .split .reception .when-where { width: 72cqw; margin-inline: auto; }
  .split .and + .person .name { margin-top: 2cqw; }

  /* RSVP arch: choices side by side and names in two columns, so the form stays short. */
  /* The form needs more room from the inner rule, and from the curve at the top. */
  .split .panel-body.panel-rsvp { padding: 21cqw 14cqw 15cqw; }
  .split .rsvp { margin-top: 0; scroll-margin-top: 100vh; } /* after an error, show the whole card */
  .split .rsvp > p { max-width: 21rem; margin-inline: auto; }
  .split .rsvp form { max-width: none; margin-top: 1rem; }
  .split .rsvp .field { margin-top: 1rem; }
  .split .choices { grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr)); }
  .split .choice { padding-inline: 1rem; }
  .split .guest-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .6rem .75rem; align-items: start; }
  .split .guest-grid .guest-name { margin-top: 0; min-width: 0; }
  .split .guest-grid .guest-name[hidden] { display: none; }
  .split .rsvp form .button { margin-top: 1.25rem; }

  /* Confirmation */
  .split .keepsake { padding-top: 0; }
  .split .foot-wide { display: block; }
  .split .foot-narrow { display: none; }
  .split .keepsake .reception { margin-top: 0; }
  .split .keepsake .reception::before { display: none; }
  .split .keepsake .countdown { margin-top: 30px; }
  .split .keepsake .reception h2 { margin-top: 3px; }
  .split .keepsake .countdown::before {
    content: ""; display: block; width: 60%; height: 7px; margin: 0 auto 23px;
    background: linear-gradient(var(--emboss-light) 0 1px, rgb(143 108 72 / .5) 1px 2px, transparent 2px 5px, var(--emboss-light) 5px 6px, rgb(143 108 72 / .5) 6px 7px);
    mask-image: linear-gradient(90deg, transparent, #000 25% 75%, transparent);
  }

  /* ---- Landscape envelope ---- */
  .envelope {
    --width: min(56.25rem, 86vw, 118vh);
    top: 50%; bottom: auto; left: 50%;
    width: var(--width); height: calc(var(--width) * 2 / 3);
    transform: translate(-50%, -50%);
  }
  .env-inside { background: var(--paper) url("../art/paper.webp") repeat; background-size: 480px 480px; box-shadow: 0 24px 40px rgb(90 62 36 / .3), 0 3px 8px rgb(90 62 36 / .2); }
  .env-lining { clip-path: polygon(0 0, 100% 0, 50.9% 56%, 49.1% 56%); background: linear-gradient(#cdbb9f, #a8906e 56%); }
  .env-left > div { clip-path: polygon(0 0, 50.9% 56%, 0 100%); background-image: linear-gradient(90deg, rgb(226 211 192 / .12), rgb(222 205 183 / .28)), url("../art/paper.webp"); }
  .env-right > div { clip-path: polygon(100% 0, 49.1% 56%, 100% 100%); background-image: linear-gradient(270deg, rgb(226 211 192 / .12), rgb(222 205 183 / .28)), url("../art/paper.webp"); }
  .env-bottom > div { clip-path: polygon(0 100%, 43.1% 58.3%, 46% 55.7%, 50% 54.6%, 54% 55.7%, 56.9% 58.3%, 100% 100%); }
  .env-flap-paper > div { clip-path: polygon(0 0, 100% 0, 57.3% 53.6%, 54% 55.8%, 50% 56.8%, 46% 55.8%, 42.7% 53.6%); background-image: linear-gradient(rgb(240 231 219 / .45), rgb(220 201 177 / .45) 56%), url("../art/paper.webp"); }
  .env-greeting { top: 17%; font-size: clamp(1.8rem, 5vh, 2.75rem); }
  .env-hint { top: 85%; font-size: 1.25rem; }
  .seal { --size: min(11.5rem, 23vh, 20vw); top: 56%; }

  /* The wide card: as big as the window, holding the two arches exactly where the page has them. */
  .env-card {
    top: 0; left: 0; width: 100%; height: 100%;
    container-type: normal;
    transform-origin: 50% 50%;
    transform: translateY(3vh) scale(var(--desk-tuck, .4));
  }
  .env-card > .frame { display: none; }
  .env-duo { display: grid; justify-content: center; padding-top: 1.5rem; }

  .opening .env-flap { transform: translateY(-95vh); }
  .opening .env-card { animation-name: wide-card-rises; }
  .env-front { transition: transform .85s cubic-bezier(.55, 0, .35, 1) 1.6s, opacity .45s ease 1.95s; }
  .opening .env-front { transform: translateY(90vh); opacity: 0; }
}

@keyframes wide-card-rises {
  0% { transform: translateY(3vh) scale(var(--desk-tuck, .4)); animation-timing-function: cubic-bezier(.3, 0, .2, 1); }
  52% { transform: translateY(-19vh) scale(var(--desk-tuck, .4)); box-shadow: 0 -2px 18px rgb(90 62 36 / .26); animation-timing-function: cubic-bezier(.55, 0, .25, 1); }
  100% { transform: translateY(0) scale(1); box-shadow: 0 -2px 18px rgb(90 62 36 / 0); }
}
