/* === Canadian Money Guide — Modern Design System === */

:root {
  /* Palette */
  --red: #c41e3a;
  --red-dark: #9b1730;
  --red-light: #fef2f4;
  --green: #1b7a4a;
  --green-dark: #145c37;
  --green-light: #ecfdf5;
  --navy: #0f172a;
  --navy-light: #1e293b;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Semantic */
  --color-bg: #fafbfc;
  --color-surface: #ffffff;
  --color-text: var(--gray-800);
  --color-text-muted: var(--gray-500);
  --color-heading: var(--navy);
  --color-primary: var(--red);
  --color-primary-dark: var(--red-dark);
  --color-accent: var(--green);
  --color-link: var(--red);
  --color-border: var(--gray-200);
  --color-border-light: #e8ecf1;

  /* Layout */
  --max-width: 800px;
  --nav-height: 62px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --font-serif: Georgia, 'Times New Roman', serif;
}

/* === Dark Mode === */
[data-theme="dark"] {
  --color-bg: #0f1117;
  --color-surface: #1a1d27;
  --color-text: #e2e4e9;
  --color-text-muted: #8b8fa3;
  --color-heading: #f0f0f5;
  --color-border: #2a2d3a;
  --color-border-light: #222530;
  --red-light: #2d151a;
  --green-light: #152d22;
  --gray-50: #1a1d27;
  --gray-100: #222530;
  --navy: #e2e4e9;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow: 0 4px 12px rgba(0,0,0,0.35);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.4);
}

[data-theme="dark"] img {
  opacity: 0.9;
}

[data-theme="dark"] .site-nav {
  background: rgba(15, 17, 23, 0.92);
  border-bottom-color: var(--color-border);
}

[data-theme="dark"] .nav-toggle span {
  background: var(--color-text);
}

[data-theme="dark"] .nav-links a:hover {
  background: rgba(196, 30, 58, 0.15);
}

[data-theme="dark"] .hero {
  background: linear-gradient(160deg, #0f1117 0%, #1a1116 40%, #0f1117 100%);
  border-bottom-color: var(--color-border);
}

[data-theme="dark"] .site-footer {
  background: #090b10;
}

[data-theme="dark"] .ad-slot {
  background: var(--gray-50);
  border-color: var(--color-border);
}

/* Theme toggle button */
.theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.05rem;
  transition: all var(--transition);
  margin-left: 0.75rem;
  flex-shrink: 0;
  color: var(--color-text);
}
.theme-toggle:hover {
  background: var(--gray-100);
  border-color: var(--color-primary);
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 17px;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + 1rem);
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === Typography === */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  color: var(--color-heading);
  line-height: 1.3;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 2.4rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

h2 {
  font-size: 1.65rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--color-border-light);
}

h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 1.75rem 0 0.6rem;
}

h4 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.25rem 0 0.5rem;
}

p { margin-bottom: 1rem; }

a {
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: color var(--transition);
}
a:hover { color: var(--color-primary-dark); }

strong { font-weight: 600; color: var(--gray-800); }

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

blockquote {
  border-left: 4px solid var(--red);
  background: var(--red-light);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  color: var(--gray-600);
}

hr {
  border: none;
  height: 1px;
  background: linear-gradient(to right, var(--gray-200), transparent);
  margin: 2.5rem 0;
}

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

/* === Navigation === */
.site-nav {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border-light);
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
}

.nav-inner {
  max-width: 1150px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 1.5rem;
  position: relative;
}

.logo {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--navy);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  letter-spacing: -0.01em;
  transition: color var(--transition);
}
.logo:hover { color: var(--color-primary); }

.nav-links {
  display: flex;
  list-style: none;
  gap: 0.25rem;
  margin: 0;
}

.nav-links a {
  display: block;
  padding: 0.4rem 0.8rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--gray-600);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.nav-links a:hover {
  color: var(--color-primary);
  background: var(--red-light);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  flex-direction: column;
  gap: 5px;
  padding: 6px;
  border-radius: var(--radius-sm);
}
.nav-toggle:hover { background: var(--gray-100); }
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--gray-700);
  border-radius: 1px;
  transition: transform var(--transition);
}

/* Mobile nav */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    padding: 0.75rem 0;
    gap: 0;
    box-shadow: var(--shadow-lg);
    margin: 0;
    z-index: 99;
  }
  .nav-links.open a {
    padding: 0.65rem 1.5rem;
    border-radius: 0;
  }
  .nav-toggle { display: flex; }
}

