/*
 * The signup experience, in Kard Kulture's own visual identity.
 *
 * ── Why this file was rewritten ────────────────────────────────────────────
 * This service renders the only pages a campaign visitor sees between the
 * marketing site and their inbox: /early-access, the confirm page their email
 * link opens, and the confirmed state. Those pages are served from the same
 * origin as the marketing site, under the same domain, in the middle of one
 * journey — so they have to be the same product, not a form that happens to
 * live at the same address.
 *
 * The previous stylesheet was a different product: #0b0b12 ground, three
 * animated purple/teal aurora blobs behind a blurred glass card, and a
 * gradient clipped through the headline. Kard Kulture's identity is the
 * opposite of all four — warm ivory paper, one serif, flat surfaces, and
 * colour reserved for Kards and deck covers where it carries meaning.
 *
 * ── Where these values come from ──────────────────────────────────────────
 * Every token below is copied from `site/src/styles/global.css`, which is
 * itself pinned by `site/tests/tokens.test.mjs` to the app's own
 * `src/design/tokens.ts` and `theme.ts`. The dark grounds are Minimal Luxe's
 * night, because that is what the app actually renders. Sage is the only
 * accent, and only for a focus ring and a link underline.
 *
 * Kept deliberately: `.wrap`, `.skip`, `#main`, the form's ARIA hooks, and
 * the mobile/focus/motion/forced-colours rules that `tests/test_v11.py`
 * asserts on. The identity changed; the accessibility contract did not.
 */

:root {
  color-scheme: light dark;

  --ground: #FBF8F5;        /* palette.ivory[100]  — lightTheme.background    */
  --surface: #FFFFFF;       /* lightTheme.surface                            */
  --ink: #171519;           /* palette.ink[900]    — lightTheme.textPrimary  */
  --ink-secondary: #6B6670; /* palette.ink[500]    — lightTheme.textSecondary*/
  --ink-tertiary: #6B6670;  /* collapsed onto ink[500]; see global.css        */
  --rule: #E6E2E9;          /* palette.ink[100]    — lightTheme.border       */
  --rule-strong: #CEC9D2;   /* palette.ink[200]    — lightTheme.borderStrong */
  --accent: #3F7150;        /* palette.sage.ink                              */
  --accent-soft: #EDF4EE;   /* palette.sage.surface                          */

  /* Status colours. Sage for success, because the product already owns it.
     The error tone is the app's own `palette.clay.ink`, not a stock red. */
  --bad: #8C3A2B;
  --bad-soft: #FBEEEB;

  --measure: 34rem;
  --measure-wide: 46rem;
  --gutter: 1.5rem;

  --serif: 'DM Serif Display', 'Iowan Old Style', 'Palatino Linotype',
           Palatino, Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
          Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #131417;        /* minimalLuxe night screenGradient[2]          */
    --surface: #25262A;       /* minimalLuxe night cardGradient[0]            */
    --ink: #F4F1EC;           /* darkTheme.textPrimary                        */
    --ink-secondary: #A7B0C6; /* darkTheme.textSecondary                      */
    --ink-tertiary: #9A958C;  /* minimalLuxe night mutedColor                 */
    --rule: rgba(216, 199, 172, 0.14);
    --rule-strong: rgba(216, 199, 172, 0.16);
    --accent: #A6CCB0;        /* palette.sage.mid — sage.ink is 1.9:1 at night */
    --accent-soft: rgba(166, 204, 176, 0.12);
    --bad: #E8A79A;
    --bad-soft: rgba(232, 167, 154, 0.12);
  }
}

/*
 * The one face, served from the marketing site's own static root.
 *
 * Same origin, so this is a plain same-document request with no CORS and no
 * second connection: Caddy serves /fonts/ from the site's build output and
 * only the waitlist paths reach this service. `font-display: swap` so the
 * first paint of a signup form never waits on 70 KB.
 */
