/* ==========================================================================
   landing/_zigzag.css
   Style "zigzag" — Secciones 50/50 imagen+texto con chevron CSS.
   Adaptado del diseño de Essere Animali / AnimaNaturalis.

   CARGA: individualmente desde los elements que lo usen:
     $this->Landing->css('_zigzag');

   FUNCIONA EN:
     landing-items.php  { "type": "items",  "style": "zigzag" }
     landing-posts.php  { "type": "posts",  "style": "zigzag" }

   TOKENS:
     --landing-primary    → color de la cifra/stat destacada
     --lf-headline        → fuente del h3
     --lf-body            → fuente del párrafo
     --chevron-size       → tamaño del triángulo (override por campaña)

   IMÁGENES:
     Las imágenes usan background-image en un div .zigzag-img (NO <img>).
     Se carga vía JS con data-src + clase .lazy-bg del sistema de la landing.
     Para el primer item above-the-fold, el JS puede cargarlo con priority.

   JSON (items):
     {
       "type": "items", "style": "zigzag",
       "items": [
         {
           "tag":   "Conejos",
           "title": "<strong>13 millones de conejos</strong> en jaula",
           "text":  "Los conejos viven…",
           "asset": "/img/conejos.jpg",
           "alt":   "Conejos en jaula"
         }
       ]
     }

   JSON (posts):
     { "type": "posts", "style": "zigzag" }
     (las secciones se construyen con title, descr, image, published del post)

   NOMENCLATURA (scoped bajo .lp-zigzag para evitar colisiones):
     .lp-zigzag           wrapper
     .zigzag-section      fila individual (imagen + texto)
     .zigzag-section.even inversa — imagen a la derecha
     .zigzag-half         mitad base (50%)
     .zigzag-pic          mitad imagen
     .zigzag-img          div con background-image (lazy-bg)
     .zigzag-body         mitad texto
     .zigzag-text         bloque interno de texto
     .zigzag-tag          etiqueta de categoría (stat-tag)
   ========================================================================== */

/* ── Variables locales del módulo ────────────────────────────────────────── */
.lp-zigzag {
  --zigzag-brand:      var(--landing-primary,   #840032);
  --zigzag-chevron:    60px;   /* override con var(--chevron-size) en JSON */
  --zigzag-strip:      30px;
  --zigzag-strip-neg: -31px;
  --zigzag-min-h:      380px;
  --zigzag-bg-pic:     #1a1a1a;
}

/* ── Wrapper ─────────────────────────────────────────────────────────────── */

.lp-zigzag { width: 100%; }

/* ── Fila ────────────────────────────────────────────────────────────────── */

.zigzag-section {
  display: flex;
  align-items: stretch;
  width: 100%;
  margin: 0;
  overflow: visible;  /* el chevron de ::after sobresale entre las dos mitades */
}

.zigzag-section.even { flex-direction: row-reverse; }
.zigzag-section.even .zigzag-half { justify-content: flex-end; }

/* ── Mitad base ──────────────────────────────────────────────────────────── */

.zigzag-half {
  width: 50%;
  display: flex;
  position: relative;
}

/* ── Mitad imagen ────────────────────────────────────────────────────────── */
/*
 * Altura proporcional:
 *   .zigzag-pic::after con padding-top: 70% activa en ≥992px.
 *   En pantallas más pequeñas usa min-height fija para evitar espacios vacíos.
 *
 * Separador blanco:
 *   border-right: 30px + ::before (tira de 31px que tapa el borde lateral).
 */

.zigzag-pic {
  background-color: var(--zigzag-bg-pic);
  overflow: hidden;
  border-right: var(--zigzag-strip) solid #fff;
  transform-origin: center right;
  min-height: var(--zigzag-min-h);
}

/* ::after — empuja la altura proporcionalmente (activado solo en ≥992px) */
.zigzag-pic::after {
  content: '';
  display: block;
  padding-top: 0;       /* se activa en el breakpoint ≥992px */
  flex-shrink: 0;
  pointer-events: none;
}

/* ::before — tira blanca que cubre el hueco del borde */
.zigzag-pic::before {
  content: '';
  width: 31px;
  height: 100%;
  background-color: #fff;
  position: absolute;
  top: 0;
  right: var(--zigzag-strip-neg);
  z-index: 1;
  pointer-events: none;
}

/* Variante .even — imagen a la derecha */
.zigzag-section.even .zigzag-pic {
  border-right: none;
  border-left: var(--zigzag-strip) solid #fff;
  transform-origin: center left;
}

.zigzag-section.even .zigzag-pic::before {
  left: var(--zigzag-strip-neg);
  right: auto;
}

/* ── Div de imagen (background-image, lazy) ──────────────────────────────── */

.zigzag-img {
  position: absolute;
  inset: 0;
  background-color: #b0b0b0;
  background-size: cover;
  background-repeat: no-repeat;
  background-position: 50% 50%;
  transition: transform 6s ease;
  /* La imagen real se aplica vía JS con data-src → lazy-bg */
}

.zigzag-section:hover .zigzag-img { transform: scale(1.04); }

/* Placeholder cuando no hay imagen aún (antes de lazy-load) */
.zigzag-img.lazy-loading { background-color: #e0e0e0; }
.zigzag-img.lazy-loading::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.3) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: zigzag-shimmer 1.5s infinite;
}

