/* Student Nutrition Program Canada — design system
   Palette: forest green (primary/trust), harvest orange (warmth/energy/food),
   warm off-white background. Accessible in both light and dark. */

:root {
  --green-900: #123326;
  --green-800: #1a4a37;
  --green-700: #1f6f4e;
  --green-600: #278a62;
  --green-500: #35a878;
  --green-100: #e3f2e9;
  --green-50: #f1f9f4;

  --orange-700: #b85c1e;
  --orange-600: #d97327;
  --orange-500: #e8833a;
  --orange-100: #fce9d7;

  --ink-900: #1c2420;
  --ink-700: #384338;
  --ink-500: #5b665c;
  --ink-300: #90998f;

  --paper-0: #fffdf9;
  --paper-50: #fbf8f2;
  --paper-100: #f3ede1;
  --paper-200: #e8dfcd;

  --blue-600: #2c6e8e;
  --blue-100: #e0eef4;

  --red-600: #b3402f;

  --bg: var(--paper-50);
  --surface: var(--paper-0);
  --surface-raised: #ffffff;
  --border: var(--paper-200);
  --text: var(--ink-900);
  --text-muted: var(--ink-500);
  --link: var(--green-700);
  --link-hover: var(--green-800);
  --focus-ring: #1f6f4e;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(28, 36, 32, 0.06), 0 1px 1px rgba(28, 36, 32, 0.04);
  --shadow-md: 0 8px 24px rgba(28, 36, 32, 0.10);
  --shadow-lg: 0 20px 48px rgba(28, 36, 32, 0.16);

  --container: 1180px;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
}

:root[data-theme="dark"] {
  --bg: #10160f;
  --surface: #171f16;
  --surface-raised: #1d271b;
  --border: #2b382a;
  --text: #eef2ea;
  --text-muted: #a9b6a5;
  --link: #6fd39c;
  --link-hover: #8fe0b3;
  --green-100: #17301f;
  --green-50: #142418;
  --orange-100: #3a2a19;
  --orange-700: #f0a868;
  --blue-100: #16262c;
  --blue-600: #7ec3e0;
  --paper-0: #171f16;
  --paper-50: #141b13;
  --paper-100: #1d271b;
  --paper-200: #2b382a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10160f;
    --surface: #171f16;
    --surface-raised: #1d271b;
    --border: #2b382a;
    --text: #eef2ea;
    --text-muted: #a9b6a5;
    --link: #6fd39c;
    --link-hover: #8fe0b3;
    --green-100: #17301f;
    --green-50: #142418;
    --orange-100: #3a2a19;
    --orange-700: #f0a868;
    --blue-100: #16262c;
    --blue-600: #7ec3e0;
    --paper-0: #171f16;
    --paper-50: #141b13;
    --paper-100: #1d271b;
    --paper-200: #2b382a;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--link); text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
a:hover { color: var(--link-hover); }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 4px;
}
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 0.5em; color: var(--text); }
h1 { font-size: clamp(2rem, 4vw, 3rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h3 { font-size: 1.3rem; }
p { margin: 0 0 1em; }
.container { max-width: var(--container); margin: 0 auto; padding: 0 24px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; background: var(--green-700); color: #fff;
  padding: 10px 16px; border-radius: var(--radius-sm); z-index: 200; transition: top .15s ease;
}
.skip-link:focus { top: 12px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 14px; padding-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--text); }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(160deg, var(--green-600), var(--green-800));
  display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small { font-family: var(--font-body); font-weight: 500; font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }

.main-nav { display: flex; align-items: center; gap: 4px; }
.main-nav a {
  color: var(--text); text-decoration: none; font-weight: 600; font-size: .93rem;
  padding: 8px 12px; border-radius: 999px; white-space: nowrap;
}
.main-nav a:hover, .main-nav a[aria-current="page"] { background: var(--green-100); color: var(--link); }
.nav-toggle {
  display: none; background: none; border: 1px solid var(--border); border-radius: 10px;
  width: 42px; height: 42px; align-items: center; justify-content: center; cursor: pointer; color: var(--text);
}
.theme-toggle {
  background: none; border: 1px solid var(--border); border-radius: 10px; width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text); margin-left: 4px;
}

@media (max-width: 880px) {
  .main-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--surface);
    border-bottom: 1px solid var(--border); flex-direction: column; align-items: stretch; padding: 8px 16px 16px; box-shadow: var(--shadow-md);
  }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 12px 10px; border-radius: 8px; }
  .nav-toggle { display: inline-flex; }
}

