/* CSS Reset & Base Styles */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Primary Colors - AI/Data Professional Palette (Deprecated - using Vallabha Mohta palette) */
  
  /* Success & Action Colors */
  --success-color: #10b981;          /* Emerald - Success, growth */
  --success-hover: #059669;          /* Deep Emerald */
  --warning-color: #f59e0b;         /* Amber - Attention, insights */
  --error-color: #ef4444;            /* Red - Errors, alerts */
  
  /* Vallabha Mohta-Inspired Dark Theme */
  --bg-primary: #0a0a0a;             /* Deep black background */
  --bg-secondary: #1a1a1a;           /* Dark gray sections */
  --bg-tertiary: #2a2a2a;            /* Darker cards */
  --bg-quaternary: #3a3a3a;          /* Subtle borders */
  
  --text-primary: #ffffff;           /* Pure white text */
  --text-secondary: #b0b0b0;         /* Light gray secondary */
  --text-tertiary: #808080;          /* Medium gray muted */
  --text-quaternary: #606060;        /* Dark gray placeholder */
  
  --border-color: #404040;           /* Dark borders */
  --border-light: #303030;           /* Subtle borders */
  --shadow-color: rgba(255, 255, 255, 0.05); /* Subtle white shadows */
  
  /* Vallabha Mohta Color Palette - Consolidated */
  --primary-color: #88c0d0;          /* Cyan - Primary brand */
  --primary-hover: #98d5e7;          /* Lighter Cyan */
  --primary-light: #bfe3ec;          /* Light Cyan */
  
  --secondary-color: #00bfff;         /* Cyan accent */
  --secondary-hover: #0099cc;        /* Darker cyan */
  --secondary-light: #33ccff;        /* Light cyan */
  
  --accent-color: #ebcb8b;           /* Soft amber accent */
  --accent-hover: #d9b876;           /* Darker amber */
  --accent-light: #f3e3b4;          /* Light amber */
  
  /* Professional Gradients - Dark Theme */
  --gradient-primary: linear-gradient(135deg, #88c0d0 0%, #98d5e7 100%);
  --gradient-secondary: linear-gradient(135deg, #88c0d0 0%, #ebcb8b 100%);
  --gradient-accent: linear-gradient(135deg, #ebcb8b 0%, #88c0d0 100%);
  --gradient-hero: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 50%, #2a2a2a 100%);
  
  /* Fonts */
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'Fira Code', 'Courier New', monospace;
  
  /* Font Sizes - Vallabha Mohta Style (Smaller, Refined) */
  --text-xss: clamp(0.5rem, 0.45rem + 0.15vw, 0.625rem);   /* 8-10px - Extra Small */
  --text-xs: clamp(0.65rem, 0.6rem + 0.2vw, 0.75rem);      /* 10-12px */
  --text-sm: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);    /* 12-14px */
  --text-base: clamp(0.875rem, 0.8rem + 0.3vw, 1rem);      /* 14-16px */
  --text-lg: clamp(1rem, 0.9rem + 0.4vw, 1.125rem);        /* 16-18px */
  --text-xl: clamp(1.125rem, 1rem + 0.5vw, 1.25rem);      /* 18-20px */
  --text-2xl: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);     /* 20-24px */
  --text-3xl: clamp(1.5rem, 1.3rem + 0.8vw, 1.875rem);   /* 24-30px */
  --text-4xl: clamp(1.875rem, 1.6rem + 1vw, 2.25rem);    /* 30-36px */
  --text-5xl: clamp(2.25rem, 1.9rem + 1.5vw, 3rem);       /* 36-48px */
  
  /* Font Weights */
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  
  /* Line Heights */
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.75;
  
  /* Spacing System */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  --space-20: 5rem;     /* 80px */
  --space-24: 6rem;     /* 96px */
  
  /* Transitions - optimized for instant hover response */
  --transition-fast: 100ms ease;
  --transition-base: 150ms ease;
  --transition-slow: 250ms ease;
  --transition-hover: 100ms ease; /* Extra fast for hover effects */
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-base: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  /* Border Radius */
  --radius-sm: 0.25rem;
  --radius-base: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-full: 9999px;
  
  /* Breakpoints */
  --mobile: 320px;
  --tablet: 768px;
  --desktop: 1024px;
  --large-desktop: 1440px;
}

