/* ISS header */
.iss-header {
	--iss-header-bg: #ffffff;
	--iss-header-color: #1f2937;
	--iss-header-primary: var(--iss-btn, #41668d);
	position: relative;
	z-index: 100;
	background: var(--iss-header-bg);
	color: var(--iss-header-color);
	box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}
.iss-header--dark {
	--iss-header-bg: #1f2937;
	--iss-header-color: #ffffff;
}
.iss-header--sticky { position: sticky; top: 0; }
.admin-bar .iss-header--sticky { top: 32px; }
@media (max-width: 782px) { .admin-bar .iss-header--sticky { top: 46px; } }

/* Desktop: tre colonne, logo a sinistra, menu centrato, azioni (lingua, bottone) a destra. */
.iss-header__inner {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	gap: 1.5rem;
	max-width: var(--iss-container, 1300px);
	margin-inline: auto;
	padding: 0.85rem var(--iss-gutter, 1.25rem);
	box-sizing: border-box;
}
.iss-header__logo { display: inline-flex; align-items: center; text-decoration: none; color: inherit; justify-self: start; }
.iss-header__logo img { display: block; height: auto; max-width: 100%; }
.iss-header__name { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.01em; }

/* Il contenitore del pannello mobile non partecipa alla griglia: menu e azioni sono figli diretti. */
.iss-header__nav { display: contents; }
.iss-header__nav > nav { justify-self: center; min-width: 0; }
.iss-header__menu, .iss-header__menu ul { list-style: none; margin: 0; padding: 0; }
.iss-header__menu { display: flex; align-items: center; gap: 0.25rem; }
.iss-header__menu li { position: relative; }
.iss-header__menu a {
	display: block;
	padding: 0.5rem 0.75rem;
	color: inherit;
	text-decoration: none;
	font-weight: 500;
	border-radius: 4px;
	transition: background 0.15s ease;
}
.iss-header__menu a:hover,
.iss-header__menu .current-menu-item > a,
.iss-header__menu .current-menu-ancestor > a { background: rgba(127, 127, 127, 0.12); }

/* Sottomenu (desktop) */
.iss-header__menu .sub-menu {
	position: absolute;
	top: 100%;
	left: 0;
	min-width: 280px;
	padding: 0.4rem;
	background: var(--iss-header-bg);
	border-radius: 6px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
	opacity: 0;
	visibility: hidden;
	transform: translateY(6px);
	transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}
.iss-header__menu li:hover > .sub-menu,
.iss-header__menu li:focus-within > .sub-menu { opacity: 1; visibility: visible; transform: none; }
/* La tendina si allinea al bordo sinistro della voce; .is-flip (header.js) la allinea a destra se sforerebbe. */
.iss-header__menu > li > .sub-menu.is-flip { left: auto; right: 0; }
/* Tendine lunghe senza terzo livello: non escono dallo schermo, scorrono. */
.iss-header__menu > li > .sub-menu:not(:has(.sub-menu)) {
	max-height: calc(100vh - var(--iss-header-h, 80px) - 1rem);
	overflow-y: auto;
}

/* Terzo livello (voce -> sottovoce -> sezioni): tendina a lato della categoria.
   La categoria è un <button> (aria-expanded): si apre con hover, focus, click o tap. */
.iss-header__menu .sub-menu .sub-menu {
	top: -0.4rem;
	left: 100%;
	margin-left: 0.25rem;
}
/* .is-flip (header.js): a destra non c'è spazio, la tendina si apre a sinistra. */
.iss-header__menu .sub-menu .sub-menu.is-flip {
	left: auto;
	right: 100%;
	margin-left: 0;
	margin-right: 0.25rem;
}
.iss-header__menu li.is-open > .sub-menu { opacity: 1; visibility: visible; transform: none; }
.iss-header__menu-heading {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	width: 100%;
	padding: 0.5rem 0.75rem;
	border: 0;
	border-radius: 4px;
	background: none;
	color: inherit;
	font: inherit;
	font-weight: 500;
	text-align: left;
	white-space: nowrap;
	cursor: pointer;
	transition: background 0.15s ease;
}
.iss-header__menu-heading::after {
	content: "";
	flex: none;
	width: 0.45em;
	height: 0.45em;
	border: solid currentColor;
	border-width: 0 2px 2px 0;
	transform: rotate(-45deg);
	opacity: 0.6;
}
.iss-header__menu li:has(> .sub-menu.is-flip) > .iss-header__menu-heading::after { transform: rotate(135deg); order: -1; }
.iss-header__menu li:has(> .sub-menu.is-flip) > .iss-header__menu-heading { justify-content: flex-start; }
/* color: inherit anche su hover/focus/active: il tema (GeneratePress) mette
   testo bianco su fondo scuro a tutti i button:hover e button:focus. */
.iss-header__menu-heading:hover,
.iss-header__menu-heading:focus,
.iss-header__menu-heading:active,
.iss-header__menu li:hover > .iss-header__menu-heading,
.iss-header__menu li.is-open > .iss-header__menu-heading {
	background: rgba(127, 127, 127, 0.12);
	color: inherit;
	border: 0;
}
.iss-header__menu-heading:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }


