/* ═══════════════════════════════════════════════════
   Canadian Money Guide — Design System (Shared)
   Fraunces + DM Sans · cream / forest · maple accents
═══════════════════════════════════════════════════ */

:root {
  --bg:           #F9F8F4;
  --bg-card:      #FFFFFF;
  --bg-tint:      #F0F4F1;
  --bg-dark:      #0D2318;
  --text:         #18181A;
  --muted:        #6A6A65;
  --green:        #1B4733;
  --green-mid:    #296049;
  --green-light:  #3A8A68;
  --maple:        #C84528;
  --maple-dark:   #A53720;
  --gold:         #C8912A;
  --border:       #E4E1D8;
  --border-mid:   #CAC7BF;
  --r:            9px;
  --display:      'Fraunces', Georgia, serif;
  --body:         'DM Sans', system-ui, sans-serif;
  --max:          1240px;
  --content-max:  780px;
  --t:            0.22s ease;
  --c1: #C8912A;
  --c2: #1B4733;
  --c3: #2E4F7A;
  --c4: #1A6B7A;
  --c5: #3A3080;
  --c6: #7A2E42;
}

[data-theme="dark"] {
  --bg:          #0B160E;
  --bg-card:     #131F16;
  --bg-tint:     #0F1A12;
  --text:        #EDE8DF;
  --muted:       #96968D;
  --green:       #38875F;
  --green-mid:   #4CAD7A;
  --green-light: #5DC98E;
  --border:      #1E3326;
  --border-mid:  #28463A;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  transition: background var(--t), color var(--t);
  overflow-x: hidden;
}

/* ─── GRAIN ─── */
.grain {
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.4'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 9999;
  opacity: 0.028; mix-blend-mode: multiply;
}
[data-theme="dark"] .grain { mix-blend-mode: screen; opacity: 0.022; }

/* ─── NAV ─── */
nav {
  position: sticky; top: 0; z-index: 200;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--max); margin: 0 auto;
  padding: 0 28px; height: 64px;
  display: flex; align-items: center; gap: 6px;
}
.logo {
  font-family: var(--display); font-size: 18px; font-weight: 500;
  color: var(--green); text-decoration: none;
  white-space: nowrap; flex-shrink: 0;
  margin-right: 16px; letter-spacing: -0.01em;
}
.logo:hover { text-decoration: none; }
.logo-maple { color: var(--maple); }
.logo-icon { display: inline; }
.logo:hover .logo-icon { opacity: 0.8; }

.nav-links { display: flex; list-style: none; flex: 1; gap: 0; }
.nav-links a {
  font-size: 13.5px; font-weight: 500;
  color: var(--muted); text-decoration: none;
  padding: 6px 12px; border-radius: 6px;
  transition: color var(--t), background var(--t);
}
.nav-links a:hover { color: var(--green); background: var(--bg-tint); }

.nav-end { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-shrink: 0; }

.btn-ghost {
  background: none; border: 1.5px solid var(--border);
  border-radius: 20px; padding: 5px 14px; cursor: pointer;
  font-family: var(--body); font-size: 12.5px; color: var(--muted);
  transition: all var(--t);
}
.btn-ghost:hover { border-color: var(--green); color: var(--green); }

.btn-maple {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--maple); color: #fff;
  font-family: var(--body); font-size: 14px; font-weight: 600;
  padding: 9px 20px; border-radius: var(--r);
  text-decoration: none; border: none; cursor: pointer;
  transition: background var(--t), transform var(--t), box-shadow var(--t);
  box-shadow: 0 1px 3px rgba(200,69,40,0.3);
}
.btn-maple:hover {
  background: var(--maple-dark); transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(200,69,40,0.35);
}

.btn-outline {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; color: var(--green);
  border: 1.5px solid var(--green);
  font-family: var(--body); font-size: 14px; font-weight: 600;
  padding: 9px 20px; border-radius: var(--r);
  text-decoration: none; cursor: pointer; transition: all var(--t);
}
.btn-outline:hover { background: var(--bg-tint); transform: translateY(-1px); }

