/* =====================================================================
   styles.css — Catálogo de afiliados (Mobile-First)
   ---------------------------------------------------------------------
   ✏️  EDITA AQUÍ: casi todo el aspecto se controla con las variables
   de :root (colores, radios, sombras, tipografía, ancho máximo).
   Estructura del archivo:
     1. Variables  2. Base/Reset  3. Utilidades  4. Header
     5. Hero + buscador  6. Filtros (chips)  7. Grid + tarjetas
     8. Botones  9. Estados (skeleton/vacío)  10. Footer
     11. Banner de cookies + diálogo  12. Páginas legales
     13. Breakpoints tablet/escritorio  14. Accesibilidad (motion)
   ===================================================================== */

/* 1. VARIABLES ------------------------------------------------------- */
:root {
  /* Colores base */
  --c-bg: #f6f7fb;          /* fondo de página */
  --c-surface: #ffffff;     /* fondo de tarjetas */
  --c-ink: #111827;         /* texto principal */
  --c-muted: #6b7280;       /* texto secundario */
  --c-line: #e5e7eb;        /* bordes */

  /* Marca (logo, enlaces, hero) */
  --c-brand: #4f46e5;
  --c-brand-dark: #3730a3;

  /* CTA (botón de compra): el color que más debe destacar */
  --c-cta: #ff5a1f;
  --c-cta-hover: #e5450c;
  --c-cta-ink: #ffffff;

  /* Badges */
  --c-sale: #e11d48;        /* -XX% */
  --c-hot: #fbbf24;         /* Destacado */
  --c-ok: #059669;          /* interruptores activos */

  /* Formas */
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .06), 0 8px 24px rgba(17, 24, 39, .06);
  --shadow-lg: 0 4px 8px rgba(17, 24, 39, .08), 0 18px 40px rgba(17, 24, 39, .12);

  /* Tipografía: si quitas Google Fonts se usa la fuente del sistema */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Layout */
  --max: 1200px;
  --gutter: 16px;
  --header-h: 60px;
}

/* 2. BASE / RESET ---------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 64px);
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--c-ink);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }
img { height: auto; }
a { color: var(--c-brand); }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--c-brand);
  outline-offset: 2px;
  border-radius: 6px;
}

/* 3. UTILIDADES ------------------------------------------------------ */
.container {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: 8px; top: -60px;
  z-index: 200;
  background: var(--c-ink); color: #fff;
  padding: 10px 14px; border-radius: var(--radius-sm);
  text-decoration: none; font-weight: 700;
}
.skip-link:focus { top: 8px; }

