@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700&display=swap');

/* ==========================================================================
   CSS Custom Properties (Theme Tokens)
   ========================================================================== */
:root {
  /* Color Palette - Quiet, Medical Trust (Light Mode Default) */
  --bg-primary: #f8fafc;        /* Soft cool gray background */
  --bg-secondary: #ffffff;      /* Pure white for containers/cards */
  --bg-tertiary: #f1f5f9;       /* Light border/divider background */
  --bg-muted: #e2e8f0;          /* Muted element background */
  
  --text-primary: #0f172a;      /* Slate 900 for high-contrast headers/body */
  --text-secondary: #475569;    /* Slate 600 for body text and details */
  --text-muted: #64748b;        /* Slate 500 for captions and small metadata */
  
  --brand-primary: #1e3a8a;     /* Deep slate blue for primary accents/headers */
  --brand-secondary: #0d9488;   /* Teal for active links, badges, highlights */
  --brand-hover: #1d4ed8;       /* Stronger blue on hover */
  --brand-secondary-hover: #0f766e;
  
  /* Alert / Disclaimer States */
  --disclaimer-bg: #fffbeb;     /* Pale amber */
  --disclaimer-border: #f59e0b; /* Amber 500 */
  --disclaimer-text: #78350f;   /* Dark amber */
  
  --error-bg: #fef2f2;          /* Pale red */
  --error-border: #ef4444;      /* Red 500 */
  --error-text: #991b1b;        /* Dark red */

  /* Typography */
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  
  /* Borders and Shadow */
  --border-radius-sm: 6px;
  --border-radius-md: 10px;
  --border-radius-lg: 16px;
  --border-color: #cbd5e1;
  --box-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --box-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --box-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.03), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
  
  /* Grid & Dimensions */
  --container-max-width: 1200px;
  --content-max-width: 72ch; /* Best readability standard */
  --header-height: 72px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #0b0f19;       /* Deep slate-black */
    --bg-secondary: #131b2e;     /* Slate-blue card background */
    --bg-tertiary: #1e293b;      /* Dark border/divider background */
    --bg-muted: #334155;
    
    --text-primary: #f8fafc;     /* High-contrast off-white */
    --text-secondary: #cbd5e1;   /* Pale slate-gray */
    --text-muted: #94a3b8;
    
    --brand-primary: #38bdf8;    /* Lighter sky blue for visibility */
    --brand-secondary: #2dd4bf;  /* Bright teal */
    --brand-hover: #7dd3fc;
    --brand-secondary-hover: #5eead4;
    
    --disclaimer-bg: #1e1b12;    /* Soft dark amber */
    --disclaimer-border: #d97706;
    --disclaimer-text: #fef3c7;
    
    --border-color: #334155;
    --box-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --box-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --box-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  }
}

/* ==========================================================================
   Base Styles
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.625;
  background-color: var(--bg-primary);
  color: var(--text-secondary);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.25;
  margin-bottom: 0.75rem;
}

h1 {
  font-size: 2.25rem;
  margin-bottom: 1rem;
}

h2 {
  font-size: 1.75rem;
  margin-top: 2rem;
  border-bottom: 1px solid var(--bg-tertiary);
  padding-bottom: 0.5rem;
}

h3 {
  font-size: 1.35rem;
  margin-top: 1.5rem;
}

p {
  margin-bottom: 1.25rem;
}

a {
  color: var(--brand-secondary);
  text-decoration: none;
  transition: color 0.15s ease-in-out;
}

a:hover {
  color: var(--brand-secondary-hover);
  text-decoration: underline;
}

ul, ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.5rem;
}

code {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  background-color: var(--bg-tertiary);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--text-primary);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--bg-tertiary);
}

th {
  background-color: var(--bg-tertiary);
  font-weight: 600;
  color: var(--text-primary);
}

/* ==========================================================================
   Layout Components
   ========================================================================== */
.container {
  width: 100%;
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

header {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--bg-tertiary);
  height: var(--header-height);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--box-shadow-sm);
}

.header-inner {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
}

.logo-icon {
  color: var(--brand-secondary);
  height: 24px;
  width: 24px;
}

.main-nav ul {
  display: flex;
  list-style: none;
  gap: 1.5rem;
  margin: 0;
  padding: 0;
}

.main-nav a {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.95rem;
}

.main-nav a:hover, .main-nav a.active {
  color: var(--brand-secondary);
  text-decoration: none;
}

/* Main Grid Layout */
.layout-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  padding: 2.5rem 0;
}

