/*
Theme Name: Atelier Brossard
Description: Thème en blocs minimaliste pour la boutique Atelier Brossard. Optimisé pour WooCommerce et les Core Web Vitals.
Author: Atelier Brossard
Version: 1.3.1
Requires at least: 6.6
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: atelierbrossard
*/

/*
 * L'essentiel du design est défini dans theme.json.
 * Ce fichier ne contient que ce que theme.json ne sait pas (encore) exprimer.
 * Les règles préfixées par :where(body:not(.editor-styles-wrapper)) ne
 * s'appliquent pas dans l'éditeur, pour que tout reste facile à modifier.
 */

/* ---------- Base ---------- */

:where(.wp-site-blocks) :focus-visible {
	outline: 1px solid currentColor;
	outline-offset: 3px;
}

header[tabindex="-1"]:focus {
	outline: none;
}

/* ---------- En-tête collant ---------- */

/*
 * Le « sticky » doit porter sur l'élément <header> que WordPress place
 * autour de la partie de modèle (enfant direct de .wp-site-blocks).
 */
.wp-site-blocks > header.wp-block-template-part {
	position: sticky;
	top: 0;
	z-index: 100;
}

.admin-bar .wp-site-blocks > header.wp-block-template-part {
	top: var(--wp-admin--admin-bar--height, 0px);
}

