/*
 * Global styles: reset, accessibility basics, layout primitives.
 * Tokens come from theme.json (--wp--preset--*). Keep this file small:
 * block-specific rules go in assets/css/blocks/core-<block>.css.
 */

/* Reset in a layer so core and theme.json win. */
@layer reset {
	*,
	*::before,
	*::after {
		box-sizing: border-box;
	}

	html {
		-webkit-text-size-adjust: none;
		text-size-adjust: none;
	}

	body {
		margin: 0;
	}

	/* Not in TinyMCE: its autoresize iframe grows forever. */
	body:not(.mce-content-body) {
		min-height: 100dvh;
	}

	img,
	picture,
	video,
	canvas,
	svg {
		display: block;
		max-width: 100%;
	}

	svg.cmlmt-icon {
		display: inline-block;
		flex-shrink: 0;
		vertical-align: middle;
	}

	img,
	video {
		height: auto;
	}

	input,
	button,
	textarea,
	select {
		font: inherit;
	}

	h1,
	h2,
	h3,
	h4 {
		text-wrap: balance;
	}

	p,
	li,
	figcaption {
		text-wrap: pretty;
		overflow-wrap: break-word;
	}
}

/* Short names for theme.json tokens. */
:root {
	--r-lg: var(--wp--custom--radius--lg);
	--r-md: var(--wp--custom--radius--md);
	--r-pill: var(--wp--custom--radius--pill);
	--r-sm: var(--wp--custom--radius--sm);
	--c-base: var(--wp--preset--color--base);
	--c-contrast: var(--wp--preset--color--contrast);
	--c-critical: var(--wp--preset--color--critical);
	--c-good: var(--wp--preset--color--good);
	--c-line: var(--wp--preset--color--line);
	--c-line-strong: var(--wp--preset--color--line-strong);
	--c-field-line: color-mix(in srgb, var(--c-line-strong) 45%, var(--c-line)); /* Input borders: softer than line-strong, darker on hover and focus. */
	--c-muted: var(--wp--preset--color--muted);
	--c-night: var(--wp--preset--color--night);
	--c-soft: var(--wp--preset--color--soft);
	--c-sunken: var(--wp--preset--color--sunken);
	--c-surface: var(--wp--preset--color--surface);
	--ff-display: var(--wp--preset--font-family--display);
	--ff-mono: var(--wp--preset--font-family--mono);
	--fs-large: var(--wp--preset--font-size--large);
	--fs-medium: var(--wp--preset--font-size--medium);
	--fs-small: var(--wp--preset--font-size--small);
	--fs-ctl: 1rem; /* 16px on touch: iOS zooms into smaller fields. */
	--fs-x-small: var(--wp--preset--font-size--x-small);
	--sp-50: var(--wp--preset--spacing--50);
	/* Fluid card padding and section gap. */
	--pad: clamp(1.25rem, 1rem + 1vw, 1.5rem);
	--pad-l: clamp(1.25rem, 0.85rem + 1.7vw, 1.75rem);
	--gap-l: clamp(1.75rem, 1.2rem + 2vw, 2.5rem);
}

/* Fluid root: 16px on phones to 105% at ~1200px. */
@media (pointer: fine) {
	:root {
		--fs-ctl: var(--fs-small);
	}
}

/* :root, not html, so plugin resets like html { font-size: 62.5% } loaded later cannot shrink every rem. */
:root {
	font-size: clamp(100%, 0.97rem + 0.12vw, 105%);
}

body {
	-webkit-font-smoothing: antialiased;
}

/* Accessibility basics. */
.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

:focus-visible {
	outline: 2px solid var(--wp--preset--color--accent-ink);
	outline-offset: 2px;
}

:target {
	scroll-margin-block-start: var(--wp--preset--spacing--60);
}

a {
	text-underline-offset: 3px;
	text-decoration-color: var(--c-line-strong);
	transition: text-decoration-color 150ms ease;
}

a:hover {
	text-decoration-color: currentColor;
}

/*
 * Components shared by the store, the account area and License Monks screens.
 * Short names on purpose: these classes also go in "Additional CSS class".
 */
.cmlmt-label {
	font-family: var(--ff-mono);
	font-size: var(--fs-x-small);
	line-height: 1.35;
	color: var(--c-muted);
}

.cmlmt-mono {
	font-family: var(--ff-mono);
	font-variant-numeric: tabular-nums;
}

.cmlmt-lede {
	max-width: 62ch;
	color: var(--c-muted);
}

/* Headings take their section color. Beats site-wide h1-h6 colors from plugins like Core Framework. */
body :is(h1, h2, h3, h4, h5, h6) {
	color: inherit;
}

