/* =====================================================================
   Saans — base: reset, typography, layout shell, header, footer.
   Mobile-first. No external fonts.
   ===================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: var(--leading);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color var(--dur-slow) var(--ease-calm), color var(--dur-slow) var(--ease-calm);
}

img, svg { display: block; max-width: 100%; }
svg { overflow: visible; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: var(--leading-tight);
  letter-spacing: -0.005em;
  margin: 0 0 var(--space-4);
  text-wrap: balance;
}
h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-2); }
h4, .h4 { font-size: var(--step-1); }
.h3 { font-size: var(--step-2); }

p, ul, ol, dl { margin: 0 0 var(--space-4); }
p { text-wrap: pretty; }
li + li { margin-top: var(--space-2); }

a {
  color: var(--primary);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}
a:hover { color: var(--primary-hover); text-decoration-thickness: 0.14em; }

strong { font-weight: 650; }
small { font-size: var(--step--1); }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-6) 0; }

/* Focus: always visible, never colour-only (2px ring + offset + halo) */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px var(--focus-halo);
  border-radius: var(--radius-s);
}
main:focus-visible { box-shadow: none; outline: none; }

.skip-link {
  position: absolute;
  inset-inline-start: var(--space-4);
  top: -100px;
  z-index: 100;
  padding: var(--space-3) var(--space-4);
  background: var(--primary);
  color: var(--on-primary);
  border-radius: var(--radius-s);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: var(--space-3); color: var(--on-primary); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.page {
  flex: 1 0 auto;
  width: 100%;
  max-width: 68rem;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-7);
}
.page--narrow { max-width: 44rem; }
.prose { max-width: var(--measure); }
.prose > * + h2 { margin-top: var(--space-7); }
.prose > * + h3 { margin-top: var(--space-6); }
.lede { font-size: var(--step-1); color: var(--text-muted); max-width: var(--measure); }
.muted { color: var(--text-muted); }
.stack > * + * { margin-top: var(--space-4); }

@media (min-width: 48rem) {
  .page { padding: var(--space-7) var(--space-6) var(--space-8); }
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.site-header__inner {
  max-width: 68rem;
  margin: 0 auto;
  padding: var(--space-2) var(--space-4);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap);
  color: var(--text);
  text-decoration: none;
  margin-inline-end: auto;
}
.brand:hover { color: var(--text); }
.brand__mark { width: 30px; height: 30px; }
.brand__halo { fill: var(--breath-in); opacity: 0.55; }
.brand__core { fill: var(--breath-out); }
.brand__name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.01em;
}

.support-pill {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  color: var(--text);
  text-decoration: none;
  font-size: var(--step--1);
  font-weight: 600;
  background: var(--surface);
}
.support-pill:hover { color: var(--text); border-color: var(--primary); }
.support-pill[aria-current="page"] { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }

.nav-toggle {
  display: none;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--step--1);
  cursor: pointer;
}
.nav-toggle__bars, .nav-toggle__bars::before, .nav-toggle__bars::after {
  display: block;
  width: 16px; height: 2px;
  background: currentColor;
  border-radius: 2px;
  position: relative;
  transition: transform var(--dur-ui) var(--ease-calm);
}
.nav-toggle__bars::before, .nav-toggle__bars::after { content: ""; position: absolute; left: 0; }
.nav-toggle__bars::before { top: -5px; }
.nav-toggle__bars::after { top: 5px; }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars::before { transform: translateY(5px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars::after { transform: translateY(-5px) rotate(-45deg); }

.site-nav { width: 100%; }
.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0 0 var(--space-2);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
}
.site-nav li + li { margin-top: 0; }
.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  color: var(--text);
  text-decoration: none;
}
.site-nav a:hover { background: var(--bg-soft); color: var(--text); }
.site-nav a[aria-current="page"] {
  background: var(--bg-soft);
  font-weight: 650;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.35em;
}

/* JS-enhanced collapsible nav on small screens. The .js class is set
   synchronously in <head>, so the collapsed state is correct on first paint
   (no layout shift). Without JS the full list shows. */
.js .nav-toggle { display: inline-flex; }
.js .site-nav { display: none; }
.js .site-nav[data-collapsed="false"] { display: block; }
.js .site-nav ul { flex-direction: column; align-items: stretch; }
.js .site-nav a { width: 100%; }

@media (min-width: 52rem) {
  .site-header__inner { flex-wrap: nowrap; padding: var(--space-2) var(--space-6); }
  .site-nav, .js .site-nav, .js .site-nav[data-collapsed] { display: block; width: auto; order: 2; }
  .site-nav ul, .js .site-nav ul { flex-direction: row; padding: 0; }
  .js .site-nav a { width: auto; }
  .support-pill { order: 3; }
  .nav-toggle { display: none !important; }
}

/* ---------- Footer ---------- */
.site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: var(--step--1);
}
.site-footer__inner {
  max-width: 68rem;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom));
}
.site-footer__promise {
  font-family: var(--font-display);
  font-size: var(--step-1);
  color: var(--text);
}
.footer-links {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
}
.footer-links li + li { margin-top: 0; }
.footer-links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  color: var(--text);
}
.site-footer__note, .site-footer__credit { max-width: var(--measure); }

/* ---------- Motion preference ---------- */
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) *,
  :root:not([data-motion="full"]) *::before,
  :root:not([data-motion="full"]) *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
:root[data-motion="reduce"] *,
:root[data-motion="reduce"] *::before,
:root[data-motion="reduce"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

@media (forced-colors: active) {
  .brand__halo, .brand__core { fill: CanvasText; }
  :focus-visible { outline-color: Highlight; }
}

@media print {
  .site-header, .site-footer, .skip-link { display: none; }
  body { background: #fff; color: #000; }
}
