/* =========================================================================
   Publisher Box - 10 stili x 2 formati x 3 dimensioni
   ========================================================================= */

.pbx {
	--pbx-cols: 3;
	--pbx-gap: 14px;
	--pbx-pad: 12px;
	--pbx-radius: 12px;
	--pbx-title: 15px;
	--pbx-desc: 12.5px;
	--pbx-img: 170px;
	--pbx-icon: 40px;
	--pbx-btn: 11px;

	--pbx-bg: #fff;
	--pbx-fg: #15181d;
	--pbx-muted: #6b7280;
	--pbx-border: rgba(0, 0, 0, .12);
	--pbx-soft: #f4f5f7;
	--pbx-accent: #2563eb;
	--pbx-accent-fg: #fff;
	--pbx-shadow: 0 1px 2px rgba(0, 0, 0, .06);
	--pbx-shadow-lg: 0 10px 28px rgba(0, 0, 0, .14);

	color: var(--pbx-fg);
	box-sizing: border-box;
}

.pbx *,
.pbx *::before,
.pbx *::after {
	box-sizing: inherit;
}

/* --- Dimensioni --------------------------------------------------------- */

.pbx-size-sm {
	--pbx-title: 13px;
	--pbx-desc: 11.5px;
	--pbx-pad: 9px;
	--pbx-img: 120px;
	--pbx-icon: 30px;
	--pbx-gap: 10px;
	--pbx-btn: 10px;
	--pbx-radius: 10px;
}

.pbx-size-lg {
	--pbx-title: 19px;
	--pbx-desc: 14px;
	--pbx-pad: 16px;
	--pbx-img: 230px;
	--pbx-icon: 54px;
	--pbx-gap: 20px;
	--pbx-btn: 12px;
	--pbx-radius: 16px;
}

/* --- Formati ------------------------------------------------------------ */

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

.pbx-layout-list {
	display: flex;
	flex-direction: column;
	gap: var(--pbx-gap);
}

/* --- Elementi comuni ---------------------------------------------------- */

.pbx-item {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 0;
	min-width: 0;
	background: var(--pbx-bg);
}

.pbx-layout-list .pbx-item {
	flex-direction: row;
	align-items: stretch;
}

.pbx-media {
	position: relative;
	display: block;
	overflow: hidden;
	background: var(--pbx-soft);
	flex-shrink: 0;
}

.pbx-media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform .4s ease;
}

.pbx-ph {
	position: absolute;
	inset: 0;
	background: linear-gradient(135deg, hsl(var(--pbx-hue, 215) 70% 62%), hsl(calc(var(--pbx-hue, 215) + 40) 65% 45%));
}

.pbx-icon {
	width: var(--pbx-icon);
	height: var(--pbx-icon);
	border-radius: 50%;
	background: hsl(var(--pbx-hue, 215) 62% 45%);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	font-size: calc(var(--pbx-icon) * .42);
	line-height: 1;
	flex-shrink: 0;
}

