/* Base + static poster (no-JS and prefers-reduced-motion). */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* iOS Safari paints the page canvas behind its translucent status bar and toolbar;
   give it the same image so those strips aren't a flat colour. */
html {
  background: var(--c-ink) url("../assets/background.jpg?v=23") center / cover no-repeat fixed;
}

body {
  margin: 0;
  min-height: 100svh;
  background: transparent;
  color: var(--c-paper);
  font-family: var(--font-primary);
  font-weight: 400;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

p {
  margin: 0;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 1px solid var(--c-paper);
  outline-offset: 6px;
}

/* ------------------------------------------------------------------ */
/* Backdrop: archival paper image, centre vignette, faint grain        */
/* ------------------------------------------------------------------ */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.backdrop__image {
  position: absolute;
  inset: 0;
  /* v12: pixel-glitch texture sits on both left and right edges, calm dark centre;
     centred so every ratio trims both edges evenly */
  background: var(--c-ink) url("../assets/background.jpg?v=23") center / cover no-repeat;
}

.backdrop__vignette {
  position: absolute;
  inset: 0;
  background:
    /* v12: lighter touch - the new paper is already dark (v11: 0.5/0.26, 0.34/0.18, edge 0.42) */
    radial-gradient(ellipse 46% 40% at 50% 50%, rgba(var(--c-shade), 0.3) 0%, rgba(var(--c-shade), 0.16) 60%, transparent 100%),
    radial-gradient(ellipse 62% 52% at 50% 50%, rgba(var(--c-shade), 0.2) 0%, rgba(var(--c-shade), 0.1) 60%, transparent 100%),
    radial-gradient(ellipse at 50% 50%, transparent 60%, rgba(var(--c-shade), 0.28) 100%);
}

/* Portrait: same landscape image in cover mode (no portrait variant); just a
   stronger central vignette for the narrow text column. */
@media (orientation: portrait) {
  /* v15: the landscape image rotated 90° so its textured edges frame the top and bottom. */
  /* iOS Safari paints its status bar / toolbar in a solid colour taken from the page, so the
     image's top and bottom edges fade into that same colour and the bars read as part of it. */
  html {
    background-color: var(--c-edge);
    background-image: url("../assets/background-portrait.jpg?v=23");
  }
  .backdrop__image {
    background-color: var(--c-edge);
    background-image:
      linear-gradient(to bottom, var(--c-edge) 0, rgba(var(--c-edge-rgb), 0.85) 2%, rgba(var(--c-edge-rgb), 0) 9%, rgba(var(--c-edge-rgb), 0) 93%, var(--c-edge) 100%),
      url("../assets/background-portrait.jpg?v=23");
  }
  .backdrop__vignette {
    background:
      /* v12: lighter for the darker paper (v11: top 0.5/0.3, centre 0.72/0.42, edge 0.34) */
      /* v19: starts transparent so the top row matches the browser's status-bar tint (--c-edge) */
      linear-gradient(to bottom, transparent 0%, rgba(var(--c-shade), 0.3) 5%, rgba(var(--c-shade), 0.22) 10%, transparent 19%),
      radial-gradient(ellipse 82% 42% at 50% 50%, rgba(var(--c-shade), 0.46) 0%, rgba(var(--c-shade), 0.26) 62%, transparent 100%),
      radial-gradient(ellipse at 50% 50%, transparent 62%, rgba(var(--c-shade), 0.26) 100%);
  }
}

.backdrop__grain {
  position: absolute;
  inset: -50%;
  opacity: 0.07;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 180px 180px;
  mix-blend-mode: overlay;
}

.stage {
  display: none;
}

/* v11: a soft dark-green halo under the small tracked type so it holds up where it
   crosses the lighter pixel texture (invite header, signup on phones) */
.hero__meta,
.signup__mark,
.signup__label,
.signup__input::placeholder {
  text-shadow: 0 0 2px rgba(var(--c-shade), 0.7), 0 0 12px rgba(var(--c-shade), 0.9);
}

/* ------------------------------------------------------------------ */
/* Typography                                                          */
/* ------------------------------------------------------------------ */

.page {
  position: relative;
  z-index: 1;
  /* static poster: identity, manifesto and signup share one calm screen */
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-4) 0; /* v7: a little tighter (larger tagline, wider coda gap) */
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 var(--gutter);
  text-align: center;
}

.hero__title {
  margin: 0 calc(-1 * var(--track-title)) 0 0; /* optically centre tracked caps */
  font-size: var(--fs-title);
  font-weight: 500;
  line-height: 1;
  letter-spacing: var(--track-title);
  color: var(--c-paper);
  white-space: nowrap;
}

