/* Self-hosted fonts (no external requests = faster pages) */
@font-face { font-family: "Bricolage Grotesque"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("/assets/fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Bricolage Grotesque"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("/assets/fonts/bricolage-grotesque-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/assets/fonts/instrument-sans-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/assets/fonts/instrument-sans-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* MoneyMath — design tokens
   Cool paper background, deep navy ink, cobalt for calculators, teal for converters.
   Display: Bricolage Grotesque. Body: Instrument Sans. */
:root {
  --bg: #f2f5fa;
  --surface: #ffffff;
  --ink: #0e1a30;
  --ink-2: #26344f;
  --muted: #5b6780;
  --line: #dce3ee;
  --track: #dfe5f1;
  --calc: #2d4ef5;
  --calc-soft: #e7ecff;
  --conv: #0b8f80;
  --conv-soft: #dcf4f0;
  --sun: #ffc83d;
  --navy: #0e1a30;
  --navy-2: #172644;
  --radius-s: 10px;
  --radius-m: 14px;
  --radius-l: 24px;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--calc); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; border-radius: 4px; }
.wrap { width: min(1120px, 100% - 40px); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; letter-spacing: -0.015em; margin: 0; }
h1 { font-size: clamp(2rem, 4.5vw, 3.1rem); font-weight: 700; }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.8rem); font-weight: 650; }
h3 { font-size: 1.15rem; font-weight: 650; }
p { margin: 0 0 1em; }

