/*
 * Gausser web funnel — signup, onboarding, account management.
 *
 * Every value here resolves to a custom property in tokens.css (the CSS binding
 * of DESIGN.md). The only literals below are geometry the token set does not
 * carry: letter-spacing values quoted from DESIGN.md typography, opacity, and
 * layout arithmetic. No colour is ever written as a literal — dark mode is
 * therefore automatic.
 *
 * NOTE ON THE `font:` SHORTHAND: it resets font-variant-numeric. Any rule that
 * uses `font: var(--type-*)` on a number must restate tabular-nums AFTER it.
 */

/* ---------------------------------------------------------------- shell -- */

body.funnel {
  background: var(--canvas-web);
  min-height: 100vh;
}

.shell {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--sp-7) var(--screen-margin) var(--sp-8);
}

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

.skip-link {
  position: absolute;
  left: var(--screen-margin);
  top: calc(var(--sp-2) * -8);
  background: var(--surface);
  color: var(--primary-deep);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: var(--sp-3) var(--sp-5);
  font: var(--type-button);
  z-index: 20;
}
.skip-link:focus { top: var(--sp-3); }

.wordmark {
  font: var(--type-wordmark);
  color: var(--text);
  text-decoration: none;
  display: inline-block;
  margin-bottom: var(--sp-6);
}
.wordmark b { color: var(--primary); font-weight: 400; }

/* ------------------------------------------------------------ typography -- */

.display {
  font: var(--type-display);
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0 0 var(--sp-4);
}
.headline { font: var(--type-headline); color: var(--text); margin: 0 0 var(--sp-3); }
.title { font: var(--type-title); color: var(--text); margin: 0 0 var(--sp-3); }
.quote {
  font: var(--type-quote);
  font-style: italic;
  color: var(--text-muted);
  margin: 0 0 var(--sp-6);
}
p { font: var(--type-body); color: var(--text); margin: 0 0 var(--sp-3); }
.muted { color: var(--text-muted); }
.small { font: var(--type-body-sm); color: var(--text-muted); }
.caption { font: var(--type-caption); color: var(--text-muted); }
.kicker {
  font: var(--type-overline);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
  margin: 0 0 var(--sp-2);
}
.footnote {
  font: var(--type-serif-footnote);
  font-style: italic;
  color: var(--text-faint);
  margin: var(--sp-4) 0 0;
}
.footnote b { font-weight: 400; font-style: italic; color: var(--text-muted); }

a { color: var(--primary-deep); }
a:hover { text-decoration: none; }

/* ----------------------------------------------------------------- card -- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--card-inset);
  margin-bottom: var(--section-gap);
}
.card > :last-child { margin-bottom: 0; }
.card-lead { box-shadow: var(--shadow-card); }

.well {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  margin: 0 0 var(--sp-4);
}
.well > :last-child { margin-bottom: 0; }

hr.rule {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--sp-6) 0;
}

/* --------------------------------------------------------------- fields -- */

.field { margin-bottom: var(--sp-5); }
.field:last-child { margin-bottom: 0; }

.field > label,
.field-label {
  display: block;
  font: var(--type-label);
  color: var(--text);
  margin-bottom: var(--sp-2);
}
.field-hint {
  font: var(--type-caption);
  color: var(--text-muted);
  margin: 0 0 var(--sp-2);
}
.field-error {
  font: var(--type-body-sm);
  color: var(--error);
  margin: var(--sp-2) 0 0;
}
.field-error:empty { display: none; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-input);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  font: var(--type-body);
}
textarea { min-height: 132px; resize: vertical; line-height: 1.5; }
select {
  appearance: none;
  padding-right: var(--sp-7);
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }

input:focus, select:focus, textarea:focus { outline: none; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  border: 1.5px solid var(--primary);
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
[aria-invalid="true"] { border-color: var(--error); }

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}
@media (max-width: 460px) { .row { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------- controls -- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: var(--sp-3) var(--sp-6);
  border-radius: var(--r-full);
  font: var(--type-button);
  cursor: pointer;
  border: 1.5px solid transparent;
  text-decoration: none;
  transition: background-color 120ms ease, color 120ms ease;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-deep); }
.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--primary-deep);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-raised); }
.btn-danger {
  background: var(--surface);
  border-color: var(--border);
  color: var(--error);
}
.btn-danger:hover:not(:disabled) { background: var(--surface-raised); }
.btn-quiet {
  background: none;
  border-color: transparent;
  color: var(--primary-deep);
  padding: var(--sp-3) var(--sp-3);
}
.btn-quiet:hover:not(:disabled) { background: var(--surface-raised); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: center;
  margin-top: var(--sp-6);
}
.actions-split { justify-content: space-between; }

