/**
 * Site header + mega menus — matched to Figma Navbar (35:1442).
 *
 * @package Atsko
 */

.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--atsko-white);
  box-shadow: 0 4px 4px rgba(0, 0, 0, 0.12);
}

.site-header__bar {
  position: relative;
  z-index: 2;
  background: var(--atsko-white);
  /* Match blog/page content inset (Figma ~128px gutters on wide screens). */
  padding-inline: max(2rem, calc((100% - var(--atsko-container)) / 2));
}

.site-header__inner {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
  width: 100%;
  padding: 1.5rem 0 0;
  min-height: 3.6875rem;
}

.site-header__logo {
  display: block;
  flex-shrink: 0;
  width: 115px;
  min-width: 115px;
}

.site-header__logo img {
  display: block;
  width: 115px;
  height: auto;
}

.site-header__nav {
  flex: 1;
  padding-top: 5px;
}

.primary-menu {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
}

.primary-menu__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  /* Bottom padding bridges the trigger into the mega panel; keep it
     identical when open so the header bar doesn't grow. */
  padding: 0.5rem 1rem 2.5rem;
  border-radius: 4px 4px 0 0;
  color: var(--atsko-charcoal);
  font-family: var(--atsko-font-sans);
  font-size: 1.125rem;
  line-height: 1.5;
  transition:
    background-color var(--atsko-transition),
    color var(--atsko-transition);
}

.primary-menu__item.is-open .primary-menu__trigger,
.primary-menu__trigger[aria-expanded="true"] {
  background: var(--atsko-blue);
  color: var(--atsko-white);
}

.primary-menu__chevron {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.primary-menu__chevron--light {
  display: none;
}

.primary-menu__item.is-open .primary-menu__chevron--dark,
.primary-menu__trigger[aria-expanded="true"] .primary-menu__chevron--dark {
  display: none;
}

.primary-menu__item.is-open .primary-menu__chevron--light,
.primary-menu__trigger[aria-expanded="true"] .primary-menu__chevron--light {
  display: block;
}

.site-header__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1.5rem;
  padding: 0.875rem 0;
  flex-shrink: 0;
}

.site-header__search-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.site-header__icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--atsko-charcoal);
}

.site-header__icon-btn img {
  width: 18px;
  height: 18px;
  display: block;
}

.site-header__cart-count {
  position: absolute;
  top: -0.25rem;
  right: -0.35rem;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: var(--atsko-blue);
  color: var(--atsko-white);
  font-size: 0.65rem;
  line-height: 1.1rem;
  text-align: center;
  font-weight: 700;
}

.site-header__cart-count[hidden] {
  display: none;
}

.site-header__search-form {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(280px, 26vw);
  height: 34px;
  padding: 0.375rem 0.5rem 0.375rem 1rem;
  border-radius: 20px;
  background: var(--atsko-gray-100);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.site-header__search-form[hidden] {
  display: none;
}

.site-header.is-search-open [data-search-toggle] {
  display: none;
}

.site-header__search-input {
  flex: 1;
  border: 0;
  background: transparent;
  font-family: var(--atsko-font-sans);
  font-size: 1rem;
  font-style: italic;
  line-height: 1.2;
  color: var(--atsko-charcoal);
  outline: none;
  min-width: 0;
}

.site-header__search-input::placeholder {
  color: var(--atsko-gray-400);
}

.site-header__search-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
}

.site-header__search-submit img {
  width: 18px;
  height: 18px;
  display: block;
}

.site-header__account {
  position: relative;
}

.site-header__toggle {
  display: none;
  width: 2.5rem;
  height: 2.5rem;
  align-items: center;
  justify-content: center;
}

.site-header__toggle-icon,
.site-header__toggle-icon::before,
.site-header__toggle-icon::after {
  display: block;
  width: 1.25rem;
  height: 2px;
  background: currentColor;
}

.site-header__toggle-icon {
  position: relative;
}

.site-header__toggle-icon::before,
.site-header__toggle-icon::after {
  content: "";
  position: absolute;
  left: 0;
  transition:
    transform var(--atsko-transition),
    top var(--atsko-transition);
}

.site-header__toggle-icon::before {
  top: -6px;
}

.site-header__toggle-icon::after {
  top: 6px;
}

.site-header.is-nav-open .site-header__toggle-icon {
  background: transparent;
}

.site-header.is-nav-open .site-header__toggle-icon::before {
  top: 0;
  transform: rotate(45deg);
}

