/* The sheet the hero's field prints on (templates/welcome-print.html).
   It covers the page; the receipt is the home page's own (.wl-receipt
   in static/welcome.css). While it prints, static/welcome-print.js
   places the slot and the paper by transform each frame: the paper's
   top is the slot's line less what has been fed, and everything below
   the slot's line is cut away. Once cut, the sheet becomes a page that
   scrolls, the receipt in the flow and what comes next under it. */

.wt {
  --wt-w: min(21.5rem, calc(100vw - 2rem));
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--app-page-background);
  color: var(--marketing-text);
  outline: none;
}
.wt[hidden] { display: none; }

.wt-close {
  position: absolute;
  top: max(1rem, env(safe-area-inset-top));
  right: 1rem;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--solid-border);
  border-radius: 9999px;
  background: var(--solid-surface);
  box-shadow: var(--solid-shadow);
  color: var(--marketing-foreground);
  transition: transform 150ms ease;
}
.wt-close:active { transform: scale(0.97); }

.wt-scroll {
  position: absolute;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: contain;
}
.wt[data-wt-cut] .wt-scroll { overflow-y: auto; }

/* ---- printing: the slot and the paper, placed by the script ---------- */

.wt-stage { position: absolute; inset: 0; }
.wt-feed {
  position: absolute;
  inset: 0;
  /* Cut at the slot's line, set by the script; the paper's shadow and
     lean stay whole above and beside it. */
  clip-path: inset(-6rem -3rem calc(100% - var(--wt-line, 50%)) -3rem);
}
.wt-paper {
  position: absolute;
  top: 0;
  left: calc(50% - var(--wt-w) / 2);
  width: var(--wt-w);
  margin: 0;
  will-change: transform;
}
.wt-slot {
  /* The home page's slot, a little wider than the paper. */
  inset: 0 auto auto calc(50% - var(--wt-w) / 2 - 0.75rem);
  width: calc(var(--wt-w) + 1.5rem);
  translate: 0 -0.25rem;
  opacity: 0;
  will-change: transform;
}

/* The line the dots fill while the chain is read, and its word at the
   end of it. */
.wt-reading { display: flex; justify-content: space-between; gap: 0.75rem; }
.wt-reading-say { min-width: 0; overflow: hidden; white-space: nowrap; }
.wt-dots { letter-spacing: 0.08em; }
.wt-status { min-width: 2ch; text-align: right; white-space: nowrap; font-weight: 600; }
.wt-meta { display: flex; justify-content: space-between; gap: 1rem; color: var(--paper-muted); }
.wt-error { font-weight: 500; text-wrap: pretty; }

/* The cut: teeth at the foot as well as the head. */
.wt[data-wt-cut] .wt-paper {
  mask:
    conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) top / 0.75rem 0.375rem repeat-x,
    conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 0.75rem 0.375rem repeat-x,
    linear-gradient(#000 0 0) center / 100% calc(100% - 0.75rem) no-repeat;
  padding-bottom: 1.25rem;
}

/* ---- cut: the receipt in the flow, what comes next under it ---------- */

.wt[data-wt-cut] .wt-stage {
  position: relative;
  inset: auto;
  padding-top: var(--wt-top, 4.5rem);
}
.wt[data-wt-cut] .wt-feed { position: static; clip-path: none; }
.wt[data-wt-cut] .wt-paper { position: relative; left: auto; margin-inline: auto; transform: none !important; }
.wt[data-wt-cut] .wt-slot { display: none; }

.wt-act {
  width: min(32rem, 100% - 2rem);
  margin: 2rem auto 0;
  padding-bottom: max(3rem, env(safe-area-inset-bottom));
}
.wt-act:empty { display: none; }
.wt-next { display: grid; justify-items: center; text-align: center; }
.wt-next .wl-field { width: 100%; margin-top: 1.25rem; }
.wt-next .wl-email-fine { margin-top: 0.75rem; }
.wt-next-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 1.25rem; }
.wt-say { margin: 0; font-size: 1.125rem; }

@media (prefers-reduced-motion: no-preference) {
  .wt[data-wt-open] { animation: wt-down 650ms var(--wl-ease-sheet) both; }
  .wt[data-wt-closing] { animation: wt-up 380ms var(--wl-ease-sheet) both; }
  .wt-next { animation: wt-rise 420ms var(--wl-ease) both; }
}
@media (prefers-reduced-motion: reduce) {
  .wt[data-wt-open] { animation: wt-fade 200ms ease both; }
  .wt[data-wt-closing] { animation: wt-fade 160ms ease reverse both; }
}
@keyframes wt-down { from { transform: translateY(-100%); } }
@keyframes wt-up { to { transform: translateY(-100%); } }
@keyframes wt-fade { from { opacity: 0; } }
@keyframes wt-rise { from { opacity: 0; translate: 0 0.75rem; } }