/* Inline button spinner — submissions, per State Patterns rule 2. */
.spinner {
  width: 15px;
  height: 15px;
  border-radius: var(--r-full);
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: spin 700ms linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* checkbox / radio rows — 44px targets, persistent visible labels */
.checkline {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  min-height: 44px;
  padding: var(--sp-2) 0;
  cursor: pointer;
}
.checkline input[type="checkbox"],
.checkline input[type="radio"] {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  accent-color: var(--primary);
  cursor: pointer;
}
.checkline span { font: var(--type-body); color: var(--text); }
.checkline .checkline-note {
  display: block;
  font: var(--type-body-sm);
  color: var(--text-muted);
  margin-top: var(--sp-1);
}

/* chips — multi-select as pills (interest-pill treatment, no tilt: scannable) */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  border: 0;
  padding: 0;
  margin: 0;
  min-inline-size: 0;
}
.chip { position: relative; display: inline-flex; }
.chip input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.chip span {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: var(--sp-2) var(--sp-5);
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--primary-deep);
  font: var(--type-label);
}
.chip input:checked + span {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}
.chip input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.chip input:disabled + span { opacity: 0.5; cursor: not-allowed; }

/* two-segment Dealbreaker <-> Preference pill (no third state, by design) */
.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface-raised);
  padding: 0;
  margin: 0;
  min-inline-size: 0;
  overflow: hidden;
}
.seg-opt { position: relative; display: inline-flex; }
.seg-opt input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.seg-opt span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: var(--sp-2) var(--sp-5);
  border-radius: var(--r-full);
  font: var(--type-button);
  color: var(--primary-deep);
}
.seg-opt input:checked + span { background: var(--primary); color: var(--on-primary); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: -2px; }
.seg-opt input:disabled + span { opacity: 0.5; cursor: not-allowed; }

/* ---------------------------------------------------------- fetch states -- */

.state-error {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-raised);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.state-error p { color: var(--error); margin: 0 0 var(--sp-3); font: var(--type-body); }
.state-error p:last-child { margin-bottom: 0; }

.state-empty {
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-5);
  text-align: center;
}
.state-empty p { color: var(--text-muted); margin: 0 0 var(--sp-2); }
.state-empty p:last-child { margin-bottom: 0; }

.banner {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
  font: var(--type-body-sm);
  color: var(--text);
}
.banner-error { color: var(--error); }
.banner a { color: var(--primary-deep); }

/* skeletons — shaped like the destination, in surface tone, never stock grey */
.skel {
  background: var(--surface-raised);
  border-radius: var(--r-sm);
  height: 14px;
  margin-bottom: var(--sp-3);
  animation: pulse 1400ms ease-in-out infinite;
}
.skel-line-lg { height: 30px; border-radius: var(--r-md); }
.skel-block { height: 96px; border-radius: var(--r-md); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

.save-state {
  font: var(--type-caption);
  color: var(--text-muted);
  margin: var(--sp-3) 0 0;
  min-height: 1.4em;
}
.save-state[data-tone="error"] { color: var(--error); }

/* --------------------------------------------------------------- photos -- */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.photo-tile {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 3 / 4;
  background: linear-gradient(155deg, var(--photo-grad-1) 0%, var(--photo-grad-2) 55%, var(--photo-grad-3) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
/* the dapple — blossom dots over the bloom canopy */
.photo-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 22% 28%, var(--blossom) 0 5px, transparent 6px),
    radial-gradient(circle at 68% 18%, var(--blossom) 0 3px, transparent 4px),
    radial-gradient(circle at 82% 62%, var(--blossom) 0 6px, transparent 7px),
    radial-gradient(circle at 38% 74%, var(--blossom) 0 4px, transparent 5px);
  opacity: 0.45;
  pointer-events: none;
}
.photo-tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-tile[data-status="rejected"] img { display: none; }
.photo-status {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: var(--sp-3);
  background: var(--surface);
  border-top: 1px solid var(--border);
  font: var(--type-label);
  color: var(--text);
}
.photo-status[data-status="rejected"] { color: var(--error); }
.photo-remove {
  position: absolute;
  top: var(--sp-2);
  right: var(--sp-2);
  z-index: 2;
  min-height: 44px;
  min-width: 44px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--primary-deep);
  font: var(--type-label);
  cursor: pointer;
}
.photo-remove:hover { background: var(--surface-raised); }

.file-field input[type="file"] {
  font: var(--type-body-sm);
  color: var(--text);
  width: 100%;
  padding: var(--sp-3) 0;
}
.file-field input[type="file"]::file-selector-button {
  min-height: 44px;
  margin-right: var(--sp-4);
  padding: var(--sp-2) var(--sp-5);
  border-radius: var(--r-full);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--primary-deep);
  font: var(--type-button);
  cursor: pointer;
}

/* -------------------------------------------------------------- receipt -- */

.receipt { margin: 0; }
.receipt-scope + .receipt-scope { margin-top: var(--sp-5); }

.stat-row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin: 0 0 var(--sp-3);
}
.stat {
  font: var(--type-stat);
  font-variant-numeric: tabular-nums;
  color: var(--primary-deep);
  line-height: 1.1;
}
.stat-attention { color: var(--error); }
.stat-desc {
  font: var(--type-body-sm);
  color: var(--text-muted);
  max-width: 22ch;
}

