/**
 * Base Styles - Reset & Foundation
 * Modern CSS reset with accessibility improvements
 */

/* Box sizing reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Remove default margin and padding */
* {
  margin: 0;
  padding: 0;
}

/* Root & Document */
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  min-height: 100vh;
  font-family: var(--fuente-sans);
  font-size: var(--texto-md);
  line-height: var(--alto-linea-normal);
  color: var(--texto-principal);
  background: var(--superficie-base);
  overflow-x: hidden;
  transition: background-color var(--duracion-normal) var(--aceleracion-entrada-salida),
    color var(--duracion-normal) var(--aceleracion-entrada-salida);
}

.tema--cambiando *,
.tema--cambiando *::before,
.tema--cambiando *::after {
  transition: none !important;
}

/* Background gradient overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    var(--gradiente-radial-superior),
    var(--gradiente-radial-inferior);
  pointer-events: none;
  animation: deriva-ambiente 40s ease-in-out infinite alternate;
}

body.panel--animando-lateral::before {
  animation-play-state: paused;
}

@keyframes deriva-ambiente {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }

  50% {
    opacity: 0.85;
    transform: translate3d(10px, -10px, 0);
  }

  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--fuente-display);
  font-weight: var(--peso-fuente-seminegrita);
  line-height: var(--alto-linea-estrecho);
  letter-spacing: var(--espaciado-letra-estrecho);
  color: var(--texto-principal);
}

h1 {
  font-size: var(--texto-xxxl);
}

h2 {
  font-size: var(--texto-xxl);
}

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

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

h5,
h6 {
  font-size: var(--texto-md);
}

p {
  line-height: var(--alto-linea-relajado);
  color: var(--texto-secundario);
}

/* Links */
a {
  color: var(--texto-enlace);
  text-decoration: none;
  transition: color var(--duracion-rapida) var(--aceleracion-salida);
}

a:hover {
  color: var(--texto-enlace-sobrevuelo);
}

a:focus-visible {
  outline: 2px solid var(--borde-foco);
  outline-offset: 2px;
  border-radius: var(--radio-sm);
}

/* Lists */
ul,
ol {
  list-style-position: inside;
}

/* Media */
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Form Elements */
input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: var(--estado-opacidad-deshabilitado);
}

/* Focus Visible - Enhanced keyboard navigation */
:focus-visible {
  outline: 2px solid var(--borde-foco);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* Selection */
::selection {
  background-color: var(--color-primario-500);
  color: var(--texto-inverso);
}

::-moz-selection {
  background-color: var(--color-primario-500);
  color: var(--texto-inverso);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--superficie-hundida);
}

::-webkit-scrollbar-thumb {
  background: var(--color-neutro-400);
  border-radius: var(--radio-completo);
  border: 3px solid var(--superficie-hundida);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-neutro-500);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-neutro-400) var(--superficie-hundida);
}

