/* ============================================================================
   carbonmonoxidedetectors.ca — Design System v2.0
   Fortune-100 caliber: refined typography, layered depth, tactile motion
   ============================================================================ */

:root {
  /* ===== Color System ===== */
  --ink-900: #0b1220;
  --ink-800: #111827;
  --ink-700: #1e293b;
  --ink-600: #334155;
  --ink-500: #475569;
  --ink-400: #64748b;
  --ink-300: #94a3b8;
  --ink-200: #cbd5e1;
  --ink-100: #e2e8f0;
  --ink-50:  #f1f5f9;
  --ink-25:  #f8fafc;

  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-light: #dbeafe;
  --danger: #dc2626;
  --danger-dark: #991b1b;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --success: #059669;

  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-sunken: var(--ink-50);

  /* ===== Typography ===== */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", Menlo, Monaco, Consolas, "Courier New", monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.5rem;
  --fs-3xl: clamp(1.75rem, 4vw, 2.25rem);
  --fs-4xl: clamp(2rem, 5vw, 3rem);
  --fs-hero: clamp(2.25rem, 5.5vw, 3.5rem);
  --lh-tight: 1.2;
  --lh-snug: 1.45;
  --lh-base: 1.65;
  --lh-relaxed: 1.75;
  --tracking-tight: -0.02em;
  --tracking-normal: 0;
  --tracking-wide: 0.025em;
  --tracking-wider: 0.05em;

  /* ===== Spacing ===== */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;

  /* ===== Radii ===== */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 9999px;

  /* ===== Shadows — layered, soft, depth-accurate ===== */
  --shadow-xs: 0 1px 2px rgba(15,23,42,0.05);
  --shadow-sm: 0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md: 0 4px 12px rgba(15,23,42,0.07), 0 2px 4px rgba(15,23,42,0.04);
  --shadow-lg: 0 10px 30px rgba(15,23,42,0.08), 0 4px 12px rgba(15,23,42,0.05);
  --shadow-xl: 0 20px 50px rgba(15,23,42,0.12), 0 8px 20px rgba(15,23,42,0.06);
  --shadow-inner: inset 0 1px 2px rgba(15,23,42,0.04);

  /* ===== Motion ===== */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 0.15s;
  --dur: 0.25s;
  --dur-slow: 0.4s;

  /* ===== Layout ===== */
  --max-w: 1160px;
  --max-w-narrow: 760px;
  --header-h: 76px;
  --radius: var(--r-md);

  /* ===== Z-Index Scale ===== */
  --z-base: 1;
  --z-sticky: 100;
  --z-overlay: 200;
  --z-modal: 300;
}

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

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

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--ink-800);
  background: var(--ink-25);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
}

h1, h2, h3, h4, h5 {
  font-weight: 700;
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--ink-900);
  margin: 0;
}

h1 { font-size: var(--fs-hero); font-weight: 800; }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
p { margin: 0; color: var(--ink-500); line-height: var(--lh-relaxed); }
ul, ol { padding-left: 1.25rem; color: var(--ink-500); }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
a:hover { color: var(--accent-dark); text-decoration: underline; }
a:active { color: var(--accent-dark); }

img { max-width: 100%; height: auto; display: block; }

::selection { background: var(--accent-light); color: var(--ink-900); }

/* ===== Layout ===== */
.container { width: min(92%, var(--max-w)); margin: 0 auto; }
.container-narrow { width: min(90%, var(--max-w-narrow)); margin: 0 auto; }

/* ===== Skip Link (Accessibility) ===== */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  z-index: var(--z-modal);
  background: var(--ink-900);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: var(--fs-sm);
  transition: top var(--dur) var(--ease-out);
}
.skip-link:focus { top: var(--space-4); color: #fff; text-decoration: none; }

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--ink-100);
  transition: box-shadow var(--dur) var(--ease-out);
}
.site-header.scrolled { box-shadow: var(--shadow-sm); }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  gap: var(--space-4);
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-weight: 800;
  font-size: var(--fs-lg);
  color: var(--ink-900);
  text-decoration: none;
  letter-spacing: var(--tracking-tight);
  flex-shrink: 0;
}
.logo:hover { text-decoration: none; color: var(--ink-900); }
.logo-img { height: 48px; width: auto; border-radius: var(--r-sm); object-fit: contain; }

