/* ============================================
   Blog System Styles
   ============================================ */

/* Blog Post Typography */
.blog-content {
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--text-primary);
}

.blog-content h1,
.blog-content h2,
.blog-content h3,
.blog-content h4,
.blog-content h5,
.blog-content h6 {
  color: var(--text-primary);
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-weight: 600;
  line-height: var(--line-height-heading);
}

.blog-content h1 {
  display: none;
  /* Hide H1 in content to avoid duplication of page title */
}

/* Target the main post title specifically */
.blog-post header h1 {
  font-size: var(--font-size-h2);
  /* Shifted down from H1 */
  font-weight: 400 !important;
  border-bottom: none;
  /* Remove border underline */
  padding-bottom: 1rem;
  display: block;
  width: 100%;
  margin-bottom: 1rem;
  text-align: center;
  position: relative;
}

.blog-post header h1::after {
  content: '';
  position: absolute;
  width: 60px;
  /* Fixed width underline like H2/H3 */
  height: 3px;
  background-color: var(--accent);
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.section-heading {
  font-size: 36px;
  letter-spacing: 2px;
  margin-bottom: 0;
}

/* Use higher specificity to override sections.css */
article.blog-post .blog-content h2 {
  font-size: var(--font-size-h3);
  /* Shifted down from H2 */
  color: var(--text);
  border-bottom: none;
  /* Remove border underline */
  position: relative;
  padding-bottom: 0.5rem;
  margin-top: 3rem;
  margin-bottom: 1.5rem;
  display: block;
  width: 100%;
}

/* Add partial underline using ::after to match H3 style from sections.css */
article.blog-post .blog-content h2::after {
  content: '';
  position: absolute;
  width: 60px;
  /* Fixed width underline like H3 */
  height: 3px;
  /* Slightly thicker for H2 */
  background-color: var(--accent);
  bottom: 0;
  left: 0;
}

article.blog-post .blog-content h3 {
  font-size: var(--font-size-h4);
  /* Shifted down from H3 */
  color: var(--text);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  font-weight: 500;
  position: relative;
  /* Ensure we don't double up if sections.css applies too, but specificity should handle it. 
     sections.css adds ::after to .blog-content h3. 
     We want to keep that underline but change the text properties.
  */
}

/* Ensure H3 underline is visible and correct if we need to override sections.css */
article.blog-post .blog-content h3::after {
  content: '';
  position: absolute;
  width: 60px;
  height: 2px;
  background-color: var(--accent);
  bottom: -5px;
  /* Adjust positioning */
  left: 0;
}

.blog-content h4 {
  font-size: var(--font-size-h5);
  /* Shifted down from H4 */
  margin-top: 2rem;
}

.blog-content p {
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
}

.blog-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

.blog-content em {
  font-style: italic;
}

/* Links */
.blog-content a {
  color: var(--accent);
  text-decoration: underline;
  transition: var(--transition);
}

.blog-content a:hover {
  color: var(--accent-hover);
}

/* Lists */
.blog-content ul,
.blog-content ol {
  margin-bottom: 1.5rem;
  padding-left: 2rem;
  color: var(--text-secondary);
}

.blog-content li {
  margin-bottom: 0.5rem;
  line-height: var(--line-height-base);
}

.blog-content ul ul,
.blog-content ol ol {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

/* Code Blocks */
.blog-content code {
  background-color: rgba(142, 173, 207, 0.1);
  color: var(--accent);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.9em;
}

.blog-content pre {
  background-color: #1e1e1e;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 1.5rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.blog-content pre code {
  background-color: transparent;
  color: #d4d4d4;
  padding: 0;
  border-radius: 0;
  font-size: var(--font-size-small);
  line-height: var(--line-height-base);
}

/* Blockquotes */
.blog-content blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 1.5rem;
  margin: 2rem 0;
  font-style: italic;
  color: var(--text-secondary);
  background-color: var(--card-bg);
  padding: 1rem 1.5rem;
  border-radius: 4px;
}

.blog-content blockquote p {
  margin-bottom: 0.5rem;
}

.blog-content blockquote p:last-child {
  margin-bottom: 0;
}

/* Images */
.blog-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 2rem 0;
  box-shadow: var(--shadow-md);
}

/* Tables */
.blog-content table {
  width: 100%;
  margin-bottom: 2rem;
  border-collapse: collapse;
  background-color: var(--card-bg);
  border-radius: 8px;
  overflow: hidden;
}

.blog-content thead {
  background-color: rgba(142, 173, 207, 0.1);
}

.blog-content th,
.blog-content td {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-light);
  text-align: left;
}

.blog-content th {
  font-weight: 600;
  color: var(--text-primary);
}

.blog-content td {
  color: var(--text-secondary);
}

/* Horizontal Rule */
.blog-content hr {
  border: 0;
  border-top: 2px solid var(--border-light);
  margin: 3rem 0;
}

/* Pagination Styles */
.pagination .page-link {
  background-color: var(--card-bg);
  border-color: var(--border-light);
  color: var(--text-primary);
  transition: var(--transition);
}

.pagination .page-link:hover {
  background-color: rgba(142, 173, 207, 0.1);
  border-color: var(--border-accent);
  color: var(--accent);
}

.pagination .page-item.active .page-link {
  background-color: var(--accent);
  border-color: var(--accent);
  color: var(--dark-bg);
}

.pagination .page-item.disabled .page-link {
  background-color: var(--card-bg);
  border-color: var(--border-light);
  color: var(--text-secondary);
  opacity: 0.5;
}

/* Blog Cards */
.blog-card {
  background-color: var(--card-bg);
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
  border: 1px solid var(--border-light);
}

.blog-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg) !important;
  border-color: var(--border-accent);
}

.blog-img-container img {
  transition: transform 0.5s ease;
}

.blog-card:hover .blog-img-container img {
  transform: scale(1.05);
}

.hover-accent:hover {
  color: var(--accent) !important;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Featured Post */
.featured-hero {
  background-color: var(--card-bg);
  border: 1px solid var(--border-light);
}

.bg-gradient-overlay {
  background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.6) 50%, rgba(0, 0, 0, 0) 100%);
}

/* Responsive Typography - handled by global system */
@media (max-width: 768px) {
  .blog-content pre {
    padding: 1rem;
  }

  .blog-content th,
  .blog-content td {
    padding: 0.5rem;
  }
}

/* Syntax Highlighting Overrides */
.hljs {
  background-color: #1e1e1e !important;
  color: #d4d4d4 !important;
  padding: 1.5rem !important;
  border-radius: 8px;
  overflow-x: auto;
}

/* Blog Post Article Spacing */
.blog-post {
  padding-bottom: 3rem;
}

.blog-post header {
  margin-bottom: 3rem;
}

/* Featured Image */
.blog-post .featured-image {
  width: 100%;
  max-height: 500px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 3rem;
  box-shadow: var(--shadow-lg);
}

/* Reading Progress Bar (Optional Enhancement) */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background-color: var(--accent);
  z-index: 1040;
  transition: width 0.2s ease;
}

/* HTMX Indicator */
.htmx-indicator {
  display: none;
  opacity: 0;
  transition: opacity 200ms ease-in;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline-block;
  opacity: 1;
}

/* Hide native search input decorations */
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  display: none;
  -webkit-appearance: none;
}

input[type="search"] {
  -webkit-appearance: none;
  appearance: none;
  background-clip: padding-box;
}

/* Custom Clear Button Visibility */
.search-clear-visible {
  display: block !important;
}