/* site/static/style.css */
/* ===== CareTransparency — Professional Healthcare UI =====
   Clean, government-style design. Fast loading. Mobile-first responsive.
   No frameworks. System fonts. High contrast. Professional trust.
*/

/* 1) Design tokens */
:root {
  /* Professional blue palette */
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --primary-800: #1e40af;

  /* Semantic colors */
  --success-50: #f0fdf4;
  --success-600: #16a34a;
  --warning-50: #fffbeb;
  --warning-600: #d97706;
  --error-50: #fef2f2;
  --error-600: #dc2626;

  /* Neutral grays */
  --neutral-50: #f9fafb;
  --neutral-100: #f3f4f6;
  --neutral-200: #e5e7eb;
  --neutral-300: #d1d5db;
  --neutral-400: #9ca3af;
  --neutral-500: #6b7280;
  --neutral-600: #4b5563;
  --neutral-700: #374151;
  --neutral-800: #1f2937;
  --neutral-900: #111827;

  /* Layout */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --max-width: 1200px;
}

/* 2) Reset and base */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  line-height: 1.6;
  color: var(--neutral-800);
  background-color: var(--neutral-50);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary-600); text-decoration: none; }
a:hover, a:focus { color: var(--primary-700); text-decoration: underline; }

/* 3) Typography */
h1 { font-size: 2rem; font-weight: 700; color: var(--neutral-900); line-height: 1.25; margin-bottom: 0.5rem; }
h2 { font-size: 1.5rem; font-weight: 600; color: var(--neutral-900); line-height: 1.3; margin-bottom: 1rem; }
h3 { font-size: 1.25rem; font-weight: 600; color: var(--neutral-900); line-height: 1.35; margin-bottom: 0.75rem; }
h4 { font-size: 1rem; font-weight: 600; color: var(--neutral-700); margin-bottom: 0.5rem; }
p { margin-bottom: 1rem; }

/* 4) Layout containers */
.wrap, .container { max-width: var(--max-width); margin: 0 auto; padding: 0 1rem; }

/* 5) Header */
.site-header { background: white; border-bottom: 1px solid var(--neutral-200); position: sticky; top: 0; z-index: 50; }
.site-header .container { display: flex; align-items: center; justify-content: space-between; min-height: 60px; gap: 1rem; }
.brand { font-weight: 700; font-size: 1.25rem; color: var(--primary-600); text-decoration: none; }

/* 6) Navigation */
nav[aria-label="Primary"] { display: flex; gap: 1.5rem; align-items: center; }
nav[aria-label="Primary"] a { color: var(--neutral-600); font-weight: 500; font-size: 0.9rem; padding: 0.5rem 0; }
nav[aria-label="Primary"] a:hover { color: var(--primary-600); text-decoration: none; }

/* Mobile menu button */
.menu-button {
  display: none; background: none; border: none; padding: 0.5rem; cursor: pointer;
  flex-direction: column; gap: 0.25rem;
}
.menu-button span { display: block; width: 1.5rem; height: 2px; background: var(--neutral-600); transition: 0.3s; }

/* 7) Cards and sections */
.card, .panel {
  background: white; border-radius: var(--radius-lg); border: 1px solid var(--neutral-200);
  box-shadow: var(--shadow-sm); padding: 1.5rem; margin-bottom: 1.5rem;
}
.section { margin: 2.5rem 0; }

/* 8) Grid layouts */
.grid, .hero { display: grid; gap: 1.5rem; margin: 1.5rem 0; }
.grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.hero { grid-template-columns: 1.2fr 0.8fr; align-items: start; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }

/* 9) Tables */
.table, table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.table th, .table td, th, td { padding: 0.75rem; text-align: left; border-bottom: 1px solid var(--neutral-200); }
.table th, th { font-weight: 600; color: var(--neutral-700); font-size: 0.9rem; background: var(--neutral-50); }
.table tbody tr:hover, tbody tr:hover { background: var(--neutral-50); }