.hero__tagline {
  margin-top: clamp(0.7rem, 1.2vw, 1.3rem);
  margin-right: calc(-1 * var(--track-tagline));
  font-size: var(--fs-tagline);
  font-weight: 300;
  line-height: 1.15;
  letter-spacing: var(--track-tagline);
  color: var(--c-paper);
}

.hero__meta {
  margin-top: clamp(0.8rem, 1.2vw, 1.25rem);
  display: flex;
  flex-direction: column; /* v7: two centred lines on every viewport */
  justify-content: center;
  align-items: center;
  gap: 0.75em;
  font-size: var(--fs-meta);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: var(--track-meta);
  color: var(--c-paper-dim);
}

.hero__meta > span {
  margin-right: calc(-1 * var(--track-meta));
}

.split__word {
  display: inline-block;
  white-space: nowrap;
}

.char {
  display: inline-block;
  line-height: 1;
}

/* ------------------------------------------------------------------ */
/* Manifesto: five lines stacked and centred, one size; the closing    */
/* two (coda) read as one block after a wider gap                       */
/* ------------------------------------------------------------------ */

.manifesto {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--manifesto-gap);
  padding: clamp(2rem, 6vh, 4.5rem) var(--gutter) 0;
  text-align: center;
  font-size: var(--fs-manifesto);
  font-weight: 500; /* v7: heavier glyphs sampled into the pixel grid */
  line-height: 1.2;
  letter-spacing: var(--manifesto-track);
  color: var(--c-paper);
}

.manifesto__line {
  text-wrap: balance; /* long lines wrap into even rows on narrow screens */
}

/* the coda: the final two lines (v9: same size as the first three), after a
   wider gap (== the gap to the signup) */
.manifesto .manifesto__line:not(.manifesto__line--coda) + .manifesto__line--coda {
  /* the flex gap (0.5em of the smaller lines) is already there */
  margin-top: calc(var(--section-gap) - 0.35em);
}

/* visual rows (JS line breaking, experience only); the text itself is in .sr-only */
.manifesto__row {
  display: block;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ */
/* Signup                                                              */
/* ------------------------------------------------------------------ */

.signup {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: var(--signup-gap);
  padding: 0 var(--gutter);
  text-align: center;
}

.signup__mark {
  display: none;
}

.signup__form {
  width: min(30rem, 100%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-3);
}

.signup__label {
  font-size: var(--fs-label);
  font-weight: 500;
  letter-spacing: 0.32em;
  margin-right: -0.32em;
  color: var(--c-paper);
}

.signup__know {
  position: relative;
  display: inline-block;
}

.signup__field {
  position: relative;
  display: flex;
  align-items: center;
  border-bottom: 1px solid transparent; /* the pixel line stands in until focus / text */
  transition: border-color 0.4s var(--ease-out);
}

.signup__field:focus-within {
  border-color: var(--c-paper);
}

.signup__input:not(:placeholder-shown) ~ .signup__pixels,
.signup__field:focus-within .signup__pixels {
  opacity: 0;
}

.signup__field:has(.signup__input:not(:placeholder-shown)):not(:focus-within) {
  border-color: var(--c-paper-faint);
}

/* the underline as a row of small square pixels (::before) + a light scan (::after) */
.signup__pixels {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  pointer-events: none;
  transition: opacity 0.45s var(--ease-out);
}

.signup__pixels::before,
.signup__pixels::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, var(--c-paper) 0 2px, transparent 2px 5px);
}

.signup__pixels::before {
  opacity: 0.42;
}

.signup__pixels::after {
  opacity: 0;
  -webkit-mask: linear-gradient(90deg, transparent, #000 40%, #000 60%, transparent) -40% 0 / 26% 100% no-repeat;
  mask: linear-gradient(90deg, transparent, #000 40%, #000 60%, transparent) -40% 0 / 26% 100% no-repeat;
}

.signup__form.has-error .signup__field {
  border-color: var(--c-brown);
}

.signup__form.has-error .signup__pixels {
  opacity: 0;
}

.signup__input {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 0.2rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--c-paper);
  font: inherit;
  font-size: clamp(1rem, 1.2vw, 1.15rem);
  letter-spacing: 0.03em;
  text-align: left;
  -webkit-appearance: none;
  appearance: none;
}

.signup__input::placeholder {
  color: rgba(var(--c-paper-rgb), 0.58); /* v11: was --c-paper-faint (0.34); AA on the lighter green */
  opacity: 1;
}

.signup__input:focus {
  outline: none;
}

.signup__input:focus-visible {
  outline: none;
}

.signup__submit {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-right: -0.5rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--c-paper);
  font: inherit;
  font-size: 1.35rem;
  cursor: pointer;
  transition: transform 0.4s var(--ease-out), opacity 0.3s;
}

.signup__submit:hover {
  transform: translateX(4px);
}

.signup__submit:focus-visible {
  outline-offset: 0;
}

