/* MFS Tool website. One stylesheet for every page.
   Palette: the app's indigo brand; highlighter yellow is reserved for parsed
   SMS values. Dark mode follows the system unless the reader picks a theme
   (stored as data-theme on <html>). */

/* Colors are the Android app's own theme values (ui/theme/Color.kt), so
   the site and the app read as one product. */
:root {
  --paper: #F6F7FC;        /* Canvas */
  --surface: #FFFFFF;      /* SurfaceWhite */
  --sunk: #F1F3FA;         /* SurfaceMuted */
  --sunk-2: #E9ECF6;       /* SurfaceMutedHigh */
  --ink: #15171F;          /* InkPrimary */
  --ink-2: #545A6B;
  --ink-3: #60667A;        /* InkSecondary, darkened for AA text contrast */
  --line: #E1E4EE;
  --line-strong: #C3C7D8;
  --brand: #4F46E5;        /* Brand */
  --brand-hover: #4338CA;  /* BrandStrong */
  --on-brand: #FFFFFF;
  --brand-soft: #EEF0FF;   /* BrandSoft */
  --on-brand-soft: #312E81;/* OnBrandSoft */
  --mark: #F7DC6F;
  --warn: #9E4A07;
  --warn-soft: #FBEFE1;
  --warn-line: #EBD3B4;
  --ok: #0B7A57;
  --ok-soft: #E7F7F0;
  --ok-line: #BFE6D6;
  --nav-bg: rgba(246, 247, 252, .88);

  --font: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --phone: Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;

  --max: 1120px;
  --gutter: 24px;
  --nav-h: 64px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0C0D14;        /* CanvasDark */
    --surface: #171826;      /* SurfaceDark */
    --sunk: #20222F;         /* SurfaceMutedDark */
    --sunk-2: #20222F;
    --ink: #ECEEF7;          /* InkPrimaryDark */
    --ink-2: #B4B8C8;
    --ink-3: #9CA1B4;        /* InkSecondaryDark */
    --line: #2C2E3E;         /* OutlineSoftDark */
    --line-strong: #43465C;
    --brand: #A5B4FC;        /* BrandLight */
    --brand-hover: #C7D2FE;
    --on-brand: #11123A;     /* onPrimary (dark) */
    --brand-soft: #1C1F33;
    --on-brand-soft: #C9D1FF;
    --mark: #5B5328;
    --warn: #FBBF24;
    --warn-soft: #2A2012;
    --warn-line: #574522;
    --ok: #34D399;
    --ok-soft: #10251D;
    --ok-line: #1F4A3A;
    --nav-bg: rgba(12, 13, 20, .86);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0C0D14;
  --surface: #171826;
  --sunk: #20222F;
  --sunk-2: #20222F;
  --ink: #ECEEF7;
  --ink-2: #B4B8C8;
  --ink-3: #9CA1B4;
  --line: #2C2E3E;
  --line-strong: #43465C;
  --brand: #A5B4FC;
  --brand-hover: #C7D2FE;
  --on-brand: #11123A;
  --brand-soft: #1C1F33;
  --on-brand-soft: #C9D1FF;
  --mark: #5B5328;
  --warn: #FBBF24;
  --warn-soft: #2A2012;
  --warn-line: #574522;
  --ok: #34D399;
  --ok-soft: #10251D;
  --ok-line: #1F4A3A;
  --nav-bg: rgba(12, 13, 20, .86);
  color-scheme: dark;
}

/* ── Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  padding-bottom: var(--safe-b);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; }
a { color: var(--brand); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; border-radius: 4px; }
p { margin: 0 0 1em; }
h1, h2, h3 { margin: 0; color: var(--ink); text-wrap: balance; }
h1 { font-size: clamp(2.35rem, 5.4vw, 3.9rem); line-height: 1.04; font-weight: 750; letter-spacing: -.028em; }
h2 { font-size: clamp(1.55rem, 3vw, 2.15rem); line-height: 1.15; font-weight: 700; letter-spacing: -.02em; }
h3 { font-size: 1.125rem; line-height: 1.35; font-weight: 650; letter-spacing: -.005em; }
code, pre { font-family: var(--mono); }
code {
  font-size: .86em;
  background: var(--sunk);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .06em .38em;
  overflow-wrap: anywhere;
}
.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--brand); color: var(--on-brand);
  padding: 10px 14px; border-radius: 8px; text-decoration: none;
}
.skip:focus { top: calc(10px + var(--safe-t)); }

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding-left: calc(var(--gutter) + var(--safe-l));
  padding-right: calc(var(--gutter) + var(--safe-r));
}

/* ── Navigation ───────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 50;
  padding-top: var(--safe-t);
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink); text-decoration: none;
  font-weight: 700; font-size: 17px; letter-spacing: -.01em;
}
.brand img { width: 32px; height: 32px; border-radius: 8px; display: block; object-fit: contain; background: #fff; }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a {
  color: var(--ink-2); text-decoration: none; font-size: 15px; font-weight: 500;
  padding: 8px 12px; border-radius: 8px;
}
.nav-links a:hover { color: var(--ink); background: var(--sunk); }
.nav-links a[aria-current="page"] { color: var(--ink); font-weight: 650; }
.theme-btn {
  width: 40px; height: 40px; margin-left: 6px; flex: none;
  display: grid; place-items: center;
  background: transparent; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; padding: 0;
}
.theme-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.theme-btn svg { width: 19px; height: 19px; }
.theme-btn .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .sun { display: none; }
  :root:not([data-theme="light"]) .theme-btn .moon { display: block; }
}
:root[data-theme="dark"] .theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .moon { display: block; }
:root[data-theme="light"] .theme-btn .sun { display: block; }
:root[data-theme="light"] .theme-btn .moon { display: none; }

/* ── Buttons ──────────────────────────────────────────────────── */
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 50px; padding: 0 16px;
  font: inherit; font-size: 15.5px; font-weight: 650; letter-spacing: -.005em;
  text-decoration: none; white-space: nowrap;
  border-radius: 10px; border: 1.5px solid transparent;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-quiet:hover { border-color: var(--brand); color: var(--brand); }

