/*
 * Site chrome: header (tokens doc §Header) and footer offset. Loaded on every
 * front-end view and in the editor.
 *
 * States:
 * - default: sticky at the top of the page (in flow, so it never covers
 *   content), white background, dark logo;
 * - transparent (`body.has-transparent-header`, from 1200px): fixed over the
 *   hero, transparent background, white logo and white top-level links;
 * - scrolled (`.is-scrolled`, set by assets/js/header.js): light background,
 *   dark logo.
 * Navigation breakpoint and item styles live in blocks/navigation.css.
 */

.site-header {
	position: sticky;
	top: var(--wp-admin--admin-bar--height, 0px);
	z-index: 1000;
	background-color: var(--wp--preset--color--white);
	transition: background-color 0.2s ease-in-out;
}

/* Below 601px the admin bar scrolls away with the page. */
@media (max-width: 600px) {

	.admin-bar .site-header {
		top: 0;
	}
}

.site-header.is-scrolled {
	background-color: var(--wp--preset--color--gray-100);
}

/* Footer follows the last section directly (no root block gap). */
.site-footer {
	margin-block-start: 0;
}

/*
 * Footer texture over the dark-gray background, as on the old site
 * (texture_footer.png, here a 1920px WebP).
 */
.site-footer__main {
	background-image: url(../images/footer-texture.webp);
	background-position: center;
	background-size: cover;
	background-repeat: no-repeat;
}

/*
 * "Richiedi informazioni": the button sits right of the title side by side;
 * once the columns stack (core breakpoint) it goes under the title, on the
 * left.
 */
@media (max-width: 781px) {

	.site-footer__top .wp-block-columns {
		gap: var(--wp--preset--spacing--40);
	}

	.site-footer__top .wp-block-buttons {
		justify-content: flex-start;
	}
}

/* Brand: two logos, one shown per state. */
.site-brand {
	flex-shrink: 0;
	width: 180px;
}

@media (min-width: 768px) {

	.site-brand {
		width: 200px;
	}
}

/* No inline line box around the logo, so it centres on the bar exactly. */
.site-brand .wp-block-image {
	margin: 0;
	line-height: 0;
}

.site-brand .wp-block-image a {
	display: block;
}

.site-brand .wp-block-image img {
	display: block;
	width: 100%;
	height: auto;
}

.site-brand__logo-white {
	display: none;
}

/*
 * Search (Theme::search_modal): the magnifier opens a modal <dialog>, a white
 * panel dropping from the top over a dimmed, blurred page, with one large
 * underlined field. Same outline icon set as the lock icon (navigation.css).
 * Below 1200px the magnifier comes first and the burger ends the header row.
 */
@media (max-width: 1199px) {

	.site-header__tools > .site-search {
		order: -1;
	}
}

.site-search__toggle,
.site-search__submit,
.site-search__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	border: 0;
	padding: 0.5rem;
	background: transparent;
	color: inherit;
	cursor: pointer;
	transition: color 0.2s ease;
}

.site-search__toggle::before,
.site-search__submit::before,
.site-search__close::before {
	content: "";
	width: var(--ragazzo-header-icon, 1.25rem);
	height: var(--ragazzo-header-icon, 1.25rem);
	background-color: currentcolor;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E") center / contain no-repeat;
}

.site-search__close::before {
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6 6 18'/%3E%3C/svg%3E");
}

.site-search__toggle:is(:hover, :focus-visible),
.site-search__submit:is(:hover, :focus-visible),
.site-search__close:is(:hover, :focus-visible) {
	color: var(--ragazzo-brand-text, var(--wp--preset--color--primary-text));
}

.site-search__dialog {
	box-sizing: border-box;
	width: 100%;
	max-width: none;
	height: auto;
	max-height: 100dvh;
	inset: 0 0 auto;
	margin: 0;
	overflow-y: auto;
	border: 0;
	border-top: 4px solid var(--wp--preset--color--primary);
	padding: 0;
	background: var(--wp--preset--color--white);
	color: var(--wp--preset--color--body-color);

	/*
	 * Entrance: the panel slides down from above the window, then the field
	 * rises in just after it (below). Closing runs the same way back, quicker.
	 */
	opacity: 0;
	transform: translateY(-100%);
	transition:
		opacity 0.2s ease,
		transform 0.25s cubic-bezier(0.4, 0, 1, 1),
		overlay 0.25s allow-discrete,
		display 0.25s allow-discrete;
}

