/* Bestellen (order.js): the book standing on the dimmed table, what it is and costs beside it, and the ways on. Its
   cover, spine and pages' edges are the start's book (app.css .start-front and its kin), here in the book's own shape
   and thickness, standing up from lying flat with a short spring as the modal opens. */
@property --turn {
  syntax: '<angle>';
  inherits: true;
  initial-value: 16deg;
}
@property --tilt {
  syntax: '<angle>';
  inherits: true;
  initial-value: 8deg;
}
@property --rise {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}

.modal-card:has(.order) {
  width: min(100%, 780px);
  padding: 28px 32px 30px;
}
.order {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  align-items: center;
  gap: 28px;
}
.order-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 320px;
  padding: 24px 0 30px;
}
.order-book {
  /* --aspect: the page's width over its height; --depth: the thickness as a share of the width (order.js) */
  --w: min(240px, 280px * var(--aspect));
  --h: calc(var(--w) / var(--aspect));
  --t: calc(var(--w) * var(--depth));
  --view: perspective(1600px) translateY(var(--rise)) rotateX(calc(var(--tilt) * -1)) rotateY(var(--turn));
  position: relative;
  width: var(--w);
  aspect-ratio: var(--aspect);
}
.order-front .tb-preview {
  pointer-events: none;
}
/* a sheen of light crossing the cover once it stands */
.order-front::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  background: linear-gradient(105deg, transparent 35%, rgb(255 255 255 / 0.32) 48%, transparent 60%);
  translate: -120% 0;
  pointer-events: none;
}
.order-book.is-arriving {
  animation:
    order-stand 1.1s var(--spring) both,
    order-appear 0.3s ease-out both;
}
.order-book.is-arriving .order-front::before {
  animation: order-sheen 1.1s 0.55s ease-in-out both;
}
.modal.open .order-stage::before {
  animation: order-appear 0.6s 0.15s ease-out both;
}
/* a spring: past where it stands, a little back, at rest */
.order {
  --spring: linear(
    0,
    0.03 2%,
    0.14 4.5%,
    0.72 13%,
    0.94 17%,
    1.02 19.5%,
    1.08 23%,
    1.1 26%,
    1.09 29%,
    1.01 39%,
    0.99 43%,
    0.986 47%,
    0.995 56%,
    1 67%,
    1
  );
}
@keyframes order-stand {
  from {
    --turn: 0deg;
    --tilt: 62deg;
    --rise: 40px;
  }
}
@keyframes order-appear {
  from {
    opacity: 0;
  }
}
@keyframes order-sheen {
  to {
    translate: 120% 0;
  }
}

.order-about {
  display: grid;
  justify-items: start;
  gap: 10px;
  padding-right: 8px;
}
.modal.open .order-about > * {
  animation: order-rise 0.5s var(--ease) both;
}
.modal.open .order-about > :nth-child(2) {
  animation-delay: 0.06s;
}
.modal.open .order-about > :nth-child(3) {
  animation-delay: 0.12s;
}
.modal.open .order-about > :nth-child(4) {
  animation-delay: 0.18s;
}
.modal.open .order-about > :nth-child(n + 5) {
  animation-delay: 0.24s;
}
@keyframes order-rise {
  from {
    opacity: 0;
    translate: 0 8px;
  }
}
.order-about .sheet-title {
  font-size: 26px;
  line-height: 1.15;
}
.order-what {
  color: var(--quiet);
}
.order-price {
  margin: 4px 0 8px;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
/* in our shop, what a copy more costs: a quiet line that belongs to the price above it */
.order-copies {
  margin-top: -12px;
}
.order-ways {
  display: grid;
  justify-items: start;
  gap: 10px;
}
.order-ways .chip {
  min-height: 48px;
  padding: 0 24px;
  font-size: 16px;
}
.order-ways .sheet-note {
  font-size: 14px;
}
/* the editor's way and its i: a small round mark that opens one line under them */
.order-copy {
  display: flex;
  align-items: center;
  gap: 8px;
}
.order-info {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  background: none;
  color: var(--quiet);
  font:
    italic 700 14px/1 Georgia,
    'Times New Roman',
    serif;
  cursor: pointer;
  transition: color 0.2s;
}
.order-info:hover,
.order-info[aria-expanded='true'] {
  color: var(--text);
}
/* the tap target is larger than the mark */
.order-info::before {
  content: '';
  position: absolute;
  inset: -9px;
}
.order-copy-note {
  max-width: 34em;
  margin-top: -2px;
}

/* a phone: the book above, smaller, its words under it */
@media (max-width: 640px) {
  .modal-card:has(.order) {
    padding: 18px 20px calc(var(--safe-bottom) + 24px);
  }
  .order {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
  .order-stage {
    min-height: 0;
    padding: 18px 0 26px;
  }
  .order-book {
    --w: min(150px, 190px * var(--aspect));
  }
  .order-ways,
  .order-ways .chip {
    width: 100%;
    justify-content: center;
  }
  .order-copy .chip {
    width: auto;
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .order-book.is-arriving,
  .order-book.is-arriving .order-front::before {
    animation: none;
  }
}
