/* Base Styles */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Prevent icon flashing on load */
[data-lucide]:not(.lucide) {
  opacity: 0;
}

[data-lucide].lucide {
  opacity: 1;
  transition: opacity 0.2s ease;
}

html {
  font-size: 16px;
  scroll-behavior: auto; /* Changed from smooth to auto for instant scrolling */
}

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--color-primary-bg);
  color: var(--color-text-primary);
  line-height: 1.6;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  overflow-x: hidden;
  position: relative;
}

/* Prevent scrolling on home page in mobile view ONLY */
@media (max-width: 767px) {
  body.page-home {
    overflow: hidden;
    height: 100vh;
    height: 100dvh; /* Use dynamic viewport height for better mobile support */
  }
  
  /* Ensure body can scroll on other pages */
  body:not(.page-home) {
    overflow-y: auto;
    height: auto;
  }
}

/* Shader background support */
#shader-background {
  touch-action: pan-x pan-y;
  user-select: none;
  -webkit-user-select: none;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-semibold);
  line-height: 1.3;
  margin-bottom: var(--space-4);
}

h1 {
  font-size: var(--font-3xl);
  font-weight: var(--font-bold);
}

h2 {
  font-size: var(--font-2xl);
}

h3 {
  font-size: var(--font-xl);
}

h4 {
  font-size: var(--font-lg);
}

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

/* Layout */
.main-container {
  position: relative;
  width: 100%;
  min-height: 100vh; /* Changed from fixed height to min-height */
  overflow: visible; /* Changed from hidden to visible */
  padding-bottom: 0;
  padding-top: var(--space-2);
}

/* Prevent scrolling for home page container on mobile */
@media (max-width: 767px) {
  .main-container {
    height: 100vh;
    height: 100dvh;
  }
}

@media (min-width: 768px) {
  .main-container {
    padding-top: 100px; /* Increased space for desktop nav to prevent overlap */
    max-width: 100%; /* Use full width instead of constrained 800px */
    margin: 0;
    padding-left: var(--space-6);
    padding-right: var(--space-6);
    height: auto; /* Allow natural height for scrolling */
    overflow-y: auto; /* Enable vertical scrolling */
  }
}

@media (min-width: 1024px) {
  .main-container {
    max-width: 100%; /* Use full width instead of constrained 900px */
    padding-left: var(--space-8);
    padding-right: var(--space-8);
  }
}

/* Page Management */
.page {
  display: none;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-1);
  visibility: hidden;
  opacity: 0;
  z-index: 0;
  pointer-events: none;
}

/* Mobile: absolute positioning for full-screen pages */
@media (max-width: 767px) {
  .page {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100%;
  }
}

/* Desktop: relative positioning for normal document flow */
@media (min-width: 768px) {
  .page {
    position: relative;
    min-height: auto; /* Allow natural height for proper scrolling */
  }
}

.page.active {
  display: block;
  visibility: visible;
  opacity: 1;
  z-index: 10;
  pointer-events: auto;
}

/* Home page specific styling for mobile - no scroll */
@media (max-width: 767px) {
  /* Only apply flex layout when home page is active */
  .page#homePage.active {
    overflow: hidden;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding-top: var(--space-1);
  }
  
  /* Ensure other pages can scroll properly within their container */
  .page:not(#homePage).active {
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-1);
    padding-bottom: 100px; /* Space for mobile nav */
  }
}

/* Remove any animation classes if accidentally added */
.page-enter,
.page-exit {
  /* No animations */
  animation: none !important;
  transition: none !important;
}

@media (min-width: 768px) {
  .page {
    padding: var(--space-2);
  }
}

@media (min-width: 1024px) {
  .page {
    padding: var(--space-3);
  }
}

/* Page Headers */
.page-header {
  text-align: center;
  margin-bottom: var(--space-8);
}

.page-header h1 {
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.page-header p {
  color: var(--color-text-secondary);
  font-size: var(--font-lg);
}

/* Buttons */
button {
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition-fast);
}

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

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-weight: var(--font-medium);
  font-size: var(--font-base);
  transition: all var(--transition-fast);
}

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

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--color-card-bg);
  color: var(--color-text-primary);
  border: 2px solid var(--color-border);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-weight: var(--font-medium);
  font-size: var(--font-base);
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  border-color: var(--color-accent-primary);
  color: var(--color-accent-primary);
}

/* Form Elements */
input[type="text"],
input[type="number"],
input[type="range"] {
  font-family: inherit;
  transition: all var(--transition-fast);
}

input[type="text"],
input[type="number"] {
  background: var(--color-card-bg);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  color: var(--color-text-primary);
  font-size: var(--font-base);
}

input[type="text"]:focus,
input[type="number"]:focus {
  outline: none;
  border-color: var(--color-accent-primary);
  box-shadow: 0 0 0 3px rgba(77, 182, 172, 0.1);
}

/* Links */
a {
  color: var(--color-accent-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-accent-secondary);
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--color-secondary-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--color-accent-primary);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-accent-secondary);
}

/* Selection */
::selection {
  background: var(--color-accent-primary);
  color: white;
}

::-moz-selection {
  background: var(--color-accent-primary);
  color: white;
}

/* Focus styles for accessibility */
*:focus {
  outline: none;
}

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

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .loading-screen {
    animation: none;
  }
  
  .lotus-petals {
    animation: none;
  }
  
  .loading-bar {
    animation: none;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  :root {
    --color-border: currentColor;
  }
  
  button:focus-visible,
  input:focus-visible,
  a:focus-visible {
    outline: 3px solid currentColor;
  }
}

/* Dark mode system preference override */
@media (prefers-color-scheme: dark) {
  /* Let CSS variables handle theming */
}

/* Print styles */
@media print {
  .nav-mobile,
  .nav-desktop {
    display: none !important;
  }
  
  .page {
    display: block !important;
  }
  
  body {
    background: white !important;
    color: black !important;
  }
}

/* Screen reader only content */
.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;
}