/* =====================================================================
   DCisGlobal — Consentimiento de cookies (aviso + panel de preferencias)
   Camila (UX/UI/motion).

   Se carga DESPUÉS de estilos.css (usa sus tokens con fallback, para no
   depender del nombre exacto de cada variable). Dos piezas:
     1. El aviso (banner): tarjeta flotante abajo a la izquierda en
        computadora, hoja inferior a todo el ancho en celular.
     2. El panel de preferencias: diálogo centrado, claro, con un
        interruptor por categoría.
   Criterios: "Aceptar todas" y "Rechazar no esenciales" con el MISMO
   peso visual y el mismo tamaño (sin patrones oscuros), contraste AA,
   foco visible, movimiento solo con transform/opacity y respeto de
   prefers-reduced-motion. Nada de layout animado: CLS = 0.
   ===================================================================== */

/* ---------------------------------------------------------------
   1. Tokens locales (se aplican a las dos piezas: clase .ck)
   --------------------------------------------------------------- */
.ck {
  --ck-violeta: var(--violeta, #7E57C2);
  --ck-lila: var(--violeta-claro, #A87ED8);
  --ck-lila-claro: #C084FC;
  --ck-noche: var(--azul-noche, #0F172A);
  --ck-tinta: var(--texto, #1E293B);
  --ck-tinta-suave: var(--texto-suave, #475569);
  --ck-papel: #FFFFFF;
  --ck-papel-suave: var(--fondo-alt, #F8FAFC);
  --ck-linea-clara: rgba(15, 23, 42, 0.12);
  --ck-linea-oscura: rgba(255, 255, 255, 0.14);
  --ck-radio: 18px;
  --ck-radio-chico: 12px;
  --ck-sombra: 0 24px 60px -18px rgba(8, 10, 25, 0.60), 0 2px 10px rgba(8, 10, 25, 0.22);
  --ck-curva: cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--fuente, 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif);
  box-sizing: border-box;
}

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

/* Texto solo para lectores de pantalla (no dependemos de estilos.css) */
.ck .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;
}

/* ---------------------------------------------------------------
   2. El aviso (banner)
   --------------------------------------------------------------- */
.ck-aviso {
  position: fixed;
  z-index: 70;              /* por encima del contenido y del progreso de lectura (60) */
  left: 24px;
  bottom: 24px;
  width: min(540px, calc(100vw - 48px));
  padding: 22px 22px 18px;
  border-radius: var(--ck-radio);
  border: 1px solid var(--ck-linea-oscura);
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(126, 87, 194, 0.42) 0%, rgba(15, 23, 42, 0) 58%),
    rgba(15, 23, 42, 0.96);
  box-shadow: var(--ck-sombra);
  color: #E2E8F3;
  overflow: hidden;
  opacity: 0;
  transform: translate3d(0, 20px, 0);
  transition: opacity 0.42s var(--ck-curva), transform 0.52s var(--ck-curva);
  will-change: transform, opacity;
}

@supports (backdrop-filter: blur(14px)) {
  .ck-aviso { backdrop-filter: blur(14px) saturate(1.1); }
}

.ck-aviso.es-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.ck-aviso.se-va {
  opacity: 0;
  transform: translate3d(0, 14px, 0);
  transition-duration: 0.26s, 0.26s;
}

.ck-aviso::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--ck-lila-claro) 22%, var(--ck-violeta) 72%, transparent 100%);
  opacity: 0.9;
}

.ck-aviso__cabecera {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.ck-aviso__icono {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--ck-lila) 0%, var(--ck-violeta) 100%);
  color: #fff;
  box-shadow: 0 6px 18px -8px rgba(126, 87, 194, 0.9);
}

.ck-aviso__icono svg { width: 20px; height: 20px; display: block; }

.ck-aviso__titulo {
  margin: 0;
  font-size: 1.0625rem;
  line-height: 1.3;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}

.ck-aviso__texto {
  margin: 0 0 16px;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: #C7D0E0;
  max-width: 52ch;
}

.ck-aviso__texto a,
.ck-panel__texto a {
  color: #DCC9FB;
  text-decoration: underline;
  text-underline-offset: 2px;
  border-radius: 3px;
}

