/* 00 · gate (sections/gate.js): the waiting room. Take a number, then go in.
   The dispenser, the printing ticket and its typesetting come from 04 · Take a number. */

:root {
  /* the ticket is pale yellow whether the lights are on or off, so the ink on it stays ink (extras.css does the same) */
  --gate-ink-on-canton: #10110f;
}

/* ------------------------------------------------------------ the shutter */
.gate {
  position: fixed; inset: 0; z-index: 39;
  background: var(--paper); color: var(--ink);
  overflow: hidden auto;
}
/* going in: the words and the stand step back, the ticket flies (gate.js), then the room fades and the receipt is underneath */
.gate.is-leaving { pointer-events: none; opacity: 0; transition: opacity 0.4s ease 0.72s; }
.gate.is-leaving .gate__copy { opacity: 0; transform: translateX(-28px); transition: opacity 0.4s ease, transform 0.6s var(--settle); }
.gate.is-leaving .gate__dispenser { opacity: 0; transform: translateY(28px) scale(0.98); transition: opacity 0.45s ease 0.05s, transform 0.65s var(--settle); }
.gate.is-leaving .gate__note, .gate.is-leaving .gate__go, .gate.is-leaving .gate__scroll, .gate.is-leaving .gate__hint { opacity: 0; transition: opacity 0.25s; }

.gate__room {
  --gate-machine-h: min(calc(100svh - 11rem), 52rem);
  --gate-machine-w: calc(var(--gate-machine-h) * 512 / 1716);
  height: 100%; max-width: 108rem; margin: 0 auto;
  padding: clamp(4.5rem, 9vh, 6rem) var(--edge) 2.25rem;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: minmax(0, 1fr); column-gap: var(--gap);
}

/* ------------------------------------------------------------ the copy, left */
.gate__copy { grid-column: 1; align-self: center; position: relative; z-index: 2; padding-bottom: clamp(2rem, 8vh, 6rem); }
.gate__title { font-size: clamp(2.75rem, 6.6vw, 6.4rem); line-height: 1; letter-spacing: -0.014em; max-width: 6.6em; white-space: pre-line; }
.gate__acts { margin-top: 1.75rem; display: flex; flex-wrap: wrap; gap: 0.75rem; }
.gate__acts [hidden] { display: none; }
.gate__acts .q-btn { min-height: 44px; }
.gate[data-state="leaving"] .q-btn, .gate[data-state="printing"] .q-btn { pointer-events: none; }

/* the button is not the machine: pressed first, it types a line under itself and points across (gate.js, notHere) */
.gate__acts { position: relative; }
.gate__nudge { position: absolute; left: 0; top: calc(100% + 1.15rem); width: max-content; max-width: 100%; font: 800 clamp(1.35rem, 2.3vw, 2.05rem) / 1.1 var(--serif); letter-spacing: -0.006em; white-space: pre-line; pointer-events: none; opacity: 0; transition: opacity 0.3s var(--settle); }
.gate__nudge.is-on { opacity: 1; }
.gate:not([data-state="arrival"]) .gate__nudge { opacity: 0; transition-duration: 0.15s; }
.gate__nudge-caret { display: inline-block; width: 0.07em; height: 0.86em; margin-left: 0.05em; vertical-align: -0.08em; background: currentColor; animation: gate-caret 1s step-end 4 forwards; }
.gate__nudge.is-typing .gate__nudge-caret { animation: none; }
@keyframes gate-caret { 0% { opacity: 1; } 50%, 100% { opacity: 0; } }
.gate__nudge-arrow { display: inline-block; width: 2.7em; height: auto; margin: -0.45em 0 0 0.25em; vertical-align: -0.05em; clip-path: inset(0 100% 0 0); }
.gate__nudge.is-pointing .gate__nudge-arrow { clip-path: inset(0 0 0 0); transition: clip-path 0.5s var(--settle); animation: gate-point 1.5s ease-in-out 0.5s infinite; }
@keyframes gate-point { 0%, 100% { translate: 0 0; } 50% { translate: 0.4rem -0.2rem; } }
/* and the machine answers: it rocks on its stand (gate.js, wobble) and its own label lights up */
.gate__art { transform-origin: 50% 97%; }
.gate__hint-text { margin: -0.15em -0.3em; padding: 0.15em 0.3em; background: linear-gradient(var(--canton), var(--canton)) 0 50% / 0% 100% no-repeat; transition: background-size 0.5s var(--settle) 0.15s, color 0.2s 0.15s; }
.gate.is-nudged .gate__hint-text { background-size: 100% 100%; color: var(--gate-ink-on-canton); }