.hamburger { display: none; background: none; border: none; cursor: pointer; padding: 8px; color: var(--text); font-size: 20px; line-height: 1; }

.mobile-menu { display: none; flex-direction: column; background: var(--bg-card); border-bottom: 1px solid var(--border); padding: 12px 0; }
.mobile-menu.open { display: flex; }
.mobile-menu a { font-size: 15px; font-weight: 500; color: var(--text); text-decoration: none; padding: 12px 28px; border-bottom: 1px solid var(--border); transition: color var(--t); }
.mobile-menu a:last-child { border: none; }
.mobile-menu a:hover { color: var(--green); }

/* ─── SCROLL-TO-TOP ─── */
#scrolltop {
  position: fixed; bottom: 28px; right: 28px;
  width: 42px; height: 42px;
  background: var(--green); color: #fff; border: none; border-radius: 50%;
  font-size: 18px; cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.3s, transform 0.3s;
  opacity: 0; transform: translateY(12px);
  pointer-events: none; z-index: 300;
}
#scrolltop.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
#scrolltop:hover { background: var(--green-mid); }

/* ─── CONTENT MAIN ─── */
.content-main {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 48px 28px 72px;
}

/* ─── TYPOGRAPHY ─── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--display);
  color: var(--text);
  line-height: 1.3;
}
h1 { font-size: 2.6rem; font-weight: 500; margin-bottom: 1rem; letter-spacing: -0.02em; }
h2 { font-size: 1.6rem; font-weight: 500; margin: 3rem 0 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); letter-spacing: -0.01em; }
h3 { font-size: 1.2rem; font-weight: 500; margin: 2rem 0 0.6rem; }
h4 { font-size: 1rem; font-weight: 600; font-family: var(--body); margin: 1.5rem 0 0.5rem; }

p { margin-bottom: 1rem; }
a { color: var(--maple); text-decoration: underline; text-underline-offset: 3px; transition: color var(--t); }
a:hover { color: var(--maple-dark); }

strong { font-weight: 600; }
em { font-style: italic; }

ul, ol { margin: 0.5rem 0 1rem 1.5rem; }
li { margin-bottom: 0.4rem; }

blockquote {
  border-left: 4px solid var(--maple);
  background: var(--bg-tint);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  border-radius: 0 var(--r) var(--r) 0;
  font-style: italic;
  color: var(--muted);
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

img { max-width: 100%; height: auto; border-radius: var(--r); }

/* ─── BREADCRUMB ─── */
.breadcrumb {
  font-size: 0.82rem; color: var(--muted);
  margin-bottom: 1.5rem;
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--green); }
.breadcrumb span { color: var(--text); }

/* ─── PAGE META ─── */
.page-meta {
  display: flex; align-items: center; gap: 0.75rem;
  flex-wrap: wrap; margin-bottom: 1.5rem;
}
.last-updated, .reading-time {
  display: inline-block;
  font-size: 0.8rem; font-weight: 500;
  color: var(--muted);
  background: var(--bg-tint);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.methodology-link {
  font-size: 0.8rem; font-weight: 500;
  color: var(--muted); text-decoration: none;
  border-bottom: 1px dashed var(--border-mid);
  transition: color var(--t), border-color var(--t);
}
.methodology-link:hover { color: var(--maple); border-color: var(--maple); }

/* ─── AFFILIATE DISCLOSURE ─── */
.affiliate-disclosure {
  font-size: 0.8rem; color: var(--muted);
  background: var(--bg-tint);
  padding: 0.6rem 1rem; border-radius: var(--r);
  margin-bottom: 1.5rem;
  border-left: 3px solid var(--border);
  line-height: 1.5;
}

/* ─── TOC ─── */
.toc {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r); padding: 0;
  margin-bottom: 2rem; overflow: hidden;
}
.toc-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background: var(--bg-tint); cursor: pointer; user-select: none;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 0.85rem; color: var(--text);
  transition: background var(--t);
}
.toc-header:hover { background: var(--border); }
.toc-header::after { content: '▾'; font-size: 0.75rem; transition: transform var(--t); color: var(--muted); }
.toc.collapsed .toc-header { border-bottom: none; }
.toc.collapsed .toc-header::after { transform: rotate(-90deg); }
.toc-body { padding: 0.75rem 1.25rem; }
.toc.collapsed .toc-body { display: none; }
.toc-body ol { list-style: decimal; margin: 0; padding-left: 1.5rem; }
.toc-body li { margin-bottom: 0.35rem; font-size: 0.88rem; }
.toc-body a { color: var(--muted); text-decoration: none; transition: color var(--t); }
.toc-body a:hover { color: var(--maple); }

