/*
 * HiTech Cookie Consent: front end.
 *
 * Theme-proofing: themes and page builders style bare `button`, `h2`, `a`
 * (Elementor kits use `.elementor-kit-N button`, specificity 0,1,1, and turned
 * our category toggles into red pills on hitech-us). Everything here is scoped
 * under #htcc-root (an id, 1,x,x), and buttons are reset with `all: unset`
 * before being styled, so a theme can only win with !important.
 *
 * Colours come from :root variables printed by PHP; the rest is derived from
 * them with color-mix so any brand palette stays calm and consistent.
 */
:where(:root) {
	--htcc-bg: #fff; --htcc-text: #1f2937; --htcc-primary: #1f2937; --htcc-primary-text: #fff;
	--htcc-secondary: #f3f4f6; --htcc-secondary-text: #1f2937; --htcc-toggle: #2563eb;
	--htcc-radius: 12px; --htcc-font-size: 14px;
}

#htcc-root {
	--htcc-accent: var(--htcc-toggle);
	--htcc-muted: color-mix(in srgb, var(--htcc-text) 70%, var(--htcc-bg));
	--htcc-border: color-mix(in srgb, var(--htcc-text) 12%, transparent);
	--htcc-soft: color-mix(in srgb, var(--htcc-text) 5%, var(--htcc-bg));
	--htcc-btn-radius: calc(var(--htcc-radius) * .6);
	--htcc-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 12px 32px -8px rgba(16, 24, 40, .18);
	font-family: inherit; /* the site's own font */
	font-size: var(--htcc-font-size); line-height: 1.55; color: var(--htcc-text);
	font-weight: 400; letter-spacing: normal; text-transform: none; text-align: left;
	-webkit-font-smoothing: antialiased;
}
#htcc-root *, #htcc-root *::before, #htcc-root *::after { box-sizing: border-box; }
#htcc-root button {
	all: unset; box-sizing: border-box; cursor: pointer; font-family: inherit;
	-webkit-tap-highlight-color: transparent;
}
#htcc-root h2, #htcc-root p, #htcc-root ul, #htcc-root dl, #htcc-root dd { margin: 0; padding: 0; }
#htcc-root svg { display: block; flex: 0 0 auto; }
html.htcc-locked { overflow: hidden; }

/* ---------------- first layer ---------------- */
#htcc-root .htcc-banner-wrap { position: fixed; z-index: 2147483640; }
#htcc-root .htcc-banner {
	position: relative; background: var(--htcc-bg); color: var(--htcc-text);
	border: 1px solid var(--htcc-border); border-radius: var(--htcc-radius);
	box-shadow: var(--htcc-shadow); padding: 20px 22px; animation: htcc-in .22s ease-out;
}
@keyframes htcc-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
	#htcc-root .htcc-banner, #htcc-root .htcc-prefs { animation: none; }
	#htcc-root .htcc-slider, #htcc-root .htcc-slider::before, #htcc-root .htcc-chevron { transition: none; }
}

#htcc-root .htcc-layout-box { width: calc(100% - 32px); max-width: 400px; }
#htcc-root .htcc-layout-box.htcc-pos-bottom-left { left: 16px; bottom: 16px; }
#htcc-root .htcc-layout-box.htcc-pos-bottom-right { right: 16px; bottom: 16px; }
#htcc-root .htcc-layout-box.htcc-pos-bottom { left: 50%; bottom: 16px; transform: translateX(-50%); }
#htcc-root .htcc-layout-box.htcc-pos-top { left: 50%; top: 16px; transform: translateX(-50%); }

#htcc-root .htcc-layout-bar { left: 0; right: 0; bottom: 0; }
#htcc-root .htcc-layout-bar.htcc-pos-top { top: 0; bottom: auto; }
#htcc-root .htcc-layout-bar .htcc-banner {
	border-radius: 0; border-width: 1px 0 0; display: flex; gap: 32px; align-items: center;
	padding: 16px max(24px, calc((100% - 1160px) / 2));
}
#htcc-root .htcc-layout-bar.htcc-pos-top .htcc-banner { border-width: 0 0 1px; }
#htcc-root .htcc-layout-bar .htcc-banner-text { flex: 1 1 auto; max-width: 760px; }
#htcc-root .htcc-layout-bar .htcc-actions { flex: 0 0 auto; margin-top: 0; }

