/**
 * Stili frontend — Blocco Articoli Correlati BD Tech
 * @since   1.0.0
 * @updated 1.4.0  Lista column layout, meta unificati, nuove modalità.
 */

/* ── Wrapper comune ──────────────────────────────────────────────────────────*/
.bd-tech-correlati {
	margin: 2rem 0;
	font-family: inherit;
}

.bd-tech-correlati__titolo {
	font-size: 1.25rem;
	font-weight: 700;
	margin: 0 0 1.25rem 0;
	padding-bottom: 0.5rem;
	border-bottom: 2px solid currentColor;
	opacity: 0.85;
}
.bd-tech-correlati__titolo--centro { text-align: center; }

/* ══════════════════════════════════════════════════════════════════════════════
   LAYOUT: LISTA TESTO
   Reset aggressivo per neutralizzare stili tema (Blocksy e altri)
══════════════════════════════════════════════════════════════════════════════ */

.bd-tech-correlati--testo .bd-tech-correlati__lista,
.bd-tech-correlati--testo .bd-tech-correlati__lista li {
	list-style: none !important;
	list-style-type: none !important;
	padding: 0 !important;
	margin: 0 !important;
}
.bd-tech-correlati--testo .bd-tech-correlati__lista li::before,
.bd-tech-correlati--testo .bd-tech-correlati__lista li::marker {
	content: none !important;
	display: none !important;
}

/* Ogni riga della lista: titolo su riga 1, meta su riga 2 sempre sotto */
.bd-tech-correlati--testo .bd-tech-correlati__item {
	display: flex !important;
	flex-direction: column !important;
	align-items: flex-start !important;
	gap: 0.2rem !important;
	padding: 0.5rem 0 !important;
	margin: 0 !important;
	list-style: none !important;
}

/* Separatore linea */
.bd-tech-correlati__lista--sep-linea .bd-tech-correlati__item {
	border-bottom: 1px solid rgba(0,0,0,.08);
}
.bd-tech-correlati__lista--sep-linea .bd-tech-correlati__item:last-child {
	border-bottom: none;
}

/* Link titolo — va a capo normalmente */
.bd-tech-correlati--testo .bd-tech-correlati__link {
	display: inline-flex;
	align-items: baseline;
	gap: 0.35rem;
	text-decoration: none;
	font-weight: 500;
	flex-shrink: 1;
	min-width: 0;
	transition: opacity 0.2s;
}
.bd-tech-correlati--testo .bd-tech-correlati__link:hover {
	text-decoration: underline;
	opacity: 0.75;
}
.bd-tech-correlati__link-titolo {
	word-break: break-word;
	overflow-wrap: break-word;
	white-space: normal;
	min-width: 0;
}

.bd-tech-correlati__sep {
	font-size: 0.9em;
	opacity: 0.5;
	flex-shrink: 0;
}

/* Meta — riga sotto il titolo (lista e card) */
.bd-tech-correlati__item-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.2rem 0;
	font-size: 0.75rem;
	opacity: 0.6;
	line-height: 1.3;
}
.bd-tech-correlati__item-meta--card {
	margin-top: 0.1rem;
}

/* Elementi meta singoli */
.bd-tech-meta__data,
.bd-tech-meta__cat,
.bd-tech-meta__autore,
.bd-tech-meta__lettura,
.bd-tech-meta__commenti,
.bd-tech-meta__viste {
	white-space: nowrap;
	font-size: inherit;
}

/* Separatore · tra elementi meta */
.bd-tech-meta__sep {
	margin: 0 0.3rem;
	opacity: 0.5;
	font-size: 0.7rem;
}

.bd-tech-correlati--testo .bd-tech-correlati__leggi {
	font-size: 0.78rem;
	text-decoration: none;
	opacity: 0.55;
	flex-shrink: 0;
	transition: opacity 0.2s;
}
.bd-tech-correlati--testo .bd-tech-correlati__leggi:hover { opacity: 1; }

/* ══════════════════════════════════════════════════════════════════════════════
   LAYOUT: GRIGLIA IMMAGINE (2–4 colonne) — normale
══════════════════════════════════════════════════════════════════════════════ */

