/* /tickets, the Tickets room: extends styles.css. Inside a ticket is the
   house, its lights down (--tickets-room, base.css): near-black with cream
   ink, as the site's first pages had it, Melodrama for the city and the
   dates (styles.css); the red Live light the only colour. */
:root {
  --ink: #ffffe3;
  --muted: #c0c0ab;
  --live: #d03e3a;   /* vivid on the dark, and white on it still reads (4.7:1) */
  color-scheme: dark;
}

.door {
  display: grid;
  justify-items: center;
  padding: 0 1.5rem;
  text-align: center;
}

/* Rhythm: date belongs to the headline, the button is the act, the note is the
   button's caption, so the gaps are grouped, not even. */
.eyebrow { margin: 0 0 1rem; }
/* Melodrama's full stop is 0.121em wide: pulling back about two thirds of it
   centres the letters without the period hanging outside. */
.door h1 { margin: 0 -0.08em 1rem 0; }
/* With the lights down, the stage comes up. */
@media (prefers-reduced-motion: no-preference) {
  .door { animation: room-arrive 0.6s 0.05s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
}
.when { margin: 0 0 1.75rem; }
.button { margin: 0 0 0.85rem; }
.note { margin: 0; }

.eyebrow,
.when,
.note {
  color: var(--muted);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-size: 0.95rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.note {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
}

/* The "live" tally: a broadcast bar, not a bullet. This is the only colour on
   the site, and only in the open and soldout states, so it reads as status
   rather than decoration. */
.live {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  /* Keep the badge's height stable when the label's line box is trimmed. */
  box-sizing: border-box;
  block-size: 1.6em;
  padding: 0 0.45em;
  background: var(--live);
  color: #fff;
  font-size: 0.75em;
  font-weight: 500;
  letter-spacing: 0.1em;
  line-height: 1;
}

/* Centre the capital-letter box. Older browsers keep flex line-box centring. */
@supports (text-box-trim: trim-both) and (text-box-edge: cap alphabetic) {
  .live-label {
    text-box-trim: trim-both;
    text-box-edge: cap alphabetic;
  }
}

.live-dot {
  width: 0.5em;
  height: 0.5em;
  border-radius: 50%;
  background: currentColor;
  animation: live-pulse 2.4s ease-in-out infinite;
}

/* opacity only, so the blink never triggers layout */
@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
}

/* Sold out: the tag stays (it is a live show, that is what the ticket was
   for) but the colour goes. Not on air; not for sale. */
.live.muted {
  background: color-mix(in oklab, var(--ink) 14%, var(--bg));
  color: var(--ink);
}

.live.muted .live-dot { animation: none; }

.when {
  font-size: 1rem;
  letter-spacing: 0.02em;
  line-height: 1.5;
}

.button {
  display: inline-block;
  padding: 0.9rem 1.9rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: background-color 120ms ease, color 120ms ease;
}

.button:focus-visible {
  background: var(--ink);
  color: var(--bg);
  outline: none;
}

/* Hover only where there's a real pointer: on a phone the last tap leaves
   :hover stuck on whatever ends up under the finger (after the password
   unlocks, a ticket sitting under the field), which reads as selected. */
@media (hover: hover) {
  .button:hover {
    background: var(--ink);
    color: var(--bg);
  }

  .button:hover .arrow { transform: translate(1px, -1px); }
}

.button .arrow {
  margin-left: 0.5em;
  vertical-align: 0.05em;
  transition: transform 120ms ease;
}

/* One date left and it sold out: the button's shape, no longer a link */
.button.gone {
  border-color: color-mix(in oklab, var(--muted) 30%, var(--bg));
  color: color-mix(in oklab, var(--muted) 60%, var(--bg));
  pointer-events: none;
}

/* Fast filling on the single-date page: the room's red, as on the stubs */
.note .hot { color: var(--hot); }

.button:focus-visible .arrow {
  transform: translate(1px, -1px);
}

/* "Unlimited" with the "un" struck out. The "Un" is drawn by CSS so the text
   itself reads "limited seats": for search snippets and screen readers the
   joke would otherwise land as the opposite claim. Dimmed so the strike reads
   as deliberate rather than a typo. */
.note .un::before {
  content: "Un";
  color: color-mix(in oklab, var(--muted) 65%, var(--bg));
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

/* The way to /join from each state (early, sold out, and quietly under the
   button when open). The link itself is .choice from styles.css. */
.door-updates {
  margin: 1rem 0 0;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}

/* open: well below the button and smaller, so it never competes with it */
.door-updates.is-quiet {
  margin-top: 3rem;
  font-size: 0.9rem;
}

/* ---------- Two or more dates: a ticket stub each ---------- */

/* Each stub is its own way in, so they sit where the button would, in the
   button's ink, and invert on hover the same way. The dashed line is the
   perforation: date above, the act below. Wraps past three dates. */
.stubs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin: 0 0 1.25rem;
}

.stub {
  position: relative;
  display: grid;
  justify-items: center;
  width: 6.5rem;
  padding: 1rem 0 0.9rem;
  border: 1px solid var(--ink);
  border-radius: 0.9rem;
  color: var(--ink);
  text-decoration: none;
  transition: background-color 120ms ease, color 120ms ease;
}

.stub::after {
  content: "";
  position: absolute;
  left: 0.6rem;
  right: 0.6rem;
  bottom: 2.3rem;
  border-top: 1px dashed color-mix(in oklab, var(--muted) 45%, var(--bg));
}

a.stub:focus-visible {
  background: var(--ink);
  color: var(--bg);
  outline: none;
}

/* real pointers only, as for .button above */
@media (hover: hover) {
  a.stub:hover {
    background: var(--ink);
    color: var(--bg);
  }

  a.stub:hover .s.hot { color: inherit; }
}

.stub .wd,
.stub .m {
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.85;
}

.stub .n {
  margin: 0.15rem 0 0.1rem;
  font: 400 3.2rem / 1 'Melodrama', Georgia, serif;
}

.stub .m { margin-bottom: 1.1rem; }

.stub .s {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.stub .s .arrow {
  margin-left: 0.4em;
  vertical-align: 0;
}

/* Fast filling: the room's red, used as status; inverted (hover, focus) the
   words carry it alone */
.stub .s.hot { color: var(--hot); }
a.stub:focus-visible .s.hot { color: inherit; }

/* Sold out: stays on the page, struck, and no longer a link */
.stub.gone {
  border-color: color-mix(in oklab, var(--ink) 40%, var(--bg));
  color: color-mix(in oklab, var(--ink) 82%, var(--bg));
}

.stub.gone .n {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

/* ---------- Runs: sold out, and past shows ---------- */

/* Quiet and last: a record, not an offer. One faded line per run, date and
   city only: a run that's sold out while its dates are still to come, then
   past shows. When it makes the door taller than the screen, the page
   scrolls instead of the footer sitting on top of it. */
body:has(.runs) {
  height: auto;
  min-height: 100%;
}

.door:has(.runs) {
  padding-top: 4.5rem;
  padding-bottom: 5.5rem;
}

.runs {
  width: min(18rem, 100%);
  margin: 3.5rem 0 0;
  color: color-mix(in oklab, var(--ink) 75%, var(--bg));
}

.runs + .runs { margin-top: 2.5rem; }

/* still to come, so a little brighter than the past */
.sold-out { color: color-mix(in oklab, var(--ink) 88%, var(--bg)); }

/* ┈┈ PAST SHOWS ┈┈ : the stub's perforation, either side of the label */
.runs h2 {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin: 0 0 1rem;
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
}

.runs h2::before,
.runs h2::after {
  content: "";
  flex: 1;
  border-top: 1px dashed color-mix(in oklab, var(--muted) 40%, var(--bg));
}

.runs ol {
  display: grid;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

/* date at the left edge, city at the right */
.runs li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

/* Past dates are crossed off; city names remain plain. */
.past li > span:first-child {
  text-decoration-line: line-through;
  text-decoration-thickness: 1px;
}

/* ---------- Password gate over the dates ---------- */

/* The dates and the field share one grid cell: the field sits on top, the
   dates show through, softly blurred. The blurred copy has no links in it
   (the Worker leaves them out until the password is right), so this is
   only looks: undoing it in the inspector reveals nothing to click. */
.gate {
  --line: color-mix(in oklab, var(--ink) 22%, var(--bg));
  display: grid;
  justify-items: center;
  align-items: center;
}

.gate > * { grid-area: 1 / 1; }

.gate-behind {
  display: grid;
  justify-items: center;
  filter: blur(7px);
  opacity: 0.7;
  pointer-events: none;
  user-select: none;
  /* breathes, so the dates feel just out of reach rather than dead */
  animation: gate-breathe 3.6s ease-in-out infinite alternate;
}

@keyframes gate-breathe {
  from { opacity: 0.7; }
  to { opacity: 0.5; }
}

.gate-form {
  width: min(18rem, 100%);
  /* a plate under the field, so the blurred faces don't run through it */
  background: var(--bg);
}

.gate-form {
  position: relative;
  /* arrives a beat after the page, rising into place */
  animation: gate-arrive 520ms cubic-bezier(0.2, 0.8, 0.2, 1) 150ms both;
}

@keyframes gate-arrive {
  from { opacity: 0; translate: 0 12px; }
}

/* Checking with the Worker (the hash matched): the arrow leans forward
   and back until the answer comes */
.gate-form button[aria-busy="true"] svg {
  animation: gate-nudge 420ms ease-in-out infinite alternate;
}

@keyframes gate-nudge {
  to { transform: translateX(5px); }
}

/* Unlocking (gate.js): the real dates are already inside the blurred layer
   by now; the field drops away and the blur lifts off them. gate.js then
   removes the wrapper, which changes nothing on screen. */
.gate.is-unlocking .gate-form { animation: gate-leave 280ms ease-in forwards; }

.gate.is-unlocking .gate-behind { animation: gate-clear 420ms ease-out forwards; }

@keyframes gate-leave {
  to { opacity: 0; translate: 0 14px; }
}

@keyframes gate-clear {
  to { filter: blur(0); opacity: 1; }
}

/* Full ink on the page's black, not the muted /join look: it sits on a
   blur, so it has to read at a glance */
.gate-form input {
  border-color: var(--ink);
  background: var(--bg);
  color: var(--ink);
  /* dots, without type="password": a password field makes the browser
     offer to save it after the unlock */
  -webkit-text-security: disc;
}

.gate-form .letter-field button { color: var(--ink); }

/* Same visible prompt as the email; not a password-like input placeholder.
   It passes clicks through and follows native input state, without JS. */
.gate-form .gate-hint {
  position: absolute;
  inset-block: 1px;
  inset-inline-start: calc(1rem + 1px);
  inset-inline-end: var(--arrow);
  display: flex;
  align-items: center;
  font-size: 1rem;
  line-height: normal;
  color: color-mix(in oklab, var(--ink) 45%, var(--bg));
  white-space: nowrap;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}

.gate-form input:not(:placeholder-shown) + .gate-hint {
  visibility: hidden;
}

.gate-form input[aria-invalid="true"] { border-color: var(--error); }

/* REJECTED! grows with every wrong try (gate.js counts them into
   --rejected), with no ceiling, and shakes each time. It hangs under the
   field out of the flow, so growing never moves the page; past the screen
   edges it is simply cut off (the page itself never scrolls sideways). */
.gate-form .letter-error {
  --rejected: 1;
  position: absolute;
  top: 100%;
  left: 50%;
  margin: 0.5rem 0 0;
  translate: -50% 0;
  font-size: calc(0.8rem + (var(--rejected) - 1) * 1.4rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  line-height: 1.1;
  white-space: nowrap;
  transition: font-size 200ms ease;
}

body:has(.gate) { overflow-x: clip; }

/* Each wrong try: REJECTED! lands like a rubber stamp (big, then down to
   its size), then shakes. scale for the stamp, translate and rotate for the
   shake, so neither undoes the centring above. */
.gate-form .letter-error.is-shaking {
  animation:
    gate-stamp 240ms cubic-bezier(0.3, 1.4, 0.5, 1) both,
    gate-shake 360ms ease 220ms;
}

@keyframes gate-stamp {
  from { scale: 2.4; opacity: 0; }
  60% { opacity: 1; }
}

@keyframes gate-shake {
  0%, 100% { translate: -50% 0; rotate: 0deg; }
  20% { translate: calc(-50% - 8px) 0; rotate: -2deg; }
  40% { translate: calc(-50% + 7px) 0; rotate: 2deg; }
  60% { translate: calc(-50% - 4px) 0; rotate: -1deg; }
  80% { translate: calc(-50% + 3px) 0; rotate: 1deg; }
}

@media (prefers-reduced-motion: reduce) {
  .gate-behind,
  .gate-form,
  .gate-form button[aria-busy="true"] svg,
  .gate-form .letter-error.is-shaking { animation: none; }
  .gate.is-unlocking .gate-form,
  .gate.is-unlocking .gate-behind { animation: none; }
}
