/*
 * Shared UI components that sit above theme.json: button behaviour, the
 * section rhythm primitives, and the eyebrow label. Every value comes from a
 * theme.json token - no literal colours or timings here.
 */

/* --- Buttons -------------------------------------------------------- */

.wp-element-button,
.wp-block-button__link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--wp--preset--spacing--2);
	border: 1px solid transparent;
	line-height: 1.2;
	text-decoration: none;
	transition:
		background-color var(--wp--custom--duration--fast) var(--wp--custom--ease--out),
		border-color var(--wp--custom--duration--fast) var(--wp--custom--ease--out),
		color var(--wp--custom--duration--fast) var(--wp--custom--ease--out),
		transform var(--wp--custom--duration--fast) var(--wp--custom--ease--out);
}

.wp-element-button:hover,
.wp-block-button__link:hover {
	transform: translateY(-1px);
}

.wp-element-button:active,
.wp-block-button__link:active {
	transform: translateY(0);
}

/* Outline variant: transparent until hover, then inverts to solid ink. */
.wp-block-button.is-style-outline > .wp-block-button__link:not(.has-background),
.wp-element-button.is-style-outline {
	background-color: transparent;
	border-color: var(--wp--custom--border--on-light);
	color: var(--wp--preset--color--contrast);
}

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

/* On dark sections the outline flips to light-on-dark. */
.section--dark .wp-block-button.is-style-outline > .wp-block-button__link:not(.has-background),
.section--dark .wp-element-button.is-style-outline {
	border-color: var(--wp--custom--border--on-dark);
	color: var(--wp--preset--color--base);
}

.section--dark .wp-block-button.is-style-outline > .wp-block-button__link:not(.has-background):hover,
.section--dark .wp-element-button.is-style-outline:hover {
	background-color: var(--wp--preset--color--base);
	border-color: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
}

/* Arrow affordance: any button whose label ends in an arrow nudges it. */
.wp-element-button .btn-arrow,
.wp-block-button__link .btn-arrow {
	display: inline-block;
	transition: transform var(--wp--custom--duration--fast) var(--wp--custom--ease--out);
}

.wp-element-button:hover .btn-arrow,
.wp-block-button__link:hover .btn-arrow {
	transform: translateX(4px);
}

/* --- Section rhythm ------------------------------------------------- */

.section {
	padding-block: var(--wp--custom--section--padding);
}

.section--tight {
	padding-block: var(--wp--custom--section--padding-tight);
}

.section--soft {
	background: var(--wp--preset--color--base-soft);
}

.section--muted {
	background: var(--wp--preset--color--base-subtle);
}

.section--dark {
	background: var(--wp--preset--color--base-dark);
	color: var(--wp--preset--color--base);
}

.section--dark :where(h1, h2, h3, h4, h5, h6) {
	color: var(--wp--preset--color--base);
}

.section--dark :where(p, li) {
	color: var(--wp--preset--color--on-dark-muted);
}

/*
 * Links on dark grounds.
 *
 * theme.json paints every link with `primary`, which is #111111 in the
 * monochrome palette - inherited onto a #0A0A0A section that renders at a
 * 1.05:1 contrast ratio, i.e. invisible. This is the guard so any future dark
 * section is safe by default; buttons keep their own colours.
 *
 * Wrapped in :where() on purpose - zero specificity, so it only ever acts as a
 * floor. A component that wants a quieter link colour (the footer does) still
 * wins without needing !important.
 */
:where(.section--dark, .cine) :where(a:not(.wp-element-button):not(.wp-block-button__link)) {
	color: var(--wp--preset--color--base);
}

/* --- Eyebrow label -------------------------------------------------- */

/*
 * Grey, not black: the eyebrow sits directly above a near-black headline, and
 * matching its colour would make the two compete instead of reading as a
 * label and its heading.
 */
.section__eyebrow {
	margin: 0;
	font-size: var(--wp--preset--font-size--xs);
	font-weight: 700;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--wp--preset--color--contrast-subtle);
}

.section--dark .section__eyebrow {
	color: var(--wp--preset--color--accent);
}

/* --- Section head (title left, link right) --------------------------- */

.section__head {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--4);
	margin-bottom: var(--wp--preset--spacing--10);
}

.section__head .section__title {
	margin: var(--wp--preset--spacing--2) 0 0;
}

