/* Post Layout with Three Columns - Scoped styles for post.html only */

/* Only apply these styles to the #post section to avoid affecting other pages */
/* Override existing blog.css styles with higher specificity */
#post .blog-container {
  max-width: 1250px !important;
  margin: 40px auto 0 auto !important;
  padding: 0 20px !important;
}

#post .blog-layout {
  display: grid !important;
  grid-template-columns: 250px 1fr 240px;
  gap: 15px;
  align-items: start;
  /* Override flex properties from blog.css */
  flex-direction: unset !important;
  flex: unset !important;
}

/* Reset and override blog-sidebar flex properties */
#post .blog-sidebar {
  grid-column: 1;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  /* Override flex properties */
  flex: unset !important;
  width: auto !important;
}

/* Reset and override blog-content flex properties */
#post .blog-content {
  grid-column: 2;
  min-width: 0; /* Prevent overflow */
  /* Override flex properties */
  flex: unset !important;
  width: auto !important;
}

/* Right sidebar (learnmorepost) */
#post .page-sidebar-fixed {
  grid-column: 3;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  width: 100%; /* Override the fixed 300px from body.css */
}

/* Ensure content containers have proper styling */
#post .content-container {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  padding: 40px;
  margin-bottom: 20px;
}

#post .content-container h1 {
  color: #2c3e50;
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 30px;
  line-height: 1.2;
}

/* Mobile CTA - hide on desktop */
#post .mobile-cta {
  display: none;
}

/* Tablet responsive (switch to single column) */
@media (max-width: 1200px) {
  #post .blog-layout {
    display: block !important;
    width: 100%;
    /* Reset all grid properties */
    grid-template-columns: none !important;
    gap: 0 !important;
    align-items: unset !important;
  }

  /* Main content - first */
  #post .blog-content {
    width: 100% !important;
    margin-bottom: 30px;
    /* Reset all positioning */
    position: static !important;
    float: none !important;
    display: block !important;
    grid-column: unset !important;
    grid-row: unset !important;
    order: unset !important;
    flex: none !important;
  }

  /* Right sidebar - second (after main content) */
  #post .page-sidebar-fixed {
    width: 100% !important;
    margin-bottom: 30px;
    /* Reset all positioning */
    position: static !important;
    float: none !important;
    display: block !important;
    grid-column: unset !important;
    grid-row: unset !important;
    order: unset !important;
    flex: none !important;
    max-height: none !important;
    overflow-y: visible !important;
    top: unset !important;
  }

  /* Left sidebar - third (TOC and categories) */
  #post .blog-sidebar {
    width: 100% !important;
    margin-bottom: 20px;
    /* Reset all positioning */
    position: static !important;
    float: none !important;
    display: block !important;
    grid-column: unset !important;
    grid-row: unset !important;
    order: unset !important;
    flex: none !important;
    max-height: none !important;
    overflow-y: visible !important;
    top: unset !important;
  }
}

/* Mobile responsive (single column) - specific adjustments for smaller screens */
@media (max-width: 768px) {
  #post .blog-container {
    padding: 0 15px;
    max-width: 100% !important;
  }

  /* Ensure all sidebar containers take full width */
  #post .sidebar-container {
    width: 100% !important;
    position: static !important;
    max-height: none !important;
    overflow-y: visible !important;
  }

  #post .toc-container,
  #post .categories-container {
    width: 100% !important;
    margin-bottom: 20px;
  }

  /* Hide mobile CTA since we're showing the actual sidebar */
  #post .mobile-cta {
    display: none !important;
  }

  #post .content-container {
    padding: 25px;
    border-radius: 8px;
    width: 100%;
    margin-bottom: 0;
  }

  #post .content-container h1 {
    font-size: 2rem;
    margin-bottom: 20px;
  }
}

/* Small mobile devices */
@media (max-width: 480px) {
  #post .blog-container {
    padding: 0 10px;
  }

  #post .content-container {
    padding: 20px;
  }

  #post .content-container h1 {
    font-size: 1.8rem;
  }
}

/* Ensure sidebar components have proper spacing */
#post .sidebar-container > * {
  margin-bottom: 20px;
}

#post .sidebar-container > *:last-child {
  margin-bottom: 0;
}

/* Override any conflicting styles from other CSS files for this specific layout */
#post .page-sidebar-fixed {
  position: sticky !important;
  width: 100% !important;
  flex-shrink: 0 !important;
}

/* Large screens - more space for content */
@media (min-width: 1250px) {
  #post .blog-layout {
    grid-template-columns: 280px 1fr 320px;
    gap: 25px;
  }

  #post .content-container {
    padding: 50px;
  }
}
