/* A single compact row leaves the projects visible while browsing. */
body[data-page="portfolio"] .filters {
  position: sticky;
  top: calc(var(--anchor-offset, 84px) + 8px);
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 3px;
  margin-inline: auto;
  margin-bottom: 28px;
  padding: 4px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-padding-inline: 4px;
  scroll-snap-type: none;
  scrollbar-width: thin;
  scrollbar-color: #477582 #e5eeee;
  border: 1px solid rgba(39, 73, 89, .16);
  border-radius: 15px;
  background: rgba(255, 255, 255, .96);
  box-shadow: inset 0 1px 0 #fff, 0 5px 18px rgba(23, 49, 63, .1);
}

/* Use the rounded native track where supported; other engines keep the
   compact standard scrollbar above. Touch and keyboard scrolling stay native. */
@supports selector(::-webkit-scrollbar) {
  body[data-page="portfolio"] .filters {
    scrollbar-width: auto;
    scrollbar-color: auto;
  }
}

body[data-page="portfolio"] .filters::-webkit-scrollbar {
  display: block;
  height: 8px;
}

body[data-page="portfolio"] .filters::-webkit-scrollbar-track {
  margin-inline: 10px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: #e5eeee;
  background-clip: padding-box;
}

body[data-page="portfolio"] .filters::-webkit-scrollbar-thumb {
  min-width: 44px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: linear-gradient(90deg, #8bbabd, #365f70);
  background-clip: padding-box;
}

body[data-page="portfolio"] .filters::-webkit-scrollbar-thumb:hover {
  background: #365f70;
  background-clip: padding-box;
}

body[data-page="portfolio"] .filters::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

body[data-page="portfolio"] .filters .filter-button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 7px 13px;
  border-radius: 11px;
  color: var(--ink);
  background: transparent;
  font-size: .875rem;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
}

@media (hover: hover) {
  body[data-page="portfolio"] .filters .filter-button:hover {
    color: var(--dark-soft);
    background: #edf3f5;
  }
}

body[data-page="portfolio"] .filters .filter-button[aria-pressed="true"] {
  color: #fff;
  background: var(--dark-soft);
  box-shadow: 0 2px 5px rgba(23, 49, 63, .12);
}

body[data-page="portfolio"] .filters .filter-button:focus-visible {
  outline: 2px solid var(--focus, #007174);
  outline-offset: 1px;
}

/* Keep touch targets comfortable without adding a second row. */
@media (pointer: coarse), (max-width: 640px) {
  body[data-page="portfolio"] .filters .filter-button {
    min-height: 44px;
    padding-inline: 12px;
  }
}

/* Keep one compact sticky row on phones and short landscape viewports.
   The live header offset also follows browser resizing and enlarged text. */
@media (max-width: 640px), (max-height: 500px) {
  body[data-page="portfolio"] .filters {
    top: calc(var(--anchor-offset, 76px) + 4px);
    margin-bottom: 20px;
    padding: 3px;
    border-radius: 14px;
  }

  body[data-page="portfolio"] .filters .filter-button {
    padding-inline: 11px;
    border-radius: 10px;
    font-size: .8125rem;
  }
}

/* System contrast themes replace fills, so preserve a visible selected state. */
@media (forced-colors: active) {
  body[data-page="portfolio"] .filters .filter-button[aria-pressed="true"] {
    outline: 2px solid Highlight;
    outline-offset: -3px;
  }

  body[data-page="portfolio"] .filters .filter-button:focus-visible {
    text-decoration: underline;
    text-underline-offset: .2em;
  }
}

@media print {
  body[data-page="portfolio"] .filters {
    position: static;
    flex-wrap: wrap;
    overflow: visible;
    box-shadow: none;
  }
}