.cmlmt-hl,
h1 mark {
	background: none;
	color: inherit;
	box-shadow: inset 0 -0.34em 0 var(--wp--preset--color--mark);
}

.cmlmt-card {
	padding: 1.125rem 1.25rem;
	background: var(--c-surface);
	border: 1px solid var(--c-line);
	border-radius: var(--r-lg);
}

.cmlmt-well {
	padding: 0.75rem 0.875rem;
	background: var(--c-sunken);
	border-radius: var(--r-md);
}

.cmlmt-ink {
	padding: var(--pad);
	background: var(--c-contrast);
	color: var(--wp--preset--color--on-ink);
	border-radius: var(--r-lg);
}

.cmlmt-ink :is(p, .cmlmt-label) {
	color: var(--wp--preset--color--on-ink-muted);
}

/* Fields: WooCommerce, License Monks and theme forms. */
:where(input:not([type=checkbox], [type=radio], [type=submit], [type=button], [type=hidden]), select, textarea) {
	inline-size: 100%;
	padding: 0.5rem 0.75rem;
	border: 1px solid var(--c-field-line);
	border-radius: var(--r-sm);
	background-color: var(--c-surface);
	color: var(--c-contrast);
	font-size: var(--fs-ctl);
	line-height: 1.43;
	transition: border-color 150ms ease;
}

:where(input, select, textarea):hover {
	border-color: var(--c-line-strong);
}

:where(input, select, textarea):focus-visible {
	border-color: var(--c-contrast);
}

:where(input[type=checkbox], input[type=radio]) {
	inline-size: 1.125rem;
	block-size: 1.125rem;
	margin: 0;
	accent-color: var(--c-contrast);
}

:where(label) {
	font-size: var(--fs-small);
	font-weight: 600;
}

::placeholder {
	color: #737e78;
}

/* Button variants; primary is in theme.json. */
.wp-element-button,
.wp-block-button__link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	border: 1px solid transparent;
	cursor: pointer;
	white-space: nowrap;
	transition: transform 160ms var(--wp--custom--ease-out), background-color 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
}

.wp-element-button:active {
	transform: scale(0.97);
}

.is-style-outline > .wp-block-button__link,
.cmlmt-btn-secondary {
	padding: 0.5rem 1rem;
	border: 1px solid var(--c-line-strong);
	background: var(--c-surface);
	color: var(--c-contrast);
	box-shadow: none;
}

.is-style-outline > .wp-block-button__link:hover,
.cmlmt-btn-secondary:hover {
	border-color: var(--c-contrast);
	background: var(--c-surface);
}

.cmlmt-btn-ghost {
	border-color: transparent;
	background: transparent;
	color: var(--c-muted);
	box-shadow: none;
}

.cmlmt-btn-ghost:hover {
	background: var(--c-sunken);
	color: var(--c-contrast);
}

.cmlmt-btn-sm {
	padding: 0.3125rem 0.75rem;
}

/* Badges. */
.cmlmt-badge {
	display: inline-flex;
	align-items: center;
	gap: 0.375rem;
	padding: 0 0.625rem;
	border-radius: var(--r-pill);
	background: var(--c-sunken);
	color: var(--c-muted);
	font-size: var(--fs-x-small);
	font-weight: 600;
	line-height: 1.25rem;
	white-space: nowrap;
}

.cmlmt-badge.is-good { background: var(--wp--preset--color--good-soft); color: var(--c-good); }
.cmlmt-badge.is-warning { background: var(--wp--preset--color--warning-soft); color: var(--wp--preset--color--warning); }
.cmlmt-badge.is-critical { background: var(--wp--preset--color--critical-soft); color: var(--c-critical); }
.cmlmt-badge.is-info { background: var(--wp--preset--color--info-soft); color: var(--wp--preset--color--info); }

/* Usage meter: <div class="cmlmt-meter"><i style="width:12%"></i></div>. */
.cmlmt-meter {
	height: 0.375rem;
	overflow: hidden;
	border-radius: var(--r-pill);
	background: var(--c-sunken);
	box-shadow: inset 0 0 0 1px var(--c-line);
}

.cmlmt-meter i {
	display: block;
	height: 100%;
	background: var(--c-contrast);
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}

/* Empty template parts take no space. */
.wp-block-template-part:not(:has(*)) {
	display: none;
}

/*
 * Layout primitives (Every Layout / CUBE CSS). Add the class in the block's
 * "Additional CSS class" field. Tune with the custom properties.
 */

/* Stack: vertical rhythm between siblings. */
.stack {
	display: flex;
	flex-direction: column;
	justify-content: flex-start;
}

.stack > * {
	margin-block: 0;
}

