/*
 * Nomon Theme — base stylesheet, loaded on the frontend and inside the editor iframe.
 *
 * Tailwind handles reset and utilities; this file owns only what utilities can't express.
 * Responsibilities and the cascade smoke-test: docs/styling.md.
 */

/* Up front so layer order doesn't depend on when Blockstudio's inline style loads. Holds
 * only while Blockstudio emits layered utilities — smoke-test in docs/styling.md. */
@layer theme, base, components, utilities;

/* Unlayered on purpose: wrapping this ties with preflight's `body { line-height: inherit }`. */
body {
	font-size: var(--wp--preset--font-size--body);
	line-height: 1.7;
	overflow-wrap: break-word;
	/* No reading cap: the legacy site runs content the full 1440px column. */
	--prose-cap: none;
}

/* Legacy container inset 60/30/20px (Bricks ≤767 / ≤478); `:root body` outranks global styles' `body`. */
@media (max-width: 767px) {
	:root body { --wp--style--root--padding-left: 30px; --wp--style--root--padding-right: 30px; }
}
@media (max-width: 478px) {
	:root body { --wp--style--root--padding-left: 20px; --wp--style--root--padding-right: 20px; }
}
/* The editor's Mobile preview is 480px wide, just past the 478px step. */
:root body:has(> .is-mobile-preview) { --wp--style--root--padding-left: 20px; --wp--style--root--padding-right: 20px; }

/* Legacy `h2` margin-bottom 20px; matches the specificity of WP's unlayered block-gap rule. */
:root :where(.is-layout-flow, .is-layout-constrained) > h2 + * {
	margin-block-start: 20px;
}

/* WP's `size-full` marker collides with Tailwind's utility of that name; unlayered on
 * purpose so it beats the layered utility. See docs/styling.md. */
.wp-block-image.size-full {
	width: auto;
	height: auto;
}

/* Block, not inline-block: the line box under an inline anchor opens a gap above the caption. */
.wp-block-image > a {
	display: block;
	width: fit-content;
}

@layer base {
	body p { margin-block: 30px; }
	body figure { margin-block: 30px; }

	body :is(h1, h2, h3, h4, h5, h6) { font-weight: 700; line-height: 1.4; margin-block: 30px; }

	body h1 { font-size: var(--wp--preset--font-size--display); }
	body h2 { font-size: var(--wp--preset--font-size--heading-2); margin-bottom: 20px; }
	body h3 { font-size: var(--wp--preset--font-size--heading-3); }
	body h4 { font-size: var(--wp--preset--font-size--heading-4); }
	body h5 { font-size: var(--wp--preset--font-size--heading-5); }
	body h6 { font-size: var(--wp--preset--font-size--heading-6); }

	:is(.site-content, .editor-styles-wrapper) :is(p, li, td, th, figcaption) a {
		color: var(--wp--preset--color--sininen);
		text-decoration: none;
	}
	:is(.site-content, .editor-styles-wrapper) :is(p, li, td, th, figcaption) a:hover { text-decoration: underline; }
	:is(.site-content, .editor-styles-wrapper) :is(.has-sininen-background-color, .has-dark-background-color) a {
		color: inherit;
		text-decoration: underline;
	}

	:focus-visible {
		outline: 2px solid var(--wp--preset--color--sininen);
		outline-offset: 2px;
	}
	:is(.has-sininen-background-color, .has-dark-background-color) :focus-visible {
		outline-color: var(--wp--preset--color--white);
	}

	body :is(h1, h2, h3, h4, h5, h6) + :is(h1, h2, h3, h4, h5, h6) { margin-top: 0; }

	/* core/list block: restore bullets/numbers and indent that Tailwind preflight zeroes. */
	.wp-block-list { margin-block: 30px; padding-inline-start: 1.5em; }
	.wp-block-list:where(ul) { list-style: disc; }
	.wp-block-list:where(ol) { list-style: decimal; }
	.wp-block-list :where(li > *) { margin-block: 0.5rem; }
	.wp-block-list :where(li > :first-child) { margin-top: 0; }
	.wp-block-list :where(li > :last-child)  { margin-bottom: 0; }

	/* First/last reset: heading at top of a section, paragraph at end, don't push the container. */
	body :is(h1, h2, h3, h4, h5, h6):first-child { margin-top: 0; }
	body p:last-child { margin-bottom: 0; }
}

