/* =========================================================================
   Monetize.me onboarding funnel — base stylesheet (B1)

   ZERO hardcoded branding. Everything visual descends from exactly three
   values that brand.js writes onto <html> at runtime from config/brand.json:

     --brand-base    <- primary_hex   (the ground the whole UI sits on)
     --brand-accent  <- accent_hex    (the one loud colour, used sparingly)
     --brand-font    <- font          (loaded from Google Fonts at runtime)

   plus two derived attributes, also set by brand.js:

     [data-polarity="dark"|"light"]   derived from the luminance of primary_hex
     [data-vibe="premium|friendly|hype"]  from welcome_vibe

   Every surface, line and text colour below is mixed from those two colours,
   so swapping config/brand.json restyles the entire site, including flipping
   it from a dark ground to a light one, with no edit anywhere else.

   The only fixed colours in this file are the semantic danger/success hues
   (an error must read as an error whatever the brand is), and even those are
   mixed toward --brand-base so they sit inside the palette.
   ========================================================================= */

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

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

body,
h1, h2, h3, p, figure, fieldset, legend, ul, ol {
  margin: 0;
  padding: 0;
}

fieldset { border: 0; min-inline-size: 0; }
ul, ol { list-style: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- scale ---------- */
:root {
  /* 4pt spacing scale, semantic names */
  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;

  /* type scale, ~1.28 ratio, fluid only on the display sizes */
  --text-micro: 0.6875rem;
  --text-xs: 0.8125rem;
  --text-sm: 0.9375rem;
  --text-base: 1rem;
  --text-lg: 1.1875rem;
  --text-display: clamp(1.9rem, 1.35rem + 2.4vw, 3.1rem);
  --text-numeral: clamp(2.6rem, 1.8rem + 3.6vw, 4.25rem);

  --radius-sm: 6px;
  --radius-md: 11px;
  --radius-lg: 16px;

  --measure: 34rem;
  --gutter: clamp(1.25rem, 5vw, 2.5rem);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  --font-body: var(--brand-font, ui-sans-serif), system-ui, -apple-system,
    "Segoe UI", sans-serif;
}

/* ---------- palette, derived ---------- */
:root[data-polarity="dark"] {
  --surface-0: var(--brand-base);
  --surface-1: color-mix(in oklab, var(--brand-base), white 5%);
  --surface-2: color-mix(in oklab, var(--brand-base), white 9%);
  --surface-sunken: color-mix(in oklab, var(--brand-base), black 40%);

  --line: color-mix(in oklab, var(--brand-base), white 14%);
  --line-strong: color-mix(in oklab, var(--brand-base), white 26%);

  /* Mix percentages are the measured WCAG AA floor against the placeholder
     base, plus headroom: 56% clears 4.5:1 on #0F0F14 at 5.5:1. Re-measure in
     W1 if the client's primary_hex lands mid-luminance. */
  --text-1: color-mix(in oklab, white 93%, var(--brand-base));
  --text-2: color-mix(in oklab, white 74%, var(--brand-base));
  --text-3: color-mix(in oklab, white 56%, var(--brand-base));

  --accent-quiet: color-mix(in oklab, var(--brand-accent) 13%, var(--brand-base));
  --accent-line: color-mix(in oklab, var(--brand-accent) 42%, var(--brand-base));
  --accent-text: color-mix(in oklab, var(--brand-accent) 82%, white);

  --wash: color-mix(in oklab, var(--brand-accent) 16%, var(--brand-base));

  --danger: oklch(0.72 0.16 25);
  --danger-quiet: color-mix(in oklab, oklch(0.72 0.16 25) 14%, var(--brand-base));
  --positive: oklch(0.78 0.14 155);
}

:root[data-polarity="light"] {
  --surface-0: var(--brand-base);
  --surface-1: color-mix(in oklab, var(--brand-base), black 3.5%);
  --surface-2: color-mix(in oklab, var(--brand-base), black 6.5%);
  --surface-sunken: color-mix(in oklab, var(--brand-base), black 10%);

  --line: color-mix(in oklab, var(--brand-base), black 13%);
  --line-strong: color-mix(in oklab, var(--brand-base), black 26%);

  --text-1: color-mix(in oklab, black 88%, var(--brand-base));
  --text-2: color-mix(in oklab, black 68%, var(--brand-base));
  --text-3: color-mix(in oklab, black 52%, var(--brand-base));

  --accent-quiet: color-mix(in oklab, var(--brand-accent) 10%, var(--brand-base));
  --accent-line: color-mix(in oklab, var(--brand-accent) 55%, var(--brand-base));
  --accent-text: color-mix(in oklab, var(--brand-accent) 88%, black);

  --wash: color-mix(in oklab, var(--brand-accent) 11%, var(--brand-base));

  --danger: oklch(0.53 0.19 25);
  --danger-quiet: color-mix(in oklab, oklch(0.53 0.19 25) 9%, var(--brand-base));
  --positive: oklch(0.55 0.14 155);
}

/* ---------- shell ---------- */
body {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--surface-0);
  color: var(--text-1);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* One soft wash of the accent behind the top of the page. The only
   decorative gradient in the build, and it carries the brand colour. */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: 62vh;
  background: radial-gradient(
    118% 74% at 50% -14%,
    var(--wash) 0%,
    transparent 62%
  );
  pointer-events: none;
  z-index: 0;
}

