/* ==========================================================================
   MAILING LIST SIGNUP.

   One stylesheet for every placement, because there will be more of them than
   the two there are today and a third copy of these rules is how they start
   drifting apart. The home page gets the full section, the scan page gets the
   --scan variant, and unsubscribe.html borrows the form pieces.
   ========================================================================== */

/* --- The section on the home page ---------------------------------------- */
.signup {
  border-top: var(--rule);
  padding-block: var(--sp-8);
}

.signup__inner {
  display: grid;
  gap: var(--sp-6);
  align-items: start;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .signup__inner {
    grid-template-columns: 1.1fr 1fr;
    gap: var(--sp-8);
  }
}

.signup__title {
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  font-weight: var(--fw-black);
  line-height: var(--lh-tight);
  letter-spacing: var(--tr-display);
  text-transform: uppercase;
  text-wrap: balance;
  margin-block: var(--sp-2) 0;
}

.signup__copy {
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text-muted);
  max-width: var(--measure);
  margin-block: var(--sp-3) 0;
}

/* --- The form itself ------------------------------------------------------ */
.signup__form {
  display: grid;
  gap: var(--sp-3);
}

.signup__row {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: 1fr;
}

/* Side by side only when the input has room to still be usable. Below this
   a cramped field next to a cramped button is worse than two full-width
   rows. */
@media (min-width: 560px) {
  .signup__row { grid-template-columns: 1fr auto; }
}

.signup__input {
  width: 100%;
  /* 44px is the floor for a touch target. This is the one field on the page
     a stranger is asked to fill in, so it gets more than the floor. */
  min-height: 52px;
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  color: var(--text);
  background: var(--bg-field);
  border: var(--rule-strong);
  border-radius: 0;
  /* iOS zooms the whole page when a focused input is under 16px. */
  -webkit-appearance: none;
  appearance: none;
}

.signup__input::placeholder { color: var(--text-faint); }

.signup__input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--text);
}

.signup__submit {
  min-height: 52px;
  white-space: nowrap;
}

.signup__submit[aria-busy="true"] { opacity: 0.6; cursor: progress; }

/* --- The honeypot --------------------------------------------------------
   Pushed off screen rather than display:none, because this has to look like
   an ordinary field to something reading the markup while being invisible and
   unreachable to anybody using the page. aria-hidden and tabindex="-1" in the
   markup keep it away from screen readers and the tab order.
   ------------------------------------------------------------------------- */
.signup__trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* --- The answer ----------------------------------------------------------- */
.signup__status {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  line-height: var(--lh-mono);
  margin: 0;
}

.signup__status[data-kind="ok"]    { color: var(--text); }
.signup__status[data-kind="error"] { color: var(--accent); }

/* Focused by the script so a screen reader lands on the answer. It is not a
   control, so it must not look like one. */
.signup__status:focus { outline: none; }
.signup__status:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* A finished form hides its own controls. Leaving an empty box on screen
   after a successful signup reads as though nothing happened, and people
   type their address in again. */
.signup__form[data-done] .signup__row { display: none; }

.signup__fineprint {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.04em;
  line-height: var(--lh-mono);
  color: var(--text-faint);
  margin: 0;
}

.signup__fineprint a { color: var(--text-muted); text-decoration: underline; }
.signup__fineprint a:hover { color: var(--text); }

/* ==========================================================================
   THE SCAN PAGE VARIANT.

   Sits under four big tiles on a phone, so it is quieter than they are: no
   heading at display size, no two-column anything, and the field and button
   stack full width because that page is only ever read at phone width.
   ========================================================================== */
.signup--scan {
  border-top: var(--rule);
  margin-top: var(--sp-6);
  padding-top: var(--sp-6);
}

.signup--scan .signup__title {
  font-size: var(--fs-h3);
  margin-bottom: var(--sp-2);
}

.signup--scan .signup__copy {
  font-size: var(--fs-small);
  margin-top: var(--sp-2);
  margin-bottom: var(--sp-4);
}

/* Never side by side here, whatever the viewport does. A tablet rendering
   this page still gets the phone layout, because that is what it is. */
.signup--scan .signup__row { grid-template-columns: 1fr; }

.signup--scan .signup__input,
.signup--scan .signup__submit { min-height: 56px; }

/* ==========================================================================
   UNSUBSCRIBE.

   Its own page, and it has one job: say what happened in as few words as
   possible. Nobody arriving here wants to be sold anything, asked why, or
   offered a survey.
   ========================================================================== */
.leaving {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: var(--sp-6) var(--gutter);
  /* The address bar on a phone covers the bottom of 100vh. */
  padding-bottom: calc(var(--sp-6) + env(safe-area-inset-bottom, 0px));
}

.leaving__inner {
  width: 100%;
  max-width: 34rem;
  text-align: center;
}

.leaving__logo {
  width: 160px;
  height: auto;
  margin-inline: auto;
  /* The artwork is black letterforms drawn for a white page, so it is
     inverted to sit on this one. Identical to .logobar__img in
     components.css and .scan__logo in scan.css: if the artwork is ever
     redrawn light, all three of these come off together. */
  filter: invert(1);
}

.leaving__title {
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  font-weight: var(--fw-black);
  line-height: var(--lh-tight);
  letter-spacing: var(--tr-display);
  text-transform: uppercase;
  text-wrap: balance;
  margin-block: var(--sp-5) 0;
}

.leaving__copy {
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text-muted);
  margin-block: var(--sp-4) 0;
}

.leaving__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  justify-content: center;
  margin-top: var(--sp-6);
}

.leaving__actions .btn { min-height: 48px; }

/* ==========================================================================
   A SELF-CONTAINED BUTTON.

   The scan page loads tokens.css, base.css, scan.css and this file, and
   nothing else. Pulling in components.css for .btn would nearly double that
   page's CSS, most of it nav, cards and drawer rules it has no use for, and
   loading instantly from a QR code is the entire reason that page exists.

   So this is a complete button that needs no other stylesheet. It matches
   .btn--primary at rest deliberately; the difference is that it inverts with
   a plain colour change rather than the wiping pseudo-element, which is not
   worth a second stylesheet.
   ========================================================================== */
.signup__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: 56px;
  padding: var(--sp-3) var(--sp-5);
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  background: var(--c-porcelain);
  color: var(--c-black);
  border: var(--rule-width) solid var(--c-porcelain);
  border-radius: var(--radius);
  transition: background var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease);
}

.signup__btn:hover,
.signup__btn:focus-visible {
  background: var(--c-black);
  color: var(--c-porcelain);
}

.signup__btn:active { transform: translateY(1px); }

.signup__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.signup__btn[aria-busy="true"] { opacity: 0.6; cursor: progress; }