/* ------------------------------------------------------------ the machine, right */
.gate__machine { grid-column: 2; align-self: end; justify-self: end; position: relative; width: var(--gate-machine-w); height: var(--gate-machine-h); margin: 0 clamp(0rem, 4vw, 5rem) 2.6rem 0; }
.gate__dispenser { display: block; width: 100%; height: 100%; cursor: pointer; transition: transform 0.2s var(--settle); -webkit-tap-highlight-color: transparent; }
.gate__art { width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none; }
.gate__dispenser:hover { transform: translateY(-3px); }
.gate__dispenser:active, .gate__dispenser.is-pressed { transform: translateY(2px); transition-duration: 0.06s; }
.gate__dispenser:focus-visible { outline-offset: 8px; }
.gate__dispenser[aria-disabled="true"] { cursor: default; }
.gate__dispenser[aria-disabled="true"]:hover { transform: none; }

/* the hand-drawn arrow and its label, pointing at the slot */
.gate__hint { position: absolute; right: calc(100% + 0.35rem); top: 28.6%; display: flex; align-items: flex-end; gap: 0.6rem; margin: 0; pointer-events: none; transition: opacity 0.3s var(--settle); }
.gate__hint-arrow { width: clamp(4.6rem, 6.2vw, 5.9rem); flex: none; transform: rotate(-10deg); transform-origin: 100% 0; }
.gate__hint-text { display: block; font: 600 var(--label) / 1.35 var(--sans); letter-spacing: 0.055em; text-transform: uppercase; white-space: nowrap; transform: translateY(0.95rem); }
.gate:not([data-state="arrival"]) .gate__hint { opacity: 0; }

/* the small line under the base */
.gate__note { position: absolute; right: calc(100% + 2.2rem); bottom: 10%; margin: 0; width: 21rem; text-align: right; line-height: 1.45; text-wrap: balance; transition: opacity 0.2s; }
.gate__note.is-swapping { opacity: 0; }

/* the way in: a button right under the ticket once it is out (the ticket's own anchors, so it follows the ticket) */
.gate__go { position: absolute; z-index: 3; right: calc(100% - clamp(0rem, 3vw, 3.25rem)); width: clamp(19rem, 29vw, 28rem); top: calc(100% - max(24%, 11.5rem) + 1.6rem); margin: 0; display: flex; justify-content: center; }
.gate__go [hidden] { display: none; }
/* and the other way in: scrolling. A drawn arrow at the bottom left says so, and keeps nodding. */
.gate__scroll { position: fixed; left: 7.6rem; bottom: 1.9rem; z-index: 2; display: flex; align-items: center; gap: 0.8rem; margin: 0; color: var(--gray-text); font: 600 var(--label) / 1 var(--sans); letter-spacing: 0.055em; text-transform: uppercase; opacity: 0; transition: opacity 0.45s var(--settle) 0.3s; pointer-events: none; }
.gate__scroll img { width: 3rem; height: auto; flex: none; margin: 0.9rem 0; transform: rotate(92deg); animation: gate-nod 1.8s ease-in-out infinite; }
@keyframes gate-nod { 0%, 100% { translate: 0 -3px; } 50% { translate: 0 5px; } }
.gate[data-state="printed"] .gate__scroll, .gate[data-state="returning"] .gate__scroll { opacity: 1; }
.gate[data-state="printed"] .gate__note, .gate[data-state="returning"] .gate__note { opacity: 0; }

