/*
Theme Name: Il Banco del Formaggio
Theme URI: https://brainfarm.eu
Author: Brainfarm
Author URI: https://brainfarm.eu
Description: Block theme che replica il design del sito Il Banco del Formaggio (Laravel + Inertia). Palette crema/terracotta, Fraunces + Inter, pattern per home, chi siamo, contatti e negozio WooCommerce.
Requires at least: 6.6
Tested up to: 6.8
Requires PHP: 7.4
Version: 1.0.0
License: GPL-2.0-or-later
Text Domain: ilbancodelformaggio
*/

/*
 * Everything that theme.json cannot express: hover/transition states,
 * the overlay header, the gallery grid, form fields and WooCommerce tweaks.
 * Colours always go through the palette variables so the "Notte" style
 * variation keeps working.
 */

:root {
	--bdf-ring: color-mix(in srgb, var(--wp--preset--color--primary) 50%, transparent);
}

html {
	scroll-behavior: smooth;
}

body {
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

/* Header, main and footer sit flush: sections carry their own padding. */
.wp-site-blocks > * + * {
	margin-block-start: 0;
}

/* Emphasis inside secondary (stone) text goes back to ink, as in the app. */
.has-muted-color strong {
	color: var(--wp--preset--color--foreground);
}

/* ---------------------------------------------------------------- Header */

/* Mirrors the .site-header of www.ilbancodelformaggio.it. */
.bdf-header {
	position: sticky;
	top: 0;
	z-index: 50;
	background-color: color-mix(in srgb, var(--wp--preset--color--background) 96%, transparent);
	box-shadow: 0 1px 0 var(--wp--preset--color--border);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	transition: background-color 0.3s ease, box-shadow 0.3s ease, color 0.3s ease;
}

.bdf-header .wp-block-site-logo img {
	width: auto;
	height: 52px;
}

.bdf-header .wp-block-site-title {
	font-size: 1.15rem;
}

.admin-bar .bdf-header {
	top: var(--wp-admin--admin-bar--height, 32px);
}

/* Over a hero the header is fixed and transparent until the page scrolls. */
body:has(.bdf-hero) .bdf-header {
	position: fixed;
	left: 0;
	right: 0;
}

body:has(.bdf-hero) .bdf-header:not(.is-scrolled) {
	background-color: transparent;
	box-shadow: none;
	backdrop-filter: none;
	-webkit-backdrop-filter: none;
	color: var(--wp--preset--color--white);
}

body:has(.bdf-hero) .bdf-header:not(.is-scrolled) .wp-block-navigation__container a,
body:has(.bdf-hero) .bdf-header:not(.is-scrolled) .wp-block-navigation__responsive-container-open,
body:has(.bdf-hero) .bdf-header:not(.is-scrolled) .bdf-header__lang a,
body:has(.bdf-hero) .bdf-header:not(.is-scrolled) .wc-block-mini-cart__button {
	color: var(--wp--preset--color--white);
}

/* Menu: ink, 600, terracotta underline on hover and on the current item. */
.bdf-header .wp-block-navigation__container a {
	padding: 0.3em 0;
	border-bottom: 2px solid transparent;
	color: var(--wp--preset--color--foreground);
	font-size: 0.95rem;
	font-weight: 600;
	text-decoration: none;
	transition: color 0.2s ease, border-color 0.2s ease;
}

.bdf-header .wp-block-navigation__container a:hover,
.bdf-header .wp-block-navigation .current-menu-item > a,
.bdf-header .wp-block-navigation .bdf-nav-current > a,
.bdf-header .wp-block-navigation__container a[aria-current="page"] {
	border-bottom-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--primary);
}

body:has(.bdf-hero) .bdf-header:not(.is-scrolled) .wp-block-navigation__container a:hover,
body:has(.bdf-hero) .bdf-header:not(.is-scrolled) .current-menu-item > a,
body:has(.bdf-hero) .bdf-header:not(.is-scrolled) .bdf-nav-current > a,
body:has(.bdf-hero) .bdf-header:not(.is-scrolled) a[aria-current="page"] {
	border-bottom-color: var(--wp--preset--color--white);
	color: var(--wp--preset--color--white);
}

