/* Castaliaweb — layout responsive (Fase 2). Caricato dopo stile.css; non sostituisce gli stili legacy. */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

.corpo {
	width: 100%;
	max-width: 1024px;
	min-height: 100%;
}

#testo iframe {
	aspect-ratio: 16 / 9;
}

/* Screenshot affiancati (SR/CSE ecc.): leggero ingrandimento rispetto ai 180px originali */
@media (min-width: 901px) {
	#testo center > img {
		width: 310px;
		height: auto;
		max-width: none;
	}

	#testo table img[width="180"],
	#testo table img[width='180'] {
		width: 210px;
		height: auto;
		max-width: none;
	}
}

/* Header e menu principale */
#header_blu {
	height: auto;
	min-height: 120px;
	padding-bottom: 0.5rem;
}

.site-header-inner {
	width: 100%;
	max-width: 1024px;
	margin: 0 auto;
	padding: 0 0.75rem;
}

.site-header-top {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	justify-content: space-between;
	gap: 0.5rem;
}

.site-header-top a img {
	max-width: min(275px, 70vw);
	height: auto;
}

.site-header-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	width: 100%;
	max-width: 1024px;
	margin: 0 auto;
	padding: 0.25rem 0.75rem;
}

.nav-toggle {
	display: none;
	margin: 0.5rem 0.75rem;
	padding: 0.45rem 0.85rem;
	border: 1px solid rgba(255, 255, 255, 0.45);
	border-radius: 4px;
	background: rgba(154, 66, 44, 0.85);
	color: #fff;
	font: bold 12px Armata, sans-serif;
	cursor: pointer;
}

.nav-toggle:hover { background: rgba(154, 66, 44, 1); }

.site-nav { flex: 1 1 auto; min-width: 0; }

.site-lang {
	flex: 0 0 auto;
	font-size: 11px;
	color: #fff;
	text-align: right;
	white-space: nowrap;
}

