/* /tickets and /join: the Tickets and Updates rooms, extending base.css
   (the theme's roles) and room.css (the way home). Each page is its
   project's room colour (--room or --own, from the class on <html>), the
   colour the way in from the home spills, with text that reads on it.
   Inside, the rooms speak in their own voice, as the site's first pages did:
   Melodrama for headings, Satoshi for the rest (fonts in base.css; the home
   keeps Barlow Condensed). Their own looks: tickets.css (the house), /join
   below (the letter). */

:root {
  --bg: var(--room, var(--own, var(--paper)));
  --ink: oklch(from var(--bg) clamp(0.2, (var(--mark-flip) - l) * 1000, 0.98) calc(c * 0.15) h);
  --muted: color-mix(in oklab, var(--ink) 80%, var(--bg));
  --error: oklch(from var(--ink) clamp(0.32, l, 0.88) 0.13 28);   /* a red that reads on the room */
  --hot: var(--error);                                              /* "Fast filling": status, in that red */
}

::selection {
  color: var(--bg);
  background-color: var(--ink);
  text-shadow: none;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  position: relative;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Satoshi', ui-sans-serif, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1 {
  margin: 0;
  font: 400 clamp(2.5rem, 9vw, 6rem) / 1 'Melodrama', Georgia, serif;
  letter-spacing: -0.01em;
}

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

/* Same register as the /tickets eyebrow: small caps above the headline */
.eyebrow {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* A link that reads as words of its sentence, only the underline marking it:
   the ways to /join from the /tickets pages (tickets.css). */
.choice {
  padding: 0;
  margin: 0; /* gap between the two is just the space in the markup, like words */
  border: 0;
  background: none;
  font: inherit;
  letter-spacing: inherit;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  transition: color 160ms ease;
}

/* The underline is a background line, thickening on press; --underline-color
   is registered below so hover can fade it. */
.choice .word {
  padding-bottom: 0.12em;
  background-image: linear-gradient(var(--underline-color), var(--underline-color));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 1px;
  transition: --underline-color 160ms ease;
}

.choice:hover,
.choice:focus-visible {
  color: var(--ink);
  outline: none;
}

.choice:hover .word,
.choice:focus-visible .word {
  --underline-color: var(--ink);
}

/* the press: the line thickens for the frame before the page changes */
.choice:active .word {
  --underline-color: var(--ink);
  background-size: 100% 2px;
}

@property --underline-color {
  syntax: "<color>";
  inherits: true;
  initial-value: transparent;
}

.choice {
  --underline-color: color-mix(in oklab, var(--muted) 55%, var(--bg));
}

/* ---------- Updates signup ----------
   Visitors see "Updates" (the home link, the page title), the page lives at
   /join, and in the code the component is "letter" (.letter, data-letter).

   Every rule is scoped to .letter and the block sets no outer position, so
   it sits wherever its markup goes. */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.letter {
  /* one hairline colour for the input border, strong enough to find the
     field on a coloured room */
  --line: color-mix(in oklab, var(--ink) 60%, var(--bg));

  width: min(26rem, 100%);
  /* inline on the page: clear of the question so it reads as the answer to
     one of them, not part of the question */
  margin-top: 3rem;
  text-align: center;
}

/* Base size for when the block sits under other content, below that page's
   own headline. On /join it is the headline, and .join .letter-title below
   raises it to a headline's size. */
.letter-title {
  margin: 0 0 0.5rem;
  font: 400 clamp(1.5rem, 4.5vw, 1.9rem) / 1.1 'Melodrama', Georgia, serif;
  letter-spacing: -0.01em;
}

/* Field, then error, then fine print, stacked.
   :not([hidden]) so display: grid never overrides the hidden attribute
   when the success state replaces the form. */
.letter-form:not([hidden]) {
  display: grid;
  gap: 0.5rem;
}

/* A square box with the submit arrow inside it, at the right edge */
.letter-field {
  --arrow: 3.25rem; /* the arrow button's width; the input leaves room for it */
  position: relative;
}

.letter-form input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  height: 3.25rem;
  padding: 0 var(--arrow) 0 1rem;
  border: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1rem; /* 16px keeps iOS from zooming in on focus */
}

.letter-form input::placeholder {
  color: color-mix(in oklab, var(--ink) 68%, var(--bg));
}

.letter-form input:focus-visible {
  outline: none;
  border-color: var(--ink);
}

.letter-field button {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--arrow);
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color 160ms ease;
}

.letter-field button svg {
  transition: transform 160ms ease;
}

/* the arrow brightens and leans the way it points */
.letter-field button:hover,
.letter-field button:focus-visible,
.letter-field input:focus ~ button {
  color: var(--ink);
}

.letter-field button:hover svg,
.letter-field button:focus-visible svg {
  transform: translateX(3px);
}

/* same idea as the tickets link: the press registers before anything else */
.letter-field button:active svg {
  transform: translateX(6px);
}

.letter-field button:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: -4px;
}

/* An extra field, off screen (join.html). */
.letter-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Turnstile's slot: takes no room while the check is invisible (the usual
   case) and centres the box when Cloudflare does show one */
.letter-check:empty { display: none; }

.letter-check {
  display: flex;
  justify-content: center;
}

/* Sending: the field dims and the arrow becomes a spinner until the server
   answers. site.js disables both, so nothing can be edited or sent twice. */
.letter-form[aria-busy="true"] input {
  opacity: 0.5;
  cursor: progress;
}

.letter-form[aria-busy="true"] .letter-field button {
  cursor: progress;
}