/* Prose cap; descendant selector so prose inside a nested group is capped too. */
.wp-block-group :is(p, h1, h2, h3, h4, h5, h6, ul, ol),
.site-content > :is(p, h1, h2, h3, h4, h5, h6, ul, ol) {
	max-width: var(--prose-cap);
	/* Pins prose to the contentSize start edge however wide the parent is;
	 * `!important` beats WP's `.is-layout-constrained > * { margin-inline: auto !important }`. */
	margin-inline-start: max(
		0px,
		calc((100% - var(--wp--style--global--content-size)) / 2)
	) !important;
}

/* Auto-bleed, mirroring native `.alignfull`; `!important` matches WP's own margin rule. */
.has-global-padding > .wp-block-group.has-background {
	max-width: none;
	margin-left: calc(var(--wp--style--root--padding-left) * -1) !important;
	margin-right: calc(var(--wp--style--root--padding-right) * -1) !important;
	padding-left: var(--wp--style--root--padding-left);
	padding-right: var(--wp--style--root--padding-right);
}

/* Spacing controls are disabled in theme.json, so colored sections need a default. */
.wp-block-group.has-background {
	padding-block: clamp(2rem, 6vw, 4rem);
}

/* Descendants inherit this; add a sibling rule per dark swatch as the palette grows. */
.wp-block-group:is(.has-sininen-background-color, .has-dark-background-color) {
	color: var(--wp--preset--color--white);
}

/* Duplo gap; the owl selector leaves the first section flush with the page top. Scoped to
 * `core/group` as the only duplo — add block names when composite blocks join. */
.has-global-padding > .wp-block-group + .wp-block-group {
	margin-top: 75px;
}

/* === Prose (#7) === */
/* Bricks' palette variable, saved inline in legacy highlight marks. */
:root { --lightblue: var(--wp--preset--color--lightblue); }
:is(td, th) a { overflow-wrap: anywhere; }
/* A bare `<mark>` only arrives by pasting; the UA's yellow is never intended. */
mark:not([class]) { background: none; color: inherit; }

/* Bands bleed into the root padding; the max() keeps them 1440 + padding wide past 1560px.
 * `!important` beats WP's constrained-layout and the prose-cap margin rules. */
:root :is(.is-style-notice, .is-style-grey, .is-style-primary, .is-style-bar, .is-style-bar-blue) {
	max-width: none !important;
	margin-left: max(calc(var(--wp--style--root--padding-left) * -1), calc((100% - var(--wp--style--global--content-size)) / 2 - var(--wp--style--root--padding-left))) !important;
	margin-right: max(calc(var(--wp--style--root--padding-right) * -1), calc((100% - var(--wp--style--global--content-size)) / 2 - var(--wp--style--root--padding-right))) !important;
	padding: 4px var(--wp--style--root--padding-right) 4px var(--wp--style--root--padding-left);
}
:root :is(.is-style-notice, .is-style-grey, .is-style-primary) { padding-block: 10px; }
.is-style-notice, .is-style-bar-blue { background-color: var(--wp--preset--color--lightblue); }
.is-style-grey, .is-style-bar { background-color: var(--wp--preset--color--lightgrey); }
.is-style-primary {
	background-color: var(--wp--preset--color--sininen);
	color: var(--wp--preset--color--white);
}
:is(.site-content, .editor-styles-wrapper) .is-style-primary a {
	color: inherit;
	text-decoration: underline;
}
.is-style-primary :focus-visible { outline-color: var(--wp--preset--color--white); }
body :is(h1, h2, h3, h4, h5, h6):is(.is-style-bar, .is-style-small) {
	font-size: var(--wp--preset--font-size--heading-6);
}

.wp-block-list { padding-inline-start: 40px; }

.wp-block-table { overflow-x: auto; }
.wp-block-table table {
	width: 100%;
	border-collapse: collapse;
}
.wp-block-table :is(td, th) {
	border: 1px solid var(--wp--preset--color--black);
	padding: 10px;
	line-height: 1.7;
}
/* Preflight makes images block, which would ignore the cell's text alignment. */
.wp-block-table :is(td, th) img { display: inline-block; max-width: 100%; height: auto; }

