/* ==========================================================================
   CSS MODERNO 2025 - PARTE 1: BASE Y VARIABLES
   ========================================================================== */

/* Variables CSS Personalizadas (Custom Properties) */
:root {
  /* Colores principales */
  --primary-color: #2448A6; 
  --primary-dark: #1a3580;
  --secondary-color: #F5B841;
  --accent-color: #F5B841;
  --brand-white: #FFFFFF;
  
  /* Colores de sistema */
  --background: #ffffff;
  --surface: #f8fafc;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  
  /* Colores de estado */
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;
  
  /* Bordes y sombras */
  --border-color: #e5e7eb;
  --border-radius: 8px;
  --border-radius-large: 16px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  
  /* Espaciado */
  --spacing-xs: 0.25rem;   /* 4px */
  --spacing-sm: 0.5rem;    /* 8px */
  --spacing-md: 1rem;      /* 16px */
  --spacing-lg: 1.5rem;    /* 24px */
  --spacing-xl: 2rem;      /* 32px */
  --spacing-2xl: 3rem;     /* 48px */
  --spacing-3xl: 4rem;     /* 64px */
  
  /* Tipografía */
  --font-size-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --font-size-sm: clamp(0.875rem, 0.8rem + 0.375vw, 1rem);
  --font-size-base: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);
  --font-size-lg: clamp(1.125rem, 1rem + 0.625vw, 1.25rem);
  --font-size-xl: clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem);
  --font-size-2xl: clamp(1.5rem, 1.3rem + 1vw, 2rem);
  --font-size-3xl: clamp(2rem, 1.7rem + 1.5vw, 3rem);
  
  /* Transiciones */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;
  
  /* Z-index scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal: 1040;
  --z-popover: 1050;
  --z-tooltip: 1060;
}

/* Tema oscuro */
:root[data-theme="dark"] {
  --background: #0B1426;
  --surface: #1A2332;
  --text-primary: #F8FAFC;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --border-color: #334155;
  
  /* Ajustes de colores para dark mode */
  --primary-color: #2448A6;
  --secondary-color: #fbbf24;
  --accent-color: #1a3580;
}

/* Detección automática de preferencia del sistema */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --background: #0f172a;
    --surface: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border-color: #334155;
    --primary-color: #818cf8;
    --secondary-color: #fbbf24;
    --accent-color: #f472b6;
  }
}

/* ==========================================================================
   RESET Y BASE
   ========================================================================== */

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

/* Base del documento */
html {
  font-size: 16px;
  scroll-behavior: smooth;
  /* Preparación para scroll timeline */
  scroll-timeline: --page-scroll block;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 
               'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--background);
  transition: background-color var(--transition-normal), 
              color var(--transition-normal);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Mejoras de legibilidad */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: var(--spacing-md);
}

p {
  margin-bottom: var(--spacing-md);
  color: var(--text-secondary);
}

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

a:hover,
a:focus-visible {
  color: var(--primary-dark);
  text-decoration: underline;
}

/* Focus visible para accesibilidad */
*:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
  border-radius: var(--border-radius);
}

/* Código inline */
code {
  background-color: var(--surface);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: calc(var(--border-radius) / 2);
  font-size: 0.9em;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
  color: var(--text-primary);
}

/* Contenedor principal */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

@media (min-width: 768px) {
  .container {
    padding: 0 var(--spacing-xl);
  }
}

/* Main crece para pushear footer abajo */
.main {
  flex: 1;
  padding: var(--spacing-xl) 0;
}

/* Secciones demo */
.demo-section {
  margin-bottom: var(--spacing-3xl);
  padding: var(--spacing-xl);
  background: var(--surface);
  border-radius: var(--border-radius-large);
  border: 1px solid var(--border-color);
  transition: background-color var(--transition-normal),
              border-color var(--transition-normal);
}

.demo-section__title {
  font-size: var(--font-size-2xl);
  color: var(--text-primary);
  margin-bottom: var(--spacing-md);
  position: relative;
}

.demo-section__title::before {
  content: '';
  position: absolute;
  left: 0;
  bottom: -8px;
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
  border-radius: 2px;
}

.demo-section__description {
  font-size: var(--font-size-lg);
  color: var(--text-secondary);
  margin-bottom: var(--spacing-xl);
  max-width: 70ch;
}

.demo-section__description strong {
  color: var(--primary-color);
  font-weight: 600;
}

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

/* Animación de entrada suave */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.demo-section {
  animation: fadeInUp 0.6s ease-out;
}