.letter-form[aria-busy="true"] .letter-field button svg {
  visibility: hidden;
}

/* the spinner: a thin ring with one bright quarter, in the arrow's place */
.letter-form[aria-busy="true"] .letter-field button::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto; /* centred in the button */
  width: 1.1rem;
  height: 1.1rem;
  border: 1.5px solid color-mix(in oklab, var(--ink) 25%, var(--bg));
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: letter-spin 700ms linear infinite;
}

@keyframes letter-spin {
  to { transform: rotate(360deg); }
}

/* reduced motion: a slow pulse instead of a spin, so it still reads as busy */
@media (prefers-reduced-motion: reduce) {
  .letter-form[aria-busy="true"] .letter-field button::after {
    animation: letter-pulse 1.4s ease-in-out infinite;
  }
}

@keyframes letter-pulse {
  50% { opacity: 0.35; }
}

/* empty until site.js writes a message, so it takes no space by default */
.letter-error:empty { display: none; }

.letter-error,
.letter-fine {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
}

.letter-error { color: var(--error); }

.letter-fine {
  letter-spacing: 0.02em;
  text-wrap: balance; /* no single word left alone on a second line */
  color: var(--muted);
}

.letter-done-title {
  margin: 0 0 0.5rem;
  font: 400 1.5rem / 1.1 'Melodrama', Georgia, serif;
}

/* A practical aside under the thanks: quieter than the line above it */
.letter-note {
  margin: 0 auto;
  max-width: 24rem;
  font-size: 0.9rem;
  line-height: 1.5;
  text-wrap: pretty; /* no word left alone on the last line */
  color: var(--muted);
}

/* the folder names are what to look for, so they stand out. Only the 400
   weight of Satoshi is loaded, so the browser draws the bold itself. */
.letter-note strong {
  font-weight: 700;
  color: var(--ink);
}

.letter-addr { color: var(--ink); }

@media (max-width: 420px) {
  .letter { margin-top: 2.5rem; }
}

/* ---------- /join: the letter ----------
   The room is the Updates volume's own blue, the inside of the airmail
   envelope, so the way in spills one colour, with the striped border round
   the edge and a Par avion label. In it, the
   letter: a sheet of pale airmail paper (--airmail-paper, base.css) in
   fountain-pen ink. */

:root.updates {
  --air-red: #b9463b;
  --air-blue: #3e5a86;
}

/* The stripes, red and cream as on the Updates volume, framing the page;
   above nothing that can be touched. */
.join-page::before {
  content: '';
  position: fixed;
  inset: 0;
  border: 8px solid;
  border-image: repeating-linear-gradient(-45deg, var(--air-red) 0 14px, var(--paper) 0 28px) 8;
  pointer-events: none;
}

.par-avion {
  position: absolute;
  inset: var(--gutter) var(--gutter) auto auto;
  margin: 0;
  padding: 0.45em 0.75em;
  background: var(--mail-label);   /* the label on the Updates volume's spine (base.css) */
  color: var(--mail-label-ink);
  font: 500 0.875rem / 1.25 'Barlow Condensed', 'Arial Narrow', sans-serif;
  letter-spacing: 0.1em;
  text-align: center;
  text-transform: uppercase;
}

/* The signup is the page here, so it gets the headline size and no gap
   above it (the .letter margin is for when it sits under other content). */
.join .letter {
  /* the sheet has its own paper and ink, so the field, the errors and the
     check read on it as they would on paper */
  --bg: var(--airmail-paper);
  --ink: #1c2e4f;
  --muted: color-mix(in oklab, var(--ink) 78%, var(--bg));
  --error: oklch(from var(--ink) clamp(0.32, l, 0.88) 0.13 28);
  --hot: var(--error);
  margin-top: 0;
  /* a generous sheet, the heading on one line with paper either side; the
     form below keeps its own narrower width. The heading is sized by the
     sheet (cqi), so it stays one line on narrow phones too. */
  container-type: inline-size;
  width: min(56rem, 100%);
  padding: clamp(3rem, 12vw, 7rem) clamp(1.5rem, 8vw, 7.5rem);
  background: var(--bg);
  color: var(--ink);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.18), 0 18px 40px -18px rgb(0 0 0 / 0.45);
}

/* the page's full width, so the sheet's width (and the heading sized by
   it) comes from the screen, not from what is in it; on a phone the sheet's
   edges line up with the way home and the label */
.join { inline-size: 100%; padding-inline: var(--gutter); }

.join .letter-form {
  width: min(30rem, 100%);
  margin: 0 auto;
}

/* The heading opens the letter. Ordinary wrapping, not balanced: the
   thank-you line breaks at its full stop (Email mil gaya. / Thanks!). */
.join .letter-title {
  font-size: clamp(2rem, 13.5cqi, 4.75rem);
  line-height: 1.05;
  margin-bottom: 1.75rem;
}

.join .letter-fine { font-size: clamp(0.8rem, 0.7rem + 0.3vw, 0.95rem); }

/* as wide as the form it replaces */
.join .letter-note { max-width: 30rem; }

/* Arriving from the home, the envelope's blue and its stripes are there at
   once, and the letter and the way home fade up as one block. Opacity
   only, so nothing shifts. */
.join-page > :not(script) {
  animation: join-in 450ms ease-out both;
}

@keyframes join-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .join-page > :not(script) { animation: none; }
}

/* The way home, as in the rooms (room.css, leave.js): top left, out of the
   centred page's way. */
.room-home { position: absolute; inset: var(--gutter) auto auto var(--gutter); }