.bd-tech-correlati--griglia .bd-tech-correlati__griglia {
	display: grid;
	gap: 1.25rem;
}
.bd-tech-correlati--col-2 .bd-tech-correlati__griglia { grid-template-columns: repeat(2, 1fr); }
.bd-tech-correlati--col-3 .bd-tech-correlati__griglia { grid-template-columns: repeat(3, 1fr); }
.bd-tech-correlati--col-4 .bd-tech-correlati__griglia { grid-template-columns: repeat(4, 1fr); }

/* Card griglia */
.bd-tech-correlati--griglia .bd-tech-correlati__card {
	border-radius: 6px;
	overflow: hidden;
	background: #fff;
	display: flex;
	flex-direction: column;
}
.bd-tech-correlati--griglia.bd-tech-correlati--stile-ombra .bd-tech-correlati__card {
	border: 1px solid rgba(0,0,0,.06);
	box-shadow: 0 2px 8px rgba(0,0,0,.07);
	transition: box-shadow 0.2s, transform 0.2s;
}
.bd-tech-correlati--griglia.bd-tech-correlati--stile-ombra .bd-tech-correlati__card:hover {
	box-shadow: 0 6px 20px rgba(0,0,0,.14);
	transform: translateY(-3px);
}
.bd-tech-correlati--griglia.bd-tech-correlati--stile-bordo .bd-tech-correlati__card {
	border: 1px solid rgba(0,0,0,.15);
	transition: border-color 0.2s;
}
.bd-tech-correlati--griglia.bd-tech-correlati--stile-bordo .bd-tech-correlati__card:hover {
	border-color: rgba(0,0,0,.35);
}
.bd-tech-correlati--griglia.bd-tech-correlati--stile-flat .bd-tech-correlati__card {
	border: none;
	background: transparent;
}
.bd-tech-correlati--griglia .bd-tech-correlati__card-link {
	display: flex;
	flex-direction: column;
	flex: 1;
	text-decoration: none;
	color: inherit;
}
.bd-tech-correlati--griglia .bd-tech-correlati__card-link:hover { color: inherit; text-decoration: none; }

.bd-tech-correlati--griglia .bd-tech-correlati__thumb {
	position: relative;
	width: 100%;
	overflow: hidden;
	background: #f0f0f1;
	flex-shrink: 0;
}
.bd-tech-correlati--griglia.bd-tech-correlati--ar-16-9 .bd-tech-correlati__thumb { aspect-ratio: 16/9; }
.bd-tech-correlati--griglia.bd-tech-correlati--ar-4-3  .bd-tech-correlati__thumb { aspect-ratio: 4/3; }
.bd-tech-correlati--griglia.bd-tech-correlati--ar-1-1  .bd-tech-correlati__thumb { aspect-ratio: 1/1; }

.bd-tech-correlati--griglia .bd-tech-correlati__thumb img {
	width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.3s;
}
.bd-tech-correlati--griglia .bd-tech-correlati__card:hover .bd-tech-correlati__thumb img {
	transform: scale(1.04);
}
.bd-tech-correlati--griglia .bd-tech-correlati__card-body {
	padding: 0.75rem 1rem;
	display: flex; flex-direction: column; gap: 0.25rem; flex: 1;
}

/* ══════════════════════════════════════════════════════════════════════════════
   SCROLL ORIZZONTALE — griglia con snap
   Attivo solo con classe --scroll su wrapper
══════════════════════════════════════════════════════════════════════════════ */

.bd-tech-correlati--scroll .bd-tech-correlati__griglia {
	display: flex !important;
	flex-direction: row !important;
	flex-wrap: nowrap !important;
	overflow-x: auto !important;
	overflow-y: hidden !important;
	scroll-snap-type: x mandatory;
	-webkit-overflow-scrolling: touch;
	gap: 1rem;
	padding-bottom: 0.75rem; /* spazio scrollbar */
	/* nascondi scrollbar visivamente ma mantieni funzionalità */
	scrollbar-width: thin;
	scrollbar-color: rgba(0,0,0,.2) transparent;
}
.bd-tech-correlati--scroll .bd-tech-correlati__griglia::-webkit-scrollbar {
	height: 4px;
}
.bd-tech-correlati--scroll .bd-tech-correlati__griglia::-webkit-scrollbar-track {
	background: transparent;
}
.bd-tech-correlati--scroll .bd-tech-correlati__griglia::-webkit-scrollbar-thumb {
	background: rgba(0,0,0,.2);
	border-radius: 2px;
}