.site-search__dialog[open] {
	opacity: 1;
	transform: none;
	transition:
		opacity 0.2s ease,
		transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
		overlay 0.45s allow-discrete,
		display 0.45s allow-discrete;
}

@starting-style {

	.site-search__dialog[open] {
		opacity: 0;
		transform: translateY(-100%);
	}
}

.site-search__dialog .site-search__form {
	opacity: 0;
	transform: translateY(0.75rem);
	transition:
		opacity 0.15s ease,
		transform 0.15s ease;
}

.site-search__dialog[open] .site-search__form {
	opacity: 1;
	transform: none;
	transition:
		opacity 0.4s ease 0.15s,
		transform 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.15s;
}

@starting-style {

	.site-search__dialog[open] .site-search__form {
		opacity: 0;
		transform: translateY(0.75rem);
	}
}

.site-search__dialog::backdrop {
	background: rgb(30 32 34 / 0%);
	backdrop-filter: blur(0);
	transition:
		background-color 0.3s ease,
		backdrop-filter 0.3s ease,
		overlay 0.35s allow-discrete,
		display 0.35s allow-discrete;
}

.site-search__dialog[open]::backdrop {
	background: rgb(30 32 34 / 55%);
	backdrop-filter: blur(4px);
}

@starting-style {

	.site-search__dialog[open]::backdrop {
		background: rgb(30 32 34 / 0%);
		backdrop-filter: blur(0);
	}
}

.site-search__panel {
	position: relative;
	box-sizing: border-box;
	max-width: calc(var(--wp--style--global--content-size) + var(--wp--style--root--padding-left) + var(--wp--style--root--padding-right));
	margin-inline: auto;
	padding:
		clamp(3.5rem, 2rem + 5vw, 6rem)
		var(--wp--style--root--padding-right)
		clamp(2.5rem, 1.5rem + 4vw, 5rem)
		var(--wp--style--root--padding-left);
}

.site-search__form {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	border-bottom: 1px solid var(--wp--preset--color--primary);
	transition: border-color 0.2s ease;
}

.site-search__form:focus-within {
	border-bottom-color: var(--wp--preset--color--primary-text);
}

.site-search__input {
	flex: 1;
	min-width: 0;
	border: 0;
	padding: 0.5rem 0;
	background: transparent;
	color: inherit;
	font-family: inherit;
	font-size: clamp(1.75rem, 1rem + 3vw, 3.5rem);
	font-weight: 300;
	line-height: 1.2;
	outline: none;
}

.site-search__input::placeholder {
	color: color-mix(in srgb, currentcolor 65%, transparent);
	opacity: 1;
}

.site-search__input::-webkit-search-cancel-button {
	display: none;
}

.site-search__submit {
	--ragazzo-header-icon: clamp(1.5rem, 1rem + 1.5vw, 2.25rem);
}

.site-search__close {
	--ragazzo-header-icon: 1.75rem;
	position: absolute;
	top: clamp(0.75rem, 0.5rem + 1vw, 1.5rem);
	right: var(--wp--style--root--padding-right);
}

/*
 * No page scroll behind the open modal. The scrollbar's space stays reserved,
 * so hiding the scrollbar does not shift the page sideways.
 */
html:has(.site-search__dialog[open]) {
	overflow: hidden;
	scrollbar-gutter: stable;
}

@media (prefers-reduced-motion: reduce) {

	.site-search__dialog,
	.site-search__dialog::backdrop,
	.site-search__dialog .site-search__form {
		transition: none;
	}
}