#htcc-root .htcc-layout-modal { inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; }
#htcc-root .htcc-layout-modal .htcc-banner { max-width: 480px; width: 100%; }
#htcc-root .htcc-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); backdrop-filter: blur(2px); }
#htcc-root .htcc-banner-wrap .htcc-overlay { z-index: -1; }

#htcc-root .htcc-title {
	display: block; font-family: inherit; font-size: 1.07em; font-weight: 600; line-height: 1.35;
	color: var(--htcc-text); margin: 0 0 6px; letter-spacing: -0.005em; text-transform: none;
}
#htcc-root .htcc-msg { color: var(--htcc-muted); font-size: .95em; }
#htcc-root .htcc-msg p + p { margin-top: 6px; }
#htcc-root a { color: var(--htcc-text); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--htcc-text) 35%, transparent); text-underline-offset: 2px; font-weight: inherit; }
#htcc-root a:hover { color: var(--htcc-accent); text-decoration-color: currentColor; }
#htcc-root .htcc-links { margin-top: 8px; font-size: .88em; color: var(--htcc-muted); display: flex; flex-wrap: wrap; gap: 4px 14px; }

#htcc-root .htcc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; align-items: center; }
#htcc-root .htcc-layout-box .htcc-actions .htcc-btn:not(.htcc-btn-link),
#htcc-root .htcc-layout-modal .htcc-actions .htcc-btn:not(.htcc-btn-link) { flex: 1 1 0; }
#htcc-root .htcc-layout-box .htcc-actions .htcc-btn-link,
#htcc-root .htcc-layout-modal .htcc-actions .htcc-btn-link { flex: 1 1 100%; order: 3; }

/* ---------------- buttons ---------------- */
#htcc-root .htcc-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px;
	padding: 8px 16px; border: 1px solid transparent; border-radius: var(--htcc-btn-radius);
	font-size: .93em; font-weight: 600; line-height: 1.2; text-align: center; white-space: nowrap;
	transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
#htcc-root .htcc-btn-primary { background: var(--htcc-primary); color: var(--htcc-primary-text); border-color: var(--htcc-primary); }
#htcc-root .htcc-btn-primary:hover { background: color-mix(in srgb, var(--htcc-primary) 88%, #000); border-color: color-mix(in srgb, var(--htcc-primary) 88%, #000); }
#htcc-root .htcc-btn-secondary { background: var(--htcc-secondary); color: var(--htcc-secondary-text); border-color: var(--htcc-border); }
#htcc-root .htcc-btn-secondary:hover { background: color-mix(in srgb, var(--htcc-secondary) 92%, var(--htcc-text)); }
#htcc-root .htcc-btn-link { min-height: 32px; padding: 4px 6px; background: none; color: var(--htcc-muted); font-weight: 500; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--htcc-text) 30%, transparent); text-underline-offset: 3px; }
#htcc-root .htcc-btn-link:hover { color: var(--htcc-text); text-decoration-color: currentColor; }
#htcc-root .htcc-btn:focus-visible, #htcc-root .htcc-x:focus-visible, #htcc-root .htcc-cat-name:focus-visible,
#htcc-root .htcc-switch input:focus-visible + .htcc-slider, #htcc-root a:focus-visible {
	outline: 2px solid var(--htcc-accent); outline-offset: 2px;
}
#htcc-root .htcc-float:focus-visible { outline: 2px solid var(--htcc-accent); outline-offset: 3px; }

#htcc-root .htcc-x {
	position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 50%;
	display: flex; align-items: center; justify-content: center; color: var(--htcc-muted); transition: background-color .15s, color .15s;
}
#htcc-root .htcc-x:hover { background: var(--htcc-soft); color: var(--htcc-text); }
#htcc-root .htcc-banner .htcc-x { top: 10px; right: 10px; }
#htcc-root .htcc-banner:has(.htcc-x) .htcc-title { padding-right: 28px; }

