/* =====================================================================
   Uuden ilmeen sivutaso (cs-site.css)
   ---------------------------------------------------------------------
   Lasiheader (pilleri), footer (pastelli + jättiteksti) ja sivuasettelu.
   Kaikki säännöt koskevat vain sivuja, joiden bodyssa on luokka
   .cs-uusi-ilme. Luokan lisää functions.php:
     - sivuille, joilla on uusi hero (.cs-hero),
     - esikatseluun osoitteella ?uusi-ilme=1,
     - kaikille sivuille, kun asetus cosmetsky_uusi_ilme = 'kaikkialla'.
   Header/footer pysyvät siis vanhoina muualla, kunnes asetus kytketään.
   Korkeudet (--cs-hero-offset, --cs-header-h) mittaa cs-design.js.
   ===================================================================== */

body.cs-uusi-ilme {
	/* sisällön reuna: root padding tai leveällä näytöllä keskitetyn 1600px:n reuna */
	--cs-edge: max(var(--wp--style--root--padding-left), calc((100vw - 1600px) / 2));
	--cs-pill-inset: 12px;
	--cs-pastel:
		radial-gradient(ellipse 70% 140% at 0% 0%, rgba(222, 242, 253, 0.95) 0%, rgba(222, 242, 253, 0) 75%),
		radial-gradient(ellipse 70% 140% at 100% 100%, rgba(253, 229, 242, 0.95) 0%, rgba(253, 229, 242, 0) 75%),
		linear-gradient(135deg, #e2f3fd 0%, #eef7fd 28%, #f8f7fb 50%, #fdf1f6 72%, #fde6f1 100%);
	/* Header-pilleri: vaalea vino pastelli (vaaleansininen vasemmalla
	   ylhäällä → lähes valkoinen → vaaleanpunainen oikealla alhaalla),
	   läpikuultava lasia varten. Sävyt käyttäjän referenssikuvasta. */
	--cs-pastel-glass:
		linear-gradient(120deg, rgba(226, 242, 253, 0.85) 0%, rgba(236, 247, 254, 0.75) 30%, rgba(251, 246, 251, 0.7) 55%, rgba(254, 238, 247, 0.8) 80%, rgba(252, 228, 241, 0.85) 100%);
	overflow-x: clip;
}

@media (max-width: 781px) {
	body.cs-uusi-ilme {
		--cs-pill-inset: 8px;
	}
}

/* ---------------------------------------------------------------------
   Sivuasettelu sivuilla, joilla on uusi hero
   --------------------------------------------------------------------- */

/* Sisältö leveämmäksi (enintään 1600px), jotta osiot ja kortit alkavat
   ja loppuvat samasta kohdasta kuin header. */
body.cs-uusi-ilme main:has(.cs-hero) {
	--wp--style--global--content-size: 1600px;
	--wp--style--global--wide-size: 1600px;
}

/* Hero alkaa 12px headerin alapuolelta ja täyttää loput näkymästä
   (16px jää alle, jotta pyöristetyt alakulmat näkyvät).
   Etusivulla sisältö on käärittynä <div data-nosnippet> -elementtiin
   (cosmetsky-woo-core/misc-integrations.php, estää Googlea poimimasta
   hakutulosotetta etusivun tekstistä), joten valitsimet kattavat myös sen. */
body.cs-uusi-ilme main:has(> .wp-block-post-content > :is(.cs-hero, .cs-hero-row):first-child),
body.cs-uusi-ilme main:has(> .wp-block-post-content > [data-nosnippet] > :is(.cs-hero, .cs-hero-row):first-child) {
	margin-top: var(--cs-pill-inset) !important;
}

body.cs-uusi-ilme .wp-block-post-content > :is(.cs-hero, .cs-hero-row):first-child,
body.cs-uusi-ilme .wp-block-post-content > [data-nosnippet] > :is(.cs-hero, .cs-hero-row):first-child {
	margin-top: 0 !important;
}

/* Desktopilla hero ei täytä koko näkymää, vaan on noin 60 % näkymän
   korkeudesta (460–640px), jolloin osastoneliöt näkyvät heti alla. */
@media (min-width: 782px) {
	body.cs-uusi-ilme .cs-hero {
		min-height: clamp(460px, 62vh, 640px) !important;
	}
}

/* Viimeisen ison kortin ja footerin väli */
body.cs-uusi-ilme .wp-block-post-content > .is-style-cs-full-bleed:last-child,
body.cs-uusi-ilme .wp-block-post-content > [data-nosnippet] > .is-style-cs-full-bleed:last-child {
	margin-bottom: clamp(32px, 4vw, 64px) !important;
}

body.cs-uusi-ilme main:has(> .wp-block-post-content > .is-style-cs-full-bleed:last-child) + footer.wp-block-template-part,
body.cs-uusi-ilme main:has(> .wp-block-post-content > [data-nosnippet] > .is-style-cs-full-bleed:last-child) + footer.wp-block-template-part {
	margin-top: 0 !important;
}

/* ---------------------------------------------------------------------
   Lasiheader
   Desktop: yksi rivi — valikko + logo | haku tarkalleen keskellä | ikonit.
   Mobiili: valikko, logo, haku-/tili-/korikuvake; hakukenttä avautuu
   suurennuslasista pillerin sisään (cs-design.js, .cs-search-open).
   Lasi on ::before-kerroksessa: backdrop-filter itse headerissa tekisi
   siitä minikorin kiinteän sivupaneelin asemointikehyksen.
   --------------------------------------------------------------------- */
body.cs-uusi-ilme header.wp-block-template-part {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 720px) minmax(0, 1fr);
	align-items: center;
	column-gap: clamp(0.75rem, 2vw, 1.75rem);
	padding: calc(var(--cs-pill-inset) + 10px) calc(var(--cs-edge) + 18px) 10px;
	background: transparent;
	border-bottom: 0;
	isolation: isolate;
}