.ck-aviso__texto a:hover { color: #fff; }

.ck-aviso__acciones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ck-aviso__acciones .ck-btn--config {
  grid-column: 1 / -1;
}

/* ---------------------------------------------------------------
   3. Botones (compartidos por el aviso y el panel)
   --------------------------------------------------------------- */
.ck-btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 12px 18px;
  border-radius: var(--ck-radio-chico);
  border: 1.5px solid transparent;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: transform 0.18s var(--ck-curva), background-color 0.18s ease,
              border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.ck-btn:hover { transform: translateY(-1px); }
.ck-btn:active { transform: translateY(0); }

.ck-btn:focus-visible,
.ck-switch:focus-visible,
.ck-panel__cerrar:focus-visible,
.ck-aviso a:focus-visible,
.ck-panel a:focus-visible,
.ck-enlace-pie:focus-visible {
  outline: 2px solid var(--ck-lila-claro);
  outline-offset: 3px;
}

.ck-btn--si {
  background: linear-gradient(135deg, var(--ck-lila) 0%, var(--ck-violeta) 100%);
  color: #fff;
  box-shadow: 0 10px 24px -14px rgba(126, 87, 194, 0.95);
}
.ck-btn--si:hover { box-shadow: 0 14px 30px -14px rgba(126, 87, 194, 1); }

.ck-btn--no {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.55);
  color: #fff;
}
.ck-btn--no:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: #fff;
}

.ck-btn--config {
  background: transparent;
  border-color: transparent;
  color: #CBD5E1;
  min-height: 40px;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.ck-btn--config:hover { color: #fff; }

.ck-panel .ck-btn--no {
  background: #fff;
  border-color: rgba(30, 41, 59, 0.38);
  color: var(--ck-tinta);
}
.ck-panel .ck-btn--no:hover {
  background: var(--ck-papel-suave);
  border-color: var(--ck-tinta);
}
.ck-panel .ck-btn--config {
  color: var(--ck-tinta-suave);
}
.ck-panel .ck-btn--config:hover { color: var(--ck-violeta); }

.ck-panel .ck-btn--guardar,
.ck-panel .ck-btn--config.ck-btn--guardar {
  background: var(--ck-noche);
  border-color: var(--ck-noche);
  color: #fff;
  min-height: 46px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 10px 24px -16px rgba(15, 23, 42, 0.9);
}
.ck-panel .ck-btn--config.ck-btn--guardar:hover {
  background: #1B2742;
  border-color: #1B2742;
  color: #fff;
}

/* ---------------------------------------------------------------
   4. Panel de preferencias (diálogo)
   --------------------------------------------------------------- */
.ck-fondo {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(10, 14, 32, 0.62);
  opacity: 0;
  transition: opacity 0.28s ease;
}

@supports (backdrop-filter: blur(6px)) {
  .ck-fondo { backdrop-filter: blur(6px); }
}

.ck-fondo.es-visible { opacity: 1; }

.ck-panel {
  position: fixed;
  z-index: 91;
  left: 50%;
  top: 50%;
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
  border-radius: var(--ck-radio);
  background: var(--ck-papel);
  color: var(--ck-tinta);
  box-shadow: var(--ck-sombra);
  overflow: hidden;
  opacity: 0;
  transform: translate3d(-50%, calc(-50% + 14px), 0) scale(0.97);
  transition: opacity 0.3s var(--ck-curva), transform 0.36s var(--ck-curva);
  will-change: transform, opacity;
}

.ck-panel.es-visible {
  opacity: 1;
  transform: translate3d(-50%, -50%, 0) scale(1);
}

.ck-panel.se-va {
  opacity: 0;
  transform: translate3d(-50%, calc(-50% + 8px), 0) scale(0.985);
  transition-duration: 0.22s, 0.22s;
}

.ck-panel__cabecera {
  position: relative;
  padding: 24px 56px 18px 26px;
  background:
    radial-gradient(110% 160% at 0% 0%, rgba(168, 126, 216, 0.16) 0%, rgba(255, 255, 255, 0) 62%),
    var(--ck-papel);
  border-bottom: 1px solid var(--ck-linea-clara);
}

.ck-panel__titulo {
  margin: 0 0 6px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ck-noche);
}

.ck-panel__texto {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--ck-tinta-suave);
  max-width: 60ch;
}

.ck-panel__texto a { color: var(--ck-violeta); }

.ck-panel__cerrar {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ck-tinta-suave);
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s var(--ck-curva);
}
.ck-panel__cerrar:hover {
  background: var(--ck-papel-suave);
  color: var(--ck-noche);
  transform: rotate(90deg);
}
.ck-panel__cerrar svg { width: 18px; height: 18px; }

.ck-panel__cuerpo {
  padding: 8px 26px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.ck-cat {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 10px 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--ck-linea-clara);
}

.ck-cat:last-child { border-bottom: 0; }

.ck-cat__titulo {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ck-noche);
}

.ck-cat__texto {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--ck-tinta-suave);
  max-width: 58ch;
}

.ck-cat__detalle {
  display: block;
  margin-top: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ck-violeta);
}

