/* Resources pages shared styles */
:root {
  --resource-max-width: 72ch;
}

/* Ensure in-page anchors scroll below fixed header on resource pages */
.resource-article [id],
.resources [id],
.resource-article :target,
.resources :target {
  scroll-margin-top: 110px;
}

/* Hero */
.resource-article .resource-hero {
  position: relative;
  background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
  padding-top: calc(100px + var(--spacing-xl));
  padding-bottom: var(--spacing-xl);
  overflow: hidden;
}
.resource-article .resource-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,.35), rgba(0,0,0,.55));
  z-index: 0;
}
.resource-article .resource-hero .container { position: relative; z-index: 1; }
.resource-article .resource-hero .section-title,
.resource-article .resource-hero .lead {
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,.4);
}

/* Typography & layout */
.resource-article .container > .article-intro p,
.resource-article .article-content p,
.resource-article .article-content ul,
.resource-article .article-content ol,
.resource-article .resource-content p,
.resource-article .resource-content ul,
.resource-article .resource-content ol {
  max-width: var(--resource-max-width);
}
.resource-article .article-content p,
.resource-article .resource-content p { line-height: 1.8; margin: 0 0 var(--spacing-md); }
.resource-article .article-content h2,
.resource-article .resource-content h2 { margin: var(--spacing-2xl) 0 var(--spacing-sm); line-height: 1.2; }
.resource-article .article-content h3,
.resource-article .resource-content h3 { margin: var(--spacing-xl) 0 var(--spacing-xs); line-height: 1.25; }
.resource-article .article-content hr,
.resource-article .resource-content hr { margin: var(--spacing-xl) 0; border: 0; border-top: 1px solid var(--light-gray); }
.resource-article .article-section { margin: var(--spacing-2xl) 0; }
/* Mild flow spacing inside sections */
.resource-article .article-section > * + * { margin-top: var(--spacing-md); }

/* Key takeaways card */
.resource-article .key-takeaways { 
  margin: var(--spacing-lg) 0 var(--spacing-xl);
  padding: var(--spacing-md) var(--spacing-lg);
  background: #f8fafc;
  border: 1px solid var(--light-gray);
  border-radius: 12px;
}
.resource-article .key-takeaways h2 { margin: 0 0 var(--spacing-sm); font-size: 1.25rem; }
.resource-article .key-takeaways ul { margin: 0; padding-left: 1.25rem; }
.resource-article .key-takeaways li { margin: 0.4rem 0; }
.resource-article .key-takeaways li::marker { color: var(--secondary-blue); }

/* Article figures */
.resource-article .article-figure { margin: var(--spacing-xl) 0; text-align: center; }
.resource-article .article-figure img { 
  display: block !important;
  margin: 0 auto !important;
  width: 100% !important;
  max-width: 900px !important; /* prevent overly wide images */
  height: auto !important; 
  border-radius: 12px !important; 
  box-shadow: 0 6px 24px rgba(0,0,0,0.08) !important; 
}
/* Narrow variant for tighter visuals */
.resource-article .article-figure.narrow img { max-width: 800px; }