/* ---------------- preference centre ---------------- */
#htcc-root .htcc-prefs-wrap { position: fixed; inset: 0; z-index: 2147483645; display: flex; align-items: center; justify-content: center; padding: 16px; }
#htcc-root .htcc-prefs-wrap[hidden] { display: none; }
#htcc-root .htcc-prefs-wrap .htcc-overlay { z-index: 0; }
#htcc-root .htcc-prefs {
	position: relative; z-index: 1; display: flex; flex-direction: column; width: 100%; max-width: 560px;
	max-height: min(86vh, 720px); background: var(--htcc-bg); color: var(--htcc-text);
	border: 1px solid var(--htcc-border); border-radius: var(--htcc-radius); box-shadow: var(--htcc-shadow);
	animation: htcc-in .2s ease-out; overflow: hidden;
}
#htcc-root .htcc-prefs-head { position: relative; padding: 18px 56px 14px 22px; border-bottom: 1px solid var(--htcc-border); }
#htcc-root .htcc-prefs-head .htcc-title { margin: 0; }
#htcc-root .htcc-prefs-body { overflow-y: auto; padding: 16px 22px 18px; flex: 1 1 auto; overscroll-behavior: contain; }
#htcc-root .htcc-prefs-body > .htcc-msg { margin-bottom: 8px; }
#htcc-root .htcc-prefs-foot {
	display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px;
	padding: 14px 22px; border-top: 1px solid var(--htcc-border); background: var(--htcc-soft);
}
#htcc-root .htcc-prefs-foot .htcc-btn { flex: 0 1 auto; }
#htcc-root .htcc-gpc { margin-top: 10px; padding: 8px 12px; border-radius: var(--htcc-btn-radius); background: var(--htcc-soft); color: var(--htcc-muted); font-size: .88em; }

#htcc-root .htcc-cat { padding: 14px 0; border-bottom: 1px solid var(--htcc-border); }
#htcc-root .htcc-cat:last-of-type { border-bottom: 0; }
#htcc-root .htcc-cat-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
#htcc-root .htcc-cat-name {
	display: inline-flex; align-items: center; gap: 8px; padding: 2px 0; border-radius: 4px;
	font-weight: 600; color: var(--htcc-text); font-size: 1em; line-height: 1.4;
}
#htcc-root .htcc-cat-name:hover { color: var(--htcc-accent); }
#htcc-root .htcc-count {
	font-weight: 500; font-size: .8em; color: var(--htcc-muted); background: var(--htcc-soft);
	border: 1px solid var(--htcc-border); border-radius: 999px; padding: 0 7px; line-height: 1.6;
}
#htcc-root .htcc-chevron { color: var(--htcc-muted); transition: transform .15s; }
#htcc-root .htcc-cat-name[aria-expanded="true"] .htcc-chevron { transform: rotate(90deg); }
#htcc-root .htcc-cat-desc { margin: 4px 0 0 22px; color: var(--htcc-muted); font-size: .9em; }
#htcc-root .htcc-cat-desc p { margin: 0; }
#htcc-root .htcc-cat-details { margin: 10px 0 0 22px; }
#htcc-root .htcc-always { font-size: .8em; font-weight: 600; color: var(--htcc-muted); white-space: nowrap; letter-spacing: .01em; }
#htcc-root .htcc-cookies-title { font-size: .8em; font-weight: 600; color: var(--htcc-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
#htcc-root .htcc-cookie-list { list-style: none; font-size: .86em; border: 1px solid var(--htcc-border); border-radius: var(--htcc-btn-radius); }
#htcc-root .htcc-cookie-list li { padding: 8px 10px; border-top: 1px solid var(--htcc-border); }
#htcc-root .htcc-cookie-list li:first-child { border-top: 0; }
#htcc-root .htcc-cookie-list code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .95em; font-weight: 600; color: var(--htcc-text); background: none; padding: 0; }
#htcc-root .htcc-prov, #htcc-root .htcc-exp { color: var(--htcc-muted); }
#htcc-root .htcc-exp::before { content: "· "; }
#htcc-root .htcc-purpose { color: var(--htcc-muted); margin-top: 2px; }
#htcc-root .htcc-consent-info dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--htcc-border); font-size: .82em; color: var(--htcc-muted); }
#htcc-root .htcc-consent-info dd { word-break: break-all; color: var(--htcc-text); }
#htcc-root .htcc-prefs-body .htcc-links { margin-top: 12px; }