@font-face {
  font-family: 'DM Serif Display';
  src: url('/fonts/DMSerifDisplay-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  letter-spacing: -0.003em;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ── Frame ───────────────────────────────────────────────────────────────── */

.wrap {
  width: 100%;
  max-width: var(--measure-wide);
  margin: 0 auto;
  padding: 0 var(--gutter) 3.5rem;
  flex: 1;
}

.wrap.narrow { max-width: 32rem; }

.brand {
  display: flex;
  align-items: center;
  padding: 1.35rem 0 0;
  margin: 0 0 3.5rem;
  font-family: var(--serif);
  font-size: 1.12rem;
  letter-spacing: -0.01em;
}

.brandlink { color: inherit; text-decoration: none; }
.brandlink:hover { text-decoration: underline; text-underline-offset: 3px; }

.hero { padding: 0 0 1rem; }

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.15;
  text-wrap: balance;
  margin: 0;
}

h1 { font-size: clamp(2.1rem, 6.5vw, 3.1rem); }
.h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(1.5rem, 4.5vw, 1.95rem); letter-spacing: -0.015em; line-height: 1.2; margin: 0 0 0.75rem; }

.eyebrow {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-tertiary);
  margin: 0 0 0.85rem;
}

.lede {
  font-size: 1.1rem;
  color: var(--ink-secondary);
  max-width: var(--measure);
  margin: 1rem 0 2rem;
}

.fine {
  color: var(--ink-tertiary);
  font-size: 0.875rem;
  line-height: 1.55;
  max-width: var(--measure);
  margin: 1.5rem 0 0;
}

a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

/* ── The form ────────────────────────────────────────────────────────────── */

/*
 * No card, no border, no shadow.
 *
 * A boxed form on a page whose only purpose is that form is a box drawn
 * around the whole page. The site's own pages separate with a rule and
 * space, so this one does too.
 */
.card {
  max-width: var(--measure);
  margin: 0;
  padding: 1.75rem 0 0;
  border-top: 1px solid var(--rule);
}

.card.center {
  max-width: var(--measure);
  margin: 0;
  padding: 0;
  border-top: 0;
  text-align: left;
}

label { display: block; font-size: 0.875rem; font-weight: 600; color: var(--ink); margin-bottom: 0.5rem; }

.row { display: flex; gap: 0.75rem; flex-wrap: wrap; }

input[type=email] {
  flex: 1 1 15rem;
  min-width: 0;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;      /* ≥16px: iOS zooms the viewport below that */
  line-height: 1.4;
  outline: none;
}

input[type=email]::placeholder { color: var(--ink-tertiary); opacity: 1; }
input[type=email]:hover { border-color: var(--ink-tertiary); }

/*
 * The button is the site's `.btn-primary`: ink pill, ground-coloured label.
 * `.cta` is kept as the class name because the templates and the mobile
 * full-width assertion in `tests/test_v11.py` both reference it.
 */
.cta {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.72rem 1.35rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--ink);
  color: var(--ground);
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.25;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.cta:hover { opacity: 0.88; }
.cta:disabled { opacity: 0.55; cursor: progress; }

.cta.alt {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--rule-strong);
}

/* Touch target floor, and the size iOS needs to not zoom on focus. */
input[type=email], .cta { min-height:52px; }

.consent {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  margin: 1.35rem 0 0;
  padding: 0.25rem 0;
  min-height: 44px;
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink-secondary);
}

.consent input {
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 0.15rem;
  accent-color: var(--accent);
}

.consent a { color: var(--ink); }

/*
 * The status line.
 *
 * `role="status"` with a reserved minimum height, so an answer arriving does
 * not reflow the button out from under a thumb. A left rule rather than a
 * coloured panel: the site marks an aside the same way.
 */
.msg {
  min-height: 1.5em;
  margin: 1.25rem 0 0;
  font-size: 0.975rem;
  line-height: 1.55;
  max-width: var(--measure);
}

