/*
 * Shared header geometry contract.
 * The design compiler writes the values from Layout Settings to :root.
 * Keep this bridge independent of the selected Header component so a logo
 * and desktop menu spacing setting follows Header v0 through Header v4.
 */

@media (min-width: 901px) {
  body[data-deceti-header="header-v0"] .deceti-megamenu,
  body[data-deceti-header="header-v1"] .deceti-megamenu,
  body[data-deceti-header="header-v2"] .sd2-main-nav .deceti-megamenu,
  body[data-deceti-header="header-v3"] .cys3-menu,
  body[data-deceti-header="header-v4"] .ch4-menu {
    gap: var(--spacing-menu-gap, 12px) !important;
  }
}

body[data-deceti-header="header-v0"] :is(.deceti-header-module--logo, .deceti-logo) img,
body[data-deceti-header="header-v1"] .deceti-logo img,
body[data-deceti-header="header-v2"] .sd2-brand img,
body[data-deceti-header="header-v3"] .cys3-logo img,
body[data-deceti-header="header-v4"] .ch4-logo img {
  width: var(--header-logo-max-width, 280px) !important;
  max-width: var(--header-logo-max-width, 280px) !important;
  height: auto !important;
  max-height: var(--header-logo-max-height, 72px) !important;
  object-fit: contain;
}

/* One submenu typography token follows every selectable Header component.
 * Keep the selectors here, in the shared header contract, so a theme's
 * legacy menu stylesheet cannot silently replace the saved admin value. */
body[data-deceti-header="header-v0"] .deceti-submenu a,
body[data-deceti-header="header-v1"] .deceti-submenu a,
body[data-deceti-header="header-v2"] .deceti-submenu a,
body[data-deceti-header="header-v3"] :is(.deceti-submenu, .cys3-submenu) a,
body[data-deceti-header="header-v4"] .ch4-submenu a {
  font-size: var(--font-navigation-submenu-size, 13px) !important;
}

/* Avoid a saved desktop size crowding the mobile Header controls. */
@media (max-width: 900px) {
  body[data-deceti-header] :is(.deceti-header-module--logo img, .deceti-logo img, .sd2-brand img, .cys3-logo img, .ch4-logo img) {
    max-width: min(var(--header-logo-max-width, 280px), 44vw) !important;
    max-height: min(var(--header-logo-max-height, 72px), 18vw) !important;
  }
}

/* Navigation geometry belongs to the shared layout contract, not to a
 * palette override. It preserves the original v0 item rhythm after the old
 * hover-color bridge is removed. */
@media (min-width: 901px) {
  /* Header v4 uses a wide navigation row. Keep its first menu item aligned
   * with the left content edge instead of centering the whole menu. */
  body[data-deceti-header="header-v4"] .ch4-menu {
    justify-content: flex-start !important;
  }

  body[data-deceti-header="header-v0"] .deceti-megamenu > li > a,
  body[data-deceti-header="header-v1"] .deceti-megamenu > li > a,
  body[data-deceti-header="header-v2"] .sd2-main-nav .deceti-megamenu > li > a,
  body[data-deceti-header="header-v3"] .cys3-menu > li > a,
  body[data-deceti-header="header-v4"] .ch4-menu > li > a {
    display: flex;
    align-items: center;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 12px !important;
    font-family: var(--font-navigation-family, Arial, sans-serif) !important;
    font-size: var(--font-navigation-size, 18px) !important;
    font-weight: var(--font-navigation-weight, 700) !important;
    line-height: 1.15 !important;
  }
}

@media (min-width: 1181px) {
  body[data-deceti-header="header-v4"] .ch4-menu {
    margin-left: 60px !important;
  }
}

/* Header v4 previously reserved a centered 1320px shell and a fixed 320px
 * logo column. Let the logo own only its rendered width and give the desktop
 * row more room, so a larger logo and a left-aligned menu can coexist. */
@media (min-width: 981px) {
  body[data-deceti-header="header-v4"] .ch4-header__inner {
    width: min(calc(100% - 24px), 1520px) !important;
    grid-template-columns: auto minmax(0, 1fr) auto !important;
  }
}

/* On medium desktop widths the phone number is the expendable item. Keeping
 * the icon, account and cart leaves the navigation row intact instead of
 * pushing it to the right or forcing it over the logo. */
@media (min-width: 981px) and (max-width: 1399px) {
  body[data-deceti-header="header-v4"] .ch4-phone__copy {
    display: none !important;
  }
}

@media (min-width: 981px) and (max-width: 1180px) {
  body[data-deceti-header="header-v4"] .ch4-logo img {
    width: min(var(--header-logo-max-width, 280px), 220px) !important;
    max-width: min(var(--header-logo-max-width, 280px), 220px) !important;
    max-height: min(var(--header-logo-max-height, 72px), 72px) !important;
  }

  body[data-deceti-header="header-v4"] .ch4-menu {
    gap: 6px !important;
    margin-left: 0 !important;
  }

  body[data-deceti-header="header-v4"] .ch4-menu > li > a {
    padding-inline: 6px !important;
    font-size: min(var(--font-navigation-size, 18px), 16px) !important;
  }
}
