/*
 * Site chrome corrections for pages this theme does not lay out itself.
 *
 * KBNexus renders its own shell, <main class="kbnx kbnx-doc-shell">, inside the Etch theme.
 * The theme's own pages get their spacing from .ks-section, which the knowledge base never
 * uses, so the last card on a documentation page sat directly against the footer with no
 * breathing room at all.
 *
 * Scoped to main.kbnx so it cannot touch a normal Etch page.
 */

main.kbnx {
	padding-block-end: clamp(3rem, 6vw, 5.5rem);
}

/*
 * A single doc reads better with a little air above it too: the article starts immediately
 * under the header, where an Etch page would have hero padding.
 */
main.kbnx.kbnx-doc-single,
main.kbnx.kbnx-doc-shell:not(.kbnx-doc-archive) {
	padding-block-start: clamp(1.5rem, 3vw, 3rem);
}

/*
 * The footer carries its own top padding, but against a light documentation background the
 * transition is abrupt. A hairline separates the two without inventing a new colour.
 */
main.kbnx + .ks-site-footer {
	border-block-start: 1px solid var(--ks-border, rgba(0, 0, 0, 0.08));
}

/*
 * ---------------------------------------------------------------------------------------------
 * Header navigation, for templates Etch does not render.
 *
 * The Add-ons dropdown is styled by Etch's PER-PAGE inline CSS, which is emitted only for the
 * elements an Etch-rendered page actually contains. A KBNexus documentation page renders inside
 * the same theme shell and outputs the same header markup, but its content is not Etch blocks, so
 * none of that inline CSS is emitted for it.
 *
 * The result was a dropdown with no rule at all on /docs/: `position: static`, `display: block`,
 * `z-index: auto`. Instead of floating over the page it took part in the header's layout and
 * pushed it apart - which reads as "the add-ons menu is broken" rather than as a missing
 * stylesheet, because everything else about the header looked right.
 *
 * These declarations are copied verbatim from the working home page. On an Etch page the inline
 * copy still applies and the two agree; on every other template this is the only copy there is.
 *
 * The `:not([hidden])` form matters: setting `display: grid` unconditionally would defeat the
 * hidden attribute the disclosure script toggles, and the menu would never close.
 * --------------------------------------------------------------------------------------------- */

.ks-nav-group {
	position: relative;
	display: flex;
}

