/*
Theme Name: MattressMan
Description: Block theme for the MattressMan luxury sleep store.
Version: 0.5.0
Requires at least: 7.0
Requires PHP: 8.2
License: GPL-2.0-or-later
Text Domain: mattressman
*/

:root {
	--mm-strip-h: 36px;
	--mm-header-h: 79px;
}

body {
	-webkit-font-smoothing: antialiased;
}

/* Breadcrumbs (shared by the PDP and archives). */
.woocommerce-breadcrumb {
	margin: 0 0 16px;
}

.wc-block-breadcrumbs {
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--text-muted, #5d6d83);
}

.wc-block-breadcrumbs a {
	color: var(--wp--preset--color--text-muted, #5d6d83);
	text-decoration: none;
}

.wc-block-breadcrumbs a:hover {
	color: var(--wp--preset--color--primary-deep, #376b81);
	text-decoration: underline;
}

.mm-crumb-sep {
	margin-inline: 8px;
}

/* Focus ring for every interactive element (spec: 0 0 0 1px #376B81, 0 0 0 4px #B9D8E1). */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
	outline: 2px solid transparent;
	outline-offset: 2px;
	box-shadow: var(--wp--custom--focus-ring);
}

.wp-element-button,
.wp-block-button__link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	box-sizing: border-box;
	transition: background-color var(--wp--custom--motion--micro) var(--wp--custom--motion--easing);
}

.mm-eyebrow {
	font-size: var(--wp--preset--font-size--eyebrow);
	font-weight: 600;
	letter-spacing: 0.14em;
	line-height: 1.2;
	text-transform: uppercase;
}

/* Buttons on dark surfaces (spec: Glacier fill, navy text; ghost variant). */
.mm-surface-dark {
	background: var(--wp--preset--color--bg-dark);
	color: var(--wp--preset--color--white);
}

.mm-surface-dark .wp-element-button {
	background: var(--wp--preset--color--accent-glacier);
	color: var(--wp--preset--color--bg-dark);
}

.mm-surface-dark .wp-element-button:hover {
	background: var(--wp--preset--color--white);
	color: var(--wp--preset--color--bg-dark);
}

.mm-surface-dark .is-style-outline .wp-element-button {
	background: transparent;
	border: 1px solid rgba(255, 255, 255, 0.4);
	color: var(--wp--preset--color--white);
}

.mm-surface-dark .mm-icon {
	stroke-width: 1.75;
}

.mm-surface-dark h1,
.mm-surface-dark h2,
.mm-surface-dark h3,
.mm-surface-dark h4 {
	color: var(--wp--preset--color--white);
}

.mm-surface-dark a:not(.wp-element-button) {
	color: var(--wp--preset--color--accent-glacier);
}

.mm-surface-dark a:not(.wp-element-button):hover {
	color: var(--wp--preset--color--white);
}

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

.mm-main {
	margin-block: 0;
}

/* Utility strip: fixed height so the sticky offset below can hide it exactly. */
.mm-utility-strip {
	box-sizing: border-box;
	height: var(--mm-strip-h);
	padding-inline: var(--wp--custom--layout--gutter);
	gap: 32px;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	background: var(--wp--preset--color--bg-dark);
	color: var(--wp--preset--color--white);
}

.mm-utility-strip p {
	margin: 0;
	font-weight: 500;
	line-height: 1.45;
	white-space: nowrap;
}

.mm-utility-strip__item {
	gap: 8px;
	flex-wrap: nowrap;
	align-items: center;
}

.mm-utility-strip .mm-icon {
	stroke-width: 1.75;
}

@media (max-width: 767px) {
	.mm-utility-strip__item:nth-child(n + 2) {
		display: none;
	}
}

/*
 * Sticky header. The template-part wrapper sticks (its parent is the whole page), and a
 * negative top equal to the strip height lets the strip scroll away while the header row stays.
 */