.signup__form.is-pending .signup__submit {
  opacity: 0.4;
  cursor: progress;
}

.signup__error {
  min-height: 1.2em;
  margin-top: calc(-1 * var(--space-2));
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-align: left;
  color: #b8977a;
}

.signup__status {
  font-size: clamp(1rem, 1.4vw, 1.3rem);
  font-weight: 500;
  letter-spacing: 0.32em;
  margin-right: -0.32em;
  color: var(--c-paper);
}

.signup__status:empty {
  display: none;
}

.signup.is-subscribed .signup__form {
  display: none;
}

/* ------------------------------------------------------------------ */
/* Consent (GDPR): a small panel just below the email field            */
/* ------------------------------------------------------------------ */

.consent {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 100%;
  width: min(28rem, calc(100% - 2 * var(--gutter)));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "agree close"
    "note confirm";
  align-items: center;
  column-gap: 1rem;
  row-gap: 0.55rem;
  padding: 1rem 0.9rem 0.85rem 1.2rem;
  background: rgba(var(--c-shade), 0.86); /* v11: dark green glass */
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(var(--c-paper-rgb), 0.16);
  color: var(--c-paper);
  font-size: clamp(0.8rem, 0.9vw, 0.88rem);
  letter-spacing: 0.03em;
  line-height: 1.45;
  text-align: left;
}

.consent[hidden] {
  display: none;
}

.consent__agree {
  grid-area: agree;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  text-wrap: balance;
  cursor: pointer;
}

/* the real checkbox sits invisibly over the custom square (keyboard + click + AT) */
.consent__check {
  position: absolute;
  left: 0;
  top: 0.2em;
  width: 14px;
  height: 14px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.consent__box {
  flex: none;
  position: relative;
  width: 14px;
  height: 14px;
  margin-top: 0.2em;
  border: 1px solid rgba(var(--c-paper-rgb), 0.7);
  transition: border-color 0.3s;
}

/* checked: a 2x2 block of pixels fills the square */
.consent__box::after {
  content: "";
  position: absolute;
  inset: 2px;
  background:
    linear-gradient(var(--c-paper), var(--c-paper)) 0 0 / 3px 3px no-repeat,
    linear-gradient(var(--c-paper), var(--c-paper)) 100% 0 / 3px 3px no-repeat,
    linear-gradient(var(--c-paper), var(--c-paper)) 0 100% / 3px 3px no-repeat,
    linear-gradient(var(--c-paper), var(--c-paper)) 100% 100% / 3px 3px no-repeat;
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.2s, transform 0.25s var(--ease-out);
}

.consent__check:checked + .consent__box {
  border-color: var(--c-paper);
}

.consent__check:checked + .consent__box::after {
  opacity: 1;
  transform: none;
}

.consent__check:focus-visible + .consent__box {
  outline: 1px solid var(--c-paper);
  outline-offset: 3px;
}

.consent__agree:hover .consent__box {
  border-color: var(--c-paper);
}

.consent__note {
  grid-area: note;
  padding-left: calc(14px + 0.75rem);
  color: var(--c-paper-dim);
  font-size: 0.92em;
  text-wrap: balance;
}

.consent__privacy {
  white-space: nowrap;
  color: var(--c-paper);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: rgba(var(--c-paper-rgb), 0.45);
}

.consent__privacy:hover {
  text-decoration-color: var(--c-paper);
}

.consent__privacy:focus-visible {
  outline-offset: 3px;
}

.consent__actions {
  display: contents;
}

.consent__close,
.consent__confirm {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--c-paper);
  font: inherit;
  cursor: pointer;
}

.consent__close {
  grid-area: close;
  align-self: start;
  margin: -0.55rem -0.35rem 0 0;
  font-size: 1.1rem;
  color: var(--c-paper-dim);
  transition: color 0.3s;
}

.consent__close:hover {
  color: var(--c-paper);
}

.consent__confirm {
  grid-area: confirm;
  margin: -0.35rem -0.35rem -0.3rem 0;
  font-size: 1.3rem;
  transition: transform 0.4s var(--ease-out), opacity 0.3s;
}

.consent__confirm:disabled {
  opacity: 0.22;
  cursor: default;
}

.consent__confirm:not(:disabled):hover {
  transform: translateX(4px);
}

.consent__close:focus-visible,
.consent__confirm:focus-visible {
  outline-offset: -2px;
}

.consent.is-pending .consent__confirm {
  opacity: 0.4;
  cursor: progress;
}

.debug-overlay {
  position: fixed;
  left: 8px;
  bottom: 8px;
  z-index: 99;
  margin: 0;
  padding: 6px 8px;
  font: 11px/1.4 ui-monospace, Menlo, monospace;
  color: #9fb0b8;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
  white-space: pre;
}