/* 10) Badges and chips */
.badge, .chip {
  display: inline-flex; align-items: center; padding: 0.25rem 0.75rem; border-radius: 9999px;
  font-size: 0.8rem; font-weight: 500; margin-right: 0.5rem; margin-bottom: 0.25rem;
  background: var(--neutral-100); color: var(--neutral-600);
}
.badge--above, .chip--good { background: var(--success-50); color: var(--success-600); }
.badge--average, .chip { background: var(--neutral-100); color: var(--neutral-600); }
.badge--below, .chip--bad { background: var(--error-50); color: var(--error-600); }
.badge--warn, .chip--warn { background: var(--warning-50); color: var(--warning-600); }

/* 11) Metric displays */
.metric-detail, .metric-highlight { font-size: 0.875rem; margin-top: 0.5rem; }
.metric-detail { color: var(--neutral-600); }
.metric-highlight { font-weight: 600; color: var(--neutral-800); }
.metric-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin: 1.5rem 0;
}
.metric {
  background: white; border: 1px solid var(--neutral-200); border-radius: var(--radius-md); padding: 1rem;
}
.metric .k {
  font-size: 0.8rem; color: var(--neutral-500); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.25rem;
}
.metric .v { font-size: 1.75rem; font-weight: 700; color: var(--neutral-900); line-height: 1; }

/* 12) Lists */
.facility-list, .ct-owner-facilities, .ct-owners-list { list-style: none; margin: 0; padding: 0; }
.facility-list li, .ct-owner-facilities li {
  padding: 0.75rem 0; border-bottom: 1px solid var(--neutral-100);
  display: flex; justify-content: space-between; align-items: center;
}
.facility-list li:last-child, .ct-owner-facilities li:last-child { border-bottom: none; }
.facility-name { font-weight: 500; color: var(--primary-600); }
.facility-location { font-size: 0.875rem; color: var(--neutral-500); margin-top: 0.125rem; }
.facility-metric { font-weight: 600; color: var(--neutral-800); font-size: 0.9rem; }

/* 13) Forms and inputs */
.input, input[type="search"], input[type="text"] {
  width: 100%; padding: 0.75rem 1rem; border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md); background: white; font-size: 1rem; transition: border-color 0.15s ease;
}
.input:focus, input:focus { outline: none; border-color: var(--primary-600); box-shadow: 0 0 0 3px var(--primary-50); }

/* 14) Search components */
#ct-search { margin: 1.5rem 0; }
#ct-search-results {
  background: white; border: 1px solid var(--neutral-200); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); max-height: 320px; overflow-y: auto;
}
.ct-hit { display: block; padding: 0.75rem 1rem; border-bottom: 1px solid var(--neutral-100); color: var(--neutral-800); text-decoration: none; }
.ct-hit:hover, .ct-hit:focus { background: var(--neutral-50); text-decoration: none; }
.ct-hit:last-child { border-bottom: none; }

/* 15) Ad slots */
.ad-slot {
  background: var(--neutral-100); border: 1px dashed var(--neutral-300); border-radius: var(--radius-md);
  min-height: 280px; display: flex; align-items: center; justify-content: center;
  margin: 2rem 0; color: var(--neutral-500); font-size: 0.9rem;
}

/* 16) Help and tooltips */
.help, .help-tip {
  display: inline-block; width: 1rem; height: 1rem; border-radius: 50%;
  background: var(--neutral-400); color: white; text-align: center; font-size: 0.7rem; line-height: 1rem;
  margin-left: 0.5rem; cursor: help; position: relative;
}
.help:hover::after, .help-tip:hover::after {
  content: attr(title); position: absolute; bottom: 125%; left: 50%; transform: translateX(-50%);
  background: var(--neutral-800); color: white; padding: 0.5rem; border-radius: var(--radius-sm);
  font-size: 0.8rem; z-index: 10; max-width: 200px; white-space: normal; width: max-content;
}

/* 17) Utility classes */
.small, .muted { font-size: 0.875rem; color: var(--neutral-500); }
.text-center { text-align: center; }
.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;
}

/* 18) Footer */
.site-footer {
  margin-top: 3rem; padding: 2rem 0; background: var(--neutral-100);
  border-top: 1px solid var(--neutral-200); color: var(--neutral-600); font-size: 0.875rem;
}

