/* =====================================================================
   SMART Health Check-in — design tokens
   Adapted from the SMART Health IT design system (smarthealthit.org).
   Sans: Inter · Editorial serif: Source Serif 4 · Mono: JetBrains Mono.
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Source+Serif+4:opsz,wght@8..60,400;8..60,600;8..60,700&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  /* SMART spectrum — the 6-petal palette (categorical only) */
  --smart-red:    #E5443B;
  --smart-orange: #F09623;
  --smart-yellow: #F1C42E;
  --smart-green:  #6FB43F;
  --smart-teal:   #1FA88E;
  --smart-blue:   #3DA9DC;
  --smart-purple: #6E4FA2;

  /* Brand accent */
  --brand:        #0E6FB8;   /* deep SMART blue, AAA on white */
  --brand-ink:    #094D80;   /* hover / pressed */
  --brand-bright: #3DA9DC;   /* original logo cyan, fills */
  --brand-wash:   #D6EAF7;   /* tint background */

  /* Neutrals */
  --gray-0:   #FFFFFF;
  --gray-50:  #F6F8FA;
  --gray-100: #EEF1F4;
  --gray-200: #E4E7EB;
  --gray-300: #CBD2D9;
  --gray-400: #9AA5B1;
  --gray-500: #7B8794;
  --gray-600: #6F7178;   /* SMART wordmark gray */
  --gray-700: #4B5563;
  --gray-800: #323F4B;
  --gray-900: #1F2933;
  --gray-950: #11161D;

  /* Semantic surfaces */
  --bg:           var(--gray-0);
  --bg-alt:       var(--gray-50);
  --surface:      var(--gray-0);
  --surface-alt:  var(--gray-50);
  --fg-1:         var(--gray-900);
  --fg-2:         var(--gray-700);
  --fg-3:         var(--gray-500);
  --fg-mark:      var(--gray-600);
  --border:        var(--gray-200);
  --border-strong: var(--gray-300);
  --border-subtle: var(--gray-100);

  /* Status */
  --success:      #1FA88E;  --success-wash: #E5F5F1;
  --warning:      #F09623;  --warning-wash: #FCEFD9;
  --danger:       #E5443B;  --danger-wash:  #FBE4E2;
  --info:         #3DA9DC;  --info-wash:    #E8F4FB;

  /* Type */
  --font-sans:  'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-serif: 'Source Serif 4', 'Source Serif Pro', Georgia, 'Times New Roman', serif;
  --font-mono:  'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --fs-xs:   12px;
  --fs-sm:   14px;
  --fs-base: 16px;
  --fs-md:   18px;
  --fs-lg:   20px;
  --fs-xl:   24px;
  --fs-2xl:  30px;
  --fs-3xl:  36px;
  --fs-4xl:  48px;
  --fs-5xl:  60px;

  --lh-tight:   1.15;
  --lh-snug:    1.3;
  --lh-normal:  1.5;
  --lh-relaxed: 1.65;

  --tracking-tight: -0.02em;
  --tracking-snug:  -0.01em;
  --tracking-caps:   0.08em;

  /* Spacing — 8pt scale */
  --space-1:  4px;
  --space-2:  8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;

  /* Radii */
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-pill: 9999px;

  /* Shadows — neutral, low-alpha */
  --shadow-xs: 0 1px 1px rgba(17, 22, 29, 0.04);
  --shadow-sm: 0 1px 2px rgba(17, 22, 29, 0.06), 0 1px 3px rgba(17, 22, 29, 0.04);
  --shadow-md: 0 2px 4px rgba(17, 22, 29, 0.06), 0 4px 8px rgba(17, 22, 29, 0.06);
  --shadow-lg: 0 4px 8px rgba(17, 22, 29, 0.06), 0 12px 24px rgba(17, 22, 29, 0.08);
  --shadow-focus: 0 0 0 3px rgba(14, 111, 184, 0.45);

  /* Layout */
  --container-narrow: 760px;
  --container:       1080px;
  --container-wide:  1280px;
  --nav-height:        72px;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur:      200ms;
}

