/* ============================================
   1. TRANSICIONES Y ANIMACIONES
   ============================================ */
@view-transition {
  navigation: auto;
}

/* Fallback para todos los navegadores */
body {
  animation: fadeIn 0.4s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* Fade-in para elementos */
.fade-in-element {
  opacity: 0;
  animation: fadeInUp 0.6s ease-out forwards;
}

/* Delays escalonados */
.fade-in-element:nth-child(1) {
  animation-delay: 0.1s;
}

.fade-in-element:nth-child(2) {
  animation-delay: 0.2s;
}

.fade-in-element:nth-child(3) {
  animation-delay: 0.3s;
}

.fade-in-element:nth-child(4) {
  animation-delay: 0.4s;
}

.fade-in-element:nth-child(5) {
  animation-delay: 0.5s;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

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

/* ============================================
   2. VARIABLES Y TEMA (ACCESIBILIDAD + VIBRANT)
   ============================================ */
:root {
  --text-multiplier: 1;

  /* --- PALETA ORIGINAL (Modo Claro) --- */
  --lego-yellow: #FFCF00;
  --lego-red: #D01012;
  --lego-blue: #005EB8;

  --mattel-red: #E1251B;
  --mattel-blue: #0057A6;

  --christmas-green: #165B33;
  --christmas-gold: #D4AF37;
  --christmas-light-blue: #6EC5E9;
  --christmas-snow: #F0F8FF;

  /* Paleta Semántica CLARO */
  --primary: var(--lego-red);
  --secondary: var(--lego-yellow);
  --accent: var(--christmas-green);
  --highlight: var(--christmas-gold);

  /* Variable especial para asegurar que el footer siempre sea verde */
  --footer-bg: var(--christmas-green);

  /* Grises y neutros */
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --border-color: #e5e7eb;
  /* Escala de grises (Tailwind-like) para consistencia en páginas) */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Espaciado */
  --container-max: 1200px;
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* Bordes */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  /* Sombras */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .08);
  --shadow-lg: 0 10px 24px rgba(0, 0, 0, .12);
}

/* --- MODO OSCURO "VIBRANT" --- */
[data-theme="dark"] {
  --bg-primary: #0f1115;
  --bg-secondary: #181b21;

  /* Textos Claros */
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --border-color: #2d3748;

  /* Colores NEÓN / INTENSOS */
  --primary: #ff4545;
  --secondary: #ffce00;
  --highlight: #ffd700;

  --lego-red: #ff4545;
  --lego-yellow: #ffce00;

  /* Footer Mantiene su identidad Verde */
  --footer-bg: #165B33;
  --christmas-green: #165B33;
  --accent: #2ecc71;

  /* Sombras fuertes */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.8);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.8);
  /* Grises en oscuro mapeados a tonos accesibles */
  --gray-50: #111317;
  --gray-100: #171a1f;
  --gray-200: #1f232a;
  --gray-300: #2a2f39;
  --gray-400: #3a4150;
  --gray-500: #4f5768;
  --gray-600: #6a7283;
  --gray-700: #8a93a3;
  --gray-800: #aab2c0;
  --gray-900: #e5e7eb;
}

/* -----------------------------------------------
CAPTCHA ESTILO FORZADO CON EL DARK THEME
----------------------------------------------- */
[data-theme="dark"] #captchaContainer,
[data-theme="dark"] #captchaContainer canvas,
[data-theme="dark"] #captchaContainer img {
  background: #ffffff;
  color: #000000;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  display: inline-block;
  filter: contrast(1.12) brightness(1.04);
}

/* Forzar color de texto dentro del contenedor por si el renderer inyecta texto */
[data-theme="dark"] #captchaContainer * {
  color: #000000 !important;
}

/* ============================================
   3. RESET Y BASE (ACCESIBILIDAD)
   ============================================ */
html {
  font-size: calc(16px * var(--text-multiplier));
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell,
    'Helvetica Neue', Arial, sans-serif;
  font-size: 1rem;
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  /* Transición suave de tema */
  transition: background-color 0.3s ease, color 0.3s ease;
}

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

a {
  color: inherit;
  text-decoration: none;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

button {
  font: inherit;
  cursor: pointer;
}

/* Container global */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

/* ============================================
   4. HEADER GLOBAL
   ============================================ */
.header {
  background: var(--bg-primary);
  border-top: 6px solid var(--secondary);
  /* Usa variable dinámica */
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.header .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-lg);
  padding: 12px 0;
  min-height: 64px;
}

/* Brand / Logo */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
}

.brand:hover {
  opacity: 0.95;
}

.brand_logo {
  height: 44px;
  width: auto;
}