.section__link {
	display: inline-flex;
	align-items: center;
	gap: var(--wp--preset--spacing--2);
	flex-shrink: 0;
	font-size: var(--wp--preset--font-size--sm);
	font-weight: 600;
	text-decoration: none;
	color: var(--wp--preset--color--contrast);
	padding-bottom: 2px;
	border-bottom: 1px solid var(--wp--custom--border--on-light);
	transition:
		color var(--wp--custom--duration--fast) var(--wp--custom--ease--out),
		border-color var(--wp--custom--duration--fast) var(--wp--custom--ease--out);
}

.section__link:hover {
	color: var(--wp--preset--color--primary);
	border-bottom-color: var(--wp--preset--color--primary);
}

.section__link .btn-arrow {
	transition: transform var(--wp--custom--duration--fast) var(--wp--custom--ease--out);
}

.section__link:hover .btn-arrow {
	transform: translateX(4px);
}

.section--dark .section__link {
	color: var(--wp--preset--color--base);
	border-bottom-color: var(--wp--custom--border--on-dark);
}

/*
 * Full-bleed sections (see cinematic.css) use the 100vw + negative-margin
 * technique, and 100vw includes the scrollbar - so on a desktop with a
 * classic scrollbar they overshoot the viewport by ~15px and the page can
 * scroll sideways.
 *
 * `clip` rather than `hidden` on purpose: `hidden` would turn this into a
 * scroll container and silently break position:sticky anywhere inside it
 * (the product gallery relies on that).
 */
.wp-site-blocks {
	overflow-x: clip;
}

/*
 * Anywhere WooCommerce's sale flash does still render, pull it into the
 * palette - core styles it olive from its own stylesheet, not from a token.
 */
.onsale {
	background-color: var(--wp--preset--color--sale);
	color: var(--wp--preset--color--base);
}

/*
 * Touch targets.
 *
 * Inline text CTAs measure their own line height (~26px), which is fine to
 * click with a mouse and awkward to hit with a thumb. On touch layouts they
 * get a 44px tap area without changing how they look - the underline still
 * hugs the text, the box around it just grows.
 */
@media (max-width: 781px) {
	.section__link,
	.uc__cta,
	.cmp__cta {
		min-height: 44px;
	}

	/* Footer link lists are the densest stack of small targets on the site. */
	.site-footer__col ul {
		gap: 0;
	}

	.site-footer__col li a {
		display: flex;
		align-items: center;
		min-height: 44px;
	}
}

/* --- Empty states (404, no posts) ------------------------------------ */

.notfound {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--wp--preset--spacing--4);
	padding-block: var(--wp--custom--section--padding);
	max-width: 46ch;
}

.notfound--inline {
	padding-block: var(--wp--preset--spacing--12);
}

.notfound__title {
	margin: 0;
	font-size: var(--wp--preset--font-size--xl-5);
	font-weight: 800;
	line-height: 1.05;
	letter-spacing: -0.04em;
	text-wrap: balance;
}

.notfound__text {
	margin: 0;
	font-size: var(--wp--preset--font-size--lg);
	line-height: 1.55;
	color: var(--wp--preset--color--contrast-subtle);
}

.notfound__search {
	display: flex;
	gap: var(--wp--preset--spacing--2);
	width: 100%;
	max-width: 420px;
	margin-top: var(--wp--preset--spacing--2);
}

.notfound__search input[type="search"] {
	flex: 1 1 auto;
	min-width: 0;
	min-height: 48px;
	padding: 0 var(--wp--preset--spacing--4);
	border: 1px solid var(--wp--custom--border--on-light);
	border-radius: var(--wp--custom--radius--md);
	font-size: var(--wp--preset--font-size--base);
}

.notfound__search button {
	flex-shrink: 0;
	min-height: 48px;
	padding: 0 var(--wp--preset--spacing--5);
	border: 0;
	border-radius: var(--wp--custom--radius--md);
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--base);
	font-size: var(--wp--preset--font-size--sm);
	font-weight: 600;
	cursor: pointer;
	transition: background-color var(--wp--custom--duration--fast) var(--wp--custom--ease--out);
}

.notfound__search button:hover {
	background: var(--wp--preset--color--primary-hover);
}

.notfound__actions {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--3);
	margin-top: var(--wp--preset--spacing--2);
}

/* Post listing (blog / generic archive). */
.wp-block-query .wp-block-post-title {
	margin: 0 0 var(--wp--preset--spacing--2);
	font-size: var(--wp--preset--font-size--xl-2);
	letter-spacing: -0.025em;
}

