/* ===== Design tokens ===== */
:root {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.4rem + 2vw, 3rem);

  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem;
  --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem; --space-10: 2.5rem;
  --space-12: 3rem; --space-16: 4rem; --space-20: 5rem; --space-24: 6rem;

  --radius-sm: 0.375rem; --radius-md: 0.5rem; --radius-lg: 0.75rem; --radius-xl: 1rem;
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

:root, [data-theme="light"] {
  --color-bg: #f6f4ef;
  --color-surface: #fbfaf6;
  --color-surface-2: #ffffff;
  --color-surface-offset: #efece5;
  --color-border: #d8d4ca;
  --color-divider: #e4e0d8;
  --color-text: #1f1d18;
  --color-text-muted: #6b6a64;
  --color-text-faint: #a8a59d;

  /* Ottawa = vert forêt (Ontario, Parlement) ; Gatineau = bleu fleuve (drapeau du QC, Gatineau River) */
  --color-ottawa: #2b6147;
  --color-ottawa-light: #d6e3db;
  --color-gatineau: #1c4d80;
  --color-gatineau-light: #d3dfec;

  --color-accent: #b45a1a;       /* terracotta — accent inventaire */
  --color-success: #437a22;
  --color-warning: #b78026;
  --color-error: #a13544;

  --shadow-sm: 0 1px 2px rgba(31, 29, 24, 0.06);
  --shadow-md: 0 4px 14px rgba(31, 29, 24, 0.08);
  --shadow-lg: 0 12px 32px rgba(31, 29, 24, 0.12);
}

[data-theme="dark"] {
  --color-bg: #161513;
  --color-surface: #1d1c1a;
  --color-surface-2: #232220;
  --color-surface-offset: #2a2926;
  --color-border: #393836;
  --color-divider: #2a2927;
  --color-text: #ecebe7;
  --color-text-muted: #9c9b96;
  --color-text-faint: #6a6964;

  --color-ottawa: #6fb592;
  --color-ottawa-light: #2f4a3d;
  --color-gatineau: #6aa3d6;
  --color-gatineau-light: #2a3f54;

  --color-accent: #e89a5e;
  --color-success: #6daa45;
  --color-warning: #e8b056;
  --color-error: #d8636e;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; scroll-behavior: smooth; }
body {
  min-height: 100dvh;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--color-text);
  background: var(--color-bg);
  transition: background var(--transition), color var(--transition);
}
.display { font-family: 'Fraunces', Georgia, serif; font-optical-sizing: auto; }

img, svg { display: block; max-width: 100%; }
button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
a { color: var(--color-ottawa); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--color-ottawa); outline-offset: 3px; border-radius: var(--radius-sm); }

/* ===== Layout ===== */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding-inline: clamp(var(--space-4), 3vw, var(--space-8));
}

header.site {
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-surface);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(8px);
}
.header-row {
  display: flex; align-items: center; justify-content: space-between;
  padding-block: var(--space-4); gap: var(--space-4);
}
.brand {
  display: flex; align-items: center; gap: var(--space-3);
  font-weight: 600; letter-spacing: -0.01em;
}
.brand-mark {
  width: 36px; height: 36px;
}
.brand-text { font-size: var(--text-base); line-height: 1.1; }
.brand-text small { display: block; color: var(--color-text-muted); font-size: var(--text-xs); font-weight: 400; letter-spacing: 0; }
.header-actions { display: flex; align-items: center; gap: var(--space-2); }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition);
}
.icon-btn:hover { background: var(--color-surface-offset); color: var(--color-text); }

main { padding-block: var(--space-8) var(--space-16); }

/* ===== Hero / intro ===== */
.hero {
  display: grid; grid-template-columns: 1fr; gap: var(--space-4);
  margin-bottom: var(--space-8);
}
.eyebrow {
  font-size: var(--text-xs); text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--color-text-muted);
  display: inline-flex; align-items: center; gap: var(--space-2);
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--color-success);
  box-shadow: 0 0 0 0 var(--color-success);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--color-success), transparent 30%); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
h1.title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: var(--text-2xl);
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 500;
  text-wrap: balance;
}
.lede {
  color: var(--color-text-muted);
  max-width: 65ch;
  font-size: var(--text-base);
}