.pbx-body {
	flex: 1;
	min-width: 0;
	padding: var(--pbx-pad);
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.pbx-title {
	font-size: var(--pbx-title);
	font-weight: 650;
	line-height: 1.3;
	margin: 0;
}

.pbx-title a {
	color: inherit;
	text-decoration: none;
}

.pbx-title a::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

.pbx-item:hover .pbx-title a {
	text-decoration: underline;
}

.pbx-title a:focus-visible::after {
	outline: 2px solid var(--pbx-accent);
	outline-offset: 3px;
	border-radius: var(--pbx-radius);
}

.pbx-desc {
	font-size: var(--pbx-desc);
	line-height: 1.5;
	color: var(--pbx-muted);
	margin: 0;
}

.pbx-meta {
	font-size: calc(var(--pbx-desc) * .92);
	color: var(--pbx-muted);
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.pbx-btn {
	align-self: flex-start;
	margin-top: auto;
	font-size: var(--pbx-btn);
	font-weight: 650;
	letter-spacing: .04em;
	text-transform: uppercase;
	padding: .5em 1em;
	border-radius: 999px;
	background: var(--pbx-accent);
	color: var(--pbx-accent-fg);
	text-decoration: none;
	pointer-events: none;
	white-space: nowrap;
}

/* =========================================================================
   1. PIASTRELLA
   ========================================================================= */

.pbx-style-tile .pbx-item {
	border: 1px solid var(--pbx-border);
	border-radius: var(--pbx-radius);
	box-shadow: var(--pbx-shadow);
	overflow: hidden;
	transition: transform .25s ease, box-shadow .25s ease;
}

.pbx-style-tile .pbx-item:hover {
	transform: translateY(-3px);
	box-shadow: var(--pbx-shadow-lg);
}

.pbx-style-tile .pbx-media {
	aspect-ratio: 4 / 3;
}

.pbx-style-tile .pbx-item:hover .pbx-media img {
	transform: scale(1.06);
}

.pbx-style-tile .pbx-body .pbx-icon {
	margin-bottom: 2px;
}

.pbx-layout-list.pbx-style-tile .pbx-media {
	width: calc(var(--pbx-img) * .8);
	aspect-ratio: auto;
}

/* =========================================================================
   2. CAPSULA
   ========================================================================= */

.pbx-style-capsule .pbx-item {
	flex-direction: row;
	align-items: center;
	gap: 10px;
	padding: calc(var(--pbx-pad) * .55) calc(var(--pbx-pad) * 1.1);
	border: 1px solid var(--pbx-border);
	border-radius: 999px;
	background: var(--pbx-soft);
	transition: background .2s ease, border-color .2s ease;
}

.pbx-style-capsule .pbx-item:hover {
	background: var(--pbx-bg);
	border-color: var(--pbx-accent);
}

.pbx-style-capsule .pbx-media {
	width: var(--pbx-icon);
	height: var(--pbx-icon);
	border-radius: 50%;
	aspect-ratio: 1;
}

.pbx-style-capsule .pbx-body {
	padding: 0;
	gap: 2px;
}

.pbx-style-capsule .pbx-title {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.pbx-style-capsule .pbx-desc {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.pbx-style-capsule .pbx-btn {
	margin: 0;
	padding: .35em .9em;
}

/* =========================================================================
   3. FOGLIO XLS
   ========================================================================= */

.pbx-style-xls {
	display: block;
	border: 1px solid #b7c0c9;
	border-radius: 4px;
	overflow: hidden;
	font-family: "Segoe UI", Calibri, system-ui, sans-serif;
	counter-reset: pbxrow;
	background: #fff;
}

.pbx-style-xls .pbx-xls-head,
.pbx-style-xls .pbx-item {
	display: grid;
	grid-template-columns: 38px minmax(0, 1fr) 130px 110px;
	align-items: center;
	border-bottom: 1px solid #d7dde3;
}

.pbx-style-xls .pbx-xls-head {
	background: #217346;
	color: #fff;
	font-size: calc(var(--pbx-desc) * .95);
	font-weight: 650;
	text-transform: uppercase;
	letter-spacing: .04em;
	border-bottom: 2px solid #185c38;
}

.pbx-style-xls .pbx-xls-head span,
.pbx-style-xls .pbx-cell {
	padding: calc(var(--pbx-pad) * .55) calc(var(--pbx-pad) * .7);
	border-right: 1px solid rgba(0, 0, 0, .1);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.pbx-style-xls .pbx-item {
	background: #fff;
	counter-increment: pbxrow;
	border-radius: 0;
}

.pbx-style-xls .pbx-item:nth-child(even) {
	background: #f2f7f4;
}

.pbx-style-xls .pbx-item:hover {
	background: #e3f0e9;
}

.pbx-style-xls .pbx-item::before {
	content: counter(pbxrow);
	padding: calc(var(--pbx-pad) * .55) 0;
	text-align: center;
	font-size: calc(var(--pbx-desc) * .9);
	color: #5b6670;
	background: #eef1f4;
	border-right: 1px solid #d7dde3;
	align-self: stretch;
	display: flex;
	align-items: center;
	justify-content: center;
}

.pbx-style-xls .pbx-media,
.pbx-style-xls .pbx-desc {
	display: none;
}

.pbx-style-xls .pbx-body {
	display: contents;
}

.pbx-style-xls .pbx-title {
	font-size: var(--pbx-desc);
	font-weight: 500;
	order: 1;
}

.pbx-style-xls .pbx-meta {
	order: 2;
}

.pbx-style-xls .pbx-btn-cell {
	order: 3;
}

.pbx-style-xls .pbx-title,
.pbx-style-xls .pbx-meta,
.pbx-style-xls .pbx-btn-cell {
	padding: calc(var(--pbx-pad) * .55) calc(var(--pbx-pad) * .7);
	border-right: 1px solid rgba(0, 0, 0, .06);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.pbx-style-xls .pbx-btn {
	margin: 0;
	padding: .3em .8em;
	border-radius: 3px;
	background: #217346;
	text-transform: none;
	letter-spacing: 0;
}

.pbx-style-xls .pbx-icon {
	display: none;
}

/* =========================================================================
   4. CARD
   ========================================================================= */

.pbx-style-card .pbx-item {
	border-radius: var(--pbx-radius);
	background: var(--pbx-bg);
	box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
	overflow: hidden;
	transition: box-shadow .25s ease, transform .25s ease;
}

.pbx-style-card .pbx-item:hover {
	box-shadow: var(--pbx-shadow-lg);
	transform: translateY(-2px);
}

.pbx-style-card .pbx-media {
	aspect-ratio: 16 / 9;
}

.pbx-style-card .pbx-body {
	padding: calc(var(--pbx-pad) * 1.1);
	gap: 8px;
}

.pbx-style-card .pbx-btn {
	border-radius: 6px;
}

.pbx-layout-list.pbx-style-card .pbx-media {
	width: var(--pbx-img);
	aspect-ratio: auto;
}

/* =========================================================================
   5. MAGAZINE
   ========================================================================= */

.pbx-style-magazine .pbx-item {
	gap: 0;
	background: transparent;
	border-bottom: 1px solid var(--pbx-border);
	padding-bottom: var(--pbx-pad);
}

.pbx-style-magazine .pbx-media {
	aspect-ratio: 3 / 2;
	border-radius: 2px;
}

.pbx-layout-list.pbx-style-magazine .pbx-item {
	gap: var(--pbx-gap);
	align-items: flex-start;
}

.pbx-layout-list.pbx-style-magazine .pbx-media {
	width: min(38%, calc(var(--pbx-img) * 1.4));
	aspect-ratio: 3 / 2;
}

.pbx-style-magazine .pbx-body {
	padding: var(--pbx-pad) 0 0;
	gap: 8px;
}

.pbx-style-magazine .pbx-title {
	font-family: Georgia, "Times New Roman", serif;
	font-size: calc(var(--pbx-title) * 1.15);
	font-weight: 700;
	letter-spacing: -.01em;
}

.pbx-style-magazine .pbx-meta {
	order: -1;
	text-transform: uppercase;
	letter-spacing: .08em;
	font-size: calc(var(--pbx-desc) * .82);
	color: var(--pbx-accent);
	font-weight: 700;
}

.pbx-style-magazine .pbx-btn {
	background: transparent;
	color: var(--pbx-accent);
	padding: 0;
	border-radius: 0;
	border-bottom: 2px solid currentColor;
	text-transform: none;
	letter-spacing: 0;
}

/* =========================================================================
   6. MINIMAL
   ========================================================================= */

.pbx-style-minimal .pbx-item {
	background: transparent;
	padding: calc(var(--pbx-pad) * .4) 0;
	border-bottom: 1px solid var(--pbx-border);
	align-items: center;
	flex-direction: row;
	gap: 10px;
}

.pbx-style-minimal .pbx-media {
	width: calc(var(--pbx-icon) * .95);
	height: calc(var(--pbx-icon) * .95);
	border-radius: 6px;
	aspect-ratio: 1;
}

.pbx-style-minimal .pbx-body {
	padding: 0;
	gap: 2px;
}

.pbx-style-minimal .pbx-title {
	font-weight: 550;
}

.pbx-style-minimal .pbx-desc {
	display: -webkit-box;
	-webkit-line-clamp: 1;
	line-clamp: 1;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.pbx-style-minimal .pbx-btn {
	background: transparent;
	color: var(--pbx-muted);
	padding: 0;
	font-size: calc(var(--pbx-btn) * 1.6);
	text-transform: none;
	margin: 0;
}

.pbx-style-minimal .pbx-item:hover .pbx-btn {
	color: var(--pbx-accent);
}

/* =========================================================================
   7. TIMELINE
   ========================================================================= */

.pbx-style-timeline {
	position: relative;
}

.pbx-style-timeline .pbx-item {
	flex-direction: row;
	align-items: flex-start;
	gap: var(--pbx-gap);
	padding-left: 26px;
	padding-bottom: var(--pbx-pad);
	background: transparent;
	border-left: 2px solid var(--pbx-border);
	margin-left: 6px;
}

.pbx-style-timeline .pbx-item::before {
	content: "";
	position: absolute;
	left: -7px;
	top: 4px;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: var(--pbx-accent);
	box-shadow: 0 0 0 3px var(--pbx-bg);
}

.pbx-style-timeline .pbx-media {
	width: calc(var(--pbx-img) * .5);
	aspect-ratio: 1;
	border-radius: 8px;
}

.pbx-style-timeline .pbx-body {
	padding: 0;
}

.pbx-style-timeline .pbx-meta {
	order: -1;
	font-weight: 650;
	color: var(--pbx-accent);
}

.pbx-style-timeline .pbx-btn {
	background: transparent;
	color: var(--pbx-accent);
	border: 1px solid currentColor;
	padding: .3em .8em;
}

.pbx-layout-grid.pbx-style-timeline .pbx-item {
	flex-direction: column;
}

/* =========================================================================
   8. POLAROID
   ========================================================================= */

.pbx-style-polaroid .pbx-item {
	background: #fff;
	padding: 10px 10px 0;
	border-radius: 2px;
	box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
	transition: transform .25s ease, box-shadow .25s ease;
	color: #15181d;
}

.pbx-style-polaroid .pbx-item:nth-child(odd) {
	transform: rotate(-1.2deg);
}

.pbx-style-polaroid .pbx-item:nth-child(even) {
	transform: rotate(1deg);
}

.pbx-style-polaroid .pbx-item:hover {
	transform: rotate(0deg) translateY(-3px);
	box-shadow: 0 12px 28px rgba(0, 0, 0, .26);
}

.pbx-style-polaroid .pbx-media {
	aspect-ratio: 1;
	border-radius: 0;
}

.pbx-style-polaroid .pbx-body {
	padding: 10px 2px 14px;
	text-align: center;
	align-items: center;
}

.pbx-style-polaroid .pbx-title {
	font-family: "Bradley Hand", "Segoe Script", "Comic Sans MS", cursive;
	font-weight: 700;
}

.pbx-style-polaroid .pbx-btn {
	align-self: center;
	background: #15181d;
	color: #fff;
}

.pbx-layout-list.pbx-style-polaroid .pbx-item {
	align-items: center;
	padding: 10px;
}

.pbx-layout-list.pbx-style-polaroid .pbx-media {
	width: var(--pbx-icon);
	height: var(--pbx-icon);
	aspect-ratio: 1;
}

/* =========================================================================
   9. NEON (vetro scuro)
   ========================================================================= */

.pbx-style-neon {
	--pbx-fg: #f4f7fb;
	--pbx-muted: #a9b6c9;
	--pbx-accent: #22d3ee;
	--pbx-accent-fg: #04212a;
}

.pbx-style-neon .pbx-item {
	background: linear-gradient(160deg, rgba(30, 41, 59, .92), rgba(15, 23, 42, .92));
	border: 1px solid rgba(148, 197, 255, .22);
	border-radius: var(--pbx-radius);
	overflow: hidden;
	color: var(--pbx-fg);
	box-shadow: 0 0 0 1px rgba(34, 211, 238, .06), 0 10px 30px rgba(2, 8, 23, .45);
	transition: box-shadow .3s ease, transform .3s ease, border-color .3s ease;
}

.pbx-style-neon .pbx-item:hover {
	transform: translateY(-3px);
	border-color: rgba(34, 211, 238, .55);
	box-shadow: 0 0 22px rgba(34, 211, 238, .28), 0 14px 34px rgba(2, 8, 23, .6);
}

.pbx-style-neon .pbx-media {
	aspect-ratio: 16 / 9;
	background: #0b1220;
}

.pbx-style-neon .pbx-icon {
	background: linear-gradient(135deg, #22d3ee, #6366f1);
	border-radius: 10px;
}

.pbx-style-neon .pbx-btn {
	background: linear-gradient(135deg, #22d3ee, #6366f1);
	color: #04212a;
	border-radius: 8px;
}

.pbx-layout-list.pbx-style-neon .pbx-media {
	width: var(--pbx-img);
	aspect-ratio: auto;
}

/* =========================================================================
   10. BIGLIETTO
   ========================================================================= */

.pbx-style-ticket .pbx-item {
	flex-direction: row;
	align-items: stretch;
	background: var(--pbx-bg);
	border: 1px dashed var(--pbx-border);
	border-radius: var(--pbx-radius);
	overflow: hidden;
	box-shadow: var(--pbx-shadow);
}

.pbx-style-ticket .pbx-item::before,
.pbx-style-ticket .pbx-item::after {
	content: "";
	position: absolute;
	left: calc(var(--pbx-icon) + var(--pbx-pad) * 1.2);
	width: 14px;
	height: 7px;
	background: var(--pbx-soft);
	border: 1px solid var(--pbx-border);
	z-index: 2;
}

.pbx-style-ticket .pbx-item::before {
	top: -1px;
	border-radius: 0 0 14px 14px;
	border-top: 0;
}

.pbx-style-ticket .pbx-item::after {
	bottom: -1px;
	border-radius: 14px 14px 0 0;
	border-bottom: 0;
}

.pbx-style-ticket .pbx-stub {
	width: calc(var(--pbx-icon) + var(--pbx-pad) * 1.2);
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--pbx-soft);
	border-right: 2px dashed var(--pbx-border);
	flex-shrink: 0;
}

.pbx-style-ticket .pbx-media {
	display: none;
}

.pbx-style-ticket .pbx-body {
	padding: var(--pbx-pad) calc(var(--pbx-pad) * 1.2);
}

.pbx-style-ticket .pbx-title {
	text-transform: uppercase;
	letter-spacing: .02em;
	font-weight: 700;
}

.pbx-style-ticket .pbx-meta {
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	letter-spacing: .06em;
}

.pbx-style-ticket .pbx-btn {
	border-radius: 4px;
}

/* =========================================================================
   Responsive
   ========================================================================= */

@media (max-width: 860px) {
	.pbx-layout-grid {
		grid-template-columns: repeat(min(var(--pbx-cols), 2), minmax(0, 1fr));
	}

	.pbx-style-xls .pbx-xls-head,
	.pbx-style-xls .pbx-item {
		grid-template-columns: 30px minmax(0, 1fr) 92px;
	}

	.pbx-style-xls .pbx-xls-head span:nth-child(4),
	.pbx-style-xls .pbx-btn-cell {
		display: none;
	}
}

@media (max-width: 560px) {
	.pbx-layout-grid {
		grid-template-columns: 1fr;
	}

	.pbx-layout-list .pbx-item {
		flex-direction: column;
	}

	.pbx-layout-list.pbx-style-capsule .pbx-item,
	.pbx-layout-list.pbx-style-minimal .pbx-item,
	.pbx-layout-list.pbx-style-ticket .pbx-item,
	.pbx-layout-list.pbx-style-timeline .pbx-item {
		flex-direction: row;
	}

	.pbx-layout-list .pbx-media {
		width: 100% !important;
	}

	.pbx-layout-list.pbx-style-capsule .pbx-media,
	.pbx-layout-list.pbx-style-minimal .pbx-media,
	.pbx-layout-list.pbx-style-polaroid .pbx-media {
		width: var(--pbx-icon) !important;
	}

	.pbx-style-xls .pbx-xls-head,
	.pbx-style-xls .pbx-item {
		grid-template-columns: 26px minmax(0, 1fr);
	}

	.pbx-style-xls .pbx-xls-head span:nth-child(3),
	.pbx-style-xls .pbx-meta {
		display: none;
	}
}

/* =========================================================================
   Tema scuro del browser (gli stili neon e polaroid restano come sono)
   ========================================================================= */

@media (prefers-color-scheme: dark) {
	.pbx:not(.pbx-style-neon):not(.pbx-style-xls) {
		--pbx-bg: #1b1e24;
		--pbx-fg: #f0f2f5;
		--pbx-muted: #a8b0bb;
		--pbx-border: rgba(255, 255, 255, .14);
		--pbx-soft: #23272e;
		--pbx-accent: #60a5fa;
		--pbx-accent-fg: #08182f;
		--pbx-shadow-lg: 0 10px 28px rgba(0, 0, 0, .5);
	}

	.pbx-style-polaroid .pbx-item {
		background: #f7f7f5;
	}
}

@media (prefers-reduced-motion: reduce) {
	.pbx-item,
	.pbx-media img {
		transition: none !important;
	}

	.pbx-item:hover {
		transform: none !important;
	}
}