.iss-header__actions { display: flex; align-items: center; gap: 1rem; justify-self: end; }
.iss-header__phone { color: inherit; text-decoration: none; font-weight: 600; white-space: nowrap; }
/* Bottone: stili completi qui perché shortcodes.css non è sempre caricato. */
.iss-header .iss-btn {
	display: inline-block;
	padding: 0.6em 1.25em;
	border-radius: var(--iss-radius, 6px);
	background: var(--iss-header-primary);
	color: #fff;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	white-space: nowrap;
	transition: opacity 0.15s ease;
}
.iss-header .iss-btn:hover { opacity: 0.9; color: #fff; text-decoration: none; }

/* Selettore lingua */
.iss-header__lang {
	display: flex;
	align-items: center;
	gap: 0.15rem;
	list-style: none;
	margin: 0;
	padding: 0;
}
.iss-header__lang a {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0.35rem 0.5rem;
	border-radius: 4px;
	color: inherit;
	text-decoration: none;
	font-size: 0.85rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	opacity: 0.7;
	transition: opacity 0.15s ease, background 0.15s ease;
}
.iss-header__lang a:hover { opacity: 1; background: rgba(127, 127, 127, 0.12); }
.iss-header__lang .is-current a { opacity: 1; text-decoration: underline; text-underline-offset: 4px; }
.iss-header__lang-flag img { display: block; width: 18px; height: auto; }
.iss-header__lang--flags a { padding: 0.35rem; }

/* Hamburger */
.iss-header__toggle {
	display: none;
	width: 44px;
	height: 44px;
	padding: 10px;
	border: 0;
	background: none;
	cursor: pointer;
	flex-direction: column;
	justify-content: space-between;
}
.iss-header__toggle span {
	display: block;
	height: 2px;
	background: currentColor;
	border-radius: 2px;
	transition: transform 0.2s ease, opacity 0.2s ease;
}
.iss-header__toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(11px) rotate(45deg); }
.iss-header__toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.iss-header__toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-11px) rotate(-45deg); }

/* Mobile */
@media (max-width: 1100px) {
	.iss-header__inner { display: flex; justify-content: space-between; }
	.iss-header__toggle { display: flex; color: inherit; }
	.iss-header__nav {
		display: none;
		position: absolute;
		top: 100%;
		left: 0;
		right: 0;
		flex-direction: column;
		align-items: stretch;
		gap: 0.5rem;
		padding: 0.75rem var(--iss-gutter, 1.25rem) 1.25rem;
		background: var(--iss-header-bg);
		box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
		/* Con l'header sticky il pannello resta fisso: deve scorrere da solo. */
		max-height: calc(100vh - var(--iss-header-h, 80px));
		overflow-y: auto;
	}
	.iss-header.is-open .iss-header__nav { display: flex; }
	.iss-header__menu { flex-direction: column; align-items: stretch; gap: 0; }
	.iss-header__menu a { padding: 0.75rem 0.5rem; }
	.iss-header__menu .sub-menu {
		position: static;
		opacity: 1;
		visibility: visible;
		transform: none;
		box-shadow: none;
		padding: 0 0 0 1rem;
	}
	.iss-header__menu .sub-menu .sub-menu { display: none; margin: 0; }
	.iss-header__menu li.is-open > .sub-menu { display: block; }
	.iss-header__menu-heading { padding: 0.75rem 0.5rem; white-space: normal; }
	.iss-header__menu-heading::after,
	.iss-header__menu li:has(> .sub-menu.is-flip) > .iss-header__menu-heading::after { transform: rotate(45deg); order: 0; }
	.iss-header__menu li:has(> .sub-menu.is-flip) > .iss-header__menu-heading { justify-content: space-between; }
	.iss-header__menu li.is-open > .iss-header__menu-heading::after { transform: rotate(-135deg); }
	.iss-header__actions { flex-direction: column; align-items: stretch; gap: 0.75rem; padding-top: 0.5rem; }
	.iss-header__phone, .iss-header__cta { text-align: center; }
	.iss-header__lang { justify-content: center; }
}