/* ── Home: hero ───────────────────────────────────────────────── */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 48px;
  align-items: center;
  padding-top: 64px;
  padding-bottom: 80px;
}
.hero-copy h1 { max-width: 13ch; }
.hero-copy .lede { margin: 22px 0 30px; max-width: 34em; font-size: 1.15rem; line-height: 1.6; color: var(--ink-2); }
.hero-copy .fineprint { margin: 18px 0 0; font-size: 15px; color: var(--ink-3); }

/* The parse figure: an SMS bubble, then the JSON it becomes. */
.parse { margin: 0; }
.sms {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px 22px 22px 6px;
  padding: 16px 20px 18px;
  font-family: var(--phone);
  box-shadow: 0 1px 0 var(--line), 0 18px 40px -28px rgba(79, 70, 229, .30);
}
.sms-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.sms-from { font-weight: 600; font-size: 15px; color: var(--ink); }
.sms-time { font-size: 13px; color: var(--ink-3); }
.sms-body { margin: 0; font-size: 16px; line-height: 1.6; color: var(--ink); }
.hop {
  display: flex; align-items: center; gap: 12px;
  margin: 14px 0 14px 22px;
  font-size: 14px; color: var(--ink-2);
}
.hop svg { width: 22px; height: 40px; flex: none; color: var(--brand); }
.payload {
  background: var(--sunk-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.payload-head {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 13px; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.payload pre {
  margin: 0; padding: 14px 16px 16px;
  font-size: 14px; line-height: 1.65; color: var(--ink);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.payload pre code { background: none; border: 0; border-radius: 0; padding: 0; font-size: inherit; overflow-wrap: normal; white-space: pre; }
.payload .k { color: var(--ink-3); }

/* Highlighter marks. Each pair (SMS value + JSON value) shares --i so they
   are swept in together, in reading order, once on page load. */
.f {
  background-image: linear-gradient(var(--mark), var(--mark));
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: 100% 100%;
  border-radius: 3px;
  padding: 0 .14em;
  margin: 0 -.06em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
@media (prefers-reduced-motion: no-preference) {
  .parse .f {
    background-size: 0% 100%;
    animation: sweep .45s cubic-bezier(.3, .7, .2, 1) forwards;
    animation-delay: calc(.6s + var(--i, 0) * .38s);
  }
  .parse .payload .f { animation-delay: calc(.78s + var(--i, 0) * .38s); }
}
@keyframes sweep { to { background-size: 100% 100%; } }

/* ── Home: sections ───────────────────────────────────────────── */
.section {
  padding-top: 72px;
  padding-bottom: 72px;
  border-top: 1px solid var(--line);
  scroll-margin-top: calc(var(--nav-h) + var(--safe-t));
}
.section-head { max-width: 40em; margin-bottom: 36px; }
.section-head p { margin: 14px 0 0; font-size: 1.075rem; color: var(--ink-2); }

/* Parsed vs forwarded comparison */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.lane {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px 26px 24px;
}
.lane h3 { font-size: 1.25rem; }
.lane .who { margin: 4px 0 14px; font-size: 15px; color: var(--ink-3); }
.lane p { color: var(--ink-2); }
.lane .fields { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 0; padding: 0; list-style: none; }
.lane .fields code { font-size: 13.5px; }
.lane-parsed { border-top: 4px solid var(--brand); }
.more { margin: 26px 0 0; }

/* Provider directory */
.directory { display: grid; grid-template-columns: 1fr 1.4fr; gap: 40px; }
.directory h3 { padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.directory h3 span { color: var(--ink-3); font-weight: 500; }
.names { margin: 0; padding: 0; list-style: none; columns: 2; column-gap: 28px; }
.directory .banks .names { columns: 3; }
.names li { padding: 5px 0; break-inside: avoid; color: var(--ink); }
.directory-note { margin: 28px 0 0; color: var(--ink-2); max-width: 44em; }

/* Numbered steps: only used for real sequences */
.steps {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px;
  margin: 0; padding: 0; list-style: none; counter-reset: step;
}
.steps li { counter-increment: step; border-top: 2px solid var(--ink); padding-top: 18px; }
.steps li::before {
  content: counter(step);
  display: block; margin-bottom: 10px;
  font-size: 2.6rem; line-height: 1; font-weight: 700; color: var(--brand);
  font-variant-numeric: lining-nums;
}
.steps h3 { margin-bottom: 8px; }
.steps p { margin: 0; color: var(--ink-2); }

/* Fact rows (term + explanation) */
.facts { margin: 0; display: grid; grid-template-columns: minmax(180px, 280px) 1fr; }
.facts dt, .facts dd { padding: 18px 0; border-top: 1px solid var(--line); }
.facts dt { font-weight: 650; padding-right: 24px; }
.facts dd { margin: 0; color: var(--ink-2); }

/* Notes */
.note {
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 6px 12px 12px 6px;
  padding: 20px 22px;
  background: var(--surface);
}
.note h2, .note h3 { font-size: 1.125rem; margin-bottom: 6px; letter-spacing: -.005em; }
.note p { margin: 0; color: var(--ink-2); }
.note-warn { background: var(--warn-soft); border-color: var(--warn-line); border-left-color: var(--warn); }
.note-warn h2, .note-warn h3 { color: var(--warn); }
.note-ok { background: var(--ok-soft); border-color: var(--ok-line); border-left-color: var(--ok); }
.note-ok h2, .note-ok h3 { color: var(--ok); }
.install .note { margin-top: 36px; max-width: 46em; }

/* Download band */
.band {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px 40px; align-items: center;
  background: var(--brand-soft);
  border-radius: 20px;
  padding: 36px 40px;
}
.band p { margin: 10px 0 0; color: var(--ink-2); }

/* ── Doc pages (privacy, webhook) ─────────────────────────────── */
.doc-head { padding-top: 56px; padding-bottom: 40px; border-bottom: 1px solid var(--line); }
.doc-head h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); }
.doc-head .lede { margin: 16px 0 0; max-width: 38em; font-size: 1.125rem; color: var(--ink-2); }
.doc-head .updated { margin: 14px 0 0; font-size: 15px; color: var(--ink-3); }
.doc {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 56px;
  padding-top: 40px;
  padding-bottom: 72px;
}
.toc-side { position: sticky; top: calc(var(--nav-h) + var(--safe-t) + 24px); align-self: start; }
.toc-title { margin: 0 0 10px; font-size: 14px; font-weight: 650; color: var(--ink); }
.toc-list { margin: 0; padding: 0; list-style: none; border-left: 1px solid var(--line); }
.toc-list a {
  display: block; padding: 5px 0 5px 14px; margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--ink-2); text-decoration: none; font-size: 15px; line-height: 1.4;
}
.toc-list a:hover { color: var(--ink); border-left-color: var(--line-strong); }
.toc-list a.is-current { color: var(--brand); border-left-color: var(--brand); font-weight: 600; }
.toc-mobile { display: none; }

.prose { max-width: 44em; }
.prose > section:not(.note) { padding: 8px 0 28px; scroll-margin-top: calc(var(--nav-h) + var(--safe-t) + 16px); }
.prose > section:not(.note) + section:not(.note) { border-top: 1px solid var(--line); padding-top: 32px; }
.prose > .note { margin: 4px 0 28px; scroll-margin-top: calc(var(--nav-h) + var(--safe-t) + 16px); }
.prose h2 { margin-bottom: 14px; font-size: clamp(1.4rem, 2.6vw, 1.75rem); }
.prose h3 { margin: 26px 0 8px; }
.prose .note h2 { font-size: 1.125rem; margin-bottom: 6px; }
.prose p { color: var(--ink-2); }
.prose p strong, .prose li strong, .prose td strong { color: var(--ink); font-weight: 650; }
.prose .lead-p { font-size: 1.1rem; color: var(--ink); }
.prose ul { margin: 0 0 1em; padding-left: 1.2em; }
.prose ul li { margin: 0 0 .55em; color: var(--ink-2); padding-left: .2em; }
.prose ul li::marker { color: var(--brand); }
.prose .toc-mobile .toc-list { padding-left: 0; }
.prose .toc-mobile .toc-list li { margin: 0; padding-left: 0; }

/* Permission list (privacy) */
.prose ul.perm { list-style: none; padding: 0; margin: 4px 0 1em; }
.prose ul.perm li { padding: 14px 0; margin: 0; border-top: 1px solid var(--line); }
.prose ul.perm li:last-child { border-bottom: 1px solid var(--line); }
.perm b { display: block; color: var(--ink); font-weight: 650; }
.perm span { color: var(--ink-2); }

/* Code blocks with a copy button (webhook) */
.code { position: relative; margin: 0 0 20px; }
.code pre {
  margin: 0; padding: 16px 18px;
  background: var(--sunk); border: 1px solid var(--line); border-radius: 12px;
  font-size: 14px; line-height: 1.6; color: var(--ink);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.code pre code { background: none; border: 0; padding: 0; font-size: inherit; overflow-wrap: normal; white-space: pre; }
.code .copy {
  position: absolute; top: 8px; right: 8px;
  font: inherit; font-size: 13px; font-weight: 600;
  min-height: 32px; padding: 0 12px;
  color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
.code .copy:hover { color: var(--ink); border-color: var(--line-strong); }
.code .copy[data-done] { color: var(--brand); border-color: var(--brand); }
.code.has-copy pre { padding-right: 84px; }

/* Tables (webhook) */
.table-wrap {
  margin: 4px 0 22px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
table { width: 100%; border-collapse: collapse; font-size: 15.5px; }
th, td { text-align: left; vertical-align: top; padding: 11px 14px; border-bottom: 1px solid var(--line); }
th { font-weight: 650; color: var(--ink); background: var(--sunk); white-space: nowrap; }
td { color: var(--ink-2); }
td:first-child { color: var(--ink); white-space: nowrap; }
table.fields td:nth-child(2) { white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tr.group td { font-weight: 650; color: var(--brand); background: var(--brand-soft); }

/* ── Footer ───────────────────────────────────────────────────── */
.footer { border-top: 1px solid var(--line); background: var(--surface); }
.footer-inner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 28px;
  padding-top: 28px; padding-bottom: 32px;
}
.footer .brand { font-size: 16px; }
.footer .brand img { width: 28px; height: 28px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 0; padding: 0; list-style: none; }
.footer-links a { color: var(--ink-2); text-decoration: none; font-size: 15px; }
.footer-links a:hover { color: var(--ink); text-decoration: underline; }
.copyright { margin: 0; font-size: 14px; color: var(--ink-3); width: 100%; }
.copyright a { color: var(--ink-2); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 980px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 44px; padding-top: 44px; padding-bottom: 64px; }
  .hero-copy h1 { max-width: 15ch; }
  .directory { grid-template-columns: 1fr; gap: 32px; }
  .doc { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 24px; }
  .toc-side { display: none; }
  .toc-mobile {
    display: block; margin-bottom: 28px;
    border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  }
  .toc-mobile summary {
    cursor: pointer; padding: 14px 16px; font-weight: 650; list-style-position: inside;
  }
  .toc-mobile .toc-list { margin: 0 16px 14px; }
}
@media (max-width: 760px) {
  :root { --gutter: 18px; --nav-h: 58px; }
  body { font-size: 16.5px; }
  .nav-links a:not(.keep) { display: none; }
  .split { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; gap: 26px; }
  .facts { grid-template-columns: 1fr; }
  .facts dd { border-top: 0; padding-top: 0; }
  .facts dt { padding-bottom: 6px; }
  .band { grid-template-columns: 1fr; padding: 28px 22px; }
  .section { padding-top: 56px; padding-bottom: 56px; }
  .directory .banks .names { columns: 2; }
}
@media (max-width: 560px) {
  :root { --gutter: 16px; }
  .actions .btn { flex: 1 1 100%; }
  .hero-copy .lede { font-size: 1.06rem; }
  .sms { padding: 14px 16px 16px; }
  .sms-body { font-size: 15.5px; }
  .payload pre { font-size: 13px; }
  .lane { padding: 22px 18px 20px; }
  table.fields thead { display: none; }
  table.fields tr { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  table.fields tbody tr:last-child { border-bottom: 0; }
  table.fields td { display: inline; padding: 0; border: 0; }
  table.fields td:nth-child(2) { color: var(--ink-3); font-size: .88rem; margin-left: 8px; }
  table.fields td:nth-child(3) { display: block; margin-top: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .001ms !important; animation-duration: .001ms !important; animation-delay: 0s !important; }
}
@media print {
  .nav, .toc-side, .toc-mobile, .theme-btn, .copy, .skip { display: none !important; }
  body { background: #fff; color: #000; }
  .f { animation: none !important; background-size: 100% 100% !important; }
  .doc { grid-template-columns: 1fr; }
  a { color: #000; }
}
