/* Mega Menu Popup Styles */
.mega-menu-popup {
  position: absolute;
  top: 100%; /* Position right below the category nav */
  left: 0;
  width: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  padding: 0;
  margin: 0;
}

.mega-menu-popup.active {
  opacity: 1;
  visibility: visible;
}

.mega-menu-content {
  width: 100%; /* Take full width of parent container */
  background-color: #fff;
  padding: 2rem;
  position: relative;
  float: none; /* Remove float to allow full width */
  margin: 0 auto; /* Center the content */
  border: var(--border-thin-light);
  border-top: none;
}

.mega-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: var(--border-thin-light);
  position: relative;
}

/* New styles for the menu title using UL/LI instead of h tags */
.mega-menu-title {
  margin: 0;
  padding: 0;
  list-style-type: none;
}

.mega-menu-title li {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0;
  color: #333;
}

/* Section title styles (replacing h3) */
.mega-menu-section-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1rem;
  list-style-type: none;
  color: #333;
}

/* Gordian Magazine Feature */
.gordian-feature {
  flex: 1.5;
  min-width: 300px;
}

.gordian-cover {
  margin-bottom: 15px;
}

.gordian-cover img {
  max-width: 100%;
  height: auto;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.gordian-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.gordian-button {
  padding: 8px 12px;
  background-color: #007bff;
  color: white !important;
  text-decoration: none;
  border-radius: 4px;
  text-align: center;
  flex: 1;
  font-weight: 500;
  transition: background-color 0.2s;
}

.gordian-button:hover {
  background-color: #0056b3;
  color: white !important;
}

.gordian-button.past-issues {
  background-color: #6c757d;
}

.gordian-button.past-issues:hover {
  background-color: #5a6268;
}

/* Close Button Styles */
.close-menu-button {
  display: none; /* Hidden on desktop by default */
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: #333;
  padding: 0;
  line-height: 1;
  margin-left: 15px;
}

/* Show close button only on mobile */
@media (max-width: 768px) {
  .close-menu-button {
    display: none;
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 2rem;
  }
}

.mega-menu-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  width: 100%;
}

.mega-menu-column {
  flex: 1;
}

@media (min-width: 768px) {
  .mega-menu-columns {
    flex-wrap: nowrap;
  }

  .mega-menu-column {
    width: 100%;
  }
}

.mega-menu-section-title {
  font-size: 1.2rem;
  margin-top: 0;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #eaeaea;
  font-weight: 700;
}

.mega-menu-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.mega-menu-links li {
  padding: 0.3rem 0;
}

.mega-menu-links a {
  color: #333;
  text-decoration: none;
  padding: 0.25rem 0;
  display: block;
}

.mega-menu-links a:hover {
  color: #007bff;
}

/* Gordian Magazine Feature */
.gordian-feature {
  flex: 1.5;
}

.gordian-cover {
  margin-bottom: 15px;
}

.gordian-cover img {
  max-width: 60%;
  height: auto;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.gordian-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.gordian-button {
  padding: 8px 12px;
  background-color: #007bff;
  color: white !important;
  text-decoration: none;
  border-radius: 4px;
  text-align: center;
  flex: 1;
  font-weight: 500;
  transition: background-color 0.2s;
}

.gordian-button:hover {
  background-color: #0056b3;
  color: white !important;
}

.gordian-button.past-issues {
  background-color: #6c757d;
}

.gordian-button.past-issues:hover {
  background-color: #5a6268;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  /* Apply overflow:hidden only on mobile devices when menu is open */
  body.menu-open {
    overflow: hidden;
  }

  .mega-menu-popup {
    position: absolute;
    top: 100%; /* Position right below the category nav, just like on desktop */
    left: 0;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
  }

  .mega-menu-content {
    width: 100%;
    max-width: 100vh; /* Full width on mobile */
    margin: 0;
    padding: 1rem;
    overflow-y: visible;
    float: none; /* Reset float */
    position: relative;
  }

  .mega-menu-columns {
    flex-direction: flex;
  }

  .mega-menu-column {
    width: 100%;
    margin-bottom: 1.5rem;
  }

  /* Ensure menu button stays visible when menu is open */
  #menu-popup-toggle.active {
    z-index: 10000;
  }

  /* Mobile-specific menu styling */
  .mega-menu-header {
    position: sticky;
    top: 0;
    background: inherit;
    z-index: 2;
    padding-top: 10px;
  }

  /* Add some extra space at the bottom for better scrolling */
  .mega-menu-columns:after {
    content: "";
    display: block;
    height: 20px;
    width: 100%;
  }
}