::selection { background: var(--brand); color: #fff; }

/* ---------- Spectrum stripe — the brand signature ------------------- */
.smart-spectrum {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  height: 3px;
  width: 100%;
}
.smart-spectrum > i {
  display: block;
}
.smart-spectrum > i:nth-child(1) { background: var(--smart-red); }
.smart-spectrum > i:nth-child(2) { background: var(--smart-orange); }
.smart-spectrum > i:nth-child(3) { background: var(--smart-green); }
.smart-spectrum > i:nth-child(4) { background: var(--smart-teal); }
.smart-spectrum > i:nth-child(5) { background: var(--smart-blue); }
.smart-spectrum > i:nth-child(6) { background: var(--smart-purple); }

/* ---------- Sticky topbar with mark + crumbs ------------------------ */
.smart-topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.smart-topbar-inner {
  max-width: var(--container-wide);
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  font-size: var(--fs-sm);
}
.smart-mark-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  border-bottom: 0;
  color: var(--fg-1);
  flex-shrink: 0;
}
.smart-mark-link:hover { color: var(--fg-1); }
.smart-mark-link svg { display: block; }
.smart-mark-link .smart-mark-text {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.05;
}
.smart-mark-link .smart-mark-eyebrow {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--fg-mark);
}
.smart-mark-link .smart-mark-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--fg-1);
  letter-spacing: -0.005em;
  margin-top: 2px;
}
.smart-topbar-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  align-items: center;
  margin-left: auto;
}
.smart-topbar-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  border-bottom: 0;
  color: var(--fg-2);
  font-weight: 600;
  font-size: 13.5px;
  text-decoration: none;
  transition: color var(--dur) var(--ease-out), background var(--dur) var(--ease-out);
}
.smart-topbar-nav a:hover {
  color: var(--brand-ink);
  background: var(--brand-wash);
}
.smart-topbar-nav a[aria-current="page"] {
  color: var(--brand-ink);
  background: var(--brand-wash);
}
.smart-topbar-nav .sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}

/* ---------- Topbar dropdown ---------------------------------------- */
.smart-topbar-nav .dropdown {
  position: relative;
}
.smart-topbar-nav .dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 11px;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--fg-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--dur) var(--ease-out), background var(--dur) var(--ease-out);
}
.smart-topbar-nav .dropdown-trigger:hover {
  color: var(--brand-ink);
  background: var(--brand-wash);
}
.smart-topbar-nav .dropdown[data-active="true"] > .dropdown-trigger {
  color: var(--brand-ink);
  background: var(--brand-wash);
}
.smart-topbar-nav .dropdown .dd-caret {
  transition: transform var(--dur) var(--ease-out);
}
.smart-topbar-nav .dropdown[data-open="true"] .dd-caret {
  transform: rotate(180deg);
}
.smart-topbar-nav .dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 280px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 70;
}
.smart-topbar-nav .dropdown[data-open="true"] > .dropdown-menu {
  display: block;
}
.smart-topbar-nav .dropdown-menu a {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border-bottom: 0;
  color: var(--fg-1);
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
  line-height: 1.35;
  transition: background var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}
.smart-topbar-nav .dropdown-menu a:hover {
  background: var(--bg-alt);
  color: var(--brand-ink);
  border-bottom: 0;
}
.smart-topbar-nav .dropdown-menu a[aria-current="page"] {
  background: var(--brand-wash);
  color: var(--brand-ink);
}
.smart-topbar-nav .dropdown-menu .dd-label {
  display: block;
  font-weight: 600;
}
.smart-topbar-nav .dropdown-menu .dd-note {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--fg-3);
  font-weight: 400;
}
.smart-topbar-nav .dropdown-menu a:hover .dd-note,
.smart-topbar-nav .dropdown-menu a[aria-current="page"] .dd-note {
  color: var(--brand-ink);
  opacity: 0.7;
}

@media (max-width: 720px) {
  .smart-topbar-nav .dropdown-menu {
    left: auto;
    right: 0;
    min-width: 240px;
  }
}

