/* ===== MOBILE NAVIGATION (OFFCANVAS) ===== */

/* Overlay */
.mobile-nav-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1001; /* Behind the menu, above header */
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s var(--ease-out);
}

body.menu-open .mobile-nav-overlay {
  opacity: 1;
  visibility: visible;
}

/* Nav Toggle (Hamburger) */
.nav-toggle {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  width: 40px;
  height: 40px;
  position: relative;
  z-index: 1003; /* Highest: Above the menu panel */
  justify-content: center;
  align-items: center;
  padding: 0;
}

.nav-toggle .bar {
  position: absolute;
  width: 24px;
  height: 2px;
  background-color: var(--text-primary);
  border-radius: 2px;
  transition: all 0.4s var(--ease-out);
}

.nav-toggle .bar.top {
  transform: translateY(-8px);
}

.nav-toggle .bar.middle {
  transform: translateY(0);
}

.nav-toggle .bar.bottom {
  transform: translateY(8px);
}

/* Hamburger to Cross Animation */
body.menu-open .nav-toggle .bar.top {
  transform: translateY(0) rotate(45deg);
}

body.menu-open .nav-toggle .bar.middle {
  opacity: 0;
  transform: translateX(-10px); /* Slight slide out */
}

body.menu-open .nav-toggle .bar.bottom {
  transform: translateY(0) rotate(-45deg);
}

/* Base styles for desktop: Keep menu visible, ignore overlay/X */
@media (min-width: 769px) {
  .mobile-nav-overlay {
    display: none !important;
  }
}

/* Mobile specific styling */
@media (max-width: 768px) {
  .nav-toggle {
    display: flex;
  }

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

  .main-navigation ul {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    max-width: 80vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(6, 8, 15, 0.95);
    border-left: 1px solid var(--border-glass);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    z-index: 1002; /* Above overlay */
    
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem;
    
    transform: translateX(100%);
    transition: transform 0.5s var(--ease-out);
  }

  body.menu-open .main-navigation ul {
    transform: translateX(0);
  }

  .main-navigation li {
    width: 100%;
    text-align: center;
    opacity: 0;
    transform: translateY(15px);
    transition: all 0.3s var(--ease-out);
  }

  /* Fade items in staggered */
  body.menu-open .main-navigation li {
    opacity: 1;
    transform: translateY(0);
  }
  body.menu-open .main-navigation li:nth-child(1) { transition-delay: 0.1s; }
  body.menu-open .main-navigation li:nth-child(2) { transition-delay: 0.15s; }
  body.menu-open .main-navigation li:nth-child(3) { transition-delay: 0.2s; }
  body.menu-open .main-navigation li:nth-child(4) { transition-delay: 0.25s; }
  body.menu-open .main-navigation li:nth-child(5) { transition-delay: 0.3s; }

  .main-navigation a {
    display: block;
    font-size: 1.125rem;
    padding: 0.75rem 1rem;
    border-radius: 12px;
  }

  .main-navigation a.nav-cta {
    width: 100%;
    margin-top: 1rem;
  }
}

/* ===== MOBILE BOTTOM NAVIGATION BAR ===== */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(10, 10, 15, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 1010;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.725rem;
  font-weight: 500;
  gap: 4px;
  width: 25%;
  height: 100%;
  transition: all 0.3s var(--ease-out);
}

.bottom-nav-item svg {
  stroke: var(--text-secondary);
  transition: stroke 0.3s var(--ease-out);
}

.bottom-nav-item:hover, .bottom-nav-item.active {
  color: #fff;
}

.bottom-nav-item:hover svg, .bottom-nav-item.active svg {
  stroke: var(--accent-indigo-light);
}

/* Quick Tools Sheet */
.quick-tools-sheet {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1020;
  visibility: hidden;
  opacity: 0;
  transition: all 0.4s var(--ease-out);
}

.quick-tools-sheet.open {
  visibility: visible;
  opacity: 1;
}

.sheet-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.sheet-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #090a0f;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 1.5rem 1.5rem calc(1.5rem + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.4s var(--ease-out);
}

.quick-tools-sheet.open .sheet-content {
  transform: translateY(0);
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.sheet-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
}

#close-sheet {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.75rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.sheet-body {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.sheet-tool-item {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.3s var(--ease-out);
}

.sheet-tool-item:hover {
  background: rgba(99, 102, 241, 0.12);
  border-color: var(--accent-indigo);
  color: #fff;
}

@media (max-width: 768px) {
  .mobile-bottom-nav {
    display: flex;
  }
  .nav-toggle {
    display: none !important; /* Hide hamburger to keep header clean */
  }
  /* Give body/footer padding so bottom nav doesn't cover content */
  body {
    padding-bottom: 75px !important;
  }
}
