/**
 * 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;
  height: 59px;
  overflow: hidden;
}

.site-header__logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.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 0.15s ease,
    color 0.15s ease;
}

.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: 24px;
  height: 24px;
  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: 40px;
  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: 24px;
  height: 24px;
  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;
}

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

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

/* —— 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);
}

.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-right: 1px solid var(--atsko-gray-400);
}

.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-charcoal);
  opacity: 0.7;
  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: rgba(95, 95, 95, 0.05);
  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;
}

.mega-menu__promo {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 4.5rem 4rem;
  border-radius: 16px;
  background: rgba(95, 95, 95, 0.05);
}

.mega-menu__promo-logo {
  width: 174px;
  height: auto;
  max-height: 64px;
  object-fit: contain;
}

/* —— 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) {
  .site-header__bar {
    padding-inline: 1rem;
  }

  .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 (max-width: 900px) {
  .site-header__toggle {
    display: inline-flex;
    margin-left: auto;
  }

  .site-header__nav {
    display: none;
    position: absolute;
    inset: 100% 0 auto;
    background: var(--atsko-white);
    border-bottom: 1px solid var(--atsko-gray-200);
    padding: 1rem;
  }

  .site-header.is-nav-open .site-header__nav {
    display: block;
  }

  .primary-menu {
    flex-direction: column;
    gap: 0.25rem;
  }

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

  .mega-menu {
    position: static;
    transform: none;
    width: 100%;
  }

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

  .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;
  }
}
