/* ==========================================================================
   Base: reset, tipografia, layout primitivo, accessibilità.
   ========================================================================== */

*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-padding-top: calc(var(--header-height) + var(--space-7));
}

@media (prefers-reduced-motion: no-preference) {
	html {
		scroll-behavior: smooth;
	}
}

body {
	margin: 0;
	min-height: 100vh;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font-body);
	font-size: var(--text-md);
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	/* Spazio per la bottom nav fissa + safe area (iPhone). */
	padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
}

img,
svg,
video,
iframe {
	max-width: 100%;
}

img,
video {
	height: auto;
	display: block;
}

h1,
h2,
h3,
h4 {
	margin: 0;
	font-family: var(--font-heading);
	font-weight: 700;
	line-height: var(--leading-tight);
	letter-spacing: -0.01em;
	text-wrap: balance;
}

p {
	margin: 0;
}

a {
	color: inherit;
	text-decoration: none;
}

ul,
ol {
	margin: 0;
	padding: 0;
}

button,
input,
select,
textarea {
	font: inherit;
	color: inherit;
}

button {
	cursor: pointer;
}

[hidden] {
	display: none !important;
}

/* Controlli che richiedono JavaScript: nascosti se lo script non gira. */
:root:not(.js) [data-theme-toggle],
:root:not(.js) [data-favorites-list] {
	display: none !important;
}

/* --------------------------------------------------------------------------
   Focus visibile ovunque (solo da tastiera).
   -------------------------------------------------------------------------- */

:focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: 3px;
	border-radius: var(--radius-xs);
}

:focus:not(:focus-visible) {
	outline: none;
}

.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.skip-link {
	position: fixed;
	top: var(--space-2);
	left: var(--space-2);
	z-index: 1000;
	padding: var(--space-3) var(--space-4);
	border-radius: var(--radius-sm);
	background: var(--accent-fill);
	color: var(--on-accent);
	font-weight: 600;
	transform: translateY(-200%);
}

.skip-link:focus {
	transform: none;
}

.site-main:focus {
	outline: none;
}

/* I blocchi a tutta larghezza (100vw) non devono creare scroll orizzontale. */
.site-main {
	overflow-x: clip;
}

.icon-sprite {
	position: absolute;
	width: 0;
	height: 0;
	overflow: hidden;
}

.icon {
	width: 20px;
	height: 20px;
	flex-shrink: 0;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.9;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.icon-flip {
	transform: scaleX(-1);
}

/* --------------------------------------------------------------------------
   Layout primitivo.
   -------------------------------------------------------------------------- */

.container {
	width: 100%;
	max-width: var(--container);
	margin-inline: auto;
	padding-inline: var(--gutter);
}

.page-pad {
	padding-top: var(--space-4);
	padding-bottom: var(--space-7);
}

.narrow {
	max-width: var(--content-width);
	margin-inline: auto;
}

/* Link esteso: tutta la card è cliccabile con un solo <a> nel titolo. */
.stretched-link::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	border-radius: inherit;
}

.stretched-link:focus-visible {
	outline: none;
}

.stretched-link:focus-visible::after {
	outline: 2px solid var(--focus);
	outline-offset: 2px;
}

/* Segnaposto immagine a proporzioni fisse: nessun layout shift. */
.media-placeholder {
	display: grid;
	place-items: center;
	width: 100%;
	height: 100%;
	background:
		radial-gradient(120% 90% at 100% 0%, rgba(var(--accent-rgb, 255, 10, 122), 0.16), transparent 60%),
		var(--surface-3);
	color: var(--text-muted);
}

.media-placeholder .icon {
	width: 32px;
	height: 32px;
	opacity: 0.6;
}

.meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-1) var(--space-2);
	color: var(--text-muted);
	font-size: var(--text-xs);
	line-height: 1.4;
}

.meta .icon {
	width: 14px;
	height: 14px;
}

.meta > span + span::before {
	content: "·";
	margin-right: var(--space-2);
}