/* Hold the first paint until brand.json has landed, so nothing ever flashes
   in an unbranded state. Removed by brand.js on resolve. */
html.brand-pending body { opacity: 0; }
body {
  opacity: 1;
  transition: opacity 220ms var(--ease-out);
}

.page {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  max-width: calc(var(--measure) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
  display: flex;
  flex-direction: column;
}

/* Keeps the last block off the footer rule on the taller steps. */
main { padding-bottom: var(--space-3xl); }

/* ---------- masthead + progress rail ---------- */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding-block: var(--space-lg) var(--space-md);
}

.mark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  min-height: 28px;
  text-decoration: none;
  color: inherit;
}
.mark img { height: 26px; width: auto; object-fit: contain; }
.mark__word {
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--text-1);
}

.counter {
  font-size: var(--text-micro);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
  white-space: nowrap;
}
.counter b {
  font-weight: 500;
  color: var(--accent-text);
}

/* Full bleed hairline that fills as the creator advances. The signature
   element: no stepper dots, no pills, just a line that moves. */
.rail {
  position: relative;
  height: 1px;
  background: var(--line);
  margin-inline: calc(var(--gutter) * -1);
}
.rail__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--brand-accent);
  transition: width 900ms var(--ease-out);
}
.rail__fill::after {
  content: "";
  position: absolute;
  right: 0;
  top: -1px;
  height: 3px;
  width: 3px;
  border-radius: 50%;
  background: var(--brand-accent);
}

/* ---------- headings ---------- */
.eyebrow {
  font-size: var(--text-micro);
  font-weight: 500;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--text-3);
}

.display {
  font-size: var(--text-display);
  font-weight: 300;
  line-height: 1.06;
  letter-spacing: -0.028em;
  text-wrap: balance;
  margin-top: var(--space-sm);
}
.display em {
  font-style: normal;
  color: var(--accent-text);
}

.lede {
  margin-top: var(--space-md);
  max-width: 32ch;
  font-size: var(--text-lg);
  line-height: 1.5;
  color: var(--text-2);
  text-wrap: pretty;
}

.intro { padding-block: var(--space-2xl) var(--space-xl); }

/* ---------- form ---------- */
.section + .section { margin-top: var(--space-2xl); }

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--line);
}
.section__label {
  font-size: var(--text-micro);
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-2);
}
.section__index {
  font-size: var(--text-micro);
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
}
.section__hint {
  margin-top: var(--space-sm);
  font-size: var(--text-xs);
  color: var(--text-3);
  max-width: 46ch;
}

.fields {
  display: grid;
  gap: var(--space-lg);
  margin-top: var(--space-lg);
}

.field { display: grid; gap: var(--space-2xs); }

.field__label {
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-2);
}
.field__label .opt {
  color: var(--text-3);
  font-weight: 400;
}

.field__help {
  font-size: var(--text-xs);
  color: var(--text-3);
  line-height: 1.45;
}

.control {
  position: relative;
  display: flex;
  align-items: stretch;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  transition: border-color 160ms var(--ease-out),
    box-shadow 160ms var(--ease-out), background-color 160ms var(--ease-out);
}
.control:hover { border-color: var(--line-strong); }
.control:focus-within {
  border-color: var(--accent-line);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px var(--accent-quiet);
}