/* Nav */
.site-nav ul {
  list-style: none;
  display: flex;
  gap: 2px;
  align-items: center;
}

.site-nav a {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--ink-600);
  text-decoration: none;
  transition: all var(--dur-fast) var(--ease-out);
  position: relative;
}
.site-nav a:hover { background: var(--ink-50); color: var(--ink-900); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-light); }

/* Hamburger */
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-sm);
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--ink-700);
  padding: 0.35rem 0.55rem;
  line-height: 1;
  transition: background var(--dur-fast) var(--ease-out);
}
.nav-toggle:hover { background: var(--ink-50); }

/* ===== Hero ===== */
.hero {
  background: linear-gradient(180deg, var(--surface) 0%, var(--ink-25) 100%);
  padding: var(--space-8) 0 var(--space-7);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(37,99,235,0.04) 0%, transparent 70%);
  pointer-events: none;
}
.hero .container { position: relative; }

.hero h1 {
  margin: var(--space-5) 0 var(--space-3);
  max-width: 800px;
}
.hero p.lead {
  font-size: var(--fs-lg);
  color: var(--ink-500);
  max-width: 680px;
  margin-bottom: var(--space-6);
  line-height: var(--lh-base);
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface);
  color: var(--ink-600);
  padding: 0.375rem 0.875rem;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  border: 1px solid var(--ink-200);
  box-shadow: var(--shadow-xs);
}

/* ===== Search ===== */
.search-bar {
  display: flex;
  gap: var(--space-2);
  max-width: 640px;
  margin: var(--space-5) 0 var(--space-7);
  position: relative;
}
.search-bar input {
  flex: 1;
  padding: 0.875rem 1.25rem;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  font-family: var(--font-sans);
  background: var(--surface);
  color: var(--ink-800);
  transition: border var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.search-bar input::placeholder { color: var(--ink-300); }
.search-bar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(37,99,235,0.12);
}
.search-bar .btn { padding: 0.875rem 1.5rem; }
#search-results { margin-bottom: var(--space-5); }

/* ===== Main ===== */
main { padding: var(--space-7) 0; }

.section-title {
  font-size: var(--fs-2xl);
  font-weight: 800;
  margin-bottom: var(--space-5);
  color: var(--ink-900);
}
.section-title::after {
  content: '';
  display: block;
  width: 48px;
  height: 3px;
  background: var(--accent);
  border-radius: var(--r-full);
  margin-top: var(--space-2);
}

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
  margin-bottom: var(--space-5);
  transition: box-shadow var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
  border: 1px solid var(--ink-100);
  position: relative;
}
.card:hover { box-shadow: var(--shadow-lg); }

.card h2 { margin-bottom: var(--space-3); }
.card h3 { margin-bottom: var(--space-2); }
.card p { margin-bottom: var(--space-3); }
.card p:last-child { margin-bottom: 0; }
.card ul { margin-bottom: var(--space-3); }
.card > ul > li { margin-bottom: var(--space-2); }

/* ===== Grid ===== */
.grid { display: grid; gap: var(--space-5); }
.grid > .card { margin-bottom: 0; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: var(--ink-900);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: var(--fs-sm);
  border: 1px solid var(--ink-900);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--dur-fast) var(--ease-out);
  font-family: var(--font-sans);
  letter-spacing: var(--tracking-wide);
  white-space: nowrap;
}
.btn:hover {
  background: var(--ink-700);
  text-decoration: none;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: var(--ink-700);
}
.btn:active { transform: translateY(0); }
.btn-red { background: var(--danger); border-color: var(--danger); }
.btn-red:hover { background: var(--danger-dark); border-color: var(--danger-dark); }
.btn-outline { background: transparent; color: var(--ink-700); border: 1px solid var(--ink-200); }
.btn-outline:hover { background: var(--ink-50); color: var(--ink-900); border-color: var(--ink-300); }
.btn-sm { padding: 0.5rem 1rem; font-size: var(--fs-xs); }

