/* =========================================================
   Teng Blog Grid
   Tutte le variabili sono sul contenitore: per ritoccare lo
   stile basta sovrascriverle nel CSS personalizzato del tema.
   ========================================================= */

.teng-blog {
	/* Lo shortcode scrive inline SOLO --teng-cols-desktop: uno stile inline
	   batte qualsiasi media query, quindi le colonne effettive devono
	   passare da una variabile diversa, che il CSS può sovrascrivere. */
	--teng-cols-desktop: 3;
	--teng-cols: var(--teng-cols-desktop);
	--teng-gap: 30px;
	--teng-radius: 30px;
	--teng-radius-card: 0;
	--teng-accent: var(--e-global-color-primary, #1a1a1a);
	--teng-accent-contrast: #ffffff;
	--teng-text: var(--e-global-color-text, #333333);
	--teng-muted: rgba(0, 0, 0, 0.12);
	--teng-speed: 0.3s;

	/* Pills e filtri: maiuscoletto spaziato come il resto del sito */
	--teng-pill-size: 13px;
	--teng-pill-tracking: 0.08em;

	/* Filtro non attivo: fondo bianco, testo nero */
	--teng-filter-bg: #ffffff;
	--teng-filter-color: #000000;

	position: relative;
}

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

/* ---------- Filtri ---------- */

.teng-blog__filters-wrap {
	position: relative;
	margin-bottom: 40px;
}

.teng-blog__filters {
	display: flex;
	gap: 10px;
	overflow-x: auto;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	-ms-overflow-style: none;
	padding: 2px 2px 4px;
	margin: -2px -2px -4px;
}

.teng-blog__filters::-webkit-scrollbar {
	display: none;
}

/* Durante il trascinamento niente scroll animato e niente selezione del
   testo. Mai `pointer-events: none` sui filtri: toglierebbe il link da
   sotto il cursore e annullerebbe il click. */
.teng-blog__filters.is-dragging {
	scroll-behavior: auto;
	cursor: grabbing;
	user-select: none;
	-webkit-user-select: none;
}

/* Stessa lingua visiva delle pills nelle card: maiuscoletto spaziato */
.teng-blog__filter {
	flex: 0 0 auto;
	white-space: nowrap;
	display: inline-block;
	font: inherit;
	font-size: var(--teng-pill-size);
	line-height: 1;
	letter-spacing: var(--teng-pill-tracking);
	text-transform: uppercase;
	background-color: var(--teng-filter-bg);
	/* Bordo trasparente: tiene la stessa misura dello stato attivo */
	border: 1px solid transparent;
	border-radius: var(--teng-radius);
	padding: 9px 20px;
	cursor: pointer;
	transition: background-color var(--teng-speed) ease, color var(--teng-speed) ease,
		border-color var(--teng-speed) ease;
}

/* Non attivo: fondo bianco, testo nero, mai sottolineato */
.teng-blog .teng-blog__filter,
.teng-blog .teng-blog__filter:link,
.teng-blog .teng-blog__filter:visited {
	color: var(--teng-filter-color);
	text-decoration: none;
}

/* Hover e attivo: pieno colore accento */
.teng-blog .teng-blog__filter:hover,
.teng-blog .teng-blog__filter:focus,
.teng-blog .teng-blog__filter.is-active {
	background-color: var(--teng-accent);
	border-color: var(--teng-accent);
	color: var(--teng-accent-contrast);
	text-decoration: none;
}

/* Sfumature laterali: dicono che il nastro continua oltre il bordo */
.teng-blog__filters-wrap::before,
.teng-blog__filters-wrap::after {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	width: 48px;
	pointer-events: none;
	opacity: 0;
	transition: opacity var(--teng-speed) ease;
	z-index: 2;
}

.teng-blog__filters-wrap::before {
	left: -2px;
	background: linear-gradient(to right, var(--teng-fade, #fff), rgba(255, 255, 255, 0));
}

.teng-blog__filters-wrap::after {
	right: -2px;
	background: linear-gradient(to left, var(--teng-fade, #fff), rgba(255, 255, 255, 0));
}

.teng-blog__filters-wrap.has-overflow-start::before,
.teng-blog__filters-wrap.has-overflow-end::after {
	opacity: 1;
}

/* Freccia animata: compare solo se c'è davvero altro da vedere
   e sparisce al primo scroll dell'utente */
.teng-blog__swipe-hint {
	position: absolute;
	top: 50%;
	right: 0;
	transform: translateY(-50%);
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background-color: var(--teng-accent);
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
	opacity: 0;
	transition: opacity var(--teng-speed) ease;
	z-index: 3;
}

.teng-blog__filters-wrap.has-overflow-end:not(.is-hint-dismissed) .teng-blog__swipe-hint {
	opacity: 1;
}

.teng-blog__swipe-arrow {
	width: 8px;
	height: 8px;
	border-top: 2px solid var(--teng-accent-contrast);
	border-right: 2px solid var(--teng-accent-contrast);
	transform: translateX(-2px) rotate(45deg);
	animation: teng-nudge 1.4s ease-in-out infinite;
}

@keyframes teng-nudge {
	0%,
	100% {
		transform: translateX(-4px) rotate(45deg);
	}
	50% {
		transform: translateX(1px) rotate(45deg);
	}
}

/* Barra di scorrimento sottile: seconda affordance, su touch */
.teng-blog__scrollbar {
	display: none;
	position: relative;
	height: 3px;
	margin-top: 14px;
	border-radius: 3px;
	background-color: var(--teng-muted);
	overflow: hidden;
}

.teng-blog__filters-wrap.has-overflow .teng-blog__scrollbar {
	display: block;
}

.teng-blog__scrollbar-thumb {
	position: absolute;
	top: 0;
	left: 0;
	height: 100%;
	width: 30%;
	border-radius: 3px;
	background-color: var(--teng-accent);
	transform-origin: left center;
}

/* ---------- Griglia ---------- */

.teng-blog__grid {
	display: grid;
	grid-template-columns: repeat(var(--teng-cols), minmax(0, 1fr));
	gap: var(--teng-gap);
}

.teng-blog__card {
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

/* Il riquadro è sempre quadrato e largo quanto la colonna, a qualsiasi
   dimensione: nessun tetto in pixel, altrimenti a una colonna l'immagine
   resterebbe più stretta della card. Il ritaglio servito è 413x413
   (size `teng-blog-card`), ma la resa non dipende da quella misura. */
.teng-blog__thumb {
	display: block;
	position: relative;
	width: 100%;
	overflow: hidden;
	border-radius: var(--teng-radius-card);
	aspect-ratio: 1 / 1;
	background-color: rgba(0, 0, 0, 0.05);
	margin-bottom: 18px;
	/* Dentro una card in colonna il riquadro non deve poter essere
	   compresso: succede quando la card è dentro una griglia che ne
	   impone l'altezza, come nel carosello sotto l'articolo. */
	flex: 0 0 auto;
}

/* Riempimento a prova di tema: molti temi impongono dimensioni e
   object-fit sulle img, e vincono per specificità. Con position absolute
   e i quattro lati a zero il riquadro viene comunque riempito. */
.teng-blog .teng-blog__img,
.teng-blog .teng-blog__thumb-placeholder,
.teng-blog .teng-blog__thumb img {
	position: absolute !important;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	max-height: none !important;
	min-height: 0 !important;
	object-fit: cover !important;
	object-position: center !important;
	transition: transform 0.5s ease;
}

.teng-blog__card:hover .teng-blog__img {
	transform: scale(1.05);
}

.teng-blog__body {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	flex: 1 1 auto;
	gap: 14px;
}

/* ---------- Pills categoria ---------- */

.teng-blog__pills {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

/* I temi tendono a forzare colore e sottolineatura su ogni <a>: qui la
   pill deve restare bianca e pulita in tutti gli stati. */
.teng-blog .teng-blog__pill,
.teng-blog .teng-blog__pill:link,
.teng-blog .teng-blog__pill:visited,
.teng-blog .teng-blog__pill:hover,
.teng-blog .teng-blog__pill:focus,
.teng-blog .teng-blog__pill:active {
	color: var(--teng-accent-contrast);
	text-decoration: none;
	border-bottom: 0;
}

.teng-blog__pill {
	display: inline-block;
	font: inherit;
	font-size: var(--teng-pill-size);
	line-height: 14px;
	letter-spacing: var(--teng-pill-tracking);
	text-transform: uppercase;
	text-decoration: none;
	color: var(--teng-accent-contrast);
	background-color: var(--teng-accent);
	border: 0;
	border-radius: var(--teng-radius);
	padding: 5px 15px;
	cursor: pointer;
	transition: opacity var(--teng-speed) ease;
}

.teng-blog__pill:hover,
.teng-blog__pill:focus-visible {
	color: var(--teng-accent-contrast);
	opacity: 0.8;
}

/* ---------- Titolo, testo, pulsante ---------- */

/* Nessun font-size dichiarato: il titolo eredita la tipografia dei
   titoli del tema, come nel resto del sito. Per forzarla basta
   sovrascrivere font-size nel CSS personalizzato. */
.teng-blog__title {
	margin: 0;
}

.teng-blog__title a {
	color: var(--teng-accent);
	text-decoration: none;
	transition: opacity var(--teng-speed) ease;
}

.teng-blog__title a:hover {
	color: var(--teng-accent);
	opacity: 0.7;
}

.teng-blog__excerpt {
	margin: 0;
	font-size: 0.9em;
	opacity: 0.8;
}

.teng-blog__cta {
	margin-top: auto;
	padding-top: 4px;
}

/* CTA testuale: nessuno stile da pulsante, solo testo sottolineato. */
.teng-blog .teng-blog__more,
.teng-blog .teng-blog__more:link,
.teng-blog .teng-blog__more:visited,
.teng-blog .teng-blog__more:hover,
.teng-blog .teng-blog__more:focus {
	display: inline-block;
	color: var(--teng-accent);
	text-decoration: underline;
	text-underline-offset: 4px;
	background: none;
	border: 0;
	padding: 0;
}

.teng-blog .teng-blog__more:hover {
	opacity: 0.7;
}

/* Rete di sicurezza: se il tema non definisce .screen-reader-text, il
   titolo nascosto nella CTA non deve comparire a schermo. */
.teng-blog .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.teng-blog__empty {
	margin: 0;
	padding: 40px 0;
	text-align: center;
	opacity: 0.7;
}

/* ---------- Paginazione ---------- */

.teng-blog__pagination {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: 8px;
	margin-top: 50px;
}

.teng-blog__page {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 40px;
	height: 40px;
	padding: 0 12px;
	border: 1px solid var(--teng-muted);
	border-radius: var(--teng-radius);
	color: var(--teng-text);
	text-decoration: none;
	font-size: 0.9em;
	line-height: 1;
	transition: background-color var(--teng-speed) ease, color var(--teng-speed) ease,
		border-color var(--teng-speed) ease;
}

.teng-blog__page:hover {
	border-color: var(--teng-accent);
	color: var(--teng-accent);
}

.teng-blog__page.is-current {
	background-color: var(--teng-accent);
	border-color: var(--teng-accent);
	color: var(--teng-accent-contrast);
}

.teng-blog__page--dots {
	border-color: transparent;
	min-width: auto;
	padding: 0 4px;
}

/* ---------- Stato di caricamento ---------- */

.teng-blog__results {
	transition: opacity var(--teng-speed) ease;
}

.teng-blog.is-loading .teng-blog__results {
	opacity: 0.35;
	pointer-events: none;
}

.teng-blog__loader {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 38px;
	height: 38px;
	margin: -19px 0 0 -19px;
	opacity: 0;
	pointer-events: none;
	transition: opacity var(--teng-speed) ease;
	z-index: 5;
}

.teng-blog.is-loading .teng-blog__loader {
	opacity: 1;
}

.teng-blog__loader span {
	display: block;
	width: 100%;
	height: 100%;
	border: 3px solid var(--teng-muted);
	border-top-color: var(--teng-accent);
	border-radius: 50%;
	animation: teng-spin 0.8s linear infinite;
}

@keyframes teng-spin {
	to {
		transform: rotate(360deg);
	}
}

/* ---------- Breakpoint (allineati ai default Elementor) ---------- */

@media (max-width: 1024px) {
	.teng-blog {
		--teng-cols: 2;
		--teng-gap: 25px;
	}
}

@media (max-width: 767px) {
	.teng-blog {
		--teng-cols: 1;
		--teng-gap: 30px;
	}

	.teng-blog__filters-wrap {
		margin-bottom: 30px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.teng-blog *,
	.teng-blog *::before,
	.teng-blog *::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}

	.teng-blog__filters {
		scroll-behavior: auto;
	}
}
