/* Tuenweb Elementos: listados de {{elementos:tipo}} (vistas tarjetas, lista y rejilla).
 * Toman colores, tipografías y radio de Site › Diseño (--tw-color-*, --tw-font-*, --tw-radius) con
 * valores de respaldo. Se carga en el <head> antes del CSS de la web: lo que cambie una web va en
 * Site › CSS adicional (o con las clases de la vista: "clase del elemento" y "clase del botón").
 *
 *   .tw-el                     contenedor (--tw-el-cols: columnas de la vista)
 *   .tw-el--tarjetas | --lista | --rejilla | --plantilla
 *   .tw-el--<tipo>  .tw-el--vista-<vista>
 *   .tw-el__item  .tw-el__media  .tw-el__body  .tw-el__title  .tw-el__field(--<campo>)  .tw-el__actions  .tw-el__btn
 */
.tw-el{
  --tw-el-gap:clamp(18px, 2.4vw, 30px);
  --tw-el-radius:var(--tw-radius, 8px);
  --tw-el-border:var(--tw-color-border, rgba(0,0,0,.12));
  --tw-el-accent:var(--tw-color-accent, #1f5fbf);
  --tw-el-accent-text:var(--tw-color-accent-text, #fff);
  display:grid;
  grid-template-columns:repeat(var(--tw-el-cols, 3), minmax(0, 1fr));
  gap:var(--tw-el-gap);
}
.tw-el *, .tw-el *::before, .tw-el *::after{ box-sizing:border-box; }
.tw-el__item{ display:flex; flex-direction:column; min-width:0; margin:0; }
.tw-el__media{ overflow:hidden; border-radius:var(--tw-el-radius); }
.tw-el__media a{ display:block; }
.tw-el__media picture{ display:block; }
.tw-el__media img{ display:block; width:100%; height:auto; }
.tw-el__body{ display:flex; flex-direction:column; gap:10px; flex:1; padding-top:14px; }
.tw-el__title{ margin:0; font-family:var(--tw-font-heading, inherit); font-weight:var(--tw-font-heading-weight, 600); font-size:1.15rem; line-height:1.3; }
.tw-el__title a{ color:inherit; text-decoration:none; }
.tw-el__title a:hover{ text-decoration:underline; }
.tw-el__field > :first-child{ margin-top:0; }
.tw-el__field > :last-child{ margin-bottom:0; }
.tw-el__actions{ margin:auto 0 0; padding-top:12px; display:flex; flex-wrap:wrap; gap:10px; }
/* Botón por defecto (con "clase del botón" en la vista se usan los de la web) */
.tw-el__btn:not([class*=" "]){ display:inline-flex; align-items:center; padding:10px 20px; border-radius:var(--tw-el-radius); background:var(--tw-el-accent); color:var(--tw-el-accent-text); font-weight:600; text-decoration:none; line-height:1.2; }
.tw-el__btn:not([class*=" "]):hover{ opacity:.88; }

/* Lista: imagen a la izquierda */
.tw-el--lista .tw-el__item{ flex-direction:row; gap:var(--tw-el-gap); align-items:flex-start; }
.tw-el--lista .tw-el__media{ flex:0 0 min(32%, 260px); }
.tw-el--lista .tw-el__body{ padding-top:0; }

/* Rejilla de imágenes con su título */
.tw-el--rejilla .tw-el__media img{ aspect-ratio:1; object-fit:cover; }
.tw-el--rejilla .tw-el__body{ padding-top:8px; }
.tw-el--rejilla .tw-el__title{ font-size:1rem; }

@media (max-width:900px){
  .tw-el{ grid-template-columns:repeat(2, minmax(0, 1fr)); }
  .tw-el[style*="--tw-el-cols:1"]{ grid-template-columns:minmax(0, 1fr); }
}
@media (max-width:560px){
  .tw-el{ grid-template-columns:minmax(0, 1fr); }
  .tw-el--lista .tw-el__item{ flex-direction:column; }
  .tw-el--lista .tw-el__media{ flex-basis:auto; width:100%; }
}

/* Filtro por término en la web (filtro="taxonomía") */
.tw-el-filter{ display:flex; flex-wrap:wrap; gap:8px; margin:0 0 clamp(18px, 2.4vw, 28px); }
.tw-el-filter a{ display:inline-flex; align-items:center; padding:7px 16px; border:1px solid var(--tw-color-border, rgba(0,0,0,.15)); border-radius:999px; color:inherit; text-decoration:none; font-size:.92rem; line-height:1.2; }
.tw-el-filter a:hover{ border-color:var(--tw-color-accent, #1f5fbf); }
.tw-el-filter a.is-active{ background:var(--tw-color-accent, #1f5fbf); border-color:var(--tw-color-accent, #1f5fbf); color:var(--tw-color-accent-text, #fff); }
.tw-el-empty{ margin:0; opacity:.75; }

/* Carrusel (1.4): carrusel="1" o la opción de la vista. El listado se desliza en horizontal (también con el
 * dedo) y el JS añade flechas, puntos y el avance automático. Tarjetas visibles: --tw-car-pc / -tablet / -movil.
 *   .tw-el-carrusel  .tw-el-carrusel__nav (__prev, __dots con button[aria-current], __next)
 * Funciona con las clases de la web en el listado (p. ej. clase="cards cards--3"): manda el carrusel. */
.tw-el-carrusel{
  --tw-car-n:var(--tw-car-pc, 3);
  --tw-car-gap:clamp(18px, 2.4vw, 30px);
  --tw-car-accent:var(--tw-color-accent, #1f5fbf);
  position:relative;
}
.tw-el-carrusel > .tw-el{
  display:grid;
  grid-template-columns:none;
  grid-auto-flow:column;
  grid-auto-columns:calc((100% - (var(--tw-car-n) - 1) * var(--tw-car-gap)) / var(--tw-car-n));
  gap:var(--tw-car-gap);
  overflow-x:auto;
  overscroll-behavior-x:contain;
  scroll-snap-type:x mandatory;
  scroll-behavior:smooth;
  scrollbar-width:none;
  -webkit-overflow-scrolling:touch;
  padding:4px 0;   /* que no se corten las sombras de las tarjetas */
}
.tw-el-carrusel > .tw-el::-webkit-scrollbar{ display:none; }
.tw-el-carrusel > .tw-el > *{ scroll-snap-align:start; min-width:0; }
@media (max-width:1023px){ .tw-el-carrusel{ --tw-car-n:var(--tw-car-tablet, 2); } }
@media (max-width:599px){ .tw-el-carrusel{ --tw-car-n:var(--tw-car-movil, 1); } }
@media (prefers-reduced-motion:reduce){ .tw-el-carrusel > .tw-el{ scroll-behavior:auto; } }

.tw-el-carrusel__prev, .tw-el-carrusel__next{
  position:absolute; top:calc(50% - 17px); z-index:2; display:flex; align-items:center; justify-content:center; flex:0 0 auto;
  width:44px; height:44px; margin-top:-22px; padding:0; border:1px solid var(--tw-color-border, rgba(0,0,0,.12)); border-radius:50%;
  background:#fff; color:var(--tw-car-accent); box-shadow:0 4px 14px rgba(0,0,0,.14); cursor:pointer; transition:opacity .2s, transform .2s;
}
.tw-el-carrusel__prev{ left:-12px; }
.tw-el-carrusel__next{ right:-12px; }
.tw-el-carrusel__prev:hover, .tw-el-carrusel__next:hover{ transform:scale(1.06); }
.tw-el-carrusel__prev:disabled, .tw-el-carrusel__next:disabled{ opacity:0; pointer-events:none; }
.tw-el-carrusel__prev svg, .tw-el-carrusel__next svg{ width:20px; height:20px; }
@media (min-width:1280px){
  .tw-el-carrusel__prev{ left:-22px; }
  .tw-el-carrusel__next{ right:-22px; }
}
.tw-el-carrusel__nav{ display:flex; align-items:center; justify-content:center; gap:16px; margin-top:clamp(16px, 2vw, 24px); }
.tw-el-carrusel__dots{ display:flex; flex-wrap:wrap; justify-content:center; gap:8px; }
/* Móvil: las flechas, debajo y a los lados de los puntos (no tapan las tarjetas) */
@media (max-width:599px){
  .tw-el-carrusel__prev, .tw-el-carrusel__next{ position:static; width:38px; height:38px; margin:0; box-shadow:0 2px 8px rgba(0,0,0,.12); }
  .tw-el-carrusel__prev:disabled, .tw-el-carrusel__next:disabled{ opacity:.35; }
}
.tw-el-carrusel__dots button{
  width:10px; height:10px; padding:0; border:0; border-radius:999px;
  background:var(--tw-car-accent); opacity:.3; cursor:pointer; transition:opacity .2s, width .2s;
}
.tw-el-carrusel__dots button[aria-current="true"]{ width:26px; opacity:1; }
.tw-el-carrusel__prev:focus-visible, .tw-el-carrusel__next:focus-visible, .tw-el-carrusel__dots button:focus-visible{ outline:2px solid var(--tw-car-accent); outline-offset:2px; }
.tw-el-carrusel [hidden]{ display:none !important; }

/* Galería (1.6): campo "Galería" ({{campo}}). Rejilla de miniaturas que abren el visor (.tw-lightbox).
 *   .tw-el-gallery (--tw-el-gallery-cols, --tw-el-gallery-gap, --tw-el-gallery-ratio)  .tw-el-gallery__item */
.tw-el-gallery{
  --tw-el-gallery-cols:4;
  --tw-el-gallery-gap:clamp(8px, 1.4vw, 16px);
  --tw-el-gallery-ratio:4 / 3;
  display:grid;
  grid-template-columns:repeat(var(--tw-el-gallery-cols), minmax(0, 1fr));
  gap:var(--tw-el-gallery-gap);
}
.tw-el-gallery__item{ display:block; overflow:hidden; aspect-ratio:var(--tw-el-gallery-ratio); border-radius:var(--tw-radius, 8px); background:rgba(0,0,0,.06); cursor:zoom-in; }
.tw-el-gallery__item picture{ display:block; width:100%; height:100%; }
.tw-el-gallery__item img{ display:block; width:100%; height:100%; object-fit:cover; transition:transform .5s ease; }
.tw-el-gallery__item:hover img, .tw-el-gallery__item:focus-visible img{ transform:scale(1.05); }
@media (max-width:900px){ .tw-el-gallery{ --tw-el-gallery-cols:3; } }
@media (max-width:600px){ .tw-el-gallery{ --tw-el-gallery-cols:2; } }
@media (prefers-reduced-motion:reduce){ .tw-el-gallery__item img{ transition:none; } }

/* Visor */
.tw-lightbox{ position:fixed; inset:0; z-index:10050; display:flex; align-items:center; justify-content:center; padding:56px 72px; background:rgba(12,14,18,.94); }
.tw-lightbox[hidden]{ display:none; }
.tw-lightbox-open, .tw-lightbox-open body{ overflow:hidden; }
.tw-lightbox__figure{ margin:0; display:flex; flex-direction:column; align-items:center; gap:12px; max-width:100%; max-height:100%; }
.tw-lightbox__img{ display:block; max-width:min(1600px, 100%); max-height:calc(100vh - 140px); width:auto; height:auto; border-radius:6px; box-shadow:0 20px 60px rgba(0,0,0,.5); }
.tw-lightbox__count{ color:rgba(255,255,255,.75); font:500 14px/1 system-ui, sans-serif; letter-spacing:.06em; }
.tw-lightbox button{ position:absolute; display:grid; place-items:center; width:48px; height:48px; padding:0; border:0; border-radius:50%; background:rgba(255,255,255,.12); color:#fff; cursor:pointer; transition:background .2s; }
.tw-lightbox button:hover, .tw-lightbox button:focus-visible{ background:rgba(255,255,255,.26); outline:none; }
.tw-lightbox button[hidden]{ display:none; }
.tw-lightbox svg{ width:24px; height:24px; }
.tw-lightbox__close{ top:14px; right:14px; }
.tw-lightbox__prev{ left:14px; top:50%; margin-top:-24px; }
.tw-lightbox__next{ right:14px; top:50%; margin-top:-24px; }
@media (max-width:600px){
  .tw-lightbox{ padding:60px 10px 70px; }
  .tw-lightbox__prev, .tw-lightbox__next{ top:auto; bottom:12px; margin:0; }
  .tw-lightbox__prev{ left:calc(50% - 60px); }
  .tw-lightbox__next{ right:calc(50% - 60px); }
}