.wp-block-image img { max-width: 100%; height: auto; }
.wp-block-image.aligncenter { width: fit-content; margin-inline: auto; }
.wp-block-image.is-style-rounded img { border-radius: 9999px; }
/* Resized legacy portraits keep their live shape (one is an oval); a full-size one becomes a circle. */
.wp-block-image.is-style-rounded:not(.is-resized) img { aspect-ratio: 1; object-fit: cover; }

.site-content .nomon-gallery { margin-block: 0; }
/* === /Prose (#7) === */

/* === Page hero (#6) === */
.page-hero::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background-image: linear-gradient(90deg, var(--wp--preset--color--sininen), rgba(66, 39, 221, 0) 50%);
}
.page-hero__text::before {
	content: "";
	position: absolute;
	inset: -100vh -120px -100vh -100vw;
	z-index: -1;
	background-image: linear-gradient(90deg, rgba(69, 42, 222, 0.85) calc(100% - 120px), rgba(69, 42, 222, 0));
}
/* Inline items so a long title wraps word by word; the zero-width space allows a break after the slash. */
.site-breadcrumbs__list {
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: var(--wp--preset--font-size--body);
	color: var(--wp--preset--color--lightblue);
}
.site-breadcrumbs__list li { display: inline; }
.site-breadcrumbs__list li:not(:last-child)::after {
	content: "/\200B";
	content: "/\200B" / "";
	margin-inline: 10px;
}
.site-breadcrumbs__list a {
	color: inherit;
	text-decoration: none;
}
.site-breadcrumbs__list a:hover { text-decoration: underline; }
.page-hero :focus-visible { outline-color: var(--wp--preset--color--white); }
/* === /Page hero (#6) === */

@layer base {
	html {
		scroll-behavior: smooth;
		scroll-padding-top: var(--scroll-offset, 2rem);
	}

	/* Gutenberg can't hide these toolbar buttons, so cancel the effect instead. */
	:where(h1, h2, h3, h4, h5, h6) :is(strong, b, em, i) {
		font-weight: inherit;
		font-style: inherit;
	}

	.screen-reader-text {
		border: 0;
		clip-path: inset(50%);
		height: 1px;
		margin: -1px;
		overflow: hidden;
		padding: 0;
		position: absolute;
		width: 1px;
		word-wrap: normal !important;
	}

	.skip-link:focus {
		clip-path: none;
		height: auto;
		margin: 0;
		overflow: auto;
		padding: 1rem;
		position: absolute;
		inset-block-start: 0;
		inset-inline-start: 0;
		width: auto;
		z-index: 100000;
		background: #000;
		color: #fff;
		text-decoration: underline;
	}

	/* WCAG 2.4.4: per-site CSS may restyle or hide the glyph, never the screen-reader text. */
	a.is-external-link::after,
	a.is-new-window::after {
		content: " ↗";
		display: inline-block;
		font-size: 0.85em;
		vertical-align: super;
		line-height: 1;
	}
	a.is-new-window::after {
		content: " ⧉";
	}
	a.is-external-link.is-new-window::after {
		content: " ⧉";
	}

	/* Hides the glyph in the footer and credit bar only; the screen-reader text stays. */
	:is(.site-footer, .nomon_footer) a.is-external-link::after,
	:is(.site-footer, .nomon_footer) a.is-new-window::after,
	:is(.site-footer, .nomon_footer) a.is-external-link.is-new-window::after {
		content: none;
	}
}

/* Critical Swiper layout before the lazy vendor CSS lands. No pre-init `visibility: hidden`
 * — that hid the hero from FlyingPress's above-the-fold pass, costing the LCP preload. */
.swiper { overflow: hidden; }
.swiper-wrapper { display: flex; }
.swiper-slide { flex-shrink: 0; width: 100%; }
/* Overrides FlyingPress Lazy Render's inline style — see docs/runtimes.md. */
.swiper-slide,
.swiper-slide * { content-visibility: visible !important; }

/* Editor-only: flattens Gutenberg's InnerBlocks wrapper chain, which breaks parent flex/grid.
 * Unlayered to outrank editor styles; descendant combinators because `useBlockProps` shifts a level. */
[data-type^="nomon/"] .block-editor-inner-blocks,
[data-type^="nomon/"] .block-editor-block-list__layout:not([data-type]) {
	display: contents;
}

