/**
 * Header Builder — Front-end Styles.
 *
 * CSS Grid layout for the header builder rows and zones.
 * Uses CSS variables for dynamic values set by the Customizer.
 *
 * @package Semilla
 * @since 0.2.0
 */

/* --------------------------------------------------------------------------
 * Layout: Base
 * -------------------------------------------------------------------------- */

.sem-header-layout {
  position: relative;
  z-index: 100;
  width: 100%;
}

/* --------------------------------------------------------------------------
 * Row: Shared
 * -------------------------------------------------------------------------- */

.sem-header-row {
  position: relative;
  display: flex;
  align-items: var(--sem-row-align, center);
  min-height: var(--sem-row-height, 80px);
  padding-top: var(--sem-row-padding-top, 0px);
  padding-bottom: var(--sem-row-padding-bottom, 0px);
  background: var(--sem-row-bg, #ffffff);
  color: var(--sem-row-color, var(--sem-color-text));
  border-color: var(--sem-color-border);
  transition: background 0.2s ease;
}

.sem-header-row__inner {
  width: 100%;
}

.sem-header-row--contained .sem-header-row__inner {
  max-width: var(--sem-container-max, 1200px);
  margin: 0 auto;
  padding-left: var(--sem-spacing-md, 1rem);
  padding-right: var(--sem-spacing-md, 1rem);
}

.sem-header-row--full .sem-header-row__inner {
  padding-left: var(--sem-spacing-md, 1rem);
  padding-right: var(--sem-spacing-md, 1rem);
}

/* Borders */
.sem-header-row--border-top {
  border-top: 1px solid var(--sem-color-border);
}

.sem-header-row--border-bottom {
  border-bottom: 1px solid var(--sem-color-border);
}

/* Shadow */
.sem-header-row--shadow {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* --------------------------------------------------------------------------
 * Row: 3-zone grid
 * -------------------------------------------------------------------------- */

.sem-header-row__grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: var(--sem-row-align, center);
  gap: var(--sem-row-zone-gap, 20px);
  min-height: var(--sem-row-height, 80px);
}

/* --------------------------------------------------------------------------
 * Zone
 * -------------------------------------------------------------------------- */

.sem-header-zone {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
}

.sem-header-zone--left {
  justify-content: flex-start;
}

.sem-header-zone--center {
  justify-content: center;
}

.sem-header-zone--right {
  justify-content: flex-end;
}

/* --------------------------------------------------------------------------
 * Element wrapper
 * -------------------------------------------------------------------------- */

.sem-header-element {
  display: flex;
  align-items: center;
}

/* --------------------------------------------------------------------------
 * Responsive visibility
 * -------------------------------------------------------------------------- */

@media (max-width: 1023px) {
  .sem-hidden-tablet {
    display: none !important;
  }
}

@media (min-width: 1024px) {
  .sem-hidden-desktop {
    display: none !important;
  }
}

@media (max-width: 767px) {
  .sem-hidden-mobile {
    display: none !important;
  }
}

/* --------------------------------------------------------------------------
 * Logo in header
 * -------------------------------------------------------------------------- */

.sem-header-element--logo .custom-logo-link {
  display: block;
  line-height: 1;
}

.sem-header-element--logo .custom-logo {
  height: auto;
  max-width: 100%;
  vertical-align: middle;
}

.sem-logo--text .sem-logo__link {
  text-decoration: none;
  color: inherit;
}

.sem-logo__title {
  font-size: 1.25rem;
  font-weight: 700;
}

.sem-logo__description {
  display: block;
  font-size: 0.75rem;
  color: var(--sem-color-text-light);
}

/* --------------------------------------------------------------------------
 * Menu in header
 * -------------------------------------------------------------------------- */

.sem-header-element--primary-menu .sem-menu__list,
.sem-header-element--secondary-menu .sem-menu__list {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 4px;
}

.sem-header-element--primary-menu .sem-menu__list li,
.sem-header-element--secondary-menu .sem-menu__list li {
  position: relative;
}

.sem-header-element--primary-menu .sem-menu__list a,
.sem-header-element--secondary-menu .sem-menu__list a {
  display: block;
  padding: 8px 14px;
  text-decoration: none;
  color: inherit;
  font-size: 0.95rem;
  border-radius: var(--sem-radius-sm, 4px);
  transition: background 0.2s ease, color 0.2s ease;
}

.sem-header-element--primary-menu .sem-menu__list a:hover,
.sem-header-element--secondary-menu .sem-menu__list a:hover,
.sem-header-element--primary-menu .sem-menu__list .current-menu-item > a,
.sem-header-element--secondary-menu .sem-menu__list .current-menu-item > a {
  background: rgba(0, 0, 0, 0.05);
}

/* Submenu indicator */
.sem-menu__list--arrows .menu-item-has-children > a::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  vertical-align: middle;
}

