/* Portfolio (issue #10 follow-up): sticky logo, main nav, and category submenu. */
:root {
  --portfolio-sticky-header: 8.5rem;
  --portfolio-sticky-submenu: 0px;
}

/* overflow-x: hidden on body computed overflow-y to auto and made body a
   scroll container, which prevents the nested category submenu from sticking
   in some browsers. overflow-x: clip on the root avoids a 100vw scrollbar
   without creating a scroll container. */
html:has(body.portfolio) {
  overflow-x: clip;
}

body.portfolio .skip-link {
  z-index: 50;
}

body.portfolio .site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: #fff;
  overflow-anchor: none;
}

body.portfolio .site-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 100vw;
  height: 100%;
  transform: translateX(-50%);
  background: #fff;
  z-index: -1;
  pointer-events: none;
  border-bottom: 1px solid transparent;
  box-sizing: border-box;
}

body.portfolio.is-scrolled .site-header::before {
  border-bottom-color: #050a30;
}

body.portfolio.is-compact-nav .site-header {
  padding-top: 8px;
}

body.portfolio.is-compact-nav .brand {
  font-size: 26px;
}

body.portfolio.is-compact-nav .brand img {
  width: 24px;
  height: 32px;
}

body.portfolio.is-compact-nav .site-header nav {
  padding: 8px 5% 10px;
  font-size: 17px;
}

body.portfolio .collection {
  scroll-margin-top: calc(var(--portfolio-sticky-header) + var(--portfolio-sticky-submenu, 0px) + 16px);
}

/* The display "Portfolio" heading uses a tight line-height, so its glyphs
   overflow the element box by about 9px. The 8px main padding left that ink
   under the sticky header even at scrollY 0. */
body.portfolio .portfolio-main {
  padding-top: 24px;
}

@media (max-width: 700px) {
  body.portfolio .portfolio-main {
    padding-top: 20px;
  }
}

@media (min-width: 701px) {
  /* Stretch the grid row to the collections column height so the submenu's
     containing block is taller than the menu itself. align-self: start keeps
     the sticky item only as tall as its links, which is what lets it stick. */
  body.portfolio .portfolio-layout {
    align-items: stretch;
  }

  body.portfolio .category-nav {
    position: sticky;
    top: var(--portfolio-sticky-header);
    align-self: start;
    z-index: 30;
    background: #fff;
    padding-top: 10px;
    padding-bottom: 10px;
  }
}

@media (max-width: 700px) {
  body.portfolio.is-compact-nav .brand {
    font-size: 22px;
  }

  body.portfolio.is-compact-nav .brand img {
    width: 20px;
    height: 26px;
  }

  body.portfolio.is-compact-nav .site-header nav {
    padding: 8px 0 10px;
    font-size: 13px;
    gap: 8px 16px;
  }

  /* Single horizontally scrollable row pinned under the sticky header. */
  body.portfolio .category-nav {
    position: sticky;
    top: var(--portfolio-sticky-header);
    z-index: 30;
    display: flex;
    flex-flow: row nowrap;
    align-items: center;
    gap: 12px 18px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    background: #fff;
    padding: 8px 0 10px;
    font-size: 14px;
  }

  body.portfolio .category-nav::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 100vw;
    height: 100%;
    transform: translateX(-50%);
    background: #fff;
    z-index: -1;
    pointer-events: none;
    border-bottom: 1px solid transparent;
    box-sizing: border-box;
  }

  body.portfolio.is-scrolled .category-nav::before {
    border-bottom-color: #050a30;
  }

  body.portfolio .category-nav a {
    flex: 0 0 auto;
    white-space: nowrap;
  }
}
