/* DM Sans variable (opsz 9–40, wght 100–1000), Google Fonts' latin subset, self-hosted: no third-party request,
   identical rendering on every load. Licence: /fonts/OFL.txt. */
@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 100 1000;
  font-display: swap;
  src: url("/fonts/dm-sans-latin-var.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Values from the measured Figma spec (references/figma/application-tab/application-tab-spec.md §2–5, §8). */
:root {
  --page-bg: #f8f8ff;
  --text: #2f2d6c;
  --label: #6b6796;
  --card-border: #eae8f7;
  --card-shadow: 0 2px 6px 0 rgba(47, 45, 108, 0.06);
  --primary: #2600bc;
  --trend-up: #00a08a;   /* "Green Text" */
  --trend-down: #ef4444; /* "Red" — the comp draws no down state */
  --font: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

.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: -9999px; top: 8px; }
.skip:focus { left: 16px; background: #fff; color: var(--primary); padding: 8px 12px; border-radius: 8px; z-index: 1; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.page-head, main, .page-foot { max-width: 1011px; margin: 0 auto; padding: 0 16px; }

.page-head { padding-top: 40px; }
.eyebrow { margin: 0 0 8px; font-size: 13px; font-weight: 500; color: var(--label); letter-spacing: 0.02em; }
h1 { margin: 0 0 12px; font-size: 28px; line-height: 1.2; font-weight: 700; color: #1b0084; }
.lede { margin: 0 0 16px; max-width: 70ch; color: var(--text); }
.demo-notice {
  margin: 0 0 24px; padding: 10px 14px; max-width: 70ch;
  background: #fff7e8; border: 1px solid #ffe0a3; border-radius: 12px; font-size: 14px;
}

/* ---- scope switcher ---- */
.scope { border: 0; margin: 0 0 20px; padding: 0; }
.scope legend { padding: 0; margin-bottom: 8px; font-size: 14px; font-weight: 500; color: var(--label); }
.scope-options { display: flex; flex-wrap: wrap; gap: 8px; }
.scope-options input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.scope-options label {
  display: inline-block; padding: 7px 15px; border: 1.5px solid var(--primary); border-radius: 40px;
  background: #fff; color: var(--primary); font-size: 14px; font-weight: 500; line-height: 18px; cursor: pointer;
}
.scope-options input:checked + label { background: var(--primary); color: #fff; }
.scope-options input:focus-visible + label { outline: 2px solid var(--primary); outline-offset: 2px; }
.scope-note { margin: 10px 0 0; max-width: 70ch; font-size: 13px; color: var(--label); }

/* ---- the card: 313 x 88, measured ---- */
.card-row { display: flex; flex-wrap: wrap; gap: 20px; }

.metric-card {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 313px;
  height: 88px;
  padding: 0 15px; /* 16 in Figma, measured from the outer edge; the 1 px border sits inside it */
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
  font-family: var(--font);
  /* Optical size left automatic (opsz = font size). Figma reports "opsz" 14; fitted against the comp PNGs, automatic
     matched slightly better (proof/fidelity.txt), so the browser default stands. */
}

.chip {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
}
.chip-icon { display: block; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.copy { flex: none; display: flex; flex-direction: column; gap: 3px; width: 125px; }
.label, .value, .trend-text { margin: 0; white-space: nowrap; }
.label { font-size: 13px; line-height: 17px; font-weight: 500; color: var(--label); }
.value { font-size: 24px; line-height: 31px; font-weight: 700; color: var(--text); }

.trend { position: relative; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; width: 96px; }
.trend-text { height: 14px; font-size: 11px; line-height: 14px; font-weight: 500; color: var(--trend-up); }
.trend-text[data-direction="down"] { color: var(--trend-down); }
.trend-text[data-direction="flat"] { color: var(--label); }

.spark { display: block; overflow: hidden; }
.spark-line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark-area { fill: var(--series); fill-opacity: 0.1; stroke: none; }

/* per-widget series colours (unbound literals in the comp, except the conversion line = "Secondary") */
[data-widget="accommodation"] { --series: #2600bc; }
[data-widget="approval"] { --series: #0fae84; }
[data-widget="conversion"] { --series: #ffb31e; }
[data-widget="accommodation"] .chip { background: #ede9fa; }
[data-widget="approval"] .chip { background: #e7f7f3; }
[data-widget="conversion"] .chip { background: rgba(255, 179, 30, 0.1); }
.chip-icon { stroke: var(--series); }

.status { margin: 16px 0 0; font-size: 13px; color: var(--label); min-height: 20px; }
body[data-state="error"] .status { color: var(--trend-down); }

/* ---- how it works ---- */
.how { margin-top: 48px; padding-top: 8px; border-top: 1px solid var(--card-border); }
.how h2 { font-size: 22px; margin: 24px 0 12px; color: #1b0084; }
.how h3 { font-size: 17px; margin: 32px 0 8px; }
.how p, .how li { max-width: 80ch; font-size: 15px; }
.flow { padding-left: 22px; }
.flow li { margin-bottom: 8px; }
.code-intro { color: var(--label); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
pre.code {
  margin: 12px 0; padding: 14px 16px; overflow-x: auto;
  background: #fff; border: 1px solid var(--card-border); border-radius: 12px;
  font-size: 12.5px; line-height: 1.55; color: #24224f;
}
pre.code code { font-size: inherit; white-space: pre; }
.rules li { margin-bottom: 8px; }

.page-foot { margin-top: 56px; padding-bottom: 32px; font-size: 13px; color: var(--label); }

@media (max-width: 400px) {
  .page-head { padding-top: 24px; }
  h1 { font-size: 24px; }
  .card-row { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