.site-lang a { color: #fff !important; text-decoration: none !important; }

/* Pagine prodotto: desktop = layout tabella originale (menu | testo | quickLinks) */

@media (min-width: 901px) {
	.layout-product-row > td > table[width="914"],
	.layout-product-row > td > table {
		width: 914px;
		max-width: 100%;
	}

	.layout-product-row > td > table > tbody > tr {
		display: table-row;
	}

	.layout-product-row > td > table > tbody > tr > td[valign="top"]:first-child {
		width: auto;
		vertical-align: top;
	}

	.layout-product-row > td > table > tbody > tr > td:last-child {
		width: auto;
		vertical-align: top;
	}
}

/* Home: sidebar + main affiancati su desktop */
@media (min-width: 901px) {
	.layout-home-row {
		display: table-row;
	}

	.layout-home-sidebar,
	.layout-home-main {
		display: table-cell;
		vertical-align: top;
	}

	.layout-home-sidebar {
		width: 250px;
	}
}

/* Home: mobile impila sidebar e main */
@media (max-width: 900px) {
	.layout-home-sidebar,
	.layout-home-main {
		display: block;
		width: 100%;
		padding: 1rem !important;
	}
}

/* Footer */
.site-footer {
	height: auto !important;
	min-height: 80px;
	padding: 1rem 0.75rem;
}

.site-footer #piede { line-height: 1.6; }

.site-footer #piede { line-height: 1.6; }

.product-nav-toggle {
	display: none;
}

/* Mobile */
@media (max-width: 900px) {
	html, body {
		overflow-x: hidden;
		max-width: 100%;
	}

	#testo,
	#titoli,
	.corpo,
	.corpo td,
	.corpo th,
	.site-footer #piede {
		overflow-wrap: break-word;
		word-wrap: break-word;
	}

	.site-footer #piede {
		white-space: normal;
		letter-spacing: 0;
		padding-left: 0.5rem;
		padding-right: 0.5rem;
	}

	/* Tutte le pagine .corpo: tabella esterna e contenuto dentro viewport */
	.corpo > tbody > tr {
		display: block;
	}

	.corpo > tbody > tr > td {
		display: block;
		width: 100% !important;
		max-width: 100%;
		box-sizing: border-box;
	}

	.corpo table[width="914"],
	.corpo table[width="90%"],
	.corpo table[width="600"],
	.corpo table[width],
	#testo table[width],
	.corpo > tbody > tr > td > table,
	.corpo table table {
		width: 100% !important;
		max-width: 100%;
	}

	.corpo td[style*="padding"],
	.layout-product-row td[style*="padding"] {
		padding: 1rem !important;
	}

	#testo img[align="left"],
	#testo img[align="right"],
	.corpo img[align="left"],
	.corpo img[align="right"] {
		float: none !important;
		display: block;
		margin: 0 auto 1rem !important;
		max-width: 100%;
		height: auto;
	}

	.corpo > tbody > tr > td > table > tbody > tr {
		display: block;
	}

	.corpo > tbody > tr > td > table > tbody > tr > td {
		display: block;
		width: 100% !important;
		box-sizing: border-box;
		padding: 1rem !important;
	}

	.corpo td[width],
	.corpo th[width] {
		width: 100% !important;
		height: auto !important;
	}

	#testo img,
	#testo iframe,
	.corpo img {
		max-width: 100%;
		height: auto;
	}

	/* Pagine SR/CSE con testo + immagine affiancati: impila e mantieni screenshot leggibili */
	#testo table tr {
		display: block;
	}

	#testo table td {
		display: block;
		width: 100% !important;
		box-sizing: border-box;
	}

	#testo table img[width] {
		width: auto;
		max-width: min(100%, 300px);
		height: auto;
		display: block;
		margin: 0.75rem auto 0;
	}

	.nav-toggle { display: inline-block; }

	.site-nav:not(.is-open) #Menu1 {
		display: none !important;
	}

	.site-nav.is-open #Menu1 {
		display: block !important;
		width: 100%;
	}

	.site-nav.is-open #Menu1,
	.site-nav.is-open #Menu1 ul {
		position: static !important;
		opacity: 1 !important;
		float: none !important;
		width: 100% !important;
		margin: 0 !important;
		padding: 0 !important;
		border: none !important;
		box-shadow: none !important;
	}

	.site-nav.is-open #Menu1 ul {
		display: none !important;
		visibility: visible !important;
	}

	.site-nav.is-open #Menu1 li.is-expanded > ul {
		display: block !important;
	}

	.site-nav.is-open #Menu1 li {
		display: block !important;
		float: none !important;
		width: 100% !important;
		border-bottom: 1px solid rgba(255, 255, 255, 0.12);
	}

	.site-nav.is-open #Menu1 li.has-sub > a::after {
		content: " +";
		float: right;
		font-weight: normal;
		opacity: 0.85;
	}

	.site-nav.is-open #Menu1 li.is-expanded.has-sub > a::after {
		content: " \2212";
	}

	.site-nav.is-open #Menu1 a {
		display: block !important;
		padding: 0.55rem 0.75rem !important;
	}

	.site-nav.is-open #Menu1 ul a {
		padding-left: 1.1rem !important;
		background: rgba(0, 0, 0, 0.12);
	}

	.site-nav.is-open #Menu1 ul ul a {
		padding-left: 1.5rem !important;
	}

	.site-nav.is-open #Menu1 ul ul ul a {
		padding-left: 1.9rem !important;
	}

	.site-nav.is-open #Menu1 ul ul ul ul a {
		padding-left: 2.3rem !important;
	}

	#menu_prodotti {
		margin-bottom: 0.75rem;
	}

	.product-nav-toggle {
		display: block;
		width: 100%;
		margin: 0 0 0.5rem;
		padding: 0.5rem 0.85rem;
		border: 1px solid rgba(255, 255, 255, 0.35);
		border-radius: 4px;
		background: rgba(15, 38, 60, 0.9);
		color: #fff;
		font: bold 12px Armata, sans-serif;
		text-align: left;
		cursor: pointer;
	}

	#menu_prodotti:not(.is-open) #Menu2 {
		display: none !important;
	}

	#menu_prodotti #Menu2,
	#menu_prodotti #Menu2 ul {
		position: static !important;
		float: none !important;
		width: 100% !important;
		box-shadow: none !important;
		margin: 0 !important;
		border: none !important;
	}

	#menu_prodotti #Menu2 ul {
		display: none !important;
		visibility: visible !important;
		opacity: 1 !important;
	}

	#menu_prodotti #Menu2 li.is-expanded > ul {
		display: block !important;
	}

	#menu_prodotti #Menu2 li {
		display: block !important;
		float: none !important;
		width: 100% !important;
	}

	#menu_prodotti #Menu2 li.has-sub > a::after {
		content: " +";
		float: right;
		font-weight: normal;
		opacity: 0.85;
	}

	#menu_prodotti #Menu2 li.is-expanded.has-sub > a::after {
		content: " \2212";
	}

	#menu_prodotti #Menu2 a {
		display: block !important;
		padding: 0.5rem 0.75rem !important;
		border-bottom: 1px solid rgba(255, 255, 255, 0.12);
	}

	#menu_prodotti #Menu2 ul a {
		padding-left: 1.25rem !important;
	}

	#menu_prodotti #Menu2 ul ul a {
		padding-left: 1.75rem !important;
	}

	/* Pagine prodotto: impila menu, testo e quickLinks */
	.layout-product-row > td {
		display: block;
		width: 100% !important;
	}

	.layout-product-row > td > table[width="914"],
	.layout-product-row > td > table {
		width: 100% !important;
		max-width: 100%;
	}

	.layout-product-row > td > table > tbody > tr {
		display: block;
	}

	.layout-product-row > td > table > tbody > tr > td {
		display: block;
		width: 100% !important;
		box-sizing: border-box;
	}

	.layout-product-row #menu_prodotti {
		margin-bottom: 1rem;
	}

	.layout-product-row td[style*="padding"] {
		padding: 0 1rem 1.5rem !important;
	}

	/* Pagine con menu prodotto laterale (SA, CSER, …) senza classe layout-product */
	.corpo > tbody > tr > td > table[width="914"] > tbody > tr > td[valign="top"]:first-child {
		width: 100% !important;
	}

	.corpo marquee { height: auto !important; max-height: 240px; }

	.corpo table[width="250"],
	.corpo td[width="250"],
	.corpo td[width="110"] {
		display: block !important;
		width: 100% !important;
	}

	#quick_sargon a,
	#quick_cse a,
	#quick_samba a {
		margin: 0 auto;
	}

	/* rugarli.asp: su telefono impila foto e testo (desktop usa margin-left:245px) */
	.layout-product-row img[align="left"],
	.layout-product-row img[align="right"] {
		float: none !important;
		display: block;
		margin: 0 auto 1rem !important;
		max-width: min(280px, 85vw);
		width: auto !important;
		height: auto;
	}

	.layout-product-row div[style*="margin-left:245px"],
	.layout-product-row div[style*="margin-left: 245px"] {
		margin-left: 0 !important;
		width: 100% !important;
		max-width: 100%;
		box-sizing: border-box;
	}
}
