/* Loanweek — one stylesheet. Tokens and rules: DESIGN.md */
:root {
  --ink: #1B2327;
  --muted: #4A5A58;
  --paper: #FFFFFF;
  --tint: #EEF3EF;
  --rule: #C3CEC7;
  --principal: #1565A6;
  --interest: #B8435A;
  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, "Noto Serif", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px;
  --radius: 3px;
  --gutter: 16px;
  color-scheme: light;
}
@media (min-width: 768px) { :root { --gutter: 24px; } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 1rem/1.5 var(--sans);
  font-variant-numeric: lining-nums tabular-nums;
}
a { color: var(--principal); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--principal); outline-offset: 2px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: var(--gutter); top: var(--s2); background: var(--paper); padding: var(--s2); z-index: 10; }

h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.2; margin: var(--s6) 0 var(--s3); }
h1 { font-size: 1.953rem; margin-top: var(--s3); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; font-family: var(--sans); margin-top: var(--s5); }
@media (min-width: 768px) { h1 { font-size: 2.441rem; } h2 { font-size: 1.563rem; } }
p, ul { max-width: 68ch; }
.lede { font-size: 1.125rem; color: var(--ink); }
.fine, .sub { color: var(--muted); font-size: 0.9rem; }
.sub { font-weight: 400; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9rem; }
pre.code { background: var(--tint); padding: var(--s4); overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.formula { font-family: var(--serif); font-size: 1.25rem; }

/* header / footer */
header.site, footer.site { padding: var(--s4) max(var(--gutter), calc((100% - 1120px) / 2 + var(--gutter))); }
header.site { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s4); border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.wordmark { font-family: var(--serif); font-weight: 700; font-size: 1.25rem; color: var(--ink); text-decoration: none; }
header.site nav { display: flex; gap: var(--s3); }
@media (min-width: 600px) { header.site nav { gap: var(--s4); } }
header.site nav a { color: var(--ink); }
footer.site { border-top: 1px solid var(--rule); margin-top: var(--s8); color: var(--muted); font-size: 0.9rem; }
footer.site nav { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); margin-top: var(--s3); }
footer.site .promise { font-family: var(--serif); color: var(--ink); font-size: 1rem; }

/* page grid */
.page { padding: 0 var(--gutter); max-width: 1120px; margin: 0 auto; }
main { min-width: 0; }
@media (min-width: 1024px) {
  .page { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--s7); }
  .page--single { grid-template-columns: minmax(0, 760px); }
  .rail { padding-top: 88px; }
}
.crumbs ol { list-style: none; padding: 0; margin: var(--s4) 0 0; display: flex; flex-wrap: wrap; gap: var(--s1) var(--s2); font-size: 0.9rem; color: var(--muted); }
.crumbs li + li::before { content: "/"; margin-right: var(--s2); color: var(--rule); }

/* answer block */
.answer { background: var(--tint); padding: var(--s5) var(--s4); margin: var(--s4) 0 var(--s5); }
@media (min-width: 768px) { .answer { padding: var(--s5) var(--s6); } }
.answer p { margin: var(--s2) 0; }
.answer__figures { display: flex; flex-wrap: wrap; gap: var(--s4) var(--s7); align-items: flex-end; }
.answer__main, .answer__side { margin: 0; }
.fig { font-family: var(--serif); font-weight: 700; font-size: clamp(2.441rem, 8vw, 3.052rem); line-height: 1.15; }
.fig--interest { font-size: clamp(1.563rem, 5vw, 1.953rem); color: var(--interest); }
.per { font-size: 1.125rem; margin-left: var(--s1); }
.label { display: block; color: var(--muted); font-size: 0.9rem; }
.split { display: block; width: 100%; height: 6px; margin: var(--s4) 0 var(--s2); }
.key { display: inline-block; width: 10px; height: 10px; margin: 0 var(--s1) 0 0; vertical-align: -1px; }
.key--p { background: var(--principal); }
.key--i { background: var(--interest); margin-left: var(--s2); }
.answer__rate { font-size: 1rem; }
.answer__source { font-size: 0.9rem; color: var(--muted); }
.answer--home .fig { font-size: clamp(2.441rem, 9vw, 3.815rem); }

/* rate cards */
.ratecards { display: grid; gap: 0; grid-template-columns: 1fr; border-top: 1px solid var(--rule); }
@media (min-width: 600px) { .ratecards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .ratecards:not(.ratecards--2) { grid-template-columns: 1fr 1fr 1fr; } }
.ratecard { padding: var(--s4) var(--s4) var(--s4) 0; border-bottom: 1px solid var(--rule); }
.answer .ratecards { border-top: 0; }
.ratecard p { margin: 0; }
.ratecard__label { color: var(--muted); font-size: 0.9rem; }
.ratecard__value { font-family: var(--serif); font-weight: 700; font-size: 2.441rem; line-height: 1.15; }
.ratecard__meta { font-size: 0.9rem; }