.bdf-header .bdf-header__lang {
	margin: 0;
	font-size: 0.82rem;
	font-weight: 700;
	letter-spacing: 0.08em;
}

.bdf-header .bdf-header__lang a {
	color: var(--wp--preset--color--foreground);
	text-decoration: none;
	transition: color 0.2s ease;
}

.bdf-header .bdf-header__lang a:hover {
	color: var(--wp--preset--color--primary);
}

.bdf-header .wc-block-mini-cart__button {
	color: var(--wp--preset--color--foreground);
	padding: 0;
}

.bdf-header .wc-block-mini-cart__button:hover {
	color: var(--wp--preset--color--primary);
}

/* Mobile: logo · cart · hamburger (as in the original). */
@media (max-width: 599px) {
	.bdf-header .bdf-header__right {
		margin-left: auto;
	}

	.bdf-header .wp-block-site-title {
		display: none;
	}

	.bdf-header .bdf-header__nav {
		order: 3;
	}
}

/* Mobile menu overlay: bordered list like the original drawer. */
.bdf-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item {
	width: 100%;
	border-bottom: 1px solid var(--wp--preset--color--border);
	padding-block: 0.75rem;
}

/* ------------------------------------------------------------------ Hero */

.bdf-hero > .wp-block-cover__inner-container {
	position: static;
}

.bdf-hero .bdf-hero__content {
	position: relative;
	z-index: 2;
}

.bdf-hero .bdf-scroll-cue {
	position: absolute;
	bottom: 1.5rem;
	left: 50%;
	z-index: 2;
	margin: 0;
	transform: translateX(-50%);
	opacity: 0.8;
}

.bdf-hero .bdf-scroll-cue img {
	border-radius: 0;
}

/* Compact page hero: height comes from padding, dark fallback without a photo. */
.wp-block-cover.bdf-hero--page {
	min-height: 0;
	background-color: #2A2620;
}

/* --------------------------------------------------------------- Buttons */

.wp-block-button__link,
.wp-element-button {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	transition: all 0.2s ease;
}

.wp-block-button:not(.is-style-outline-light):not(.is-style-outline) .wp-block-button__link:hover {
	transform: translateY(-2px);
}

.wp-block-button.is-style-outline-light .wp-block-button__link:hover {
	background-color: var(--wp--preset--color--white);
	color: var(--wp--preset--color--foreground);
}

/* On the terracotta strip the outline button turns terracotta on hover. */
.has-primary-background-color .wp-block-button.is-style-outline-light .wp-block-button__link:hover {
	color: var(--wp--preset--color--primary);
}

.wp-block-button.is-style-dark .wp-block-button__link:hover {
	background-color: color-mix(in srgb, var(--wp--preset--color--foreground) 90%, transparent);
	color: var(--wp--preset--color--background);
}

.wp-block-button.is-style-light .wp-block-button__link:hover {
	background-color: var(--wp--preset--color--white);
	color: var(--wp--preset--color--primary);
}

.wp-block-button.is-style-outline .wp-block-button__link:hover {
	background-color: var(--wp--preset--color--secondary);
	color: var(--wp--preset--color--foreground);
}

.wp-block-button__link:focus-visible,
.wp-element-button:focus-visible {
	outline: 3px solid var(--bdf-ring);
	outline-offset: 2px;
}

/* ----------------------------------------------------------------- Cards */

