/*
 * Applica il tema scuro soltanto quando è richiesto dal browser o dal sistema.
 * Le variabili restano condivise da tutte le shell e dagli aggiornamenti PairUI.
 */
@media (prefers-color-scheme: dark) {
	:root {
		--scv-navy-900: #e6f0f6;
		--scv-sky-500: #53c7ef;
		--scv-sun-500: #ffd270;
		--scv-sand-100: #1c3040;
		--scv-ivory-50: #0b1824;
		--scv-green-500: #8fc49a;
		--scv-text: #e7edf2;
		--scv-muted: #aab8c4;
		--scv-border: #34495b;
		--scv-danger: #f08080;
		--scv-danger-text: #ffb0b0;
		--scv-success: #72c99a;
		--scv-background: #0b1824;
		--scv-surface: #132536;
		--scv-focus: #67c7ec;
		--scv-shadow-soft: 0 0.75rem 2rem rgba(0, 0, 0, 0.34);
		--scv-button-primary-background: #1b5f78;
		--scv-button-primary-border: var(--scv-sky-500);
		--scv-button-primary-color: #ffffff;
		--scv-button-primary-hover-background: #216f8c;
		--scv-button-primary-hover-border: #bce9fa;
		--scv-button-primary-hover-color: #ffffff;
	}

	html {
		color-scheme: dark;
	}

	.scv-button--secondary,
	.scv-ui-control,
	.scv-select__trigger,
	.scv-select__listbox,
	.scv-auth-control,
	.scv-rental-form input,
	.scv-rental-form select,
	.scv-rental-form textarea,
	.scv-rental-action-panel input,
	.scv-rental-action-panel select,
	.scv-rental-action-panel textarea {
		background: var(--scv-surface);
		border-color: #53697a;
		color: var(--scv-text);
	}

	/* Neutralizza il colore di autofill imposto dal browser senza nascondere il valore compilato. */
	.scv-auth-control:autofill {
		-webkit-text-fill-color: var(--scv-text);
		background-color: var(--scv-surface);
		border-color: #53697a;
		box-shadow: 0 0 0 1000px var(--scv-surface) inset;
		caret-color: var(--scv-text);
		color: var(--scv-text);
	}

	.scv-auth-control:-webkit-autofill,
	.scv-auth-control:-webkit-autofill:hover,
	.scv-auth-control:-webkit-autofill:focus {
		-webkit-text-fill-color: var(--scv-text);
		background-color: var(--scv-surface);
		border-color: #53697a;
		box-shadow: 0 0 0 1000px var(--scv-surface) inset;
		caret-color: var(--scv-text);
		color: var(--scv-text);
	}

	.scv-button--secondary:hover {
		background: color-mix(in srgb, var(--scv-sky-500) 16%, var(--scv-surface));
		color: var(--scv-navy-900);
	}

	.scv-private-shell {
		--scv-private-sidebar: #102130;
		background: var(--scv-background);
	}

	.scv-private-account__profile[aria-current="page"],
	.scv-private-nav a[aria-current="page"] {
		background: color-mix(in srgb, var(--scv-private-accent) 18%, var(--scv-surface));
	}

	.scv-private-account__action:hover,
	.scv-private-account__action:focus-visible,
	.scv-private-nav a:hover,
	.scv-ui-link-button--icon:hover,
	.scv-ui-link-button--icon:focus-visible,
	.scv-ui-view-switch__item:hover,
	.scv-ui-view-switch__item:focus-visible,
	.scv-ui-period-navigation__step:hover,
	.scv-ui-period-navigation__step:focus-visible {
		background: #1a3042;
		color: var(--scv-text);
	}

	.scv-ui-alert,
	.scv-ui-empty,
	.scv-ui-filter,
	.scv-tech-file-list li {
		background: #102130;
	}

	.scv-ui-empty {
		border-color: #607486;
	}

	.scv-ui-alert[data-tone="success"] {
		background: color-mix(in srgb, var(--scv-success) 12%, var(--scv-surface));
	}

	.scv-ui-alert[data-tone="warning"] {
		background: color-mix(in srgb, var(--scv-sun-500) 10%, var(--scv-surface));
	}

	.scv-ui-alert[data-tone="danger"] {
		background: color-mix(in srgb, var(--scv-danger) 12%, var(--scv-surface));
	}

	.scv-ui-badge,
	.scv-health-summary__icon,
	.scv-health-section-card__icon {
		background: #263a4b;
		color: #dce7ee;
	}

	.scv-ui-badge[data-tone="success"],
	.scv-health-summary__icon[data-tone="success"],
	.scv-health-section-card__icon[data-tone="success"] {
		background: #173c2d;
		color: #9ee2ba;
	}

	.scv-ui-badge[data-tone="warning"],
	.scv-health-summary__icon[data-tone="warning"],
	.scv-health-section-card__icon[data-tone="warning"] {
		background: #443718;
		color: #ffe19a;
	}

	.scv-ui-badge[data-tone="danger"],
	.scv-health-summary__icon[data-tone="danger"],
	.scv-health-section-card__icon[data-tone="danger"] {
		background: #482728;
		color: var(--scv-danger-text);
	}

	.scv-ui-badge[data-tone="info"] {
		background: color-mix(in srgb, var(--scv-sky-500) 18%, var(--scv-surface));
		color: #bce9fa;
	}

	.scv-admin-photo-grid figure,
	.scv-editorial,
	.scv-experiences,
	.scv-information-hero {
		background: #102130;
	}

	.scv-public-header,
	.scv-shell--public-hero.scv-shell--js .scv-public-header.is-scrolled {
		background: rgba(11, 24, 36, 0.97);
		box-shadow: 0 0.35rem 1.25rem rgba(0, 0, 0, 0.24);
	}

	/* Sulle barre blu usa il marchio bianco e oro senza alterare il giallo. */
	.scv-public-header .scv-brand__logo--default {
		display: none;
	}

	.scv-public-header .scv-brand__logo--on-dark {
		display: block;
	}

	/* I pulsanti "light" conservano il proprio fondo chiaro. */
	.scv-button--light {
		background: #fffdf8;
		color: var(--scv-on-accent);
	}

	.scv-public-menu[open] summary,
	.scv-public-menu nav {
		background: var(--scv-surface);
		color: var(--scv-text);
	}

	.scv-opportunity--ivory {
		background: #263848;
	}

	/* L'ocra attenuato conserva l'accento solare senza abbagliare nel tema scuro. */
	.scv-opportunity--sun {
		--scv-navy-900: #0b1824;
		background: #b98632;
		color: #0b1824;
	}

	.scv-tech-code-block {
		border: 0.0625rem solid var(--scv-border);
	}

	.scv-profile-photo__preview {
		border-color: var(--scv-surface);
	}
}