/* 4. HEADER ---------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: rgba(255, 255, 255, .88);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--c-line);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.125rem;
  letter-spacing: -.02em;
  color: var(--c-ink);
  text-decoration: none;
}
.logo__mark {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--c-brand), var(--c-cta));
  color: #fff;
}
.logo__mark svg { width: 18px; height: 18px; }
.logo b { color: var(--c-cta); }

.nav { display: flex; gap: 2px; }
.nav a {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 600;
  color: var(--c-ink);
  text-decoration: none;
}
.nav a:hover { background: var(--c-bg); }

/* 5. HERO + BUSCADOR ------------------------------------------------- */
.hero {
  padding: 32px 0 40px;
  color: #fff;
  background: radial-gradient(120% 120% at 0% 0%, #6366f1 0%, var(--c-brand) 40%, #1e1b4b 100%);
}
.hero__eyebrow {
  display: inline-flex;
  margin: 0 0 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.hero__title {
  max-width: 18ch;
  margin: 0 0 12px;
  font-size: clamp(1.75rem, 7vw, 3.25rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -.03em;
}
.hero__title span { color: #fdba74; } /* palabra resaltada del H1 */
.hero__lead { max-width: 46ch; margin: 0 0 20px; opacity: .9; }

.search { position: relative; max-width: 560px; }
.search__icon {
  position: absolute;
  left: 16px; top: 50%;
  width: 20px; height: 20px;
  transform: translateY(-50%);
  color: var(--c-muted);
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 52px;
  padding: 0 52px 0 48px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--c-ink);
  font-size: 1rem;            /* ≥16px evita el zoom automático en iOS */
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
  -webkit-appearance: none;
  appearance: none;
}
.search input::placeholder { color: #9ca3af; }
.search input::-webkit-search-cancel-button { display: none; }
.search__clear {
  position: absolute;
  right: 8px; top: 50%;
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 50%;
  background: var(--c-bg);
  color: var(--c-ink);
  cursor: pointer;
}
.search__clear svg { width: 16px; height: 16px; }

/* Aviso de afiliación visible bajo el hero (requisito de transparencia) */
.disclosure {
  margin: 0;
  padding: 10px var(--gutter);
  background: #fff;
  border-bottom: 1px solid var(--c-line);
  color: var(--c-muted);
  font-size: .8rem;
  text-align: center;
}

/* 6. FILTROS (CHIPS) ------------------------------------------------- */
.catalog { padding: 20px 0 56px; }
.catalog__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.catalog__head h2 { margin: 0; font-size: 1.25rem; letter-spacing: -.02em; }
.catalog__count { margin: 0; color: var(--c-muted); font-size: .85rem; }

.chips {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  display: flex;
  gap: 8px;
  margin: 0 calc(var(--gutter) * -1) 12px;
  padding: 10px var(--gutter);
  overflow-x: auto;
  background: var(--c-bg);
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--c-line);
  border-radius: 999px;
  background: #fff;
  font-size: .875rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  scroll-snap-align: start;
  transition: background-color .2s, color .2s, border-color .2s;
}
.chip:hover { border-color: var(--c-ink); }
.chip[aria-pressed="true"] { background: var(--c-ink); border-color: var(--c-ink); color: #fff; }

/* 7. GRID + TARJETAS ------------------------------------------------- */
/* Móvil: 2 columnas (formato catálogo, ideal para tráfico de Reels/TikTok) */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--c-surface);
  box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease;
}

.card__media {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  background: #fff;
}
.card__media img {
  width: 100%;
  height: 100%;
  object-fit: contain;   /* "cover" si tus fotos son de ambiente y no de producto */
}

.card__badges {
  position: absolute;
  top: 8px; left: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.badge {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: .02em;
  color: #fff;
}
.badge--sale { background: var(--c-sale); }
.badge--hot { background: var(--c-hot); color: #111827; }

.card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
}
.card__cat {
  color: var(--c-brand);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.card__title,
.card__desc {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.card__title { margin: 0; font-size: .95rem; font-weight: 700; line-height: 1.3; }
.card__desc { margin: 0; color: var(--c-muted); font-size: .82rem; line-height: 1.45; }

.card__price {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  margin-top: auto;
  padding-top: 4px;
}
.price { font-size: 1.2rem; font-weight: 800; letter-spacing: -.02em; }
.price-old { color: var(--c-muted); font-size: .85rem; }

/* 8. BOTONES --------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;            /* tamaño táctil mínimo recomendado */
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .2s, box-shadow .2s, transform .15s, border-color .2s;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 16px; height: 16px; flex: 0 0 auto; transition: transform .2s; }

/* Botón de compra (CTA principal) */
.btn--buy {
  width: 100%;
  margin-top: 6px;
  background: var(--c-cta);
  color: var(--c-cta-ink);
  box-shadow: 0 6px 16px rgba(255, 90, 31, .3);
}
.btn--primary { background: var(--c-brand); color: #fff; }
.btn--dark { background: var(--c-ink); color: #fff; }
.btn--ghost { background: transparent; border-color: var(--c-line); color: var(--c-ink); }
.btn--link {
  min-height: 44px;
  padding-inline: 8px;
  border: 0;
  background: none;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Efectos hover solo en dispositivos con ratón (evita "hover pegado" en móvil) */
@media (hover: hover) {
  .card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
  .btn--buy:hover { background: var(--c-cta-hover); box-shadow: 0 10px 24px rgba(255, 90, 31, .4); }
  .btn--buy:hover svg { transform: translate(2px, -2px); }
  .btn--primary:hover { background: var(--c-brand-dark); }
  .btn--dark:hover { background: #000; }
  .btn--ghost:hover { border-color: var(--c-ink); }
}

/* 9. ESTADOS --------------------------------------------------------- */
.card--skeleton {
  min-height: 300px;
  background: linear-gradient(90deg, #eceef3 25%, #f7f8fa 37%, #eceef3 63%);
  background-size: 400% 100%;
  box-shadow: none;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.empty { padding: 48px 16px; color: var(--c-muted); text-align: center; }
.empty h3 { margin: 0 0 6px; color: var(--c-ink); }
.empty p { margin: 0 0 16px; }

/* 10. FOOTER --------------------------------------------------------- */
.site-footer {
  padding: 40px 0 calc(32px + env(safe-area-inset-bottom));
  background: #0b1020;
  color: #cbd5e1;
  font-size: .9rem;
}
.site-footer a { color: #fff; }
.footer__grid { display: grid; gap: 28px; }
.footer__brand .logo { color: #fff; margin-bottom: 12px; }
.footer__disclaimer {
  margin: 0;
  padding-left: 12px;
  border-left: 3px solid var(--c-cta);
  color: #e2e8f0;
}
.footer__title {
  margin: 0 0 12px;
  color: #94a3b8;
  font-size: .75rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.footer__links { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.footer__links a,
.footer__links button {
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
  font-size: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.footer__links a:hover,
.footer__links button:hover { text-decoration: underline; }
.footer__bottom {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, .1);
  color: #94a3b8;
  font-size: .8rem;
}

/* 11. COOKIES: BANNER + DIÁLOGO -------------------------------------- */
.cookie-banner {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 100;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  animation: slideUp .35s ease-out;
}
.cookie-banner__inner {
  display: grid;
  gap: 12px;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
  border: 1px solid var(--c-line);
  border-radius: var(--radius);
  background: var(--c-surface);
  box-shadow: 0 -4px 40px rgba(17, 24, 39, .18);
}
.cookie-banner__text { margin: 0; font-size: .875rem; }
/* Aceptar y Rechazar con el mismo peso visual (criterio de la AEPD) */
.cookie-banner__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cookie-banner__actions [data-consent="settings"] { grid-column: 1 / -1; order: 3; }
@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.cookie-dialog {
  width: min(560px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  color: var(--c-ink);
  box-shadow: var(--shadow-lg);
}
.cookie-dialog::backdrop { background: rgba(11, 16, 32, .55); }
.cookie-dialog__form { display: grid; gap: 4px; padding: 20px; }
.cookie-dialog h2 { margin: 0 0 4px; font-size: 1.2rem; }
.cookie-dialog__intro { margin: 0 0 8px; color: var(--c-muted); font-size: .875rem; }
.toggle-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--c-line);
}
.toggle-row label { font-weight: 700; cursor: pointer; }
.toggle-row p { margin: 2px 0 0; color: var(--c-muted); font-size: .82rem; }

/* Interruptor (checkbox con estilo) */
.switch {
  position: relative;
  flex: 0 0 auto;
  width: 46px; height: 28px;
  margin: 0;
  border-radius: 999px;
  background: #d1d5db;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color .2s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .2s;
}
.switch:checked { background: var(--c-ok); }
.switch:checked::after { transform: translateX(18px); }
.switch:disabled { opacity: .6; cursor: not-allowed; }
.cookie-dialog__actions { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--c-line); }

/* 12. PÁGINAS LEGALES ------------------------------------------------ */
.legal { padding: 32px 0 56px; }
.legal .container { max-width: 800px; }
.legal h1 { margin: 0 0 8px; font-size: clamp(1.6rem, 5vw, 2.25rem); letter-spacing: -.02em; line-height: 1.15; }
.legal .updated { margin: 0 0 24px; color: var(--c-muted); font-size: .875rem; }
.legal h2 { margin: 36px 0 8px; font-size: 1.2rem; letter-spacing: -.01em; }
.legal h3 { margin: 20px 0 6px; font-size: 1rem; }
.legal p, .legal li { color: #374151; }
.legal ul { padding-left: 20px; }
.legal li { margin-bottom: 6px; }
.toc {
  margin-bottom: 24px;
  padding: 16px 20px;
  border: 1px solid var(--c-line);
  border-radius: var(--radius);
  background: #fff;
}
.toc strong { display: block; margin-bottom: 6px; }
.toc ol { margin: 0; padding-left: 20px; }
.table-wrap { overflow-x: auto; margin: 12px 0; }
.legal table { width: 100%; min-width: 520px; border-collapse: collapse; font-size: .85rem; }
.legal th, .legal td { padding: 8px 10px; border: 1px solid var(--c-line); text-align: left; vertical-align: top; }
.legal th { background: #f3f4f6; }
.notice {
  padding: 12px 16px;
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-sm);
  background: #eef2ff;
  font-size: .9rem;
}
/* Marca los huecos que debes rellenar con tus datos. Bórralos al terminar. */
.fill {
  padding: 0 4px;
  border-radius: 4px;
  background: #fef3c7;
  color: #92400e;
  font-weight: 600;
}

/* 13. BREAKPOINTS ---------------------------------------------------- */
/* Móvil muy pequeño: se oculta la descripción para priorizar precio y CTA */
@media (max-width: 399px) {
  .card__desc { display: none; }
  .btn--buy { padding-inline: 10px; font-size: .88rem; }
}

@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .card__body { padding: 14px 16px 16px; }
  .cookie-dialog__actions { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 768px) {
  :root { --gutter: 24px; --header-h: 68px; }
  .hero { padding: 64px 0 72px; }
  .catalog__head h2 { font-size: 1.5rem; }
  .footer__grid { grid-template-columns: 2fr 1fr 1fr; }
  .cookie-banner { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
  .cookie-banner__inner { grid-template-columns: 1fr auto; align-items: center; gap: 20px; padding: 18px 20px; }
  .cookie-banner__actions { display: flex; }
  .cookie-banner__actions [data-consent="settings"] { order: 0; }
}

@media (min-width: 1024px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
}

/* 14. ACCESIBILIDAD: reducir animaciones si el usuario lo pide -------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
