/* Mobile-specific styles */

/* New Hamburger Menu Styles */
.hamburger-menu {
  display: none;
  position: fixed;
  top: 12px;
  right: 16px;
  width: 44px;
  height: 44px;
  background: rgba(59, 130, 246, 0.1);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: 1001;
  padding: 10px;
  transition: background-color 0.3s;
}

.hamburger-menu:hover {
  background: rgba(59, 130, 246, 0.2);
}

.hamburger-menu:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Hamburger bars */
.hamburger-bar {
  display: block;
  width: 24px;
  height: 3px;
  margin: 5px 0;
  background-color: var(--text-soft);
  border-radius: 3px;
  transition: transform 0.3s, opacity 0.3s;
}

/* Active state (X shape) */
.hamburger-menu.active .hamburger-bar:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.hamburger-menu.active .hamburger-bar:nth-child(2) {
  opacity: 0;
}

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

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

/* Ensure hamburger menu is visible on mobile */
@media (max-width: 768px) {
  .hamburger-menu {
    display: block !important;
  }
}

/* Base mobile adjustments */
@media (max-width: 768px) {
  /* Adjust container for mobile */
  .container {
    padding: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0 auto;
  }
  
  /* Ensure the body doesn't overflow */
  body {
    width: 100%;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
  }
  
  /* Ensure all sections are properly centered */
  main.container {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  
  /* Make all sections full width */
  main.container > section {
    width: 100%;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
  }
  
  /* Header adjustments */
  .header-flex {
    padding: 0 1rem;
    justify-content: space-between;
    width: 100vw; /* Use viewport width instead of percentage */
    box-sizing: border-box;
    position: relative;
  }
  
  .site-header {
    width: 100vw; /* Use viewport width instead of percentage */
    box-sizing: border-box;
    position: fixed; /* Keep header fixed at the top */
    left: 0;
    right: 0;
  }
  
  .logo {
    display: flex;
    align-items: center;
  }
  
  .logo a {
    font-size: 1.3rem;
  }
  
  /* Ensure header has proper height on mobile */
  .site-header {
    height: var(--header-height);
    position: fixed; /* Changed from sticky to fixed */
    top: 0;
    z-index: 1000;
    max-width: 100vw; /* Ensure it doesn't exceed viewport width */
    overflow-x: hidden; /* Prevent horizontal scrolling within header */
  }
  
  /* Add padding to the top of main content to account for fixed header */
  main.container {
    padding-top: calc(var(--header-height) + 10px);
  }
  
  /* Hide old mobile menu button */
  .mobile-menu-btn {
    display: none !important;
  }
  
  /* Mobile navigation - now outside the header */
  .main-nav {
    position: fixed;
    top: var(--header-height); /* Position it right below the header */
    left: 0;
    width: 100%;
    height: calc(100vh - var(--header-height)); /* Full viewport height minus header */
    background: var(--surface-alt);
    border-bottom: 1px solid var(--card-border);
    box-shadow: var(--shadow);
    z-index: 999; /* Make sure it's below the header but above content */
    overflow-y: auto; /* Allow scrolling within the menu */
    overflow-x: hidden;
    padding: 1rem 0;
    transform: translateY(-100%);
    transition: transform 0.3s ease, opacity 0.3s ease;
    display: none; /* Hide initially */
    opacity: 0;
    visibility: hidden;
  }
  
  /* Desktop navigation styles - moved to main.css */
  
  .main-nav ul {
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 0;
    margin: 0;
    list-style: none;
  }
  
  .main-nav li {
    width: 100%;
    text-align: center;
  }
  
  .main-nav a {
    display: block;
    font-size: 1.1rem;
    padding: 1rem 0;
    border-bottom: 1px solid rgba(75, 85, 99, 0.1);
    text-decoration: none;
    color: var(--text-soft);
    transition: color 0.2s ease;
  }
  
  .main-nav a:hover, 
  .main-nav a:focus {
    color: var(--accent-light);
  }
  
  .main-nav li:last-child {
    margin-top: 0.5rem;
  }
  
  /* Theme toggle in mobile menu */
  .main-nav .theme-toggle {
    margin: 0 auto;
    width: 50px;
    height: 50px;
    background-color: rgba(59, 130, 246, 0.1);
  }
  
  .main-nav .theme-toggle:hover,
  .main-nav .theme-toggle:focus {
    background-color: rgba(59, 130, 246, 0.2);
    transform: none;
  }
  
  /* Prevent scrolling when menu is open */
  body.menu-open {
    overflow: hidden;
  }
  
  /* Hero section adjustments */
  .hero {
    padding: 2rem 1.5rem;
    margin: 1.5rem 1rem 2.5rem 1rem;
    width: calc(100% - 2rem);
    box-sizing: border-box;
    border-radius: var(--radius);
  }
  
  .hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    background: linear-gradient(to right, var(--text), var(--accent-light));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
  }
  
  .hero-subtitle {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
  }
  
  .hero-content {
    width: 100%;
  }
  
  /* Features section adjustments */
  .features {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin: 2rem 1rem;
    width: calc(100% - 2rem);
  }
  
  .feature-card {
    padding: 1.5rem 1rem;
    max-width: 100%;
    width: 100%;
    margin: 0;
    box-sizing: border-box;
    border-radius: var(--radius);
  }
  
  /* Make all cards consistent */
  .card, .hero, .feature-card, .tech-stack-card {
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--card-border);
  }
  
  /* Tech stack adjustments */
  .tech-stack-card {
    padding: 2rem 1rem;
    margin: 2rem 1rem;
    width: calc(100% - 2rem);
    box-sizing: border-box;
  }
  
  .tech-stack {
    gap: 1.2rem;
  }
  
  /* Fix popup text positioning for mobile */
  .tech-stack li .popup-text {
    width: 250px;
    font-size: 0.85rem;
    padding: 0.8rem;
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
  }
  
  .tech-stack li:hover .popup-text {
    transform: translateX(-50%) translateY(-10px);
  }
  
  /* Ensure popups don't get cut off at the edges on mobile */
  .tech-stack li:first-child .popup-text,
  .tech-stack li:nth-child(2) .popup-text,
  .tech-stack li:last-child .popup-text,
  .tech-stack li:nth-last-child(2) .popup-text {
    left: 50%;
    right: auto;
    transform: translateX(-50%) translateY(-5px);
  }
  
  .tech-stack li:first-child:hover .popup-text,
  .tech-stack li:nth-child(2):hover .popup-text,
  .tech-stack li:last-child:hover .popup-text,
  .tech-stack li:nth-last-child(2):hover .popup-text {
    transform: translateX(-50%) translateY(-10px);
  }
  
  .tech-stack li:first-child .popup-text::after,
  .tech-stack li:nth-child(2) .popup-text::after,
  .tech-stack li:last-child .popup-text::after,
  .tech-stack li:nth-last-child(2) .popup-text::after {
    left: 50%;
  }
}

