/* Mula web: the app's tokens (App/Views/Theme.swift), mobile first. */
:root {
  --navy: #0B1B33;
  --text: #1F2A3D;
  --muted: #5D6879;
  --cobalt: #1D4ED8;
  --cobalt-pressed: #1E40AF;
  --tint: #EAF1FF;
  --surface: #F6F8FB;
  --border: #E3E8F0;
  --white: #FFFFFF;
  --green-text: #065F46;
  --green-bg: #ECFDF5;
  --amber-text: #8A4B08;
  --amber-bg: #FFF7E8;
  --red-text: #991B1B;
  --red-bg: #FEF2F2;
  --radius-card: 18px;
  --radius-button: 14px;
  --shadow: 0 1px 2px rgba(11, 27, 51, 0.04), 0 8px 24px rgba(11, 27, 51, 0.06);
  /* Brand type: headlines in SF Pro Display Bold, smaller labels in SF Pro Text. */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  /* Brand blue, sampled from Brand/mula-on-textured-blue.png. */
  --brand-light: #336ECF;
  --brand: #2953B7;
  --brand-deep: #1C3B91;
  --focus: 0 0 0 3px var(--white), 0 0 0 5px var(--cobalt);
  color-scheme: light;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--surface);
  color: var(--text);
  font: 400 17px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, p, ol, ul, dl, dd { margin: 0; }
img, svg { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
a { color: var(--cobalt); }

:focus { outline: none; }
:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; border-radius: 6px; }
[tabindex="-1"]:focus-visible { outline: none; }

.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 {
  position: absolute; left: 16px; top: -60px; z-index: 10;
  background: var(--navy); color: var(--white); padding: 10px 14px; border-radius: 10px; text-decoration: none;
}
.skip:focus { top: 12px; }

/* Header */
.topbar {
  display: flex; align-items: center; justify-content: center;
  height: 56px; padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
}
/* The wordmark is the brand artwork ("mula.", lowercase with its period), never retyped:
   assets/mula-wordmark.png used as a mask, so it takes the text color. Navy here; white on blue. */
.wordmark {
  display: inline-block; position: relative;
  width: 72px; height: 22px;
  margin: 10px 6px;
  text-decoration: none;
  border-radius: 6px;
}
/* The mask sits on an inner layer so the link keeps its keyboard focus ring. */
.wordmark::before {
  content: ""; position: absolute; inset: 0;
  background-color: var(--navy);
  -webkit-mask: url(/assets/mula-wordmark.png) center / contain no-repeat;
  mask: url(/assets/mula-wordmark.png) center / contain no-repeat;
}
.wordmark.on-brand::before { background-color: var(--white); }
.demo-badge {
  position: absolute; right: 16px; top: calc(14px + env(safe-area-inset-top));
  font-size: 12px; font-weight: 600; color: var(--amber-text); background: var(--amber-bg);
  border-radius: 999px; padding: 4px 10px;
}

main {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 4px 16px calc(16px + env(safe-area-inset-bottom));
}