/* ---------- LLM-friendly docs bundle widget (in topbar) ------------- */
.llm-widget {
  display: inline-flex;
  align-items: stretch;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-left: 4px;
  overflow: visible;
}
.llm-widget .llm-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-2);
  cursor: pointer;
  white-space: nowrap;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.llm-widget .llm-primary:hover {
  background: var(--bg-alt);
  color: var(--brand-ink);
}
.llm-widget .llm-primary svg { width: 14px; height: 14px; }
.llm-widget .llm-secondary {
  border-left: 1px solid var(--border);
}
.llm-widget .llm-secondary .dropdown-trigger {
  padding: 6px 8px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--fg-2);
}
.llm-widget .llm-secondary .dropdown-menu {
  left: auto;
  right: 0;
  min-width: 220px;
}

/* ---------- Footer with spectrum top stripe ------------------------- */
.smart-footer {
  position: relative;
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  padding: 40px 0 28px;
  margin-top: 48px;
  font-size: var(--fs-sm);
  color: var(--fg-2);
}
.smart-footer .smart-spectrum {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}
.smart-footer-inner {
  max-width: var(--container-wide);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 24px;
}
.smart-footer-meta {
  flex: 2 1 320px;
  min-width: 0;
}
.smart-footer-meta .smart-mark-link { margin-bottom: 12px; }
.smart-footer-meta p {
  margin: 0;
  color: var(--fg-2);
  max-width: 56ch;
  font-size: var(--fs-sm);
  line-height: var(--lh-relaxed);
}
.smart-footer-links {
  flex: 1 1 220px;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: flex-end;
}
.smart-footer-links a {
  color: var(--fg-2);
  border-bottom: 1px solid transparent;
  font-weight: 600;
}
.smart-footer-links a:hover {
  color: var(--brand-ink);
  border-bottom-color: currentColor;
}
.smart-footer-fine {
  max-width: var(--container-wide);
  margin: 24px auto 0;
  padding: 16px 24px 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: var(--fs-xs);
  color: var(--fg-3);
}
.smart-footer-fine .spacer { flex: 1; }

@media (max-width: 720px) {
  .smart-topbar-inner { padding: 10px 18px; gap: 12px; }
  .smart-topbar-nav { width: 100%; margin-left: 0; }
  .smart-footer-inner { flex-direction: column; }
  .smart-footer-links { justify-content: flex-start; }
}

/* ---------------------------------------------------------------------
   Site-wide additions: footer columns, and the doc/page shells used by
   every part of the site.
   --------------------------------------------------------------------- */
.site-foot-inner { max-width: var(--container-wide, 72rem); margin: 0 auto; padding: 8px 24px 0; }
.site-foot-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: var(--space-6); }
.site-foot-cols h4 {
  margin: 0 0 var(--space-3); font-size: var(--fs-xs); font-weight: 700;
  letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--fg-3);
}
.site-foot-cols ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.site-foot-cols a { color: var(--fg-1); text-decoration: none; font-size: var(--fs-sm); }
.site-foot-cols a:hover { color: var(--brand); }
.smart-footer .smart-footer-fine {
  max-width: var(--container-wide, 72rem); margin: var(--space-6) auto 0; padding: var(--space-4) 24px 0;
  border-top: 1px solid var(--border); display: flex; gap: var(--space-4); font-size: var(--fs-sm); color: var(--fg-3);
}
.smart-footer .smart-footer-fine .spacer { margin-left: auto; }

/* A demo page closes with the same spectrum rule as the site footer, but
   without the site map: one line of context under the app. */
.smart-footer.shallow { margin-top: var(--space-7); }
.smart-footer.shallow .smart-footer-fine { margin-top: 0; padding-top: var(--space-4); border-top: 0; }

/* On a phone the nav wraps to two or three rows; a sticky bar that tall eats
   the screen, so it scrolls away instead. */
@media (max-width: 46rem) {
  .smart-topbar { position: static; }
  .smart-topbar-inner { padding: 10px 16px; gap: 8px; }
  .smart-topbar-nav { margin-left: 0; width: 100%; }
  .smart-topbar-nav a, .smart-topbar-nav .dropdown-trigger { padding: 6px 8px; }
  .smart-topbar-nav .sep { display: none; }  /* it lands mid-wrap, not before GitHub */
  .site-foot-inner { padding: 8px 16px 0; }
}