/* Small mobile devices */
@media (max-width: 480px) {
  /* Header adjustments for very small screens */
  .header-flex {
    justify-content: space-between;
    gap: 0.5rem;
  }
  
  .logo {
    flex: 1;
  }
  
  .main-nav ul {
    gap: 1rem;
  }
  
  /* Hero section adjustments */
  .hero {
    padding: 1.5rem 1rem;
  }
  
  .hero h1 {
    font-size: 2rem;
  }
  
  .hero-subtitle {
    font-size: 1rem;
  }
  
  .cta-btn {
    padding: 0.7rem 1.5rem;
    font-size: 1rem;
  }
  
  /* Features section adjustments */
  .feature-card {
    min-width: 100%;
    margin: 0.5rem 0;
  }
  
  .feature-icon {
    width: 60px;
    height: 60px;
    font-size: 1.8rem;
  }
  
  /* Tech stack adjustments */
  .tech-stack li {
    min-width: 50px;
    height: 50px;
  }
  
  .tech-stack img {
    width: 30px;
    height: 30px;
  }
  
  /* Footer adjustments */
  .footer-content {
    gap: 1rem;
    flex-direction: column;
    align-items: center;
    padding: 0 1rem;
    width: 100%;
  }
  
  .footer-left {
    text-align: center;
    width: 100%;
    margin-bottom: 1rem;
  }
  
  .footer-right {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
  }
  
  .site-footer {
    width: 100vw; /* Use viewport width */
    box-sizing: border-box;
    padding: 1.5rem 0;
    left: 0;
    right: 0;
    position: relative;
    overflow-x: hidden; /* Prevent horizontal scrolling within footer */
  }
  
  .site-footer .container {
    padding: 0;
    width: 100vw; /* Use viewport width */
    max-width: 100vw;
  }
}

/* Fix for navigation on very small screens */
@media (max-width: 380px) {
  .main-nav ul {
    gap: 0.7rem;
  }
  
  .main-nav a {
    font-size: 0.85rem;
  }
  
  .theme-toggle {
    width: 40px; /* Increased from 36px */
    height: 40px; /* Increased from 36px */
  }
  
  .theme-toggle .material-icons-round {
    font-size: 1.2rem; /* Increased from 1.1rem */
  }
  
  /* Ensure hamburger menu is still accessible */
  .mobile-menu-btn {
    right: 0.5rem;
    top: 7px;
  }
}

/* Hamburger menu for very small screens */
@media (max-width: 340px) {
  .header-flex {
    position: relative;
  }
  
  .main-nav {
    width: 100vw; /* Use viewport width */
  }
  
  .main-nav ul {
    justify-content: space-between;
  }
}

/* Fix for zooming and horizontal scrolling issues */
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden;
    position: relative;
    width: 100%;
  }
  
  /* Ensure content doesn't cause horizontal scrolling */
  .container, main.container, section, .hero, .features, .tech-stack-card {
    max-width: 100vw;
    overflow-x: hidden;
  }
  
  /* Ensure the mobile menu button stays visible when scrolling horizontally */
  .mobile-menu-btn {
    position: fixed;
    z-index: 1002;
  }
  
  /* Ensure the header and footer span the full width */
  .site-header, .site-footer {
    width: 100vw;
    max-width: 100vw;
    left: 0;
    right: 0;
  }
}