/* ===== Filtres ===== */
.filters {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-6);
  display: flex; flex-wrap: wrap; gap: var(--space-4) var(--space-6);
  align-items: end;
}
.filter-group { display: flex; flex-direction: column; gap: var(--space-2); }
.filter-group label {
  font-size: var(--text-xs); text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--color-text-muted); font-weight: 600;
}
.segmented {
  display: inline-flex; background: var(--color-surface-offset);
  border-radius: var(--radius-md); padding: 3px;
}
.segmented button {
  padding: var(--space-2) var(--space-4);
  border-radius: calc(var(--radius-md) - 2px);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  transition: all var(--transition);
}
.segmented button[aria-pressed="true"] {
  background: var(--color-surface-2);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}
.metric-select {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: var(--text-sm);
  min-width: 200px;
}

/* ===== KPI cards (côte à côte Ottawa / Gatineau) ===== */
.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}
.city-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
}
.city-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.city-card.ottawa::before { background: var(--color-ottawa); }
.city-card.gatineau::before { background: var(--color-gatineau); }
.city-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-4);
}
.city-name { font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.01em; }
.city-meta { font-size: var(--text-xs); color: var(--color-text-muted); }
.kpi-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3) var(--space-4);
}
.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.kpi-value {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.kpi-delta {
  font-size: var(--text-xs);
  display: inline-flex; align-items: center; gap: 3px;
}
.delta-up { color: var(--color-success); }
.delta-down { color: var(--color-error); }
.delta-flat { color: var(--color-text-muted); }

/* ===== Market temperature gauge ===== */
.temp-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-8);
}
.temp-title { font-size: var(--text-lg); font-weight: 600; margin-bottom: var(--space-4); display:flex; align-items:center; gap: var(--space-3); }
.temp-title small { font-size: var(--text-xs); font-weight: 400; color: var(--color-text-muted); letter-spacing:0; text-transform: none; }
.temp-row {
  display: grid; grid-template-columns: 120px 1fr 100px;
  align-items: center; gap: var(--space-4);
  padding-block: var(--space-3);
  border-top: 1px solid var(--color-divider);
}
.temp-row:first-of-type { border-top: none; }
.temp-row .city-label { display:flex; align-items: center; gap: var(--space-2); font-weight: 500; }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.ottawa { background: var(--color-ottawa); }
.dot.gatineau { background: var(--color-gatineau); }
.temp-bar {
  position: relative;
  height: 32px;
  border-radius: var(--radius-md);
  background: linear-gradient(to right,
    color-mix(in oklab, var(--color-error), transparent 70%) 0%,
    color-mix(in oklab, var(--color-warning), transparent 60%) 33%,
    color-mix(in oklab, var(--color-success), transparent 70%) 66%,
    color-mix(in oklab, #2563eb, transparent 70%) 100%);
  overflow: hidden;
}
.temp-bar::before, .temp-bar::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 1px;
  background: var(--color-border);
}
.temp-bar::before { left: 33.33%; }
.temp-bar::after { left: 66.66%; }
.temp-marker {
  position: absolute; top: -4px; bottom: -4px; width: 4px;
  border-radius: 2px;
  box-shadow: 0 0 0 2px var(--color-surface);
}
.temp-marker.ottawa { background: var(--color-ottawa); }
.temp-marker.gatineau { background: var(--color-gatineau); }
.temp-scale {
  display: grid; grid-template-columns: 120px 1fr 100px;
  gap: var(--space-4);
  margin-top: var(--space-3); padding-top: var(--space-3);
  border-top: 1px solid var(--color-divider);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.temp-scale .scale-bar {
  display: grid; grid-template-columns: 1fr 1fr 1fr; text-align: center;
}
.temp-scale .scale-bar span { padding-inline: 4px; }

.temp-value { text-align: right; font-family: 'Fraunces', Georgia, serif; font-size: 1.25rem; }

/* ===== Charts ===== */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}
.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.chart-header {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: var(--space-4); gap: var(--space-3);
}
.chart-title { font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.01em; }
.chart-subtitle { font-size: var(--text-xs); color: var(--color-text-muted); }
.chart-wrap { height: 280px; position: relative; }
.chart-card.span-2 { grid-column: 1 / -1; }
.chart-card.span-2 .chart-wrap { height: 340px; }

.legend {
  display: flex; gap: var(--space-4); margin-top: var(--space-3); flex-wrap: wrap;
  font-size: var(--text-xs); color: var(--color-text-muted);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 14px; height: 8px; border-radius: 2px; }
.legend-swatch.solid-ottawa { background: var(--color-ottawa); }
.legend-swatch.solid-gatineau { background: var(--color-gatineau); }
.legend-swatch.dashed-ottawa {
  background: repeating-linear-gradient(to right, var(--color-ottawa) 0 4px, transparent 4px 7px);
}
.legend-swatch.dashed-gatineau {
  background: repeating-linear-gradient(to right, var(--color-gatineau) 0 4px, transparent 4px 7px);
}

/* ===== Property type breakdown ===== */
.types-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}
.type-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.type-header { font-size: var(--text-base); font-weight: 600; margin-bottom: var(--space-4); }
.type-row {
  display: grid; grid-template-columns: 1fr auto auto;
  gap: var(--space-3); align-items: center;
  padding-block: var(--space-3);
  border-top: 1px solid var(--color-divider);
  font-size: var(--text-sm);
}
.type-row:first-of-type { border-top: none; padding-top: 0; }
.type-row .type-label { color: var(--color-text-muted); }
.type-row .type-price { font-family: 'Fraunces', Georgia, serif; font-weight: 500; }
.type-row .type-moi { font-size: var(--text-xs); color: var(--color-text-muted); white-space: nowrap; }