/* =====================================================================
   Components
   The pieces every page needs — buttons, surfaces, chips, banners,
   callouts, form controls — defined once here rather than reinvented
   with ad-hoc rem values in each page's <style> block.
   ===================================================================== */

/* --- buttons --- */
.smart-btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font: inherit; font-size: var(--fs-sm); font-weight: 600; line-height: 1.1;
  padding: 10px 16px; border-radius: var(--radius-md);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--fg-1);
  text-decoration: none; cursor: pointer;
  transition: border-color .12s ease, background-color .12s ease, color .12s ease;
}
.smart-btn:hover { border-color: var(--brand); color: var(--brand); }
.smart-btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.smart-btn[disabled], .smart-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.smart-btn[disabled]:hover { border-color: var(--border-strong); color: var(--fg-1); }

.smart-btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.smart-btn.primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); color: #fff; }
.smart-btn.primary[disabled]:hover { background: var(--brand); border-color: var(--brand); color: #fff; }

.smart-btn.ghost { border-color: transparent; background: transparent; color: var(--fg-2); }
.smart-btn.ghost:hover { border-color: var(--border); color: var(--brand); background: var(--gray-50); }

.smart-btn.sm { font-size: var(--fs-xs); padding: 6px 10px; border-radius: var(--radius-sm); font-weight: 500; }
.smart-btn.mono { font-family: var(--font-mono); font-weight: 400; }

/* --- surfaces --- */
.smart-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-5);
}
.smart-panel.quiet { background: var(--surface-alt); }
.smart-panel.flush { padding: 0; overflow: hidden; }
.smart-panel.dashed { border-style: dashed; background: none; }
.smart-panel-head {
  padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border);
  background: var(--surface); color: var(--fg-3);
  font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: var(--tracking-caps); text-transform: uppercase;
}

/* --- chips --- */
.smart-chip {
  display: inline-flex; align-items: center; gap: var(--space-1);
  font-family: var(--font-mono); font-size: var(--fs-xs); line-height: 1;
  letter-spacing: var(--tracking-caps); text-transform: uppercase;
  padding: 4px 8px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); color: var(--fg-3); background: var(--surface);
  white-space: nowrap;
}
.smart-chip.warning { border-color: #E7C88F; color: #7A5A16; background: var(--warning-wash); }
.smart-chip.success { border-color: #9BD9CB; color: #12705E; background: var(--success-wash); }
.smart-chip.info    { border-color: #A9D6EE; color: var(--brand-ink); background: var(--info-wash); }
.smart-chip.danger  { border-color: #F0B6B1; color: #A32A22; background: var(--danger-wash); }

/* --- a full-bleed contextual band (e.g. "this is a demo") --- */
.smart-banner {
  background: var(--surface-alt); border-bottom: 1px solid var(--border);
  color: var(--fg-2); font-size: var(--fs-sm);
}
.smart-banner-inner { display: flex; align-items: center; gap: var(--space-3); min-height: 44px; }
.smart-banner .grow { flex: 1; min-width: 0; }
.smart-banner a { color: var(--fg-2); }
.smart-banner a:hover { color: var(--brand); }

/* --- left-rule callout --- */
.smart-note {
  border-left: 3px solid var(--brand-bright);
  padding: var(--space-1) var(--space-4);
  color: var(--fg-2); font-size: var(--fs-sm);
}
.smart-note.warning { border-left-color: var(--warning); }
.smart-note.danger  { border-left-color: var(--danger); }

/* --- form controls --- */
.smart-field { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.smart-field > .lbl {
  font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--fg-3);
}
.smart-input, .smart-select {
  font-family: var(--font-mono); font-size: var(--fs-sm);
  padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--fg-1); width: 100%; min-width: 0;
}
.smart-input:focus-visible, .smart-select:focus-visible {
  outline: none; border-color: var(--brand); box-shadow: var(--shadow-focus);
}