/* Transparent header over the hero, from the desktop breakpoint. */
@media (min-width: 1200px) {

	.has-transparent-header .site-header {
		position: fixed;
		right: 0;
		left: 0;
	}

	.has-transparent-header .site-header:not(.is-scrolled) {
		background-color: transparent;
		color: var(--wp--preset--color--white);
	}

	/*
	 * Soft dark scrim behind the transparent header so the white logo and
	 * links stay legible over the hero video. Extends past the header and
	 * fades out; hidden once the header turns light on scroll.
	 */
	.has-transparent-header .site-header::before {
		content: "";
		position: absolute;
		inset: 0 0 -1.5rem;
		z-index: -1;
		pointer-events: none;

		/* Eased stops: no visible edge where the fade ends. */
		background: linear-gradient(to bottom, rgb(0 0 0 / 0.42) 0%, rgb(0 0 0 / 0.34) 25%, rgb(0 0 0 / 0.22) 50%, rgb(0 0 0 / 0.1) 72%, rgb(0 0 0 / 0.03) 88%, rgb(0 0 0 / 0) 100%);
		transition: opacity 0.2s ease-in-out;
	}

	.has-transparent-header .site-header.is-scrolled::before {
		opacity: 0;
	}

	.has-transparent-header .site-header:not(.is-scrolled) .site-brand__logo-white {
		display: block;
	}

	.has-transparent-header .site-header:not(.is-scrolled) .site-brand__logo-dark {
		display: none;
	}

	.has-transparent-header .site-header:not(.is-scrolled) .wp-block-navigation__container > .wp-block-navigation-item > .wp-block-navigation-item__content,
	.has-transparent-header .site-header:not(.is-scrolled) .wp-block-navigation__container > .wp-block-navigation-item > .wp-block-navigation__submenu-icon {
		color: var(--wp--preset--color--white);
	}

	.has-transparent-header .site-header:not(.is-scrolled) .wp-block-navigation__container > .wp-block-navigation-item > .wp-block-navigation-item__content:is(:hover, :focus-visible) {
		color: var(--wp--preset--color--primary);
	}
}

/*
 * Search results page (templates/search.html): one row per result divided by
 * thin rules: title, excerpt, "Leggi di più".
 */
.search-results .wp-block-post-template {
	border-bottom: 1px solid var(--wp--preset--color--light-gray);
}

.search-results .search-result {
	padding-block: var(--wp--preset--spacing--40);
	border-top: 1px solid var(--wp--preset--color--light-gray);
}

.search-results .search-result .wp-block-post-title {
	margin: 0;
	font-size: var(--wp--preset--font-size--h-4);
	text-transform: uppercase;
}

.search-results .search-result .wp-block-post-excerpt {
	margin-top: 0.75rem;
}

.search-results .search-result :is(.wp-block-post-excerpt__excerpt, .wp-block-post-excerpt__more-text) {
	margin: 0;
}

.search-results .search-result .wp-block-post-excerpt__more-text {
	margin-top: 0.5rem;
}

.search-results .wp-block-query-pagination {
	margin-top: var(--wp--preset--spacing--50);
}

/*
 * Catalogue (archive-prodotto and the product taxonomy templates), like the
 * old site: filter sidebar on the left behind a thin brand rule, products in
 * three columns on the right. Below 782px (core columns stack) the two filter
 * lists sit side by side above the products.
 */
.catalog-sidebar {
	box-sizing: border-box;
}

.catalog-products .product-card .wp-block-post-title {
	margin-top: 0.75rem;
	font-size: var(--wp--preset--font-size--h-4);
	text-transform: uppercase;
}

.catalog-products .product-card .wp-block-post-title a {
	color: inherit;
	text-decoration: none;
}

.catalog-products .product-card .wp-block-post-title a:is(:hover, :focus-visible) {
	color: var(--ragazzo-brand-text, var(--wp--preset--color--primary-text));
}

.catalog-products .product-card .wp-block-post-terms {
	margin: 0;
}

.catalog-products .product-card .wp-block-post-terms__prefix {
	font-weight: 700;
}

.catalog-products .product-card .wp-block-post-terms a {
	color: inherit;
	text-decoration: none;
}

.catalog-products .product-card .wp-block-post-terms a:is(:hover, :focus-visible) {
	color: var(--ragazzo-brand-text, var(--wp--preset--color--primary-text));
	text-decoration: underline;
}