/* Submenu dropdown */
.sem-header-element--primary-menu .sub-menu,
.sem-header-element--secondary-menu .sub-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  border-radius: var(--sem-radius-md, 8px);
  padding: 8px 0;
  z-index: 200;
  list-style: none;
  margin: 0;
}

.sem-header-element--primary-menu .menu-item-has-children:hover > .sub-menu,
.sem-header-element--primary-menu .menu-item-has-children:focus-within > .sub-menu,
.sem-header-element--secondary-menu .menu-item-has-children:hover > .sub-menu,
.sem-header-element--secondary-menu .menu-item-has-children:focus-within > .sub-menu {
  display: block;
}

.sem-submenu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.25rem;
  padding: 0.25rem;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.sem-submenu-toggle:focus-visible {
  outline: 2px solid var(--sem-color-primary);
  outline-offset: 2px;
}

.menu-item-has-children.is-expanded > .sub-menu {
  display: block;
}

.sem-header-element--primary-menu .sub-menu a,
.sem-header-element--secondary-menu .sub-menu a {
  padding: 8px 20px;
  white-space: nowrap;
  border-radius: 0;
}

/* --------------------------------------------------------------------------
 * CTA in header
 * -------------------------------------------------------------------------- */

.sem-header-element--cta .sem-btn {
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
 * Search toggle in header
 * -------------------------------------------------------------------------- */

.sem-search-toggle {
  position: relative;
}

.sem-search-toggle__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  border-radius: var(--sem-radius-sm, 4px);
}

.sem-search-toggle__btn:hover,
.sem-search-toggle__btn:focus-visible {
  background: rgba(0, 0, 0, 0.05);
}

.sem-search-toggle__dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  width: 300px;
  max-width: 90vw;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  border-radius: var(--sem-radius-md, 8px);
  padding: 16px;
  z-index: 300;
}

.sem-search-toggle__dropdown.is-active {
  display: block;
}

.sem-search-toggle__form {
  display: flex;
  gap: 8px;
}

.sem-search-toggle__input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--sem-color-border);
  border-radius: var(--sem-radius-sm, 4px);
  font-size: 0.9rem;
}

/* --------------------------------------------------------------------------
 * Socials in header
 * -------------------------------------------------------------------------- */

.sem-header-element--socials .sem-socials {
  display: flex;
  gap: 4px;
  align-items: center;
}

/* Prevent three-zone rows from overflowing on narrow screens. */
@media (max-width: 1023px) {
  .sem-header-row__grid {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .sem-header-zone--center {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
  }

  .sem-header-zone {
    min-width: 0;
    flex-wrap: wrap;
  }

  .sem-header-zone .sem-menu__list {
    flex-wrap: wrap;
  }
}

@media (max-width: 767px) {
  .sem-header-row__grid {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .sem-header-zone--center {
    display: none;
  }

  .sem-header-element--primary-menu .sem-menu__list,
  .sem-header-element--secondary-menu .sem-menu__list {
    flex-direction: column;
    align-items: flex-start;
  }

  .sem-header-element--primary-menu .sub-menu,
  .sem-header-element--secondary-menu .sub-menu {
    position: static;
    width: 100%;
    min-width: 0;
    box-shadow: none;
  }
}

.sem-socials__link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: inherit;
  border-radius: var(--sem-radius-sm, 4px);
  transition: background 0.2s ease, color 0.2s ease;
}

.sem-socials__link:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--sem-color-primary);
}

/* --------------------------------------------------------------------------
 * Spacer
 * -------------------------------------------------------------------------- */

.sem-spacer {
  display: block;
}

/* --------------------------------------------------------------------------
 * HTML content
 * -------------------------------------------------------------------------- */

.sem-html-content {
  font-size: 0.9rem;
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
 * Responsive: Mobile
 * -------------------------------------------------------------------------- */

@media (max-width: 1023px) {
  .sem-header-row__grid {
    grid-template-columns: 1fr auto;
  }

  .sem-header-zone--center {
    display: none;
  }

  /* Hide desktop menu, show in mobile panel instead */
  .sem-header-element--primary-menu,
  .sem-header-element--secondary-menu {
    display: none;
  }
}

@media (max-width: 767px) {
  .sem-header-row {
    min-height: 60px;
    --sem-row-height: 60px;
  }

  .sem-header-row__grid {
    min-height: 60px;
  }
}
