/* =========================================================================
 * QuoVadis Core v2 — Base Components
 * Primitive UI riusabili: bottoni, card, chip, pill, form, grid, hero,
 * section, stati e utility. Dipende da qv-tokens.css.
 * ========================================================================= */

/* =========================================================================
 * Buttons — .qv-btn (base) + varianti
 * ========================================================================= */
.qv-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--qv-sp-2);
	padding: var(--qv-sp-3) var(--qv-sp-5);
	font-family: var(--qv-font);
	font-size: var(--qv-fs-base);
	font-weight: var(--qv-fw-semibold);
	line-height: 1.2;
	color: var(--qv-fg);
	background: var(--qv-neutral-100);
	border: 1px solid transparent;
	border-radius: var(--qv-r-md);
	cursor: pointer;
	text-decoration: none;
	text-align: center;
	white-space: nowrap;
	transition: background var(--qv-tr-fast), color var(--qv-tr-fast),
				border-color var(--qv-tr-fast), box-shadow var(--qv-tr-fast),
				transform var(--qv-tr-fast);
	-webkit-tap-highlight-color: transparent;
	user-select: none;
}

.qv-btn:hover {
	background: var(--qv-neutral-200);
	text-decoration: none;
}

.qv-btn:active {
	transform: translateY(1px);
}

.qv-btn:focus-visible {
	outline: none;
	box-shadow: var(--qv-shadow-focus);
}

.qv-btn[disabled],
.qv-btn:disabled {
	opacity: 0.55;
	cursor: not-allowed;
	pointer-events: none;
}

/* Primary — verde brand */
.qv-btn--primary {
	background: var(--qv-green-600);
	color: var(--qv-neutral-0);
}

.qv-btn--primary:hover {
	background: var(--qv-green-700);
	color: var(--qv-neutral-0);
}

/* Secondary — blu brand */
.qv-btn--secondary {
	background: var(--qv-blue-600);
	color: var(--qv-neutral-0);
}

.qv-btn--secondary:hover {
	background: var(--qv-blue-700);
	color: var(--qv-neutral-0);
}

.qv-btn--secondary:focus-visible {
	box-shadow: var(--qv-shadow-focus-blue);
}

/* Ghost — solo bordo */
.qv-btn--ghost {
	background: transparent;
	color: var(--qv-fg);
	border-color: var(--qv-border-strong);
}

.qv-btn--ghost:hover {
	background: var(--qv-neutral-100);
	color: var(--qv-fg);
}

/* Size lg */
.qv-btn--lg {
	padding: var(--qv-sp-4) var(--qv-sp-6);
	font-size: var(--qv-fs-md);
	border-radius: var(--qv-r-lg);
}

/* Block — full width */
.qv-btn--block {
	display: flex;
	width: 100%;
}

/* =========================================================================
 * Card — layout immagine-in-cima per POI / attività
 * ========================================================================= */
.qv-card {
	display: flex;
	flex-direction: column;
	background: var(--qv-bg);
	border: 1px solid var(--qv-border);
	border-radius: var(--qv-r-lg);
	overflow: hidden;
	transition: transform var(--qv-tr-normal), box-shadow var(--qv-tr-normal),
				border-color var(--qv-tr-normal);
	text-decoration: none;
	color: inherit;
	height: 100%;
}

.qv-card:hover {
	transform: translateY(-2px);
	box-shadow: var(--qv-shadow-md);
	border-color: var(--qv-border-strong);
	text-decoration: none;
}

.qv-card__media {
	position: relative;
	aspect-ratio: 16 / 10;
	background: var(--qv-neutral-100);
	overflow: hidden;
}

.qv-card__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform var(--qv-tr-slow);
}

.qv-card:hover .qv-card__media img {
	transform: scale(1.04);
}

.qv-card__body {
	display: flex;
	flex-direction: column;
	gap: var(--qv-sp-2);
	padding: var(--qv-sp-4);
	flex: 1;
}

.qv-card__title {
	font-size: var(--qv-fs-md);
	font-weight: var(--qv-fw-bold);
	line-height: var(--qv-lh-snug);
	color: var(--qv-fg);
	margin: 0;
}

.qv-card__meta {
	font-size: var(--qv-fs-sm);
	color: var(--qv-fg-muted);
}

.qv-card__excerpt {
	font-size: var(--qv-fs-sm);
	color: var(--qv-fg-muted);
	line-height: var(--qv-lh-normal);
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.qv-card__footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--qv-sp-2);
	padding-top: var(--qv-sp-2);
	margin-top: auto;
}

.qv-card__pills {
	display: flex;
	flex-wrap: wrap;
	gap: var(--qv-sp-1);
	margin-bottom: var(--qv-sp-2);
}

/* =========================================================================
 * Chip — selezionabile (radio/checkbox nascosto, label cliccabile)
 * ========================================================================= */
