/* Article Layout Optimizations */

/* Optimize layout for better content width */
@media (min-width: 1024px) {
  /* Flexbox layout for article and TOC - More specific selector */
  .container .lg\\:flex.lg\\:gap-12 {
    display: flex !important;
    align-items: flex-start !important;
    gap: 6rem !important;
  }
  
  /* Main content area */
  .lg\\:flex-1 {
    flex: 1 1 0% !important;
    min-width: 0 !important;
  }
  
  /* Left-align article content */
  article.prose {
    max-width: 800px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  
  /* TOC container width and alignment */
  aside.lg\\:w-80 {
    width: 22rem !important;
    flex-shrink: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
  
  /* TOC navigation styling */
  .toc-nav {
    font-size: 0.875rem !important;
    line-height: 1.5 !important;
    padding: 1.5rem !important;
    background-color: var(--b2) !important;
    border-radius: 0.5rem !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    width: 100% !important;
  }
  
  /* Override theme's TOC scrolling behavior */
  #TableOfContents {
    position: static !important;
    overflow-y: visible !important;
    overflow: visible !important;
    max-height: none !important;
    height: auto !important;
  }
  
  /* TOC list styling */
  .toc-nav ul {
    padding-left: 0 !important;
    list-style: none !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
  
  .toc-nav ul ul {
    padding-left: 1rem !important;
    margin-top: 0.25rem !important;
  }
  
  .toc-nav li {
    margin-bottom: 0.5rem !important;
  }
  
  .toc-nav a {
    color: var(--bc) !important;
    opacity: 0.7;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
    display: block !important;
    padding: 0.25rem 0.5rem !important;
    border-radius: 0.25rem !important;
  }
  
  .toc-nav a:hover {
    opacity: 1 !important;
    color: #059669 !important; /* emerald-600 */
    background-color: rgba(16, 185, 129, 0.15) !important;
  }
  
  .toc-nav a.active {
    opacity: 1 !important;
    color: #ffffff !important; /* pure white */
    background-color: #059669 !important; /* emerald-600 */
    font-weight: 600 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
  }
  
  /* Override any theme-specific active states */
  .toc-nav a.active,
  .toc-nav li > a[class*="active"],
  nav a.active {
    color: #ffffff !important;
    background-color: #059669 !important;
    opacity: 1 !important;
  }
  
  /* Dark theme TOC */
  [data-theme="forest"] .toc-nav,
  html.dark .toc-nav {
    background-color: rgba(30, 41, 59, 0.5) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
  }
  
  /* Dark theme active states */
  [data-theme="forest"] .toc-nav a.active,
  html.dark .toc-nav a.active {
    color: #ffffff !important;
    background-color: #059669 !important;
  }
}

/* For very wide screens, add max width to maintain readability */
@media (min-width: 1536px) {
  .container {
    max-width: 1400px !important;
  }
}

/* Mobile and tablet optimization */
@media (max-width: 1023px) {
  article.prose {
    max-width: none !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
}

/* Typography is now handled by typography-optimized.css */

/* Optimize images */
article.prose img {
  border-radius: 0.5rem !important;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
  margin-top: 2rem !important;
  margin-bottom: 2rem !important;
}

/* Move ads to less intrusive positions */
.dream-adsense {
  margin: 2rem auto !important;
  max-width: 720px !important;
  text-align: center !important;
}

/* Style the metadata section better */
article header {
  margin-bottom: 2rem !important;
  padding-bottom: 1rem !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
}

/* Dark mode adjustments */
[data-theme="forest"] article header,
html.dark article header {
  border-bottom-color: rgba(255, 255, 255, 0.1) !important;
}

/* Related posts section */
.related-posts {
  margin-top: 3rem !important;
  padding-top: 2rem !important;
  border-top: 1px solid rgba(0, 0, 0, 0.1) !important;
}

[data-theme="forest"] .related-posts,
html.dark .related-posts {
  border-top-color: rgba(255, 255, 255, 0.1) !important;
}

/* Navigation buttons enhancement */
.btn-outline {
  border-width: 1px !important;
  font-size: 0.875rem !important;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  article.prose {
    font-weight: 500 !important;
  }
  
  article header,
  .related-posts {
    border-width: 2px !important;
  }
}