/* === Main Content Area === */
.site-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem;
}

/* === Byline === */
.byline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border-light);
}
.byline strong { color: var(--gray-700); }
.byline .reviewer { font-style: italic; }

/* === Hero (Homepage) === */
.hero {
  text-align: center;
  padding: 4rem 1.5rem 3rem;
  margin: -2.5rem -1.5rem 2.5rem;
  background: linear-gradient(160deg, #fafbfc 0%, #fef2f4 40%, #fafbfc 100%);
  border-bottom: 1px solid var(--color-border-light);
}

.hero h1 {
  font-size: 2.8rem;
  font-weight: 800;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
  color: var(--navy);
}

.hero p {
  font-size: 1.2rem;
  color: var(--gray-500);
  max-width: 620px;
  margin: 0 auto 2rem;
  line-height: 1.6;
}

.hero .cta-group {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.hero .cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.8rem 2rem;
  background: var(--color-primary);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 1rem;
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(196, 30, 58, 0.25);
}
.hero .cta-btn:hover {
  background: var(--red-dark);
  box-shadow: 0 4px 16px rgba(196, 30, 58, 0.35);
  transform: translateY(-1px);
}

.hero .cta-btn.secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border: 2px solid var(--color-border);
  box-shadow: none;
}
.hero .cta-btn.secondary:hover {
  border-color: var(--color-primary);
  background: var(--red-light);
  transform: translateY(-1px);
}

@media (max-width: 768px) {
  .hero { padding: 2.5rem 1rem 2rem; }
  .hero h1 { font-size: 2rem; }
  .hero p { font-size: 1.05rem; }
  .hero .cta-group { flex-direction: column; align-items: center; }
  .hero .cta-btn { width: 100%; max-width: 320px; justify-content: center; }
}

/* === Hub Grid === */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0 2rem;
}

.hub-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.hub-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-primary);
  transform: scaleX(0);
  transition: transform var(--transition);
}
.hub-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--color-border);
  transform: translateY(-2px);
}
.hub-card:hover::before { transform: scaleX(1); }

.hub-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}
.hub-card h3 a {
  color: var(--color-heading);
  text-decoration: none;
  font-family: var(--font-sans);
}
.hub-card h3 a:hover { color: var(--color-primary); }
.hub-card p {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.55;
}

/* === Card (generic content card) === */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow-sm);
}

.card--featured {
  border-left: 4px solid var(--color-primary);
  background: linear-gradient(135deg, #fff 0%, var(--red-light) 100%);
}

.card--green {
  border-left: 4px solid var(--color-accent);
  background: linear-gradient(135deg, #fff 0%, var(--green-light) 100%);
}

/* === Callout / Disclaimer === */
.callout {
  background: var(--red-light);
  border-left: 4px solid var(--color-primary);
  padding: 1.25rem 1.5rem;
  margin: 2rem 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.9rem;
  color: var(--gray-600);
  line-height: 1.6;
}
.callout strong { color: var(--navy); }

/* Disclaimer callout variant */
.callout--disclaimer {
  background: #fffbeb;
  border-left-color: #f59e0b;
}

/* === Tables === */
.table-wrapper {
  overflow-x: auto;
  margin: 1.25rem 0 1.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border-light);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th {
  background: var(--gray-50);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500);
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 2px solid var(--color-border);
}

td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--color-border-light);
  color: var(--gray-700);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

tr.highlight td {
  background: #fffbeb;
  font-weight: 500;
}
tr.highlight:hover td { background: #fef3c7; }

/* === Widget Styles (HISA widget) === */
.widget {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin: 2rem 0;
  box-shadow: var(--shadow-sm);
}

.widget h2, .widget h3 {
  margin-top: 0;
  text-align: center;
  font-family: var(--font-sans);
  border: none;
}

.widget label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--gray-700);
  margin-bottom: 0.4rem;
}

.widget select, .widget input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  margin-bottom: 1rem;
  background: var(--color-surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  color: var(--gray-800);
}
.widget select:focus, .widget input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(196, 30, 58, 0.1);
}

.widget .btn {
  display: block;
  width: 100%;
  padding: 0.85rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: all var(--transition);
}
.widget .btn:hover { background: var(--red-dark); }

.widget .result {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--green-light);
  border-radius: var(--radius);
  text-align: center;
}
.widget .result h4 {
  margin-top: 0;
  color: var(--color-accent);
  font-family: var(--font-sans);
}
.widget .result .cta-btn {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.65rem 1.5rem;
  background: var(--color-accent);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  transition: background var(--transition);
}
.widget .result .cta-btn:hover { background: var(--green-dark); }