/* ─── SUMMARY BOX ─── */
.summary-box {
  background: linear-gradient(135deg, var(--bg-tint), var(--bg-card));
  border: 1px solid var(--border);
  border-left: 4px solid var(--maple);
  border-radius: 0 var(--r) var(--r) 0;
  padding: 1.25rem 1.5rem; margin-bottom: 2rem;
}
.summary-box h4 {
  margin: 0 0 0.5rem; font-family: var(--body);
  font-size: 0.8rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--maple);
}
.summary-box ul { margin: 0; padding-left: 1.25rem; }
.summary-box li { font-size: 0.9rem; color: var(--muted); }

/* ─── CALLOUT ─── */
.callout {
  background: var(--bg-tint);
  border-left: 4px solid var(--maple);
  padding: 1.25rem 1.5rem; margin: 2rem 0;
  border-radius: 0 var(--r) var(--r) 0;
  font-size: 0.9rem; color: var(--muted); line-height: 1.6;
}
.callout strong { color: var(--text); }

/* ─── TABLES ─── */
.table-wrapper {
  overflow-x: auto; margin: 1.5rem 0 2rem;
  border-radius: var(--r); box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  border: 1px solid var(--border);
}
table {
  width: 100%; border-collapse: collapse;
  font-size: 0.88rem; background: var(--bg-card);
}
thead th {
  background: var(--green); color: #fff;
  font-family: var(--body); font-weight: 600;
  font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.8rem 0.9rem; text-align: left;
  white-space: nowrap;
}
thead th:first-child { border-radius: var(--r) 0 0 0; }
thead th:last-child { border-radius: 0 var(--r) 0 0; }
tbody td { padding: 0.75rem 0.9rem; border-bottom: 1px solid var(--border); color: var(--text); }
tbody tr:nth-child(even) td { background: var(--bg-tint); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(196,69,40,0.04); }

tr.row--top-pick td {
  background: linear-gradient(90deg, rgba(27,71,51,0.06), transparent);
  border-left: 4px solid var(--green);
  font-weight: 500;
}
tr.row--top-pick td:first-child::before {
  content: 'Top Pick';
  display: inline-block;
  font-size: 0.62rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--green);
  background: rgba(27,71,51,0.08);
  padding: 0.15rem 0.5rem; border-radius: 4px;
  margin-right: 0.5rem; vertical-align: middle;
}

@media (max-width: 768px) {
  table { font-size: 0.8rem; }
  thead th { padding: 0.55rem 0.6rem; font-size: 0.66rem; }
  tbody td { padding: 0.5rem 0.6rem; }
  .table-wrapper::after {
    content: '← scroll →'; display: block; text-align: center;
    font-size: 0.7rem; color: var(--muted); padding: 0.5rem 0 0;
  }
}

