.site-header:has([data-project-list]) { position: relative; z-index: 6; }
.site-header:has([data-project-list]) .header-inner { position: relative; }

.catalog-home .site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--charcoal);
}
.catalog-home .site-header .header-inner {
  width: min(100% - 4rem, 78rem);
  min-height: 3.95rem;
  gap: 0.75rem;
}
.catalog-home .site-header .wordmark { gap: 0.65rem; font-weight: 730; letter-spacing: normal; }
.catalog-home .header-nav { width: auto; }
.catalog-home .cabinet-heading h1 { margin: 0; font-size: clamp(2.4rem, 5.4vw, 4.4rem); }
.catalog-home #main { scroll-margin-block-start: 3.95rem; }

.project-list-trigger {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: var(--button-height);
  padding-inline: 0.65rem;
  border-radius: 0.65rem;
  list-style: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.project-list-trigger::-webkit-details-marker { display: none; }
.project-list-trigger::after {
  width: 0.38rem;
  height: 0.38rem;
  margin-block-start: -0.2rem;
  border: solid currentColor;
  border-width: 0 1px 1px 0;
  transform: rotate(45deg);
  transition: transform 210ms ease, margin 210ms ease;
  content: "";
}
.project-list-trigger:hover,
[data-project-list][data-visible] .project-list-trigger {
  color: var(--ink);
  background: var(--surface);
}
[data-project-list][data-visible] .project-list-trigger::after {
  margin-block-start: 0.12rem;
  transform: rotate(225deg);
}

.project-list-panel {
  position: absolute;
  z-index: 1;
  inset: 100% 0 auto auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0.88rem;
  width: min(43rem, 100%);
  max-height: min(44rem, calc(100vh - 7rem));
  max-height: min(44rem, calc(100dvh - 7rem));
  padding: 1rem 1.05rem 0.9rem;
  border: 1px solid #818b8059;
  border-radius: 0.95rem;
  background: #202226;
  box-shadow: 0 1.2rem 3.5rem #0008;
  color: var(--ink);
  white-space: normal;
  overflow: hidden;
  transform-origin: top right;
}
.project-list-panel:has([data-project-category="hubs"]:not([hidden])) { width: min(48rem, 100%); }
[data-project-list]:not([data-ready]) .project-list-panel { grid-template-rows: minmax(0, 1fr) auto; }
.project-list-panel > noscript { min-height: 0; overflow: auto; }
.project-list-static {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.15rem;
  overflow: auto;
}
[data-project-list][data-ready] .project-list-panel {
  opacity: 0;
  transform: translateY(-0.42rem) scale(0.985);
  pointer-events: none;
  transition: opacity 180ms ease, transform 220ms cubic-bezier(.22, .68, .26, 1);
}
[data-project-list][data-visible] .project-list-panel {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.project-list-shade {
  position: fixed;
  z-index: 5;
  inset: 0;
  background: #11131880;
  backdrop-filter: blur(5px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 210ms ease;
}
.project-list-shade[data-visible] {
  opacity: 1;
  pointer-events: auto;
}

.project-list-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  width: max-content;
  max-width: 100%;
  padding: 0.2rem;
  border: 1px solid var(--rule);
  border-radius: 0.7rem;
  background: var(--charcoal);
}
.project-list-tab {
  min-height: 2.75rem;
  padding-inline: 1rem;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 650;
  cursor: pointer;
}
.project-list-tab:hover { color: var(--ink); }
.project-list-tab[aria-selected="true"] {
  border-color: var(--selection-border);
  background: var(--selection);
  color: var(--accent);
}

.project-list-category {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 0.6rem;
}
[data-project-category="hubs"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.project-list-independent { display: grid; gap: 0.6rem; }
@media (min-width: 38.01rem) {
  [data-project-category="hubs"] {
    grid-template-areas: "m r" "independent r";
  }
  [data-project-family="m"] { grid-area: m; }
  [data-project-family="r"] { grid-area: r; }
  .project-list-independent { grid-area: independent; }
}
.project-list-groups {
  padding: 0.28rem;
  margin: -0.28rem;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-padding: 0.28rem;
  scrollbar-color: var(--control-border) transparent;
}
.project-list-category > .project-list-series,
.project-list-family {
  min-width: 0;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--rule);
  border-radius: 0.65rem;
  background: #191b1fc7;
}
.project-list-family-title {
  margin: 0.15rem 0.35rem 0.55rem;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
}
.project-list-family .project-list-model + .project-list-model {
  margin-top: 0.24rem;
  padding-top: 0.33rem;
  border-top: 1px solid var(--rule);
}
.project-list-series-title {
  margin: 0.1rem 0.35rem 0.22rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}
.project-list-models {
  display: grid;
  gap: 0.2rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.project-list-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  min-height: var(--button-height);
  padding: 0.28rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 0.42rem;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.3;
}
[data-project-category="hubs"] .project-list-link {
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.35;
}
.project-list-previews {
  display: flex;
  flex: none;
  gap: 0.5rem;
}
.project-list-thumb {
  flex: none;
  width: clamp(4.3rem, 11vw, 6.2rem);
  aspect-ratio: 32 / 19;
  background-repeat: no-repeat;
  background-position: var(--thumb-x) var(--thumb-y);
  background-size: 500% 200%;
}
[data-project-category="hubs"] .project-list-thumb {
  width: clamp(2.65rem, 7vw, 3.67rem);
  aspect-ratio: 8 / 11;
  background-size: 500% 400%;
}
[data-project-category="c-clamps"] .project-list-thumb {
  width: clamp(2.9rem, 8vw, 4.5rem);
  aspect-ratio: 10 / 9;
  background-size: 300% 100%;
}
.project-list-category[data-project-category="c-clamps"] { grid-template-columns: minmax(0, 1fr); }
[data-project-list][open] [data-project-category="calipers"]:not([hidden]) .project-list-thumb {
  background-image: url('/assets/menu-calipers-v107.webp?v=113');
  background-size: 500% 500%;
}
.project-list-category[data-project-category="levers"] { grid-template-columns: minmax(0, 1fr); }
[data-project-category="levers"] .project-list-previews { gap: 0.2rem; }
[data-project-list][open] [data-project-category="levers"]:not([hidden]) .project-list-thumb {
  background-image: url('/assets/menu-levers-v105.webp?v=106');
  background-size: 500% 200%;
}
[data-project-category="levers"] .project-list-thumb[data-thumbnail^="cr-"] {
  width: clamp(1.9rem, 9vw, 3.8rem);
}
[data-project-category="calipers"] .project-list-thumb[data-thumbnail^="cr-"] {
  width: clamp(2rem, 6.25vw, 2.8rem);
}
[data-project-list][open] [data-project-category="hubs"]:not([hidden]) .project-list-thumb {
  background-image: url('/assets/menu-hubs-v68.webp');
}
[data-project-list][open] [data-project-category="c-clamps"]:not([hidden]) .project-list-thumb {
  background-image: url('/assets/menu-c-clamps-v88.webp');
}
.project-list-link:hover { background: var(--surface-raised); color: var(--ink); }
.project-list-link[aria-current],
.project-list-link[data-project-target] {
  border-color: var(--selection-border);
  background: var(--selection);
  color: var(--accent);
}
.project-list-return {
  justify-self: start;
  padding: 0.2rem 0.35rem;
  color: var(--muted);
  font-size: 0.8rem;
}
.project-list-return:hover { color: var(--accent); }

@media (max-width: 45rem) {
  .project-list-category { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 64rem) {
  .catalog-home .site-header .header-inner { width: calc(100% - 2.6rem); }
}
@media (max-width: 44rem) {
  .catalog-home .site-header .header-inner {
    width: calc(100% - 1.6rem);
    min-height: 3.55rem;
    padding-block: 0.3rem;
    flex-wrap: nowrap;
  }
  .catalog-home #main { scroll-margin-block-start: 3.55rem; }
}
@media (max-width: 38rem) {
  .project-list-panel { gap: 0.65rem; padding: 0.75rem; }
  .project-list-category { grid-template-columns: minmax(0, 1fr); gap: 0.45rem; }
  .project-list-tabs { width: 100%; }
  .project-list-tab { flex: 1; padding-inline: 0.3rem; }
  [data-project-category="hubs"] .project-list-thumb { width: clamp(2.4rem, 11.6vw, 3.36rem); }
  .project-list-thumb { width: clamp(4.6rem, 24vw, 6.2rem); }
  .project-list-return { display: flex; align-items: center; min-height: var(--button-height); }
}

@media (prefers-reduced-motion: reduce) {
  .project-list-trigger::after,
  [data-project-list][data-ready] .project-list-panel,
  .project-list-shade { transition: none; }
}

/* Keep both CR models visible while the longer Tang list fills its own column. */
@media (min-width: 45.01rem) {
  [data-project-category="calipers"] { grid-template-areas: "cr tang eight" ". tang other"; grid-template-rows: auto 1fr; }
}
@media (min-width: 38.01rem) and (max-width: 45rem) {
  [data-project-category="calipers"] { grid-template-areas: "cr tang" "eight tang" "other tang"; }
}
@media (min-width: 38.01rem) {
  [data-project-category="calipers"] > :nth-child(1) { grid-area: cr; }
  [data-project-category="calipers"] > :nth-child(2) { grid-area: tang; }
  [data-project-category="calipers"] > :nth-child(3) { grid-area: eight; }
  [data-project-category="calipers"] > :nth-child(4) { grid-area: other; }
}