/* Editor-only: the block wrapper, not the link, is the flex child of `nomon/buttons`. */
[data-type="nomon/button"] {
	display: grid;
}
.nomon-buttons--equal.flex-row > [data-type="nomon/button"] {
	flex: 1 1 0%;
	min-width: 0;
}

/* Editor-only: Blockstudio's marker span takes `:first-child`, so the block after it gets a block gap. */
:is(.is-layout-flow, .is-layout-constrained) > [data-blockstudio-render-marker]:first-child + * {
	margin-block-start: 0;
}

/* Editor-only: the front end swaps the `+` glyph for `plus.svg` (inc/integrations/core-blocks.php). */
[data-type="core/accordion-heading"] .wp-block-accordion-heading__toggle-icon {
	position: relative;
	-webkit-text-fill-color: transparent;
}
[data-type="core/accordion-heading"] .wp-block-accordion-heading__toggle-icon::before {
	content: "";
	position: absolute;
	inset: 0;
	background-color: currentColor;
	mask: url("../icons/plus.svg") center / contain no-repeat;
}

/* Editor-only: a drag saves the box's computed `aspectRatio`, which the ratio dropdown
 * cannot display or clear (`docs/integrations.md`). Selector length beats the components
 * stylesheet's own `.has-show-handle` rule at (0,3,0). */
[data-type="core/image"] .components-resizable-box__container.has-show-handle .components-resizable-box__handle {
	display: none;
}

/* Editor-only: the post title as a flat page-hero band; WP's iframe body also gets a top padding. */
body {
	padding-top: 0;
}

.edit-post-visual-editor__post-title-wrapper {
	background-color: var(--wp--preset--color--sininen);
	color: var(--wp--preset--color--white);
	--title-muted: var(--wp--preset--color--lightblue);
	margin-block-start: 0 !important;
	margin-block-end: 3rem;
	padding-inline: var(--wp--style--root--padding-left);
}

.edit-post-visual-editor__post-title-wrapper .editor-post-title {
	color: inherit;
	font-size: var(--wp--preset--font-size--display);
	margin: 0 auto;
	max-width: var(--wp--style--global--content-size, 1440px);
	padding-block: 75px;
}

.edit-post-visual-editor__post-title-wrapper .editor-post-title::before {
	content: "Sivun otsikko";
	display: block;
	color: var(--title-muted);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
	margin-block-end: 0.75rem;
}

.post-type-post .edit-post-visual-editor__post-title-wrapper .editor-post-title::before {
	content: "Artikkelin otsikko";
}

.edit-post-visual-editor__post-title-wrapper .editor-post-title [data-rich-text-placeholder]::after {
	color: var(--title-muted);
	opacity: 1;
}

/* Packages and the front page (it opens with `nomon/hero`) have no page hero on the frontend. */
.post-type-valokuituliittyma .edit-post-visual-editor__post-title-wrapper,
.edit-post-visual-editor__post-title-wrapper:has(+ .is-root-container > [data-type="nomon/hero"]:first-child) {
	background-color: transparent;
	color: inherit;
	--title-muted: #666;
}

/* === Header & navigation (#3, #4) === */
:root {
	/* Must stay numeric: JS reads it via getComputedStyle for matchMedia. */
	--breakpoint-nav: 1439px;

	--hamburger-color: var(--wp--preset--color--white);
	--hamburger-color-active: var(--wp--preset--color--white);
	--hamburger-width: 40px;
	--hamburger-layer-height: 3px;

	/* Desktop dropdowns */
	--color-main-level: var(--wp--preset--color--black);
	--color-hover-main-level: var(--wp--preset--color--black);
	--color-current: var(--wp--preset--color--black);
	--typography-size-main-level: var(--wp--preset--font-size--ui);
	--typography-weight-main-level: 500;
	--padding-main-level-vertical: 0;
	--gap-main-level-horizontal: clamp(24px, 2.3vw - 9px, 30px);
	--gap-between-dropdown-toggle: 8px;
	--dropdown-toggle-size: 24px;

	--color-sub-menu: var(--wp--preset--color--black);
	--color-hover-sub-menu: var(--wp--preset--color--white);
	--color-background-sub-menu: var(--wp--preset--color--white);
	--color-background-hover-sub-menu: var(--wp--preset--color--sininen);
	--typography-size-sub-menu: var(--wp--preset--font-size--small);
	--typography-weight-sub-menu: 400;
	--padding-sub-menu-link-vertical: 18px;
	--padding-sub-menu-link-horizontal: 20px;
	--gap-dropdown: 20px;

	/* Mobile drawer */
	--width-navigation: 300px;
	--color-background-menu-items: var(--wp--preset--color--white);
	--color-main-level-menu-item-mobile: var(--wp--preset--color--sininen);
	--color-sub-menu-mobile: var(--wp--preset--color--sininen);
	--color-dropdown-toggle-mobile: var(--wp--preset--color--sininen);
	--typography-size-main-level-mobile: 20px;
	--typography-size-sub-menu-mobile: var(--wp--preset--font-size--small);
	--padding-main-level-vertical-mobile: 10px;
	--padding-sub-menu-mobile: 10px 10px 10px 20px;
	--padding-drawer: 30px;
	--width-dropdown-toggle-mobile: 40px;
}

