/**
 * WML Mobile Menu CSS
 * Adapted for WordPress from the original slide-in submenu design
 */

:root{
  --ff-sans: 'Nunito Sans', sans-serif;
  --fs-400: 16px;
  --fs-btn: 11px;
  --color-text: #000000;
  --trans-500: all 350ms ease-in-out;
  --trans: all 250ms ease-in-out;
  --padding-container-inline: 20px;
  --padding-container-block: 50px;
  --gap-100: 4px;
  --gap-300: 12px;
  --height-header: 10px;
  --ls-200: 1.2px;
  --lh-200: 1.25;
}

/* Reset and base styles for the menu component */
.wml-mobile-menu-container {
  font-family: var(--ff-sans);
}

/* Container starts hidden and becomes visible after initialization */
.wml-mobile-menu-container.wml-initialized {
  opacity: 1 !important;
  transition: opacity 0.1s ease-in-out;
}

.wml-mobile-menu-container *,
.wml-mobile-menu-container *::before,
.wml-mobile-menu-container *::after {
  box-sizing: border-box;
}

.wml-mobile-menu-container a {
  text-decoration: none;
  color: inherit;
}

.wml-mobile-menu-container button {
  background-color: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}

/***************************/
/***** BUTTON **************/
/***************************/
.wml-mobile-menu-container a.btn,
.wml-mobile-menu-container .btn {
	position: relative;
	padding: var(--padding-button, 20px 32px);
	display: inline-flex;
	justify-content: center;
	align-items: center;
	font-family: var(--ff-sans);
	font-size: var(--fs-btn, 14px);
	line-height: var(--lh-200, 1.25);
	border: 1px solid currentColor;
	text-transform: uppercase;
	letter-spacing: var(--ls-200, 1.2px);
	transition: var(--trans);
	z-index: 1;
}

.wml-mobile-menu-container .btn .btn__icon,
.wml-mobile-menu-container .btn .btn__label {
  pointer-events: none;
}

/***************************/
/***** Mobile Menu ********/
/***************************/
.wml-mobile-menu-container .hidden {
  display: none !important;
}

.wml-mobile-menu-container aside#mega-menu--mobile {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100svh;
  z-index: 999999;
  background-color: rgba(0, 0, 0, 0.5);
  transform: translateX(-100%);
  transition: none; /* Start with no transitions */
  visibility: hidden; /* Additional layer of hiding */
  opacity: 0;
}

/* Enable transitions only after initialization */
.wml-mobile-menu-container.wml-initialized aside#mega-menu--mobile {
  transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
  visibility: visible;
  opacity: 1;
}

/* Prevent any transitions during loading */
.wml-mobile-menu-container.wml-loading aside#mega-menu--mobile {
  transition: none !important;
  transform: translateX(-100%) !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

/* Ensure menu starts closed on page load */
.wml-mobile-menu-container aside#mega-menu--mobile:not(.active) {
  transform: translateX(-100%);
}

.wml-mobile-menu-container aside#mega-menu--mobile.active {
  transform: translateX(0);
}

.wml-mobile-menu-container aside#mega-menu--mobile .mega__container {
  width: 100%;
  max-width: 400px;
  height: 100vh;
  height: 100svh;
  max-height: 100vh;
  max-height: 100svh;
  padding-top: var(--height-header, 10px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: white;
  margin-left: auto;
}

.wml-mobile-menu-container aside#mega-menu--mobile .mega__container[data-active-depth="1"] button#menu-back {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

.wml-mobile-menu-container aside#mega-menu--mobile .mega__header {
  height: 60px;
  padding-inline: var(--padding-container-inline, 20px);
  background-color: white;
  border-bottom: 1px solid #eee;
}

.wml-mobile-menu-container aside#mega-menu--mobile .mega__header .mega__controls {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.wml-mobile-menu-container aside#mega-menu--mobile .mega__header .mega__controls button {
  font-family: var(--ff-sans);
  font-size: var(--fs-btn);
  text-transform: uppercase;
  letter-spacing: var(--ls-200);
  display: flex;
  align-items: center;
  gap: var(--gap-100, 4px);
  transition: var(--trans);
  color: var(--color-text);
}

.wml-mobile-menu-container aside#mega-menu--mobile .mega__header .mega__controls button .btn__icon,
.wml-mobile-menu-container aside#mega-menu--mobile .mega__header .mega__controls button .btn__label {
  display: flex;
  pointer-events: none;
}

/* Close button styling */
.wml-mobile-menu-container .wml-close-button {
  background: transparent !important;
  border: none !important;
  padding: 8px !important;
  cursor: pointer;
  color: #000000;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.wml-mobile-menu-container .wml-close-button:hover {
  background-color: rgba(0, 0, 0, 0.1) !important;
}

.wml-mobile-menu-container .wml-close-button svg {
  width: 14px;
  height: 14px;
  display: block;
}

.wml-mobile-menu-container aside#mega-menu--mobile .mega__body {
  width: 100%;
  height: 100%;
  position: relative;
}

.wml-mobile-menu-container aside#mega-menu--mobile .mega__screen {
  padding-block: var(--padding-container-block, 50px);
  padding-inline: var(--padding-container-inline, 20px);
  width: 100%;
  height: 100%;
  overflow: auto;
  position: absolute;
  inset: 0;
  background-color: white;
  transition: var(--trans-500);
}