/* ---------- Hero ---------- */
.hero { padding: 64px 0 48px; position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: -20% -10% auto -10%; height: 480px;
  background: radial-gradient(60% 100% at 30% 0%, var(--green-100), transparent 70%),
              radial-gradient(50% 90% at 85% 10%, var(--orange-100), transparent 70%);
  z-index: -1;
}
.hero-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px; align-items: center; }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; } }
.eyebrow {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: .78rem;
  letter-spacing: .07em; text-transform: uppercase; color: var(--green-700);
  background: var(--green-100); padding: 6px 12px; border-radius: 999px; margin-bottom: 16px;
}
.hero p.lead { font-size: 1.15rem; color: var(--text-muted); max-width: 52ch; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: .95rem;
  padding: 13px 22px; border-radius: 999px; text-decoration: none; border: 1px solid transparent; cursor: pointer;
}
.btn-primary { background: var(--green-700); color: #fff; }
.btn-primary:hover { background: var(--green-800); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--paper-100); color: var(--text); }
.btn-orange { background: var(--orange-600); color: #fff; }
.btn-orange:hover { background: var(--orange-700); color: #fff; }

/* ---------- Sections / cards ---------- */
section { padding: 56px 0; }
section.tight { padding: 32px 0; }
.section-head { max-width: 62ch; margin-bottom: 32px; }
.section-head .eyebrow { margin-bottom: 10px; }
.section-head p { color: var(--text-muted); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 24px; box-shadow: var(--shadow-sm);
}
.card h3 { margin-bottom: 8px; }
.card p { color: var(--text-muted); margin-bottom: 0; }
.source-card h3 { font-size: 1.05rem; margin-bottom: 12px; }
.source-list { display: flex; flex-direction: column; gap: 10px; }
.source-list a {
  font-size: .92rem; color: var(--text); text-decoration: none; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.source-list a:last-child { border-bottom: none; padding-bottom: 0; }
.source-list a:hover { color: var(--link); }
.card-icon {
  width: 44px; height: 44px; border-radius: 12px; background: var(--green-100); color: var(--green-700);
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 20px; }
.stat-tile .num { font-family: var(--font-display); font-size: 2.1rem; font-weight: 700; color: var(--green-700); line-height: 1; margin-bottom: 6px; }
.stat-tile .label { font-size: .88rem; color: var(--text-muted); }
.stat-tile .src { font-size: .74rem; color: var(--text-muted); margin-top: 8px; }
.stat-tile .src a { color: var(--text-muted); }

.alt-bg { background: var(--paper-100); }

/* ---------- Cartogram map ---------- */
.map-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow-sm); }
.cartogram {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 8px;
  max-width: 620px;
  margin: 0 auto;
}
.carto-cell { grid-column: span 3; aspect-ratio: 1.6; }
.carto-cell.span2 { grid-column: span 2; }
.carto-cell.span4 { grid-column: span 4; }
.carto-tile {
  width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--green-100); color: var(--link); border: 1px solid var(--border); border-radius: 12px;
  text-decoration: none; font-weight: 700; font-size: .8rem; gap: 2px; transition: transform .12s ease, background .12s ease;
}
.carto-tile:hover, .carto-tile:focus-visible { background: var(--green-600); color: #fff; transform: translateY(-2px); }
.carto-tile .code { font-size: 1rem; }
.carto-tile .full { font-size: .62rem; font-weight: 600; opacity: .85; text-align: center; padding: 0 4px; }

/* ---------- Province page ---------- */
.province-hero { background: linear-gradient(160deg, var(--green-800), var(--green-700)); color: #fff; padding: 48px 0; }
.province-hero .eyebrow { background: rgba(255,255,255,.15); color: #fff; }
.province-hero h1 { color: #fff; }
.province-hero p.lead { color: rgba(255,255,255,.85); }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700; padding: 5px 12px; border-radius: 999px; background: var(--orange-100); color: var(--orange-700); }
.badge.verify { background: var(--blue-100); color: var(--blue-600); }
.info-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 24px; }
.info-panel + .info-panel { margin-top: 20px; }
.info-panel h3 { display: flex; align-items: center; gap: 10px; }
.source-note { font-size: .82rem; color: var(--text-muted); border-top: 1px dashed var(--border); margin-top: 16px; padding-top: 12px; }
.source-note a { color: var(--text-muted); }

.contact-card { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 22px; }
.contact-card .prov { font-weight: 700; font-family: var(--font-display); font-size: 1.1rem; }
.contact-card a.phone { font-weight: 700; color: var(--green-700); text-decoration: none; }
.contact-card a.phone:hover { text-decoration: underline; }

table.contact-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
table.contact-table th, table.contact-table td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: .92rem; }
table.contact-table th { background: var(--paper-100); font-family: var(--font-display); }
table.contact-table tr:last-child td { border-bottom: none; }
.table-scroll { overflow-x: auto; border-radius: var(--radius-md); }

/* ---------- Breadcrumb / prose ---------- */
.breadcrumb { font-size: .85rem; color: var(--text-muted); margin-bottom: 18px; }
.breadcrumb a { color: var(--text-muted); }
.prose { max-width: 72ch; }
.prose h2 { margin-top: 1.6em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin-bottom: .5em; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 64px; padding: 48px 0 28px; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 32px; margin-bottom: 32px; }
@media (max-width: 720px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-grid h4 { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-family: var(--font-body); }
.footer-grid ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.footer-grid a { color: var(--text); text-decoration: none; font-size: .92rem; }
.footer-grid a:hover { color: var(--link); }
.footer-bottom { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; border-top: 1px solid var(--border); padding-top: 20px; font-size: .8rem; color: var(--text-muted); }
.disclaimer { font-size: .78rem; color: var(--text-muted); max-width: 70ch; }

/* ---------- Forms ---------- */
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow-sm); max-width: 640px; }
.form-field { margin-bottom: 20px; }
.form-field label { display: block; font-weight: 700; font-size: .88rem; margin-bottom: 6px; }
.form-field .hint { font-size: .78rem; color: var(--text-muted); font-weight: 400; margin-left: 4px; }
.form-field input, .form-field textarea, .form-field select {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 14px;
  background: var(--bg); color: var(--text); font-family: inherit; font-size: .95rem;
}
.form-field input:focus, .form-field textarea:focus, .form-field select:focus { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.form-field textarea { resize: vertical; min-height: 120px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.form-honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-status { margin-top: 16px; padding: 12px 16px; border-radius: var(--radius-sm); font-size: .9rem; display: none; }
.form-status.show { display: block; }
.form-status.success { background: var(--green-100); color: var(--green-800); }
.form-status.error { background: var(--orange-100); color: var(--orange-700); }
.form-submit { display: inline-flex; align-items: center; gap: 8px; }
.form-submit[disabled] { opacity: .6; cursor: not-allowed; }

/* ---------- Chatbot widget ---------- */
#snp-chat-launcher {
  position: fixed; bottom: 22px; right: 22px; z-index: 300;
  width: 60px; height: 60px; border-radius: 50%; background: var(--green-700); color: #fff;
  border: none; box-shadow: var(--shadow-lg); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
#snp-chat-launcher:hover { background: var(--green-800); }
#snp-chat-panel {
  position: fixed; bottom: 96px; right: 22px; z-index: 300; width: min(370px, calc(100vw - 32px));
  height: min(520px, calc(100vh - 140px)); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); display: none; flex-direction: column; overflow: hidden;
}
#snp-chat-panel.open { display: flex; }
.snp-chat-head { background: var(--green-700); color: #fff; padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.snp-chat-head strong { font-family: var(--font-display); font-size: 1.02rem; }
.snp-chat-head span { font-size: .74rem; opacity: .85; display: block; }
.snp-chat-close { background: rgba(255,255,255,.15); border: none; color: #fff; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; }
.snp-chat-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--paper-50); }
:root[data-theme="dark"] .snp-chat-body { background: var(--bg); }
.snp-msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: .9rem; line-height: 1.45; }
.snp-msg.bot { background: var(--surface); border: 1px solid var(--border); align-self: flex-start; border-bottom-left-radius: 4px; }
.snp-msg.user { background: var(--green-700); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.snp-msg.typing { display: inline-flex; gap: 4px; align-items: center; }
.snp-msg.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); animation: snp-bounce 1.1s infinite ease-in-out; }
.snp-msg.typing span:nth-child(2) { animation-delay: .15s; }
.snp-msg.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes snp-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
.snp-chat-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 12px; }
.snp-chat-suggest button { font-size: .76rem; background: var(--green-100); color: var(--link); border: none; padding: 6px 10px; border-radius: 999px; cursor: pointer; }
.snp-chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: var(--surface); }
.snp-chat-form input { flex: 1; border: 1px solid var(--border); border-radius: 999px; padding: 10px 16px; background: var(--bg); color: var(--text); font-size: .9rem; }
.snp-chat-form button { background: var(--green-700); color: #fff; border: none; width: 42px; height: 42px; border-radius: 50%; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.snp-chat-note { font-size: .68rem; color: var(--text-muted); text-align: center; padding: 0 16px 10px; }

@media (max-width: 480px) {
  #snp-chat-panel { right: 12px; left: 12px; width: auto; bottom: 88px; }
  #snp-chat-launcher { right: 16px; bottom: 16px; }
}
