/* BWI motion + interaction states. Only states, motion and core-block overrides theme.json cannot express.
 * Every rule carries a WHY comment. Owner of the button + nav sections: bwi:foundation. */

/* == Buttons ============================================================== */

/* WHY: theme.json has no transition property; colour/border changes ease between the 5 sheet states. */
.wp-element-button,
.wp-block-button__link {
	transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

/* WHY: Focus state on the Figma sheet (35404:6822) is the red fill plus a 4px #727272 stroke INSIDE the pill (kept as an
 * inset shadow), but gray on #B11D29 is ~1.6:1, too faint alone (QA round 1). Added a two-tone ring outside it: 2px white
 * band + 2px black outline. White vs red/charcoal/ink >= 4.8:1 and black vs white/off-white >= 19:1, so one of the two
 * bands clears 3:1 on any button and any section background (WCAG technique C40) without per-section colours. */
.wp-element-button:focus-visible,
.wp-block-button__link:focus-visible {
	outline: 2px solid var(--wp--preset--color--black);
	outline-offset: 2px;
	box-shadow: inset 0 0 0 4px var(--wp--preset--color--gray), 0 0 0 2px var(--wp--preset--color--white);
}

/* WHY: Inactive state (35404:6827) = #D1D5DB fill, white label. Buttons are links, so the state is opted into with the
 * block class "is-inactive" (Additional CSS class on the Button block) or aria-disabled; :disabled covers form buttons. */
.wp-block-button.is-inactive .wp-block-button__link,
.wp-element-button[aria-disabled="true"],
.wp-element-button:disabled {
	background-color: var(--wp--preset--color--light-gray) !important;
	border-color: var(--wp--preset--color--light-gray) !important;
	color: var(--wp--preset--color--white) !important;
	box-shadow: none;
	pointer-events: none;
	cursor: not-allowed;
}

/* WHY: Outline Light states (Figma row 2: 35404:6808 / 6814 / 6820 / 6826). Variation partials only carry the neutral state.
 * Hover = gray fill + white border; Click = white fill + black label; Focus = bright red ring around the pill. */
.wp-block-button.is-style-outline-light .wp-block-button__link:hover {
	background-color: var(--wp--preset--color--gray);
	border-color: var(--wp--preset--color--white);
	color: var(--wp--preset--color--white);
}
.wp-block-button.is-style-outline-light .wp-block-button__link:active {
	background-color: var(--wp--preset--color--white);
	border-color: var(--wp--preset--color--white);
	color: var(--wp--preset--color--black);
}
/* WHY: Figma draws the outline styles' focus as a 1px #E81B29 frame; bright-red is under 3:1 next to the red pills, so the
 * outline styles share the two-tone ring above, without the inset gray (their fill stays transparent). */
.wp-block-button.is-style-outline-light .wp-block-button__link:focus-visible,
.wp-block-button.is-style-outline-dark .wp-block-button__link:focus-visible,
.wp-block-button.is-style-outline-red .wp-block-button__link:focus-visible,
.wp-block-button.is-style-outline-bright-red .wp-block-button__link:focus-visible {
	box-shadow: 0 0 0 2px var(--wp--preset--color--white);
}

/* WHY: Outline Dark is the light-background twin of Outline Light (charcoal-stroked pills on white sections in the page
 * frames). No sheet row exists for it, so states mirror Outline Light with charcoal in place of white. */
.wp-block-button.is-style-outline-dark .wp-block-button__link:hover {
	background-color: var(--wp--preset--color--gray);
	border-color: var(--wp--preset--color--gray);
	color: var(--wp--preset--color--white);
}
.wp-block-button.is-style-outline-dark .wp-block-button__link:active {
	background-color: var(--wp--preset--color--charcoal);
	border-color: var(--wp--preset--color--charcoal);
	color: var(--wp--preset--color--white);
}

/* WHY: Bright-red filled pills on dark sections (products#03, oem#05 "Compare Products") have no sheet row. States
 * follow the default filled button one step lighter: hover = red (default hover is the next darker red), click = gray;
 * focus ring + inactive are the shared rules above. Box and padding come from the button element (47px). */
.wp-block-button.is-style-fill-bright-red .wp-block-button__link:hover {
	background-color: var(--wp--preset--color--red);
	color: var(--wp--preset--color--white);
}
.wp-block-button.is-style-fill-bright-red .wp-block-button__link:active {
	background-color: var(--wp--preset--color--gray);
	color: var(--wp--preset--color--white);
}

/* WHY: Red outline pills in the page frames (35321:3949 on white, 35396:3915 on ink cards) have no sheet row.
 * States follow the sheet pattern: hover = gray fill, click = solid fill; focus ring shared above. */
.wp-block-button.is-style-outline-red .wp-block-button__link:hover {
	background-color: var(--wp--preset--color--gray);
	border-color: var(--wp--preset--color--gray);
	color: var(--wp--preset--color--white);
}
.wp-block-button.is-style-outline-red .wp-block-button__link:active {
	background-color: var(--wp--preset--color--red);
	border-color: var(--wp--preset--color--red);
	color: var(--wp--preset--color--white);
}
.wp-block-button.is-style-outline-bright-red .wp-block-button__link:hover {
	background-color: var(--wp--preset--color--gray);
	border-color: var(--wp--preset--color--bright-red);
	color: var(--wp--preset--color--white);
}
.wp-block-button.is-style-outline-bright-red .wp-block-button__link:active {
	background-color: var(--wp--preset--color--white);
	border-color: var(--wp--preset--color--white);
	color: var(--wp--preset--color--black);
}

/* == Navigation ============================================================ */

/* WHY: core/navigation collapses to the overlay only below 600px (hard-coded). The 4 BWI groups + 338px logo need
 * ~950px, so the hamburger must take over below 1024px. */
@media (min-width: 600px) and (max-width: 1023.98px) {
	.bwi-header .wp-block-navigation__responsive-container-open:not(.always-shown) {
		display: flex;
	}
	.bwi-header .wp-block-navigation__responsive-container:not(.hidden-by-default):not(.is-menu-open) {
		display: none;
	}
}

/* WHY: Keyboard focus on nav labels, submenu toggles and the open/close buttons needs a ring theme.json cannot target. */
.bwi-header .wp-block-navigation-item__content:focus-visible,
.bwi-header .wp-block-navigation-submenu__toggle:focus-visible,
.bwi-header .wp-block-navigation__responsive-container-open:focus-visible,
.bwi-header .wp-block-navigation__responsive-container-close:focus-visible {
	outline: 2px solid var(--wp--preset--color--bright-red);
	outline-offset: 2px;
}

/* WHY: Submenu chevron flips when its group is open (state, not layout). */
.bwi-header .wp-block-navigation__submenu-icon svg {
	transition: transform 160ms ease;
}
.bwi-header [aria-expanded="true"] .wp-block-navigation__submenu-icon svg,
.bwi-header [aria-expanded="true"] + .wp-block-navigation__submenu-icon svg {
	transform: rotate(180deg);
}

/* WHY: Core always shows every submenu expanded inside the overlay; the Figma mobile menu (35396:5988) shows the
 * 4 groups collapsed with chevrons, so groups open as an accordion on their toggle. */
.bwi-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-submenu__toggle + .wp-block-navigation__submenu-icon,
.bwi-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__submenu-icon {
	display: inline-flex;
}
.bwi-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-submenu__toggle[aria-expanded="false"] ~ .wp-block-navigation__submenu-container {
	display: none;
}

/* == Reduced motion ======================================================== */

/* WHY: Respect the OS setting for every transition defined above. */
@media (prefers-reduced-motion: reduce) {
	.wp-element-button,
	.wp-block-button__link,
	.bwi-header .wp-block-navigation__submenu-icon svg {
		transition: none;
	}
}

/* == w5-tables: row-list states (bwi:w5-tables) ============================ */

/* WHY: Each .bwi-rows__row is one stretched link (heading/link ::after covers the row). Hover nudges the arrow
   (Loom: arrows nudge, translate not scale); keyboard focus rings the whole row because the link's own box is
   only the visible text. */
.bwi-rows__row--arrow::after,
.bwi-rows__more::after {
	transition: translate 0.2s ease-out;
}
.bwi-rows__row:hover.bwi-rows__row--arrow::after,
.bwi-rows__row:hover .bwi-rows__more::after {
	translate: 4px 0;
}
.bwi-rows__row:hover .bwi-rows__name a,
.bwi-rows__row:hover .bwi-rows__more a {
	text-decoration: underline;
	text-underline-offset: 4px;
}
.bwi-rows__row a:focus-visible {
	outline: none;
}
.bwi-rows__row:has(a:focus-visible) {
	outline: 2px solid var(--wp--preset--color--bright-red);
	outline-offset: 4px;
}
@media (prefers-reduced-motion: reduce) {
	.bwi-rows__row--arrow::after,
	.bwi-rows__more::after {
		transition: none;
	}
}
/* == w5-tables end == */

/* == bwi:w2-cards ========================================================= */
/* WHY: Loom note on the workflow icon tiles: a slight move on hover, a translate and never a scale.
 * theme.json cannot express transitions or hover transforms on a group, so it lives here. */
.bwi-icon-card {
	transition: transform 200ms ease;
}
.bwi-icon-card:hover {
	transform: translateY(-4px);
}
/* WHY: prefers-reduced-motion users get no movement at all on the icon tiles. */
@media (prefers-reduced-motion: reduce) {
	.bwi-icon-card { transition: none; }
	.bwi-icon-card:hover { transform: none; }
}
/* WHY: product cards are one stretched title link, so the ring goes on the card, not the clipped title. Same two-tone
 * Product cards only sit on the ink section (home#05, products#02): a black outline vanished there and a 2px white band
 * hugging the card read as its resting border. Solid white ring with an ink gap reads as a distinct focus state.
 * :has(:focus-visible) instead of :focus-within so a mouse click does not draw it. */
.bwi-product-card:has(.bwi-product-card__title a:focus-visible) {
	outline: 3px solid var(--wp--preset--color--white);
	outline-offset: 4px;
}