/* Generic figure support (in case class isn't present) */
.resource-article figure { margin: var(--spacing-xl) auto; text-align: center; }
.resource-article figure img { 
  display: block !important; width: 100% !important; height: auto !important; margin: 0 auto !important;
  max-width: 900px !important; border-radius: 12px !important; box-shadow: 0 6px 24px rgba(0,0,0,0.08) !important;
}
.resource-article figure figcaption { margin-top: .5rem; font-size: .95rem; color: #667085; }

/* Images placed directly in article content paragraphs/lists */
.resource-article .article-content > p > img,
.resource-article .article-content > ul > li > img,
.resource-article .article-content > ol > li > img,
.resource-article .resource-content > p > img,
.resource-article .resource-content > ul > li > img,
.resource-article .resource-content > ol > li > img {
  display: block !important; margin: var(--spacing-lg) auto !important; width: 100% !important; max-width: 900px !important;
  height: auto !important; border-radius: 12px !important; box-shadow: 0 6px 24px rgba(0,0,0,0.08) !important;
}

/* Catch-all for plain images within article content */
.resource-article .article-content img:not(.no-figure),
.resource-article .resource-content img:not(.no-figure) {
  display: block !important;
  margin: var(--spacing-lg) auto !important;
  width: 100% !important;
  max-width: 900px !important;
  height: auto !important;
  border-radius: 12px !important;
  box-shadow: 0 6px 24px rgba(0,0,0,0.08) !important;
}

/* Final safeguard: any image inside resource article */
.resource-article img:not(.no-figure) {
  display: block !important;
  margin: var(--spacing-lg) auto !important;
  width: 100% !important;
  max-width: 900px !important;
  height: auto !important;
  border-radius: 12px !important;
  box-shadow: 0 6px 24px rgba(0,0,0,0.08) !important;
}

/* Explicit utility class for article images */
.resource-article img.article-image {
  display: block !important;
  margin: var(--spacing-lg) auto !important;
  width: 100% !important;
  max-width: 900px !important;
  height: auto !important;
  border-radius: 12px !important;
  box-shadow: 0 6px 24px rgba(0,0,0,0.08) !important;
}

/* Global utility (unscoped) as a failsafe */
img.article-image {
  display: block !important;
  margin: var(--spacing-lg) auto !important;
  width: 100% !important;
  max-width: 900px !important;
  height: auto !important;
  border-radius: 12px !important;
  box-shadow: 0 6px 24px rgba(0,0,0,0.08) !important;
}

/* Lists */
.resource-article .article-content ul,
.resource-article .resource-content ul { list-style: disc; padding-left: 1.5rem; margin: 0 0 var(--spacing-md); }
.resource-article .article-content ol,
.resource-article .resource-content ol { list-style: decimal; padding-left: 1.5rem; margin: 0 0 var(--spacing-md); }
.resource-article .article-content li,
.resource-article .resource-content li { margin: 0.5rem 0; line-height: 1.7; }
.resource-article .article-content li::marker,
.resource-article .resource-content li::marker { color: var(--secondary-blue); font-weight: 600; }
.resource-article .article-content li ul,
.resource-article .resource-content li ul { list-style: circle; margin-top: 0.35rem; margin-bottom: 0.35rem; padding-left: 1.25rem; }
.resource-article .article-content li ol,
.resource-article .resource-content li ol { margin-top: 0.35rem; margin-bottom: 0.35rem; padding-left: 1.25rem; }
.resource-article .article-content ul + p,
.resource-article .article-content ol + p,
.resource-article .resource-content ul + p,
.resource-article .resource-content ol + p { margin-top: var(--spacing-md); }
/* Headings followed by lists: ensure a tight but clear gap */
.resource-article .article-content h2 + ul,
.resource-article .article-content h2 + ol,
.resource-article .resource-content h2 + ul,
.resource-article .resource-content h2 + ol { margin-top: var(--spacing-sm); }
.resource-article .article-content h3 + ul,
.resource-article .article-content h3 + ol,
.resource-article .resource-content h3 + ul,
.resource-article .resource-content h3 + ol { margin-top: var(--spacing-xs); }
/* Slightly smaller text for nested items for hierarchy */
.resource-article .article-content li li,
.resource-article .resource-content li li { font-size: 0.95em; }

/* High-specificity safeguards to ensure bullets/indentation on all resource pages */
/* These override any aggressive resets from global CSS by scoping to resource articles */
.resource-article article.resource-content ul,
.resource-article .article-section ul {
  list-style: disc !important;
  padding-left: 1.5rem !important;
  margin: 0 0 var(--spacing-md) !important;
}
.resource-article article.resource-content ol,
.resource-article .article-section ol {
  list-style: decimal !important;
  padding-left: 1.5rem !important;
  margin: 0 0 var(--spacing-md) !important;
}
.resource-article article.resource-content li,
.resource-article .article-section li {
  margin: 0.5rem 0 !important;
  line-height: 1.7 !important;
}
.resource-article article.resource-content li::marker,
.resource-article .article-section li::marker {
  color: var(--secondary-blue) !important;
  font-weight: 600 !important;
}

/* Final catch-all: any list within resource articles */
.resource-article ul { list-style: disc !important; list-style-position: outside !important; padding-left: 1.5rem !important; margin-left: 1.25rem !important; }
.resource-article ol { list-style: decimal !important; list-style-position: outside !important; padding-left: 1.5rem !important; margin-left: 1.25rem !important; }
.resource-article li { margin: 0.5rem 0 !important; line-height: 1.7 !important; }
.resource-article li::marker { color: var(--secondary-blue) !important; font-weight: 600 !important; }

/* Ultra-specific path to match actual DOM structure and guarantee indentation */
.resource-article article.resource-content section.article-section ul {
  list-style: disc !important;
  list-style-position: outside !important;
  padding-left: 1.5rem !important;
  margin-left: 1.25rem !important;
  padding-inline-start: 1.75rem !important;
  margin-inline-start: 1rem !important;
}
.resource-article article.resource-content section.article-section ol {
  list-style: decimal !important;
  list-style-position: outside !important;
  padding-left: 1.5rem !important;
  margin-left: 1.25rem !important;
  padding-inline-start: 1.75rem !important;
  margin-inline-start: 1rem !important;
}

/* TOC */
.resource-article .article-toc { margin: var(--spacing-xl) 0; padding: var(--spacing-md); background: #f8fafc; border: 1px solid var(--light-gray); border-radius: 12px; }
.resource-article .article-toc ul { margin: .5rem 0 0; padding-left: 1.25rem; }
.resource-article .article-toc a { color: var(--primary-blue); text-decoration: none; }
.resource-article .article-toc a:hover { text-decoration: underline; }

/* Badges (for categories only, not external refs) */
.resource-article .article-meta { display:flex; gap: var(--spacing-sm); margin-bottom: var(--spacing-md); }
.resource-article .badge { background: rgba(59,130,246,.1); color: var(--secondary-blue); padding: .325rem .5rem; border-radius: 999px; font-size: .85rem; }

/* Tables */
.resource-article .table-responsive { width: 100%; overflow-x: auto; margin: var(--spacing-lg) 0; }
.resource-article .comparison-table { width: 100%; border-collapse: collapse; }
.resource-article .comparison-table th,
.resource-article .comparison-table td { border-bottom: 1px solid #e5e7eb; padding: .75rem; text-align: left; }
.resource-article .comparison-table thead th { background: #f3f4f6; font-weight: 600; }
.resource-article .comparison-table tbody tr:nth-child(even) { background: #fcfcfd; }

/* CTA row */
.resource-article .cta-row { display:flex; gap: var(--spacing-md); margin-top: var(--spacing-lg); }

/* Pros/Cons two-column layout */
.resource-article .pros-cons { 
  display: grid; 
  gap: var(--spacing-xl);
  margin: var(--spacing-lg) 0 var(--spacing-xl);
}
.resource-article .pros-cons > div h3 { margin: 0 0 var(--spacing-xs); }
.resource-article .pros-cons > div ul { margin: 0; padding-left: 1.25rem; }
@media (min-width: 768px) {
  .resource-article .pros-cons { grid-template-columns: 1fr 1fr; align-items: start; }
}

/* Aside */
.resource-article .article-aside { margin-top: var(--spacing-2xl); padding-top: var(--spacing-xl); border-top: 1px solid #e5e7eb; }

/* Mobile */
@media (max-width: 768px) {
  .resource-article .resource-hero { padding-top: 180px !important; padding-bottom: var(--spacing-lg); }
  .resources .resources-hero { padding-top: 180px !important; padding-bottom: var(--spacing-lg); }
  /* Catch-all for any hero within resources pages */
  .resource-article .hero { padding-top: 180px !important; }
  .resources .hero { padding-top: 180px !important; }
  /* Fallback: ensure main wrappers also clear header if a page lacks hero padding */
  main.resource-article { padding-top: 100px !important; }
  main.resources { padding-top: 100px !important; }
  .resource-article .cta-row { flex-direction: column; }
  /* Slightly smaller offset on mobile due to shorter header */
  .resource-article [id],
  .resources [id],
  .resource-article :target,
  .resources :target { scroll-margin-top: 180px !important; }
}

/* Resource-scoped buttons: ensure visibility and proper sizing */
.resource-article .btn-secondary {
  background-color: var(--primary-blue) !important;
  color: var(--white) !important;
  border-color: var(--primary-blue) !important;
}

.resource-article .btn-secondary:hover {
  background-color: var(--secondary-blue) !important;
  border-color: var(--secondary-blue) !important;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Support Bootstrap-style naming used in markup */
.resource-article .btn-block {
  display: block !important;
  width: 100% !important;
}

/* Sidebar card button spacing */
.resource-article .sidebar-card .btn { margin-top: var(--spacing-sm); }

/* =========================
   Resources Listing Page
   ========================= */
.resources .resources-hero {
  position: relative;
  background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
  padding-top: calc(100px + var(--spacing-xl));
  padding-bottom: var(--spacing-xl);
  color: var(--white);
}
.resources .resources-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,.25), rgba(0,0,0,.45));
  z-index: 0;
}
.resources .resources-hero .container { position: relative; z-index: 1; }
.resources .resources-hero .section-title,
.resources .resources-hero .lead {
  color: var(--white);
  text-shadow: 0 2px 8px rgba(0,0,0,.35);
}

/* Stronger contrast for outline buttons on the Resources hero */
.resources .resources-hero .btn-outline {
  background-color: rgba(255, 255, 255, 0.22) !important;
  color: var(--white) !important;
  border-color: var(--white) !important;
  border-width: 2px !important;
  backdrop-filter: blur(10px);
}
.resources .resources-hero .btn-outline:hover {
  background-color: var(--white) !important;
  color: var(--primary-blue) !important;
  border-color: var(--white) !important;
}

/* CTA row consistent with resource articles */
.resources .cta-row {
  display: flex;
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
}

.resources .resources-grid {
  display: grid;
  gap: var(--spacing-xl);
  margin-top: var(--spacing-xl);
}
@media (min-width: 768px) {
  .resources .resources-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }
}
@media (max-width: 768px) {
  .resources .cta-row { flex-direction: column; }
}

.resources .resource-card {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  background: var(--white);
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--spacing-lg);
  transition: transform .2s ease, box-shadow .2s ease;
}
.resources .resource-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}
.resources .resource-card-title { margin: 0; font-size: 1.25rem; }
.resources .resource-card-title a { color: var(--dark); text-decoration: none; }
.resources .resource-card-title a:hover { color: var(--secondary-blue); text-decoration: underline; }
.resources .resource-card-excerpt { margin: 0; color: #4b5563; }
.resources .resource-card-cta { margin-top: auto; }

/* Ensure visible secondary buttons within resources listing */
.resources .btn-secondary {
  background-color: var(--primary-blue) !important;
  color: var(--white) !important;
  border-color: var(--primary-blue) !important;
}
.resources .btn-secondary:hover {
  background-color: var(--secondary-blue) !important;
  border-color: var(--secondary-blue) !important;
}

.resources .resources-footer-cta { margin-top: var(--spacing-2xl); }
.resources .resources-footer-cta .sidebar-card {
  background: #f8fafc;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
}
