/* Scroll buttons and section index of every layout (#262, docs/rebuild/layout.md); driven by
   public/js/page-nav.js. z-index 1030: above the page, the footer and the bid box, below the Bootstrap modal
   backdrop (1040), the image viewer (lightGallery, 1040+) and the red top bar. */

:root {
  --page-nav-offset: 0px;
  --page-nav-red: #ec0016;
  --page-nav-sidebar: 264px;
}

/* Section marker (<x-page-section>): hash jumps land below the fixed top bar. */
.page-section-anchor {
  display: block;
  height: 0;
  overflow: hidden;
  scroll-margin-top: calc(var(--page-nav-offset) + 12px);
}

.page-section-flash {
  animation: page-section-flash 1.6s ease-out;
  border-radius: 4px;
}

.page-section-flash-frame {
  animation: page-section-flash-frame 1.6s ease-out;
}

@keyframes page-section-flash-frame {
  0%, 30% { box-shadow: 0 0 0 3px rgba(236, 0, 22, 0.45); }
  100% { box-shadow: 0 0 0 3px transparent; }
}

@keyframes page-section-flash {
  0%, 30% { box-shadow: 0 0 0 4px rgba(236, 0, 22, 0.45); }
  100% { box-shadow: 0 0 0 4px transparent; }
}

/* Round buttons bottom-right. */
.page-nav[hidden] {
  display: none;
}

.page-nav {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1030;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.page-nav__btn {
  pointer-events: auto;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: #333;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  opacity: 0.92;
}

.page-nav__btn:hover,
.page-nav__btn:focus-visible {
  opacity: 1;
  color: var(--page-nav-red);
}

.page-nav__btn:focus-visible {
  outline: 2px solid var(--page-nav-red);
  outline-offset: 2px;
}

.page-nav__btn[hidden] {
  display: none;
}

.page-nav__btn--index {
  background: var(--page-nav-red);
  color: #fff;
}

.page-nav__btn--index:hover,
.page-nav__btn--index:focus-visible {
  color: #fff;
}

/* Section index: shared look. */
.section-index {
  position: fixed;
  z-index: 1030;
  background: #fff;
  border: 1px solid #dee2e6;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  font-size: 14px;
}

.section-index[hidden] {
  display: none;
}

.section-index__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 8px 14px;
  border-bottom: 1px solid #dee2e6;
  font-weight: 600;
}

.section-index__close {
  border: 0;
  background: transparent;
  color: #555;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
}

.section-index__close:hover,
.section-index__close:focus-visible {
  background: #f1f1f1;
  color: var(--page-nav-red);
}

.section-index__list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.section-index__link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  color: #333;
  border-left: 3px solid transparent;
  line-height: 1.3;
}

.section-index__link:hover,
.section-index__link:focus-visible {
  background: #f6f6f6;
  color: #000;
  text-decoration: none;
}

.section-index__link.is-active {
  border-left-color: var(--page-nav-red);
  color: var(--page-nav-red);
  font-weight: 600;
}

.section-index__label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.section-index__count {
  color: #777;
  font-weight: 400;
  white-space: nowrap;
}

.section-index__error {
  flex: none;
  width: 9px;
  height: 9px;
  margin-left: auto;
  border-radius: 50%;
  background: #dc3545;
}

.section-index__link.has-error .section-index__label {
  color: #dc3545;
}

/* Wide screens (from 1400 px): sticky sidebar on the right; the page makes room for it. */
.section-index--sidebar {
  right: 16px;
  width: var(--page-nav-sidebar);
  border-radius: 6px;
}

body.has-section-index .content-wrapper {
  padding-right: calc(var(--page-nav-sidebar) + 24px);
}

/* Smaller screens: popover above the buttons. */
.section-index--popover {
  right: 16px;
  width: 300px;
  max-width: calc(100vw - 32px);
  max-height: 60vh;
  border-radius: 6px;
}

/* Phone: bottom sheet over the full width. */
@media (max-width: 575.98px) {
  .section-index--popover {
    left: 0;
    right: 0;
    bottom: 0 !important;
    width: auto;
    max-width: none;
    max-height: 65vh;
    border-radius: 12px 12px 0 0;
    z-index: 1031;
  }

  .page-nav__btn {
    width: 38px;
    height: 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .page-section-flash,
  .page-section-flash-frame {
    animation: none;
    box-shadow: 0 0 0 3px rgba(236, 0, 22, 0.45);
  }
}

@media print {
  .page-nav,
  .section-index {
    display: none !important;
  }
}