/* ===== Province Cards ===== */
.province-card {
  border-left: 3px solid var(--ink-300);
  display: block;
  text-decoration: none;
  color: inherit;
  transition: all var(--dur) var(--ease-out);
}
.province-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-left-color: var(--accent);
  text-decoration: none;
  color: inherit;
}
.province-card h3 { color: var(--ink-900); margin-bottom: var(--space-2); }
.province-card p { font-size: var(--fs-sm); }
.province-card .code {
  display: inline-block;
  background: var(--ink-50);
  color: var(--ink-500);
  font-weight: 800;
  padding: 0.125rem 0.5rem;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  margin-bottom: var(--space-2);
  letter-spacing: var(--tracking-wide);
}

/* ===== Product Cards ===== */
.product-card {
  border-left: 3px solid var(--ink-200);
  display: flex;
  flex-direction: column;
}
.product-card:hover { border-left-color: var(--accent); }
.product-card .meta { color: var(--ink-400); font-size: var(--fs-sm); margin: 0 0 var(--space-3); }
.product-card .why { font-size: var(--fs-sm); color: var(--ink-500); font-style: italic; margin: var(--space-2) 0; }
.product-card .btn { margin-top: auto; align-self: flex-start; }

/* ===== Tags ===== */
.tag {
  display: inline-block;
  background: var(--ink-50);
  color: var(--ink-500);
  padding: 0.2rem 0.6rem;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: 600;
  margin-right: var(--space-1);
  margin-bottom: var(--space-1);
  border: 1px solid var(--ink-100);
}
.tag-accent { background: var(--accent-light); color: var(--accent-dark); border-color: var(--accent-light); }

/* ===== Disclosure ===== */
.affiliate-disclosure {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--r-md);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-5);
  font-size: var(--fs-sm);
  color: var(--ink-600);
  border-left: 4px solid var(--warn);
}

/* ===== Resource List ===== */
.resource-list { list-style: none; padding: 0; margin: 0; }
.resource-list li {
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--ink-50);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
}
.resource-list li:last-child { border-bottom: none; }
.resource-list .meta { color: var(--ink-400); font-size: var(--fs-sm); }