.qv-chip {
	display: inline-flex;
	align-items: center;
	gap: var(--qv-sp-2);
	padding: var(--qv-sp-2) var(--qv-sp-4);
	font-family: var(--qv-font);
	font-size: var(--qv-fs-sm);
	font-weight: var(--qv-fw-medium);
	color: var(--qv-fg);
	background: var(--qv-neutral-0);
	border: 1px solid var(--qv-border-strong);
	border-radius: var(--qv-r-full);
	cursor: pointer;
	user-select: none;
	transition: background var(--qv-tr-fast), color var(--qv-tr-fast),
				border-color var(--qv-tr-fast), box-shadow var(--qv-tr-fast);
	position: relative;
}

.qv-chip:hover {
	border-color: var(--qv-green-600);
	background: var(--qv-green-50);
}

/* Input nascosto ma accessibile — focus si trasferisce sul chip */
.qv-chip input[type="checkbox"],
.qv-chip input[type="radio"] {
	position: absolute;
	opacity: 0;
	pointer-events: none;
	width: 1px;
	height: 1px;
}

/* Stato selezionato — sfondo verde brand */
.qv-chip.is-checked,
.qv-chip:has(input:checked) {
	background: var(--qv-green-600);
	color: var(--qv-neutral-0);
	border-color: var(--qv-green-600);
}

.qv-chip:has(input:focus-visible) {
	box-shadow: var(--qv-shadow-focus);
}

/* =========================================================================
 * Pill — etichetta piccola (tier, distanza, intent)
 * ========================================================================= */
.qv-pill {
	display: inline-flex;
	align-items: center;
	gap: var(--qv-sp-1);
	padding: 2px var(--qv-sp-2);
	font-size: var(--qv-fs-xs);
	font-weight: var(--qv-fw-semibold);
	line-height: 1.4;
	color: var(--qv-fg-muted);
	background: var(--qv-neutral-100);
	border-radius: var(--qv-r-full);
	white-space: nowrap;
	text-transform: uppercase;
	letter-spacing: 0.02em;
}

.qv-pill--green {
	background: var(--qv-green-100);
	color: var(--qv-green-800);
}

.qv-pill--blue {
	background: var(--qv-blue-100);
	color: var(--qv-blue-800);
}

.qv-pill--warning {
	background: var(--qv-warning-bg);
	color: var(--qv-warning);
}

.qv-pill--danger {
	background: var(--qv-danger-bg);
	color: var(--qv-danger);
}

/* =========================================================================
 * Form controls — input, select, textarea
 * ========================================================================= */
.qv-form-control {
	display: block;
	width: 100%;
	padding: var(--qv-sp-3) var(--qv-sp-4);
	font-family: var(--qv-font);
	font-size: var(--qv-fs-base);
	line-height: var(--qv-lh-normal);
	color: var(--qv-fg);
	background: var(--qv-bg);
	border: 1px solid var(--qv-border-strong);
	border-radius: var(--qv-r-md);
	transition: border-color var(--qv-tr-fast), box-shadow var(--qv-tr-fast);
	appearance: none;
	-webkit-appearance: none;
}

.qv-form-control::placeholder {
	color: var(--qv-neutral-400);
}

.qv-form-control:hover {
	border-color: var(--qv-neutral-400);
}

.qv-form-control:focus,
.qv-form-control:focus-visible {
	outline: none;
	border-color: var(--qv-green-600);
	box-shadow: var(--qv-shadow-focus);
}

.qv-form-control[disabled],
.qv-form-control:disabled {
	background: var(--qv-neutral-100);
	color: var(--qv-fg-muted);
	cursor: not-allowed;
}

textarea.qv-form-control {
	min-height: 6rem;
	resize: vertical;
}

select.qv-form-control {
	background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23525252'><path d='M5 7l5 6 5-6z'/></svg>");
	background-repeat: no-repeat;
	background-position: right var(--qv-sp-3) center;
	background-size: 18px 18px;
	padding-right: var(--qv-sp-7);
}

.qv-form-label {
	display: block;
	font-size: var(--qv-fs-sm);
	font-weight: var(--qv-fw-semibold);
	color: var(--qv-fg);
	margin-bottom: var(--qv-sp-1);
}

.qv-form-help {
	display: block;
	font-size: var(--qv-fs-xs);
	color: var(--qv-fg-muted);
	margin-top: var(--qv-sp-1);
}

/* =========================================================================
 * Grid — generico + variante POI (auto-fill min 280px)
 * ========================================================================= */
.qv-grid {
	display: grid;
	gap: var(--qv-sp-4);
}

.qv-grid--poi {
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: var(--qv-sp-5);
}

@media (min-width: 768px) {
	.qv-grid--poi { gap: var(--qv-sp-6); }
}

