/*
 * Single resource template: metadata sidebar + content area.
 * Colours and fonts: same tokens as archive.css.
 */

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

/* ── Base ─────────────────────────────────────────── */
.risorsa-page {
	/* Theme hooks: set --reslib-* in the theme, or let them fall back to the
	   ali-blocks --block-* tokens, then to neutral defaults. */
	--rsr-navy: var(--reslib-ink, var(--block-dark, #1f2933));
	--rsr-teal: var(--reslib-accent, var(--block-accent, #4f9d8f));          /* fills only */
	--rsr-teal-text: var(--reslib-accent-text, var(--block-accent-text, #2c6b61)); /* accent as ink */
	--rsr-btn-ink: var(--reslib-accent-ink, var(--block-accent-ink, #1f2933));   /* text on accent fills */
	--rsr-cream: var(--reslib-bg, var(--block-bg, #f8f7f4));
	--rsr-text: var(--reslib-text, var(--block-text, #2c2c2c));
	--rsr-muted: var(--reslib-muted, var(--block-text-secondary, #5c6370));
	--rsr-font-heading: var(--reslib-font-heading, var(--block-font-heading, Georgia, 'Times New Roman', serif));
	--rsr-font-body: var(--reslib-font-body, var(--block-font-body, inherit));
	box-sizing: border-box;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	overflow-x: hidden;
	background: var(--rsr-cream);
}

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

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

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

.risorsa-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;
}

.risorsa-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");
}

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

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

.risorsa-back:hover {
	color: var(--rsr-teal-text);
}

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

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

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

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

/* ── Hero heading ────────────────────────────────── */
.risorsa-hero h1 {
	font-family: var(--rsr-font-heading);
	color: var(--rsr-navy);
	font-size: clamp(2rem, 5vw, 3.2rem);
	line-height: 1.15;
	margin: 0;
	animation: resFadeInUp .8s ease both;
}

/* titles over 60 characters (paper and report titles) step down a size */
.risorsa-hero--long h1 {
	font-size: clamp(1.5rem, 3.4vw, 2.3rem);
	max-width: 32ch;
	margin-inline: auto;
}

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

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

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

.risorsa-hero-badge--tipo {
	background: color-mix(in srgb, var(--tipo-color) 12%, transparent);
	color: var(--tipo-color);
}

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

/* ── Two-column content ──────────────────────────── */
.risorsa-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 ─────────────────────────────────────── */
.risorsa-sidebar {
	position: sticky;
	top: 100px;
	align-self: start;
}

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

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

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

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

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

/* Cover image in sidebar */
.risorsa-sidebar__cover {
	margin-bottom: 20px;
	border-radius: 10px;
	overflow: hidden;
	box-shadow: 0 4px 20px rgba(26,35,50,.1);
}
.risorsa-sidebar__cover img {
	display: block;
	width: 100%;
	height: auto;
}

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

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

.risorsa-sidebar__link:hover {
	background: var(--rsr-teal);
	color: var(--rsr-btn-ink);
}

/* Theme-wide `a:hover { text-decoration: underline }` (0,1,1) outranks these
   single-class rules, so buttons, cards and the TOC would underline on hover. */
:is(.risorsa-back, .risorsa-sidebar__link, .risorsa-sidebar__related-item, .risorsa-toc__item a, .risorsa-articolo):hover {
	text-decoration: none;
}

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

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

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

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

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

.risorsa-sidebar__related-label {
	display: block;
	font-family: var(--rsr-font-body);
	font-size: .65rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .08em;
	color: var(--rsr-teal-text);
	margin: 12px 0 4px;
}

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

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

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

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

.risorsa-punti h3 {
	font-family: var(--rsr-font-heading);
	color: var(--rsr-navy);
	font-size: 1.4rem;
	margin: 0 0 16px;
}

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

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

.risorsa-punti li::before {
	content: "";
	position: absolute;
	left: 0;
	top: 5px;
	width: 16px;
	height: 16px;
	background: var(--rsr-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 ───────────────────────────── */
.risorsa-toc {
	background: var(--rsr-cream);
	border-radius: var(--res-radius);
	padding: 24px 28px;
	margin-bottom: 36px;
}

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

.risorsa-toc__title {
	font-family: var(--rsr-font-heading);
	font-size: 1.25rem;
	color: var(--rsr-navy);
}

.risorsa-toc__icon {
	width: 20px;
	height: 20px;
	background: var(--res-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;
}

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

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

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

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

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

.risorsa-toc__item a:hover {
	color: var(--rsr-teal-text);
}

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

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

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

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

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

/* ── Analisi (WYSIWYG) ───────────────────────────── */
.risorsa-analisi h2,
.risorsa-analisi h3,
.risorsa-analisi h4 {
	font-family: var(--rsr-font-heading);
	color: var(--rsr-navy);
	line-height: 1.25;
}

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

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

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

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

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

.risorsa-analisi a:hover {
	color: var(--rsr-teal-text);
	text-decoration: underline;
}

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

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

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

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

/* the share bar brings its own spacing */
.risorsa-articoli + .risorsa-share {
	margin-top: -48px;
}

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

.risorsa-articoli h3 {
	font-family: var(--rsr-font-heading);
	color: var(--rsr-navy);
	font-size: 1.4rem;
	margin: 0 0 24px;
}

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

.risorsa-articolo {
	display: flex;
	flex-direction: column;
	background: #fff;
	border-radius: var(--res-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;
}

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

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

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

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

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

.risorsa-articolo__body h4 {
	font-family: var(--rsr-font-heading);
	color: var(--rsr-navy);
	font-size: clamp(.95rem, 1.5vw, 1.1rem);
	line-height: 1.35;
	margin: 0 0 8px;
}

.risorsa-articolo__body p {
	color: var(--res-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 ───────────────────────────────── */
.risorsa-share {
	padding: 40px 24px;
	margin-top: 32px;
}

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

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

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

	/* phones read top-down: cover and links first, then the details */
	.risorsa-sidebar {
		position: static;
		display: flex;
		flex-direction: column;
	}

	.risorsa-sidebar__cover {
		order: -2;
		width: min(240px, 70%);
		margin-inline: auto;
	}

	.risorsa-sidebar__links {
		order: -1;
	}

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

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

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

	.risorsa-hero--long h1 {
		font-size: 1.25rem;
	}

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

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

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

	/* details as a two-column grid: half the scroll before the summary */
	.risorsa-sidebar__section:first-child {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		column-gap: 16px;
	}

	.risorsa-sidebar__section:first-child > .risorsa-sidebar__heading,
	.risorsa-sidebar__section:first-child > .risorsa-sidebar__item:has(.risorsa-sidebar__value--tags) {
		grid-column: 1 / -1;
	}
}

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

/* ── Sidebar materia tags ───────────────────────── */
.risorsa-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(--rsr-teal)) 10%, #fff);
	font-size: .82rem;
	line-height: 1.3;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/* Other editions / translations */
.risorsa-sidebar__edition {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin-bottom: 16px;
}
.risorsa-sidebar__edition:last-child { margin-bottom: 0; }
.risorsa-sidebar__edition-title {
	font-family: var(--rsr-font-heading);
	font-size: 1.05rem;
	line-height: 1.25;
	color: var(--rsr-navy);
}
a.risorsa-sidebar__edition-title {
	text-decoration: underline;
	text-decoration-color: rgba(26, 35, 50, .25);
	text-underline-offset: 3px;
}
a.risorsa-sidebar__edition-title:hover { color: var(--rsr-teal-text); }
.risorsa-sidebar__edition-meta {
	font-size: .85rem;
	color: #5c6370;
	line-height: 1.45;
}