@keyframes zigzag-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* ── Chevron (triángulo CSS) ──────────────────────────────────────────────── */
/*
 * Secciones normales: triángulo apunta ← (izquierda, hacia la foto)
 * Secciones .even:    triángulo apunta → (derecha,   hacia la foto)
 */

.zigzag-body::after {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  left: calc(-1 * var(--zigzag-chevron));
  top: 50%;
  margin-top: calc(-1 * var(--zigzag-chevron));
  border-width: var(--zigzag-chevron) var(--zigzag-chevron) var(--zigzag-chevron) 0;
  border-color: transparent #fff transparent transparent;
  border-style: solid;
  z-index: 2;
  pointer-events: none;
}

.zigzag-section.even .zigzag-body::after {
  left: auto;
  right: calc(-1 * var(--zigzag-chevron));
  border-width: var(--zigzag-chevron) 0 var(--zigzag-chevron) var(--zigzag-chevron);
  border-color: transparent transparent transparent #fff;
}

/* Sobre fondos de color (bg != #fff) — el chevron debe usar el mismo color */
.zigzag-section.bg-light .zigzag-body::after { border-right-color: var(--landing-bg-light, #f3f4f5); }
.zigzag-section.even.bg-light .zigzag-body::after { border-left-color: var(--landing-bg-light, #f3f4f5); }

/* ── Mitad texto ─────────────────────────────────────────────────────────── */

.zigzag-body {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 48px 48px 48px 56px;
  background: #fff;
  width: 50%;
  position: relative;   /* necesario para ::after (chevron) */
  overflow: visible;    /* el chevron sobresale del borde izquierdo */
}

.zigzag-section.even .zigzag-body { padding: 48px 56px 48px 48px; }

/* ── Bloque de texto interno ─────────────────────────────────────────────── */

.zigzag-text { max-width: 540px; margin-top: 20px; }

/* Etiqueta de categoría */
.zigzag-tag {
  display: inline-block;
  background: #f3f3f1;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  padding: 3px 10px;
  margin-bottom: 14px;
  color: #888;
}

/* Título: número/stat grande en rojo, subtexto normal */
.zigzag-text h3 {
  font-family: var(--lf-headline);
  font-size: clamp(1.6rem, 3vw, 2.8rem);
  font-weight: 400;
  line-height: 1.25;
  color: #111;
  margin: 0 0 1rem;
}

/* La cifra: <strong> dentro del h3 → grande, de color primario */
.zigzag-text h3 strong,
.zigzag-text h3 b {
  color: var(--zigzag-brand);
  font-size: 1.5em;
  font-weight: 700;
  display: block;
  line-height: 1.1;
}

/* Párrafo */
.zigzag-text p {
  font-size: 15px;
  line-height: 1.75;
  color: #555;
  margin: 0 0 1rem;
}

.zigzag-text p strong { font-weight: 600; color: #222; }

/* Enlace CTA debajo del texto */
.zigzag-text .zigzag-cta {
  display: inline-block;
  margin-top: .5rem;
  color: var(--zigzag-brand);
  font-weight: 700;
  font-size: .88rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  text-decoration: none;
  border-bottom: 2px solid currentColor;
  padding-bottom: 2px;
  transition: opacity var(--lf-transition-fast, .15s);
}

.zigzag-text .zigzag-cta:hover { opacity: .75; }


/* ── Breakpoint ≥992px — altura proporcional ────────────────────────────── */

@media (min-width: 992px) {
  .zigzag-pic {
    min-height: 0; /* padding-top de ::after toma el control */
  }
  .zigzag-pic::after { padding-top: 70%; }
  .zigzag-body { align-items: center; }
}

/* ── Responsive ≤768px ───────────────────────────────────────────────────── */

@media (max-width: 768px) {

  .zigzag-section,
  .zigzag-section.even {
    flex-direction: column !important;
    margin: 0 0 16px;
  }

  .zigzag-half,
  .zigzag-pic,
  .zigzag-body  { width: 100%; }

  /* Imagen: ancho completo, sin bordes laterales */
  .zigzag-pic,
  .zigzag-section.even .zigzag-pic {
    min-height: 300px;
    border: none !important;
    order: 0;
    transform-origin: center center;
  }

  .zigzag-pic::before,
  .zigzag-section.even .zigzag-pic::before { display: none; }

  /* Chevron móvil: triángulo ↑ desde el bloque de texto */
  .zigzag-body::after,
  .zigzag-section.even .zigzag-body::after {
    left: 20px;
    right: auto;
    top: -29px;
    margin: 0;
    border-width: 0 30px 30px;
    border-color: transparent transparent #fff transparent;
  }

  .zigzag-body,
  .zigzag-section.even .zigzag-body {
    padding: 32px 20px;
    order: 1;
  }
}

@media (max-width: 400px) {
  .zigzag-body,
  .zigzag-section.even .zigzag-body { padding: 24px 16px; }
}

/* ── Accesibilidad ───────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .zigzag-section .zigzag-text {
    transition: none;
    opacity: 1;
    transform: none;
  }
  .zigzag-section:hover .zigzag-img { transition: none; transform: none; }
  @keyframes zigzag-shimmer { from, to { background-position: 0 0; } }
}