/* Dark Mode (Optional but Impressive) */
[data-theme="dark"] {
  --bg-primary: #111827;
  --bg-secondary: #1f2937;
  --bg-tertiary: #374151;
  --text-primary: #f9fafb;
  --text-secondary: #d1d5db;
  --text-tertiary: #9ca3af;
  --border-color: #374151;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  overflow-x: hidden; /* Prevent horizontal scrolling on entire page */
}

body {
  font-family: var(--font-primary);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  overflow-x: hidden;
  margin: 0; /* Ensure no default margin */
  padding: 0; /* Ensure no default padding */
  width: 100%;
  max-width: 100vw; /* Prevent horizontal overflow */
}

body.no-scroll {
  overflow: hidden !important;
  /* Don't use position: fixed as it prevents sidebar scrolling */
  /* The sidebar itself will scroll independently with overflow-y: auto */
}

/* Universal overflow prevention */
* {
  max-width: 100%;
  box-sizing: border-box;
}

/* Ensure consistent rendering across browsers */
* {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

/* Ensure all containers fit within viewport */
.container, .main-content, .hero, .sidebar, section {
  max-width: 100vw;
  overflow-x: hidden;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  color: var(--text-primary);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

p {
  margin-bottom: var(--space-4);
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color var(--transition-hover);
}

a:hover {
  color: var(--primary-hover);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Utility Classes */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.section {
  padding: var(--space-20) 0;
  padding-bottom: var(--space-20) !important; /* Consistent bottom padding for all sections */
}

.section-title {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  margin-bottom: var(--space-3);
  color: var(--text-primary);
}

.section-divider {
  width: 60px;
  height: 4px;
  background: var(--accent-color);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-8);
}

.section-subtitle {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  margin-bottom: var(--space-12);
  max-width: 600px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  border-radius: var(--radius-base);
  border: 2px solid transparent;
  cursor: pointer;
  transition: background-color var(--transition-hover), color var(--transition-hover), border-color var(--transition-hover), transform var(--transition-hover), box-shadow var(--transition-hover);
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background-color: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

.btn-secondary:hover {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-outline {
  background-color: transparent;
  color: var(--primary-color);
  border-color: var(--primary-color);
}

.btn-outline:hover {
  background-color: var(--primary-color);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-text {
  background: none;
  border: none;
  color: var(--primary-color);
  font-weight: var(--font-medium);
  cursor: pointer;
  padding: 0;
}

.btn-text:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-success {
  background-color: #d1fae5;
  color: #065f46;
}

.badge-live {
  background-color: #fef3c7;
  color: #92400e;
  -webkit-animation: pulse 2s infinite; /* Safari animation prefix */
  animation: pulse 2s infinite;
  -webkit-transform: translateZ(0); /* Force hardware acceleration */
  transform: translateZ(0);
}

@-webkit-keyframes pulse {
  0%, 100% { 
    opacity: 1;
    -webkit-opacity: 1;
  }
  50% { 
    opacity: 0.7;
    -webkit-opacity: 0.7;
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.live-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  -webkit-animation: blink 1.5s infinite; /* Safari animation prefix */
  animation: blink 1.5s infinite;
  -webkit-transform: translateZ(0); /* Force hardware acceleration */
  transform: translateZ(0);
}

@-webkit-keyframes blink {
  0%, 100% { 
    opacity: 1;
    -webkit-opacity: 1;
  }
  50% { 
    opacity: 0.3;
    -webkit-opacity: 0.3;
  }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Tags */
.tag, .tech-tag, .highlight-tag {
  display: inline-block;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  margin-right: var(--space-2);
  margin-bottom: var(--space-2);
}

.tech-tag {
  background-color: var(--primary-light);
  color: var(--primary-color);
}

/* Animations */
@-webkit-keyframes fadeInUp {
  from {
    opacity: 0;
    -webkit-opacity: 0;
    -webkit-transform: translateY(30px);
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    -webkit-opacity: 1;
    -webkit-transform: translateY(0);
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  -webkit-animation: fadeInUp 0.6s ease-out forwards; /* Safari animation prefix */
  animation: fadeInUp 0.6s ease-out forwards;
  -webkit-transform: translateZ(0); /* Force hardware acceleration */
  transform: translateZ(0);
}

/* Loading Screen */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: opacity 0.5s ease-out;
}

.loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  text-align: center;
  color: var(--text-primary);
}

.loading-spinner p {
  margin-top: var(--space-4);
  font-size: var(--text-lg);
  font-weight: var(--font-medium);
}

/* Loading Spinner */
.spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid rgba(34, 139, 34, 0.3);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  background-color: var(--text-primary);
  color: white;
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-base);
  box-shadow: var(--shadow-xl);
  opacity: 0;
  transform: translateY(20px);
  transition: all var(--transition-base);
  z-index: 10000;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Mobile-only Skills Section - Hidden on desktop */
.mobile-only {
  display: none;
}

@media (max-width: 767px) {
  .mobile-only {
    display: block;
  }
  /* Hide sidebar core skills on mobile (skills now shown in main content) */
  .sidebar .sidebar-skills {
    display: none !important;
  }
}

/* Scroll to Top Button */
.scroll-to-top {
  position: fixed;
  bottom: calc(1.5 * var(--space-12) + env(safe-area-inset-bottom)); /* 50% gap + safe area */
  right: var(--space-8); /* Increased from var(--space-6) */
  width: 50px;
  height: 50px;
  /* Mobile touch optimization */
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  cursor: pointer;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: opacity var(--transition-hover), visibility var(--transition-hover), transform var(--transition-hover), background-color var(--transition-hover), box-shadow var(--transition-hover);
  box-shadow: var(--shadow-lg);
  z-index: 1001; /* Increased z-index to be above footer */
}

.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-to-top:hover {
  background-color: var(--primary-hover);
  transform: translateY(-3px);
  box-shadow: var(--shadow-xl);
}

/* Scroll down (next page) button */
.scroll-to-next {
  position: fixed;
  bottom: calc(var(--space-2) + env(safe-area-inset-bottom));
  right: var(--space-8);
  width: 50px;
  height: 50px;
  /* Mobile touch optimization */
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  cursor: pointer;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: opacity var(--transition-hover), visibility var(--transition-hover), transform var(--transition-hover), background-color var(--transition-hover), box-shadow var(--transition-hover);
  box-shadow: var(--shadow-lg);
  z-index: 1001;
}

.scroll-to-next.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-to-next:hover {
  background-color: var(--primary-hover);
  transform: translateY(-3px);
  box-shadow: var(--shadow-xl);
}

/* Mobile-Optimized Scroll Navigation Arrows */
@media (max-width: 767px) {
  .scroll-to-top,
  .scroll-to-next {
    /* Mobile: Smaller size, better positioning for touch */
    width: 44px !important; /* Touch-friendly minimum size (44x44px recommended) */
    height: 44px !important;
    /* Position: Bottom-RIGHT corner (aligned with hamburger on right) */
    left: auto !important;
    right: var(--space-4) !important; /* Right side - 16px from right edge */
    /* Stack vertically in bottom-right */
    bottom: auto !important;
    /* Use z-index above mobile elements but below sidebar when open */
    z-index: 9999 !important; /* Below sidebar (10004) but above most content */
    /* Enhanced touch feedback */
    -webkit-tap-highlight-color: rgba(136, 192, 208, 0.3);
    touch-action: manipulation;
    /* Mobile-optimized shadow for better visibility */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
    /* Larger border for better visibility */
    border: 2px solid var(--bg-primary) !important;
  }

  /* Scroll to Top - Bottom-right, higher position */
  .scroll-to-top {
    bottom: calc(80px + env(safe-area-inset-bottom)) !important; /* Positioned above next button */
  }

  /* Scroll to Next - Bottom-right, lower position */
  .scroll-to-next {
    bottom: calc(20px + env(safe-area-inset-bottom)) !important; /* Near bottom, above safe area */
  }

  /* Mobile: Replace hover with active state for touch */
  .scroll-to-top:active,
  .scroll-to-next:active {
    background-color: var(--primary-hover) !important;
    transform: translateY(0) scale(0.95) !important; /* Press down effect */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
  }

  /* Mobile: Better visibility - slightly more opaque when visible */
  .scroll-to-top.visible,
  .scroll-to-next.visible {
    opacity: 0.95 !important; /* More visible on mobile */
    transform: translateY(0) !important;
  }

  /* Mobile: Hide hover effects (not applicable on touch devices) */
  .scroll-to-top:hover,
  .scroll-to-next:hover {
    background-color: var(--primary-color) !important;
    transform: translateY(0) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
  }

  /* Mobile: Larger SVG icons for better visibility */
  .scroll-to-top svg,
  .scroll-to-next svg {
    width: 24px !important;
    height: 24px !important;
  }
}

/* Highlight Text */
.highlight {
  color: var(--primary-color);
  font-weight: var(--font-semibold);
}

.metric {
  color: var(--accent-color);
  font-weight: var(--font-bold);
}

/* Skip Navigation Link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary-color);
  color: white;
  padding: 8px;
  text-decoration: none;
  z-index: 10000;
}

.skip-link:focus {
  top: 0;
}

/* Icon Styles */
.icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

.social-icon {
  width: 24px;
  height: 24px;
  transition: transform var(--transition-hover), color var(--transition-hover), filter var(--transition-hover);
  -webkit-transform: translateZ(0); /* avoid blurring during scale on Safari */
  transform: translateZ(0);
  will-change: transform;
  shape-rendering: geometricPrecision;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.social-icon:hover {
  -webkit-transform: translateZ(0) scale(1.08);
  transform: translateZ(0) scale(1.08);
}

/* Text Utilities */
.text-sm {
  font-size: var(--text-sm);
}

.text-xs {
  font-size: var(--text-xs);
}

/* Focus Styles for Accessibility */
*:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

button:focus,
a:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Form Elements */
input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

/* Smooth scrolling for older browsers */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  html {
    scroll-behavior: auto;
  }
}

/* Safari/mobile overrides to ensure consistent backgrounds and SVG colors */
@supports (-webkit-appearance: none) or (-webkit-touch-callout: none) {
  :root {
    /* Align secondary backgrounds with primary to avoid mixed backgrounds */
    --bg-secondary: var(--bg-primary);
  }
  /* Keep Safari coloring behavior predictable without forcing global fills/strokes */
  svg { color: inherit !important; }
  /* Contact method icons must stay white on iOS */
  .contact-section .method-icon svg { color: #ffffff !important; stroke: #ffffff !important; fill: none !important; }
}

/* ===== CRITICAL MOBILE FIXES FOR AUTO-OPENING SIDEBAR ===== */

/* Mobile Safari viewport height fix */
@supports (-webkit-touch-callout: none) {
  .hero,
  .sidebar,
  .main-content {
    height: -webkit-fill-available !important;
  }
}

/* Emergency mobile overflow fixes - MOBILE ONLY */
@media (max-width: 767px) {
  /* CRITICAL: Lock everything to viewport width */
  * {
    max-width: 100vw !important;
  }
  
  /* CRITICAL: Prevent horizontal scroll - NUCLEAR OPTION */
  html {
    overflow-x: hidden !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  body {
    overflow-x: hidden !important;
    width: 100vw !important;
    max-width: 100vw !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 100vh !important;
  }
  
  /* Prevent ANY transforms on mobile - CRITICAL for no shift */
  .main-content,
  .hero,
  .section,
  .container,
  footer,
  .footer {
    transform: none !important;
    transition: none !important;
    overflow-x: visible !important; /* Allow horizontal overflow for puppy circle */
  }
  
  /* Exception: Keep overflow-x hidden for sections other than hero */
  .section:not(.hero),
  .container,
  footer,
  .footer {
    overflow-x: hidden !important;
  }
  
  /* Allow sidebar to animate */
  .sidebar {
    transition: left 0.3s ease-in-out, visibility 0.3s !important;
  }
  
  /* Main content visible but not scrollable when sidebar open */
  body.sidebar-open {
    overflow: hidden !important;
    height: 100vh !important;
  }
  
  body.sidebar-open .main-content {
    overflow: hidden !important;
    touch-action: none !important;
  }
  
  /* CRITICAL: When sidebar closes, ensure body is scrollable */
  body:not(.sidebar-open) {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: auto !important;
    min-height: 100vh !important; /* Allow content to expand beyond viewport */
    position: relative !important;
  }
  
  /* CRITICAL: Restore main-content scrolling when sidebar closes */
  body:not(.sidebar-open) .main-content {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    touch-action: pan-y !important; /* Allow vertical scrolling on mobile */
    -webkit-overflow-scrolling: touch !important;
  }
  
  /* Ensure navigation links are clickable on mobile */
  @media (max-width: 767px) {
    a[href^="#"] {
      pointer-events: auto;
      touch-action: manipulation;
      cursor: pointer;
      -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
  }
  
  /* Duplicate rule removed - already defined above */
  
  /* ALIGNMENT FIX - Make all sections same width */
  .main-content {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: var(--space-4) !important;
    padding-right: var(--space-4) !important;
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    overflow-x: visible !important; /* Allow horizontal overflow for puppy circle */
  }
  
  .hero,
  .section,
  #about,
  #skills,
  #experience,
  #projects,
  #education,
  #contact,
  footer,
  .footer {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: var(--space-4) !important;
    padding-right: var(--space-4) !important;
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }
  
  /* Ensure containers inside sections also align */
  .container {
    padding-left: 0 !important;
    padding-right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }
  
  /* Prevent all child elements from causing horizontal scroll */
  .main-content *,
  .section *,
  footer * {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  
  /* Prevent specific wide elements */
  img, video, iframe, svg, canvas {
    max-width: 100% !important;
    height: auto !important;
  }
  
  /* Prevent tables and pre from overflowing */
  table, pre, code {
    max-width: 100% !important;
    overflow-x: auto !important;
  }
  
  /* Ensure no element can push beyond viewport */
  .main-content {
    overflow-x: visible !important; /* Allow horizontal overflow for puppy circle */
  }
  
  .main-content > *:not(.hero),
  .section,
  .section > * {
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }
  
  /* Hero section needs visible overflow for puppy */
  .hero {
    overflow-x: hidden !important; /* Prevent horizontal scroll */
    overflow-y: visible !important; /* Allow vertical overflow for puppy circle */
  }
}

/* DESKTOP FIXES - Restore simultaneous scrolling on desktop */
@media (min-width: 768px) {
  /* Restore normal scrolling for desktop */
  html, body {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    position: relative !important;
    height: auto !important;
  }
  
  /* Ensure sidebar and main content scroll independently on desktop */
  .sidebar {
    overflow-y: auto !important;
    position: fixed !important;
  }
  
  .main-content {
    overflow-y: auto !important;
    overflow-x: visible !important; /* Allow horizontal overflow for puppy circle */
    position: relative !important;
    height: auto !important;
    opacity: 1 !important;
    pointer-events: all !important;
  }
  
  /* Remove any mobile-specific body classes on desktop */
  body.sidebar-open {
    overflow: auto !important;
    position: relative !important;
  }
}

/* Prevent horizontal scrolling globally */
* {
  max-width: 100%;
  box-sizing: border-box;
}

/* Ensure body handles scrolling properly */
body {
  overflow-x: hidden !important;
  overflow-y: auto !important; /* Allow vertical scrolling */
  width: 100% !important;
}

html {
  overflow-x: hidden !important;
  overflow-y: auto !important; /* Allow vertical scrolling */
}

/* Loading screen should not interfere with main content */
.loading-screen.hidden {
  display: none !important;
}
