/*
 * Crazy Runners — the shop's place in the header and footer: product search, account link,
 * shop sub-menu, reassurance strip, free-delivery line of the top bar, "Promos" menu entry.
 * Markup: inc/woo-header.php (and header.php for the top bar), behaviour: assets/js/theme.js.
 *
 * Loaded with WooCommerce only, after style.css and assets/css/woocommerce.css. Mobile first,
 * same breakpoints as style.css (900px: horizontal navigation).
 */

/* ==========================================================================
   1. Header actions: search button, account link
   ========================================================================== */

/* .crs-icon-link was written for links: the search buttons need a button reset. */
.crs-header__search-toggle,
.crs-header__search-close {
	flex: 0 0 auto;
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	cursor: pointer;
}

.crs-header__search-toggle[aria-expanded="true"] {
	background: var(--crs-accent-soft);
	color: var(--crs-accent-hover);
}

/* Without JavaScript the search row is simply visible: nothing to open or close. */
html:not(.crs-js) .crs-header__search-toggle,
html:not(.crs-js) .crs-header__search-close {
	display: none;
}

/* On the narrowest phones the row keeps logo, search, cart and menu; Instagram stays in the footer. */
@media (max-width: 399.98px) {
	.crs-header__instagram {
		display: none;
	}
}

/* "Mon compte": in the menu panel on a phone, in the header actions on a wide screen. */
.crs-header__account {
	display: none;
}

.crs-nav__account {
	display: flex;
	align-items: center;
	min-height: 48px;
	padding: 6px 4px;
	border-bottom: 1px solid var(--crs-border);
	color: var(--crs-text);
	font-weight: 600;
	line-height: 1.3;
	text-decoration: none;
}

.crs-nav__account:hover {
	color: var(--crs-accent-hover);
}

/* Without JavaScript the search form is unfolded in the header at every width (and, on a phone, the menu
   and its sub-menu too): the header must then scroll away with the page instead of sticking over it.
   "relative" rather than "static" keeps its z-index, which the sub-menu of a wide screen opens above the page with;
   "top" cancels the offset style.css gives the sticky header under the admin bar. */
html:not(.crs-js) .crs-header {
	position: relative;
	top: auto;
}

/* ==========================================================================
   2. Search row, under the header
   ========================================================================== */

.crs-header__search {
	border-top: 1px solid var(--crs-border);
	background: var(--crs-bg);
}

.crs-js .crs-header__search:not(.is-open) {
	display: none;
}

.crs-header__search-inner {
	display: flex;
	align-items: center;
	gap: 8px;
	padding-top: 12px;
	padding-bottom: 12px;
}

/* The header form does not take the centred, narrow layout of the page search form (style.css). */
.crs-header__search .crs-search {
	flex: 1 1 auto;
	flex-wrap: nowrap;
	gap: 8px;
	min-width: 0;
	max-width: 640px;
	margin: 0;
}

.crs-header__search .crs-search__field {
	flex: 1 1 auto;
	width: auto;
	min-width: 0;
}

.crs-header__search .crs-search__submit {
	padding-right: 16px;
	padding-left: 16px;
}

