/**
 * Base Styles - Shared across all pages
 * Contains: Reset, typography, common variables, utilities
 * @version 2.0.0 - Responsive Optimized
 */

/* ========================================
   RESPONSIVE BREAKPOINTS (Estandarizados)
   ======================================== */

:root {
  --breakpoint-xs: 360px;   /* Móviles muy pequeños */
  --breakpoint-sm: 480px;   /* Móviles pequeños */
  --breakpoint-md: 640px;   /* Móviles grandes */
  --breakpoint-lg: 768px;   /* Tablets */
  --breakpoint-xl: 1024px;  /* Desktop pequeño */
  --breakpoint-2xl: 1440px; /* Desktop grande */
}

/* ========================================
   CSS RESET & BASE
   ======================================== */

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #333;
  background: #fff;
  overflow-x: hidden;
}

/* ========================================
   CSS VARIABLES - DESIGN TOKENS
   ======================================== */

:root {
  /* Spacing Scale */
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Font Sizes */
  --font-xs: 0.75rem;
  --font-sm: 0.875rem;
  --font-base: 1rem;
  --font-lg: 1.125rem;
  --font-xl: 1.25rem;
  --font-2xl: 1.5rem;
  --font-3xl: 1.875rem;
  --font-4xl: 2.25rem;
  --font-5xl: 3rem;

  /* Font Weights */
  --font-light: 300;
  --font-normal: 400;
  --font-bold: 700;

  /* Line Heights */
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.75;

  /* Border Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --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);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-Index Scale */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal-backdrop: 400;
  --z-modal: 500;
  --z-popover: 600;
  --z-tooltip: 700;
}

/* ========================================
   TYPOGRAPHY
   ======================================== */

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  margin-bottom: var(--space-md);
}

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

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

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

ul, ol {
  list-style: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* ========================================
   MOBILE NAVIGATION - SHARED
   ======================================== */

.menu-toggle {
  display: none;
  position: relative;
  z-index: var(--z-fixed);
  width: 2.5rem;
  height: 2.5rem;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: white;
}

.menu-toggle span,
.menu-toggle .bar {
  display: block;
  width: 28px;
  height: 2px;
  background: white;
  border-radius: 2px;
  transition: all var(--transition-base);
  position: relative;
}

.menu-toggle span:nth-child(2),
.menu-toggle .bar:nth-child(2) {
  margin: 6px 0;
}

.menu-toggle[aria-expanded="true"] span:nth-child(1),
.menu-toggle[aria-expanded="true"] .bar:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.menu-toggle[aria-expanded="true"] span:nth-child(2),
.menu-toggle[aria-expanded="true"] .bar:nth-child(2) {
  opacity: 0;
}

.menu-toggle[aria-expanded="true"] span:nth-child(3),
.menu-toggle[aria-expanded="true"] .bar:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
  z-index: calc(var(--z-fixed) - 1);
}

.menu-overlay.active {
  opacity: 1;
  visibility: visible;
}

@media (max-width: 968px) {
  .menu-toggle {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .menu-toggle span,
  .menu-toggle .bar {
    display: block !important;
    width: 28px !important;
    height: 2px !important;
    background: white !important;
  }

  .menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: min(300px, 80vw);
    height: 100vh;
    background: #fff;
    box-shadow: var(--shadow-2xl);
    transition: right var(--transition-base);
    z-index: var(--z-fixed);
    overflow-y: auto;
    padding: var(--space-2xl) var(--space-lg);
  }

  .menu.active {
    right: 0;
  }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

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

.container-wide {
  max-width: 1400px;
}

/* Inner wrapper for sections */
.inner {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

@media (max-width: 768px) {
  .container,
  .inner {
    padding: 0 var(--space-md);
  }
}

@media (max-width: 480px) {
  .container,
  .inner {
    padding: 0 var(--space-sm);
  }
}

/* Flexbox Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* Grid Utilities */
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Text Utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

/* Visibility */
.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;
}

/* Loading States */
.loading {
  opacity: 0.6;
  pointer-events: none;
  cursor: wait;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Responsive Helpers */
@media (max-width: 968px) {
  .hide-mobile { display: none !important; }
  .grid-cols-2, .grid-cols-3, .grid-cols-4 {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 969px) {
  .hide-desktop { display: none !important; }
}

/* ========================================
   BACKGROUND IMAGE FIXES FOR MOBILE
   ======================================== */

/* Fix para background-attachment: fixed en móviles */
@media (max-width: 968px) {
  /* Desactivar parallax/fixed en móviles para mejor rendimiento */
  section[style*="background-attachment: fixed"],
  .section[style*="background-attachment: fixed"] {
    background-attachment: scroll !important;
  }

  /* Optimizar background-size para móviles */
  section[style*="background-image"],
  .section[style*="background-image"],
  .section-areas,
  .section-cta,
  .section-blue,
  .section-pillars {
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
  }

  /* Asegurar que los overlays cubran bien */
  .section-areas-overlay,
  .cta-overlay {
    position: absolute !important;
    inset: 0 !important;
    z-index: 0 !important;
  }

  /* Asegurar que el contenido esté sobre el overlay */
  .section-areas .inner,
  .section-cta .inner,
  .section-blue .inner {
    position: relative !important;
    z-index: 1 !important;
  }
}

/* Optimización adicional para pantallas muy pequeñas */
@media (max-width: 640px) {
  /* En móviles pequeños, usar background-position optimizado */
  section[style*="background-image"],
  .section[style*="background-image"] {
    background-position: center 30% !important;
  }

  /* Reducir padding en secciones con background */
  .section-blue,
  .section-areas {
    padding: 2rem 0 !important;
  }
}

/* Fix específico para imágenes de alta resolución en móviles */
@media (max-width: 480px) {
  section[style*="background-image"],
  .section[style*="background-image"] {
    /* Forzar scroll para evitar glitches de iOS */
    background-attachment: scroll !important;
    /* Mejor posicionamiento para móviles muy pequeños */
    background-position: center 40% !important;
    /* Asegurar que cubra pero no se estire */
    background-size: cover !important;
    /* Optimización de rendering */
    will-change: auto !important;
  }
}

/* ========================================
   NAVBAR ACTION BUTTONS
   ======================================== */

/* Botones de acción en el navbar */
.nav-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-left: 1rem;
}

/* Botón Donar (Education) */
.btn-nav-donate {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  background: linear-gradient(135deg, #f42959, #ff1744);
  color: white !important;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: 10px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(244, 41, 89, 0.25);
  border: none;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn-nav-donate:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(244, 41, 89, 0.4);
  background: linear-gradient(135deg, #ff1744, #f42959);
}

.btn-nav-donate svg {
  width: 16px;
  height: 16px;
}

/* Botón Encuesta (Anchor) */
.btn-nav-survey {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  background: linear-gradient(135deg, #2a6a8a, #3a7a9a);
  color: white !important;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: 10px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(42, 106, 138, 0.25);
  border: none;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn-nav-survey:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(42, 106, 138, 0.4);
  background: linear-gradient(135deg, #3a7a9a, #2a6a8a);
}

.btn-nav-survey svg {
  width: 16px;
  height: 16px;
}

/* Responsive para botones en navbar */
@media (max-width: 968px) {
  .nav-actions {
    display: none;
  }

  /* Mostrar botones en el menú móvil */
  .menu-overlay__actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding: 0 1.5rem;
  }

  .menu-overlay__actions .btn-nav-donate,
  .menu-overlay__actions .btn-nav-survey {
    width: 100%;
    justify-content: center;
    padding: 0.85rem 1.5rem;
  }
}