@media (min-width: 992px) {
  .layout-grid {
    grid-template-columns: 8fr 4fr; /* Content 8 cols, Sidebar 4 cols */
  }
}

.main-content {
  max-width: var(--content-max-width);
  width: 100%;
}

aside {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* ==========================================================================
   UI / Content Elements
   ========================================================================== */

/* Cards & Containers */
.card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--border-radius-md);
  padding: 1.5rem;
  box-shadow: var(--box-shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--box-shadow-md);
}

.card h3 a {
  color: var(--text-primary);
}

.card h3 a:hover {
  color: var(--brand-secondary);
}

/* Disclaimers & Alert Banners */
.disclaimer-box {
  background-color: var(--disclaimer-bg);
  border-left: 4px solid var(--disclaimer-border);
  color: var(--disclaimer-text);
  padding: 1.25rem;
  border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

.disclaimer-box p:last-child {
  margin-bottom: 0;
}

.disclaimer-title {
  font-weight: 700;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Short Answer Box (SEO optimized summary) */
.short-answer-box {
  background-color: var(--bg-secondary);
  border: 2px solid var(--brand-secondary);
  border-radius: var(--border-radius-md);
  padding: 1.75rem;
  margin: 2rem 0;
  box-shadow: var(--box-shadow-md);
}

.short-answer-title {
  color: var(--brand-secondary);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.short-answer-text {
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.5rem;
  margin-bottom: 0;
}

/* Sidebar Widgets */
.sidebar-widget {
  background-color: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--border-radius-md);
  padding: 1.5rem;
  box-shadow: var(--box-shadow-sm);
}

.sidebar-widget h3 {
  margin-top: 0;
  font-size: 1.15rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--bg-tertiary);
}

/* Sources List */
.sources-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.88rem;
}

.sources-list li {
  margin-bottom: 0.75rem;
  line-height: 1.4;
  padding-left: 1rem;
  text-indent: -1rem;
}

.sources-list a {
  word-break: break-all;
}

/* Metadata & Badges */
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge-topic {
  background-color: #ccfbf1;
  color: #0d9488;
}

@media (prefers-color-scheme: dark) {
  .badge-topic {
    background-color: #115e59;
    color: #ccfbf1;
  }
}

/* Search bar on article list */
.search-container {
  margin-bottom: 2.5rem;
}

.search-input-wrapper {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  padding: 1rem 1.25rem 1rem 3rem;
  font-size: 1.1rem;
  font-family: var(--font-body);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  box-shadow: var(--box-shadow-sm);
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.search-input:focus {
  border-color: var(--brand-secondary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.search-icon-svg {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 20px;
  height: 20px;
}

/* Category Filters */
.filters-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.filter-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}

.filter-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--brand-secondary);
  border-color: var(--brand-secondary);
  color: #ffffff;
}

/* ==========================================================================
   Specific Layouts
   ========================================================================== */

/* Hero block for Homepage */
.hero-block {
  text-align: center;
  padding: 4rem 0 3rem;
  max-width: 800px;
  margin: 0 auto;
}

.hero-block h1 {
  font-size: 2.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hero-lead {
  font-size: 1.25rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 2rem;
}

.topic-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-top: 3rem;
}

@media (min-width: 768px) {
  .topic-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.topic-card {
  text-align: left;
  border-top: 4px solid var(--brand-secondary);
}

.topic-card h3 {
  margin-top: 0.5rem;
}

/* Articles List Grid */
.articles-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .articles-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==========================================================================
   Footer
   ========================================================================== */
footer {
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--bg-tertiary);
  padding: 4rem 0 3rem;
  margin-top: 4rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
  margin-bottom: 3rem;
}

@media (min-width: 768px) {
  .footer-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.footer-col h4 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.footer-col ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-col li {
  margin-bottom: 0.75rem;
}

.footer-col a {
  color: var(--text-secondary);
}

.footer-col a:hover {
  color: var(--brand-secondary);
  text-decoration: none;
}

.footer-bottom {
  border-top: 1px solid var(--bg-tertiary);
  padding-top: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

@media (min-width: 768px) {
  .footer-bottom {
    flex-direction: row;
  }
}

.footer-bottom p {
  margin-bottom: 0;
}

.footer-disclaimer {
  max-width: 100%;
  font-size: 0.8rem;
  line-height: 1.5;
  text-align: center;
  color: var(--text-muted);
  border-top: 1px dashed var(--bg-tertiary);
  padding-top: 1.5rem;
  margin-top: 2rem;
}

@media (min-width: 768px) {
  .footer-disclaimer {
    text-align: left;
  }
}