.wp-block-query .wp-block-post-template > li + li {
	margin-top: var(--wp--preset--spacing--10);
	padding-top: var(--wp--preset--spacing--10);
	border-top: 1px solid var(--wp--custom--border--on-light);
}

.archive-heading {
	margin: var(--wp--preset--spacing--10) 0 var(--wp--preset--spacing--8);
	font-size: var(--wp--preset--font-size--xl-4);
	font-weight: 800;
	line-height: 1.05;
	letter-spacing: -0.035em;
	text-wrap: balance;
}

/* --- Static content pages (Гарантія, Контакти, Доставка …) ------------ */

/*
 * These pages were left with no treatment at all: the title rendered at the
 * default heading size with no vertical rhythm, which read as unfinished next
 * to the rest of the site.
 */
/*
 * Named .content-page, not .page: WordPress puts a `page` class on <body> for
 * every page, so a bare `.page` rule here also matched the document body and
 * added 144px of padding under the footer on every single page.
 */
.content-page {
	padding-bottom: var(--wp--custom--section--padding);
}

.content-page__title {
	margin: var(--wp--preset--spacing--8) 0 var(--wp--preset--spacing--10);
	font-size: var(--wp--preset--font-size--xl-4);
	font-weight: 800;
	line-height: 1.05;
	letter-spacing: -0.035em;
	text-wrap: balance;
}

.content-page .wp-block-post-content {
	font-size: var(--wp--preset--font-size--lg);
	line-height: 1.7;
	color: var(--wp--preset--color--contrast-subtle);
}

.content-page .wp-block-post-content > * + * {
	margin-top: var(--wp--preset--spacing--5);
}

.content-page .wp-block-post-content :where(h2, h3, h4) {
	margin-top: var(--wp--preset--spacing--12);
	color: var(--wp--preset--color--contrast);
}

.content-page .wp-block-post-content :where(ul, ol) {
	padding-left: var(--wp--preset--spacing--5);
}

.content-page .wp-block-post-content li + li {
	margin-top: var(--wp--preset--spacing--2);
}

.content-page .wp-block-post-content a:not(.wp-block-button__link) {
	color: var(--wp--preset--color--contrast);
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
}

/*
 * Building blocks for the info pages (Про нас, Доставка, Контакти, Оферта,
 * Центр підтримки). All of them are plain core blocks with a className, so the
 * pages stay editable in the block editor.
 */

/* Callout. --todo marks facts that still have to be confirmed by the owner. */
.content-page .ef-note {
	padding: var(--wp--preset--spacing--5) var(--wp--preset--spacing--6);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--lg);
	background: var(--wp--preset--color--base-soft);
	font-size: var(--wp--preset--font-size--base);
}

.content-page .ef-note > * + * {
	margin-top: var(--wp--preset--spacing--2);
}

.content-page .ef-note--warning {
	border-color: var(--wp--preset--color--warning);
	background: color-mix(in srgb, var(--wp--preset--color--warning) 8%, var(--wp--preset--color--base));
}

.content-page .ef-todo {
	padding: 0.1em 0.4em;
	border-radius: 4px;
	background: color-mix(in srgb, var(--wp--preset--color--warning) 18%, var(--wp--preset--color--base));
	color: var(--wp--preset--color--contrast);
	font-size: 0.9em;
	font-weight: 600;
}

/* Card grid: contact channels, "чому ми" points. */
.content-page .ef-cards {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--wp--preset--spacing--4);
}

.content-page .ef-cards > .ef-card {
	margin: 0;
	padding: var(--wp--preset--spacing--6);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--lg);
	background: var(--wp--preset--color--base);
	font-size: var(--wp--preset--font-size--base);
	overflow-wrap: anywhere;
}

.content-page .ef-card > * {
	margin: 0;
}

.content-page .ef-card > * + * {
	margin-top: var(--wp--preset--spacing--2);
}

.content-page .ef-card :where(h3) {
	margin-top: 0;
	font-size: var(--wp--preset--font-size--sm);
	font-weight: 600;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: var(--wp--preset--color--contrast-muted);
}

.content-page .ef-card__value {
	font-size: var(--wp--preset--font-size--lg);
	font-weight: 700;
	color: var(--wp--preset--color--contrast);
}

