/* TriRepo design system: shared by the landing page (/) and the clinic (/app). */

:root {
  --bg: #f5f8f6;
  --surface: #ffffff;
  --surface-2: #f2f6f3;
  --border: #e2e9e5;
  --border-strong: #d0dbd4;
  --text: #0d1f15;
  --muted: #56675d;
  --faint: #83948a;

  --green-50: #effbf3;
  --green-100: #dcf5e4;
  --green-200: #b8ead0;
  --green-400: #4ade80;
  --green-500: #22c55e;
  --green-600: #16a34a;
  --green-700: #15803d;
  --green-900: #0f3d24;
  --red-50: #fef2f2;
  --red-600: #dc2626;
  --red-700: #b91c1c;
  --amber-50: #fff8eb;
  --amber-600: #d97706;
  --amber-700: #b45309;
  --slate-50: #f1f5f9;
  --slate-600: #475569;
  --ink: #102a1c;
  --code-bg: #0f1f17;
  --code-text: #e3efe8;
  --code-border: transparent;

  /* Role tokens: what a colour is for, so the dark theme can swap it in one place. */
  --surface-3: #fbfcfb;
  --primary: var(--green-900);
  --primary-hover: var(--green-700);
  --on-primary: #ffffff;
  --on-green: #ffffff;
  --ink-fg: #ffffff;
  --code-inline: var(--green-900);
  --link-hover: var(--green-900);
  --deep-bg: var(--green-900);
  --deep-border: var(--green-900);
  --nav-bg: rgba(255, 255, 255, 0.86);
  --row-hover: #fafcfb;
  --amber-border: #f3dcac;
  --ring: #e3ebe6;
  --cta-bg: radial-gradient(120% 140% at 50% 0%, var(--green-100) 0%, var(--green-50) 45%, #ffffff 100%);
  color-scheme: light;

  --shadow-sm: 0 1px 2px rgba(15, 42, 28, 0.06);
  --shadow-md: 0 12px 28px -14px rgba(15, 42, 28, 0.25), 0 2px 6px rgba(15, 42, 28, 0.05);
  --radius: 14px;

  --font-prose: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;

  /* Names used by the clinic page's inline script. */
  --accent-lies: var(--red-600);
  --accent-crash: var(--amber-700);
  --accent-bump: var(--green-700);
  --accent-active: var(--green-700);
}

/* ── Dark theme (set by theme.js as <html data-theme="dark">) ── */
:root[data-theme="dark"] {
  --bg: #0b110d;
  --surface: #111a15;
  --surface-2: #17231c;
  --surface-3: #131e18;
  --border: #22332a;
  --border-strong: #2f4439;
  --text: #e6efe9;
  --muted: #a1b4a8;
  --faint: #76897e;

  --green-50: rgba(34, 197, 94, 0.1);
  --green-100: rgba(34, 197, 94, 0.18);
  --green-200: rgba(34, 197, 94, 0.32);
  --green-600: #22c55e;
  --green-700: #4ade80;
  --red-50: rgba(248, 113, 113, 0.12);
  --red-600: #f87171;
  --red-700: #fca5a5;
  --amber-50: rgba(251, 191, 36, 0.12);
  --amber-600: #fbbf24;
  --amber-700: #fcd34d;
  --slate-50: rgba(148, 163, 184, 0.14);
  --slate-600: #cbd5e1;
  --ink: #d7e6dc;
  --ink-fg: #0b110d;
  --code-bg: #09100c;
  --code-border: #22332a;

  --primary: #22c55e;
  --primary-hover: #4ade80;
  --on-primary: #052e16;
  --on-green: #052e16;
  --code-inline: #bbf7d0;
  --link-hover: #86efac;
  --deep-bg: #0f2c1c;
  --deep-border: rgba(74, 222, 128, 0.22);
  --nav-bg: rgba(17, 26, 21, 0.82);
  --row-hover: rgba(255, 255, 255, 0.025);
  --amber-border: rgba(251, 191, 36, 0.28);
  --ring: #1c2b23;
  --cta-bg: radial-gradient(120% 140% at 50% 0%, rgba(34, 197, 94, 0.2) 0%, rgba(34, 197, 94, 0.07) 45%, var(--surface) 100%);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 14px 30px -14px rgba(0, 0, 0, 0.7), 0 2px 6px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

/* The logo's darkest node would vanish on a dark background. */
:root[data-theme="dark"] .brand svg path { stroke: rgba(187, 247, 208, 0.35); }
:root[data-theme="dark"] .brand svg circle:nth-of-type(1) { fill: #22c55e; }
:root[data-theme="dark"] .brand svg circle:nth-of-type(2) { fill: #bbf7d0; }
:root[data-theme="dark"] .brand svg circle:nth-of-type(3) { fill: #4ade80; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font-prose);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; }
a { color: var(--green-700); }
code { font-family: var(--font); }
button, input, textarea { font: inherit; }
::selection { background: var(--green-200); }

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

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: 600 14px var(--font-prose);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.btn:hover { border-color: var(--green-600); color: var(--green-700); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--green-200); outline-offset: 2px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.btn-primary:disabled { background: var(--border-strong); border-color: var(--border-strong); color: var(--muted); opacity: 1; }
.btn-sm { height: 34px; padding: 0 13px; font-size: 13px; border-radius: 9px; }
.btn svg { width: 16px; height: 16px; }

/* ── Navigation ──────────────────────────────────────────── */
.site-nav {
  position: sticky;
  top: 12px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 20px;
  max-width: 1040px;
  margin: 12px auto 0;
  padding: 7px 7px 7px 16px;
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border: 1px solid var(--border);
  border-radius: 15px;
  box-shadow: var(--shadow-sm);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
}
.brand svg { width: 26px; height: 26px; flex: none; }
.nav-links { display: flex; gap: 2px; margin: 0 auto; }
.nav-links a {
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-links a:hover { color: var(--text); background: var(--surface-2); }
.nav-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* ── Light / dark toggle ─────────────────────────────────── */
.theme-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.theme-toggle:hover { color: var(--green-700); border-color: var(--green-600); }
.theme-toggle:focus-visible { outline: 3px solid var(--green-200); outline-offset: 2px; }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
.nav-links + .nav-actions { margin-left: 0; }

/* ── Footer ──────────────────────────────────────────────── */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px 32px;
  max-width: 1040px;
  margin: 72px auto 0;
  padding: 28px 20px 44px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}
.site-footer .brand { font-size: 15px; }
.site-footer .brand svg { width: 22px; height: 22px; }
.site-footer .credit { max-width: 620px; line-height: 1.6; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--green-700); }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; }

@media (max-width: 760px) {
  .site-nav { margin: 10px 12px 0; top: 8px; gap: 12px; }
  .nav-links { display: none; }
}
