/* =========================================================
   HC Header + WP Navigation (production)
   - Uses CSS variables for consistent offsets.
   - Supports fixed/solid/hidden header states.
   - Provides accessible focus-visible styles.
   - Handles WP Navigation overlay stacking and mobile panel layout.
========================================================= */

/* -------------------------
   Config variables
------------------------- */
:root {
  --hc-adminbar-h: 0px; /* Set via JS/PHP if WP admin bar is present */
  --hc-header-h: 72px;  /* Must match actual rendered header height */
  --hc-header-bg: var(--wp--custom--artisan--color--header, #f5e1d7e6);
  --hc-header-cream: var(--wp--custom--artisan--color--cream, #fcf8f4);
  --hc-header-ink: var(--wp--custom--artisan--color--ink, #5b5550);
  --hc-header-green: var(--wp--custom--artisan--color--green, #74c17c);
  --hc-header-green-hover: var(--wp--custom--artisan--color--green-hover, #69b971);
  --hc-header-width: var(--wp--custom--artisan--layout--wide, 1200.97px);
  --hc-header-gutter: var(--wp--custom--artisan--layout--page-gutter, clamp(18px, 3.52vw, 48px));
}

body.admin-bar {
  --hc-adminbar-h: 32px;
}

@media (max-width: 782px) {
  body.admin-bar {
    --hc-adminbar-h: 46px;
  }
}

/* -------------------------
   Theme structural override
   Note: Prefer scoping this to your theme wrapper if possible.
------------------------- */
body.home .wp-site-blocks > header.wp-block-template-part {
  height: 0;
}

/* -------------------------
   Header base
------------------------- */
.hc-header {
  position: absolute;
  top: calc(var(--hc-adminbar-h) + 23px);
  left: 0;
  right: 0;
  z-index: 100;
  transition: background-color .2s ease, box-shadow .2s ease, transform .2s ease;
  width: 100%;
  margin-inline: 0;
  padding-inline: 0 !important;
  box-sizing: border-box;
}

.hc-header:not(.has-background) {
  background-color: var(--hc-header-bg);
}

.hc-header .custom-logo-link,
.hc-header .custom-logo-link img {
  display: block;
}

.hc-header .custom-logo-link img {
  width: auto;
  max-height: 68px;
}

.hc-header > .wp-block-group,
.hc-header__row {
  width: min(var(--hc-header-width), calc(100% - (var(--hc-header-gutter) * 2))) !important;
  max-width: none;
  margin-inline: auto;
}

.hc-header__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  width: 100%;
}

.hc-header__brand,
.hc-header__nav-wrap,
.hc-header .header-cta-row {
  margin: 0;
}

.hc-header__nav-wrap {
  min-width: 0;
}

.hc-header .wp-block-group.alignwide {
  width: 100%;
}

.hc-header .wp-block-site-logo {
  margin: 0;
}

.hc-header .wp-block-site-logo img,
.hc-header .hc-header__logo img {
  width: 148px;
  height: auto;
}

.hc-header .hc-header__logo {
  width: 148px;
  margin: 0;
  line-height: 0;
}

.hc-header .main-header-nav,
.hc-header .header-cta-row,
.hc-header .header-cta-row .wp-block-buttons,
.hc-header .header-cta-row .wp-block-button {
  margin: 0;
}

.hc-header .header-cta-row {
  display: flex;
  align-items: center;
}

.hc-header .main-header-nav .wp-block-navigation__container {
  gap: 30px !important;
}

.hc-header .main-header-nav .wp-block-navigation-item__content {
  padding: 0 !important;
  font-size: 18.6667px !important;
  font-weight: 300;
  line-height: 1.2;
}

.hc-header .header-cta-btn .wp-block-button__link {
  min-height: 53.84px;
  min-width: 124.64px;
  padding: 0 28px !important;
  border: 0;
  border-radius: 999px;
  font-size: 14.6667px !important;
  font-weight: 400;
  line-height: 1 !important;
  box-shadow: none;
}

.hc-header .header-cta-btn .wp-block-button__link:not(.has-background) {
  background: var(--hc-header-green);
}

.hc-header .header-cta-btn .wp-block-button__link:not(.has-text-color) {
  color: #fff;
}

.hc-header .header-cta-btn .wp-block-button__link:hover {
  background: var(--hc-header-green-hover) !important;
  color: #fff !important;
}

/* Home page: allow transparent header until it becomes "solid" */
.home .hc-header:not(.hc-header--solid) {
  background: transparent !important;
}

/* -------------------------
   Header state modifiers
------------------------- */

/* Fixed header sticks beneath admin bar */
.hc-header--fixed {
  position: fixed;
  top: var(--hc-adminbar-h);
}

/* Solid header adds elevation/shadow */
.hc-header--solid {
  box-shadow: 0 10px 30px rgba(0, 0, 0, .08);
}

.hc-header--solid:not(.has-background) {
  background-color: var(--hc-header-bg);
}

/* Hidden state for scroll-down behavior */
.hc-header--hidden {
  transform: translateY(-100%);
}

/* -------------------------
   Document offsets (anchors / scrollIntoView)
------------------------- */
body.hc-has-fixed-header {
  scroll-padding-top: calc(var(--hc-adminbar-h) + var(--hc-header-h));
}

/* Keep header visible while the responsive menu is open */
body.hc-menu-open .hc-header,
body.hc-menu-open .hc-header--hidden {
  transform: none !important;
}

/* -------------------------
   WP Navigation overlay stacking
   Ensures the responsive container overlays content properly.
------------------------- */
.wp-block-navigation__responsive-container,
.wp-block-navigation__responsive-dialog {
  z-index: 100000;
}

/* Helper class when hero content sits behind header */
.has-hc-hero { padding-top: 120px; }

/* -------------------------
   Active/current link styling
   Targets both desktop navigation and responsive container content.
------------------------- */
.main-header-nav .wp-block-navigation-item__content[aria-current="page"],
.main-header-nav .current-menu-item > .wp-block-navigation-item__content,
.main-header-nav .wp-block-navigation-item__content:hover,
.wp-block-navigation__responsive-container-content
  .current-menu-item > .wp-block-navigation-item__content {
  color: var(--wp--preset--color--custom-gold) !important;
}

/* -------------------------
   Accessible focus treatment
   Uses focus-visible to avoid showing outlines on mouse click.
------------------------- */
.main-header-nav .wp-block-navigation-item__content:focus {
  outline: none;
  box-shadow: none !important;
}
.main-header-nav .wp-block-navigation-item__content:focus-visible {
  outline: 2px solid var(--hc-header-bg);
  outline-offset: 3px;
  border-radius: 2px;
}
.main-header-nav .wp-block-navigation-item__content:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}

/* Improve tap UX on iOS */
.main-header-nav a { -webkit-tap-highlight-color: transparent; }

/* =========================================================
   Mobile (<= 767px)
========================================================= */
@media (max-width: 767px) {
  .hc-header {
    width: 100%;
  }

  .hc-header > .wp-block-group,
  .hc-header__row {
    width: calc(100% - 36px) !important;
  }

  .hc-header__row {
    gap: 12px;
  }

  /* Responsive container background */
  .is-menu-open {
    background-color: var(--wp--preset--color--custom-linen) !important;
  }

  /* Close icon fill */
  .is-menu-open .wp-block-navigation__responsive-container-close svg {
    fill: var(--hc-header-ink) !important;
  }

  /* Force left-justified layout for the navigation container */
  .main-header-nav.wp-block-navigation,
  .main-header-nav .wp-block-navigation,
  .items-justified-right.main-header-nav.wp-block-navigation {
    --navigation-layout-justify: flex-start !important;
    --navigation-layout-justification-setting: flex-start !important;
  }

  .main-header-nav .wp-block-navigation__container {
    justify-content: flex-start !important;
  }

  .main-header-nav
    .wp-block-navigation__responsive-container
    .wp-block-navigation__container {
    justify-content: flex-start !important;
    align-items: flex-start !important;
    width: 100%;
  }

  /* Ensure toggle icons are comfortably tappable */
  .wp-block-navigation__responsive-container-close svg,
  .wp-block-navigation__responsive-container-open svg {
    width: 40px !important;
    height: 40px !important;
  }

  /* Mobile menu item typography */
  .wp-block-navigation__responsive-container-content
    .wp-block-navigation-item
    .wp-block-navigation-item__label {
    line-height: 56px !important;
    font-size: 24px !important;
    color: var(--hc-header-ink) !important;
  }

  /* Current menu item in the mobile panel */
  .wp-block-navigation__responsive-container-content
    .current-menu-item
    .wp-block-navigation-item__label {
    color: var(--wp--preset--color--custom-gold) !important;
  }

  /* Focus styles inside the mobile panel */
  .is-menu-open .wp-block-navigation__responsive-container-content
    .wp-block-navigation-item__content:focus {
    outline: none;
    box-shadow: none !important;
  }
  .is-menu-open .wp-block-navigation__responsive-container-content
    .wp-block-navigation-item__content:focus-visible {
    outline: 2px solid var(--hc-header-ink);
    outline-offset: 3px;
    border-radius: 2px;
  }
}

/* =========================================================
   Reduced motion
========================================================= */
@media (prefers-reduced-motion: reduce) {
  .hc-header {
    transition: background-color .2s ease, box-shadow .2s ease;
  }
  .hc-header--hidden {
    transform: none;
  }
}

/* =========================================================
   Global current item in responsive container contexts
========================================================= */
.wp-block-navigation__responsive-container-content
  .current-menu-item
  .wp-block-navigation-item__label {
  color: var(--wp--preset--color--custom-gold) !important;
}

/* =========================================================
   Submenu elements
========================================================= */
@media (min-width: 768px) {
	.wp-block-navigation__container>.wp-block-navigation-item {
		padding: 14px 0 !important;
	}

	.wp-block-navigation__container .wp-block-navigation__submenu-container {
		-webkit-box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3), 0 4px 6px -2px rgba(0,0,0,0.1);
		-moz-box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3), 0 4px 6px -2px rgba(0,0,0,0.1);
		box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3), 0 4px 6px -2px rgba(0,0,0,0.1);
		border-radius: 5px !important;
	}

	.wp-block-navigation__container .wp-block-navigation__submenu-container a {
		padding-top: 7px !important;
		padding-bottom: 7px !important;
		font-size: 1rem;
	}
}