/* FAQ accordion (core/details). */
.content-page .ef-faq {
	border-top: 1px solid var(--wp--preset--color--border);
}

.content-page .ef-faq > .wp-block-details {
	margin: 0;
	border-bottom: 1px solid var(--wp--preset--color--border);
}

.content-page .ef-faq summary {
	position: relative;
	padding: var(--wp--preset--spacing--5) var(--wp--preset--spacing--10) var(--wp--preset--spacing--5) 0;
	list-style: none;
	cursor: pointer;
	font-size: var(--wp--preset--font-size--lg);
	font-weight: 600;
	line-height: 1.4;
	color: var(--wp--preset--color--contrast);
}

.content-page .ef-faq summary::-webkit-details-marker {
	display: none;
}

.content-page .ef-faq summary::after {
	content: "+";
	position: absolute;
	top: 50%;
	right: 0;
	transform: translateY(-50%);
	font-size: 1.5em;
	font-weight: 400;
	line-height: 1;
	transition: transform var(--wp--custom--duration--fast) var(--wp--custom--ease--out);
}

.content-page .ef-faq details[open] > summary::after {
	transform: translateY(-50%) rotate(45deg);
}

.content-page .ef-faq summary:focus-visible {
	outline: 2px solid var(--wp--preset--color--contrast);
	outline-offset: 4px;
}

.content-page .ef-faq .wp-block-details > :not(summary) {
	margin: 0 0 var(--wp--preset--spacing--4);
	font-size: var(--wp--preset--font-size--base);
}

/* Google Maps embed on Контакти. */
.content-page .ef-map iframe {
	display: block;
	width: 100%;
	height: clamp(280px, 50vw, 420px);
	border: 0;
	border-radius: var(--wp--custom--radius--lg);
	background: var(--wp--preset--color--base-subtle);
}

/* Long legal text: tighter, numbered-clause friendly. */
.content-page .ef-legal {
	font-size: var(--wp--preset--font-size--base);
}

.content-page .ef-legal :where(h2) {
	font-size: var(--wp--preset--font-size--xl-2);
}

@media (max-width: 600px) {
	.content-page .ef-cards {
		grid-template-columns: minmax(0, 1fr);
	}

	.content-page .ef-note,
	.content-page .ef-cards > .ef-card {
		padding: var(--wp--preset--spacing--5);
	}
}

/* Breadcrumbs are shared by pages, the catalogue and single products. */
.wp-block-woocommerce-breadcrumbs {
	margin-top: var(--wp--preset--spacing--6);
	font-size: var(--wp--preset--font-size--sm);
	color: var(--wp--preset--color--contrast-muted);
}

.wp-block-woocommerce-breadcrumbs a {
	color: var(--wp--preset--color--contrast-subtle);
	text-decoration: none;
	border-bottom: 1px solid transparent;
	transition: border-color var(--wp--custom--duration--fast) var(--wp--custom--ease--out);
}

.wp-block-woocommerce-breadcrumbs a:hover {
	border-bottom-color: var(--wp--preset--color--contrast-subtle);
}

/*
 * WordPress gives every top-level block a --wp--style--block-gap margin. The
 * header is position:fixed and out of flow, so that margin landed on <main>
 * instead - a 24px white strip above the hero, and another above the footer.
 * Header, main and footer are meant to sit flush.
 */
.wp-site-blocks > header,
.wp-site-blocks > main,
.wp-site-blocks > footer {
	margin-block: 0;
}

/* --- Touch input ------------------------------------------------------- */

/*
 * iOS Safari zooms the page into any field under 16px on focus, and a zoomed
 * page re-arms double-tap-to-zoom: the next tap on a button is held back as a
 * possible double tap, and the bottom bars move under the finger when the
 * keyboard closes - the "had to tap Оформити twice" on checkout. Checkout's own
 * 16px rule (checkout.css) loses to WooCommerce's
 * `.woocommerce-page form .form-row input.input-text`, and the qty, search and
 * price-filter fields were 13-14px, hence !important. Touch devices only;
 * mouse users keep the designed sizes.
 */
@media (hover: none) and (pointer: coarse) {
	input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="button"]):not([type="submit"]):not([type="hidden"]),
	select,
	textarea {
		font-size: max(16px, 1em) !important;
	}
}

/* No double-tap-to-zoom on controls, so a single tap is never held back. */
a,
button,
input,
select,
textarea,
label,
summary,
[role="button"] {
	touch-action: manipulation;
}