/* switch */
#htcc-root .htcc-switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: 0 0 auto; cursor: pointer; margin: 0; }
#htcc-root .htcc-switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
#htcc-root .htcc-slider { position: absolute; inset: 0; background: color-mix(in srgb, var(--htcc-text) 22%, var(--htcc-bg)); border-radius: 999px; transition: background-color .18s; }
#htcc-root .htcc-slider::before {
	content: ""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; background: #fff;
	border-radius: 50%; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .18s;
}
#htcc-root .htcc-switch input:checked + .htcc-slider { background: var(--htcc-accent); }
#htcc-root .htcc-switch input:checked + .htcc-slider::before { transform: translateX(16px); }
#htcc-root .htcc-switch input:disabled + .htcc-slider { opacity: .45; }
#htcc-root .htcc-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* floating button */
#htcc-root .htcc-float {
	position: fixed; bottom: 16px; z-index: 2147483630; width: 44px; height: 44px; border-radius: 50%;
	display: flex; align-items: center; justify-content: center;
	background: var(--htcc-bg); color: var(--htcc-text); border: 1px solid var(--htcc-border);
	box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 6px 16px -4px rgba(16, 24, 40, .16);
	transition: transform .15s, color .15s, box-shadow .15s; opacity: .92;
}
#htcc-root .htcc-float:hover { color: var(--htcc-accent); transform: translateY(-1px); opacity: 1; box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 10px 22px -6px rgba(16, 24, 40, .22); }
#htcc-root .htcc-float-left { left: 16px; }
#htcc-root .htcc-float-right { right: 16px; }

/* ---------------- outside #htcc-root: embed placeholder, declaration ---------------- */
.htcc-placeholder {
	--htcc-border: color-mix(in srgb, var(--htcc-text) 14%, transparent);
	max-width: 100%; min-height: 180px; display: flex; align-items: center; justify-content: center; text-align: center;
	background: color-mix(in srgb, var(--htcc-text) 4%, #fff); color: var(--htcc-text);
	border: 1px solid var(--htcc-border); border-radius: 10px; padding: 24px; font-size: 14px; line-height: 1.55;
}
.htcc-placeholder .htcc-ph-inner { max-width: 420px; }
.htcc-placeholder .htcc-ph-inner p { margin: 0 0 14px; color: color-mix(in srgb, var(--htcc-text) 75%, #fff); }
html body .htcc-placeholder button.htcc-btn {
	all: unset; box-sizing: border-box; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
	min-height: 36px; padding: 8px 16px; border-radius: 8px; font-family: inherit; font-size: 14px; font-weight: 600; line-height: 1.2;
	background: var(--htcc-primary); color: var(--htcc-primary-text);
}
html body .htcc-placeholder button.htcc-btn:hover { background: color-mix(in srgb, var(--htcc-primary) 88%, #000); }
html body .htcc-placeholder button.htcc-btn:focus-visible { outline: 2px solid var(--htcc-toggle); outline-offset: 2px; }

.htcc-consent-status { padding: 14px 16px; border: 1px solid rgba(0, 0, 0, .12); border-radius: 10px; margin-bottom: 24px; }
.htcc-consent-status dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 10px 0; font-size: .9em; }
.htcc-consent-status dt { opacity: .7; }
.htcc-consent-status dd { margin: 0; word-break: break-all; }
.htcc-decl-scroll { overflow-x: auto; margin-bottom: 24px; }
.htcc-decl-table { width: 100%; border-collapse: collapse; font-size: .9em; }
.htcc-decl-table th, .htcc-decl-table td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid rgba(0, 0, 0, .1); }
.htcc-decl-count { font-weight: 400; opacity: .6; }

/* ---------------- small screens ---------------- */
@media (max-width: 640px) {
	#htcc-root .htcc-layout-box { left: 8px !important; right: 8px; bottom: 8px !important; top: auto !important; width: auto; max-width: none; transform: none !important; }
	#htcc-root .htcc-layout-bar .htcc-banner { flex-direction: column; align-items: stretch; gap: 0; padding: 16px; }
	#htcc-root .htcc-layout-bar .htcc-actions { margin-top: 14px; }
	#htcc-root .htcc-banner { padding: 16px; max-height: 82vh; overflow-y: auto; }
	#htcc-root .htcc-actions .htcc-btn:not(.htcc-btn-link) { flex: 1 1 0; }
	#htcc-root .htcc-actions .htcc-btn-link { flex: 1 1 100%; order: 3; }
	#htcc-root .htcc-prefs-wrap { padding: 0; align-items: flex-end; }
	#htcc-root .htcc-prefs { max-height: 92vh; border-radius: var(--htcc-radius) var(--htcc-radius) 0 0; }
	#htcc-root .htcc-prefs-foot { justify-content: stretch; }
	#htcc-root .htcc-prefs-foot .htcc-btn { flex: 1 1 calc(50% - 4px); }
	#htcc-root .htcc-prefs-foot .htcc-btn[data-htcc="accept"] { flex-basis: 100%; }
	#htcc-root .htcc-cat-desc, #htcc-root .htcc-cat-details { margin-left: 0; }
}