/* Utility Classes */
.visually-oculto {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.skip-enlace {
  position: absolute;
  top: var(--espacio-2);
  left: var(--espacio-2);
  z-index: var(--z-notificacion);
  padding: var(--espacio-3) var(--espacio-4);
  background: var(--superficie-elevada);
  color: var(--texto-principal);
  border-radius: var(--radio-md);
  font-weight: var(--peso-fuente-seminegrita);
  transform: translateY(-200%);
  transition: transform var(--duracion-rapida) var(--aceleracion-salida);
}

.skip-enlace:focus {
  transform: translateY(0);
}

/* Text Utilities */
.texto-primario {
  color: var(--texto-principal);
}

.texto-secundario {
  color: var(--texto-secundario);
}

.texto-terciario {
  color: var(--texto-terciario);
}

.texto-apagado {
  color: var(--texto-terciario);
  font-size: var(--texto-sm);
  line-height: var(--alto-linea-relajado);
}

.resaltado {
  background: color-mix(in srgb, var(--color-primario-200) 65%, transparent);
  color: inherit;
  padding-inline: 2px;
  border-radius: var(--radio-xs);
}

.texto-balanceado {
  text-wrap: balance;
}

.texto-armonioso {
  text-wrap: pretty;
}

/* Display Utilities */
.flex {
  display: flex;
}

.flex-en-linea {
  display: inline-flex;
}

.cuadricula {
  display: grid;
}

.oculto {
  display: none;
}

/* Spacing Utilities */
.gap-1 {
  gap: var(--espacio-1);
}

.gap-2 {
  gap: var(--espacio-2);
}

.gap-3 {
  gap: var(--espacio-3);
}

.gap-4 {
  gap: var(--espacio-4);
}

.gap-5 {
  gap: var(--espacio-5);
}

.gap-6 {
  gap: var(--espacio-6);
}

/* Container */
.contenedor {
  width: 100%;
  max-width: 1400px;
  margin-inline: auto;
  padding-inline: var(--espacio-4);
}

@media (min-width: 640px) {
  .contenedor {
    padding-inline: var(--espacio-6);
  }
}

@media (min-width: 1024px) {
  .contenedor {
    padding-inline: var(--espacio-8);
  }
}

/* Animation Utilities */
@keyframes desvanecer-entrada {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes desvanecer-salida {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

@keyframes deslizar-arriba {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes deslizar-abajo {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes deslizar-izquierda {
  from {
    transform: translateX(-20px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes deslizar-derecha {
  from {
    transform: translateX(20px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes escalar-entrada {
  from {
    transform: scale(0.95);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

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

  @keyframes pulso {

    0%,
    100% {
      opacity: 1;
    }

    50% {
      opacity: 0.5;
    }
  }

  @keyframes pulso-suave {
    0%,
    100% {
      opacity: 0.65;
    }

    50% {
      opacity: 1;
    }
  }

  @keyframes destello-barra {
    0% {
      transform: translateX(-120%);
    }

    100% {
      transform: translateX(120%);
    }
  }

  @keyframes brillo {
    0% {
      background-position: -1000px 0;
    }

  100% {
    background-position: 1000px 0;
  }
}

@keyframes ondular {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

  @keyframes resplandecer {

    0%,
    100% {
      box-shadow: 0 0 10px rgba(255, 106, 0, 0.2);
    }

    50% {
      box-shadow: 0 0 20px rgba(255, 106, 0, 0.4);
    }
  }

  @keyframes rebote-suave {
    0%,
    100% {
      transform: translateY(0);
    }

    40% {
      transform: translateY(-3px);
    }

    70% {
      transform: translateY(1px);
    }
  }

  @keyframes rebote-escala {
    0%,
    100% {
      transform: scale(1);
    }

    50% {
      transform: scale(1.05);
    }
  }

/* Animation Classes */
.animar-desvanecer {
  animation: desvanecer-entrada var(--duracion-normal) var(--aceleracion-salida);
}

.animar-deslizar-arriba {
  animation: deslizar-arriba var(--duracion-normal) var(--aceleracion-salida);
}

.animar-deslizar-abajo {
  animation: deslizar-abajo var(--duracion-normal) var(--aceleracion-salida);
}

.animar-escalar {
  animation: escalar-entrada var(--duracion-normal) var(--aceleracion-salida);
}

.animar-giro {
  animation: giro 1s linear infinite;
}

.animar-pulso {
  animation: pulso 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Accessibility - Screen Reader Only Text */
.solo-lector {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Print Styles */
@media print {

  *,
  *::before,
  *::after {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  a,
  a:visited {
    text-decoration: underline;
  }

  abbr[title]::after {
    content: " (" attr(title) ")";
  }

  pre,
  blockquote {
    border: 1px solid #999;
    page-break-inside: avoid;
  }

  thead {
    display: table-header-group;
  }

  tr,
  img {
    page-break-inside: avoid;
  }

  p,
  h2,
  h3 {
    orphans: 3;
    widows: 3;
  }

  h2,
  h3 {
    page-break-after: avoid;
  }
}