.wp-block-group.is-style-card,
.wp-block-group.is-style-product-card {
	position: relative;
	overflow: hidden;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.wp-block-group.is-style-card:hover {
	transform: translateY(-6px);
	box-shadow: var(--wp--preset--shadow--card-hover);
}

.wp-block-group.is-style-product-card:hover {
	transform: translateY(-4px);
	box-shadow: 0 0 0 1px color-mix(in srgb, var(--wp--preset--color--foreground) 10%, transparent), var(--wp--preset--shadow--card-hover);
}

/* The whole specialty card is clickable through its title link. */
.wp-block-group.is-style-card .wp-block-heading a {
	color: inherit;
	text-decoration: none;
}

.wp-block-group.is-style-card .wp-block-heading a::after {
	content: "";
	position: absolute;
	inset: 0;
}

.wp-block-group.is-style-card .bdf-card__icon img {
	border-radius: 0;
}

.wc-block-product > .wp-block-group.is-style-product-card {
	height: 100%;
}

.wp-block-group.is-style-product-card .bdf-product-card__body {
	flex: 1;
}

.wp-block-group.is-style-product-card .wp-block-read-more {
	margin-top: auto;
}

.wp-block-group.is-style-product-card .wp-block-post-title a {
	color: inherit;
	text-decoration: none;
}

.wp-block-group.is-style-product-card .wc-block-components-product-image,
.wp-block-group.is-style-product-card .wc-block-components-product-image img {
	border-radius: 0;
	margin: 0;
}

/* -------------------------------------------------------------- Images */

.wp-block-image.is-style-elevated img {
	border-radius: var(--wp--custom--radius--lg);
	box-shadow: var(--wp--preset--shadow--photo);
}

.wp-block-image img {
	border-radius: inherit;
}

/* Gallery mosaic: 2 cols on mobile, 4 from 640px; wide tiles span 2 (or 3). */
.bdf-gallery {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 0.625rem;
}

.bdf-gallery > * {
	margin: 0 !important;
}

.bdf-gallery .wp-block-image img {
	width: 100%;
	height: 100%;
	border-radius: var(--wp--custom--radius--md);
}

.bdf-gallery .bdf-span-2,
.bdf-gallery .bdf-span-3 {
	grid-column: span 2;
}

@media (min-width: 640px) {
	.bdf-gallery {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	.bdf-gallery .bdf-span-3 {
		grid-column: span 3;
	}
}

/* ---------------------------------------------------------------- Footer */

.bdf-text-85 {
	color: color-mix(in srgb, currentColor 85%, transparent);
}

.bdf-footer .bdf-text-70,
.bdf-text-70 {
	color: color-mix(in srgb, var(--wp--preset--color--background) 70%, transparent);
}

.bdf-footer__bottom {
	border-top: 1px solid color-mix(in srgb, var(--wp--preset--color--background) 10%, transparent);
	color: color-mix(in srgb, var(--wp--preset--color--background) 60%, transparent);
}

.bdf-footer a {
	color: color-mix(in srgb, var(--wp--preset--color--background) 85%, transparent);
	text-decoration: none;
	transition: color 0.2s ease;
}

.bdf-footer a:hover {
	color: var(--wp--preset--color--background);
	text-decoration: none;
}

.bdf-footer-menu {
	list-style: none;
	padding: 0;
	margin: 0;
}

.bdf-footer-menu li + li {
	margin-top: 0.5rem;
}

/* --------------------------------------------------------- Social links */

.wp-block-social-links.is-style-round-soft,
.wp-block-social-links.is-style-round-dark {
	gap: 0.75rem;
}

.wp-block-social-links.is-style-round-soft .wp-social-link,
.wp-block-social-links.is-style-round-dark .wp-social-link {
	width: 2.5rem;
	height: 2.5rem;
	border-radius: 9999px;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.wp-block-social-links.is-style-round-soft .wp-social-link a,
.wp-block-social-links.is-style-round-dark .wp-social-link a {
	width: 100%;
	height: 100%;
	justify-content: center;
	padding: 0;
}

.wp-block-social-links.is-style-round-soft .wp-social-link svg,
.wp-block-social-links.is-style-round-dark .wp-social-link svg {
	width: 1rem;
	height: 1rem;
}

.wp-block-social-links.is-style-round-soft .wp-social-link {
	background-color: var(--wp--preset--color--secondary);
	color: var(--wp--preset--color--primary);
}

.wp-block-social-links.is-style-round-dark .wp-social-link {
	background-color: color-mix(in srgb, var(--wp--preset--color--background) 10%, transparent);
	color: var(--wp--preset--color--background);
}

.wp-block-social-links.is-style-round-soft .wp-social-link:hover,
.wp-block-social-links.is-style-round-dark .wp-social-link:hover {
	background-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--white);
}

/* ------------------------------------------------------- Contact details */

.bdf-info-item img {
	border-radius: 0;
}

.bdf-info-item strong {
	display: block;
	font-family: var(--wp--preset--font-family--heading);
}

.bdf-map iframe {
	display: block;
	width: 100%;
	height: 380px;
	border: 0;
	border-radius: var(--wp--custom--radius--lg);
}

.bdf-notice {
	padding: 1rem;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--lg);
	background-color: var(--wp--preset--color--secondary);
	font-size: var(--wp--preset--font-size--sm);
}

/* ----------------------------------------------------------------- Forms */
/* Contact Form 7 / WPForms / WooCommerce classic fields. */

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="password"],
input[type="search"],
input[type="url"],
select,
textarea {
	width: 100%;
	padding: 0.75rem 0.875rem;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--lg);
	background-color: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--foreground);
	font: inherit;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
	border-color: var(--wp--preset--color--primary);
	outline: none;
	box-shadow: 0 0 0 2px var(--bdf-ring);
}

