/* ===================================
   Critical Above-the-Fold CSS
   ================================= */

/* Essential CSS Custom Properties */
:root {
  --primary-bg: linear-gradient(135deg, #0f1419 0%, #1a1f3a 25%, #2d3561 75%, #3d4785 100%);
  --accent-primary: #8b5cf6;
  --text-primary: #ffffff;
  --text-secondary: #b8c5d6;
  --card-bg: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.15);
  --gradient-primary: linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%);
  --mobile-header-height: 60px;
  --safe-area-top: env(safe-area-inset-top);
  --safe-area-bottom: env(safe-area-inset-bottom);
  --safe-area-left: env(safe-area-inset-left);
  --safe-area-right: env(safe-area-inset-right);
}

/* Critical Reset and Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: auto; /* Disable smooth scroll initially for performance */
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--primary-bg);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  width: 100%;
  min-height: calc(100vh - var(--safe-area-top) - var(--safe-area-bottom));
}

/* Critical Header Styles */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--mobile-header-height);
  z-index: 1000;
  background: rgba(15, 20, 25, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: var(--safe-area-top);
  transform: translateZ(0); /* Force GPU layer */
  will-change: transform;
}

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1rem;
  height: var(--mobile-header-height);
  max-width: 100%;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  z-index: 1001;
  transform: translateZ(0);
}

/* Critical Mobile Navigation */
.nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 48px;
  height: 48px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  z-index: 1001;
  position: relative;
  transform: translateZ(0);
}

.hamburger {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  margin: 3px 0;
  transition: all 0.2s ease;
  transform-origin: center;
}

/* Critical Main Content */
main {
  padding-top: calc(var(--mobile-header-height) + var(--safe-area-top));
  min-height: calc(100vh - var(--mobile-header-height) - var(--safe-area-top));
}

/* Critical Container */
.container {
  padding: 0 1rem;
  max-width: 100%;
  margin: 0 auto;
}

/* Critical Hero Section - Above the Fold */
.hero-section {
  padding: 3rem 0;
  text-align: center;
  min-height: auto;
}

.hero-content {
  max-width: 100%;
  margin: 0 auto;
}

/* Critical Typography */
h1 {
  font-size: 2.25rem;
  line-height: 1.1;
  margin-bottom: 1rem;
  font-weight: 700;
}

h2 {
  font-size: 1.875rem;
  line-height: 1.2;
  margin-bottom: 1rem;
  font-weight: 600;
}

p {
  margin-bottom: 1rem;
  line-height: 1.6;
}

/* Critical Button Styles */
.btn {
  min-height: 48px;
  padding: 12px 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-width: 44px;
  transform: translateZ(0);
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--card-bg);
  color: var(--text-primary);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(10px);
}

/* Critical Card Styles */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transform: translateZ(0);
}

/* Critical Phone Showcase */
.phone-showcase {
  margin: 2rem 0;
}

.phone-container {
  max-width: 280px;
  margin: 0 auto;
}

/* Critical Navigation Menu - Hidden by Default */
.nav-menu {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--primary-bg);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  padding: calc(var(--mobile-header-height) + var(--safe-area-top) + 1.5rem) 1rem 1.5rem;
  overflow-y: auto;
  z-index: 999;
  will-change: transform;
}

.nav-menu.active {
  transform: translateX(0);
}

.nav-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.nav-link {
  display: block;
  padding: 1rem 1.5rem;
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 12px;
  transition: all 0.2s ease;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.nav-link:hover,
.nav-link:focus,
.nav-link.active {
  color: var(--text-primary);
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.3);
}

/* Critical Utilities */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Prevent body scroll when mobile menu is open */
body.nav-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

/* Critical Performance Optimizations */
.nav-menu,
.nav-toggle,
.btn,
.card {
  transform: translateZ(0);
  will-change: transform;
}

/* Desktop Optimizations */
@media (min-width: 768px) {
  .nav-toggle {
    display: none;
  }
  
  .nav-menu {
    position: static;
    transform: none;
    background: none;
    padding: 0;
    overflow: visible;
    z-index: auto;
    backdrop-filter: none;
  }
  
  .nav-links {
    flex-direction: row;
    gap: 2rem;
  }
  
  .nav-link {
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
    min-height: auto;
  }
  
  .logo {
    font-size: 1.75rem;
  }
  
  .hero-section {
    padding: 6rem 0;
  }
  
  h1 {
    font-size: 3.5rem;
  }
  
  .container {
    max-width: 1200px;
    padding: 0 2rem;
  }
}

/* High Performance Mode for Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .nav-menu {
    transition: none !important;
  }
}