/* ─── BUTTONS ─── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.65rem 1.5rem;
  background: var(--maple); color: #fff;
  text-decoration: none; border: none; border-radius: var(--r);
  font-family: var(--body); font-weight: 600; font-size: 0.9rem;
  cursor: pointer; transition: all var(--t);
  box-shadow: 0 2px 8px rgba(200,69,40,0.2);
}
.btn-primary:hover { background: var(--maple-dark); box-shadow: 0 4px 14px rgba(200,69,40,0.3); text-decoration: none; color: #fff; }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.65rem 1.5rem;
  background: var(--bg-card); color: var(--green);
  text-decoration: none; border: 1.5px solid var(--border);
  border-radius: var(--r); font-family: var(--body); font-weight: 600; font-size: 0.9rem;
  cursor: pointer; transition: all var(--t);
}
.btn-secondary:hover { border-color: var(--green); background: var(--bg-tint); text-decoration: none; }

/* ─── WIDGET / CALCULATOR ─── */
.widget, .calculator {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r); padding: 2rem;
  margin: 2rem 0; box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.widget h2, .widget h3, .calculator h2, .calculator h3 {
  margin-top: 0; font-family: var(--display); border: none;
}
.widget label, .calculator label {
  display: block; font-weight: 600; font-size: 0.88rem;
  color: var(--muted); margin-bottom: 0.35rem;
}
.widget select, .widget input, .calculator select, .calculator input,
input[type="email"], input[type="text"], textarea {
  width: 100%; padding: 0.65rem 0.85rem;
  border: 1px solid var(--border); border-radius: var(--r);
  font-size: 0.95rem; font-family: var(--body);
  background: var(--bg); color: var(--text);
  transition: border-color var(--t), box-shadow var(--t);
  margin-bottom: 0.75rem;
}
.widget select:focus, .widget input:focus, .calculator input:focus,
input:focus, textarea:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(27,71,51,0.1);
}

.calc-row {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 0.75rem; flex-wrap: wrap;
}
.calc-row label { flex: 1; font-weight: 500; min-width: 160px; }
.calc-row input { width: 200px; }

.widget .btn, .calculator .btn {
  display: block; width: 100%;
  padding: 0.8rem;
  background: var(--maple); color: #fff;
  border: none; border-radius: var(--r);
  font-family: var(--body); font-size: 1rem; font-weight: 600;
  cursor: pointer; margin-top: 0.5rem;
  transition: all var(--t);
}
.widget .btn:hover, .calculator .btn:hover { background: var(--maple-dark); }

.calc-result {
  margin-top: 1.5rem; padding: 2rem;
  background: var(--bg-card); border: 2px solid var(--green);
  border-radius: var(--r); text-align: center;
  position: relative; overflow: hidden;
}
.calc-result::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--green), #4CAD7A, var(--green));
}
.calc-result .result-badge {
  display: inline-block; font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--green); background: rgba(27,71,51,0.08);
  padding: 0.2rem 0.7rem; border-radius: 999px; margin-bottom: 0.75rem;
}
.calc-result .result-label { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.25rem; }
.calc-result .total {
  font-size: 2.5rem; font-weight: 700;
  font-family: var(--display); color: var(--green);
  margin: 0.25rem 0; line-height: 1.2;
}
.calc-result .breakdown { font-size: 0.88rem; color: var(--muted); margin-top: 0.5rem; }
.calc-result .result-actions { margin-top: 1.25rem; display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }
.calc-result .result-footer {
  margin-top: 1.25rem; padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem; color: var(--muted);
}

.widget .result {
  margin-top: 1.5rem; padding: 1.25rem;
  background: rgba(27,71,51,0.05);
  border-radius: var(--r); text-align: center;
}