.stack > * + * {
	margin-block-start: var(--space, var(--wp--preset--spacing--40));
}

/* Cluster: wrapping row of items (tags, buttons, links). */
.cluster {
	display: flex;
	flex-wrap: wrap;
	align-items: var(--align, center);
	justify-content: var(--justify, flex-start);
	gap: var(--space, var(--wp--preset--spacing--30));
}

/* Header: dark tab hanging from a thin strip, shoulders curving into the page. */
.cmlmt-hdr {
	--tab-r: 1.75rem;
	--strip: 0.625rem; /* Ends exactly where the tab and its shoulders start. */
	overflow-x: clip; /* The shoulders would widen the page on phones; clip keeps the layout. */
	padding-block-start: var(--strip);
	background: linear-gradient(var(--c-night) var(--strip), transparent 0);
}

.cmlmt-hdr__bar {
	position: relative;
	gap: 1rem; /* Same as the menu items, so Support (account block) sits like one more link. */
	min-height: 4.5rem;
	padding: 0.625rem clamp(1rem, 3.4vw, 2.875rem);
	border-radius: 0 0 var(--tab-r) var(--tab-r);
	background: var(--c-night);
	box-shadow: 0 -2px 0 var(--c-night); /* Covers the hairline seam with the strip. */
	color: var(--wp--preset--color--on-ink);
}

.cmlmt-hdr__bar::before,
.cmlmt-hdr__bar::after {
	content: "";
	position: absolute;
	top: -2px; /* Overlaps the strip, so no seam; the curve keeps its place at the bottom. */
	width: var(--tab-r);
	height: calc(var(--tab-r) + 2px);
	pointer-events: none;
}

.cmlmt-hdr__bar::before {
	right: 100%;
	background: radial-gradient(circle at 0 100%, var(--c-base) calc(var(--tab-r) - 0.5px), var(--c-night) var(--tab-r));
}

.cmlmt-hdr__bar::after {
	left: 100%;
	background: radial-gradient(circle at 100% 100%, var(--c-base) calc(var(--tab-r) - 0.5px), var(--c-night) var(--tab-r));
}

.cmlmt-hdr :focus-visible {
	outline-color: var(--wp--preset--color--neon);
}

.cmlmt-brand {
	gap: 0.875rem;
}

.cmlmt-brand .wp-block-image {
	margin: 0;
}

/* Core makes the link inline-block, which adds descender space under the logo. */
.cmlmt-brand .wp-block-image a {
	display: block;
}

.cmlmt-brand__where {
	margin: 0;
	padding-inline-start: 0.875rem;
	border-inline-start: 1px solid var(--wp--preset--color--ink-line);
	color: var(--wp--preset--color--on-ink-muted);
}

.cmlmt-hdr__bar > .cmlmt-hdr__site {
	margin-inline-start: auto;
	font-size: 0.9375rem;
}

.cmlmt-hdr__site .cmlmt-nav__list {
	gap: 0.25rem clamp(0.25rem, 1.2vw, 1rem);
}

.cmlmt-hdr__site a,
a.cmlmt-hdr__site {
	display: block;
	padding: 0.375rem 0.5rem;
	color: var(--wp--preset--color--on-ink);
	text-decoration: none;
	transition: color 150ms ease;
}

/* Neon on hover and current page; specific enough to beat theme.json's link hover. */
.cmlmt-hdr :is(.cmlmt-hdr__site a, a.cmlmt-hdr__site, .cmlmt-account__login):is(:hover, [aria-current]) {
	color: var(--wp--preset--color--neon);
	text-decoration: none;
}

.cmlmt-hdr__bar > .cmlmt-brand + .wp-block-cmlm-theme-account {
	margin-inline-start: auto;
}

/* Footer: sage ground, sans column heads, faded wordmark, as on classicmonks.com. */
.cmlmt-foot {
	overflow: hidden;
	margin-block-start: var(--wp--preset--spacing--70);
	padding-block: clamp(3rem, 2rem + 4vw, 5.5rem) 0;
	background: var(--c-sunken);
	font-size: var(--fs-small);
}

.cmlmt-foot p {
	margin: 0;
}

.cmlmt-foot a {
	color: var(--c-muted);
	transition: color 150ms ease;
}

.cmlmt-foot a:hover {
	color: var(--c-contrast);
}

.cmlmt-foot__top {
	gap: var(--gap-l) 4rem;
}

.cmlmt-foot__about {
	flex: 1 1 280px;
	max-width: 22.5rem;
	gap: 1rem;
}

.cmlmt-foot__about .wp-block-image {
	margin: 0;
}