.catalog-products .product-card .wp-block-post-featured-image img {
	transition: transform 0.3s ease;
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {

	.catalog-products .product-card:hover .wp-block-post-featured-image img {
		transform: scale(1.03);
	}
}

.catalog-products .product-card .wp-block-post-featured-image {
	overflow: hidden;
}

/*
 * Filter and infinite loading (term-grid view.js, core router): the grid dims
 * while the server's next one loads; cards added to it fade in.
 */
.catalog-results .wp-block-post-template {
	transition: opacity 0.2s ease;
}

/* Not while more products load under the list: the whole list would flash. */
.catalog-results.is-loading:not(.is-appending) .wp-block-post-template {
	opacity: 0.55;
}

.catalog-results .wp-block-post-template > li {
	animation: ragazzo-reveal 0.45s ease both;
}

@keyframes ragazzo-reveal {

	from {
		opacity: 0;
		transform: translateY(1rem);
	}
}

@media (prefers-reduced-motion: reduce) {

	.catalog-results .wp-block-post-template > li {
		animation: none;
	}
}

.catalog-more {
	justify-content: center;
	margin-top: var(--wp--preset--spacing--50);
}

@media (min-width: 782px) {

	/*
	 * The filters stay in view while the products scroll: sticky under the
	 * sticky header (75px from 1200px, see header.js), scrolling on their own
	 * if taller than the window. The full-height divider is the products
	 * column's left border, so it still runs the whole list.
	 */
	.catalog-sidebar {
		position: sticky;
		top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--ragazzo-header-height, 75px) + var(--wp--preset--spacing--30));
		align-self: flex-start;
		max-height: calc(100vh - var(--wp-admin--admin-bar--height, 0px) - var(--ragazzo-header-height, 75px) - 2 * var(--wp--preset--spacing--30));
		overflow-y: auto;
		padding-right: clamp(1.5rem, 0.5rem + 2vw, 2.25rem);
		overscroll-behavior: contain;
		scrollbar-width: thin;
	}

	.catalog-products {
		padding-left: clamp(1.5rem, 0rem + 4vw, 5rem);
		border-left: 3px solid var(--wp--preset--color--primary);
	}
}

@media (max-width: 781.98px) {

	.catalog-sidebar {
		display: grid;
		grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
		gap: var(--wp--preset--spacing--40);
		padding-bottom: var(--wp--preset--spacing--40);
		border-bottom: 1px solid var(--wp--preset--color--primary);
	}

	.catalog-sidebar .is-variant-checklist + .is-variant-checklist {
		margin-top: 0;
	}
}

/*
 * Phones: two products per row instead of core's single column below 600px
 * (post-template style.min.css), so the list is half as long; smaller titles
 * to fit the narrower cards.
 */
@media (max-width: 600px) {

	.catalog-products .catalog-query .wp-block-post-template-is-layout-grid[class*="columns-"] {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		column-gap: var(--wp--preset--spacing--30);
	}

	.catalog-products .product-card .wp-block-post-title {
		font-size: var(--wp--preset--font-size--h-6);
		overflow-wrap: anywhere;
	}
}

/*
 * Touch screens: larger tap areas on the small text links (the "Materiali" /
 * "Stili" links on product cards, the breadcrumbs). Vertical padding on an
 * inline link grows what a finger can hit without moving the text; the
 * catalogue's two term rows get a little room so their areas do not overlap.
 */
@media (pointer: coarse) {

	.product-card .wp-block-post-terms a,
	.wp-block-breadcrumbs a {
		padding-block: 0.3rem;
	}

	.catalog-products .product-card .wp-block-post-terms + .wp-block-post-terms {
		margin-top: 0.5rem;
	}
}

/*
 * Product page (single-prodotto): description a little larger than body
 * text, room before the accordion, and "Materiale: Legno  Stile: Evergreen"
 * on one row with bold labels (old site). The intro paragraphs sit in the
 * locked "Testo" box (.prodotto-intro, ragazzo-core LockedContent).
 */
.product-layout .wp-block-post-content > p,
.prodotto-intro > p {
	font-size: clamp(1.125rem, 1rem + 0.35vw, 1.3125rem);
	line-height: 1.55;
}

.product-layout .wp-block-post-content > .wp-block-accordion.is-style-product {
	margin-block-start: var(--wp--preset--spacing--50);
}

.product-terms {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 2rem;
	margin-block: var(--wp--preset--spacing--30);
}

.product-terms > .wp-block-post-terms {
	margin: 0;
}

.product-terms .wp-block-post-terms__prefix {
	font-weight: 700;
}

.product-terms .wp-block-post-terms a {
	color: inherit;
	text-decoration: none;
}

.product-terms .wp-block-post-terms a:is(:hover, :focus-visible) {
	color: var(--ragazzo-brand-text, var(--wp--preset--color--primary-text));
	text-decoration: underline;
}