/* ------------------------------------------------------------ the ticket */
.gate-ticket {
  --rest: -3deg;
  position: absolute; z-index: 3;
  /* rests beside the stem; measured from the base so it clears the first-visit notice (Form 15-C) on short screens too */
  right: calc(100% - clamp(0rem, 3vw, 3.25rem)); bottom: max(24%, 11.5rem);
  width: clamp(19rem, 29vw, 28rem);
  color: var(--gate-ink-on-canton);
  transform: rotate(var(--rest));
  filter: drop-shadow(0 1px 0 rgba(16, 17, 15, 0.22));
  will-change: transform;
  container-type: inline-size;
}
.gate-ticket[hidden] { display: none; }
.gate-ticket__paper {
  --notch: clamp(0.62rem, 1vw, 0.85rem);
  --perf: 45%;
  position: relative; background: var(--canton);
  -webkit-mask:
    radial-gradient(circle var(--notch) at 0 var(--perf), #0000 96%, #000 100%),
    radial-gradient(circle var(--notch) at 100% var(--perf), #0000 96%, #000 100%);
  -webkit-mask-composite: source-in;
  mask:
    radial-gradient(circle var(--notch) at 0 var(--perf), #0000 96%, #000 100%),
    radial-gradient(circle var(--notch) at 100% var(--perf), #0000 96%, #000 100%);
  mask-composite: intersect;
}
.gate-ticket__top { padding: 8.5% 9% 7%; text-align: center; }
.gate-ticket__mark { --wordmark-width: 56%; margin: 0 auto; }
.gate-ticket__world { justify-content: center; }
.gate-ticket .q-wordmark { color: inherit; }
.gate-ticket__world { font-size: clamp(0.5rem, 0.72vw, 0.66rem); margin-top: 0.9em; }
.gate-ticket .q-pretitle::before { background: currentColor; }
.gate-ticket__perf { height: 0; margin: 0 7%; border-top: 2px dashed currentColor; }
.gate-ticket__bottom { padding: 6.5% 9% 7%; text-align: center; }
.gate-ticket__ask { font: 800 clamp(0.8rem, 1.1vw, 1rem) / 1.1 var(--serif); letter-spacing: -0.006em; }
.gate-ticket__num { margin-top: 0.4em; font-size: clamp(1.4rem, 2.5vw, 2.3rem); line-height: 0.9; letter-spacing: 0.03em; white-space: nowrap; }
@supports (font-size: 1cqi) { .gate-ticket__num { font-size: 8.4cqi; } }
.gate-ticket__fine { margin-top: 1em; font: 400 clamp(0.56rem, 0.74vw, 0.69rem) / 1.3 var(--sans); }

/* ------------------------------------------------------------ phones: title and body across, the actions beside the machine */
@media (max-width: 880px) {
  .gate__room {
    --gate-machine-h: min(calc(100svh - 24.5rem), 34rem);
    padding: 4.75rem 1.25rem 2rem;
    grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto minmax(0, 1fr); column-gap: 0.75rem;
  }
  .gate__copy { display: contents; }
  .gate__head { grid-column: 1 / -1; grid-row: 1; position: relative; z-index: 2; }
  .gate__title { font-size: clamp(2.6rem, 15vw, 3.75rem); line-height: 1; max-width: none; }
  .gate__acts { grid-column: 1; grid-row: 3; align-self: start; margin-top: 1.25rem; position: relative; z-index: 2; }
  .gate__machine { grid-column: 2; grid-row: 3; margin: 0.25rem 0 2.6rem; }
  .gate__hint { top: 30.2%; right: calc(100% - 0.2rem); gap: 0.4rem; }
  .gate__hint-arrow { width: 3.4rem; }
  .gate__hint-text { white-space: normal; width: 5.2rem; text-align: right; transform: translateY(1.5rem); }
  /* the ticket rests beside the slot, above the first-visit notice (Form 15-C) that sits over the base */
  .gate-ticket { width: 15rem; top: 18%; bottom: auto; right: calc(100% - 2.9rem); }
  .gate__note { right: auto; left: 0; bottom: auto; top: calc(100% + 0.6rem); width: 12rem; text-align: left; }
  .gate__go { right: calc(100% - 2.9rem); width: 15rem; top: calc(18% + var(--ticket-h, 9.5rem) + 1rem); }
  .gate__scroll { left: 5rem; bottom: 1.5rem; }
  .gate__scroll img { width: 2.4rem; }
}
@media (max-width: 880px) and (max-height: 700px) {
  .gate__room { --gate-machine-h: 17rem; }
}

@media (prefers-reduced-motion: reduce) {
  .gate, .gate__hint, .gate__note, .gate__dispenser, .gate__copy, .gate__go, .gate__scroll { transition: none; }
  .gate__scroll img { animation: none; }
  .gate__nudge, .gate__hint-text { transition: none; }
  .gate__nudge-caret { display: none; }
  .gate__nudge-arrow { clip-path: none; }
  .gate__nudge.is-pointing .gate__nudge-arrow { animation: none; }
}