/* tables */
.table-scroll { overflow-x: auto; margin: var(--s3) 0; -webkit-overflow-scrolling: touch; }
.table-scroll:focus-visible { outline-offset: 0; }
.table-scroll--tall { max-height: 70vh; overflow-y: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
caption { text-align: left; color: var(--muted); font-size: 0.9rem; padding: 0 0 var(--s2); caption-side: top; }
th, td { padding: var(--s2) var(--s3); border-bottom: 1px solid var(--rule); vertical-align: top; }
thead th { background: var(--tint); font-weight: 600; text-align: right; white-space: nowrap; position: sticky; top: 0; }
thead th:first-child { text-align: left; }
tbody th, tfoot th { text-align: left; font-weight: 400; }
table.num td { text-align: right; white-space: nowrap; }
table.num td.text { text-align: left; white-space: normal; min-width: 14ch; }
tfoot th, tfoot td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--ink); }
tr.mark th, tr.mark td { font-weight: 700; background: var(--tint); }
tr.dim th, tr.dim td { color: var(--muted); }
table.compact th, table.compact td { padding: var(--s1) var(--s3); }
table.sticky tbody th, table.sticky thead th:first-child { position: sticky; left: 0; background: var(--paper); z-index: 1; }
table.sticky thead th:first-child { background: var(--tint); z-index: 2; }
table.breakdown { max-width: 520px; }
table.plainlist th, table.plainlist td { padding: var(--s1) 0; }
table.plainlist td { padding-left: var(--s3); }
.hubtable { max-width: 480px; }
@media (max-width: 600px) {
  table { font-size: 0.875rem; }
  th, td { padding: 6px 6px; }
  thead th { white-space: normal; vertical-align: bottom; }
  tbody th .sub { display: block; }
  .table-scroll table.num tbody th, .table-scroll table.num tfoot th, .table-scroll table.num thead th:first-child { position: sticky; left: 0; background: var(--paper); z-index: 1; }
  .table-scroll table.num thead th:first-child { background: var(--tint); z-index: 2; }
  .table-scroll table.num tr.mark th { background: var(--tint); }
  table.compact th, table.compact td { padding: 3px 6px; }
}

/* charts: text sizes live here so phones get larger labels in the same SVG */
.chart-wrap { margin: var(--s4) 0; }
.chart { display: block; max-width: 720px; height: auto; font-family: var(--sans); }
.chart text { font-size: 12px; }
.chart .lg { font-size: 13px; }
@media (max-width: 600px) {
  .chart text { font-size: 19px; }
  .chart .lg { font-size: 20px; }
}

/* forms */
label { font-size: 0.9rem; font-weight: 600; }
input, select, button { font: inherit; border-radius: var(--radius); }
input, select { border: 1px solid var(--muted); padding: var(--s2); background: var(--paper); color: var(--ink); min-height: 44px; }
button, .button { background: var(--principal); color: #fff; border: 1px solid var(--principal); padding: var(--s2) var(--s4); min-height: 44px; cursor: pointer; text-decoration: none; display: inline-block; border-radius: var(--radius); }
button:hover, .button:hover { background: #0F4F86; }
.inline-form { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); align-items: center; margin: var(--s3) 0; }
.calc { display: grid; gap: var(--s3) var(--s4); grid-template-columns: 1fr; margin: var(--s4) 0; max-width: 720px; }
@media (min-width: 600px) { .calc { grid-template-columns: 1fr 1fr; } }
.calc .field { display: flex; flex-direction: column; gap: var(--s1); }
.calc button { justify-self: start; align-self: end; }
.search { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-top: var(--s4); }
.search input { flex: 1 1 220px; }

/* lists, faq, related, sources */
.plain { padding-left: 1.1em; }
.plain li { margin: var(--s2) 0; }
.plain--big li { font-size: 1.125rem; }
.faq details { border-bottom: 1px solid var(--rule); padding: var(--s3) 0; max-width: 68ch; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: var(--s2) 0 0; }
.related h2 { font-size: 1rem; font-family: var(--sans); margin: var(--s5) 0 var(--s2); }
.related ul { list-style: none; padding: 0; margin: 0; }
.related li { padding: var(--s1) 0; }
.related--inline ul { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); }
.sources ul { padding-left: 1.1em; font-size: 0.9rem; }
.sources li { margin: var(--s2) 0; }
details.full { margin: var(--s4) 0; }
details.full summary { cursor: pointer; font-weight: 600; padding: var(--s2) 0; }
.columns { display: grid; gap: 0 var(--s7); grid-template-columns: 1fr; }
@media (min-width: 768px) { .columns { grid-template-columns: 1fr 1fr; } }
.columns-list { columns: 2 16em; }
.embed-preview { border: 1px solid var(--rule); max-width: 100%; }

/* ads & affiliate: never above the answer; space reserved so nothing shifts */
.ad { margin: var(--s5) 0; min-height: 280px; display: flex; flex-direction: column; }
.ad--rail { min-height: 600px; position: sticky; top: var(--s4); }
.ad__label { font-size: 0.75rem; color: var(--muted); }
.ad ins { display: block; flex: 1; }
.affiliate { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: var(--s4) 0; margin: var(--s5) 0; }
.affiliate__disclosure { font-size: 0.9rem; color: var(--muted); margin-top: 0; }
.affiliate__partner { color: var(--muted); font-size: 0.9rem; margin-left: var(--s3); }

/* consent */
.consent { position: fixed; left: 0; right: 0; bottom: 0; background: var(--paper); border-top: 2px solid var(--ink); padding: var(--s4) var(--gutter); z-index: 20; display: flex; flex-wrap: wrap; gap: var(--s3) var(--s5); align-items: center; }
.consent[hidden] { display: none; }
.consent p { margin: 0; flex: 1 1 280px; }
.consent__buttons { display: flex; gap: var(--s3); }
.consent__buttons button { min-width: 110px; }
.consent__buttons button[data-consent-choice="reject"] { background: var(--paper); color: var(--principal); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media print {
  header.site nav, footer.site nav, .ad, .affiliate, .consent, form, .rail, .skip, .crumbs { display: none !important; }
  body { color: #000; font-size: 11pt; }
  .page { display: block; max-width: none; padding: 0; }
  .answer { background: none; border: 1px solid #000; }
  a { color: #000; text-decoration: none; }
  .table-scroll, .table-scroll--tall { overflow: visible; max-height: none; }
  details > *:not(summary) { display: block !important; }
  details summary { list-style: none; }
  thead th, table.sticky tbody th { position: static; background: none; }
  tr { break-inside: avoid; }
}