.cmlmt-foot__social a {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.375rem 0.875rem;
	border: 1px solid var(--c-line);
	border-radius: var(--r-pill);
	background: var(--c-surface);
	text-decoration: none;
}

.cmlmt-foot__cols {
	flex: 2 1 480px;
	gap: 1.5rem;
}

.cmlmt-foot__col {
	gap: 0.75rem;
	font-size: 0.9375rem;
}

.cmlmt-foot__col .cmlmt-label {
	margin-block-end: 0.125rem;
	color: var(--c-contrast);
	font: 600 var(--fs-small) / 1.43 var(--wp--preset--font-family--sans);
}

.cmlmt-foot__col a {
	text-decoration: none;
}

.cmlmt-foot__bottom {
	margin-block-start: var(--gap-l);
	padding-block: 1.25rem;
	border-top: 1px solid var(--c-line);
	color: var(--c-muted);
	font-size: 0.8125rem;
}

.cmlmt-foot__bottom.cmlmt-foot__bottom {
	gap: 0.5rem 1.5rem;
}

.cmlmt-foot__bottom > :last-child {
	margin-inline-start: auto;
}

.cmlmt-foot__bottom p {
	font-size: inherit;
}

.cmlmt-foot__top-link {
	display: inline-flex;
	align-items: center;
	gap: 0.375rem;
	text-decoration: none;
}

/* Standalone small links get a 24px tap height. */
:is(.cmlmt-foot__top-link, .cmlmt-crumbs a, a.cmlmt-label, a.cmlmt-sub, .cmlmt-well a, .cmlmt-trust a, .cmlmt-account__login, a.cmlmt-push) {
	min-height: 1.5rem;
	align-content: center;
}

.woocommerce-breadcrumb a {
	padding-block: 0.25rem;
}

/* Wordmark: the logo type at 12% ink, fading into the footer ground at the bottom. */
.cmlmt-foot__mark {
	margin-block-start: 2rem;
	aspect-ratio: 1320 / 159;
	background: linear-gradient(var(--c-contrast) 22%, transparent);
	-webkit-mask: url("../images/wordmark.svg") center bottom / contain no-repeat;
	mask: url("../images/wordmark.svg") center bottom / contain no-repeat;
}

/* Phones and small tablets: a round menu button opens a dark sheet from the top. */
@media (max-width: 47.99rem) {
	.cmlmt-hdr__bar > .cmlmt-hdr__site {
		order: 3;
		margin-inline-start: 0;
	}

	.cmlmt-hdr :is(.cmlmt-nav__toggle, .cmlmt-nav__close) {
		justify-content: center;
		inline-size: 2.5rem;
		block-size: 2.5rem;
		padding: 0;
		border: 0;
		border-radius: 50%;
		background: var(--wp--preset--color--ink-surface);
		color: var(--wp--preset--color--on-ink);
	}

	.cmlmt-hdr :is(.cmlmt-nav__toggle, .cmlmt-nav__close) span {
		position: absolute;
		inline-size: 1px;
		block-size: 1px;
		overflow: hidden;
		clip-path: inset(50%);
		white-space: nowrap;
	}

	.cmlmt-hdr .cmlmt-nav__panel {
		inset: 0 0 auto;
		block-size: auto;
		max-block-size: 100svh;
		padding: 1rem 1rem max(1.5rem, env(safe-area-inset-bottom));
		border-radius: 0 0 1.75rem 1.75rem;
		background: var(--c-night);
		color: var(--wp--preset--color--on-ink);
		box-shadow: 0 28px 56px -20px rgb(0 0 0 / 0.6);
		overscroll-behavior: contain;
	}

	.cmlmt-hdr .cmlmt-nav__panel::backdrop {
		background: rgb(10 15 13 / 0.55);
	}

	.cmlmt-hdr .cmlmt-nav__panel .cmlmt-nav__list {
		gap: 0;
	}

	.cmlmt-hdr .cmlmt-nav__panel a {
		padding: 0.875rem 0.25rem;
		border-block-end: 1px solid var(--wp--preset--color--ink-line);
	}

	.cmlmt-hdr .cmlmt-nav__panel li:last-child > a {
		border: 0;
	}
}

@media (max-width: 720px) {
	.cmlmt-hdr {
		--tab-r: 1.25rem;
	}

	.cmlmt-hdr__bar {
		min-height: 3.5rem;
		padding-block: 0.5rem;
	}

	a.cmlmt-hdr__site,
	.cmlmt-brand__where {
		display: none;
	}

	.cmlmt-hdr__bar > .wp-block-cmlm-theme-account {
		margin-inline-start: auto;
		column-gap: 0.5rem; /* Fits the logo row at 375px. */
	}
}
