/*
 * Avtoservis Kovačič: only what the editor cannot set (design-plan.md, DESIGN.md).
 * Spacing, colours, sizes, borders, radii and grid columns are block settings in the pages and parts.
 */

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

/* Sticky position: not a block setting. The sticky element is the template-part wrapper (a sticky
   child of a wrapper of its own height never sticks). Phones too, as on the old site, but not on a
   phone turned sideways. */
@media (min-height: 560px) {
	header.wp-block-template-part:has(> .forge-kv-header) {
		position: sticky;
		top: 0;
		z-index: 50;
	}

	/* Below the admin bar while it is fixed (≥ 601 px); on phones it scrolls away. */
	@media (min-width: 601px) {
		.admin-bar header.wp-block-template-part:has(> .forge-kv-header) {
			top: var(--wp-admin--admin-bar--height, 32px);
		}
	}
}

/* Logo in the middle cell of the header grid (start on phones, where the call button is hidden),
   menu at the end. Cell placement is not a block setting. */
.forge-kv-header__row {
	align-items: center;
}

.forge-kv-header__logo {
	justify-self: center;
}

.forge-kv-header__nav {
	justify-self: end;
}

@media (max-width: 599px) {
	.forge-kv-header__logo {
		justify-self: start;
	}
}

/* Menu link underline on hover / current page: decoration (pseudo-element). */
.forge-kv-header__nav .wp-block-navigation-item__content {
	position: relative;
	padding-block: 0.75rem;
	text-decoration: none;
}

.forge-kv-header__nav .wp-block-navigation-item__content::after {
	content: "";
	position: absolute;
	inset: auto 0 0.25rem;
	height: 2px;
	background: var(--wp--preset--color--accent);
	transform: scaleX(0);
	transition: transform var(--wp--custom--motion--base, 200ms) ease-out;
}

.forge-kv-header__nav .wp-block-navigation-item__content:hover::after,
.forge-kv-header__nav .current-menu-item > .wp-block-navigation-item__content::after {
	transform: scaleX(1);
}

/* Menu toggle and close button: 44 px touch targets (core draws them 24 px).
   Size only: core decides when they show. */
.forge-kv-header__nav :is(.wp-block-navigation__responsive-container-open, .wp-block-navigation__responsive-container-close) {
	align-items: center;
	justify-content: center;
	min-width: 44px;
	min-height: 44px;
}

/* The open menu on phones: links as full-width rows with a line, left-aligned, like the old site's
   panel (the overlay would otherwise keep the desktop "justify right"). */
.forge-kv-header__nav .is-menu-open .wp-block-navigation__responsive-container-content,
.forge-kv-header__nav .is-menu-open .wp-block-navigation__container {
	align-items: stretch;
	width: 100%;
}

.forge-kv-header__nav .is-menu-open .wp-block-navigation-item {
	width: 100%;
	border-bottom: 1px solid var(--wp--preset--color--line);
	font-size: var(--wp--preset--font-size--medium);
}

.forge-kv-header__nav .is-menu-open .wp-block-navigation-item__content {
	padding-block: var(--wp--preset--spacing--30);
}

.forge-kv-header__nav .is-menu-open .wp-block-navigation-item__content::after {
	content: none;
}

/* ---------- Block styles (registered in modules/kovacic) ---------- */

/* Button "Phone icon": the old site's handset before the number; follows the text colour. */
.wp-block-button.is-style-phone .wp-block-button__link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--wp--preset--spacing--20);
}

.wp-block-button.is-style-phone .wp-block-button__link::before {
	content: "";
	flex: none;
	width: 1em;
	height: 1em;
	background: currentColor;
	mask: url("../icons/phone.svg") center / contain no-repeat;
}

/* Every button: at least 44 px high (touch target), pressed state 1 px down. */
.wp-block-button__link {
	min-height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background-color var(--wp--custom--motion--base, 200ms) ease-out, transform var(--wp--custom--motion--fast, 150ms) ease-out;
}

.wp-block-button__link:active {
	transform: translateY(1px);
}

/* The call button's hover: a darker blue (the global button hover is for the dark button). */
.wp-block-button__link.has-accent-background-color:hover {
	background-color: var(--wp--preset--color--accent-strong);
	color: var(--wp--preset--color--on-primary);
}

/* Paragraph "Badge": a pill as wide as its text, placed by the paragraph's own alignment (left by
   default, centred when the text is centred). Padding only as a default (:where), so the block's own
   padding setting wins. */
.is-style-badge {
	width: fit-content;
	border-radius: var(--wp--custom--radius--pill);
	box-shadow: var(--wp--preset--shadow--soft);
}

.is-style-badge.has-text-align-center {
	margin-inline: auto;
}

.is-style-badge.has-text-align-right {
	margin-inline-start: auto;
}

/* Core pads every paragraph with a background (p.has-background, 1.25em 2.375em): too big for a pill.
   The block's own padding setting (inline style) still wins over this. */
.is-style-badge,
.is-style-badge.has-background {
	padding: var(--wp--preset--spacing--20) var(--wp--preset--spacing--30);
}

/* List "Check marks": a tick before each item in the list's own text colour. */
.wp-block-list.is-style-check {
	list-style: none;
	padding-inline-start: 0;
}

.wp-block-list.is-style-check li {
	display: flex;
	gap: var(--wp--preset--spacing--20);
}

.wp-block-list.is-style-check li + li {
	margin-top: var(--wp--preset--spacing--20);
}

.wp-block-list.is-style-check li::before {
	content: "";
	flex: none;
	width: 1em;
	height: 1.6em;
	background: currentColor;
	mask: url("../../../forge-wp/assets/icons/check.svg") center / 1em no-repeat;
}

/* Group "Card that lifts on hover": 2 px up with the raised shadow (motion level 1). */
.wp-block-group.is-style-card {
	transition: transform var(--wp--custom--motion--base, 200ms) ease-out, box-shadow var(--wp--custom--motion--base, 200ms) ease-out;
}

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

/* ---------- Pieces of the pages ---------- */

/* Yellow highlight in the Castrol heading: the inline mark's padding and corners. */
mark.has-inline-color {
	padding: 0 var(--wp--preset--spacing--20);
	border-radius: var(--wp--custom--radius--control);
	box-decoration-break: clone;
	-webkit-box-decoration-break: clone;
}

/* Gallery slider: the active bullet in the site's accent (the parent uses gold, which is Castrol
   yellow here). Inside a theme block. */
.forge-slider__bullet.is-active::before {
	background: var(--wp--preset--color--accent);
}

/* Contact form: the submit button in the site's call colour (inside a theme block). */
.wp-block-forge-contact-form .wpcf7-submit {
	background: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--on-primary);
}

.wp-block-forge-contact-form .wpcf7-submit:hover {
	background: var(--wp--preset--color--accent-strong);
}

/* Focus ring in the accent on every control. */
:where(a, button, input, select, textarea, .wp-block-button__link):focus-visible {
	outline: 3px solid var(--wp--preset--color--accent);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.forge-kv-header__nav .wp-block-navigation-item__content::after,
	.wp-block-group.is-style-card,
	.wp-block-button__link {
		transition: none;
	}

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