.msg.ok, .msg.err {
  padding: 0.7rem 0 0.7rem 0.9rem;
  border-left: 2px solid var(--rule-strong);
}

.msg.ok { border-left-color: var(--accent); color: var(--ink); }
.msg.err { border-left-color: var(--bad); color: var(--ink); }

/* The honeypot. Off-screen, never announced, never focusable. */
.hp { position: absolute; left: -9999px; height: 0; overflow: hidden; }

input[type=email][aria-invalid=true] { border-color: var(--bad); }

/* ── Confirmed / expired / removed states ────────────────────────────────── */

/*
 * One mark, drawn in CSS rather than shipped as an icon: a sage rule above
 * the heading. Enough to say "this worked" without a stock checkmark badge.
 */
.state { padding-top: 2.5rem; }
.state .eyebrow { color: var(--accent); }
.state .lede { margin-bottom: 1.5rem; }

.next { margin: 2rem 0 0; display: flex; flex-wrap: wrap; gap: 0.75rem; }

/* ── Footer ──────────────────────────────────────────────────────────────── */

.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  max-width: var(--measure-wide);
  margin: 0 auto;
  width: 100%;
  padding: 1.5rem var(--gutter) calc(1.5rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
  color: var(--ink-tertiary);
  font-size: 0.85rem;
}

.foot nav { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.foot a { color: var(--ink-tertiary); }

/* ── Skip link, visually-hidden, focus ───────────────────────────────────── */

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10;
  padding: 0.7rem 1.1rem;
  background: var(--ink);
  color: var(--ground);
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
}

.skip:focus { left: var(--gutter); top: var(--gutter); }

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ── Long-form copy (the draft privacy page this service still renders) ──── */

.prose { max-width: var(--measure); }
.prose h1 { margin-bottom: 1.5rem; }
.prose p { color: var(--ink-secondary); }
.prose p strong { color: var(--ink); font-weight: 600; }

/* ── Private admin and launch dashboard ──────────────────────────────────── */

/*
 * Never public: denied at the proxy on both hosts and reachable only through
 * an authorised tunnel. Styled to the same tokens anyway, because a person
 * reading it at 3am should not have to switch visual languages.
 */
.admin { max-width: 60rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 1rem;
}

.stat b { display: block; font-family: var(--serif); font-size: 2rem; font-weight: 400; line-height: 1.1; }
.stat span { color: var(--ink-secondary); font-size: 0.85rem; }

table { width: 100%; border-collapse: collapse; margin: 0.75rem 0 1.75rem; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--rule); }
th { color: var(--ink-secondary); font-weight: 600; }

/* ── Narrow ──────────────────────────────────────────────────────────────── */

/*
 * Exactly 560px and the spelling `max-width:560px`, because
 * `tests/test_v11.py::test_css_mobile_cta_full_width_and_focus_and_motion`
 * splits this file on that literal to prove the primary action is full-width
 * on a phone. The assertion is worth keeping: a 160px button beside a 160px
 * field is the single most common way a mobile signup form fails.
 */
@media (max-width:560px) {
  .row { flex-direction: column; }
  .row .cta { width:100%; }
  input[type=email] { flex-basis: auto; width: 100%; }
  .wrap { padding-left: 1.25rem; padding-right: 1.25rem; }
  .brand { margin-bottom: 2.5rem; }
  .foot { padding-left: 1.25rem; padding-right: 1.25rem; }
  .eyebrow { letter-spacing: 0.08em; }
}

/* 320px: the narrowest phone still in the field. Nothing may overflow it. */
@media (max-width: 23.5rem) {
  h1 { font-size: 1.95rem; }
  .wrap { padding-left: 1rem; padding-right: 1rem; }
  .foot { padding-left: 1rem; padding-right: 1rem; }
  .foot { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

@media (forced-colors: active) {
  .cta { border: 2px solid ButtonText; }
  .msg.ok, .msg.err { border-left: 3px solid CanvasText; }
  input[type=email] { border: 1px solid CanvasText; }
}
