/*
 * Styles theme.json cannot express. Values come from theme.json presets.
 */

/* Work archive: topic filter links as pills; the current topic is filled. */
.om-filter .wp-block-categories {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--30);
	margin: 0;
	padding: 0;
	list-style: none;
}

.om-filter-all a,
.om-filter .wp-block-categories a {
	display: inline-block;
	padding: 0.375rem 0.875rem;
	border: var(--wp--custom--border--width) solid var(--wp--preset--color--line);
	border-radius: var(--wp--custom--radius--pill);
	color: var(--wp--preset--color--contrast);
	text-decoration: none;
}

.om-filter-all a:hover,
.om-filter .wp-block-categories a:hover {
	border-color: var(--wp--preset--color--accent);
}

.post-type-archive-case_study .om-filter-all a,
.om-filter .current-cat a {
	border-color: var(--wp--preset--color--contrast);
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

/* Case study cards: the border darkens on hover and keyboard focus (no motion; the lift is below). */
.om-card:hover,
.om-card:focus-within {
	border-color: var(--wp--preset--color--contrast) !important;
}

.om-card .wp-block-post-title a {
	color: var(--wp--preset--color--contrast);
	text-decoration: none;
}

.om-card .wp-block-post-title a:hover {
	text-decoration: underline;
}

/* Case study section numbers: "01 Problem". */
.om-step {
	margin-inline-end: 0.5rem;
	font-family: var(--wp--preset--font-family--mono);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
	color: var(--wp--preset--color--accent);
}

/* Hero terminal: a labelled figure, without the browser's default figure margins. */
.om-terminal-figure {
	margin: 0;
}

/*
 * Ring motif from the logo: the O with its centre dot. ring.svg is a mask, so the
 * shape comes from the file and the colors from the gradient: accent dot, currentColor ring.
 */
.is-style-root li::before,
.single-case_study .wp-block-post-content ul.wp-block-list li::before,
.wp-block-osama-portfolio-case-study-summary__result dd::before,
.om-eyebrow::before {
	content: "" / "";
	display: inline-block;
	flex: none;
	width: 0.75em;
	height: 0.75em;
	background: radial-gradient(circle closest-side, var(--wp--preset--color--accent) 0 40%, currentColor 40%);
	-webkit-mask: url(../ring.svg) center / contain no-repeat;
	mask: url(../ring.svg) center / contain no-repeat;
}

/* Lists: the ring replaces the bullet and hangs in the margin. */
.is-style-root,
.single-case_study .wp-block-post-content ul.wp-block-list {
	padding-inline-start: 1.5em;
	list-style: none;
}

.is-style-root li::before,
.single-case_study .wp-block-post-content ul.wp-block-list li::before {
	margin-inline: -1.5em 0.75em;
	vertical-align: -0.05em;
}

/* Summary block: ring before the Outcome value. */
.wp-block-osama-portfolio-case-study-summary__result dd {
	display: flex;
	gap: 0.5em;
	align-items: baseline;
}

/* Eyebrow labels such as "01 / Work": a 16px ring in front. */
.om-eyebrow::before {
	width: 16px;
	height: 16px;
	margin-inline-end: 0.5em;
	vertical-align: -3px;
}

/*
 * Dark mode. The palette from styles/dark.json, applied at runtime: follows the system
 * setting until the visitor picks light or dark with the header switch (data-theme on <html>).
 */
:root[data-theme="dark"] {
	color-scheme: dark;
	--wp--preset--color--base: #0F1215;
	--wp--preset--color--surface: #171B20;
	--wp--preset--color--contrast: #E9ECEF;
	--wp--preset--color--muted: #9BA4AE;
	--wp--preset--color--line: #2A3038;
	--wp--preset--color--accent: #45C79B;
	--wp--preset--color--accent-contrast: #062018;
	--om-code-border: var(--wp--preset--color--line);
}

@media (prefers-color-scheme: dark) {

	:root:not([data-theme="light"]) {
		color-scheme: dark;
		--wp--preset--color--base: #0F1215;
		--wp--preset--color--surface: #171B20;
		--wp--preset--color--contrast: #E9ECEF;
		--wp--preset--color--muted: #9BA4AE;
		--wp--preset--color--line: #2A3038;
		--wp--preset--color--accent: #45C79B;
		--wp--preset--color--accent-contrast: #062018;
		--om-code-border: var(--wp--preset--color--line);
	}
}

/* The terminal stays dark in both modes; in dark mode a hairline keeps its edge. */
.wp-block-code {
	border: var(--wp--custom--border--width) solid var(--om-code-border, transparent);
}

/* Logo: the mark that matches the active palette. */
.om-logo-dark {
	display: none !important;
}

:root[data-theme="dark"] .om-logo-light {
	display: none !important;
}

:root[data-theme="dark"] .om-logo-dark {
	display: block !important;
}

@media (prefers-color-scheme: dark) {

	:root:not([data-theme="light"]) .om-logo-light {
		display: none !important;
	}

	:root:not([data-theme="light"]) .om-logo-dark {
		display: block !important;
	}
}

/* Dark mode switch in the header: 44px target, icon in currentColor, same focus ring as other controls. */
.om-theme-toggle {
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: var(--wp--custom--radius--pill);
	background: transparent;
	color: var(--wp--preset--color--contrast);
	cursor: pointer;
}

.om-theme-toggle[hidden] {
	display: none;
}

/* The copy in the mobile menu shows only while the overlay is open, under the links. */
.wp-block-navigation__responsive-container:not(.is-menu-open) .om-theme-toggle--overlay {
	display: none;
}

.om-theme-toggle--overlay {
	margin-top: var(--wp--preset--spacing--40);
}

.om-theme-toggle:hover {
	background: var(--wp--preset--color--base);
}

.om-theme-toggle:focus-visible {
	outline: var(--wp--custom--focus--width) solid var(--wp--preset--color--accent);
	outline-offset: var(--wp--custom--focus--offset);
}

/* Moon offers dark mode; the sun shows while dark mode is on. */
.om-theme-toggle[aria-pressed="true"] .om-theme-toggle__moon,
.om-theme-toggle[aria-pressed="false"] .om-theme-toggle__sun {
	display: none;
}

/* Visually hidden, still read by screen readers. */
.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/*
 * Mobile menu overlay. Colours come from the Navigation block (base and contrast), so the
 * overlay follows dark mode. Here: margins on every side (plus notches), left-aligned links
 * with 44px targets, and a 44px close button inside the padding.
 */
.wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open {
	--navigation-layout-justification-setting: flex-start;
	padding-top: calc(var(--wp--preset--spacing--50) + env(safe-area-inset-top, 0px));
	padding-right: calc(var(--wp--preset--spacing--50) + env(safe-area-inset-right, 0px));
	padding-bottom: calc(var(--wp--preset--spacing--50) + env(safe-area-inset-bottom, 0px));
	padding-left: calc(var(--wp--preset--spacing--50) + env(safe-area-inset-left, 0px));
}

.wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
	align-items: flex-start;
	padding-top: calc(44px + var(--wp--preset--spacing--40));
}

.wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container {
	align-items: flex-start;
	gap: var(--wp--preset--spacing--40);
}

.wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item {
	align-items: flex-start;
}

.wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content {
	display: flex;
	align-items: center;
	min-height: 44px;
	font-size: var(--wp--preset--font-size--x-large);
	font-weight: 600;
}

.wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	top: 0;
	right: 0;
	width: 44px;
	height: 44px;
}

/*
 * Motion. Small, CSS only, and only for visitors who have not asked for reduced motion.
 * Nothing fades or slides in: content is at full opacity on first paint. Focus rings never animate.
 */
@media (prefers-reduced-motion: no-preference) {

	/* Smooth fade between pages, no JavaScript. Browsers without support just navigate. */
	@view-transition {
		navigation: auto;
	}

	/* Case study cards: a small lift on hover and keyboard focus. */
	.om-card {
		transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
	}

	.om-card:hover,
	.om-card:focus-within {
		transform: translateY(-2px);
	}

	/* Text links: the underline grows in. */
	.wp-block-post-content a,
	.wp-block-group a:not(.wp-element-button) {
		text-decoration-thickness: 1px;
		text-underline-offset: 0.2em;
		transition: text-decoration-thickness 120ms ease, text-underline-offset 120ms ease;
	}

	.wp-block-post-content a:hover,
	.wp-block-group a:not(.wp-element-button):hover {
		text-decoration-thickness: 2px;
		text-underline-offset: 0.15em;
	}

	/* Dark mode switch: the page colours ease over instead of flashing. Only body animates. */
	body {
		transition: background-color 150ms ease, color 150ms ease;
	}

	/* Buttons: colour change only, no movement. */
	.wp-element-button {
		transition: background-color 120ms ease, color 120ms ease;
	}

	/* Hero terminal: the cursor blinks four times after the last line, then stays (WCAG 2.2.2). */
	.om-terminal code > span:last-of-type::after {
		/* Empty alternative text: decoration only, never announced. */
		content: "" / "";
		display: inline-block;
		width: 0.55em;
		height: 1.1em;
		margin-inline-start: 0.3em;
		vertical-align: text-bottom;
		background: currentColor;
		animation: om-blink 1s steps(1) 4;
	}
}

@keyframes om-blink {

	50% {
		opacity: 0;
	}
}

/* Reduced motion: nothing moves, fades or blinks. */
@media (prefers-reduced-motion: reduce) {

	*,
	*::before,
	*::after {
		animation: none !important;
		transition: none !important;
	}
}