/* Card in scroll: larghezza fissa che dipende dalle colonne scelte
   (colonne = numero di card visibili in contemporanea) */
.bd-tech-correlati--scroll.bd-tech-correlati--col-2 .bd-tech-correlati__card { min-width: calc(50% - 0.5rem); scroll-snap-align: start; }
.bd-tech-correlati--scroll.bd-tech-correlati--col-3 .bd-tech-correlati__card { min-width: calc(33.333% - 0.67rem); scroll-snap-align: start; }
.bd-tech-correlati--scroll.bd-tech-correlati--col-4 .bd-tech-correlati__card { min-width: calc(25% - 0.75rem); scroll-snap-align: start; }

/* Su mobile scroll mostra sempre 1.2 card per far capire che c'è scroll */
@media (max-width: 600px) {
	.bd-tech-correlati--scroll.bd-tech-correlati--col-2 .bd-tech-correlati__card,
	.bd-tech-correlati--scroll.bd-tech-correlati--col-3 .bd-tech-correlati__card,
	.bd-tech-correlati--scroll.bd-tech-correlati--col-4 .bd-tech-correlati__card {
		min-width: 80vw;
		max-width: 280px;
	}
}

/* ══════════════════════════════════════════════════════════════════════════════
   LAYOUT: MEDIA OBJECT — 1 colonna
══════════════════════════════════════════════════════════════════════════════ */

.bd-tech-correlati--media .bd-tech-correlati__media-list {
	display: flex; flex-direction: column; gap: 1rem;
}
.bd-tech-correlati--media .bd-tech-correlati__card {
	border-radius: 6px; overflow: hidden; background: #fff;
}
.bd-tech-correlati--media.bd-tech-correlati--stile-ombra .bd-tech-correlati__card {
	border: 1px solid rgba(0,0,0,.06);
	box-shadow: 0 2px 8px rgba(0,0,0,.07);
	transition: box-shadow 0.2s, transform 0.2s;
}
.bd-tech-correlati--media.bd-tech-correlati--stile-ombra .bd-tech-correlati__card:hover {
	box-shadow: 0 4px 16px rgba(0,0,0,.12);
	transform: translateY(-2px);
}
.bd-tech-correlati--media.bd-tech-correlati--stile-bordo .bd-tech-correlati__card {
	border: 1px solid rgba(0,0,0,.15); transition: border-color 0.2s;
}
.bd-tech-correlati--media.bd-tech-correlati--stile-bordo .bd-tech-correlati__card:hover {
	border-color: rgba(0,0,0,.35);
}
.bd-tech-correlati--media.bd-tech-correlati--stile-flat .bd-tech-correlati__card {
	border: none; background: transparent;
}
.bd-tech-correlati--media .bd-tech-correlati__card-link {
	display: flex !important;
	flex-direction: row !important;
	align-items: stretch;
	text-decoration: none; color: inherit; min-height: 80px;
}
.bd-tech-correlati--media .bd-tech-correlati__card-link:hover { color: inherit; text-decoration: none; }

.bd-tech-correlati--media .bd-tech-correlati__thumb {
	position: relative; flex-shrink: 0; overflow: hidden;
	background: #f0f0f1; align-self: stretch;
}
.bd-tech-correlati--media.bd-tech-correlati--dim-piccola .bd-tech-correlati__thumb { width: 100px; min-width: 100px; }
.bd-tech-correlati--media.bd-tech-correlati--dim-media   .bd-tech-correlati__thumb { width: 160px; min-width: 160px; }
.bd-tech-correlati--media.bd-tech-correlati--dim-grande  .bd-tech-correlati__thumb { width: 240px; min-width: 240px; }

