/*
 * Design Refresh v2 base styles (enqueued as hitek-v2-base while v2 renders).
 * The floating preview switcher, and the placeholder chrome and content the
 * areas replace.
 */

/*
 * Floating "v2 preview" switcher (visitor preview only; inc/v2/core.php, assets/js/v2/preview.js).
 * Bottom right (the HITEK chat widget sits bottom left). preview.js lifts it above fixed elements at the
 * bottom of the screen (--hitek-v2-preview-lift: consent banner, mobile bottom bar, chat widget, anything
 * marked data-hitek-v2-avoid). On phones it starts folded into a small "v2" pill.
 */
.hitek-v2-preview {
	position: fixed;
	right: calc(16px + env(safe-area-inset-right, 0px));
	bottom: calc(16px + env(safe-area-inset-bottom, 0px));
	z-index: 99990;
	box-sizing: border-box;
	max-width: min(320px, calc(100vw - 32px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
	border: 1px solid rgb(255 255 255 / 0.14);
	border-radius: 10px;
	background: rgb(13 13 13 / 0.96);
	box-shadow: 0 12px 32px rgb(0 0 0 / 0.45);
	color: #f5f5f5;
	font-size: 13px;
	line-height: 1.45;
}

/* Placed by preview.js: above whatever is fixed at the bottom under it. */
.hitek-v2-preview.is-placed {
	bottom: max(calc(16px + env(safe-area-inset-bottom, 0px)), calc(var(--hitek-v2-preview-lift, 0px) + 8px));
}

.hitek-v2-preview__toggle {
	display: flex;
	align-items: center;
	gap: 8px;
	box-sizing: border-box;
	width: 100%;
	min-height: 44px;
	padding: 10px 14px;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	font-weight: 700;
	letter-spacing: 0.02em;
	text-align: left;
	cursor: pointer;
	touch-action: manipulation;
}

.hitek-v2-preview__dot {
	flex: none;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #ed001e;
	box-shadow: 0 0 0 3px rgb(237 0 30 / 0.25);
}

.hitek-v2-preview__short {
	display: none;
}

.hitek-v2-preview__body {
	padding: 0 14px 12px;
}

.hitek-v2-preview__body p {
	margin: 0 0 8px;
	color: rgb(255 255 255 / 0.7);
}

.hitek-v2-preview__body .hitek-v2-preview__note {
	font-size: 12px;
	color: rgb(255 255 255 / 0.58);
}

.hitek-v2-preview__body ul {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.hitek-v2-preview__body a {
	display: inline-block;
	padding: 6px 10px;
	border-radius: 6px;
	background: #ed001e;
	color: #fff;
	font-weight: 700;
	text-decoration: none;
}

.hitek-v2-preview__body li + li a {
	background: rgb(255 255 255 / 0.1);
}

.hitek-v2-preview__body a:hover,
.hitek-v2-preview__body a:focus-visible {
	filter: brightness(1.12);
}

.hitek-v2-preview a:focus-visible,
.hitek-v2-preview button:focus-visible {
	outline: 2px solid #ed001e;
	outline-offset: 2px;
}

.hitek-v2-preview.is-collapsed .hitek-v2-preview__body {
	display: none;
}

/* Without the script: clear the mobile bottom bar of the site header. */
@media (max-width: 1023px) {
	.hitek-v2-preview:not(.is-placed) {
		bottom: calc(84px + env(safe-area-inset-bottom, 0px));
	}

	.hitek-v2-preview__body a {
		display: inline-flex;
		align-items: center;
		min-height: 44px;
		box-sizing: border-box;
		padding: 8px 14px;
	}
}

/* Phones: a folded switcher is a small "v2" pill; unfolded it may use the width of the screen. */
@media (max-width: 767px) {
	.hitek-v2-preview {
		max-width: calc(100vw - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
	}

	.hitek-v2-preview.is-placed {
		right: calc(12px + env(safe-area-inset-right, 0px));
	}

	.hitek-v2-preview:not(.is-collapsed) .hitek-v2-preview__body {
		max-height: calc(100vh - var(--hitek-v2-preview-lift, 0px) - 120px);
		max-height: calc(100dvh - var(--hitek-v2-preview-lift, 0px) - 120px);
		overflow-y: auto;
		overscroll-behavior: contain;
	}

	.hitek-v2-preview.is-collapsed {
		border-radius: 999px;
	}

	.hitek-v2-preview.is-collapsed .hitek-v2-preview__toggle {
		justify-content: center;
		width: auto;
		min-width: 52px;
		padding: 10px 14px;
	}

	.hitek-v2-preview.is-collapsed .hitek-v2-preview__label {
		position: absolute;
		width: 1px;
		height: 1px;
		margin: -1px;
		padding: 0;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
		border: 0;
	}

	.hitek-v2-preview.is-collapsed .hitek-v2-preview__short {
		display: inline;
	}
}

/*
 * Consent banner and preferences above the HITEK Manager chat widget (#hitek-chat-iframe, z-index 999998, bottom
 * left; loaded by inc/rest-api.php). Below that, on phones the widget covers "Reject all" and preference
 * checkboxes (spec §8a); refusing must stay as easy as accepting. consent.css (z-index 100000) is unchanged, so the
 * site without v2 still has the overlap.
 */
body.hitek-v2 .hitek-consent {
	z-index: 999999;
}

/*
 * Headings inside the design inherit their section colour, as in the export. WordPress's global styles
 * (theme.json elements.heading: "h1, h2, h3, h4, h5, h6 { color: #FFFFFF }", #global-styles-inline-css) do not
 * exist there. Same specificity as that rule (0,0,1) and printed after it, so every class-based rule (the
 * scoped export CSS, the areas' CSS, Tailwind utilities) still sets heading colours as before.
 */
:where(.hwr2) :is(h1, h2, h3, h4, h5, h6) {
	color: inherit;
}

/*
 * Headings of the live WooCommerce description on dealer supply pages (D3's .recovered-product-details, whose
 * body text is #d4d4d4) take the page colour, as in the export, where that box has no colour of its own and its
 * headings inherit the dealer body's #f6f6f6. Same specificity as the rules above, so inline styles and class-based
 * colours in the description still win.
 */
:where(.hwr2 .recovered-product-details) :is(h1, h2, h3, h4, h5, h6) {
	color: #f6f6f6;
}

/*
 * Touch targets of theme controls on every v2 page (spec §8a, 44x44 where the design allows): the notification
 * bar's dismiss button (28x28, inc/notification-bar.php), the site popup's close button (32x32,
 * template-parts/popup.php) and the cookie banner's close button (36x36, shown when "Cookie settings" reopens
 * the banner, template-parts/consent-banner.php) keep their look and get a 44x44 hit area. The bar's 10px
 * padding, the popup panel's 8px inset and the banner's padding (16px on phones) less the button's -8px / -10px
 * margins hold it, so their overflow: hidden does not clip it. v1 keeps the theme's sizes.
 */
@media (max-width: 760px), (pointer: coarse) {
	body.hitek-v2 .hitek-notif-bar__close,
	body.hitek-v2 .hitek-consent__close {
		position: relative;
	}

	body.hitek-v2 .hitek-notif-bar__close::after,
	body.hitek-v2 .hitek-popup button[data-popup-close]::after,
	body.hitek-v2 .hitek-consent__close::after {
		content: "";
		position: absolute;
		inset: calc((100% - 44px) / 2);
	}
}

/*
 * The site popup's close button takes focus when the popup opens (assets/js/v2/popup-focus.js). Its red focus
 * ring (Tailwind focus:ring-2) shows for keyboard focus only, so a popup that opens after a click or tap looks
 * as it did.
 */
body.hitek-v2 .hitek-popup button[data-popup-close]:focus:not(:focus-visible) {
	box-shadow: none;
}

/* Placeholder dealer chrome (template-parts/v2/chrome/dealer-*.php). */
.hitek-v2-stub-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px 24px;
	padding: 14px 16px;
	border-bottom: 1px solid rgb(255 255 255 / 0.1);
	background: #0d0d0d;
	color: rgb(255 255 255 / 0.75);
	font-size: 13px;
}

footer.hitek-v2-stub-bar {
	justify-content: space-between;
	margin-top: 48px;
	border-top: 1px solid rgb(255 255 255 / 0.1);
	border-bottom: 0;
}

.hitek-v2-stub-bar p {
	margin: 0;
}

.hitek-v2-stub-bar__brand img {
	display: block;
	width: auto;
	height: 26px;
}

.hitek-v2-stub-bar__note {
	color: #ed001e;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.hitek-v2-stub-bar__links {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	margin-left: auto;
}

.hitek-v2-stub-bar a,
.hitek-v2-stub-bar button {
	border: 0;
	background: none;
	color: #fff;
	font: inherit;
	text-decoration: none;
	cursor: pointer;
}

.hitek-v2-stub-bar a:hover,
.hitek-v2-stub-bar button:hover {
	color: #ed001e;
}

/* Placeholder content (template-parts/v2/placeholder.php). */
.hitek-v2-placeholder {
	box-sizing: border-box;
	max-width: 880px;
	margin: 48px auto;
	padding: 28px 24px;
	border: 2px dashed rgb(237 0 30 / 0.6);
	border-radius: 12px;
	color: rgb(255 255 255 / 0.8);
}

.hitek-v2-placeholder h1 {
	margin: 0 0 8px;
	color: #fff;
	font-size: clamp(24px, 4vw, 34px);
	line-height: 1.15;
}

.hitek-v2-placeholder__eyebrow {
	margin: 0 0 8px;
	color: #ed001e;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
}

.hitek-v2-placeholder dl {
	display: grid;
	gap: 6px;
	margin: 20px 0 0;
}

.hitek-v2-placeholder dl > div {
	display: grid;
	grid-template-columns: minmax(80px, 120px) 1fr;
	gap: 12px;
}

.hitek-v2-placeholder dt {
	color: rgb(255 255 255 / 0.5);
}

.hitek-v2-placeholder dd {
	margin: 0;
	overflow-wrap: anywhere;
	color: #fff;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 13px;
}

@media (max-width: 480px) {
	.hitek-v2-placeholder {
		margin: 24px 16px;
		padding: 20px 16px;
	}
}