.wp-block-template-part:has(> .mm-header-row) {
	position: sticky;
	top: calc(var(--mm-strip-h) * -1);
	z-index: 100;
	background: var(--wp--preset--color--white);
}

.admin-bar .wp-block-template-part:has(> .mm-header-row) {
	top: calc(32px - var(--mm-strip-h));
}

@media (max-width: 782px) {
	.admin-bar .wp-block-template-part:has(> .mm-header-row) {
		top: calc(46px - var(--mm-strip-h));
	}
}

@media (max-width: 600px) {
	.admin-bar .wp-block-template-part:has(> .mm-header-row) {
		top: calc(0px - var(--mm-strip-h));
	}
}

.mm-header-row {
	display: grid;
	grid-template-areas: "brand nav search actions";
	grid-template-columns: auto 1fr auto auto;
	align-items: center;
	gap: 24px;
	box-sizing: border-box;
	min-height: 72px;
	padding: 12px var(--wp--custom--layout--gutter);
	background: var(--wp--preset--color--white);
	border-bottom: var(--wp--custom--border-hairline);
}

.mm-header-row > .wp-block-site-title { grid-area: brand; margin: 0; }
.mm-header-row > .mm-primary-nav { grid-area: nav; justify-self: center; }
.mm-header-row > .mm-header-search { grid-area: search; margin: 0; }
.mm-header-row > .mm-header-actions { grid-area: actions; justify-self: end; gap: 8px; align-items: center; }

.wp-block-site-title a {
	color: var(--wp--preset--color--text-main);
	text-decoration: none;
}

.mm-primary-nav a {
	color: var(--wp--preset--color--text-main);
	text-decoration: none;
}

.mm-primary-nav a:hover {
	color: var(--wp--preset--color--primary-deep);
}

/* Compact search. */
.mm-header-search {
	width: 240px;
}

.mm-header-search .wp-block-search__inside-wrapper {
	border: var(--wp--custom--border-hairline);
	border-radius: var(--wp--custom--radius--button);
	background: var(--wp--preset--color--white);
}

.mm-header-search .wp-block-search__input {
	min-height: 44px;
	padding: 0 12px;
	border: 0;
	background: transparent;
	font-size: 16px;
}

.mm-header-search .wp-block-search__button {
	min-height: 44px;
	padding: 0 10px;
	border: 0;
	background: transparent;
	color: var(--wp--preset--color--text-main);
}

.mm-header-search .wp-block-search__button:hover {
	background: transparent;
	color: var(--wp--preset--color--primary-deep);
}

.mm-header-icon-link,
.mm-header-actions .wc-block-mini-cart__button,
.mm-header-actions .wc-block-customer-account__link {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	min-height: 44px;
	color: var(--wp--preset--color--text-main);
}

.mm-header-icon-link:hover {
	color: var(--wp--preset--color--primary-deep);
}

/* Below 1280: burger replaces inline navigation (Gutenberg switches at 600px, so override 600-1279). */
@media (max-width: 1279px) {
	.mm-header-row {
		grid-template-areas: "brand search actions nav";
		grid-template-columns: auto 1fr auto auto;
	}

	.mm-header-row > .mm-header-search {
		justify-self: end;
		width: 200px;
	}
}

@media (min-width: 600px) and (max-width: 1279px) {
	.mm-primary-nav .wp-block-navigation__responsive-container-open:not(.always-shown) {
		display: flex;
	}

	.mm-primary-nav .wp-block-navigation__responsive-container:not(.hidden-by-default):not(.is-menu-open) {
		display: none;
	}
}

.mm-primary-nav .wp-block-navigation__responsive-container-open,
.mm-primary-nav .wp-block-navigation__responsive-container-close {
	box-sizing: border-box;
	min-width: 44px;
	min-height: 44px;
	align-items: center;
	justify-content: center;
}