/* ===== FAQ ===== */
.faq details {
  background: var(--surface);
  border: 1px solid var(--ink-100);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-3);
  transition: all var(--dur) var(--ease-out);
}
.faq details[open] { box-shadow: var(--shadow-md); border-color: var(--ink-200); }
.faq summary {
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  color: var(--ink-900);
  font-size: var(--fs-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: '+';
  font-size: var(--fs-2xl);
  font-weight: 300;
  color: var(--ink-300);
  line-height: 1;
  transition: transform var(--dur) var(--ease-out);
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { margin-top: var(--space-3); }

/* ===== Alert ===== */
.alert-box {
  background: var(--ink-50);
  border-left: 4px solid var(--ink-400);
  border-radius: var(--r-md);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-5);
}
.alert-box strong { color: var(--ink-900); }
.alert-box.alert-danger { border-left-color: var(--danger); background: #fef2f2; }
.alert-box.alert-danger strong { color: var(--danger-dark); }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); border: 1px solid var(--ink-100); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td { text-align: left; padding: 0.875rem 1rem; border-bottom: 1px solid var(--ink-50); }
th {
  background: var(--ink-50);
  font-weight: 700;
  color: var(--ink-700);
  text-transform: uppercase;
  font-size: var(--fs-xs);
  letter-spacing: var(--tracking-wider);
}
tbody tr:hover { background: var(--ink-25); }
tbody tr:last-child td { border-bottom: none; }

/* ===== Breadcrumbs (visible) ===== */
.breadcrumbs {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  font-size: var(--fs-sm);
  color: var(--ink-400);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
  list-style: none;
  padding: 0;
}
.breadcrumbs li { display: flex; gap: var(--space-2); align-items: center; }
.breadcrumbs li::after { content: '/'; color: var(--ink-200); font-weight: 400; }
.breadcrumbs li:last-child::after { display: none; }
.breadcrumbs a { color: var(--ink-500); font-weight: 600; }
.breadcrumbs a:hover { color: var(--accent); text-decoration: none; }
.breadcrumbs li[aria-current="page"] { color: var(--ink-400); font-weight: 600; }

/* ===== Footer ===== */
.site-footer {
  background: var(--ink-900);
  color: var(--ink-300);
  padding: var(--space-8) 0 var(--space-6);
  margin-top: var(--space-8);
  font-size: var(--fs-sm);
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-7);
  flex-wrap: wrap;
  padding-bottom: var(--space-6);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.footer-brand { display: flex; align-items: flex-start; gap: var(--space-4); max-width: 520px; }
.footer-logo { height: 48px; width: auto; border-radius: var(--r-sm); }
.footer-brand p { color: var(--ink-400); margin-top: var(--space-2); line-height: var(--lh-base); }
.footer-brand strong { color: var(--ink-100); font-size: var(--fs-base); display: block; }
.footer-nav { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); align-items: center; max-width: 400px; }
.footer-nav a { color: var(--ink-300); font-weight: 500; font-size: var(--fs-sm); text-decoration: none; }
.footer-nav a:hover { color: #fff; text-decoration: none; }
.site-footer .disclaimer {
  color: var(--ink-400);
  margin-top: var(--space-5);
  font-size: var(--fs-xs);
  line-height: var(--lh-base);
  max-width: 700px;
}

/* ===== Skeleton Loading ===== */
.skeleton {
  background: linear-gradient(90deg, var(--ink-50) 25%, var(--ink-100) 50%, var(--ink-50) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-sm);
  height: 1em;
  margin-bottom: var(--space-2);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Animations ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeInUp var(--dur-slow) var(--ease-out) both; }

/* ===== Focus States (Accessibility) ===== */
a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ===== Misc ===== */
.disclaimer { font-size: var(--fs-sm); color: var(--ink-400); margin-top: var(--space-4); }
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--ink-50);
  padding: 0.15em 0.4em;
  border-radius: var(--r-sm);
  color: var(--ink-700);
}

/* ===== Mobile ===== */
@media (max-width: 768px) {
  .nav-toggle { display: flex; align-items: center; justify-content: center; }
  .site-nav {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--ink-100);
    padding: var(--space-2) 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--dur) var(--ease-out);
  }
  .site-nav.open { max-height: 480px; }
  .site-nav ul { flex-direction: column; align-items: stretch; gap: 0; }
  .site-nav a { padding: var(--space-3) var(--space-5); border-radius: 0; font-size: var(--fs-base); border-bottom: 1px solid var(--ink-50); }
  .site-nav a:last-child { border-bottom: none; }
  
  .footer-inner { flex-direction: column; gap: var(--space-5); }
  .footer-brand { max-width: 100%; }
  .footer-nav { max-width: 100%; }
  
  .search-bar { flex-direction: column; }
  .search-bar .btn { width: 100%; }
  
  .hero { padding: var(--space-6) 0 var(--space-5); }
  .card { padding: var(--space-5); }
  
  h1 { font-size: var(--fs-3xl); }
  h2 { font-size: var(--fs-xl); }
}

/* ===== Print ===== */
@media print {
  .site-header, .site-footer, .nav-toggle, .search-bar, .badge { display: none; }
  body { background: white; }
  .card { box-shadow: none; border: 1px solid var(--ink-200); break-inside: avoid; }
  a { color: var(--ink-900); text-decoration: underline; }
}