/* === Emergency Fund Calculator === */
.calculator {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin: 2rem 0;
  box-shadow: var(--shadow-sm);
}

.calculator h2, .calculator h3 {
  margin-top: 0;
  font-family: var(--font-sans);
  border: none;
}

.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;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.calc-row input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(196, 30, 58, 0.1);
}

.calc-result {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--red-light) 0%, #fff 100%);
  border: 2px solid var(--red);
  border-radius: var(--radius);
  text-align: center;
}
.calc-result .total { font-size: 2.25rem; font-weight: 800; color: var(--color-primary); }
.calc-result .breakdown { font-size: 0.85rem; color: var(--color-text-muted); margin-top: 0.5rem; }

/* === Quick Picks Box === */
.quick-picks {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow-sm);
}

.quick-picks > h2, .quick-picks > h3 {
  margin-top: 0;
  font-family: var(--font-sans);
  border: none;
}

.quick-picks .pick {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border-light);
}
.quick-picks .pick:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.pick-label {
  display: inline-block;
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: 0.06em;
  background: var(--red-light);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  margin-bottom: 0.3rem;
}

/* === Article List (homepage popular articles) === */
.article-list {
  list-style: none;
  margin: 0.5rem 0 1.5rem;
}
.article-list li {
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--color-border-light);
}
.article-list li:last-child { border-bottom: none; }
.article-list a {
  font-weight: 500;
  text-decoration: none;
  color: var(--gray-800);
  transition: color var(--transition);
}
.article-list a:hover { color: var(--color-primary); }
.article-list .article-desc {
  display: block;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
}

/* === Badge === */
.badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--green-light);
  color: var(--color-accent);
  margin-right: 0.4rem;
}

.badge--new {
  background: var(--red-light);
  color: var(--red);
}

/* === Footer === */
.site-footer {
  background: var(--navy);
  color: #cbd5e1;
  padding: 3rem 1.5rem 1.5rem;
  margin-top: 4rem;
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 2.5rem;
}

.footer-col h4 {
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 1rem;
  font-weight: 600;
}

.footer-col p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #94a3b8;
}

.footer-col ul { list-style: none; margin: 0; }
.footer-col li { margin-bottom: 0.4rem; }

.footer-col a {
  font-size: 0.88rem;
  color: #94a3b8;
  text-decoration: none;
  transition: color var(--transition);
}
.footer-col a:hover { color: #fff; }

.footer-col .disclaimer {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 1rem;
  line-height: 1.6;
}
.footer-col .disclaimer strong { color: #94a3b8; }

.footer-bottom {
  max-width: 1100px;
  margin: 2rem auto 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--navy-light);
  text-align: center;
  font-size: 0.8rem;
  color: #64748b;
}

@media (max-width: 768px) {
  .footer-inner { grid-template-columns: 1fr; gap: 1.5rem; }
}

/* === Print === */
@media print {
  .site-nav, .site-footer, .widget, .calculator, .hero { display: none; }
  body { font-size: 13px; background: #fff; color: #000; }
  .site-main { max-width: 100%; padding: 0; }
}

/* === Utility === */
.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); font-size: 0.9rem; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 2rem; }
.mb-2 { margin-bottom: 2rem; }

/* === Selection === */
::selection {
  background: rgba(196, 30, 58, 0.15);
  color: var(--navy);
}

/* === Ad Slots === */
.ad-slot {
  background: var(--gray-50);
  border: 1px dashed var(--gray-200);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  margin: 2rem 0;
  overflow: hidden;
}

.ad-slot--banner {
  min-height: 90px;
  max-height: 110px;
}

.ad-slot--incontent {
  min-height: 250px;
}

.ad-slot::before {
  content: 'Advertisement';
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-400);
}

/* Hide placeholder label once ad loads */
.ad-slot ins {
  position: absolute;
  inset: 0;
}
.ad-slot:has(ins)::before { display: none; }

/* Sticky mobile footer ad */
.ad-sticky-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--color-border);
  padding: 0.75rem 1rem;
  z-index: 50;
  display: flex;
  justify-content: center;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}
.ad-sticky-footer.visible {
  transform: translateY(0);
}
.ad-sticky-footer .ad-close {
  position: absolute;
  top: 4px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--gray-400);
  padding: 4px 8px;
}

@media (min-width: 769px) {
  .ad-sticky-footer { display: none; }
  .ad-slot--mobile-only { display: none; }
}