body.cs-uusi-ilme header.wp-block-template-part::before {
	content: "";
	position: absolute;
	inset: var(--cs-pill-inset) var(--cs-edge) 0;
	z-index: -1;
	border: 1px solid rgba(255, 255, 255, 0.55);
	border-radius: 999px;
	background: var(--cs-pastel-glass);
	-webkit-backdrop-filter: blur(18px) saturate(160%);
	backdrop-filter: blur(18px) saturate(160%);
	box-shadow: 0 8px 28px rgba(120, 40, 70, 0.10);
}

/* Header pysyy aina näkyvissä (header-scroll.js:n piilotus pois) */
body.cs-uusi-ilme header.wp-block-template-part.header-hidden {
	transform: none;
}

/* Ylärivin ryhmä puretaan, jotta sen osat ja hakurivi asettuvat samaan
   ruudukkoon headerin rakennetta muuttamatta. */
body.cs-uusi-ilme .cosmetsky-header {
	display: contents;
}

body.cs-uusi-ilme .cosmetsky-header-start,
body.cs-uusi-ilme .cosmetsky-header-logo {
	grid-column: 1;
	grid-row: 1;
	justify-self: start;
}

body.cs-uusi-ilme .cosmetsky-header-logo {
	margin: 0 0 0 41px;
}

body.cs-uusi-ilme .cosmetsky-header-logo img {
	width: auto;
	height: 36px;
}

body.cs-uusi-ilme .cosmetsky-search-row {
	grid-column: 2;
	grid-row: 1;
	justify-self: center;
	width: 100%;
	max-width: 720px;
	margin: 0;
	padding: 0;
}

body.cs-uusi-ilme .cosmetsky-header-actions {
	grid-column: 3;
	grid-row: 1;
	justify-self: end;
}

/* Hampurilainen: kolme 4px viivaa yhtenä SVG:nä (yhtä paksut kaikilla
   näyttötiheyksillä), logon kirjainten pystykeskellä. */
body.cs-uusi-ilme .custom-menu-toggle-btn {
	width: 30px;
	height: 36px;
	border-radius: 0;
	background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='26' viewBox='0 0 28 26'%3E%3Cg fill='%231d1d1d'%3E%3Crect y='0' width='28' height='4' rx='2'/%3E%3Crect y='11' width='28' height='4' rx='2'/%3E%3Crect y='22' width='28' height='4' rx='2'/%3E%3C/g%3E%3C/svg%3E") center 5px / 28px 26px no-repeat;
}

body.cs-uusi-ilme .custom-menu-toggle-btn svg {
	display: none;
}

body.cs-uusi-ilme .cosmetsky-search-field {
	padding: 0.6rem 1rem;
	border-color: rgba(255, 255, 255, 0.9);
	background: rgba(255, 255, 255, 0.7);
	box-shadow: 0 2px 12px rgba(120, 40, 70, 0.08);
}

body.cs-uusi-ilme .cs-search-results {
	top: calc(100% + 8px);
	left: 0;
	right: 0;
}

body.cs-uusi-ilme .wc-block-mini-cart__button:hover,
body.cs-uusi-ilme .cosmetsky-account-link:hover {
	background-color: rgba(255, 255, 255, 0.55);
}

/* Mobiilin hakukuvake (lisätään cs-design.js:ssä) näkyy vain mobiilissa */
.cs-search-toggle {
	display: none;
}

