/*
 * Single Normativa (Legislation) Template
 * Two-column layout: metadata sidebar + content area
 */

/* ── Local Variables ─────────────────────────────── */
:root {
	--norm-text: #2c2c2c;
	--norm-text-secondary: #5a5a5a;
	--norm-radius: 16px;
}

/* ── Base ─────────────────────────────────────────── */
.normativa-page {
	box-sizing: border-box;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	overflow-x: hidden;
	background: var(--ali-cream, #faf9f7);
}

.normativa-page *,
.normativa-page *::before,
.normativa-page *::after {
	box-sizing: border-box;
}

/* ── Animations ──────────────────────────────────── */
@keyframes normFadeInUp {
	from {
		opacity: 0;
		transform: translateY(32px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ── Hero ─────────────────────────────────────────── */
.normativa-hero {
	background: var(--ali-cream, #faf9f7);
	text-align: center;
	padding: 120px 24px 64px;
	position: relative;
	overflow: hidden;
}

.normativa-hero::before {
	content: "";
	position: absolute;
	inset: 0;
	background: radial-gradient(ellipse at 50% 30%, rgba(61, 170, 189, .08) 0%, transparent 70%);
	pointer-events: none;
}

.normativa-hero::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 420px;
	height: 420px;
	pointer-events: none;
	opacity: .6;
	background: no-repeat center / contain;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' fill='none' stroke='rgba(26,35,50,0.05)' stroke-width='0.6'%3E%3Crect x='20' y='10' width='60' height='80' rx='3'/%3E%3Cline x1='30' y1='25' x2='70' y2='25'/%3E%3Cline x1='30' y1='35' x2='70' y2='35'/%3E%3Cline x1='30' y1='45' x2='70' y2='45'/%3E%3Cline x1='30' y1='55' x2='55' y2='55'/%3E%3Cline x1='30' y1='65' x2='65' y2='65'/%3E%3Cline x1='30' y1='75' x2='50' y2='75'/%3E%3C/svg%3E");
}

.normativa-hero-content {
	position: relative;
	z-index: 2;
	max-width: 800px;
	margin: 0 auto;
}

/* ── Back link ───────────────────────────────────── */
.normativa-back {
	display: block;
	color: var(--norm-text-secondary);
	font-size: .85rem;
	font-weight: 600;
	text-decoration: none;
	margin-bottom: 28px;
	transition: color .25s ease;
	text-align: left;
}

.normativa-back:hover {
	color: var(--ali-teal);
}

/* ── Hero materia icon ───────────────────────────── */
.normativa-hero-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	border-radius: 14px;
	background: color-mix(in srgb, var(--materia-color, var(--ali-teal)) 10%, var(--ali-cream, #faf9f7));
	color: var(--materia-color, var(--ali-teal));
	margin: 0 auto 20px;
	animation: normFadeInUp .8s ease both;
}

.normativa-hero-icon svg {
	width: 28px;
	height: 28px;
}

/* ── Hero label ──────────────────────────────────── */
.normativa-hero-label {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	text-transform: uppercase;
	font-size: .75rem;
	font-weight: 700;
	letter-spacing: .12em;
	color: var(--ali-teal);
	margin-bottom: 16px;
}

.normativa-hero-label::before {
	content: "";
	display: inline-block;
	width: 28px;
	height: 2px;
	background: var(--ali-teal);
}

/* ── Hero heading ────────────────────────────────── */
.normativa-hero h1 {
	font-family: 'DM Serif Display', serif;
	color: var(--ali-navy, #1a2332);
	font-size: clamp(2rem, 5vw, 3.2rem);
	line-height: 1.15;
	margin: 0;
	animation: normFadeInUp .8s ease both;
}

/* ── Hero reference ──────────────────────────────── */
.normativa-hero-ref {
	font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
	color: var(--ali-teal);
	font-size: 1.1rem;
	margin-top: 12px;
	animation: normFadeInUp .8s ease .15s both;
}

/* ── Hero badges ─────────────────────────────────── */
.normativa-hero-badges {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 10px;
	margin-top: 16px;
	animation: normFadeInUp .8s ease .25s both;
}

.normativa-hero-badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 14px;
	border-radius: 20px;
	font-size: .78rem;
	font-weight: 600;
	color: var(--norm-text-secondary);
	background: rgba(26, 35, 50, .06);
}

.normativa-hero-badge--vigore {
	background: rgba(61, 170, 189, .12);
	color: #2B8A9A;
}

.normativa-hero-badge--proposta {
	background: rgba(139, 92, 246, .1);
	color: #7c3aed;
}

.normativa-hero-badge--abrogata {
	background: rgba(160, 160, 160, .15);
	color: #777;
}

.normativa-hero-badge--modificata {
	background: rgba(232, 168, 23, .12);
	color: #b8860b;
}

.normativa-hero-badge-dot {
	display: inline-block;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: currentColor;
}

.normativa-hero-badge--vigore .normativa-hero-badge-dot {
	background: var(--ali-teal);
}

.normativa-hero-badge--proposta .normativa-hero-badge-dot {
	background: #8b5cf6;
}

.normativa-hero-badge--abrogata .normativa-hero-badge-dot {
	background: #999;
}

.normativa-hero-badge--modificata .normativa-hero-badge-dot {
	background: #E8A817;
}

.normativa-hero-badge--landmark {
	background: rgba(232, 168, 23, .12);
	color: #b8860b;
}

/* ── Two-column content ──────────────────────────── */
.normativa-content {
	max-width: 1140px;
	margin: 0 auto;
	padding: 64px 24px;
	display: grid;
	grid-template-columns: 280px 1fr;
	gap: 48px;
	background: #fff;
	border-radius: 20px 20px 0 0;
	margin-top: -24px;
	position: relative;
	z-index: 1;
	box-shadow: 0 -4px 32px rgba(26, 35, 50, .04);
}

/* ── Sidebar ─────────────────────────────────────── */
.normativa-sidebar {
	position: sticky;
	top: 100px;
	align-self: start;
}

.normativa-sidebar__section {
	margin-bottom: 28px;
}

.normativa-sidebar__heading {
	text-transform: uppercase;
	font-size: .7rem;
	font-weight: 700;
	letter-spacing: .1em;
	color: var(--ali-teal);
	margin: 0 0 12px;
}

.normativa-sidebar__item {
	display: flex;
	flex-direction: column;
	margin-bottom: 16px;
}

.normativa-sidebar__label {
	text-transform: uppercase;
	font-size: .68rem;
	font-weight: 700;
	letter-spacing: .06em;
	color: var(--norm-text-secondary);
	margin-bottom: 2px;
}

.normativa-sidebar__value {
	font-size: .95rem;
	color: var(--ali-navy);
	line-height: 1.5;
}

.normativa-sidebar__links {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.normativa-sidebar__link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 16px;
	border: 1.5px solid var(--ali-teal);
	border-radius: 24px;
	color: var(--ali-teal);
	font-size: .85rem;
	font-weight: 600;
	text-decoration: none;
	transition: background .25s ease, color .25s ease;
}

.normativa-sidebar__link:hover {
	background: var(--ali-teal);
	color: #fff;
}

.normativa-sidebar__link span {
	transition: transform .25s ease;
}
.normativa-sidebar__link:hover span {
	transform: translateX(3px);
}

/* ── Related normative sidebar ───────────────────── */
.normativa-sidebar__related {
	list-style: none;
	margin: 0;
	padding: 0;
}

.normativa-sidebar__related-item {
	display: block;
	padding: 10px 0;
	border-bottom: 1px solid #eee;
	text-decoration: none;
	color: var(--norm-text);
	font-size: .88rem;
	line-height: 1.45;
	transition: background .2s ease, padding-left .2s ease;
}

.normativa-sidebar__related-item:hover {
	background: var(--ali-cream);
	padding-left: 8px;
}

.normativa-sidebar__related-item:last-child {
	border-bottom: none;
}

.normativa-sidebar__related-label {
	display: block;
	font-family: 'Karla', sans-serif;
	font-size: .65rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .08em;
	color: var(--ali-teal);
	margin: 12px 0 4px;
}

.normativa-sidebar__related-label:first-child {
	margin-top: 0;
}

/* ── Content body ────────────────────────────────── */
.normativa-body {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

/* ── Riassunto block ─────────────────────────────── */
.normativa-riassunto {
	background: var(--ali-cream, #faf9f7);
	border-left: 4px solid var(--ali-teal);
	padding: 24px 28px;
	border-radius: 0 var(--norm-radius) var(--norm-radius) 0;
	margin-bottom: 36px;
	font-size: 1.05rem;
	line-height: 1.8;
	color: var(--norm-text);
}

/* ── Punti chiave ────────────────────────────────── */
.normativa-punti {
	margin-bottom: 36px;
}

.normativa-punti h3 {
	font-family: 'DM Serif Display', serif;
	color: var(--ali-navy);
	font-size: 1.4rem;
	margin: 0 0 16px;
}

.normativa-punti ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.normativa-punti li {
	position: relative;
	padding-left: 28px;
	margin-bottom: 12px;
	line-height: 1.7;
	color: var(--norm-text);
}

.normativa-punti li::before {
	content: "";
	position: absolute;
	left: 0;
	top: 5px;
	width: 16px;
	height: 16px;
	background: var(--ali-teal);
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z'/%3E%3C/svg%3E");
	-webkit-mask-size: contain;
	-webkit-mask-repeat: no-repeat;
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z'/%3E%3C/svg%3E");
	mask-size: contain;
	mask-repeat: no-repeat;
}

/* ── Table of Contents ───────────────────────────── */
.normativa-toc {
	background: var(--ali-cream);
	border-radius: var(--norm-radius);
	padding: 24px 28px;
	margin-bottom: 36px;
}

.normativa-toc__toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	background: none;
	border: none;
	cursor: pointer;
	padding: 0;
}

.normativa-toc__title {
	font-family: 'DM Serif Display', serif;
	font-size: 1.25rem;
	color: var(--ali-navy);
}

.normativa-toc__icon {
	width: 20px;
	height: 20px;
	background: var(--norm-text-secondary);
	transition: transform .3s ease;
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6z'/%3E%3C/svg%3E");
	-webkit-mask-size: contain;
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6z'/%3E%3C/svg%3E");
	mask-size: contain;
}

.normativa-toc__toggle[aria-expanded="false"] .normativa-toc__icon {
	transform: rotate(-90deg);
}

.normativa-toc__list {
	list-style: none;
	margin: 16px 0 0;
	padding: 0;
	border-top: 1px solid rgba(0, 0, 0, .08);
	padding-top: 16px;
}

.normativa-toc__toggle[aria-expanded="false"] + .normativa-toc__list {
	display: none;
}

.normativa-toc__item {
	margin-bottom: 6px;
}

.normativa-toc__item a {
	display: block;
	padding: 5px 0;
	color: var(--norm-text);
	text-decoration: none;
	font-size: .92rem;
	line-height: 1.45;
	transition: color .2s ease;
}

.normativa-toc__item a:hover {
	color: var(--ali-teal);
}

.normativa-toc__item--l2 {
	padding-left: 0;
}

.normativa-toc__item--l2 a {
	font-weight: 600;
}

.normativa-toc__item--l3 {
	padding-left: 20px;
}

.normativa-toc__item--l4 {
	padding-left: 40px;
	font-size: .88rem;
}

/* Scroll-margin for anchor links (clear sticky header) */
.normativa-analisi h2[id],
.normativa-analisi h3[id],
.normativa-analisi h4[id] {
	scroll-margin-top: 100px;
}

/* ── Analisi (WYSIWYG) ───────────────────────────── */
.normativa-analisi h2,
.normativa-analisi h3,
.normativa-analisi h4 {
	font-family: 'DM Serif Display', serif;
	color: var(--ali-navy);
	line-height: 1.25;
}

.normativa-analisi h2 {
	font-size: 1.5rem;
	margin: 2rem 0 .8rem;
}

.normativa-analisi h3 {
	font-size: 1.25rem;
	margin: 1.6rem 0 .6rem;
}

.normativa-analisi > h3:first-child {
	font-size: 2.25rem;
	margin: 0 0 1.2rem;
}

@media (max-width: 900px) {
	.normativa-analisi > h3:first-child {
		font-size: 1.75rem;
	}
}

.normativa-analisi h4 {
	font-size: 1.1rem;
	margin: 1.4rem 0 .5rem;
}

.normativa-analisi p {
	line-height: 1.8;
	margin: 0 0 1.2em;
	color: var(--norm-text);
}

.normativa-analisi a {
	color: var(--ali-teal);
	text-decoration: none;
	transition: color .2s ease;
}

.normativa-analisi a:hover {
	color: var(--ali-teal-deep);
	text-decoration: underline;
}

.normativa-analisi blockquote {
	border-left: 4px solid var(--ali-teal);
	background: var(--ali-cream);
	margin: 1.5em 0;
	padding: 16px 24px;
	border-radius: 0 var(--norm-radius) var(--norm-radius) 0;
	font-style: italic;
	color: var(--norm-text-secondary);
}

.normativa-analisi ul,
.normativa-analisi ol {
	padding-left: 1.8em;
	margin: 0 0 1.2em;
	line-height: 1.8;
}

.normativa-analisi li {
	margin-bottom: .4em;
}

/* ── Related articles ────────────────────────────── */
.normativa-articoli {
	width: 100%;
	padding: 48px 24px 0;
}

.normativa-articoli-inner {
	max-width: 1140px;
	margin: 0 auto;
}

.normativa-articoli h3 {
	font-family: 'DM Serif Display', serif;
	color: var(--ali-navy);
	font-size: 1.4rem;
	margin: 0 0 24px;
}

.normativa-articoli-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 24px;
}

.normativa-articolo {
	display: flex;
	flex-direction: column;
	background: #fff;
	border-radius: var(--norm-radius);
	box-shadow: 0 2px 12px rgba(0, 0, 0, .06);
	overflow: hidden;
	text-decoration: none;
	color: inherit;
	transition: transform .3s ease, box-shadow .3s ease;
}

.normativa-articolo:hover {
	transform: translateY(-4px);
	box-shadow: 0 8px 24px rgba(0, 0, 0, .1);
}

.normativa-articolo__img {
	aspect-ratio: 16 / 9;
	overflow: hidden;
}

.normativa-articolo__img img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform .4s ease;
}

.normativa-articolo:hover .normativa-articolo__img img {
	transform: scale(1.05);
}

.normativa-articolo__body {
	padding: 20px;
	flex: 1;
	display: flex;
	flex-direction: column;
}

.normativa-articolo__body h4 {
	font-family: 'DM Serif Display', serif;
	color: var(--ali-navy);
	font-size: clamp(.95rem, 1.5vw, 1.1rem);
	line-height: 1.35;
	margin: 0 0 8px;
}

.normativa-articolo__body p {
	color: var(--norm-text-secondary);
	font-size: .88rem;
	line-height: 1.55;
	margin: 0;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* ── Share section ───────────────────────────────── */
.normativa-share {
	padding: 40px 24px;
	margin-top: 32px;
}

.normativa-share-inner {
	max-width: 1140px;
	margin: 0 auto;
	display: flex;
	justify-content: center;
}

/* ── Responsive: tablet ──────────────────────────── */
@media (max-width: 900px) {
	.normativa-hero {
		padding: 80px 20px 48px;
	}

	.normativa-content {
		grid-template-columns: 1fr;
		gap: 32px;
		padding: 40px 20px;
	}

	.normativa-sidebar {
		position: static;
	}

	.normativa-articoli-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

/* ── Responsive: mobile ──────────────────────────── */
@media (max-width: 520px) {
	.normativa-hero {
		padding: 64px 16px 36px;
	}

	.normativa-hero h1 {
		font-size: 1.6rem;
	}

	.normativa-content {
		padding: 32px 16px;
	}

	.normativa-articoli-grid {
		grid-template-columns: 1fr;
	}

	.normativa-riassunto {
		padding: 18px 20px;
	}
}

/* ── Sidebar tags layout ────────────────────────── */
.normativa-sidebar__value--tags {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

/* ── Sidebar materia tags ───────────────────────── */
.normativa-sidebar__materia-tag {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 4px 10px 4px 6px;
	border-radius: 8px;
	background: color-mix(in srgb, var(--materia-color, var(--ali-teal)) 10%, #fff);
	font-size: .82rem;
	line-height: 1.3;
}

.normativa-sidebar__materia-icon {
	flex-shrink: 0;
	width: 22px;
	height: 22px;
	border-radius: 5px;
	color: var(--materia-color, var(--ali-teal));
	display: flex;
	align-items: center;
	justify-content: center;
}

.normativa-sidebar__materia-icon svg {
	width: 14px;
	height: 14px;
}

.normativa-sidebar__materia-link {
	color: var(--materia-color, var(--ali-teal));
	text-decoration: none;
	font-weight: 600;
	transition: color .2s ease;
}

.normativa-sidebar__materia-link:hover {
	color: var(--ali-navy);
	text-decoration: underline;
}

/* ── Sidebar species tags ───────────────────────── */
.normativa-sidebar__specie-tag {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 20px;
	background: color-mix(in srgb, var(--ali-teal) 10%, #fff);
	color: var(--ali-navy);
	font-size: .8rem;
	font-weight: 500;
	line-height: 1.4;
}

/* ── Print styles ────────────────────────────────── */
@media print {
	.normativa-hero {
		background: #fff !important;
		color: #000 !important;
		padding: 20px 0 !important;
		page-break-after: avoid;
	}

	.normativa-hero::before,
	.normativa-hero::after {
		display: none !important;
	}

	.normativa-hero h1 {
		color: #000 !important;
		font-size: 1.6rem !important;
		text-shadow: none !important;
	}

	.normativa-hero-label {
		color: #333 !important;
	}

	.normativa-hero-label::before {
		background: #333 !important;
	}

	.normativa-hero-ref {
		color: #333 !important;
	}

	.normativa-hero-badge {
		color: #000 !important;
		background: #eee !important;
		border: 1px solid #ccc !important;
	}

	.normativa-hero-badge-dot {
		display: none !important;
	}

	.normativa-back {
		display: none !important;
	}

	.normativa-content {
		display: block !important;
		padding: 10px 0 !important;
	}

	.normativa-sidebar {
		position: static !important;
		margin-bottom: 24px;
		padding-bottom: 16px;
		border-bottom: 1px solid #ccc;
	}

	.normativa-sidebar__section {
		display: inline-block;
		margin-right: 24px;
		vertical-align: top;
	}

	.normativa-sidebar__link {
		color: #000 !important;
		border-color: #999 !important;
	}

	.normativa-sidebar__link span {
		display: none !important;
	}

	.normativa-sidebar__link::after {
		content: " (" attr(href) ")";
		font-size: .75rem;
		font-weight: 400;
		word-break: break-all;
	}

	.normativa-body {
		max-width: 100% !important;
	}

	.normativa-riassunto {
		background: #f5f5f5 !important;
		border-left-color: #333 !important;
	}

	.normativa-toc,
	.normativa-articoli,
	.normativa-share {
		display: none !important;
	}

	/* Show all text */
	.normativa-analisi {
		page-break-inside: auto;
	}

	.normativa-analisi a::after {
		content: " (" attr(href) ")";
		font-size: .75rem;
		font-weight: 400;
	}
}