.brand_tagline {
  display: none;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Navegación */
.nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav_link {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-weight: 600;
  color: var(--text-primary);
  background: transparent;
  transition: background .15s ease, color .15s ease, transform .12s ease;
  white-space: nowrap;
}

.nav_link:hover,
.nav_link:focus-visible {
  background: rgba(125, 125, 125, 0.1);
  transform: translateY(-1px);
}

.nav_link.active {
  background: transparent;
  color: var(--primary);
  box-shadow: none;
  border-bottom: 3px solid var(--primary);
  padding-bottom: 6px;
}

.nav_link.action {
  padding: 8px 12px;
}

/* Controles de Accesibilidad (Estilos para tus botones JS) */
.accessibility-controls {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin-left: 12px;
}

.btn-theme,
.btn-font {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-theme:hover,
.btn-font:hover {
  background: rgba(125, 125, 125, 0.1);
}

.font-indicator {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Menú de usuario */
.user-menu {
  display: none;
  position: relative;
}

body.logged-in .login-link {
  display: none;
}

body.logged-in .user-menu {
  display: inline-block;
}

.user-button {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  border-radius: 8px;
  padding: 6px 0;
  min-width: 160px;
  display: none;
  z-index: 200;
}

.user-menu.open .user-dropdown {
  display: block;
}

.dropdown-link {
  display: block;
  padding: 8px 12px;
  color: var(--text-primary);
  text-decoration: none;
}

.dropdown-link:hover {
  background: rgba(125, 125, 125, 0.1);
}


/* ============================================
   5. FOOTER GLOBAL (RESTAURADO + COLORES NUEVOS)
   ============================================ */
.footer {
  background: var(--footer-bg);
  color: white;
  padding: var(--spacing-lg) 0 var(--spacing-sm);
  margin-top: auto;
  transition: background-color 0.3s ease;
}

.footer_container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

.footer_grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-lg);
  border-bottom: 1px solid rgba(255, 255, 255, .2);
}

.footer_section h3 {
  font-size: 0.875rem;
  margin: 0 0 8px;
  color: var(--highlight);
  font-weight: 700;
}

.footer_logo {
  height: 35px;
  width: auto;
  margin-bottom: 6px;
}

.footer_tagline {
  font-size: 0.8125rem;
  margin: 4px 0;
  color: rgba(255, 255, 255, .9);
}

.footer_location {
  font-size: 0.8125rem;
  margin: 2px 0;
  color: rgba(255, 255, 255, .8);
}

.footer_links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.footer_link {
  color: rgba(255, 255, 255, .85);
  font-size: 0.8125rem;
  transition: color .2s;
}

.footer_link:hover {
  color: var(--highlight);
}

/* Boletín */
.footer_boletin {
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid rgba(255, 255, 255, .15);
}

.footer_boletin h3 {
  font-size: 0.9375rem;
  margin: 0 0 6px;
  color: var(--highlight);
}

.footer_boletin p {
  font-size: 0.8125rem;
  margin: 0 0 8px;
  color: rgba(255, 255, 255, .85);
}

.boletin_formulario {
  display: flex;
  gap: 8px;
  max-width: 500px;
}

.boletin_formulario input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, .1);
  color: white;
  font-size: 0.8125rem;
}

.boletin_formulario input::placeholder {
  color: rgba(255, 255, 255, .6);
}

.boletin_formulario button {
  padding: 8px 16px;
  background: var(--highlight);
  color: #165B33;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
  font-size: 0.8125rem;
}

.boletin_formulario button:hover {
  filter: brightness(1.1);
}

/* Redes sociales */
.footer_social_section {
  margin-bottom: var(--spacing-md);
}

.footer_social_section h3 {
  font-size: 0.875rem;
  margin: 0 0 8px;
  color: var(--highlight);
}

/* RESTAURADO: Iconos en fila */
.footer_social {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.footer_social_link {
  padding: 6px 12px;
  background: rgba(255, 255, 255, .15);
  border-radius: var(--radius-md);
  color: white;
  font-size: 0.8125rem;
  transition: all .2s;
}

.footer_social_link:hover {
  background: var(--highlight);
  color: #165B33;
  transform: translateY(-2px);
}

/* Footer bottom */
.footer_bottom {
  text-align: center;
  padding-top: var(--spacing-sm);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, .7);
}

.footer_bottom p {
  margin: 3px 0;
}

.footer_bottom strong {
  color: var(--highlight);
  font-weight: 700;
}

html,
body {
  height: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1 0 auto;
}
/* ============================================
   6. TARJETAS DE PRODUCTO
   ============================================ */
.products-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--spacing-lg);
  padding: 18px 0;
}

.product-card {
  min-width: 260px;
  max-width: 280px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(16, 24, 40, 0.06);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.product-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.product-image-container {
  position: relative;
  margin-bottom: 8px;
}

.product-card img {
  height: 160px;
  width: 100%;
  object-fit: contain;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f6fbff);
  padding: 5px;
  transition: transform 0.3s ease;
}

.product-card:hover img {
  transform: scale(1.05);
}

.product-badges {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.product-badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.badge-oferta {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
}

.badge-agotado {
  background: var(--gray-400);
  color: white;
}

.product-title {
  font-size: 0.9375rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.3;
  min-height: 2.6em;
}

.product-price {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0;
  text-align: center;
  color: var(--primary);
}

.product-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-align: center;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
  min-height: 2.8em;
  flex-grow: 1;
}


.card-cta {
  display: inline-block;
  margin: 0 auto;
  background: transparent;
  color: var(--primary);
  padding: 8px 16px;
  border-radius: var(--radius-lg);
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  border: 2px solid var(--border-color);
  transition: all .2s ease;
}

.card-cta:hover {
  background: var(--secondary);
  color: #111827;
  border-color: var(--secondary);
}




/* ============================================
   7. RESPONSIVE / SECCIONES
   ============================================ */
.section {
  padding: var(--spacing-lg) 0;
}

.section h2 {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.section p {
  color: var(--text-secondary);
  margin-bottom: 18px;
}

@media (min-width: 640px) {
  .brand_tagline {
    display: inline;
  }

  .footer_grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 768px) {
  .nav {
    flex-wrap: nowrap;
  }

  .footer_grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

  .footer_grid {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-md);
  }

  .products-row {
    gap: 20px;
  }
}