/* 19) Mobile responsiveness */
@media (max-width: 768px) {
  /* Navigation */
  .menu-button { display: flex; }
  nav[aria-label="Primary"] {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: white; border-top: 1px solid var(--neutral-200);
    flex-direction: column; align-items: stretch; padding: 1rem; gap: 0; z-index: 40;
  }
  nav[aria-label="Primary"].open { display: flex; }
  nav[aria-label="Primary"] a { padding: 0.75rem 0; border-bottom: 1px solid var(--neutral-100); }
  nav[aria-label="Primary"] a:last-child { border-bottom: none; }

  /* Typography */
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.25rem; }

  /* Layout */
  .wrap, .container { padding: 0 0.75rem; }
  .grid-2, .hero { grid-template-columns: 1fr; }
  .card, .panel { padding: 1rem; margin-bottom: 1rem; }

  /* Tables */
  .table, table { font-size: 0.9rem; }
  .table th, .table td, th, td { padding: 0.5rem; }

  /* Lists */
  .facility-list li { flex-direction: column; align-items: flex-start; gap: 0.25rem; }
  .facility-metric { align-self: flex-end; }
}

@media (max-width: 480px) {
  /* Header */
  .site-header .container { padding: 0.75rem; min-height: 56px; }
  .brand { font-size: 1.125rem; }

  /* Content */
  .wrap, .container { padding: 0 1rem; }

  /* Typography */
  h1 { font-size: 1.5rem; }

  /* Tooltips on mobile */
  .help:hover::after, .help-tip:hover::after {
    position: fixed; bottom: 2rem; left: 1rem; right: 1rem; transform: none; max-width: none; width: auto;
  }

  /* Ad slots */
  .ad-slot { min-height: 250px; margin: 1.5rem 0; }
}

/* --- Compatibility shims (existing partials/markup) --- */
.badge__delta { margin-left: 0.25rem; font-weight: 600; }
.breadcrumbs { font-size: 0.875rem; color: var(--neutral-500); margin-bottom: 0.5rem; }
.nearby{}
.nearby__title{ font-size: 0.95rem; color: var(--neutral-700); margin-bottom: 0.25rem; }
.nearby__intro{ margin-bottom: 0.5rem; }
.nearby__list{ list-style: none; margin: 0; padding: 0; }
.nearby__item{
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem;
  padding: 0.5rem 0; border-bottom: 1px solid var(--neutral-100);
}
.nearby__item:last-child{ border-bottom:none; }
.nearby__link{ font-weight: 600; }
.nearby__meta{ font-size: 0.85rem; color: var(--neutral-500); }
.nearby__value{ margin-left: auto; font-variant-numeric: tabular-nums; color: var(--neutral-800); }

/* ===== Additional CSS for Remaining Templates =====
   Add these rules to the existing site/static/style.css
   These cover home.html, report.html, and trust pages
*/

/* 19) Home page specific styles */
#browse-title {
  scroll-margin-top: 2rem;
}

.state-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  list-style: none;
  margin: 1rem 0;
  padding: 0;
}

.state-grid li {
  margin: 0;
}

.state-grid a {
  display: block;
  padding: 0.5rem 0.75rem;
  background: white;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}

.state-grid a:hover {
  background: var(--primary-50);
  border-color: var(--primary-200);
  text-decoration: none;
  transform: translateY(-1px);
}

/* Search component enhancements */
#ct-search label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--neutral-700);
}

#ct-search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--neutral-300);
  border-radius: var(--radius-md);
  font-size: 1rem;
  background: white;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#ct-search-input:focus {
  outline: none;
  border-color: var(--primary-600);
  box-shadow: 0 0 0 3px var(--primary-50);
}

#ct-search-results {
  background: white;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 320px;
  overflow-y: auto;
  z-index: 30;
}

.ct-hit {
  display: block;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--neutral-100);
  color: var(--neutral-800);
  text-decoration: none;
  transition: background-color 0.1s ease;
}

.ct-hit:hover,
.ct-hit:focus {
  background: var(--neutral-50);
  text-decoration: none;
}

.ct-hit:last-child {
  border-bottom: none;
}

/* 20) Report page styles */
.report-header {
  margin-bottom: 2rem;
}

.report-header h1 {
  margin-bottom: 0.5rem;
}