/* ---------- Header ---------- */
.site-header { background: var(--navy); color: #fff; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 68px; }
.logo { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; letter-spacing: -0.02em; }
.logo-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--sun); display: grid; place-content: center; gap: 4px; }
.logo-mark i { display: block; width: 14px; height: 3px; border-radius: 2px; background: var(--navy); }
.nav { display: flex; gap: 6px; }
.nav a { color: #cfd8ea; text-decoration: none; padding: 8px 14px; border-radius: 999px; font-weight: 500; font-size: 0.95rem; }
.nav a:hover, .nav a[aria-current="page"] { background: var(--navy-2); color: #fff; }

/* ---------- Hero (home) ---------- */
.hero { background: var(--navy); color: #fff; position: relative; padding: 48px 0 96px; overflow: hidden; }
.hero::after { /* ruler along the bottom edge */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 44px;
  background:
    repeating-linear-gradient(90deg, #3c4d73 0 2px, transparent 2px 40px) bottom / 100% 26px no-repeat,
    repeating-linear-gradient(90deg, #2a3a5e 0 1px, transparent 1px 8px) bottom / 100% 12px no-repeat;
}
.hero-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 48px; align-items: center; }
.hero h1 { color: #fff; max-width: 14ch; }
.hero .lead { color: #b9c5de; font-size: 1.15rem; max-width: 46ch; margin: 18px 0 26px; }
.search { position: relative; max-width: 460px; }
.search svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--muted); }
.search input { width: 100%; height: 54px; border-radius: 14px; border: 2px solid transparent; padding: 0 16px 0 46px; font: inherit; font-size: 1rem; color: var(--ink); background: #fff; }
.search input:focus { outline: none; border-color: var(--sun); }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.quick a { color: #dbe4f7; text-decoration: none; border: 1px solid #34466e; padding: 5px 13px; border-radius: 999px; font-size: 0.9rem; }
.quick a:hover { border-color: var(--sun); color: #fff; }

/* hero converter */
.hero-card { background: #fff; color: var(--ink); border-radius: var(--radius-l); padding: 22px; box-shadow: 0 24px 60px rgba(3, 10, 28, 0.45); }
.hero-card h2 { font-size: 1.05rem; margin-bottom: 14px; color: var(--ink-2); }

/* ---------- Home sections ---------- */
.section { padding: 56px 0 8px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.section-head p { color: var(--muted); margin: 0; }
.tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.tile { display: flex; gap: 14px; align-items: center; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); text-decoration: none; color: inherit; height: 100%; }
.tile:hover { border-color: var(--ink); }
.glyph { flex: none; width: 52px; height: 52px; border-radius: 12px; display: grid; place-content: center; font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; background: var(--calc-soft); color: var(--calc); }
.glyph.small { font-size: 0.85rem; }
.conv-glyph { background: var(--conv-soft); color: var(--conv); }
.tile strong { display: block; font-family: var(--font-display); font-size: 1.05rem; line-height: 1.25; }
.tile span.d { display: block; color: var(--muted); font-size: 0.9rem; line-height: 1.4; margin-top: 2px; }
.no-results { display: none; color: var(--muted); padding: 24px 0; }

.points { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; padding: 64px 0 24px; }
.points h3 { margin-bottom: 6px; }
.points p { color: var(--muted); margin: 0; }

/* ---------- Tool page ---------- */
.crumbs { padding: 22px 0 8px; font-size: 0.9rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.tool-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 40px; padding-bottom: 72px; align-items: start; }
.tool-head { padding: 8px 0 22px; }
.tool-head .lead { color: var(--muted); font-size: 1.1rem; margin: 12px 0 0; max-width: 60ch; }
.badge { display: inline-block; font-size: 0.82rem; font-weight: 600; padding: 3px 11px; border-radius: 999px; background: var(--calc-soft); color: var(--calc); margin-bottom: 12px; }
.badge.conv { background: var(--conv-soft); color: var(--conv); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 26px; margin-bottom: 20px; }
.panel > h2 { font-size: 1.15rem; margin-bottom: 16px; }
.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }

.field { margin-bottom: 20px; }
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.field label, .lbl { font-weight: 600; font-size: 0.95rem; color: var(--ink-2); }
.input { display: inline-flex; align-items: center; background: var(--bg); border: 2px solid transparent; border-radius: var(--radius-s); padding: 0 12px; height: 44px; min-width: 0; }
.input:focus-within { border-color: var(--calc); background: #fff; }
.input input { border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--ink); width: 9ch; min-width: 0; text-align: right; padding: 0 4px; height: 100%; }
.input input:focus { outline: none; }
.input .pre, .input .suf { color: var(--muted); font-weight: 600; }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.input input[type="date"] { width: auto; text-align: left; }
.hint { min-height: 1.3em; margin: 6px 0 0; font-size: 0.85rem; color: var(--muted); text-align: right; }

.slider { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 99px; margin: 0; cursor: pointer;
  background: linear-gradient(to right, var(--calc) var(--p, 0%), var(--track) var(--p, 0%)); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 4px solid var(--calc); box-shadow: 0 2px 6px rgba(14, 26, 48, 0.25); }
.slider::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 4px solid var(--calc); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip, .seg button { font: inherit; font-weight: 600; font-size: 0.9rem; border: 1px solid var(--line); background: #fff; color: var(--ink-2); padding: 6px 14px; border-radius: 999px; cursor: pointer; }
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.seg { display: inline-flex; background: var(--bg); padding: 4px; border-radius: 999px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* results */
.out { background: var(--bg); border-radius: var(--radius-m); padding: 22px; }
.out .empty { color: var(--muted); margin: 0; }
.primary { margin-bottom: 18px; }
.plabel { display: block; font-size: 0.9rem; color: var(--muted); font-weight: 600; }
.pvalue { display: block; font-family: var(--font-display); font-size: clamp(2.1rem, 5vw, 2.8rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; word-break: break-word; }
.rows { margin: 0; }
.rows div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-top: 1px solid var(--line); }
.rows dt { color: var(--muted); }
.rows dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.donut-wrap { display: flex; align-items: center; gap: 20px; margin: 4px 0 18px; }
.donut { flex: none; width: 112px; height: 112px; border-radius: 50%; position: relative; }
.donut::after { content: ""; position: absolute; inset: 24px; border-radius: 50%; background: var(--bg); }
.legend { list-style: none; margin: 0; padding: 0; font-size: 0.9rem; }
.legend li { display: flex; align-items: center; gap: 8px; margin: 4px 0; color: var(--ink-2); }
.legend i { width: 12px; height: 12px; border-radius: 4px; flex: none; }

/* mini calculator groups (percentage page) */
.mini { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: center; }
.sentence { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-weight: 600; color: var(--ink-2); }
.sentence .input input { width: 8ch; }

/* converter */
.conv-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: end; }
.cfield { display: grid; gap: 8px; min-width: 0; }
.cfield .lbl { font-size: 0.85rem; color: var(--muted); }
.cfield input, .cfield select, .cout {
  width: 100%; height: 56px; border-radius: var(--radius-s); border: 2px solid transparent; background: var(--bg);
  font: inherit; font-weight: 650; font-size: 1.25rem; padding: 0 14px; color: var(--ink); font-variant-numeric: tabular-nums; min-width: 0;
}
.cfield input:focus, .cfield select:focus { outline: none; border-color: var(--conv); background: #fff; }
.cfield select { font-size: 0.95rem; font-weight: 600; height: 46px; cursor: pointer; }
.cout { display: flex; align-items: center; background: var(--conv-soft); color: #064e45; overflow-x: auto; white-space: nowrap; }
.swap { width: 46px; height: 46px; margin-bottom: 0; border-radius: 50%; border: 0; background: var(--sun); color: var(--navy); font-size: 1.2rem; font-weight: 700; cursor: pointer; align-self: end; }
.swap:hover { filter: brightness(0.95); }
.formula { margin: 16px 0 0; color: var(--muted); font-size: 0.95rem; }
.formula strong { color: var(--ink); }
.hero-card .cfield input, .hero-card .cout { height: 52px; }
.hero-card .cat { margin-bottom: 14px; }

table.ref { width: 100%; border-collapse: collapse; margin: 14px 0 24px; font-variant-numeric: tabular-nums; }
.ref th, .ref td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); }
.ref thead th { background: var(--bg); font-family: var(--font-display); }
.ref tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.6); }
.table-scroll { overflow-x: auto; }

/* content */
.prose { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 30px; max-width: 100%; }
.prose h2 { margin: 1.6em 0 0.5em; }
.prose h2:first-child { margin-top: 0; }
.prose p, .prose li { max-width: 68ch; }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose code, .formula-box { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; }
.formula-box { background: var(--bg); border-radius: var(--radius-s); padding: 14px 16px; margin: 0 0 1em; overflow-x: auto; font-size: 0.95rem; }
.faq details { border-top: 1px solid var(--line); padding: 14px 0; }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; font-weight: 650; font-family: var(--font-display); font-size: 1.05rem; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.4rem; line-height: 1; color: var(--muted); }
.faq details[open] summary::after { content: "−"; }
.faq details p { margin: 10px 0 0; color: var(--ink-2); }
.notice { font-size: 0.88rem; color: var(--muted); margin-top: 20px; }

/* sidebar */
.side { position: sticky; top: 20px; display: grid; gap: 20px; }
.side-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 18px; }
.side-box h2 { font-size: 1.05rem; margin-bottom: 8px; }
.side-box ul { list-style: none; margin: 0; padding: 0; }
.side-box li a { display: flex; align-items: center; gap: 10px; padding: 9px 0; text-decoration: none; color: var(--ink); font-weight: 550; border-top: 1px solid var(--line); }
.side-box li:first-child a { border-top: 0; }
.side-box li a:hover { color: var(--calc); }
.side-box .glyph { width: 34px; height: 34px; font-size: 0.8rem; border-radius: 9px; }

/* ads: hidden until you switch them on (add class "ads" to <html>) */
.ad { display: none; }
html.ads .ad { display: block; margin: 0 0 20px; min-height: 100px; text-align: center; }
html.ads .ad-side { min-height: 250px; }

/* ---------- Pages, footer ---------- */
.page { padding: 40px 0 80px; max-width: 760px; }
.page h1 { margin-bottom: 20px; }
.page h2 { margin: 1.6em 0 0.5em; }
.page ul { padding-left: 1.2em; }
.cat-list { padding: 8px 0 72px; }
.cat-list > p { color: var(--muted); max-width: 60ch; }

.site-footer { background: var(--navy); color: #b9c5de; padding: 44px 0 32px; font-size: 0.95rem; }
.footer-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr 0.8fr; gap: 32px; }
.site-footer h2 { color: #fff; font-size: 1rem; margin-bottom: 10px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin: 6px 0; }
.site-footer a { color: #b9c5de; text-decoration: none; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.footer-note { border-top: 1px solid #263659; margin-top: 32px; padding-top: 20px; font-size: 0.85rem; color: #8b99b8; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .hero-grid { grid-template-columns: 1fr; gap: 32px; }
  .hero h1 { max-width: 18ch; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tool-layout { grid-template-columns: 1fr; }
  .side { position: static; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 680px) {
  body { font-size: 16px; }
  .hero { padding: 32px 0 84px; }
  .tiles { grid-template-columns: 1fr; }
  .points { grid-template-columns: 1fr; gap: 20px; padding-top: 44px; }
  .calc-grid, .mini { grid-template-columns: 1fr; gap: 20px; }
  .panel, .prose { padding: 20px; border-radius: 18px; }
  .conv-grid { grid-template-columns: 1fr; }
  .swap { justify-self: center; transform: rotate(90deg); }
  .footer-grid { grid-template-columns: 1fr; }
  .nav a { padding: 8px 10px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* result note, category groups */
.out .note-line { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 0.88rem; color: var(--muted); }
.cat-list .group { margin-top: 40px; }
.cat-list .group > p { margin: 6px 0 18px; color: var(--muted); }
.cat-list .group:first-of-type { margin-top: 28px; }