label {
	display: block;
	margin: 1rem 0 0.375rem;
	font-size: var(--wp--preset--font-size--sm);
	font-weight: 600;
}

input[type="submit"] {
	width: auto;
	margin-top: 1.25rem;
	padding: 0.875rem 1.75rem;
	border: 0;
	border-radius: 9999px;
	background-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--white);
	font-size: var(--wp--preset--font-size--sm);
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s ease;
}

input[type="submit"]:hover {
	background-color: var(--wp--preset--color--primary-hover);
	transform: translateY(-2px);
}

/* ----------------------------------------------------------- WooCommerce */

.wc-block-components-text-input input,
.wc-block-components-combobox .wc-block-components-combobox-control input,
.wc-blocks-components-select .wc-blocks-components-select__select {
	border-color: var(--wp--preset--color--border) !important;
	border-radius: var(--wp--custom--radius--lg) !important;
	background-color: var(--wp--preset--color--surface) !important;
}

.wc-block-components-button:not(.is-link),
.wc-block-cart__submit-button,
.wc-block-components-checkout-place-order-button {
	border-radius: 9999px !important;
	font-weight: 600;
}

.wc-block-components-sidebar-layout .wc-block-components-totals-wrapper,
.wc-block-cart-items {
	border-color: var(--wp--preset--color--border);
}

.wp-block-woocommerce-product-image-gallery img,
.wc-block-components-product-image img {
	border-radius: var(--wp--custom--radius--xl);
}

.wc-block-components-product-sale-badge {
	border-radius: 9999px;
	border-color: var(--wp--preset--color--primary);
	background-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--white);
}

/* Single product: quantity + full-width add-to-cart pill. */
.bdf-product-summary form.cart {
	display: flex;
	gap: 0.75rem;
	margin-top: 1.5rem;
}

.bdf-product-summary form.cart .quantity input {
	width: 5rem;
	text-align: center;
	border-radius: 9999px;
}

.bdf-product-summary form.cart .single_add_to_cart_button {
	flex: 1;
	justify-content: center;
}

.wc-block-components-quantity-selector {
	border-radius: 9999px;
	border-color: var(--wp--preset--color--border);
}

.woocommerce-breadcrumb,
.wc-block-breadcrumbs {
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--sm);
}

.wp-block-query-pagination a,
.wp-block-query-pagination .current {
	padding: 0.25rem 0.625rem;
	border-radius: 9999px;
}

.wp-block-query-pagination .current {
	background-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--white);
}

/* ------------------------------------------------------- Reduced motion */

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}

	*,
	*::before,
	*::after {
		transition: none !important;
	}

	.wp-block-button__link:hover,
	.wp-block-group.is-style-card:hover,
	.wp-block-group.is-style-product-card:hover {
		transform: none !important;
	}
}