.mm-header-actions .wc-block-mini-cart__icon,
.mm-header-actions .wc-block-customer-account__visual svg {
	width: 20px;
	height: 20px;
}

/* Mobile < 768: search wraps to a full-width second row (design decision D12), so the header is 131px, not 79px. */
@media (max-width: 767px) {
	:root {
		--mm-header-h: 131px;
	}

	.mm-header-row {
		grid-template-areas:
			"brand actions nav"
			"search search search";
		grid-template-columns: 1fr auto auto;
		gap: 8px 12px;
	}

	.mm-header-row > .mm-header-search {
		justify-self: stretch;
		width: auto;
	}
}

/* Below 375: tighter gaps and a smaller wordmark keep the row inside 320px (WCAG 1.4.10); controls stay 44px. */
@media (max-width: 374px) {
	.mm-header-row {
		gap: 8px 4px;
	}

	.mm-header-row > .wp-block-site-title {
		font-size: 1.125rem;
	}

	.mm-header-row > .mm-header-actions {
		gap: 0;
	}
}

/* Footer. It is part of every template, including WooCommerce's cart and checkout templates, which already reference a "footer" part. */
footer.wp-block-template-part {
	margin-block-start: 0;
}

.mm-footer {
	box-sizing: border-box;
	padding: 56px var(--wp--custom--layout--gutter, 16px) 32px;
	color: rgb(255 255 255 / 0.75);
}

.mm-footer .mm-footer__inner {
	max-width: var(--wp--style--global--content-size, 1200px);
	margin-inline: auto;
}

.mm-footer .mm-footer__inner > *,
.mm-footer .mm-footer__main > * {
	margin-block: 0;
}

.mm-footer .mm-footer__main {
	display: flex;
	flex-direction: column;
	gap: 40px;
}

/* Phones: newsletter first, then the brand, then the links (visual order only; see README for the accessibility note). */
@media (max-width: 767px) {
	.mm-footer .mm-footer__newsletter {
		order: -2;
	}

	.mm-footer .mm-footer__brand {
		order: -1;
	}
}

@media (min-width: 768px) {
	.mm-footer .mm-footer__main {
		display: grid;
		grid-template-columns: repeat(6, minmax(0, 1fr));
		gap: 40px;
	}

	.mm-footer .mm-footer__brand {
		grid-column: 1 / span 3;
		grid-row: 1;
	}

	.mm-footer .mm-footer__newsletter {
		grid-column: 4 / span 3;
		grid-row: 1;
	}

	.mm-footer .mm-footer__col {
		grid-column: span 2;
		grid-row: 2;
	}
}

@media (min-width: 1024px) {
	.mm-footer .mm-footer__main {
		display: flex;
		flex-direction: row;
		align-items: flex-start;
	}

	.mm-footer .mm-footer__main > * {
		min-width: 0;
	}

	.mm-footer .mm-footer__brand {
		flex: 1.5 1 0;
	}

	.mm-footer .mm-footer__col {
		flex: 1 1 0;
	}

	.mm-footer .mm-footer__newsletter {
		flex: 1.6 1 0;
	}
}

/* A link column whose pages are all unpublished has no visible item: hide the heading and the empty landmark with it. */
.mm-footer .mm-footer__col:not(:has(.wp-block-navigation-item)),
.mm-footer .mm-footer__legal-nav:not(:has(.wp-block-navigation-item)) {
	display: none;
}