.hamburger {
	display: block;
	width: var(--hamburger-width);
	height: var(--hamburger-layer-height);
	background-color: var(--hamburger-color);
	position: relative;
	transition: all 0.2s ease 0s;
	flex-shrink: 0;
}
.hamburger::before,
.hamburger::after {
	content: "";
	display: block;
	width: var(--hamburger-width);
	height: var(--hamburger-layer-height);
	background-color: var(--hamburger-color);
	position: absolute;
	transition: all 0.2s ease 0s;
}
.hamburger::before { top: -8px; }
.hamburger::after  { bottom: -8px; }

.js-nav-active .hamburger { background-color: transparent; }
.js-nav-active .hamburger::before,
.js-nav-active .hamburger::after {
	background-color: var(--hamburger-color-active);
	left: 0;
	top: 0;
}
.js-nav-active .hamburger::before { transform: rotate(-45deg); }
.js-nav-active .hamburger::after  { transform: rotate(45deg); }

.nav-toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 44px;
	margin: 0;
	padding: 10px;
	background: var(--wp--preset--color--sininen);
	border: 0;
	border-radius: 15px 0;
	cursor: pointer;
	position: relative;
	z-index: 99999;
}

body.js-nav-active { overflow: hidden; }

/* Glyph hidden as in the footer (the live menu shows none); the screen-reader text stays. */
.site-header a.is-external-link::after { content: none; }

.nav-cta { display: none; }

.nav-primary .menu-items ul { display: none; }
.nav-primary ul .sub-menu.toggled-on { display: block; }

.nav-primary { align-self: center; }

.site-header ul,
.site-header li,
.site-header a { position: relative; }

body.js-nav-active::before {
	content: "";
	position: fixed;
	inset: 0;
	background: rgb(0 0 0 / 0.5);
	z-index: 99990;
}

/* !important: navigation.js sets an inline top/height that docks the drawer under the
 * header; this drawer runs full height like the legacy off-canvas. */
.nav-primary .menu-items-wrapper {
	position: fixed;
	top: var(--wp-admin--admin-bar--height, 0px) !important;
	left: 0;
	width: var(--width-navigation);
	max-width: 100vw;
	height: calc(100dvh - var(--wp-admin--admin-bar--height, 0px)) !important;
	padding: var(--padding-drawer);
	background-color: var(--color-background-menu-items);
	transform: translate3d(-100%, 0, 0);
	transition: transform 220ms cubic-bezier(0.19, 1, 0.22, 1), opacity 180ms ease-in-out;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	overflow: auto;
	backface-visibility: hidden;
	z-index: 99995;
}

.nav-primary .menu-items { margin: 0; padding: 0; list-style: none; }
.nav-primary .menu-item  { margin: 0; }

.nav-primary .menu-item a {
	display: block;
	padding-block: var(--padding-main-level-vertical-mobile);
	padding-inline: 0 var(--width-dropdown-toggle-mobile);
	color: var(--color-main-level-menu-item-mobile);
	font-size: var(--typography-size-main-level-mobile);
	font-weight: 400;
	line-height: 1.7;
	text-decoration: none;
}
.nav-primary .menu-item a:hover,
.nav-primary .menu-item a[aria-current="page"] { text-decoration: underline; }
.nav-primary .menu-item a br { display: none; }

.nav-primary .sub-menu { margin: 0; padding: 0; list-style: none; }
.nav-primary .sub-menu a {
	color: var(--color-sub-menu-mobile);
	font-size: var(--typography-size-sub-menu-mobile);
	padding: var(--padding-sub-menu-mobile);
}

