/* Professional Blog Enhancements */

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

:root {
  --primary-color: #2563eb;
  --primary-dark: #1d4ed8;
  --accent-color: #0f172a;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-accent: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

/* Sidebar visibility fix on mid-width screens (tablet / small laptop)
   Force light background and readable text even under device dark preference */
@media (max-width: 1200px) {
  .sidebar-container {
    background: #ffffff !important;
    color: #111827 !important;
    border: 1px solid #e2e8f0;
  }
  .sidebar-container h5 { color: #475569 !important; }
  .sidebar-container .short-about p { color: #111827 !important; }
  .sidebar-container .tags a {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #475569;
  }
  /* Ensure nested blocks in sidebar do not reintroduce dark bg */
  .sidebar-container *,
  .sidebar-container .panel,
  .sidebar-container .short-about,
  .sidebar-container .short-about * {
    background-color: transparent !important;
  }

  /* Also reinforce content text/headers contrast at this width */
  .post-container h1 { color: #111827 !important; font-weight: 700; }
  .post-container h2,
  .post-container h3,
  .post-container h4,
  .post-container h5,
  .post-container h6 { color: #111827 !important; font-weight: 600; }
  .post-container p,
  .post-container li { color: #111827 !important; }
}

@media (max-width: 1200px) and (prefers-color-scheme: dark) {
  .sidebar-container,
  .sidebar-container * {
    color: #111827 !important;
  }
  .sidebar-container { background: #ffffff !important; }
}

/* Enhanced Body and Typography */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  font-weight: 400;
  letter-spacing: -0.01em;
}

/* Modern Headers */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.025em;
  color: var(--accent-color);
  margin-bottom: 1rem;
}

h1 { font-size: 2.5rem; font-weight: 700; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

/* Enhanced Navigation */
.navbar-custom {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.navbar-custom.is-fixed {
  box-shadow: var(--shadow-md);
}

.navbar-brand {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--accent-color) !important;
}

.navbar-nav .nav-link {
  font-weight: 500;
  color: var(--text-primary) !important;
  transition: color 0.3s ease;
  position: relative;
}

.navbar-nav .nav-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--primary-color);
  transition: all 0.3s ease;
}

.navbar-nav .nav-link:hover::after {
  width: 100%;
  left: 0;
}

/* Post Preview Styling */
.post-preview {
  padding: 2rem;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  margin-bottom: 2rem;
  background: var(--bg-primary);
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

.post-preview:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-color);
}

.post-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.post-subtitle {
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.post-meta {
  font-size: 0.95rem; /* Increased font size */
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.post-meta > span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Tags Styling */
.post-meta .tag {
  font-size: 0.9rem; /* Increased font size */
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  transition: all 0.3s ease;
}

.post-meta .tag:hover {
  background-color: var(--primary-color);
  color: white;
}

/* Read More Button */
.btn.btn-primary {
  background: var(--gradient-primary);
  color: white !important;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-md);
}

.btn.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Sidebar Styling */
.sidebar-container {
  background: var(--bg-secondary);
  padding: 2rem;
  border-radius: 16px;
}

.sidebar-container .short-about {
  display: flex;
  flex-direction: column;
  align-items: center; /* Robust centering with flexbox */
}

.sidebar-container .short-about img {
  width: 120px;
  height: 120px;
  border-radius: 50% !important; /* Force circular shape */
  object-fit: cover; /* Prevent image distortion */
  margin-bottom: 1rem;
  box-shadow: 0 0 0 4px var(--bg-primary), 0 0 0 6px var(--primary-color);
}

.short-about p {
  font-size: 1.6rem; /* Final larger description text */
  color: var(--text-primary);
  min-height: 100px; /* Reserve more space for typed text */
}

.sidebar-container h5 {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.sidebar-container .tags a {
  display: inline-block;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.4rem 0.8rem;
  margin: 0.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.sidebar-container .tags a:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* Post Footer for alignment */
.post-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap; /* Allow wrapping on small screens */
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  row-gap: 1rem; /* Add some space between meta and button when they wrap */
}

/* Enhanced Social Links */
.sidebar-container .list-inline-item a i {
  font-size: 3rem; /* Final definitive icon size */
  transition: transform 0.3s ease;
}

.list-inline-item a {
  color: var(--text-muted);
  transition: background-color 0.3s ease;
  padding: 0.5rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 70px; /* Larger touch target */
  height: 70px; /* Larger touch target */
}

.list-inline-item a:hover i {
    transform: scale(1.1);
}

.list-inline-item a:hover {
  color: var(--primary-color);
  background: var(--bg-secondary);
  transform: translateY(-2px);
}

/* Enhanced Pagination */
.pagination {
  justify-content: center;
  margin-top: 3rem;
}

.page-link {
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin: 0 0.25rem;
  transition: all 0.3s ease;
}

.page-link:hover {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
  transform: translateY(-1px);
}

/* Responsive Enhancements */
@media (max-width: 768px) {
  .intro-header .page-heading h1,
  .intro-header .post-heading h1,
  .intro-header .site-heading h1 {
    font-size: 2rem;
  }

  .post-preview {
    padding: 1.5rem;
  }

  .sidebar-container {
    margin-top: 2rem;
    padding: 1.5rem;
  }
}

/* Dark Mode Support (keep light palette to avoid low-contrast mismatches) */
@media (prefers-color-scheme: dark) {
  :root {
    --text-primary: #1e293b;   /* light scheme text */
    --text-secondary: #475569;
    --text-muted: #64748b;
    --bg-primary: #ffffff;     /* keep white backgrounds */
    --bg-secondary: #f8fafc;
    --border-color: #e2e8f0;
    --accent-color: #0f172a;
  }

  body,
  article,
  .post-container,
  .sidebar-container {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
  }
  .post-container h1,
  .post-container h2,
  .post-container h3,
  .post-container h4,
  .post-container h5,
  .post-container h6,
  .post-container p,
  .post-container li {
    color: var(--text-primary) !important;
  }
  .post-preview {
    background: var(--bg-primary);
  }
}

/* Loading Animation */
.fade-in {
  animation: fadeIn 0.6s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Smooth Scrolling */
html {
  scroll-behavior: smooth;
}

/* Focus States for Accessibility */
*:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Header text color and shadow for readability */
.intro-header .site-heading h1,
.intro-header .post-heading h1,
.intro-header .post-heading .subheading,
.intro-header .site-heading .subheading {
    color: white;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
}

/* ==========================================================
   Mobile/Tablet readability overrides for post content only
   (Do not affect desktop; do not touch code blocks/mermaid)
   ========================================================== */
@media (max-width: 992px) {
  /* Base container typography on tablet */
  .post-container {
    font-size: 1.03rem;
    line-height: 1.75;
  }
  .post-container p,
  .post-container li {
    color: #111827 !important; /* ensure contrast on devices with auto-dark */
  }
  /* Headings on tablet */
  .post-container h1 { color: #111827 !important; font-weight: 700; }
  .post-container h2,
  .post-container h3,
  .post-container h4,
  .post-container h5,
  .post-container h6 { color: #111827 !important; font-weight: 600; }

  /* Tables on tablet */
  .post-container table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    background: #ffffff;
  }
  .post-container th,
  .post-container td {
    color: #111827 !important;
    border: 1px solid #e2e8f0;
    padding: 0.6rem 0.75rem;
    vertical-align: top;
  }
  .post-container thead th {
    background: #f8fafc;
    font-weight: 700;
  }
}

@media (max-width: 768px) {
  .post-container {
    font-size: 1.08rem;   /* ~18px */
    line-height: 1.8;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  .post-container h1 { font-size: 1.75rem; color: #111827 !important; font-weight: 700; }
  .post-container h2 { font-size: 1.4rem;  color: #111827 !important; font-weight: 600; }
  .post-container h3 { font-size: 1.2rem;  color: #111827 !important; font-weight: 600; }
  .post-container h4,
  .post-container h5,
  .post-container h6 { color: #111827 !important; }

  .post-container p,
  .post-container li {
    color: #111827 !important;
  }
  .post-container blockquote {
    color: #0f172a !important;
    border-left: 4px solid #e2e8f0;
    padding-left: 1rem;
  }

  /* Tables: readable in mobile, high contrast */
  .post-container table {
    width: 100%;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
    border-spacing: 0;
    background: #ffffff;
  }
  .post-container th,
  .post-container td {
    color: #111827 !important;
    border: 1px solid #e2e8f0;
    padding: 0.6rem 0.75rem;
    vertical-align: top;
  }
  .post-container thead th {
    background: #f8fafc;
    font-weight: 700;
  }
}