/* ---------------------------------------------------------------------------
   ISS: aspetto dell'header Avada (logo a sinistra, menu e bottone a destra).
   --------------------------------------------------------------------------- */
.iss-header {
	--iss-header-color: var(--iss-text, #1c1c1c);
	--iss-header-primary: var(--iss-red-dark, #d62d22); /* non dipende da shortcodes.css */
	box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
}
.iss-header__inner {
	grid-template-columns: auto 1fr auto;
	max-width: none; /* tutta la larghezza, come l'header Avada */
	padding-block: 0.6rem;
	padding-inline: clamp(1rem, 2vw, 2rem);
}
.iss-header__nav > nav { justify-self: end; }
.iss-header__menu { gap: 0.5rem; }
.iss-header__menu a,
.iss-header__menu-heading {
	padding: 0.6rem 0.85rem;
	font-size: 0.94rem;
	font-weight: 400;
}
.iss-header__menu a:hover,
.iss-header__menu .current-menu-item > a,
.iss-header__menu .current-menu-ancestor > a,
.iss-header__menu-heading:hover,
.iss-header__menu li:hover > .iss-header__menu-heading,
.iss-header__menu li.is-open > .iss-header__menu-heading {
	background: none;
	color: var(--iss-red-dark, #d62d22);
}
/* Freccia in giù sulle voci di primo livello con tendina (link o intestazione). */
.iss-header__menu > .menu-item-has-children > a {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}
.iss-header__menu > .menu-item-has-children > a::after,
.iss-header__menu > li > .iss-header__menu-heading::after {
	content: "";
	flex: none;
	width: 0.4em;
	height: 0.4em;
	border: solid currentColor;
	border-width: 0 1.5px 1.5px 0;
	transform: translateY(-0.15em) rotate(45deg);
	opacity: 0.75;
}
.iss-header__menu > li > .iss-header__menu-heading { justify-content: flex-start; gap: 0.5rem; }
/* Tendina */
.iss-header__menu .sub-menu {
	min-width: 240px;
	padding: 0.5rem 0;
	border-radius: 0;
	border-top: 3px solid var(--iss-red, #ef4035);
}
.iss-header__menu .sub-menu a { padding: 0.55rem 1.25rem; font-size: 0.9rem; }
.iss-header__menu .sub-menu a:hover { background: var(--iss-page, #f5f5f7); }
.iss-header .iss-btn { font-weight: 500; font-size: 0.9rem; padding: 0.75em 1.75em; border-radius: 2px; }
.iss-header .iss-btn:hover { opacity: 1; background: #b8241b; }
.iss-header__actions { gap: 1.25rem; margin-left: 0.75rem; }
@media (max-width: 1100px) {
	.iss-header__menu .sub-menu { border-top: 0; padding: 0 0 0 1rem; min-width: 0; }
	.iss-header__menu .sub-menu a:hover { background: none; }
	.iss-header__actions { margin-left: 0; }
	.iss-header__menu > .menu-item-has-children > a::after { display: none; }
}

/* ---------------------------------------------------------------------------
   Mobile
   --------------------------------------------------------------------------- */
/* Sotto i 600px la barra admin di WordPress non è fissa (scorre con la pagina):
   l'header sticky deve agganciarsi al bordo dello schermo, non 46px più in basso. */
@media (max-width: 600px) {
	.admin-bar .iss-header--sticky { top: 0; }
}
@media (max-width: 1100px) {
	/* Logo più piccolo: header basso, più spazio al contenuto (l'attributo inline viene dalle impostazioni). */
	.iss-header__logo img { width: 96px !important; }
	.iss-header__inner { padding-block: 0.5rem; }
	/* Hamburger: niente fondo scuro dei bottoni di GeneratePress su hover/focus/aperto. */
	.iss-header__toggle,
	.iss-header__toggle:hover,
	.iss-header__toggle:focus,
	.iss-header__toggle:active,
	.iss-header__toggle[aria-expanded="true"] { background: none; color: var(--iss-header-color); }
	.iss-header__toggle:focus-visible { outline: 2px solid var(--iss-red-dark, #d62d22); outline-offset: 2px; }
	.iss-header__menu a,
	.iss-header__menu-heading { font-size: 1rem; }
	.iss-header__menu .sub-menu a { font-size: 0.94rem; }
}