.ck-cat__fija {
  align-self: center;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ck-violeta);
  background: rgba(126, 87, 194, 0.10);
  border: 1px solid rgba(126, 87, 194, 0.22);
  padding: 6px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.ck-switch {
  -webkit-appearance: none;
  appearance: none;
  align-self: center;
  flex: 0 0 auto;
  position: relative;
  width: 50px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #CBD5E1;
  cursor: pointer;
  transition: background-color 0.22s ease;
}

.ck-switch::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.35);
  transform: translate3d(0, 0, 0);
  transition: transform 0.24s var(--ck-curva);
}

.ck-switch[aria-checked="true"] {
  background: linear-gradient(135deg, var(--ck-lila) 0%, var(--ck-violeta) 100%);
}

.ck-switch[aria-checked="true"]::after {
  transform: translate3d(22px, 0, 0);
}

.ck-panel__pie {
  padding: 16px 26px 22px;
  border-top: 1px solid var(--ck-linea-clara);
  background: var(--ck-papel-suave);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ck-panel__pie .ck-btn--guardar { grid-column: 1 / -1; order: -1; }

@media (min-width: 620px) {
  .ck-panel__pie { grid-template-columns: 1fr 1fr 1fr; }
  .ck-panel__pie .ck-btn--guardar { grid-column: auto; order: 0; }
}

/* ---------------------------------------------------------------
   5. Enlace fijo "Preferencias de cookies" (pie del sitio)
   --------------------------------------------------------------- */
.ck-enlace-pie {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  cursor: pointer;
  opacity: 0.85;
  text-decoration: none;
  transition: opacity 0.18s ease, color 0.18s ease;
}

.ck-enlace-pie::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
  transition: transform 0.22s var(--ck-curva), opacity 0.22s ease;
}

.ck-enlace-pie:hover {
  opacity: 1;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ck-enlace-pie:hover::before { transform: scale(1.35); opacity: 1; }

/* ---------------------------------------------------------------
   6. Confirmación breve ("guardamos tus preferencias")
   --------------------------------------------------------------- */
.ck-aviso-guardado {
  position: fixed;
  z-index: 92;
  left: 50%;
  bottom: 28px;
  transform: translate3d(-50%, 12px, 0);
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--ck-noche);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--ck-sombra);
  opacity: 0;
  transition: opacity 0.26s ease, transform 0.32s var(--ck-curva);
  pointer-events: none;
}

.ck-aviso-guardado.es-visible {
  opacity: 1;
  transform: translate3d(-50%, 0, 0);
}

/* ---------------------------------------------------------------
   7. Celular
   --------------------------------------------------------------- */
@media (max-width: 640px) {
  .ck-aviso {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    padding: 18px 18px 14px;
    border-radius: 16px;
  }
  .ck-aviso__texto { font-size: 0.9rem; max-width: none; }
  .ck-aviso__acciones { grid-template-columns: 1fr; }
  .ck-panel {
    width: 100%;
    left: 0;
    top: auto;
    bottom: 0;
    max-height: 88vh;
    max-height: 88dvh;
    border-radius: 20px 20px 0 0;
    transform: translate3d(0, 24px, 0) scale(1);
  }
  .ck-panel.es-visible { transform: translate3d(0, 0, 0) scale(1); }
  .ck-panel.se-va { transform: translate3d(0, 16px, 0) scale(1); }
  .ck-panel__cabecera { padding: 22px 52px 16px 20px; }
  .ck-panel__cuerpo { padding: 4px 20px 16px; }
  .ck-panel__pie { padding: 14px 20px 20px; }
  .ck-cat { grid-template-columns: 1fr auto; gap: 8px 12px; }
}

/* Bloqueo de scroll del fondo mientras el panel está abierto */
html.ck-panel-abierto,
html.ck-panel-abierto body { overflow: hidden; }

/* ---------------------------------------------------------------
   8. Movimiento reducido: todo aparece y desaparece sin desplazarse
   --------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .ck-aviso,
  .ck-panel,
  .ck-fondo,
  .ck-aviso-guardado {
    transition-duration: 0.01ms !important;
    transform: none !important;
  }
  .ck-panel {
    left: 50%;
    top: 50%;
    margin-left: 0;
    translate: -50% -50%;
  }
  @media (max-width: 640px) {
    .ck-panel { left: 0; top: auto; bottom: 0; translate: none; }
  }
  .ck-btn:hover,
  .ck-panel__cerrar:hover,
  .ck-enlace-pie:hover::before { transform: none; }
  .ck-switch::after { transition-duration: 0.01ms !important; }
}

/* Sin JavaScript no se muestra nada roto: el aviso lo inyecta cookies.js */
