/* ========== DROPDOWN MENU STYLES ========== */

/* Hide dropdowns by default */
ul.submenu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  /* background-color: #333; */
  z-index: 1000;
  min-width: 180px;
  border-radius: 4px;
  margin-top: 0 !important;
}

/* Show dropdown on hover */
li:hover > ul.submenu {
  display: block;
}

/* Dropdown list items */
ul.submenu li {
  padding: 0.5em 1em;
}

/* Dropdown links */
ul.submenu li a {
  color: #eee;
  display: block;
  padding: 0.4rem 0.6rem;
  white-space: nowrap;
  text-decoration: none;
}

/* Hover effects */
ul.submenu li a:hover {
  background-color: #444;
  color: #fff;
}

/* Optional utility: semi-transparent background */
.bg-semi-transparent {
  background-color: rgba(0, 0, 0, 0.5); /* dark background, 60% opacity */
}

/* ========== RESPONSIVE NAV ========== */

/* Hide hamburger on large screens, show on small */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
}

/* Small screens: stack layout and hide menu by default */
@media (max-width: 768px) {
  /* Show hamburger on small screens */
  .menu-toggle {
    position: absolute;  /* position relative to nav */
    top: -0.7rem;        /* adjust vertical spacing */
    right: -0.2rem;      /* adjust horizontal spacing */
    display: block;
    font-size: 2rem;
    z-index: 1001;       /* above menu */
  }

  /* Ensure the flex container can position absolute children */
  nav .flex-l.items-center {
    position: relative;
  }

  /* Main menu hidden by default */
  .main-menu {
    display: none;
    flex-direction: column;
    background-color: #333;
    position: absolute;
    top: 100%;
    right: 0;
    width: auto;
    min-width: 180px;
    z-index: 999; /* ensure it overlays other content */
    border-radius: 4px;
  }

  /* Show menu when toggled */
  .main-menu.show {
    display: flex;
  }

  /* Menu items styling */
  .main-menu li {
    display: block;
    padding: 1rem;
    border-bottom: 1px solid #444;
  }

  .main-menu li a {
    color: #eee;
    text-decoration: none;
    white-space: nowrap;
  }

  .main-menu li a:hover {
    background-color: #444;
  }

  .bg-semi-transparent {
    background-color: #333; /* dark background, 60% opacity */
  }

  /* ========== MOBILE-SPECIFIC SUBMENU ========== */
  .main-menu li ul.submenu {
    position: static !important; /* stack vertically */
    display: none;               /* hidden by default */
    width: 100%;
    padding-left: 0;
    margin: 0;
  }

  .main-menu li ul.submenu.show {
    display: block;
  }

  .main-menu li ul.submenu li {
    border-bottom: 1px solid #444;
  }

  .main-menu li ul.submenu li a {
    color: #eee;
    display: block;
    padding: 0.8rem 1rem;
    text-decoration: none;
  }

  .main-menu li ul.submenu li a:hover {
    background-color: #444;
  }

  /* Back button styling */
  .back-button {
    cursor: pointer;
    padding: 1rem;
    border-bottom: 1px solid #444;
    font-weight: 600;
  }

  .back-button a {
    color: #eee;
    display: block;
    padding: 0.8rem 1rem;
    font-weight: 600;
    background-color: #222;
    border-bottom: 1px solid #444;
    text-decoration: none;
  }

  .back-button a:hover {
    background-color: #444;
  }

  /* Optional submenu header inside submenu */
  .submenu-header {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #aaa;
    padding: 0.5rem 1rem;
    font-weight: 600;
  }

  .submenu-active a {
    color: #eee;
    text-decoration: none;
  }

  .submenu-active a:hover {
    background-color: #444;
  }
}

/* ========== IPAD-SPECIFIC ====== */
@media (max-width: 1024px) { /* includes iPads */
  .main-menu li ul.submenu {
    width: fit-content;   /* shrink to text */
    max-width: 100%;      /* never wider than menu */
    padding-left: 0rem;   /* optional small padding */
  }
}
