/* ==========================================================================
   Section bar: slides in under the fixed site header once the page's own
   header has scrolled away. Drawn as one more row of the site header: the
   same opaque paper, shadow and type as its top row, so the two read as one
   piece. Markup: templates/pages/departments/parts/subnav.php; behaviour and
   the measured --dept-header-h / --dept-subnav-h: js/components/section-subnav.js.

   It began on the department template, hence the dept- names; the paid
   services page uses it too.
   ========================================================================== */

.dept-subnav {
  position: fixed;
  top: var(--dept-header-h, 0px);
  left: 0;
  right: 0;
  z-index: 60;
  background: var(--color-bg-primary);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  border-top: 1px solid var(--color-border);
  /* A hairline under it too: the soft shadow alone let the bar melt into a
     page of the same paper (tables, lists). */
  border-bottom: 1px solid var(--color-border);
  transform: translateY(-100%);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s ease, visibility 0s linear 0.3s;
}

.dept-subnav.is-visible {
  transform: none;
  opacity: 1;
  visibility: visible;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s ease, visibility 0s;
}

.dept-subnav__inner {
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 44px;
  padding: 0 calc(var(--wrap) * 2);
}

.dept-subnav__title {
  flex-shrink: 0;
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--color-text-heading);
  text-decoration: none;
}

.dept-subnav__list {
  position: relative;
  display: flex;
  gap: 2px;
  margin: 0 0 0 auto;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
}

.dept-subnav__list::-webkit-scrollbar {
  display: none;
}

/* A row longer than the bar is dragged sideways with a mouse (section-subnav.js). */
@media (hover: hover) and (pointer: fine) {
  .dept-subnav__list {
    cursor: grab;
  }

  .dept-subnav__list.is-dragging {
    cursor: grabbing;
    user-select: none;
  }

  .dept-subnav__list.is-dragging .dept-subnav__link {
    pointer-events: none;
  }
}

.dept-subnav__list li {
  flex-shrink: 0;
}

.dept-subnav__link {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease;
}


@media (min-width: 1600px) {
  .dept-subnav__title,
  .dept-subnav__link {
    font-size: 1rem;
  }
}

.dept-subnav__link:hover,
.dept-subnav__link.is-active {
  color: var(--color-text-heading);
}

.dept-subnav__indicator {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 2px;
  background: var(--color-text-heading);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), width 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s ease;
}

.dept-subnav__indicator.is-on {
  opacity: 1;
}

/* The arrow at the right end tucks the bar away under the header. */
.dept-subnav__toggle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.dept-subnav__toggle .ph-icon {
  width: 16px;
  height: 16px;
  transition: transform 0.25s ease;
}

.dept-subnav__toggle:hover,
.dept-subnav__toggle:focus-visible {
  color: var(--color-text-heading);
}

/*
 * Tucked away: the bar slides under the header and only the arrow stays out,
 * hanging from the header as a small tab that brings the bar back.
 */
.dept-subnav.is-visible.is-collapsed {
  transform: translateY(-100%);
  box-shadow: none;
}

.dept-subnav.is-collapsed .dept-subnav__toggle {
  position: absolute;
  top: 100%;
  right: calc(var(--wrap) * 2);
  width: 36px;
  height: 22px;
  /* Tucked away, the tab needs its own paper to show over the page. */
  background: var(--color-bg-primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.dept-subnav.is-collapsed .dept-subnav__toggle .ph-icon {
  transform: rotate(180deg);
}

.dept-subnav.is-collapsed :is(.dept-subnav__title, .dept-subnav__list) {
  visibility: hidden;
}

@media (max-width: 768px) {
  .dept-subnav__inner {
    padding: 0 12px 0 5vw;
    gap: 12px;
  }

  .dept-subnav__title {
    display: none;
  }

  /* The bar scrolls sideways; its right edge fades to say so. */
  .dept-subnav__list {
    margin-left: 0;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dept-subnav,
  .dept-subnav.is-visible {
    transition: none;
    transform: none;
  }
}