.mm-footer .mm-footer__wordmark,
.mm-footer .mm-footer__wordmark a {
	color: var(--wp--preset--color--white, #fff);
	text-decoration: none;
}

.mm-footer .mm-footer__wordmark {
	margin: 0;
}

.mm-footer .mm-footer__tagline {
	margin: 10px 0 20px;
	font-size: 0.9375rem;
}

.mm-footer .mm-footer__heading {
	margin: 0 0 16px;
	color: var(--wp--preset--color--white, #fff);
	font-family: var(--wp--preset--font-family--inter);
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.14em;
	line-height: 1.4;
	text-transform: uppercase;
}

.mm-footer .mm-footer__heading--serif {
	margin-bottom: 8px;
	font-family: var(--wp--preset--font-family--cormorant-garamond);
	font-size: 1.625rem;
	letter-spacing: -0.01em;
	line-height: 1.15;
	text-transform: none;
}

.mm-footer .mm-footer__microcopy {
	margin: 0 0 16px;
	font-size: 0.875rem;
}

.mm-footer .wp-block-navigation {
	font-family: inherit;
	font-size: 0.875rem;
	font-weight: 400;
	letter-spacing: 0;
	text-transform: none;
}

.mm-footer .mm-footer__nav .wp-block-navigation__container {
	gap: 0;
}

/* Four classes: core's `.wp-block-navigation .wp-block-navigation-item__content.wp-block-navigation-item__content { color: inherit }` has three. */
.mm-footer .wp-block-navigation .wp-block-navigation-item .wp-block-navigation-item__content {
	padding-block: 6px;
	color: var(--wp--preset--color--accent-glacier, #b9d8e1);
	text-decoration: none;
}

.mm-footer .wp-block-navigation .wp-block-navigation-item .wp-block-navigation-item__content:hover {
	color: var(--wp--preset--color--white, #fff);
	text-decoration: underline;
}

.mm-footer .mm-footer__social {
	gap: 8px;
	margin: 0;
	padding: 0;
}

.mm-footer .mm-footer__social .wp-social-link a {
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	min-height: 44px;
	padding: 0;
	color: var(--wp--preset--color--accent-glacier, #b9d8e1);
}

.mm-footer .mm-footer__bar {
	display: flex;
	flex-direction: column;
	gap: 16px;
	margin-top: 48px;
	padding-top: 24px;
	border-top: 1px solid rgb(255 255 255 / 0.12);
}

@media (min-width: 1100px) {
	.mm-footer .mm-footer__bar {
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
	}
}

.mm-footer .mm-footer__legal {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	margin: 0;
	font-size: 0.75rem;
}

.mm-footer .mm-footer__copyright {
	margin: 0;
}

.mm-footer .mm-footer__legal-nav {
	font-size: 0.75rem;
}

.mm-footer .mm-footer__legal-nav .wp-block-navigation__container {
	flex-direction: row;
	flex-wrap: wrap;
	gap: 0;
}

.mm-footer .mm-footer__legal-nav .wp-block-navigation-item::before {
	content: "\00b7";
	margin-inline: 8px;
}

/* Phones: the copyright sits above the links, so the first link needs no separator. */
@media (max-width: 767px) {
	.mm-footer .mm-footer__legal {
		flex-direction: column;
		align-items: flex-start;
	}

	.mm-footer .mm-footer__legal-nav .wp-block-navigation-item:first-child::before {
		content: none;
	}
}

/* Keyboard focus on navy. The global ring has zero specificity and core's social-link anchors set `box-shadow: none`, so the doubled class wins by specificity, not by order. */
.mm-footer.mm-footer :is(a, button, input):focus-visible {
	outline: 2px solid transparent;
	outline-offset: 2px;
	box-shadow: var(--wp--custom--focus-ring);
}

.mm-footer .mm-footer__social .wp-social-link a:focus-visible {
	border-radius: var(--wp--custom--radius--badge, 6px);
}

.mm-payment-marks-wrap {
	margin: 0;
}

.mm-footer .mm-payment-marks {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.mm-footer .mm-payment-marks li {
	margin: 0;
	padding: 4px 10px;
	border: 1px solid var(--wp--preset--color--accent-glacier, #b9d8e1);
	border-radius: var(--wp--custom--radius--badge, 6px);
	color: var(--wp--preset--color--accent-glacier, #b9d8e1);
	font-size: 0.6875rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	line-height: 1.4;
	text-transform: uppercase;
}
