/* ============================================
   MOBILE HAMBURGER MENU STYLES
   ============================================ */

/* Hamburger Menu Button - Hidden on desktop, visible on mobile */
.hamburger-menu {
  display: none;
  flex-direction: column;
  justify-content: space-around;
  width: 30px;
  height: 24px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 1000;
  margin: auto var(--gap);
}

.hamburger-menu span {
  width: 30px;
  height: 3px;
  background-color: var(--primary);
  border-radius: 2px;
  transition: all 0.3s ease-in-out;
  transform-origin: center;
}

/* Hamburger animation when menu is open */
.hamburger-menu.active span:nth-child(1) {
  transform: translateY(10.5px) rotate(45deg);
}

.hamburger-menu.active span:nth-child(2) {
  opacity: 0;
  transform: translateX(-20px);
}

.hamburger-menu.active span:nth-child(3) {
  transform: translateY(-10.5px) rotate(-45deg);
}

/* Mobile Menu Styles */
@media (max-width: 768px) {
  /* Show hamburger button on mobile */
  .hamburger-menu {
    display: flex;
  }

  /* Hide menu by default on mobile */
  #menu {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    background-color: var(--theme);
    flex-direction: column;
    width: 100%;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
    box-shadow: none;
    z-index: 999;
    margin: 0;
    padding: 0;
    list-style: none;
    word-break: normal;
    white-space: normal;
  }

  /* Show menu when active */
  #menu.mobile-active {
    max-height: calc(100vh - var(--header-height));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid var(--border);
  }

  /* Style menu items for mobile */
  #menu li {
    width: 100%;
    margin: 0 !important;
    border-bottom: 1px solid var(--border);
  }

  #menu li:last-child {
    border-bottom: none;
  }

  #menu li a {
    display: block;
    padding: 16px var(--gap);
    font-size: 18px;
    text-align: left;
    width: 100%;
    transition: background-color 0.2s ease;
  }

  #menu li a:hover,
  #menu li a:focus {
    background-color: var(--code-bg);
  }

  #menu .active {
    font-weight: 600;
    border-bottom: none;
    border-left: 4px solid var(--primary);
  }

  /* Prevent body scroll when menu is open */
  body.menu-open {
    overflow: hidden;
  }

  /* Adjust nav layout for mobile */
  .nav {
    position: relative;
  }

  /* Ensure logo and hamburger are on same line */
  .logo {
    flex: 1;
  }
}

/* Desktop - Keep original horizontal menu */
@media (min-width: 769px) {
  #menu {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    white-space: nowrap;
  }

  #menu li + li {
    margin-inline-start: var(--gap);
  }
}

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */

/* Focus styles for keyboard navigation */
.hamburger-menu:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

#menu a:focus {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

/* Smooth scrolling for menu */
#menu {
  scroll-behavior: smooth;
}

/* ============================================
   ADDITIONAL MOBILE OPTIMIZATIONS
   ============================================ */

@media (max-width: 768px) {
  /* Ensure header doesn't overflow */
  .header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: var(--theme);
  }

  /* Optimize touch targets for mobile */
  #menu li a {
    min-height: 48px;
    display: flex;
    align-items: center;
  }

  /* Better emoji rendering on mobile */
  #menu a span {
    display: flex;
    align-items: center;
    gap: 8px;
  }
}

/* Override first-entry min-height */
.first-entry {
  min-height: 5px;
}

.profile img {
    border-radius: 0 !important;
}

/* .main .profile {
    align-items: initial !important; 
    min-height: initial !important; 
} */