.control__prefix {
  display: grid;
  place-items: center;
  padding-left: var(--space-md);
  font-size: var(--text-base);
  color: var(--text-3);
  user-select: none;
}

/* 16px min font-size stops iOS from zooming the viewport on focus.
   52px min height keeps every target thumb-sized. */
.control input,
.control select,
.control textarea {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  padding: var(--space-sm) var(--space-md);
  font-size: 1rem;
  background: transparent;
  border: 0;
  border-radius: inherit;
  color: var(--text-1);
  appearance: none;
}
.control textarea {
  min-height: 96px;
  padding-top: var(--space-md);
  resize: vertical;
  line-height: 1.55;
}
.control:has(.control__prefix) input { padding-left: 2px; }
.control input:focus,
.control select:focus,
.control textarea:focus { outline: none; }

.control input::placeholder,
.control textarea::placeholder { color: var(--text-3); }

/* date inputs render a UA icon that ignores colour in dark polarity */
:root[data-polarity="dark"] .control input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  opacity: 0.45;
}
.control input[type="number"]::-webkit-outer-spin-button,
.control input[type="number"]::-webkit-inner-spin-button { appearance: none; margin: 0; }

.control--select::after {
  content: "";
  position: absolute;
  right: var(--space-md);
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -5px;
  border-right: 1px solid var(--text-3);
  border-bottom: 1px solid var(--text-3);
  transform: rotate(45deg);
  pointer-events: none;
}
.control--select select { padding-right: var(--space-2xl); }
.control select option {
  background: var(--surface-2);
  color: var(--text-1);
}

.field[data-invalid="true"] .control {
  border-color: var(--danger);
  background: var(--danger-quiet);
}
.field[data-invalid="true"] .control:focus-within {
  box-shadow: 0 0 0 3px var(--danger-quiet);
}
.field__error {
  font-size: var(--text-xs);
  color: var(--danger);
}

.counterline {
  justify-self: end;
  font-size: var(--text-micro);
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  min-height: 54px;
  padding-inline: var(--space-xl);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.005em;
  text-decoration: none;
  transition: transform 140ms var(--ease-out), background-color 160ms var(--ease-out),
    border-color 160ms var(--ease-out), opacity 160ms var(--ease-out);
}
.btn:active { transform: translateY(1px) scale(0.995); }

.btn--primary {
  width: 100%;
  background: var(--brand-accent);
  color: var(--on-accent);
}
.btn--primary:hover { background: color-mix(in oklab, var(--brand-accent), white 10%); }
.btn--primary[disabled],
.btn--primary[aria-disabled="true"] {
  background: var(--surface-2);
  color: var(--text-3);
  cursor: not-allowed;
  transform: none;
}

.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-2);
}
.btn--ghost:hover { border-color: var(--line-strong); color: var(--text-1); }

.btn--quiet {
  min-height: 0;
  padding: 0;
  background: none;
  border: 0;
  color: var(--text-3);
  font-size: var(--text-xs);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn--quiet:hover { color: var(--text-1); }

.submit {
  margin-top: var(--space-2xl);
  display: grid;
  gap: var(--space-md);
  justify-items: center;
}
.submit .note {
  font-size: var(--text-xs);
  color: var(--text-3);
  text-align: center;
  max-width: 40ch;
  text-wrap: pretty;
}

.formstatus {
  margin-top: var(--space-md);
  font-size: var(--text-xs);
  color: var(--danger);
  text-align: center;
  min-height: 1.2em;
}

/* ---------- step 2 + 3 blocks ---------- */
.panel {
  margin-top: var(--space-xl);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  padding: var(--space-lg);
}
.panel__label {
  font-size: var(--text-micro);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-3);
}
.panel__body {
  margin-top: var(--space-sm);
  color: var(--text-2);
  font-size: var(--text-sm);
  text-wrap: pretty;
}

/* the PandaDoc frame lands here in B3 */
.docslot {
  margin-top: var(--space-xl);
  display: grid;
  place-items: center;
  gap: var(--space-md);
  min-height: 300px;
  padding: var(--space-xl) var(--space-lg);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-sunken);
  text-align: center;
}
.docslot__title {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-1);
}
.docslot__note {
  font-size: var(--text-xs);
  color: var(--text-3);
  max-width: 34ch;
}