@media (max-width: 781px) {
	body.cs-uusi-ilme header.wp-block-template-part {
		grid-template-columns: auto auto minmax(0, 1fr) auto;
		row-gap: 0;
		padding: calc(var(--cs-pill-inset) + 10px) calc(var(--cs-edge) + 12px) 10px;
	}

	body.cs-uusi-ilme header.wp-block-template-part.cs-search-open {
		row-gap: 10px;
	}

	body.cs-uusi-ilme header.wp-block-template-part.cs-search-open::before {
		border-radius: 26px;
	}

	body.cs-uusi-ilme .cosmetsky-header-start {
		grid-column: 1;
	}

	body.cs-uusi-ilme .cosmetsky-header-logo {
		grid-column: 2;
		margin: 0;
	}

	body.cs-uusi-ilme .cosmetsky-header-logo img {
		height: 30px;
	}

	body.cs-uusi-ilme .cosmetsky-header-actions {
		grid-column: 4;
		gap: 0.15rem;
	}

	body.cs-uusi-ilme .cosmetsky-search-row {
		grid-column: 1 / -1;
		grid-row: 2;
		max-width: none;
	}

	body.cs-uusi-ilme header.wp-block-template-part:not(.cs-search-open) .cosmetsky-search-row {
		display: none;
	}

	body.cs-uusi-ilme .custom-menu-toggle-btn {
		width: 26px;
		height: 30px;
		background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='22' viewBox='0 0 24 22'%3E%3Cg fill='%231d1d1d'%3E%3Crect y='0' width='24' height='4' rx='2'/%3E%3Crect y='9' width='24' height='4' rx='2'/%3E%3Crect y='18' width='24' height='4' rx='2'/%3E%3C/g%3E%3C/svg%3E") center 4px / 24px 22px no-repeat;
	}

	body.cs-uusi-ilme .cs-search-toggle {
		display: inline-flex;
	}
}

/* ---------------------------------------------------------------------
   Footer: valkoinen, alareunasta nouseva pastelli (sininen vasemmalla,
   pinkki oikealla) ja valkoinen jättiteksti "COSMETSKY" aivan alhaalla.
   Tumman footerin valkoiset tekstit/logo/viivat käännetään tummiksi.
   --------------------------------------------------------------------- */
body.cs-uusi-ilme .cosmetsky-footer.has-background {
	container-type: inline-size;
	overflow: hidden;
	padding-bottom: 0 !important;
	color: var(--wp--preset--color--contrast) !important;
	/* Vaalea vino pastelli kuten headerissa (referenssikuvan sävyt),
	   alareunassa hieman syvempänä, jotta valkoinen jättiteksti erottuu.
	   Yläosa häipyy valkoiseen. */
	background:
		linear-gradient(to bottom, #ffffff 0%, rgba(255, 255, 255, 0.6) 25%, rgba(255, 255, 255, 0) 55%),
		linear-gradient(to top, rgba(200, 200, 235, 0.32) 0%, rgba(200, 200, 235, 0) 40%),
		linear-gradient(135deg, #cfe8fa 0%, #e4f3fe 25%, #faf4fa 52%, #fce9f4 75%, #f3cde2 100%),
		#ffffff !important;
}

body.cs-uusi-ilme .cosmetsky-footer > .wp-block-group {
	max-width: 1600px;
}

body.cs-uusi-ilme .cosmetsky-footer a,
body.cs-uusi-ilme .cosmetsky-footer .wp-block-navigation a,
body.cs-uusi-ilme .cosmetsky-footer .trust-badges-label,
body.cs-uusi-ilme .cosmetsky-footer h3,
body.cs-uusi-ilme .cosmetsky-footer p {
	color: var(--wp--preset--color--contrast);
}

body.cs-uusi-ilme .cosmetsky-footer .wp-block-image img {
	filter: brightness(0); /* valkoinen logo → musta */
}

body.cs-uusi-ilme #omnisend-form-trigger,
body.cs-uusi-ilme .cosmetsky-footer .wp-social-link {
	border-color: var(--wp--preset--color--contrast);
}

body.cs-uusi-ilme .cosmetsky-footer [style*="border-bottom-color"] {
	border-bottom-color: rgba(0, 0, 0, 0.1) !important;
}

body.cs-uusi-ilme .cosmetsky-footer [style*="border-top-color"] {
	border-top-color: rgba(0, 0, 0, 0.1) !important;
}

/* Jättiteksti: koko sisältöleveys (Barlow Condensed 700 on tällä
   tekstillä 4.16em leveä), valkoinen, alaosa häipyy läpinäkyväksi.
   Koriste: ruudunlukijoille tyhjä vaihtoehtoinen teksti. */
body.cs-uusi-ilme .cosmetsky-footer::after {
	content: "COSMETSKY" / "";
	display: block;
	width: 100%;
	max-width: 1600px;
	margin: clamp(1.5rem, 4cqw, 3rem) auto 0;
	font-family: var(--wp--preset--font-family--barlow-condensed);
	font-weight: 700;
	font-size: calc(min(100cqw, 1600px) / 4.16);
	line-height: 0.74;
	letter-spacing: -0.01em;
	text-align: center;
	white-space: nowrap;
	color: #ffffff;
	-webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, 0.05) 0%, rgba(0, 0, 0, 0.35) 45%, rgba(0, 0, 0, 0.75) 100%);
	mask-image: linear-gradient(to top, rgba(0, 0, 0, 0.05) 0%, rgba(0, 0, 0, 0.35) 45%, rgba(0, 0, 0, 0.75) 100%);
	pointer-events: none;
	user-select: none;
}

@media (max-width: 781px) {
	/* Mobiilissa 1.5× suurempi ja keskitetty: reunakirjaimet rajautuvat */
	body.cs-uusi-ilme .cosmetsky-footer::after {
		width: max-content;
		max-width: none;
		margin-left: 50%;
		margin-right: 0;
		transform: translateX(-50%);
		font-size: calc(100cqw / 4.16 * 1.5);
	}
}
