/* Ultra-Minimal Pagination Navigation */
.pagination-nav {
  z-index: 100;
}

/* Bottom position (default) */
.pagination-nav.pagination-bottom {
  position: sticky;
  bottom: 2rem;
  margin: 3rem auto 2rem auto;
  max-width: 240px;
}

/* Top position - inline with title using CSS Grid, no underline */
/* Use CSS Grid to place title and pagination on the same line */
/* PERFORMANCE: Using class instead of :has() for much faster rendering */
body.has-pagination-top main {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
}

body.has-pagination-top header.quarto-title-block {
  grid-column: 1;
  grid-row: 1;
  border-bottom: none !important;
  padding-bottom: 0 !important;
  margin-bottom: 0 !important;
  align-self: start;
}

.pagination-nav.pagination-top {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  margin: 0;
  padding: 0;
  background: transparent;
  z-index: 1000;
  pointer-events: auto;
}

/* Remove separator lines from title */
body.has-pagination-top .quarto-title::after {
  display: none !important;
}

/* All other content goes in second row spanning both columns */
body.has-pagination-top main > *:not(header):not(.pagination-nav) {
  grid-column: 1 / -1;
}

/* Ensure pagination doesn't break layout on smaller screens */
@media (max-width: 768px) {
  body.has-pagination-top main {
    display: block;
  }
  
  .pagination-nav.pagination-top {
    display: block;
    text-align: right;
    margin: 0.5rem 0 1rem 0;
  }
}

/* Top position container - right aligned and wider */
.pagination-nav.pagination-top .pagination-container {
  justify-content: flex-end;
  padding: 0.25rem 0.5rem;
  min-height: 40px;
  pointer-events: auto;
}

.pagination-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: transparent;
}

.pagination-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  color: var(--bs-secondary, #6c757d);
  text-decoration: none;
  border-radius: 0.375rem;
  transition: all 0.15s ease;
  border: none;
  cursor: pointer;
  pointer-events: auto;
  z-index: 1001;
  position: relative;
  flex-shrink: 0;
}

.pagination-btn:hover:not(.pagination-disabled) {
  background: var(--bs-light, #f8f9fa);
  color: var(--bs-body-color, #212529);
}

.pagination-btn:active:not(.pagination-disabled) {
  background: var(--bs-gray-200, #e9ecef);
}

.pagination-btn.pagination-disabled {
  color: var(--bs-gray-300, #dee2e6);
  cursor: default;
}

.pagination-icon {
  flex-shrink: 0;
  opacity: 0.7;
}

.pagination-btn:hover:not(.pagination-disabled) .pagination-icon {
  opacity: 1;
}

.pagination-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--bs-secondary, #6c757d);
}

.pagination-prefix {
  color: var(--bs-secondary, #6c757d);
  font-weight: 500;
}

.pagination-input {
  width: 2.5rem;
  padding: 0.25rem 0.5rem;
  text-align: center;
  border: 1px solid transparent;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--bs-body-color, #212529);
  background: transparent;
  transition: all 0.15s ease;
  cursor: pointer;
  pointer-events: auto;
  z-index: 1001;
  position: relative;
}

.pagination-input:hover {
  background: var(--bs-light, #f8f9fa);
  border-color: var(--bs-border-color, #dee2e6);
  cursor: text;
}

/* Top position input - no border, minimal styling */
.pagination-nav.pagination-top .pagination-input {
  border: none;
  background: transparent;
}

.pagination-input:focus {
  outline: none;
  background: var(--bs-body-bg, #fff);
  border-color: var(--bs-primary, #0d6efd);
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.1);
}

.pagination-input::-webkit-inner-spin-button,
.pagination-input::-webkit-outer-spin-button {
  opacity: 0;
}

.pagination-separator {
  color: var(--bs-secondary, #6c757d);
  font-weight: 400;
  font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
  .pagination-nav {
    max-width: 220px;
    bottom: 1.5rem;
  }
  
  .pagination-container {
    gap: 0.75rem;
    padding: 0.4rem 0.75rem;
  }
  
  .pagination-btn {
    width: 30px;
    height: 30px;
  }
  
  .pagination-icon {
    width: 16px;
    height: 16px;
  }
  
  .pagination-info {
    font-size: 0.8rem;
  }
  
  .pagination-input {
    width: 2.25rem;
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .pagination-nav {
    max-width: 200px;
  }
  
  .pagination-btn {
    width: 28px;
    height: 28px;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .pagination-btn:hover:not(.pagination-disabled) {
    background: rgba(255, 255, 255, 0.05);
  }
  
  .pagination-btn:active:not(.pagination-disabled) {
    background: rgba(255, 255, 255, 0.1);
  }
  
  .pagination-input:hover {
    background: rgba(255, 255, 255, 0.05);
  }
}

/* Override Quarto's back-to-top button position */
.back-to-top {
  right: 2rem !important;
  left: auto !important;
}

@media (max-width: 768px) {
  .back-to-top {
    right: 1rem !important;
  }
}

