/* Disable auto-hide navbar on scroll */
#quarto-header.headroom {
  will-change: auto !important;
  transition: none !important;
}

#quarto-header.headroom--pinned,
#quarto-header.headroom--unpinned,
#quarto-header.headroom--top,
#quarto-header.headroom--not-top {
  transform: translateY(0) !important;
  position: fixed !important;
  top: 0 !important;
}

/* Improved Typography and Readability */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.7;
  color: #333;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  margin-top: 1.5em;
  margin-bottom: 0.75em;
  color: #1a1a1a;
}

h1 {
  font-size: 2.25rem;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.75rem;
  letter-spacing: -0.01em;
}

p {
  margin-bottom: 1.25em;
  max-width: 75ch;
}

.lead {
  font-size: 1.2rem;
  font-weight: 400;
  line-height: 1.6;
  color: #555;
  margin-bottom: 1.5rem;
}

.subtitle {
  color: #666;
  font-size: 1.25rem;
  margin-top: 0.5rem;
}

/* Improve content spacing */
.content section {
  margin-bottom: 3rem;
}

/* Better figure styling */
figure {
  margin: 2rem 0;
}

figcaption {
  font-size: 0.95rem;
  color: #666;
  font-style: italic;
  margin-top: 0.75rem;
  line-height: 1.5;
  text-align: center;
}

img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Navigation Bar Active Link Highlighting */
.navbar .nav-item .nav-link.active {
  background-color: #007bff !important;
  color: white !important;
  font-weight: 600;
  border-radius: 6px;
  padding: 8px 16px;
  margin: 0 4px;
  box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
  transform: translateY(-1px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.navbar .nav-item .nav-link {
  color: #495057 !important;
  padding: 8px 16px;
  margin: 0 4px;
  border-radius: 6px;
  transition: all 0.2s ease;
  position: relative;
  text-decoration: none !important;
}

.navbar .nav-item .nav-link:hover {
  background-color: #f8f9fa;
  color: #007bff !important;
  transform: translateY(-1px);
}

/* Optional: Add subtle animation */
@keyframes activePulse {
  0% { box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3); }
  50% { box-shadow: 0 2px 12px rgba(0, 123, 255, 0.5); }
  100% { box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3); }
}

.navbar .nav-item .nav-link.active {
  animation: activePulse 2s ease-in-out infinite;
}

/* Improve link accessibility and visibility */
a {
  color: #007bff;
  text-decoration: underline;
  transition: color 0.2s ease;
}

a:hover {
  color: #0056b3;
  text-decoration: underline;
}

a:focus {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

/* Center-align footer content */
.nav-footer {
  text-align: center !important;
  padding: 2rem 0;
  background-color: #f8f9fa;
  border-top: 1px solid #dee2e6;
}

.nav-footer-left,
.nav-footer-center,
.nav-footer-right {
  text-align: center !important;
  width: 100% !important;
}

.nav-footer-left p {
  text-align: center !important;
  margin: 0 auto !important;
  color: #666;
}

/* Improve code block readability */
code {
  background-color: #f5f5f5;
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-size: 0.9em;
}

pre {
  background-color: #f5f5f5;
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  line-height: 1.5;
}

/* Table of Contents improvements */
#TOC {
  background-color: #f8f9fa;
  padding: 1.5rem;
  border-radius: 8px;
  line-height: 1.8;
}

#TOC h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

/* Sidebar improvements */
.sidebar {
  font-size: 0.95rem;
  line-height: 1.6;
}

.sidebar-item-text {
  padding: 0.5rem 0;
}

/* Responsive design for mobile */
@media (max-width: 768px) {
  h1 {
    font-size: 1.75rem;
  }
  
  h2 {
    font-size: 1.5rem;
  }
  
  .lead {
    font-size: 1.1rem;
  }
  
  body {
    font-size: 1rem;
  }
  
  .content {
    padding: 1rem;
  }
  
  figure {
    margin: 1.5rem 0;
  }
  
  img {
    border-radius: 6px;
  }
}

/* Print styles for better readability */
@media print {
  body {
    font-size: 12pt;
    line-height: 1.6;
    color: #000;
  }
  
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
  }
  
  img {
    max-width: 100%;
    page-break-inside: avoid;
  }
  
  a {
    text-decoration: underline;
    color: #000;
  }
  
  .navbar, .nav-footer, .sidebar {
    display: none;
  }
}

/* Focus visible for keyboard navigation accessibility */
*:focus-visible {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

/* Skip to main content link for accessibility */
.skip-to-main {
  position: absolute;
  left: -9999px;
  z-index: 999;
}

.skip-to-main:focus {
  left: 0;
  background: #007bff;
  color: white;
  padding: 1rem;
  text-decoration: none;
}