.site-header.is-nav-open .site-header__toggle-icon::after {
  top: 0;
  transform: rotate(-45deg);
}

body.nav-open {
  overflow: hidden;
}

/* —— Mega menus —— */
.mega-menu {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: min(100% - 4rem, var(--atsko-container));
  z-index: 1;
  border-top: 6px solid var(--atsko-blue);
  border-radius: 0 0 16px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.mega-menu[hidden],
.account-dropdown[hidden] {
  display: none;
}

.mega-menu__panel {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
  align-items: stretch;
  background: var(--atsko-white);
  padding: 2.5rem 4.5rem;
  border-radius: 0 0 16px 16px;
}

.mega-menu__panel--brands {
  grid-template-columns: 1fr;
  padding: 2.5rem 9rem 4.5rem;
}

.mega-menu__panel--company {
  grid-template-columns: 1fr 1fr 1fr;
  padding: 2.5rem 4.5rem 4.5rem;
}

.mega-menu__section-head {
  width: 100%;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--atsko-charcoal);
}

.mega-menu__eyebrow {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--atsko-blue);
  line-height: 1.12;
}

.mega-menu__links {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
}

.mega-menu__link {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  width: 100%;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid #dcdcdc;
  font-size: 0.875rem;
  line-height: 1.12;
  color: var(--atsko-charcoal);
}

.mega-menu__link img {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  object-fit: contain;
}

.mega-menu__link--all {
  border-bottom: 0;
  text-decoration: underline;
  margin-bottom: 0;
}

.mega-menu__col {
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  border-radius: 16px;
}

.mega-menu__product {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-height: 336px;
  padding: 1rem 0;
  border: 1px solid var(--atsko-gray-200);
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
}

.mega-menu__badge {
  position: absolute;
  top: 15px;
  left: 15px;
  z-index: 2;
  padding: 2px 10px 3px;
  border-radius: 4px;
  background: var(--atsko-yellow);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.5;
  text-transform: uppercase;
  color: #000;
}

.mega-menu__product-media {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 260px;
  max-width: 100%;
  min-height: 180px;
  padding: 1rem 1.5rem 0.5rem;
  box-sizing: border-box;
}

.mega-menu__product-img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 11.5rem;
  object-fit: contain;
  object-position: center;
  display: block;
}

.mega-menu__product-meta {
  width: 260px;
  max-width: 100%;
  padding: 0 1.5rem;
  text-align: center;
}

.mega-menu__product-title {
  margin: 0 0 0.65rem;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--atsko-charcoal);
}

.mega-menu__product-price {
  margin: 0;
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  font-size: 1.125rem;
  line-height: 1.5;
  color: var(--atsko-charcoal);
}

.mega-menu__product-price strong {
  color: var(--atsko-orange);
  font-weight: 700;
}

.mega-menu__brands-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem 0.5rem;
  width: 100%;
}

.mega-menu__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.5rem 0.25rem 2rem;
  text-align: center;
}

.mega-menu__brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 174px;
  max-width: 100%;
  /* Room for logos; do not force a fixed image height. */
  min-height: 2.5rem;
}

.mega-menu__brand-logo img {
  display: block;
  width: auto;
  height: auto;
  max-width: 174px;
  max-height: 64px;
  object-fit: contain;
}

.mega-menu__brand-text {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 900;
  font-size: 1.5rem;
  line-height: 1.12;
  text-transform: uppercase;
  color: #000;
}

.mega-menu__brand-label {
  margin: 0;
  width: 150px;
  max-width: 100%;
  font-size: 0.875rem;
  line-height: 1.12;
  color: var(--atsko-charcoal);
  text-align: center;
}

.mega-menu__brand-label--link {
  text-decoration: underline;
}

.mega-menu__brand--view-all {
  justify-content: center;
}

/* —— Account dropdown —— */
.account-dropdown {
  position: absolute;
  top: calc(100% + 1.25rem);
  right: -4.5rem;
  z-index: 5;
  width: 230px;
}

.account-dropdown__caret {
  display: block;
  width: 27px;
  height: 14px;
  margin: 0 auto 0;
  position: relative;
  top: 6px;
  z-index: 1;
}

.account-dropdown__inner {
  padding: 2.5rem;
  background: var(--atsko-gray-100);
  border-top: 6px solid var(--atsko-blue);
}