.nav-primary .dropdown-toggle {
	position: absolute;
	top: 0;
	right: 0;
	width: var(--width-dropdown-toggle-mobile);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	background: transparent;
	border: 0;
	color: var(--color-dropdown-toggle-mobile);
	cursor: pointer;
}
.nav-primary .dropdown-toggle svg {
	width: var(--dropdown-toggle-size);
	height: var(--dropdown-toggle-size);
	transition: transform 150ms;
	pointer-events: none;
}
.nav-primary .dropdown-toggle.toggled-on svg { transform: rotate(180deg); }

.js-nav-active .nav-primary .menu-items-wrapper {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transform: translate3d(0, 0, 0);
}

@media (min-width: 1440px) {
	:root:not(.nav-collapsed) .nav-toggle,
	:root:not(.nav-collapsed) .nav-primary .menu-item-services { display: none; }

	:root:not(.nav-collapsed) .nav-primary { line-height: 0; padding-block: 0; align-self: auto; margin-right: auto; }
	:root:not(.nav-collapsed) .site-logo { align-self: flex-start; margin-right: 50px; }
	:root:not(.nav-collapsed) .nav-cta { display: inline-flex; }
	:root:not(.nav-collapsed) .site-header a { position: static; }

	:root:not(.nav-collapsed) .nav-primary .menu-items-wrapper {
		position: static;
		top: auto !important;
		width: auto;
		max-width: none;
		height: auto !important;
		padding: 0;
		background: none;
		transform: none;
		transition: none;
		opacity: 1;
		visibility: visible;
		pointer-events: auto;
		overflow: visible;
	}

	:root:not(.nav-collapsed) .nav-primary .menu-items {
		display: flex;
		align-items: stretch;
		column-gap: var(--gap-main-level-horizontal);
		margin: 0;
		padding: 0;
		list-style: none;
		position: relative;
	}

	:root:not(.nav-collapsed) .nav-primary .menu-item { margin: 0; position: relative; }

	:root:not(.nav-collapsed) .nav-primary .menu-items > .menu-item > a {
		display: block;
		color: var(--color-main-level);
		font-size: var(--typography-size-main-level);
		font-weight: var(--typography-weight-main-level);
		line-height: 1.7;
		padding-block: var(--padding-main-level-vertical);
		padding-inline: 0;
		text-decoration: none;
		white-space: nowrap;
	}
	:root:not(.nav-collapsed) .nav-primary .menu-items > .menu-item > a:hover,
	:root:not(.nav-collapsed) .nav-primary .menu-items > .menu-item > a[aria-current="page"] {
		color: var(--color-hover-main-level);
		text-decoration: underline;
	}

	/* Grid, not flex: the single auto row is the label's height, so the stretched toggle
	 * centres the chevron on the label while the li itself stretches to the tallest item. */
	:root:not(.nav-collapsed) .nav-primary .menu-items > .menu-item-has-children {
		display: grid;
		grid-template-columns: auto auto;
		align-content: start;
		column-gap: var(--gap-between-dropdown-toggle);
	}

	/* Bridges the menu-item/submenu gap so hover survives the empty space; only present
	 * while hovered, so it doesn't capture clicks at rest. */
	:root:not(.nav-collapsed) .nav-primary .menu-item.menu-item-has-children::after {
		content: "";
		display: block;
		position: absolute;
		top: 100%;
		width: 100%;
		height: var(--gap-dropdown);
		visibility: hidden;
	}
	:root:not(.nav-collapsed) .nav-primary .menu-item.menu-item-has-children.hover-intent::after {
		visibility: visible;
		z-index: 100;
	}
	:root:not(.nav-collapsed) .nav-primary .sub-menu .menu-item-has-children::after { display: none; }

	:root:not(.nav-collapsed) .nav-primary .sub-menu {
		display: block;
		position: absolute;
		top: 100%;
		left: 0;
		width: max-content;
		margin: 0;
		margin-top: var(--gap-dropdown);
		padding: 0;
		list-style: none;
		background-color: var(--color-background-sub-menu);
		box-shadow: 0 0 10px 0 rgb(0 0 0 / 0.19);
		opacity: 0;
		visibility: hidden;
		transition: all 0.2s cubic-bezier(0.19, 1, 0.22, 1);
		z-index: 9;
	}
	:root:not(.nav-collapsed) .nav-primary .sub-menu .sub-menu { top: 0; left: 100%; margin-top: 0; }

	:root:not(.nav-collapsed) .nav-primary .sub-menu.is-out-of-viewport { left: auto; right: 0; }
	:root:not(.nav-collapsed) .nav-primary .sub-menu.is-out-of-viewport .sub-menu,
	:root:not(.nav-collapsed) .nav-primary .sub-menu .sub-menu.is-out-of-viewport { left: auto; right: 100%; }

	:root:not(.nav-collapsed) .nav-primary .menu-item .sub-menu a {
		display: block;
		color: var(--color-sub-menu);
		font-size: var(--typography-size-sub-menu);
		font-weight: var(--typography-weight-sub-menu);
		line-height: 1.5;
		padding-block: var(--padding-sub-menu-link-vertical);
		padding-inline: var(--padding-sub-menu-link-horizontal);
		text-decoration: none;
		white-space: nowrap;
	}
	:root:not(.nav-collapsed) .nav-primary .menu-item .sub-menu a:hover,
	:root:not(.nav-collapsed) .nav-primary .menu-item .sub-menu a:focus-visible {
		color: var(--color-hover-sub-menu);
		background-color: var(--color-background-hover-sub-menu);
	}
	:root:not(.nav-collapsed) .nav-primary .menu-item .sub-menu a:focus-visible {
		outline-color: var(--wp--preset--color--white);
		outline-offset: -4px;
	}
	:root:not(.nav-collapsed) .nav-primary .menu-item .sub-menu a:hover:not([aria-current="page"]) { text-decoration: none; }
	:root:not(.nav-collapsed) .nav-primary .sub-menu a[aria-current="page"] { text-decoration: underline; }
	:root:not(.nav-collapsed) .nav-primary .menu-item a br { display: revert; }

	/* :hover for mouse, :focus-within for keyboard, .hover-intent (JS) to keep the menu
	 * open briefly after the cursor leaves and absorb stray movement. */
	:root:not(.nav-collapsed) .nav-primary .menu-item-has-children:hover > .sub-menu,
	:root:not(.nav-collapsed) .nav-primary .menu-item-has-children:focus-within > .sub-menu,
	:root:not(.nav-collapsed) .nav-primary .menu-item-has-children.hover-intent > .sub-menu {
		opacity: 1;
		visibility: visible;
		z-index: 12;
	}
	:root:not(.nav-collapsed) .nav-primary .menu-item-has-children.is-dismissed > .sub-menu {
		opacity: 0;
		visibility: hidden;
	}

	/* Dropdown toggle on desktop is decorative — pointer-events: none lets
	 * clicks fall through to the parent <a>. The svg is the visual cue. */
	:root:not(.nav-collapsed) .nav-primary .dropdown-toggle {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		flex-shrink: 0;
		padding: 0;
		background: transparent;
		border: 0;
		position: static;
		width: auto;
		color: var(--color-main-level);
		cursor: auto;
		pointer-events: none;
	}
	:root:not(.nav-collapsed) .nav-primary .dropdown-toggle svg {
		width: var(--dropdown-toggle-size);
		height: var(--dropdown-toggle-size);
		margin-inline: calc(var(--dropdown-toggle-size) / -4);
		transform: none;
		transition: transform 0.35s cubic-bezier(0.19, 1, 0.22, 1);
	}
	:root:not(.nav-collapsed) .nav-primary .menu-item-has-children.hover-intent > .dropdown-toggle svg {
		transform: rotateX(180deg);
	}
	:root:not(.nav-collapsed) .nav-primary .sub-menu .dropdown-toggle svg { transform: rotate(-90deg); }
	:root:not(.nav-collapsed) .nav-primary .sub-menu .hover-intent > .dropdown-toggle svg {
		transform: rotate(-90deg) rotateX(180deg);
	}
}
/* === /Header & navigation (#3, #4) === */

/* === 404 & search (#15) === */
.site-content .nav-links { display: flex; flex-wrap: wrap; gap: 15px; margin-top: 50px; }
.site-content .nav-links a { color: var(--wp--preset--color--sininen); text-decoration: none; }
.site-content .nav-links a:hover { text-decoration: underline; }
/* === /404 & search (#15) === */