.ab-header {
	background-color: var(--wp--preset--color--base);
	border-bottom: 1px solid var(--wp--preset--color--border);
	transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* Accueil avec diaporama : en-tête transparent par-dessus, blanc dès qu'on fait défiler.
   (Sans diaporama, l'en-tête reste blanc : jamais de texte blanc sur fond blanc.) */
.home:has(.ab-slider) .wp-site-blocks > header.wp-block-template-part {
	position: fixed;
	right: 0;
	left: 0;
}

.home:has(.ab-slider) .ab-header:not(.is-scrolled) {
	border-bottom-color: transparent;
	background-color: transparent;
	color: var(--wp--preset--color--base);
}

/* Diapositive claire (sans photo ou photo claire) : texte de l'en-tête en noir. */
.home:has(.ab-slider.is-light) .ab-header:not(.is-scrolled) {
	color: var(--wp--preset--color--contrast);
}

/* Bouton loupe : icône seule, couleur de l'en-tête. */
.ab-header .wp-block-search__button,
.ab-header .wp-block-search__button:hover {
	padding: 0.25rem;
	border: 0;
	background: none;
	color: inherit;
}

/* ---------- Sur-titre (« LA SÉLECTION », « ACCESSOIRES »…) ---------- */

.ab-eyebrow {
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 600;
	letter-spacing: 0.3em;
	line-height: 1.4;
	text-transform: uppercase;
}

.ab-eyebrow a {
	text-decoration: none;
}

/* ---------- Bouton contour : survol ---------- */

.wp-block-button.is-style-outline > .wp-block-button__link:hover,
.wp-block-button.is-style-outline > .wp-block-button__link:focus-visible {
	background-color: var(--wp--preset--color--contrast);
	border-color: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

/* ---------- Diaporama plein écran à navigation numérotée ---------- */

.ab-slider .wp-block-heading {
	line-height: 1.05;
}

:where(body:not(.editor-styles-wrapper)) .ab-slider {
	position: relative;
}

:where(body:not(.editor-styles-wrapper)) .ab-slider__track {
	position: relative;
	display: flex;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
}

:where(body:not(.editor-styles-wrapper)) .ab-slider__track::-webkit-scrollbar {
	display: none;
}

:where(body:not(.editor-styles-wrapper)) .ab-slider__track > * {
	flex: 0 0 100%;
	margin-block: 0 !important;
	scroll-snap-align: start;
	scroll-snap-stop: always;
}

/* Navigation posée sur la photo, en bas au centre. Blanche sur photo sombre, noire sur fond clair. */
.ab-slider__nav {
	position: absolute;
	right: 0;
	bottom: clamp(1.5rem, 5vh, 3.5rem);
	left: 0;
	z-index: 2;
	display: flex;
	gap: 1.75rem;
	align-items: center;
	justify-content: center;
	color: var(--wp--preset--color--base);
}

.ab-slider.is-light .ab-slider__nav {
	color: var(--wp--preset--color--contrast);
}

.ab-slider__dot {
	padding: 0.5rem 0.25rem;
	border: 0;
	background: none;
	color: inherit;
	font-family: var(--wp--preset--font-family--display);
	font-size: 1.5rem;
	font-variant-numeric: oldstyle-nums;
	line-height: 1;
	opacity: 0.6;
	cursor: pointer;
	transition: opacity 0.2s ease;
}

.ab-slider__dot:hover,
.ab-slider__dot[aria-current="true"] {
	opacity: 1;
}

.ab-slider__progress {
	position: relative;
	display: block;
	width: 3.5rem;
	height: 1px;
	overflow: hidden;
	background-color: color-mix(in srgb, currentColor 35%, transparent);
}

.ab-slider__progress > span {
	position: absolute;
	inset: 0;
	background-color: currentColor;
	transform-origin: left center;
}

.ab-slider.is-autoplay .ab-slider__progress > span {
	transform: scaleX(0);
}

/*
 * Propriétés détaillées (et non le raccourci « animation ») : le raccourci
 * remettrait animation-play-state à « running » et annulerait la pause.
 */
.ab-slider.is-autoplay .ab-slider__progress > span.is-animating {
	animation-name: ab-slider-progress;
	animation-duration: var(--ab-slider-duration, 7s);
	animation-timing-function: linear;
	animation-fill-mode: forwards;
}

/* Pause : bouton pause, ou navigation au clavier dans le diaporama. */
.ab-slider.is-autoplay:has(:focus-visible) .ab-slider__progress > span.is-animating,
.ab-slider.is-paused .ab-slider__progress > span.is-animating {
	animation-play-state: paused;
}

@keyframes ab-slider-progress {
	to {
		transform: scaleX(1);
	}
}

.ab-slider__toggle {
	position: relative;
	width: 2rem;
	height: 2rem;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	cursor: pointer;
}

/* Icône pause (deux barres). */
.ab-slider__toggle::before {
	content: "";
	position: absolute;
	top: 0.6rem;
	left: 0.75rem;
	width: 2px;
	height: 0.8rem;
	background-color: currentColor;
	box-shadow: 6px 0 0 currentColor;
}

/* Icône lecture (triangle) quand le diaporama est en pause. */
.ab-slider.is-paused .ab-slider__toggle::before {
	top: 0.6rem;
	left: 0.8rem;
	width: 0;
	height: 0;
	border-style: solid;
	border-width: 0.4rem 0 0.4rem 0.65rem;
	border-color: transparent transparent transparent currentColor;
	background: none;
	box-shadow: none;
}

/* ---------- Grille « lookbook » (tuiles catégories) ---------- */

.ab-tile {
	overflow: hidden;
}

.ab-tile .wp-block-cover__inner-container {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
}

.ab-tile__label a {
	text-decoration: none;
}

/* Toute la tuile est cliquable. */
.ab-tile__label a::after {
	content: "";
	position: absolute;
	inset: 0;
}

.ab-tile .wp-block-cover__image-background {
	transition: transform 0.6s ease;
}

.ab-tile:hover .wp-block-cover__image-background {
	transform: scale(1.04);
}

/* Sur ordinateur, le libellé apparaît au survol (seulement quand une photo est en place). */
@media (hover: hover) {
	:where(body:not(.editor-styles-wrapper)) .ab-tile:has(.wp-block-cover__image-background) .ab-tile__label {
		opacity: 0;
		transition: opacity 0.3s ease;
	}

	:where(body:not(.editor-styles-wrapper)) .ab-tile:hover .ab-tile__label,
	:where(body:not(.editor-styles-wrapper)) .ab-tile:focus-within .ab-tile__label {
		opacity: 1;
	}
}

/* ---------- Deux grands blocs côte à côte (photo + encart sable) ---------- */

.ab-split > .wp-block-cover {
	min-height: 0;
	aspect-ratio: 9 / 10;
}

/* ---------- Grilles de produits WooCommerce ---------- */

.ab-product-image {
	position: relative;
}

/* Étiquette « Nouveau » (produits publiés depuis moins de 30 jours). */
.ab-badge-new {
	position: absolute;
	top: 0.75rem;
	right: 0.75rem;
	z-index: 2;
	color: var(--wp--preset--color--accent-dark);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 600;
	letter-spacing: 0.3em;
	line-height: 1;
	text-transform: uppercase;
	pointer-events: none;
}

.wc-block-product-template .wp-block-post-title {
	font-family: var(--wp--preset--font-family--display);
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.wc-block-product-template .wp-block-post-title a {
	text-decoration: none;
}

.wc-block-components-product-sale-badge {
	border: 0;
	background: none;
	color: var(--wp--preset--color--accent-dark);
	font-size: var(--wp--preset--font-size--x-small);
	letter-spacing: 0.2em;
	text-transform: uppercase;
}

/* ---------- Bouton « retour en haut » ---------- */

.ab-back-to-top {
	position: fixed;
	right: 1.25rem;
	bottom: 1.25rem;
	z-index: 90;
	display: grid;
	place-items: center;
	width: 2.75rem;
	height: 2.75rem;
	background-color: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--base);
	opacity: 0;
	visibility: hidden;
	transform: translateY(0.5rem);
	transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

.ab-back-to-top.is-visible {
	opacity: 1;
	visibility: visible;
	transform: none;
}

.ab-back-to-top:hover {
	background-color: var(--wp--preset--color--accent-dark);
}

.ab-back-to-top span {
	width: 0.6rem;
	height: 0.6rem;
	border-top: 1.5px solid currentColor;
	border-left: 1.5px solid currentColor;
	transform: translateY(2px) rotate(45deg);
}

/* ---------- Respect de la préférence « réduire les animations » ---------- */

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}

	/* Sans cela, la barre se terminerait instantanément et ferait défiler les diapositives en boucle. */
	.ab-slider__progress > span {
		animation: none !important;
	}
}