/* Phones: the button keeps its icon, its label stays for screen readers. */
@media (max-width: 479.98px) {
	.crs-header__search .crs-search__submit-label {
		position: absolute;
		width: 1px;
		height: 1px;
		margin: -1px;
		overflow: hidden;
		clip: rect(1px, 1px, 1px, 1px);
		clip-path: inset(50%);
		white-space: nowrap;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.crs-js .crs-header__search.is-open {
		animation: crs-header-search-in .18s ease-out;
	}
}

@keyframes crs-header-search-in {
	from {
		opacity: 0;
		transform: translateY(-6px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

/* ==========================================================================
   3. Shop sub-menu
   ========================================================================== */

/* The button is added by JavaScript next to an entry that has a sub-menu. In the mobile panel the
   sub-menu is always unfolded under its entry, so the button is of no use there. */
.crs-shopmenu__toggle {
	display: none;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 44px;
	margin-left: -8px;
	padding: 0;
	border: 0;
	border-radius: var(--crs-radius-sm);
	background: none;
	color: var(--crs-muted);
	cursor: pointer;
}

.crs-shopmenu__toggle:hover,
.crs-shopmenu__toggle[aria-expanded="true"] {
	background: var(--crs-surface);
	color: var(--crs-text);
}

/* The arrow of crs_icon(), turned to point down, then up once the sub-menu is open. */
.crs-shopmenu__toggle .crs-icon {
	transform: rotate(90deg);
	transition: transform .15s ease;
}

.crs-shopmenu__toggle[aria-expanded="true"] .crs-icon {
	transform: rotate(-90deg);
}

@media (min-width: 900px) {
	/* An icon link like its neighbours (.crs-icon-link in style.css gives it its size and its hover). */
	.crs-header__account {
		display: inline-flex;
	}

	.crs-nav__account {
		display: none;
	}

	.crs-header__search-inner {
		justify-content: center;
		padding-top: 16px;
		padding-bottom: 16px;
	}

	.crs-menu > li.crs-shopmenu {
		display: flex;
		align-items: center;
	}

	.crs-shopmenu__toggle {
		display: inline-flex;
	}

	/* With the button, the state of the sub-menu is the one the button announces: it no longer opens
	   on focus alone (style.css: .crs-menu li:focus-within > ul), only on hover or once expanded. */
	.crs-js .crs-menu > li.crs-shopmenu:focus-within > ul {
		display: none;
	}

	.crs-js .crs-menu > li.crs-shopmenu:hover > ul,
	.crs-js .crs-menu > li.crs-shopmenu.is-open > ul {
		display: block;
	}

	.crs-menu .crs-shopmenu__item--all {
		margin-top: 6px;
		padding-top: 6px;
		border-top: 1px solid var(--crs-border);
	}
}

/* ==========================================================================
   4. Reassurance strip, above the footer
   ========================================================================== */

.crs-reassure {
	padding: clamp(28px, 4vw, 44px) 0;
	border-top: 1px solid var(--crs-border);
	background: var(--crs-bg);
}

.crs-reassure__list {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
	gap: 20px 32px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.crs-reassure__item {
	display: flex;
	align-items: center;
	gap: 14px;
	min-width: 0;
}

.crs-reassure__icon {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 46px;
	height: 46px;
	border-radius: 50%;
	background: var(--crs-sage-50);
	color: var(--crs-sage-600);
}

.crs-reassure__text {
	display: flex;
	flex-direction: column;
	min-width: 0;
	line-height: 1.35;
}

.crs-reassure__label {
	font-size: .9375rem;
	font-weight: 700;
}

.crs-reassure__detail {
	color: var(--crs-muted);
	font-size: .875rem;
}

/* ==========================================================================
   5. Top bar: "Livraison offerte dès … d’achat"
   ========================================================================== */

/* Every rule here hangs on .crs-topbar--franco, a class header.php only prints when the delivery method
   has a "free from" amount: without one, the top bar is the one of style.css, untouched.

   The line comes first and stays on the left; the practical information keeps to the right. One line
   tall at every width, so what gives way is decided per width (the hours are a long text):
   - below 480px: the line and the phone as an icon (its number stays the name of the link);
   - from 480px:  the line and the phone number;
   - from 760px:  + the hours (style.css shows them from 640px without the line);
   - from 1100px: + the address (from 900px without the line). */

.crs-topbar__item--franco {
	display: inline-flex;
	flex: 0 1 auto;
	min-width: 0;
	margin-right: auto;
	font-weight: 600;
}

/* The accent as text on the dark fill: --crs-on-ink-accent, not --crs-accent. */
.crs-topbar__amount {
	color: var(--crs-on-ink-accent);
	font-weight: 700;
	white-space: nowrap;
}

@media (max-width: 479.98px) {
	.crs-topbar--franco .crs-topbar__inner {
		flex-wrap: nowrap;
		gap: 0 12px;
	}

	/* The phone keeps its 44px target; the number is moved out of sight, not out of the link. */
	.crs-topbar--franco .crs-topbar__item--phone {
		position: relative;
		flex: 0 0 44px;
		justify-content: center;
		width: 44px;
		height: 44px;
	}

	.crs-topbar--franco .crs-topbar__item--phone .crs-phone-link {
		position: absolute;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		display: block;
		overflow: hidden;
		text-indent: 200%;
		white-space: nowrap;
	}
}

@media (min-width: 640px) and (max-width: 759.98px) {
	.crs-topbar--franco .crs-topbar__item--hours {
		display: none;
	}
}

@media (min-width: 900px) and (max-width: 1099.98px) {
	.crs-topbar--franco .crs-topbar__item--address {
		display: none;
	}
}

/* ==========================================================================
   6. "Promos" entry of the primary menu
   ========================================================================== */

/* Printed while products are on promotion. It wears the accent whatever the page; a dot sets it apart
   from the current entry, which is accent-coloured too in the mobile panel. */
.crs-menu .crs-menu__promo > a {
	gap: 8px;
	color: var(--crs-accent);
	font-weight: 700;
}

.crs-menu .crs-menu__promo > a::before {
	flex: 0 0 auto;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: currentColor;
	content: "";
}

.crs-menu .crs-menu__promo > a:hover {
	color: var(--crs-accent-hover);
}

/* On its own page, in the mobile panel: underlined, since the colour no longer tells. */
.crs-menu .crs-menu__promo.current-menu-item > a {
	text-decoration: underline;
	text-decoration-thickness: 2px;
	text-underline-offset: 5px;
}

@media (min-width: 900px) {
	.crs-menu .crs-menu__promo > a:hover {
		background: var(--crs-accent-soft);
		color: var(--crs-accent-hover);
	}

	/* On its own page: filled, white on the accent (5:1), where the other entries get the soft tint. */
	.crs-menu .crs-menu__promo.current-menu-item > a,
	.crs-menu .crs-menu__promo.current-menu-item > a:hover {
		background: var(--crs-accent);
		color: #fff;
		text-decoration: none;
	}
}

/* ==========================================================================
   7. Print
   ========================================================================== */

@media print {
	.crs-header__search,
	.crs-reassure {
		display: none !important;
	}
}

/* ==========================================================================
   7. Room for the primary menu on one line
   ========================================================================== */

/*
 * With the shop's entries (the sub-menu arrow, "Promos") the primary menu no longer fitted next to all the
 * header's actions at two ranges of width, and wrapped onto a second line. What gives way, in this order:
 * the Instagram icon (it is in the footer), a little of the entries' side padding, then the "Nous trouver"
 * button, which only joins the header once there is room for it (the top bar and the footer keep the
 * address and the itinerary at every width).
 */
@media (min-width: 900px) and (max-width: 1099.98px) {
	.crs-header__instagram {
		display: none;
	}

	.crs-menu a {
		padding-right: 7px;
		padding-left: 7px;
	}
}

@media (min-width: 1100px) and (max-width: 1239.98px) {
	.crs-header .crs-header__cta {
		display: none;
	}
}
