/*
 * styles.css — crscalculatorcanada.com
 * Mobile-first, fast, INP/CLS-safe, WCAG 2.2 AA.
 *
 * CLS discipline (Ch.27 §27.5.1): every ad slot reserves min-height BEFORE any
 * fill so a late ad causes zero layout shift. The result panel also reserves
 * space so a recalc never shifts layout (INP/CLS safe).
 * Separation (INV-3 / Ch.27 §27.2): --ad-gap keeps every ad ≥150px from any
 * control or the result, with a visible divider.
 * No framework, no web fonts (system stack → instant LCP, no FOUT).
 */

:root {
  --maple: #c8102e;          /* Canada red accent (brand, not government impersonation) */
  --maple-dark: #9b0c23;
  --ink: #1a1d22;
  --muted: #5a6270;
  --line: #e2e6ec;
  --bg: #ffffff;
  --bg-soft: #f5f7fa;
  --bg-panel: #eef6f0;       /* result panel */
  --ok: #176f3d;
  --warn: #8a5a00;
  --focus: #1558d6;
  --ad-gap: 150px;           /* INV-3: minimum separation between ads and controls/result */
  --radius: 10px;
  --maxw: 820px;
  --shadow: 0 1px 2px rgba(20,29,40,.06), 0 2px 8px rgba(20,29,40,.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 18px; }

/* ── Header ─────────────────────────────────────────────────────────────── */
.site-head {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; padding-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; }
.brand .mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; background: var(--maple); color: #fff; font-weight: 800; }
.site-nav a { color: var(--muted); text-decoration: none; font-size: 15px; margin-left: 16px; }
.site-nav a:hover, .site-nav a:focus-visible { color: var(--ink); }

/* ── Typography ─────────────────────────────────────────────────────────── */
h1 { font-size: 1.85rem; line-height: 1.2; margin: 22px 0 8px; }
h2 { font-size: 1.4rem; line-height: 1.25; margin: 34px 0 10px; }
h3 { font-size: 1.12rem; margin: 22px 0 6px; }
p { margin: 0 0 14px; }
a { color: var(--focus); }
abbr[title] { text-decoration: underline dotted; cursor: help; }
small, .small { font-size: .86rem; color: var(--muted); }
.lede { font-size: 1.06rem; color: var(--muted); }

/* ── Answer block (AEO/GEO extractable) ─────────────────────────────────── */
.answer {
  background: var(--bg-soft);
  border-left: 4px solid var(--maple);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 16px;
  margin: 16px 0 8px;
}
.answer p { margin: 0; }
mark { background: #fff3b0; padding: 0 .18em; border-radius: 3px; font-weight: 700; }

/* ── Calculator ─────────────────────────────────────────────────────────── */
.calc {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow);
  padding: 18px 16px 6px;
  margin: 18px 0;
}
.calc legend, .calc h2 { margin-top: 0; }
fieldset { border: 0; padding: 0; margin: 0 0 6px; }
fieldset + fieldset { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.field { margin: 0 0 14px; }
.field > label, .field > .field-label { display: block; font-weight: 600; margin-bottom: 5px; font-size: .98rem; }
.field .hint { display: block; font-weight: 400; color: var(--muted); font-size: .82rem; margin-top: 2px; }

.grid2 { display: grid; grid-template-columns: 1fr; gap: 14px; }
.abilities { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

select, input[type="number"], input[type="text"] {
  width: 100%;
  font-size: 16px;                 /* ≥16px: no iOS zoom */
  font-family: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid #c3cad6;
  border-radius: 8px;
  padding: 11px 12px;
  min-height: 44px;                /* target size */
}
select:focus-visible, input:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

/* toggles / checkboxes */
.check { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; }
.check input[type="checkbox"] { width: 22px; height: 22px; min-height: 22px; margin-top: 2px; accent-color: var(--maple); }
.check label { font-weight: 500; }

/* radio group (marital status) */
.radios { display: flex; flex-wrap: wrap; gap: 8px; }
.radios label {
  flex: 1 1 auto; min-width: 130px;
  border: 1px solid #c3cad6; border-radius: 8px;
  padding: 11px 12px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 8px; min-height: 44px;
}
.radios input { accent-color: var(--maple); width: 20px; height: 20px; }
.radios label:has(input:checked) { border-color: var(--maple); background: #fdeef0; }

#spouse-block[hidden] { display: none; }

/* ── Result panel (reserved height → no CLS on recalc) ──────────────────── */
.result {
  margin: 18px 0;
  border: 1px solid #cfe3d6;
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 18px 16px;
  min-height: 230px;               /* reserve space: recalc never shifts layout */
}
.score-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.score {
  font-size: 3.1rem; line-height: 1; font-weight: 800; color: var(--maple-dark);
}
.score-unit { font-size: 1rem; color: var(--muted); }
.score-sub { margin: 6px 0 0; color: var(--ink); }
.compare-note { margin-top: 10px; font-size: .96rem; }
.compare-note strong { color: var(--ok); }

/* breakdown definition list */
.breakdown { margin: 14px 0 0; }
.breakdown dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; margin: 0; }
.breakdown dt { color: var(--muted); }
.breakdown dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.breakdown dt.total, .breakdown dd.total { border-top: 1px solid #cfe3d6; padding-top: 6px; margin-top: 4px; font-weight: 800; color: var(--ink); }

/* ── Disclaimer (adjacent to result; anti-YMYL) ─────────────────────────── */
.disclaimer {
  font-size: .85rem; color: var(--muted);
  background: #fff8ec; border: 1px solid #f0e0bf; border-radius: 8px;
  padding: 10px 12px; margin: 12px 0;
}
.disclaimer strong { color: var(--warn); }

/* ── Tables (captioned: points grid + draw history) ─────────────────────── */
.table-wrap { overflow-x: auto; margin: 12px 0 18px; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
caption { text-align: left; font-weight: 700; padding: 8px 0; color: var(--ink); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { background: var(--bg-soft); font-weight: 700; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #fafbfd; }

/* ── Glossary / definition lists ────────────────────────────────────────── */
.glossary dt { font-weight: 700; margin-top: 10px; }
.glossary dd { margin: 2px 0 0; color: var(--ink); }

/* ── FAQ ─────────────────────────────────────────────────────────────────── */
.faq details { border: 1px solid var(--line); border-radius: 8px; padding: 0 14px; margin: 8px 0; }
.faq summary { cursor: pointer; font-weight: 600; padding: 12px 0; }
.faq details[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 10px; }

/* ── Ad slots (reserved height, ≥150px gap, divider) ────────────────────── */
.ad-slot {
  display: block;
  margin: var(--ad-gap) auto;       /* ≥150px separation from neighbouring content */
  min-height: 250px;                /* reserved → zero CLS on fill */
  max-width: 728px;
  background: repeating-linear-gradient(45deg, #f3f5f8, #f3f5f8 12px, #eef1f5 12px, #eef1f5 24px);
  border: 1px dashed #cdd5e0;
  border-radius: 8px;
  display: grid; place-items: center;
  color: #9aa3b2; font-size: .8rem; letter-spacing: .04em; text-transform: uppercase;
}
.ad-slot::before { content: "Advertisement"; }
.ad-divider { border: 0; border-top: 1px solid var(--line); margin: 26px 0 0; }
.ad-slot.in-content { min-height: 280px; }

/* ── Affiliate kicker (after result; visually NOT an ad) ─────────────────── */
.kicker {
  margin: 18px 0;
  border: 1px solid #cdd9ec; background: #f3f7fd; border-radius: var(--radius);
  padding: 14px 16px;
}
.kicker h3 { margin: 0 0 6px; }
.kicker a.cta {
  display: inline-block; margin-top: 6px; background: var(--focus); color: #fff;
  text-decoration: none; font-weight: 700; padding: 11px 18px; border-radius: 8px; min-height: 44px;
}
.kicker .label { font-size: .78rem; color: var(--muted); }

/* ── Generic sections ───────────────────────────────────────────────────── */
section { margin: 8px 0; }
.prose { max-width: 70ch; }
.verified { font-size: .85rem; color: var(--muted); margin: 8px 0 0; }
.sources li { margin-bottom: 6px; }
.related { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 10px 0; padding: 0; list-style: none; }
.related a { display: block; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; text-decoration: none; color: var(--ink); }
.related a:hover { border-color: var(--maple); }

/* prose lists (trust-shell pages) */
.bullets { margin: 10px 0 14px; padding-left: 22px; }
.bullets li { margin-bottom: 8px; }
.steps { margin: 10px 0 14px; padding-left: 22px; }
.steps li { margin-bottom: 8px; }

/* ── Footer ─────────────────────────────────────────────────────────────── */
.site-foot { border-top: 1px solid var(--line); margin-top: 36px; padding: 22px 0 40px; color: var(--muted); font-size: .9rem; }
.site-foot a { color: var(--muted); }
.site-foot .foot-links { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 10px; }

/* ── Consent banner (CMP placeholder) ───────────────────────────────────── */
.consent {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--ink); color: #fff; padding: 14px 16px;
  display: none;
}
.consent.show { display: block; }
.consent .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: space-between; }
.consent p { margin: 0; font-size: .9rem; flex: 1 1 320px; }
.consent a { color: #ffd; }
.consent .btns { display: flex; gap: 10px; }
.consent button {
  font: inherit; font-weight: 700; border: 0; border-radius: 8px; padding: 10px 18px; cursor: pointer; min-height: 44px;
}
#consent-accept { background: var(--maple); color: #fff; }
#consent-reject { background: #4b5360; color: #fff; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (min-width: 640px) {
  body { font-size: 18px; }
  h1 { font-size: 2.2rem; }
  .grid2 { grid-template-columns: 1fr 1fr; }
  .abilities { grid-template-columns: repeat(4, 1fr); }
  .related { grid-template-columns: 1fr 1fr; }
}

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

.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff;
  padding: 10px 14px; border-radius: 0 0 8px 0; z-index: 100;
}
.skip-link:focus { left: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Ad placeholders hidden until AdSense approval — delete this rule when live ad code is added */
.ad-slot{display:none !important}
