/* Give the wax-sealed envelope the whole focal plane on portrait phones.
   Keep its placement, the paper rendering and the clickable area in sync. */
#envelope .envelope-frame { display: contents; }
@media (max-width: 767px) and (max-aspect-ratio: 1/1) {
  #envelope {
    --mx: 50%;
    --my: 41.5svh;
    --envelope: min(86vw, 59svh);
    --relief-bg-speed: 1.58;
    --relief-bg-highlight-cut: .105;
    --relief-bg-shadow-fill: .22;
    --relief-card-speed: 1.45;
    /* Enlarged text can extend past the end of the scene. Let it scroll, not crop. */
    display: block;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  #envelope .envelope-frame {
    position: relative;
    isolation: isolate;
    display: block;
    min-block-size: 100%;
    padding:
      calc(var(--my) + var(--envelope) * .331 + 3.4rem + clamp(.3rem, 1.85svh, .72rem))
      5.5%
      max(10px, env(safe-area-inset-bottom));
  }

  /* Keep the same lifted shadow and gentler highlight palette in both CSS fallbacks. */
  #envelope .surface::before {
    background-image: linear-gradient(115deg, #482630 2%, #663242 16%, #512934 24%, #6c3a46 37%, #562d39 45%, #44232d 58%, #66313d 78%, #4f2a35 92%);
  }

  #envelope header {
    z-index: 3;
    left: max(5.5%, env(safe-area-inset-left));
    right: max(5.5%, env(safe-area-inset-right));
    gap: clamp(7px, 2.2vw, 14px);
  }

  #envelope .season { color: #ead5c9; white-space: nowrap; }

  #envelope .seal-link { aspect-ratio: 1280 / 847; }
  #envelope .seal-link span {
    top: calc(100% + .38rem);
    min-height: 36px;
    display: grid;
    place-items: center;
    color: #f8e9db;
    font-size: .8rem;
    letter-spacing: .105em;
  }
  #envelope .seal-link:active span { color: #fffaf3; }

  #envelope .opening-greeting {
    position: relative;
    width: auto;
    max-width: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    pointer-events: none;
  }
  #envelope .opening-greeting h1 {
    font-size: clamp(2.5rem, 12.3vw, 4.85rem);
    margin: 0;
    max-inline-size: 100%;
    white-space: normal;
  }
  #envelope .opening-greeting .salute {
    align-self: center;
    margin: 0;
    color: #ead5c9;
    letter-spacing: .115em;
  }
  [data-font=hand] #envelope .opening-greeting .salute { margin-top: .55rem; }
}

@media (max-width: 767px) and (max-aspect-ratio: 1/1) and (prefers-reduced-motion: no-preference) {
  #envelope .surface::before, #envelope .weft { animation-duration: 7s; }
  #envelope .tabletop picture img, #envelope .tabletop picture::before { animation-duration: 5.5s; }
}