/* ─── RELATED GUIDES ─── */
.related-guides { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--border); }
.related-guides h4 {
  font-family: var(--body); font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin-bottom: 1rem;
}
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem; }
.related-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r); padding: 1rem;
  text-decoration: none; transition: all var(--t);
}
.related-card:hover { border-color: var(--green); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.related-card strong { display: block; color: var(--text); margin-bottom: 0.25rem; font-size: 0.9rem; }
.related-card span { font-size: 0.8rem; color: var(--muted); }

/* ─── FEEDBACK WIDGET ─── */
.feedback-widget {
  margin-top: 3rem; padding: 1.5rem 2rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r); text-align: center;
}
.feedback-question { font-weight: 600; font-size: 0.9rem; color: var(--text); margin: 0 0 0.75rem; }
.feedback-buttons { display: flex; gap: 0.75rem; justify-content: center; }
.feedback-btn {
  padding: 0.5rem 1.25rem;
  background: var(--bg-tint); border: 1px solid var(--border);
  border-radius: var(--r); font-size: 0.88rem;
  font-family: var(--body); font-weight: 500; cursor: pointer;
  transition: all var(--t); color: var(--muted); min-height: 44px;
}
.feedback-btn:hover { border-color: var(--maple); color: var(--maple); }
.feedback-btn.voted { border-color: var(--green); background: rgba(27,71,51,0.08); color: var(--green); pointer-events: none; }
.feedback-thanks { margin: 0.75rem 0 0; font-size: 0.82rem; color: var(--green); font-weight: 500; }

/* ─── FOOTER ─── */
footer {
  background: #0B2017;
  color: rgba(255,255,255,0.6);
  padding: 80px 28px 40px;
  margin-top: 0;
}
[data-theme="dark"] footer { background: #05100A; }
.footer-inner { max-width: var(--max); margin: 0 auto; }
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 56px;
  padding-bottom: 56px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.foot-brand .logo { color: #fff; font-size: 20px; display: block; margin-bottom: 18px; text-decoration: none; }
.foot-brand .logo:hover { color: rgba(255,255,255,0.8); }
.foot-brand p { font-size: 13.5px; line-height: 1.7; max-width: 280px; margin-bottom: 20px; }
.foot-disclaimer { font-size: 11.5px; opacity: 0.4; line-height: 1.65; max-width: 280px; }
.foot-col h5 {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: rgba(255,255,255,0.3); margin-bottom: 20px;
}
.foot-col ul { list-style: none; display: flex; flex-direction: column; gap: 11px; }
.foot-col a { font-size: 14px; color: rgba(255,255,255,0.57); text-decoration: none; transition: color var(--t); }
.foot-col a:hover { color: #fff; }
.footer-bottom {
  padding-top: 26px; display: flex;
  justify-content: space-between; align-items: center;
  font-size: 12px; opacity: 0.32;
}

/* ─── AD SLOTS ─── */
.ad-slot-wrap { max-width: var(--content-max); margin: 0 auto; padding: 0 28px; }
.ad-slot {
  background: var(--bg-tint);
  border: 1px dashed var(--border);
  border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  min-height: 90px; margin: 2rem 0; overflow: hidden;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 1000px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 36px; }
}
@media (max-width: 768px) {
  .content-main { padding: 32px 20px 56px; }
  h1 { font-size: 1.9rem; }
  h2 { font-size: 1.35rem; margin: 2rem 0 0.75rem; }
  h3 { font-size: 1.1rem; }
  .page-meta { gap: 0.5rem; }
  .calc-result .result-actions { flex-direction: column; }
  .calc-result .total { font-size: 2rem; }
}
@media (max-width: 640px) {
  .nav-links { display: none; }
  .hamburger { display: block; }
  .footer-grid { grid-template-columns: 1fr; gap: 32px; }
  .footer-bottom { flex-direction: column; gap: 8px; text-align: center; }
}

/* ─── PRINT ─── */
@media print {
  nav, footer, .grain, #scrolltop, .ad-slot-wrap, .feedback-widget, .toc-header { display: none !important; }
  body { font-size: 12pt; background: #fff; color: #000; }
  .content-main { max-width: 100%; padding: 0; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #666; }
  a[href^="/"]::after { content: " (https://canadianmoneyguide.ca" attr(href) ")"; font-size: 0.8em; color: #666; }
  a[href^="#"]::after, .nav-links a::after { content: none; }
}