/* ===== Projections summary ===== */
.projections {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}
.projections h2 {
  font-family: 'Fraunces', Georgia, serif; font-weight: 500;
  font-size: var(--text-xl); letter-spacing: -0.02em;
  margin-bottom: var(--space-2);
}
.projections .lede { margin-bottom: var(--space-5); }
.proj-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
}
.proj-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  background: var(--color-surface-2);
}
.proj-card-head { display:flex; flex-direction: column; gap: 4px; margin-bottom: var(--space-3); }
.proj-city { font-weight: 600; font-size: var(--text-sm); display:flex; align-items:center; gap: var(--space-2); }
.proj-metric { font-size: var(--text-xs); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.proj-now-next {
  display: flex; align-items: baseline; gap: var(--space-3);
}
.proj-now { font-size: var(--text-xs); color: var(--color-text-muted); }
.proj-next {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.5rem; font-weight: 500;
}
.proj-arrow { color: var(--color-text-faint); }

/* ===== Footer ===== */
footer.site {
  border-top: 1px solid var(--color-divider);
  margin-top: var(--space-16);
  padding-block: var(--space-8);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
footer.site .container { display: grid; gap: var(--space-4); grid-template-columns: 1fr auto; align-items: start; }
footer.site h4 { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.1em; color: var(--color-text); margin-bottom: var(--space-2); }
footer.site ul { list-style: none; display: flex; flex-direction: column; gap: 4px; }
footer.site a { color: var(--color-text-muted); }
footer.site a:hover { color: var(--color-text); }
.note {
  background: color-mix(in oklab, var(--color-warning), transparent 88%);
  border-left: 3px solid var(--color-warning);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-3);
}

@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .temp-row { grid-template-columns: 1fr; gap: var(--space-2); }
  .temp-scale { display: none; }
  .chart-wrap { height: 240px; }
  footer.site .container { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== États réactifs aux filtres ===== */

/* KPI mis en évidence par la métrique principale sélectionnée */
.kpi-active .kpi-label {
  color: var(--color-accent);
  font-weight: 700;
}
.kpi-active .kpi-value {
  color: var(--color-accent);
}

/* Ligne de type de propriété sélectionnée */
.type-row-active {
  background: color-mix(in oklab, var(--color-accent), transparent 90%);
  border-radius: var(--radius-sm);
  outline: 1px solid color-mix(in oklab, var(--color-accent), transparent 65%);
  outline-offset: -1px;
}
.type-row-active .type-label {
  color: var(--color-text);
  font-weight: 600;
}

/* Carte de projection correspondant à la métrique sélectionnée */
.proj-card-active {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--color-accent), transparent 80%);
}

/* Note contextuelle — type filtré, graphiques affichent données agrégées */
.filter-note {
  grid-column: 1 / -1;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  background: color-mix(in oklab, var(--color-gatineau), transparent 92%);
  border-left: 3px solid color-mix(in oklab, var(--color-gatineau), transparent 50%);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
}