.account-dropdown__title {
  margin: 0 0 0.95rem;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.09;
  color: var(--atsko-charcoal);
}

.account-dropdown__links {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

.account-dropdown__links a {
  font-size: 0.875rem;
  line-height: 1.12;
  color: var(--atsko-charcoal);
}

.account-dropdown__links a:hover {
  color: var(--atsko-blue);
  text-decoration: underline;
}

@media (max-width: 1100px) and (min-width: 901px) {
  .site-header {
    grid-template-columns: 1rem 115px minmax(0, 1fr) auto 1rem;
    column-gap: 1rem;
  }

  .site-header__logo {
    padding-top: 1rem;
  }

  .site-header__nav {
    padding-top: calc(1rem + 5px);
  }

  .site-header__actions {
    padding: calc(0.875rem + 1rem) 0 0;
  }
}

@media (max-width: 1100px) {
  .site-header__inner {
    width: 100%;
    align-items: center;
    padding: 1rem 0;
  }

  .mega-menu__panel,
  .mega-menu__panel--company,
  .mega-menu__panel--brands {
    padding: 1.5rem;
  }

  .mega-menu__brands-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .site-header__search-form {
    width: min(240px, 40vw);
  }
}

@media (min-width: 901px) {
  .site-header__panel {
    display: contents;
  }

  .site-header {
    display: grid;
    grid-template-columns:
      max(2rem, calc((100% - var(--atsko-container)) / 2))
      115px minmax(0, 1fr) auto
      max(2rem, calc((100% - var(--atsko-container)) / 2));
    align-items: start;
    column-gap: 2rem;
  }

  .site-header__overlay {
    display: none;
  }

  .site-header__bar {
    display: contents;
    padding: 0;
  }

  .site-header__inner {
    display: contents;
  }

  .site-header__logo {
    grid-column: 2;
    grid-row: 1;
    justify-self: start;
    padding-top: 1.5rem;
  }

  .site-header__nav {
    grid-column: 3;
    grid-row: 1;
    padding-top: calc(1.5rem + 5px);
  }

  .site-header__actions {
    grid-column: 4;
    grid-row: 1;
    padding: calc(0.875rem + 1.5rem) 0 0;
  }

  .site-header__toggle {
    display: none;
  }

  /* Panel uses display:contents, so megas become grid row-1 items; anchor below header row. */
  .mega-menu {
    top: 100%;
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .site-header__overlay {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: rgba(0, 0, 0, 0.7);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--atsko-transition);
  }

  .site-header.is-nav-open .site-header__overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .site-header.is-nav-open {
    position: fixed;
    inset: 0;
    z-index: 200;
    overflow: hidden;
    background: transparent;
    box-shadow: none;
  }

  .site-header.is-nav-open .site-header__bar {
    position: relative;
    z-index: 2;
    background: var(--atsko-white);
    box-shadow: 0 4px 4px rgba(0, 0, 0, 0.12);
  }

  .site-header__panel {
    display: none;
  }

  .site-header.is-nav-open .site-header__panel {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    top: var(--site-header-bar-height, 4.75rem);
    bottom: 0;
    z-index: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    background: var(--atsko-white);
  }

  .site-header__toggle {
    display: inline-flex;
    margin-left: auto;
  }

  .site-header__nav {
    padding: 0;
    border-bottom: 1px solid var(--atsko-gray-200);
  }

  .primary-menu {
    flex-direction: column;
    gap: 0;
    width: 100%;
  }

  .primary-menu__item {
    width: 100%;
    border-bottom: 1px solid var(--atsko-gray-200);
  }

  .primary-menu__item.is-open,
  .primary-menu__item:last-child {
    border-bottom: 0;
  }

  .primary-menu__trigger,
  .primary-menu__item.is-open .primary-menu__trigger,
  .primary-menu__trigger[aria-expanded="true"] {
    display: flex;
    width: 100%;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    border-radius: 0;
  }

  .mega-menu {
    position: static;
    transform: none;
    width: 100%;
    border-top: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .mega-menu__panel,
  .mega-menu__panel--company {
    grid-template-columns: 1fr;
  }

  .mega-menu__product {
    display: none;
  }

  .site-header__actions {
    gap: 1rem;
  }

  .site-header__search-form {
    position: absolute;
    left: 1rem;
    right: 1rem;
    top: calc(100% + 0.5rem);
    width: auto;
    z-index: 3;
  }

  .account-dropdown {
    right: 0;
  }
}
