/* Shared site chrome: one header layout across home / resources / account / legal / guide.
   Optional slot: .header-search or .quick-search only — everything else stays aligned. */

.site-header,
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 28px;
  min-height: 78px;
  padding: 0 5vw;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  border-bottom: 1px solid var(--line, var(--border));
  backdrop-filter: blur(16px);
}

.site-header .brand,
.topbar .brand {
  justify-self: start;
  min-width: 0;
}

.site-header .site-nav,
.topbar .site-nav {
  justify-self: center;
}

.site-header .header-actions,
.topbar .header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  grid-column: 3;
  justify-self: end;
  margin-left: 0;
  flex: 0 0 auto;
}

.header-search {
  display: flex;
  align-items: center;
  order: 1;
}
.header-search input {
  width: 190px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line, var(--border));
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  outline: none;
}
.header-search input:focus {
  border-color: var(--plum);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--plum) 18%, transparent);
}

.header-actions .language-menu { order: 2; }
.header-actions .theme-toggle,
.header-actions .theme-toggle#themeToggle { order: 3; }
.header-actions .menu-toggle,
.header-actions .mobile-menu-button { order: 4; }
.header-actions .auth-trigger,
.header-actions .auth-menu { order: 5; }
.header-actions .header-search,
.header-actions .quick-search { order: 1; }

/* Language lives in the footer and opens upward. */
footer .language-menu .language-panel,
.footer .language-menu .language-panel,
.account-footer .language-menu .language-panel {
  top: auto;
  bottom: 44px;
  right: 0;
}

@media (max-width: 900px) {
  .site-header,
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .site-header .brand,
  .topbar .brand {
    flex: 0 1 auto;
    min-width: 0;
    justify-self: auto;
  }

  .site-header .header-actions,
  .topbar .header-actions {
    grid-column: auto;
    justify-self: auto;
    margin-left: auto;
    flex: 0 0 auto;
    gap: 8px;
  }

  .header-search {
    position: relative;
    width: 36px;
    height: 36px;
  }
  .header-search::before {
    content: "";
    position: absolute;
    left: 11px;
    top: 10px;
    width: 9px;
    height: 9px;
    border: 1.6px solid var(--ink);
    border-radius: 50%;
    pointer-events: none;
  }
  .header-search::after {
    content: "";
    position: absolute;
    left: 19px;
    top: 19px;
    width: 5px;
    height: 1.6px;
    background: var(--ink);
    transform: rotate(45deg);
    transform-origin: left center;
    pointer-events: none;
  }
  .header-search input {
    width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    border-radius: 10px;
    font-size: 0;
    cursor: pointer;
    background: transparent;
  }
  .header-search input::placeholder { color: transparent; }
  .header-search input:focus,
  .header-search input:not(:placeholder-shown) {
    position: absolute;
    right: 0;
    width: min(210px, 42vw);
    padding: 0 10px;
    font-size: 13px;
    background: var(--paper);
    cursor: text;
  }
  .header-search:focus-within::before,
  .header-search:focus-within::after { display: none; }
}

@media (max-width: 560px) {
  .site-header,
  .topbar {
    min-height: 66px;
    gap: 10px;
  }

  /* Mobile footer: language sits with brand, above link stack. */
  footer.footer,
  .footer.wrap,
  .account-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 12px;
    row-gap: 18px;
    align-items: start;
    line-height: 1.8;
  }

  footer.footer > div,
  .footer.wrap > div,
  .account-footer > div {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  footer.footer > nav,
  .footer.wrap > nav,
  .account-footer > nav {
    display: contents;
  }

  footer.footer .language-menu,
  .footer.wrap .language-menu,
  .account-footer .language-menu {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: start;
    z-index: 6;
  }

  footer.footer > nav > a,
  footer.footer > nav > span,
  .footer.wrap > nav > a,
  .footer.wrap > nav > span,
  .account-footer > nav > a,
  .account-footer > nav > button[data-account-signout],
  .account-footer > nav > span,
  footer.footer > small,
  .footer.wrap > small,
  .account-footer > small {
    grid-column: 1 / -1;
  }

  footer.footer .language-menu .language-panel,
  .footer.wrap .language-menu .language-panel,
  .account-footer .language-menu .language-panel {
    right: 0;
    left: auto;
    width: min(184px, calc(100vw - 24px));
  }
}