.step { display: flex; flex-direction: column; gap: 16px; animation: fade-in 180ms ease-out; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Type */
h1 {
  font-family: var(--font-display);
  font-size: 26px; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; color: var(--navy);
  overflow-wrap: anywhere;
}
.h3 { font-size: 17px; line-height: 1.35; font-weight: 600; color: var(--navy); }
.eyebrow {
  font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.sub { font-size: 15px; color: var(--text); margin-top: 4px; }
.lead { font-size: 16px; color: var(--text); margin-top: -6px; }
.muted { color: var(--muted); }
.strong { font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.footnote { font-size: 13px; color: var(--muted); padding: 0 4px; }
.footnote.center { text-align: center; }

/* Invitation header */
.invite-head { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start; padding-top: 8px; }
.invite-head .eyebrow { margin-bottom: 4px; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  background: var(--tint); color: var(--navy); font-weight: 700; font-size: 17px;
}
.avatar.is-me { background: var(--cobalt); color: var(--white); }
.avatar-lg { width: 52px; height: 52px; font-size: 22px; }

/* Cards */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
  min-width: 0;
}
.card-row { flex-direction: row; align-items: flex-start; gap: 12px; }
.card-row p { font-size: 15px; margin-top: 4px; }
.row-icon { color: var(--cobalt); flex: none; margin-top: 1px; }
.tone-amber-text { color: var(--amber-text); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-between.wrap { flex-wrap: wrap; }

.amount {
  font: 700 44px/1.05 var(--font-display);
  color: var(--navy);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.of-total { font-size: 16px; }

.info { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.info div { display: flex; justify-content: space-between; gap: 16px; }
.info dt { color: var(--muted); flex: none; }
.info dd { text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

/* Chips */
.chip {
  display: inline-flex; align-items: center; flex: none;
  font-size: 13px; font-weight: 600; line-height: 1;
  padding: 6px 10px; border-radius: 999px;
}
.chip-waiting { color: var(--muted); background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); }
.chip-held { color: var(--cobalt); background: var(--tint); }
.chip-charged { color: var(--green-text); background: var(--green-bg); }
.chip-released { color: var(--amber-text); background: var(--amber-bg); }

/* Banners */
.banner {
  display: grid; grid-template-columns: auto 1fr; gap: 12px;
  padding: 16px; border-radius: var(--radius-card);
  font-size: 15px;
}
.banner:focus-visible { outline: 3px solid var(--cobalt); }
.banner-title { font-size: 17px; font-weight: 600; color: var(--navy); margin-bottom: 2px; }
.tone-green { background: var(--green-bg); }
.tone-green .banner-icon { color: var(--green-text); }
.tone-amber { background: var(--amber-bg); }
.tone-amber .banner-icon { color: var(--amber-text); }
.tone-blue { background: var(--tint); }
.tone-blue .banner-icon { color: var(--cobalt); }
.tone-red .banner-icon { color: var(--red-text); }

/* Steps */
.steps { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 14px; counter-reset: step; }
.steps li { display: grid; grid-template-columns: 28px 1fr; gap: 12px; counter-increment: step; font-size: 15px; }
.steps li::before {
  content: counter(step);
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--tint); color: var(--cobalt);
  font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.steps p { padding-top: 3px; }

/* People */
.people { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.people li { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.person { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.person-name { font-weight: 500; color: var(--navy); overflow-wrap: anywhere; }
.person-sub { font-size: 13px; color: var(--muted); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 48px; padding: 12px 18px;
  border-radius: var(--radius-button); border: 0;
  font-size: 17px; font-weight: 600; text-align: center; text-decoration: none;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background-color 120ms ease, transform 120ms ease;
}
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn-primary { min-height: 54px; background: var(--cobalt); color: var(--white); }
.btn-primary:hover { background: var(--cobalt-pressed); }
.btn-primary:active { background: var(--cobalt-pressed); transform: scale(0.99); }
.btn-primary:disabled { background: var(--cobalt); opacity: 0.55; cursor: default; transform: none; }
.btn-primary[aria-busy="true"]:disabled { opacity: 0.85; }
.btn-secondary { background: var(--white); color: var(--cobalt); box-shadow: inset 0 0 0 1px var(--border); }
.btn-secondary:active { background: var(--tint); }
.btn-secondary:focus-visible { box-shadow: inset 0 0 0 1px var(--border), var(--focus); }
.btn-ghost { background: transparent; color: var(--cobalt); }
.btn-ghost:active { background: var(--tint); }

.btn-link, .link-inline {
  background: none; border: 0; padding: 0; color: var(--cobalt); font-weight: 600; cursor: pointer;
}
.btn-link { min-height: 44px; font-size: 15px; }
.btn-link:disabled { color: var(--muted); font-weight: 500; cursor: default; font-variant-numeric: tabular-nums; }
.link-inline { font-size: inherit; text-decoration: underline; min-height: 24px; }

.back {
  display: inline-flex; align-items: center; gap: 4px; align-self: flex-start;
  min-height: 44px; padding: 0 12px 0 4px; margin: 0 0 -8px -4px;
  background: none; border: 0; border-radius: 10px;
  color: var(--cobalt); font-weight: 600; cursor: pointer;
}
.back svg { width: 22px; height: 22px; }

.action-bar {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; flex-direction: column; gap: 4px;
  margin: 0 -16px; padding: 20px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(246, 248, 251, 0), var(--surface) 20px);
}
.stack { display: flex; flex-direction: column; gap: 8px; width: 100%; }

/* Forms */
.form { gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; color: var(--navy); font-size: 15px; }
.field input {
  width: 100%; min-height: 52px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--white);
  font-size: 17px; /* 16px+ keeps iOS from zooming */
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.field input::placeholder { color: #8A94A6; }
.field input:focus { border-color: var(--cobalt); box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.2); }
.field input[aria-invalid="true"] { border-color: var(--red-text); }
.code-input { font-size: 26px !important; letter-spacing: 0.3em; font-variant-numeric: tabular-nums; font-weight: 600; }
.hint { font-size: 13px; color: var(--muted); }
.field-error { font-size: 14px; color: var(--red-text); font-weight: 500; }
.inline-error {
  display: flex; gap: 8px; align-items: flex-start;
  background: var(--red-bg); color: var(--red-text);
  border-radius: 12px; padding: 12px; font-size: 15px; font-weight: 500;
}
.inline-error svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.inline-error[hidden], .field-error[hidden] { display: none; }

.summary { display: flex; gap: 12px; align-items: center; font-size: 15px; padding: 0 4px; }
.summary strong { color: var(--navy); font-variant-numeric: tabular-nums; }

.test-hint {
  display: flex; gap: 8px; align-items: flex-start;
  background: var(--tint); color: var(--navy); border-radius: 12px; padding: 12px; font-size: 14px;
}
.test-hint svg { width: 20px; height: 20px; color: var(--cobalt); flex: none; margin-top: 1px; }
.loading-line { display: flex; align-items: center; gap: 10px; min-height: 120px; justify-content: center; font-size: 15px; }

/* Demo card placeholder */
.demo-card { display: flex; flex-direction: column; gap: 8px; }
.demo-card-label { font-size: 15px; color: var(--text); }
.demo-input {
  min-height: 48px; padding: 13px 14px; border: 1px solid var(--border); border-radius: 12px;
  color: #8A94A6; font-variant-numeric: tabular-nums; background: var(--white);
}
.demo-split { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Loading and errors */
.center-state {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px;
  padding: 48px 8px 24px;
}
.center-state p { max-width: 34ch; }
.center-state .stack { margin-top: 12px; }
.state-icon {
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.state-icon svg { width: 30px; height: 30px; }
.state-icon.tone-amber { background: var(--amber-bg); color: var(--amber-text); }
.state-icon.tone-red { background: var(--red-bg); color: var(--red-text); }

.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--tint); border-top-color: var(--cobalt);
  animation: spin 0.8s linear infinite;
}
.spinner-sm { width: 18px; height: 18px; border-width: 2px; flex: none; }
.spinner.on-dark { border-color: rgba(255, 255, 255, 0.35); border-top-color: var(--white); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Demo state switcher */
.demo-nav {
  margin-top: 28px; padding: 14px; border: 1px dashed #C9D2E0; border-radius: 14px; font-size: 13px; color: var(--muted);
}
.demo-nav ul { list-style: none; padding: 0; margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.demo-nav a {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 10px; border-radius: 999px;
  background: var(--white); box-shadow: inset 0 0 0 1px var(--border); text-decoration: none; font-weight: 600;
}
.demo-nav a[aria-current="page"] { background: var(--cobalt); color: var(--white); box-shadow: none; }

/* Landing page */
/* Home hero: the brand's textured blue (the artwork itself), white type. */
.hero {
  display: flex; flex-direction: column; align-items: flex-start; gap: 14px;
  margin-top: calc(16px + env(safe-area-inset-top)); padding: 28px 22px 26px;
  border-radius: 22px;
  background: var(--brand) url(/assets/brand-blue.jpg) center / cover no-repeat;
  box-shadow: 0 12px 28px rgba(28, 59, 145, 0.25);
  color: var(--white);
}
.hero .wordmark { width: 104px; height: 32px; margin: 0 0 4px; }
.hero h1 { font-size: 32px; color: var(--white); }
.hero p { font-size: 18px; color: rgba(255, 255, 255, 0.88); margin: 0; }

@media (min-width: 720px) {
  main { padding-top: 24px; }
  h1 { font-size: 30px; }
  .action-bar { position: static; margin: 0; padding: 4px 0 0; background: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .spinner { animation: none; border-top-color: var(--cobalt); border-right-color: var(--cobalt); }
}

@media (forced-colors: active) {
  .btn, .chip, .card, .banner { border: 1px solid CanvasText; }
}
