:root {
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --settle: cubic-bezier(0.18, 0.72, 0.22, 1);
  --pick-up: cubic-bezier(0.22, 0.65, 0.28, 1);
}
.scene {
  padding-left: max(var(--margin), calc(var(--safe-left) + 12px));
  padding-right: max(var(--margin), calc(var(--safe-right) + 12px));
}
.room-imprint {
  left: max(34px, calc(var(--safe-left) + 12px));
}

/* Rest, contact, lift, and return share the same direction of light. */
.entry-chair {
  transform-origin: 50% 94%;
  transition:
    transform 0.52s var(--settle),
    filter 0.52s var(--settle);
}
.entry-chair.is-pressed {
  transform: translateX(-50%) rotate(-2deg) translateY(3px);
}
.envelope-object {
  --lift: 0px;
  transition: transform 0.48s var(--settle);
}
.envelope-object > img {
  transition: filter 0.48s var(--settle);
}
.envelope-object.is-pressed {
  --lift: -3px;
}
.envelope-object .invitation-preview {
  display: none;
}
.kept-note {
  transition: transform 0.45s var(--settle);
}
.kept-note.is-selected {
  transform: rotate(var(--note-angle)) translateY(-3px);
}
.kept-note.is-pressed {
  transform: rotate(var(--note-angle)) translateY(2px);
}
.kept-note.in-hand img {
  visibility: hidden;
}
.tear-stub {
  transform-origin: 10px 50%;
  transition:
    transform 0.42s var(--settle),
    filter 0.42s var(--settle);
}
.tear-stub.is-pressed {
  transform: perspective(600px) rotateY(-7deg) rotate(-2deg);
}
.room-tag {
  transform-origin: 14% 15%;
  transition:
    transform 0.42s var(--settle),
    filter 0.42s var(--settle);
}
.room-tag.is-pressed {
  transform: rotate(-3deg) translateY(2px);
}
.return-corner {
  transition:
    transform 0.36s var(--settle),
    filter 0.36s var(--settle);
  touch-action: manipulation;
}
.return-corner.is-pressed {
  transform: rotate(-10deg) translate(-2px, -2px);
}
.guide-spine {
  display: none;
}
.worktable::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 12px;
  background: linear-gradient(
    #547180bb,
    #173541 28%,
    #102d3980 42%,
    transparent
  );
  pointer-events: none;
}