/* Rows, not cards. The fanout checklist on step 3. */
.tasks { margin-top: var(--space-xl); border-top: 1px solid var(--line); }
.task {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: var(--space-md);
  padding-block: var(--space-md);
  border-bottom: 1px solid var(--line);
}
.task__name { font-size: var(--text-sm); color: var(--text-2); }
.task__state {
  font-size: var(--text-micro);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  justify-self: center;
  position: relative;
}
.task[data-state="running"] .dot {
  border-color: var(--accent-line);
  animation: breathe 1.9s var(--ease-in-out) infinite;
}
.task[data-state="running"] .task__state { color: var(--accent-text); }
.task[data-state="done"] .dot {
  border-color: var(--positive);
  background: var(--positive);
}
.task[data-state="done"] .dot::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 3px;
  height: 6px;
  border-right: 1.5px solid var(--surface-0);
  border-bottom: 1.5px solid var(--surface-0);
  transform: rotate(42deg);
}
.task[data-state="done"] .task__name { color: var(--text-1); }

@keyframes breathe {
  0%, 100% { opacity: 0.35; transform: scale(0.86); }
  50% { opacity: 1; transform: scale(1); }
}

/* The moment a step actually lands.

   Without this the row simply IS done on the next poll, which reads as a static
   list rather than something happening. The pop is what tells a creator watching
   the page that the machine just did a thing for them. It fires only on the poll
   where a row CHANGES to done, never on repaint, so returning to the page later
   is calm rather than a firework display. */
.task[data-just-done="true"] .dot {
  animation: land 420ms var(--ease-out, cubic-bezier(0.2, 0.8, 0.2, 1)) both;
}
.task[data-just-done="true"] .task__state {
  animation: fade-up 420ms var(--ease-out, cubic-bezier(0.2, 0.8, 0.2, 1)) both;
}

@keyframes land {
  0% { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.28); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes fade-up {
  0% { transform: translateY(4px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* Progress across the whole fanout, so the wait has a shape. */
.progress {
  margin-top: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}
.progress__track {
  flex: 1;
  height: 3px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.progress__fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent, var(--brand-accent));
  transition: width 600ms var(--ease-out, cubic-bezier(0.2, 0.8, 0.2, 1));
}
.progress__label {
  font-size: var(--text-micro);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Someone who set "reduce motion" gets the state, never the choreography. */
@media (prefers-reduced-motion: reduce) {
  .task[data-just-done="true"] .dot,
  .task[data-just-done="true"] .task__state { animation: none; }
  .task[data-state="running"] .dot { animation: none; }
  .progress__fill { transition: none; }
}

.handoff {
  margin-top: var(--space-2xl);
  display: grid;
  gap: var(--space-md);
}

.nextlist { margin-top: var(--space-xl); display: grid; gap: var(--space-md); }
.nextlist li {
  display: grid;
  grid-template-columns: 1.6rem 1fr;
  gap: var(--space-sm);
  font-size: var(--text-sm);
  color: var(--text-2);
  align-items: start;
}
.nextlist .n {
  font-size: var(--text-micro);
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
  padding-top: 0.28em;
  letter-spacing: 0.08em;
}

/* ---------- recovery + footer ---------- */
.recover {
  margin-top: var(--space-2xl);
  padding: var(--space-lg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  display: grid;
  gap: var(--space-md);
  justify-items: start;
}

.foot {
  margin-top: auto;
  padding-block: var(--space-xl);
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs) var(--space-md);
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-micro);
  color: var(--text-3);
}
.foot .ref { font-variant-numeric: tabular-nums; letter-spacing: 0.06em; }

/* ---------- utility ---------- */
[hidden] { display: none !important; }

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

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent-line);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

a { color: var(--accent-text); text-underline-offset: 3px; }

/* ---------- entrance ---------- */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  animation: rise 620ms var(--ease-out) forwards;
  animation-delay: calc(var(--i, 0) * 70ms + 60ms);
}
@keyframes rise {
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- wider viewports ----------
   Mobile is the real target. Above 640px the measure just breathes. */
@media (min-width: 40rem) {
  :root { --measure: 36rem; }
  .intro { padding-block: var(--space-3xl) var(--space-2xl); }
  .btn--primary { width: auto; min-width: 15rem; }
  .fields--pair {
    grid-template-columns: 1fr 1fr;
  }
}