.report-header .sub {
  color: var(--neutral-600);
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.download-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--primary-600);
  color: white;
  border-radius: var(--radius-md);
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.download-link:hover {
  background: var(--primary-700);
  color: white;
  text-decoration: none;
}

.download-link::after {
  content: "↓";
  font-size: 1.1rem;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--neutral-200);
}

.report-table th {
  background: var(--neutral-50);
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--neutral-700);
  border-bottom: 2px solid var(--neutral-200);
}

.report-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--neutral-100);
}

.report-table tbody tr:hover {
  background: var(--neutral-50);
}

.report-table tbody tr:last-child td {
  border-bottom: none;
}

.report-note {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--neutral-50);
  border-radius: var(--radius-md);
  color: var(--neutral-600);
  font-size: 0.9rem;
  border-left: 4px solid var(--neutral-300);
}

/* 21) Trust pages (about, methodology, etc.) */
.trust-page {
  max-width: 800px;
  margin: 0 auto;
}

.trust-page h1 {
  margin-bottom: 1.5rem;
  color: var(--neutral-900);
}

.trust-page h2 {
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: var(--neutral-800);
  border-bottom: 2px solid var(--neutral-200);
  padding-bottom: 0.5rem;
}

.trust-page p {
  margin-bottom: 1.5rem;
  line-height: 1.7;
  color: var(--neutral-700);
}

.trust-page ul, .trust-page ol {
  margin: 1rem 0 1.5rem 0;
  padding-left: 2rem;
  color: var(--neutral-700);
}

.trust-page li {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.trust-page strong {
  color: var(--neutral-900);
}

.trust-page code {
  background: var(--neutral-100);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.875em;
  color: var(--neutral-800);
}

.trust-page blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  background: var(--neutral-50);
  border-left: 4px solid var(--primary-600);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--neutral-700);
  font-style: italic;
}

/* 22) Navigation breadcrumb consistency */
.breadcrumb, nav[style*="font-size:0.875rem"] {
  font-size: 0.875rem;
  color: var(--neutral-500);
  margin-bottom: 1rem;
}

.breadcrumb a, nav[style*="font-size:0.875rem"] a {
  color: var(--primary-600);
  text-decoration: none;
}

.breadcrumb a:hover, nav[style*="font-size:0.875rem"] a:hover {
  text-decoration: underline;
}

/* 23) Owner-specific content styles */
.owner-link {
  display: inline-block;
  margin-bottom: 0.5rem;
  color: var(--primary-600);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.owner-link:hover {
  text-decoration: underline;
}

/* 24) Facility metadata styling */
.facility-meta {
  color: var(--neutral-600);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

/* 25) Mobile enhancements for complex layouts */
@media (max-width: 640px) {
  .state-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.375rem;
  }
  
  .state-grid a {
    padding: 0.375rem 0.5rem;
    font-size: 0.85rem;
  }
  
  .report-table {
    font-size: 0.9rem;
  }
  
  .report-table th,
  .report-table td {
    padding: 0.5rem;
  }
  
  .download-link {
    padding: 0.625rem 1rem;
    font-size: 0.9rem;
  }
  
  .trust-page {
    padding: 0 0.5rem;
  }
}

@media (max-width: 480px) {
  .state-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* Stack report table headers on very small screens */
  .report-table thead {
    display: none;
  }
  
  .report-table,
  .report-table tbody,
  .report-table tr,
  .report-table td {
    display: block;
    width: 100%;
  }
  
  .report-table tr {
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    padding: 0.75rem;
  }
  
  .report-table td {
    border: none;
    padding: 0.25rem 0;
  }
  
  .report-table td::before {
    content: attr(data-label) ": ";
    font-weight: 600;
    color: var(--neutral-700);
  }
}
/* Ensure body text has strong contrast on white */
body { color: #111; background: #fff; }

/* Make in-content links not rely on color */
a { text-decoration: underline; text-underline-offset: 0.15em; }

/* Keep nav/brand/state-grid clean, but still accessible on focus */
.site-header nav a,
.brand,
.state-grid a { text-decoration: none; }
.state-grid a:focus-visible,
.site-header nav a:focus-visible { text-decoration: underline; }

/* Clear, visible keyboard focus everywhere */
:focus-visible { outline: 2px solid #0a66c2; outline-offset: 2px; border-radius: 2px; }