.ks-nav-menu {
	position: absolute;
	inset-block-start: calc(100% + 0.4rem);
	inset-inline-start: 0;
	z-index: 60;
	min-inline-size: 17.5rem;
	gap: 0.1rem;
	padding: 0.5rem;
	background: var(--ks-surface, #fff);
	border: 1px solid var(--ks-border, rgba(0, 0, 0, 0.12));
	border-radius: var(--ks-radius-lg, 12px);
	box-shadow: 0 18px 44px -24px color-mix(in oklch, var(--ks-ink, #222) 60%, transparent);
}

.ks-nav-menu:not([hidden]) {
	display: grid;
}

@media (max-width: 980px) {
	.ks-nav-group {
		display: block;
	}

	/* On a narrow screen the menu belongs in the flow, under its toggle. */
	.ks-nav-menu {
		position: static;
		box-shadow: none;
		min-inline-size: 0;
		margin-block-start: 0.35rem;
	}
}

/*
 * The items inside the menu, and the control that opens it.
 *
 * Same cause as the block above: these live in Etch's per-page inline CSS. Without them the
 * dropdown floats correctly and then renders as a stack of default blue underlined links, with
 * each add-on's name and description running together on one line - "FiltersFaceted product
 * filtering" - because the two-line grid never applied.
 *
 * Copied verbatim from the home page. Fallbacks are supplied for the focus tokens, which come
 * from Automatic.css rather than from IvaSure's own token block.
 */

.ks-nav-toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	border: 0;
	background: none;
	cursor: pointer;
	font: inherit;
	border-radius: var(--ks-radius-sm, 6px);
	color: var(--ks-ink-soft, #333);
	font-size: 0.9rem;
	font-weight: 600;
	padding: 0.55rem 0.75rem;
	text-decoration: none;
}

.ks-nav-toggle:hover {
	background: var(--ks-nav-hover, var(--ks-surface-soft, rgba(0, 0, 0, 0.04)));
	color: var(--ks-ink, #111);
}

.ks-nav-toggle:focus-visible {
	outline: var(--focus-width, 2px) solid var(--focus-color, currentcolor);
	outline-offset: var(--focus-offset, 2px);
}

/* The chevron, and its flip when the disclosure is open. */
.ks-nav-toggle::after {
	content: "";
	inline-size: 0.42rem;
	block-size: 0.42rem;
	border-inline-end: 2px solid currentcolor;
	border-block-end: 2px solid currentcolor;
	transform: translateY(-0.12em) rotate(45deg);
	transition: transform 0.18s;
}

.ks-nav-toggle[aria-expanded="true"]::after {
	transform: translateY(0.06em) rotate(-135deg);
}

@media (prefers-reduced-motion: reduce) {
	.ks-nav-toggle::after {
		transition: none;
	}
}

@media (max-width: 980px) {
	.ks-nav-toggle {
		border: 1px solid var(--ks-border, rgba(0, 0, 0, 0.12));
		background: var(--ks-surface, #fff);
		inline-size: 100%;
		justify-content: space-between;
	}
}

.ks-nav-menu__link {
	display: grid;
	gap: 0.1rem;
	padding: 0.5rem 0.6rem;
	border-radius: var(--ks-radius-sm, 6px);
	text-decoration: none;
	color: var(--ks-ink, #111);
}

.ks-nav-menu__link:hover {
	background: var(--ks-nav-hover, var(--ks-surface-soft, rgba(0, 0, 0, 0.04)));
}

.ks-nav-menu__link:focus-visible {
	outline: var(--focus-width, 2px) solid var(--focus-color, currentcolor);
	outline-offset: calc(var(--focus-offset, 2px) * -1);
}

.ks-nav-menu__name {
	font-size: 0.9rem;
	font-weight: 600;
}

.ks-nav-menu__desc {
	font-size: 0.78rem;
	color: var(--ks-muted, #666);
}

/* The separator is a ::before hairline in the margin gap rather than a border
   on the element, so the hover tint has somewhere to sit without hugging the
   divider. Symmetric padding and rounded corners let this row hover like the
   ones above it. */
.ks-nav-menu__all {
	position: relative;
	margin-block-start: 0.45rem;
	padding: 0.5rem 0.6rem;
	border-radius: var(--ks-radius-sm, 6px);
	font-size: 0.82rem;
	font-weight: 600;
	color: var(--ks-action, #0b6);
	text-decoration: none;
}

.ks-nav-menu__all::before {
	content: "";
	position: absolute;
	inset-inline: 0;
	inset-block-start: -0.225rem;
	block-size: 1px;
	background: var(--ks-border, rgba(0, 0, 0, 0.12));
}

/* Underline KEPT alongside the tint: the rows above are whole-row targets whose
   label is their name, this one is a text link, and colour alone is not a
   sufficient affordance for a link. */
.ks-nav-menu__all:hover {
	background: var(--ks-nav-hover, var(--ks-surface-soft, rgba(0, 0, 0, 0.04)));
	/* This row's label IS the brand colour and so is the tint, so hovering moved
	   the two toward each other: 4.48:1 in light, under AA by a hair. Mixing the
	   ink in darkens it in light and lightens it in dark - either way, away from
	   the page. */
	color: color-mix(in srgb, var(--ks-action, #0b6) 78%, var(--ks-ink, #111));
	text-decoration: underline;
}

.ks-nav-menu__all:focus-visible {
	outline: var(--focus-width, 2px) solid var(--focus-color, currentcolor);
	outline-offset: calc(var(--focus-offset, 2px) * -1);
}

/*
 * ---------------------------------------------------------------------------------------------
 * Motion: the hero entrance cascade, and nothing scroll-armed.
 *
 * The guard is the no-preference media query, NOT a reduce-cancel block: the animation is
 * *defined* only for people who accept motion, so the no-motion path is the default and
 * nothing can ever be stuck invisible for a reduced-motion visitor (WCAG 2.3.3 direction;
 * researched 2026-08-29 - entrance completes inside the first second, 70ms stagger,
 * transform+opacity only, ease-out).
 *
 * A one-time fade-up on the hero's own children, pure CSS and time-based, so it can never
 * strand content: it always finishes, with or without JavaScript. `backwards` fill keeps
 * delayed items at their from-state so nothing pops in twice. Scroll-armed section reveals
 * were tried and REMOVED 2026-08-29: they hold below-fold sections at opacity 0 until an
 * observer fires, which full-page screenshots - the design QA instrument here - capture as
 * a blank page. See site-chrome.js for the full note.
 * --------------------------------------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
	@keyframes ks-enter {
		from { opacity: 0; translate: 0 14px; }
		to { opacity: 1; translate: 0 0; }
	}

	/*
	 * The switchboard pips "power on" in sequence after the hero settles - the page's one
	 * orchestrated moment (a licence key turning modules on). The keyframes live here
	 * because Etch style records cannot carry @keyframes (invalid when nested); the
	 * animation declarations sit in the switchboard records and reference this name.
	 * Time-based and finished by ~1.2s, so it passes the full-page-screenshot rule.
	 */
	@keyframes ks-pip-on {
		from { opacity: 0; scale: 0.4; }
		to { opacity: 1; scale: 1; }
	}

	/* The home page hero owns its own entrance in its style records (Figma timing);
	 * these site-wide rules cover the Filters page hero only. */
	.ks-flt-hero__eyebrow, .ks-flt-hero__title, .ks-flt-hero__sub, .ks-flt-hero__actions, .ks-flt-hero__micro {
		animation: ks-enter 560ms cubic-bezier(0.2, 0, 0, 1) backwards;
	}

	.ks-flt-hero__title { animation-delay: 70ms; }
	.ks-flt-hero__sub { animation-delay: 140ms; }
	.ks-flt-hero__actions { animation-delay: 210ms; }
	.ks-flt-hero__micro { animation-delay: 280ms; }
	.ks-flt-hero .ks-flt-shot { animation: ks-enter 560ms cubic-bezier(0.2, 0, 0, 1) 180ms backwards; }

	/*
	 * The Figma-design home page motion vocabulary. ks-fade-up is the design's
	 * entrance (0.65s, its own spring-ish bezier); ks-float is the mockup's gentle
	 * infinite drift; ks-pip-pulse is the glowing status dot. The infinite two only
	 * translate or re-shadow - they can never hide content, so full-page
	 * screenshots stay valid at any moment.
	 */
	@keyframes ks-fade-up {
		from { opacity: 0; translate: 0 20px; }
		to { opacity: 1; translate: 0 0; }
	}

	@keyframes ks-float {
		0%, 100% { transform: translateY(0); }
		50% { transform: translateY(-10px); }
	}

	@keyframes ks-pip-pulse {
		0%, 100% { box-shadow: 0 0 5px rgba(69, 223, 202, 0.6), 0 0 10px rgba(69, 223, 202, 0.3); }
		50% { box-shadow: 0 0 10px rgba(69, 223, 202, 0.9), 0 0 22px rgba(69, 223, 202, 0.5); }
	}
}

/*
 * The shared announcement bar carries one message for the whole site, and on the
 * Filters product page that message promoted a different module's waitlist directly
 * above the page's own headline. Hidden here, still shown everywhere else. The body
 * class comes from ivasure_body_slug_class() in the mu-plugin: a slug, not the
 * page id, because ids differ between local and production.
 */
body.ks-page--filters-taxonomy .ks-announcement-bar { display: none; }