/* =========================================================================
 * Hero — full-width con overlay gradient
 * ========================================================================= */
.qv-hero {
	position: relative;
	width: 100%;
	min-height: 360px;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	color: var(--qv-neutral-0);
	background: var(--qv-green-700);
}

.qv-hero__media {
	position: absolute;
	inset: 0;
	z-index: 0;
}

.qv-hero__media img,
.qv-hero__media video {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.qv-hero::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(180deg,
		rgba(0, 0, 0, 0.20) 0%,
		rgba(0, 0, 0, 0.55) 100%);
	z-index: 1;
	pointer-events: none;
}

.qv-hero__content {
	position: relative;
	z-index: 2;
	width: 100%;
	max-width: var(--qv-container-max);
	margin-inline: auto;
	padding: var(--qv-sp-6) var(--qv-sp-4);
	text-align: center;
}

.qv-hero__title {
	font-size: var(--qv-fs-2xl);
	font-weight: var(--qv-fw-extra);
	line-height: var(--qv-lh-tight);
	color: var(--qv-neutral-0);
	margin: 0 0 var(--qv-sp-3);
	text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.qv-hero__subtitle {
	font-size: var(--qv-fs-md);
	color: var(--qv-neutral-0);
	opacity: 0.95;
	max-width: 640px;
	margin: 0 auto var(--qv-sp-5);
}

@media (min-width: 768px) {
	.qv-hero { min-height: 480px; }
	.qv-hero__title { font-size: var(--qv-fs-4xl); }
	.qv-hero__subtitle { font-size: var(--qv-fs-lg); }
	.qv-hero__content { padding: var(--qv-sp-7) var(--qv-sp-5); }
}

/* =========================================================================
 * Section — ritmo verticale tra blocchi
 * ========================================================================= */
.qv-section {
	padding-block: var(--qv-sp-6);
}

.qv-section--lg {
	padding-block: var(--qv-sp-7);
}

.qv-section--alt {
	background: var(--qv-bg-alt);
}

.qv-section__header {
	margin-bottom: var(--qv-sp-5);
}

.qv-section__title {
	font-size: var(--qv-fs-xl);
	font-weight: var(--qv-fw-bold);
	margin: 0 0 var(--qv-sp-2);
}

.qv-section__lead {
	font-size: var(--qv-fs-md);
	color: var(--qv-fg-muted);
	margin: 0;
}

@media (min-width: 768px) {
	.qv-section    { padding-block: var(--qv-sp-7); }
	.qv-section--lg{ padding-block: var(--qv-sp-8); }
	.qv-section__title { font-size: var(--qv-fs-2xl); }
}

/* =========================================================================
 * Stati — errore, successo, loading
 * ========================================================================= */
.qv-error,
.qv-success {
	padding: var(--qv-sp-3) var(--qv-sp-4);
	border-radius: var(--qv-r-md);
	font-size: var(--qv-fs-sm);
	border: 1px solid transparent;
}

.qv-error {
	background: var(--qv-danger-bg);
	color: var(--qv-danger);
	border-color: rgba(220, 38, 38, 0.25);
}

.qv-success {
	background: var(--qv-success-bg);
	color: var(--qv-green-800);
	border-color: rgba(22, 163, 74, 0.25);
}

.qv-loading {
	display: inline-flex;
	align-items: center;
	gap: var(--qv-sp-2);
	color: var(--qv-fg-muted);
	font-size: var(--qv-fs-sm);
}

.qv-loading::before {
	content: "";
	width: 1em;
	height: 1em;
	border: 2px solid currentColor;
	border-top-color: transparent;
	border-radius: 50%;
	animation: qv-spin 0.8s linear infinite;
	display: inline-block;
}

@keyframes qv-spin {
	to { transform: rotate(360deg); }
}

/* Riduzione movimento per chi lo preferisce */
@media (prefers-reduced-motion: reduce) {
	.qv-loading::before { animation-duration: 3s; }
	.qv-card,
	.qv-card__media img,
	.qv-btn { transition: none; }
}

/* =========================================================================
 * Utility
 * ========================================================================= */

/* Solo screen reader */
.qv-sr-only {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

/* Stack verticale — gap uniforme tra figli */
.qv-stack {
	display: flex;
	flex-direction: column;
	gap: var(--qv-sp-4);
}

.qv-stack--sm { gap: var(--qv-sp-2); }
.qv-stack--lg { gap: var(--qv-sp-5); }

/* Cluster orizzontale — flex wrap, gap uniforme */
.qv-cluster {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--qv-sp-2);
}

.qv-cluster--lg { gap: var(--qv-sp-4); }
.qv-cluster--center { justify-content: center; }
.qv-cluster--end    { justify-content: flex-end; }
.qv-cluster--between{ justify-content: space-between; }