.meter {
  height: 8px;
  border-radius: var(--r-full);
  background: var(--surface-raised);
  overflow: hidden;
  margin: 0 0 var(--sp-3);
}
.meter > i {
  display: block;
  height: 100%;
  border-radius: var(--r-full);
  background: var(--primary);
  transition: width 220ms ease;
}
.meter-global > i { opacity: 0.75; }
.meter-attention > i { background: var(--error); }

.scope-line {
  font: var(--type-body);
  color: var(--text);
  margin: 0 0 var(--sp-2);
}
.scope-line b {
  font-variant-numeric: tabular-nums;
  color: var(--primary-deep);
  font-weight: 600;
}

.cost-line { margin: 0 0 var(--sp-3); }
.cost-line .stat-inline {
  font: var(--type-quote);
  font-style: normal;
  font-variant-numeric: tabular-nums;
  color: var(--error);
}

/*
 * The demote row states a fact. Neutral ink (primary-deep), the demote
 * projection in the same voice as the stat above it — never leaf, never a
 * success wash. It must not argue for loosening a filter.
 */
.fixrow {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  min-height: 44px;
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-raised);
  color: var(--primary-deep);
  font: var(--type-body-sm);
  cursor: pointer;
}
.fixrow:hover { border-color: var(--border-input); }
.fixrow .fix-delta {
  font-variant-numeric: tabular-nums;
  color: var(--primary-deep);
  font-weight: 600;
  white-space: nowrap;
}

/* narrow-viewport compact Receipt summary — sticky under the step header */
.receipt-compact {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0 0 var(--section-gap);
}
.receipt-compact-bar {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  min-height: 44px;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font: var(--type-body-sm);
  cursor: pointer;
  text-align: left;
}
.receipt-compact-bar b {
  font-variant-numeric: tabular-nums;
  color: var(--primary-deep);
}
.receipt-compact-bar .chev { color: var(--text-muted); flex: none; }
.receipt-compact-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 var(--r-md) var(--r-md);
  padding: var(--card-inset);
}
.receipt-compact-body[hidden] { display: none; }

/* --------------------------------------------------------------- wizard -- */

.step-head { margin-bottom: var(--section-gap); }
.step-meta {
  font: var(--type-overline);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 var(--sp-2);
}
.step-head h1 {
  font: var(--type-headline);
  color: var(--text);
  margin: 0 0 var(--sp-3);
}
.step-head h1:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; }

.step-dots { display: flex; gap: var(--sp-2); margin: 0 0 var(--sp-5); }
.step-dots i {
  height: 3px;
  flex: 1;
  border-radius: var(--r-full);
  background: var(--surface-raised);
}
.step-dots i[data-done="true"] { background: var(--primary); }

.axis-row {
  border-top: 1px solid var(--border);
  padding: var(--sp-5) 0;
}
.axis-row:first-of-type { border-top: 0; padding-top: 0; }
.axis-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-3);
}
.axis-name { font: var(--type-body); color: var(--text); font-weight: 600; margin: 0; }
.axis-row[data-declared="false"] .axis-name { color: var(--text-muted); font-weight: 400; }
.axis-hint { font: var(--type-caption); color: var(--text-muted); margin: 0; }
.axis-body { margin-top: var(--sp-4); }
.axis-body[hidden] { display: none; }

/* two-pane on wide viewports: editor left, live Receipt right */
@media (min-width: 1024px) {
  .shell-wide { max-width: 1024px; }
  .pane {
    display: grid;
    grid-template-columns: minmax(0, 640px) minmax(280px, 1fr);
    gap: var(--sp-7);
    align-items: start;
  }
  .pane-side { position: sticky; top: var(--sp-6); }
  .receipt-compact { display: none; }
}
@media (max-width: 1023.98px) {
  .pane-side { display: none; }
}

/* ---------------------------------------------------------- store badges -- */

.badges { display: flex; flex-wrap: wrap; gap: var(--sp-4); margin: var(--sp-5) 0; }
.badge-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 56px;
  padding: var(--sp-3) var(--sp-6);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.badge-link:hover { background: var(--surface-raised); }
.badge-link .badge-small { display: block; font: var(--type-caption); color: var(--text-muted); }
.badge-link .badge-big { display: block; font: var(--type-button); color: var(--text); }

/* ---------------------------------------------------------------- misc --- */

.stack > * + * { margin-top: var(--sp-4); }
.linkrow { display: flex; flex-wrap: wrap; gap: var(--sp-5); margin-top: var(--sp-6); }
.linkrow a, .linkrow button { font: var(--type-body-sm); }

.page-footer {
  font: var(--type-serif-footnote);
  font-style: italic;
  color: var(--text-muted);
  text-align: center;
  padding: var(--sp-7) var(--screen-margin) var(--sp-8);
}
.page-footer a { color: var(--text-muted); }