/* A card lifts from its slot, turns, and returns before the pile closes. */
.question-cards {
  position: relative;
  display: block;
  width: 100%;
  max-width: 850px;
  perspective: 1800px;
  overflow-anchor: none;
  transition: height 0.5s var(--settle);
}
.question-card {
  position: absolute;
  top: 0;
  left: 2%;
  width: 73%;
  max-width: 450px;
  height: var(--paper-height, 340px);
  margin: 0;
  z-index: 1;
  transform: translate3d(0, var(--card-y, 0px), 0)
    rotate(var(--card-angle, -4deg));
  transition: transform 0.5s var(--settle);
}
.question-card:nth-child(2) {
  left: 18%;
  --card-angle: 3deg;
}
.question-card:nth-child(3) {
  left: 5%;
  --card-angle: -2deg;
}
.question-card:nth-child(4) {
  left: 22%;
  --card-angle: 4deg;
}
.question-card.is-open,
.question-card.is-lifted {
  z-index: 14;
  transform: translate3d(0, calc(var(--card-y) - 10px), 15px) rotate(0deg);
}
.card-turn,
.imprint-turn {
  position: relative;
  height: 100%;
  width: 100%;
  transform-style: preserve-3d;
  transform-origin: 50% 52%;
}
.question-face,
.imprint-front,
.imprint-back {
  position: absolute;
  inset: 0;
  padding: 30px 33px 72px;
  background: url("paper-stock.webp") center/100% 100% no-repeat;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  filter: drop-shadow(6px 10px 6px #081e2d55);
  transition: filter 0.4s var(--settle);
}
.question-card.is-open .question-face,
.question-card.is-lifted .question-face {
  filter: drop-shadow(13px 23px 11px #081e2d66);
}
.question-cover {
  display: flex;
  align-items: start;
  justify-content: start;
  text-align: left;
  color: var(--blue-ink);
  width: 100%;
  font:
    27px/1.2 Ink,
    cursive;
  touch-action: pan-y;
}
.question-cover > span:first-child {
  display: block;
  max-width: 100%;
}
.question-reverse {
  transform: rotateY(180deg);
}
.question-reverse h3,
.imprint-back h2 {
  font:
    25px/1.25 Ink,
    cursive;
  color: var(--rust);
  margin: 0 0 17px;
}
.question-reverse p {
  font:
    14px/1.75 Text,
    sans-serif;
}
.question-reverse:has(.answer-invitation) {
  padding-bottom: 135px;
}
.answer-invitation {
  position: absolute;
  bottom: 33px;
  left: 27px;
  width: 95px;
  height: 85px;
  padding: 0;
  transform: rotate(-7deg);
  transition: transform 0.42s var(--settle);
}
.answer-invitation img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.answer-invitation.is-pressed {
  transform: rotate(-4deg) translateY(2px);
}
.imprint-card {
  width: 435px;
  max-width: 48%;
  height: var(--paper-height, 340px);
  position: relative;
  perspective: 1600px;
  transform: rotate(-3deg);
}
.imprint-front,
.imprint-back {
  padding: 37px 39px 64px;
}
.imprint-front {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: start;
  gap: 18px;
}
.imprint-back {
  transform: rotateY(180deg);
}
.imprint-back p {
  font:
    13px/1.8 Text,
    sans-serif;
  margin-top: 14px;
}
.imprint-back p:first-of-type {
  margin-top: 0;
}
.imprint-card.is-lifted .imprint-front,
.imprint-card.is-lifted .imprint-back {
  filter: drop-shadow(10px 19px 10px #071d2c66);
}

/* A keyboard leaves clear graphite marks on the same objects. */
.entry-chair:focus-visible,
.envelope-object:focus-visible,
.kept-note:focus-visible,
.tear-stub:focus-visible,
.room-tag:focus-visible,
.question-cover:focus-visible,
.question-reverse:focus-visible,
.imprint-front:focus-visible,
.imprint-back:focus-visible,
.answer-invitation:focus-visible {
  outline: none;
}
.entry-chair:focus-visible .chair-annotation {
  border: 2px solid var(--rust);
  border-radius: 48% 43% 46% 41%;
  padding: 9px 11px;
}
.envelope-object:focus-visible .object-caption {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
  text-decoration-color: #f0eddf;
}
.kept-note:focus-visible::after {
  content: "";
  position: absolute;
  inset: 3px 4px;
  border: 2px solid #f0eddf;
  border-radius: 42% 47% 37% 39%;
  transform: rotate(-3deg);
  pointer-events: none;
}
.kept-note:focus-visible {
  z-index: 12 !important;
}
.tear-stub:focus-visible::before,
.room-tag:focus-visible::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 2px solid var(--rust);
  border-radius: 4px 11px 5px 9px;
  pointer-events: none;
}
.question-cover:focus-visible > span:first-child,
.imprint-front:focus-visible .imprint-name,
.question-reverse:focus-visible h3,
.imprint-back:focus-visible h2 {
  text-decoration: underline;
  text-decoration-color: var(--rust);
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}
.answer-invitation:focus-visible {
  outline: 2px solid var(--rust);
  outline-offset: 3px;
  border-radius: 12%;
}
.return-corner:focus-visible {
  outline: 2px solid var(--rust);
  outline-offset: 2px;
}

/* Copy feedback leaves an ink receipt without changing the ticket's size. */
.keepsake-stub::after {
  content: "kept";
  position: absolute;
  top: -10px;
  right: 4px;
  border: 2px solid #813329a6;
  border-radius: 48%;
  padding: 1px 12px;
  font:
    16px/1.3 Ink,
    cursive;
  color: var(--rust);
  transform: rotate(-12deg) scale(0.92);
  opacity: 0;
}
.keepsake-stub.copied::after {
  opacity: 1;
  transform: rotate(-12deg) scale(1);
}
.keepsake-stub[aria-busy="true"] {
  transform: perspective(700px) rotateY(-10deg) rotate(2deg) translateY(-7px);
}
.keepsake-stub.copied {
  transform: rotate(5deg);
}
.copy-correction {
  display: block;
  position: absolute;
  top: 100%;
  right: 0;
  width: 185px;
  font:
    15px/1.4 Ink,
    cursive;
  color: var(--paper);
  margin-top: 10px;
}

/* Fixed edge widths let a long sheet grow without stretching its transparent margins. */
.writing-paper {
  background: none;
  border: 1px solid transparent;
  border-image: url("paper-stock.webp") 80 fill / 28px / 0 stretch;
}
.paper-front > .writing-paper {
  border-image: url("paper-stock.webp") 80 fill / 28px / 0 stretch;
}
.paper-back {
  background-color: #efebdd;
  background-size: 100% auto;
}
.writing-desk {
  padding-bottom: max(80px, calc(env(safe-area-inset-bottom) + 40px));
  padding-left: max(26px, calc(var(--safe-left) + 8px));
  padding-right: max(26px, calc(var(--safe-right) + 8px));
}
.wayfinder {
  bottom: max(28px, calc(env(safe-area-inset-bottom) + 17px));
}
.writing-paper .reply-return {
  z-index: 9;
}
.reply-dialog.in-transit {
  overflow-y: hidden;
  touch-action: none;
}

@media (hover: hover) and (pointer: fine) {
  .entry-chair:hover,
  .entry-chair:focus-visible {
    transform: translateX(-50%) rotate(-2deg);
    filter: drop-shadow(17px 20px 8px #2f2a214a);
  }
  .envelope-object:hover,
  .envelope-object:focus-visible {
    --lift: -9px;
  }
  .envelope-object:hover > img {
    filter: drop-shadow(13px 24px 11px #071a2473);
  }
  .kept-note:hover {
    transform: rotate(var(--note-angle)) translateY(-7px);
  }
  .invitation-stub:hover {
    transform: perspective(700px) rotateY(-8deg) rotate(-1deg);
  }
  .keepsake-stub:hover {
    transform: perspective(700px) rotateY(-8deg) rotate(3deg);
  }
  .room-tag:hover {
    transform: rotate(-3deg) translateY(-2px);
  }
  .return-corner:hover,
  .question-cover:hover .fold-corner,
  .imprint-front:hover .fold-corner {
    transform: rotate(-8deg) translate(-2px, -2px);
  }
  .answer-invitation:hover {
    transform: rotate(-5deg) translateY(-4px);
  }
  .stamp-action:hover {
    transform: rotate(-3deg) translateY(-3px);
  }
}
@media (max-width: 1000px) {
  .writing-desk {
    padding-left: max(18px, calc(var(--safe-left) + 8px));
    padding-right: max(18px, calc(var(--safe-right) + 8px));
  }
  .imprint-card {
    width: 390px;
    max-width: 49%;
  }
  .imprint-front,
  .imprint-back {
    padding-inline: 32px;
  }
}
@media (max-width: 850px) {
  .writing-desk {
    padding-left: max(20px, calc(var(--safe-left) + 8px));
    padding-right: max(20px, calc(var(--safe-right) + 8px));
  }
  .room-imprint {
    left: max(24px, calc(var(--safe-left) + 12px));
  }
  .question-cards {
    max-width: 610px;
    margin: 0 auto;
  }
  .question-card {
    max-width: 420px;
  }
  .imprint-card {
    max-width: 58%;
  }
}
@media (max-width: 650px) {
  .writing-desk {
    padding-left: max(13px, calc(var(--safe-left) + 8px));
    padding-right: max(13px, calc(var(--safe-right) + 8px));
  }
  .room {
    min-height: 0;
    height: 100svh;
  }
  .room-imprint {
    left: max(19px, calc(var(--safe-left) + 12px));
    top: max(19px, calc(env(safe-area-inset-top) + 12px));
  }
  .open-invitation > p:not(.ink) {
    font-size: 14px;
    line-height: 1.85;
  }
  .envelope-object {
    height: 326px;
  }
  .envelope-spread {
    height: 1050px;
  }
  .cause-object {
    top: 335px;
  }
  .hello-object {
    top: 670px;
  }
  .invitation-beats p {
    font-size: 12px;
    line-height: 1.85;
  }
  .question-cards {
    width: 100%;
    max-width: 370px;
  }
  .question-card {
    width: 88%;
    max-width: 330px;
    left: 2%;
  }
  .question-card:nth-child(2) {
    width: 88%;
    left: 8%;
  }
  .question-card:nth-child(3) {
    width: 88%;
    left: 0;
  }
  .question-card:nth-child(4) {
    width: 88%;
    left: 9%;
  }
  .question-face {
    padding: 30px 28px 73px;
  }
  .question-cover {
    font-size: 26px;
  }
  .question-reverse h3 {
    font-size: 24px;
  }
  .question-reverse p {
    font-size: 14px;
    line-height: 1.75;
  }
  .imprint-card {
    width: 100%;
    max-width: none;
  }
  .imprint-front,
  .imprint-back {
    padding: 34px 30px 67px;
  }
  .imprint-back p {
    font-size: 13px;
    line-height: 1.85;
  }
  .wayfinder {
    left: max(12px, calc(var(--safe-left) + 6px));
    bottom: max(21px, calc(env(safe-area-inset-bottom) + 14px));
  }
  .guide-object {
    transform: translateX(calc((1 - var(--unfold)) * (44px - var(--leaf))))
      translateY(calc((1 - var(--unfold)) * 38px));
  }
  .guide-cover > span:first-child,
  .guide-cover small,
  .guide-cover .guide-location {
    visibility: hidden;
  }
  .guide-spine {
    display: block;
    position: absolute;
    right: 11px;
    top: 18px;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font:
      17px/1.3 Ink,
      cursive;
    color: var(--blue-ink);
  }
  .guide-cover:focus-visible {
    outline-offset: -4px;
  }
  .kept-note img {
    max-height: none;
  }
  .outbox-heading p,
  .collection-note p {
    font-size: 12px;
  }
  .writing-tools > small {
    font-size: 10px;
  }
  .writing-tools > p {
    font-size: 14px;
  }
  .motion-note > span {
    font-size: 11px;
  }
  .imprint-scene {
    padding-bottom: max(135px, calc(env(safe-area-inset-bottom) + 100px));
  }
}
@media (max-width: 375px) {
  .envelope-spread {
    height: 1000px;
  }
  .cause-object {
    top: 320px;
  }
  .hello-object {
    top: 640px;
  }
  .question-face {
    padding-inline: 24px;
  }
  .question-cover {
    font-size: 24px;
  }
}
@media (max-height: 650px) {
  .room {
    min-height: 0;
    height: 100svh;
  }
}
html[data-motion="off"] .entry-chair {
  transform: translateX(-50%) rotate(-5deg);
}
html[data-motion="off"] .envelope-object {
  --lift: 0px;
}
html[data-motion="off"] .question-card,
html[data-motion="off"] .imprint-card {
  transition: none;
}
@media (prefers-reduced-motion: reduce) {
  .entry-chair,
  .entry-chair:hover {
    transform: translateX(-50%) rotate(-5deg);
  }
  .envelope-object {
    --lift: 0px;
  }
}
