/* Site header (D-044, layout B): a navy masthead (logo, search, methodology, language),
   a white strip of departments and tools, and the current department's categories. */

@layer components {
.site-header {
  position: relative;
  & ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; }
  & :focus-visible { outline-color: var(--orange); }
}

.masthead {
  background: var(--header-bg);
  color: var(--header-text);

  & .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-5); padding-block: var(--space-3); }
  & .search {
    flex: 1; margin: 0; max-width: 34rem;
    & input { width: 100%; background: var(--header-field-bg); border-color: var(--header-field-line); color: var(--header-text); }
    & input::placeholder { color: var(--header-placeholder); }
    & button { display: none; } /* Enter submits; the label stays for screen readers */
  }

  @media (max-width: 48rem) {
    & .search { order: 3; flex-basis: 100%; max-width: none; }
    & .utility { margin-left: auto; }
  }
}

.logo {
  font-size: 1.6rem; font-weight: 800; font-stretch: var(--narrow); letter-spacing: 0.01em;
  color: var(--header-text); text-decoration: none;
  &::after { content: "."; color: var(--orange); display: inline-block; transform-origin: 50% 85%; }
}

.utility {
  margin-left: auto; font-size: 0.875rem;
  & ul { gap: var(--space-4); }
  & a {
    color: var(--header-text); text-decoration: none; padding-bottom: 2px;
    background: linear-gradient(var(--orange), var(--orange)) no-repeat left bottom / 0% 2px;
  }
  & a:hover, & a[aria-current] { background-size: 100% 2px; }
  & .languages [aria-current] { font-weight: 700; color: var(--orange); }
}

/* Departments and tools. Scrolls sideways on narrow screens instead of a hamburger menu. */
.sections {
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  & .wrap { overflow-x: auto; scrollbar-width: none; }
  & ul { flex-wrap: nowrap; white-space: nowrap; }
  & a {
    display: block; padding: var(--space-3) var(--space-3); font-weight: 600; color: var(--text); text-decoration: none;
    /* The underline is a background line, so it can slide in (motion.css, D-042). */
    background: linear-gradient(var(--orange), var(--orange)) no-repeat left bottom / 0% 3px;
  }
  & .wrap > ul > li:first-child > a { padding-left: 0; }
  & a:hover, & a[aria-current] { background-size: 100% 3px; }
  & a:hover:not([aria-current]) { color: var(--link); }
}

/* "Products ▾" (owner, 2026-12-04): a disclosure listing each department's categories,
   so products read as one menu beside Rankings, Brands and Knowledge. No script: the
   summary opens and closes it. The bar no longer scrolls sideways (four short items
   fit a phone), so the panel is not clipped. */
.sections .wrap { overflow: visible; }
.nav-menu {
  position: relative;
  & summary {
    display: flex; align-items: center; gap: 0.35rem; cursor: pointer; list-style: none;
    padding: var(--space-3) var(--space-3) var(--space-3) 0; font-weight: 600;
    background: linear-gradient(var(--orange), var(--orange)) no-repeat left bottom / 0% 3px;
    &::-webkit-details-marker { display: none; }
    &::after { content: "▾"; font-size: 0.9em; line-height: 1; transition: transform 0.15s ease; }
    &:hover { color: var(--link); }
    &:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
  }
  &.is-current summary, & details[open] summary { background-size: 100% 3px; }
  & details[open] summary::after { transform: rotate(180deg); }
}
.nav-menu__panel {
  position: absolute; left: 0; top: 100%; z-index: 20; min-width: 15rem;
  padding: var(--space-2); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 28px rgb(20 33 61 / 0.16);
  & ul { display: block; margin: 0; padding: 0; list-style: none; white-space: normal; }
  & a { padding: var(--space-2) var(--space-3); border-radius: var(--radius); background: none; font-weight: 500; }
  & a:hover { background: var(--hover); color: var(--text); }
  & a[aria-current] { font-weight: 700; color: var(--accent-text); }
  & .nav-menu__all { font-weight: 700; border-bottom: 1px solid var(--line); border-radius: 0; margin-bottom: var(--space-1); }
}

/* Categories of the current department. */
.subnav {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  & .wrap { padding-block: var(--space-2); overflow-x: auto; }
  & ul { gap: var(--space-2); flex-wrap: nowrap; white-space: nowrap; }
  & a {
    display: block; padding: 0.2rem 0.65rem; font-size: 0.9rem; border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--bg); color: var(--text); text-decoration: none; transition: border-color 0.2s;
  }
  & a:hover { border-color: var(--field-line); }
  & a[aria-current] { background: var(--navy); border-color: var(--navy); color: #fff; }
}

@media (prefers-color-scheme: dark) {
  .subnav a[aria-current] { background: var(--orange); border-color: var(--orange); color: var(--btn-text); }
}

/* Decorative line that runs once along the bottom of the header (motion.css). */
.stride { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; pointer-events: none; }
.nav-menu__panel ul a { display: flex; align-items: center; gap: 0.55rem; }
.nav-menu__panel .category-icon { width: 1.25rem; height: 1.25rem; flex: none; }

}