.wml-mobile-menu-container aside#mega-menu--mobile .mega__screen[data-active-menu="false"] {
  transform: translateX(100%);
}

.wml-mobile-menu-container aside#mega-menu--mobile .mega__screen[data-active-menu="false"].stacked,
.wml-mobile-menu-container aside#mega-menu--mobile .mega__screen[data-active-menu="true"] {
  transform: translateX(0%);
}

.wml-mobile-menu-container aside#mega-menu--mobile nav.navigation {
  display: flex;
  flex-direction: column;
  gap: var(--gap-300, 12px);
  margin-bottom: 20px;
}

.wml-mobile-menu-container aside#mega-menu--mobile nav.navigation a.btn {
  --item-height: 48px;
  --icon-size: 12px;
  width: 100%;
  height: var(--item-height);
  padding: 0;
  background-color: transparent;
  border: 0;
  color: var(--color-text);
  justify-content: space-between;
  gap: var(--gap);
  text-transform: none;
  letter-spacing: normal;
  border-bottom: 1px solid #f0f0f0;
  border-radius: 0;
}

.wml-mobile-menu-container aside#mega-menu--mobile nav.navigation a.btn:hover {
  background-color: #f8f8f8;
}

.wml-mobile-menu-container aside#mega-menu--mobile nav.navigation a.btn .btn__label {
  width: auto;
  height: 100%;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  font-weight: 400;
  font-size: 16px;
}

.wml-mobile-menu-container aside#mega-menu--mobile nav.navigation a.btn .btn__icon:empty {
  display: none;
  pointer-events: none;
}

.wml-mobile-menu-container aside#mega-menu--mobile nav.navigation a.btn .btn__icon {
  width: 100%;
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  pointer-events: all;
}

.wml-mobile-menu-container aside#mega-menu--mobile nav.navigation a.btn .btn__icon svg {
  width: var(--icon-size);
  height: var(--icon-size);
  pointer-events: none;
}

/* Menu toggle button - to be placed in theme */
.wml-mobile-menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  z-index: 0;
}

.wml-mobile-menu-toggle:hover {
  background-color: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.wml-mobile-menu-toggle .hamburger {
  width: 24px;
  height: 18px;
  position: relative;
  transform: rotate(0deg);
  transition: 0.3s ease-in-out;
}

.wml-mobile-menu-toggle .hamburger span {
  display: block;
  position: absolute;
  height: 2px;
  width: 100%;
  background: currentColor;
  border-radius: 1px;
  opacity: 1;
  left: 0;
  transform: rotate(0deg);
  transition: 0.3s ease-in-out;
}

.wml-mobile-menu-toggle .hamburger span:nth-child(1) {
  top: 0px;
}

.wml-mobile-menu-toggle .hamburger span:nth-child(2) {
  top: 8px;
}

.wml-mobile-menu-toggle .hamburger span:nth-child(3) {
  top: 16px;
}

.wml-mobile-menu-toggle.active .hamburger span:nth-child(1) {
  top: 8px;
  transform: rotate(135deg);
}

.wml-mobile-menu-toggle.active .hamburger span:nth-child(2) {
  opacity: 0;
  left: -60px;
}

.wml-mobile-menu-toggle.active .hamburger span:nth-child(3) {
  top: 8px;
  transform: rotate(-135deg);
}

/* Custom SVG icon styles */
.wml-mobile-menu-toggle.wml-custom-icon .hamburger {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wml-mobile-menu-toggle.wml-custom-icon .hamburger svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
  transition: 0.3s ease-in-out;
}

.wml-mobile-menu-toggle.wml-custom-icon.active .hamburger svg {
  transform: rotate(180deg);
}

/* Ensure custom SVG inherits the hamburger color */
.wml-mobile-menu-toggle.wml-custom-icon .hamburger svg {
  color: inherit;
}

/* Close button overlay */
.wml-mobile-menu-container .mega-menu-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  cursor: pointer;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .wml-mobile-menu-container aside#mega-menu--mobile .mega__container {
    width: 90%;
    max-width: none;
  }
}

@media (max-width: 480px) {
  .wml-mobile-menu-container aside#mega-menu--mobile .mega__container {
    width: 100%;
  }
  
  .wml-mobile-menu-container aside#mega-menu--mobile .mega__screen {
    padding-inline: 15px;
  }
}

/* Hide mobile menu in page builder contexts */
body.bricks-is-frontend-builder .wml-mobile-menu-container,
body.elementor-editor-active .wml-mobile-menu-container,
body.fl-builder-edit .wml-mobile-menu-container,
body.et-db .wml-mobile-menu-container,
body.vc_editor .wml-mobile-menu-container,
body.oxygen-builder-body .wml-mobile-menu-container,
body.themify_builder_active .wml-mobile-menu-container,
iframe .wml-mobile-menu-container {
  display: none !important;
  visibility: hidden !important;
  z-index: -1 !important;
}

/* WordPress admin bar compensation */
body.admin-bar .wml-mobile-menu-container aside#mega-menu--mobile {
  top: 32px;
  height: calc(100vh - 32px);
}

@media screen and (max-width: 782px) {
  body.admin-bar .wml-mobile-menu-container aside#mega-menu--mobile {
    top: 46px;
    height: calc(100vh - 46px);
  }
}