.bd-tech-correlati--media .bd-tech-correlati__thumb img {
	width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.3s;
}
.bd-tech-correlati--media .bd-tech-correlati__card:hover .bd-tech-correlati__thumb img { transform: scale(1.05); }
.bd-tech-correlati--media .bd-tech-correlati__thumb-placeholder {
	width: 100%; height: 100%; min-height: 80px; background: #e8e8e8;
}
.bd-tech-correlati--media .bd-tech-correlati__card-body {
	padding: 0.75rem 1rem;
	display: flex; flex-direction: column; gap: 0.25rem;
	justify-content: center; flex: 1; min-width: 0;
}
.bd-tech-correlati--media .bd-tech-correlati__card-titolo {
	font-size: 1rem; font-weight: 600; margin: 0; line-height: 1.4;
	display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* ── Elementi comuni griglia + media ─────────────────────────────────────────*/

.bd-tech-correlati__badge {
	position: absolute; top: 0.5rem; left: 0.5rem; z-index: 2;
	background: rgba(0,0,0,.55); color: #fff;
	font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
	padding: 0.2rem 0.5rem; border-radius: 3px; pointer-events: none;
}
.bd-tech-correlati__card-data { font-size: 0.75rem; opacity: 0.5; }
.bd-tech-correlati__card-titolo {
	font-size: 0.95rem; font-weight: 600; margin: 0; line-height: 1.4;
	display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.bd-tech-correlati__excerpt {
	font-size: 0.82rem; color: #666; margin: 0; line-height: 1.5;
	display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.bd-tech-correlati__card-body .bd-tech-correlati__leggi {
	font-size: 0.8rem; font-weight: 600; opacity: 0.65;
	margin-top: auto; padding-top: 0.3rem; pointer-events: none;
}
.bd-tech-correlati__thumb-placeholder {
	width: 100%; height: 100%; background: #e8e8e8; min-height: 120px;
}

/* ══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE — griglia normale (non scroll)
══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
	.bd-tech-correlati--griglia:not(.bd-tech-correlati--scroll).bd-tech-correlati--col-4 .bd-tech-correlati__griglia { grid-template-columns: repeat(2, 1fr); }
	.bd-tech-correlati--griglia:not(.bd-tech-correlati--scroll).bd-tech-correlati--col-3 .bd-tech-correlati__griglia { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
	.bd-tech-correlati--griglia:not(.bd-tech-correlati--scroll).bd-tech-correlati--col-2 .bd-tech-correlati__griglia,
	.bd-tech-correlati--griglia:not(.bd-tech-correlati--scroll).bd-tech-correlati--col-3 .bd-tech-correlati__griglia,
	.bd-tech-correlati--griglia:not(.bd-tech-correlati--scroll).bd-tech-correlati--col-4 .bd-tech-correlati__griglia {
		grid-template-columns: 1fr;
	}
	/* Media object → verticale su mobile */
	.bd-tech-correlati--media .bd-tech-correlati__card-link { flex-direction: column !important; }
	.bd-tech-correlati--media .bd-tech-correlati__thumb {
		width: 100% !important; min-width: 0 !important; aspect-ratio: 16/9;
	}
}

/* ══════════════════════════════════════════════════════════════════════════════
   DARK MODE — Blocksy .custom-dark
══════════════════════════════════════════════════════════════════════════════ */

.custom-dark .bd-tech-correlati--griglia .bd-tech-correlati__card,
.custom-dark .bd-tech-correlati--media .bd-tech-correlati__card {
	background: #1e1e1e;
	border-color: rgba(255,255,255,.08);
}
.custom-dark .bd-tech-correlati--stile-ombra .bd-tech-correlati__card { box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.custom-dark .bd-tech-correlati__excerpt   { color: #aaa; }
.custom-dark .bd-tech-correlati__card-data { color: #888; }
.custom-dark .bd-tech-correlati__thumb-placeholder { background: #2a2a2a; }
.custom-dark .bd-tech-correlati__lista--sep-linea .bd-tech-correlati__item { border-color: rgba(255,255,255,.08); }
.custom-dark .bd-tech-correlati--scroll .bd-tech-correlati__griglia {
	scrollbar-color: rgba(255,255,255,.2) transparent;
}

/* ── Editor ──────────────────────────────────────────────────────────────────*/
.bd-tech-correlati-editor-wrap { min-height: 80px; }
