/**
 * OTA Secondary Nav widget styles.
 *
 * The jump link bar from the content page design: a muted "On this page"
 * label, an 18px hairline divider, and a row of bold underlined links,
 * centred in a white band with a hairline bottom border. Figma node
 * 2253:25431; in situ under the page hero on node 220:39887.
 *
 * Every colour is a colour theme role, mapped once in the token block below,
 * so the bar follows whatever theme is in force above it. The frame binds the
 * links to brand/black and draws the label and both hairlines in brand/navy
 * at 59% and 14%, which are exactly what the text, muted-text and divider
 * roles resolve to on the default theme:
 *
 *   band surface   --ota-background
 *   label          --ota-text-muted
 *   hairlines      --ota-divider
 *   links          --ota-text
 *
 * Typography comes from the Elementor global fonts where a slot exists. The
 * links are the body size (17px) with a local bold, the same pairing the News
 * Block rows use. The 15px label has no slot in the type scale, so it is a
 * local constant with the Figma number on it.
 *
 * THE UNDERLINE IS A BORDER, AND THE HOVER IS A SHADOW
 *
 * Figma draws each link's underline as a 1px line 4px below the text, which
 * `text-decoration` cannot be told to do across browsers; `border-bottom` with
 * 4px of padding is the same drawing exactly. The hover thickens it to 2px by
 * adding a box-shadow under the border rather than widening the border, which
 * would move every link below the hovered one by a pixel.
 */

.ota-secnav {
	--osn-surface: var(--ota-background, #fff);
	--osn-label: var(--ota-text-muted, rgba(0, 48, 56, 0.59));
	--osn-divider: var(--ota-divider, rgba(0, 48, 56, 0.14));
	--osn-text: var(--ota-text, #000);
	--osn-accent: var(--ota-accent, #f04c3a);

	/* The frame's own measurements: 24px over 56px of padding, 31px gaps. */
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 31px;
	padding: 24px 56px;
	background-color: var(--osn-surface);
	border-bottom: 1px solid var(--osn-divider);
}

.ota-secnav__label {
	margin: 0;
	/* 15px: no slot in the AAA type scale, see the header note. */
	font-size: 0.9375rem;
	line-height: 1;
	color: var(--osn-label);
	white-space: nowrap;
}

.ota-secnav__divider {
	flex: none;
	width: 1px;
	height: 18px;
	background-color: var(--osn-divider);
}

.ota-secnav__list {
	display: flex;
	align-items: center;
	gap: 31px;
	margin: 0;
	padding: 0;
	list-style: none;
}

/*
 * The margins are not redundant with the list reset above. The theme spaces
 * stacked list items with a margin on every item after the first, and inside
 * a centred flex row half of that margin reappears as a 4px vertical offset
 * on links two onward. `line-height: 1` for the same reason: the theme's list
 * line-height is taller than the link inside, and the difference wobbles the
 * underline positions.
 */
.ota-secnav__item {
	margin: 0;
	padding: 0;
	line-height: 1;
}

/*
 * The class alone does not win that fight inside the page body. The theme
 * rule is the known one from _content.scss:
 *
 *   main#agendtheme-content .agendtheme-content-inner:not(…) ul:not(…, …)
 *   li + li { margin-top: 0.5rem }
 *
 * which counts one id, three classes and four elements, so a single class
 * loses on the id and the plain reset above only holds outside the content
 * container (popups, theme parts). This restates it at one id and four
 * classes. Measure the fix on the SECOND item: the theme rule skips the
 * first, which reads 0 and looks cured while the rest sit 4px low.
 */
#agendtheme-content .ota-secnav .ota-secnav__list > .ota-secnav__item + .ota-secnav__item {
	margin-top: 0;
}

.ota-secnav__link {
	display: inline-block;
	font-size: var(--e-global-typography-body-font-size, 1.0625rem);
	font-weight: 700;
	line-height: 1;
	color: var(--osn-text);
	text-decoration: none;
	white-space: nowrap;
	border-bottom: 1px solid currentColor;
	padding-bottom: 4px;
}

a.ota-secnav__link:hover,
a.ota-secnav__link:focus-visible {
	color: var(--osn-text);
	text-decoration: none;
	box-shadow: 0 1px 0 0 currentColor;
}

/*
 * The scrollspy's answer, written by ota-secondary-nav.js as `.is-active` and
 * `aria-current`. The design file draws no active variant, every link in the
 * frame carries the same underline, so this is a house call: the accent role
 * plus the hover's thicker underline, which is the same red the page's
 * eyebrows already use for "you are here" emphasis. `currentColor` keeps the
 * underline and the box-shadow on the accent for free.
 */
a.ota-secnav__link.is-active {
	color: var(--osn-accent);
	box-shadow: 0 1px 0 0 currentColor;
}

/*
 * WHY THE PAGE ITSELF GETS TWO RULES FROM A WIDGET'S STYLESHEET
 *
 * The site header is `position: fixed`, so a plain `#faq` jump puts the top
 * of the section underneath it. `scroll-padding-top` on the scrolling element
 * is the fix the platform provides, and `--ota-header-height` is already
 * measured onto `html` by ota-mega-menu.js, so the rule can read it directly.
 * The 16px on top is breathing room so the section does not land flush
 * against the header's edge.
 *
 * Scoped to pages that can jump, not the whole site, because this stylesheet
 * only loads where the widget renders: it is registered under
 * `elementor/frontend/after_register_styles` and enqueued through the
 * widget's get_style_depends(). A link INTO a page lands on the page that has
 * the bar, so the destination always carries these rules.
 *
 * The admin bar sits above the fixed header and `--ota-admin-bar` is scoped
 * to `body.admin-bar`, where `html` cannot read it, hence the `:has()` rules
 * restating WordPress's own two heights. Logged-in editors only.
 *
 * Three tiers, the same three ota-mega-menu.css models on `--ota-admin-bar`:
 * 32px, 46px from 782px down, and nothing from 600px down, where core
 * switches `#wpadminbar` to `position: absolute` so it scrolls away and stops
 * overlapping the fixed header. Without that last tier a logged-in user on a
 * phone gets 46px of padding for a bar no longer in the way, and every jump
 * lands the section 46px short under an empty gap.
 */
html {
	scroll-padding-top: calc(var(--ota-header-height, 0px) + var(--ota-secnav-height, 0px) + 16px);
}

html:has(body.admin-bar) {
	scroll-padding-top: calc(var(--ota-header-height, 0px) + var(--ota-secnav-height, 0px) + 32px + 16px);
}

@media screen and (max-width: 782px) {
	html:has(body.admin-bar) {
		scroll-padding-top: calc(var(--ota-header-height, 0px) + var(--ota-secnav-height, 0px) + 46px + 16px);
	}
}

@media screen and (max-width: 600px) {
	html:has(body.admin-bar) {
		scroll-padding-top: calc(var(--ota-header-height, 0px) + var(--ota-secnav-height, 0px) + 16px);
	}
}

/*
 * THE BAR STAYS UNDER THE HEADER WHILE THE PAGE SCROLLS
 *
 * Sticky must sit on the Elementor SECTION, not on the nav. A sticky element
 * sticks only within its parent, and the nav's parents (widget wrapper,
 * column, section) are each exactly as tall as the bar itself, so sticking
 * any of them is a no-op. The section's own parent is the document wrapper
 * that runs the full length of the page, which is what lets the bar ride to
 * the bottom. `:has()` reaches the section from here because the widget
 * cannot put a class on an ancestor it does not render.
 *
 * `top` is the fixed header's underside: the measured header height plus the
 * admin bar, which is readable here because the section sits inside `body`,
 * where `body.admin-bar` scopes `--ota-admin-bar` (unlike the `html`-level
 * scroll-padding rules above, which have to restate the numbers).
 *
 * The z-index only has to clear the page content the bar slides over.
 * Elementor's stretched-section margins are layout, not paint, so they
 * survive sticking untouched.
 *
 * Both wrappers are named because the site builds with legacy sections today
 * but Elementor's Flexbox container (`.e-con`) is what a new page gets once
 * containers are switched on. Dropped into a container with only the section
 * selector here, the bar renders correctly and silently neither sticks nor
 * bleeds, which is a hard failure to place.
 *
 * The `:not()` on BOTH is load-bearing, and legacy sections need it just as
 * much as containers: an Elementor inner section carries `.elementor-section`
 * too, so a bar dropped into one would otherwise match the outer section as
 * well. That turns a section full of unrelated sibling widgets sticky, and
 * applies the negative-margin bleed at two levels, pulling the bar off the
 * left edge by the content inset. Only the innermost wrapper holding the bar
 * may match.
 *
 * THE LIST VIEW MUST NOT MATCH, and the `:not()` above does not save it.
 *
 * That guard only defends against a nested SECTION. The stacked list view goes
 * in a sidebar COLUMN beside the article, which is the same section as
 * `theme-post-content`, with no inner section between them. Matched on the bare
 * `.ota-secnav`, the news single's whole article body went sticky, 100vw and
 * `z-index: 90`, and rode over the resources, author, ad and related-news
 * sections as the page scrolled. So the match is on the widget wrapper with the
 * bar view, not on the nav: the list view sets `ota-secnav-view--list` there and
 * wants none of this block, exactly as the list rules at the foot of this file
 * say. A section holding both a bar and a list still sticks, correctly, on the
 * strength of the bar.
 */
.elementor-section:not(:has(.elementor-section .ota-secnav)):has(.elementor-widget-ota_secondary_nav:not(.ota-secnav-view--list) .ota-secnav),
.e-con:not(:has(.e-con .ota-secnav)):has(.elementor-widget-ota_secondary_nav:not(.ota-secnav-view--list) .ota-secnav) {
	position: sticky;
	top: calc(var(--ota-admin-bar, 0px) + var(--ota-header-height, 0px));
	z-index: 90;

	/*
	 * FULL BLEED IN CSS, NOT VIA ELEMENTOR'S "STRETCH SECTION"
	 *
	 * The bar shipped stretched and it broke as soon as an admin looked at
	 * it: Elementor stretches by measuring the section's left offset and
	 * setting a negative margin, and any re-measure that runs while the bar
	 * is STUCK reads the stuck position (left edge at the viewport) instead
	 * of the natural one, bakes in a margin of zero, and the whole bar
	 * slides right by the content inset. Sticky and measure-then-write
	 * stretching cannot coexist, so the widget does the bleed itself: pin
	 * the width to the viewport and pull the left edge back by the distance
	 * between the section's natural position and the viewport edge, which
	 * `50% - 50vw` is by definition. Nothing is measured, so there is
	 * nothing to measure at the wrong moment.
	 */
	width: 100vw;
	margin-left: calc(50% - 50vw);
}

/*
 * 100vw includes the scrollbar gutter, so on a classic-scrollbar setup the
 * bar runs a few px under the scrollbar and would otherwise open a sideways
 * scroll. `clip`, not `hidden`: clip does not create a scroll container, so
 * it cannot swallow the sticky positioning above it.
 *
 * Scoped to the bar view for the same reason as the block above: this exists
 * only to contain that bleed, and the list view has none to contain. Clamping
 * `overflow` on the body of every page carrying a sidebar list would be a
 * page-wide side effect bought for nothing.
 */
body:has(.elementor-widget-ota_secondary_nav:not(.ota-secnav-view--list) .ota-secnav) {
	overflow-x: clip;
}

@media (prefers-reduced-motion: no-preference) {
	html {
		scroll-behavior: smooth;
	}
}

/*
 * Below the desktop layout the row keeps its order and scrolls sideways
 * instead of wrapping, which is the usual treatment for a jump bar: a wrapped
 * second line reads as two bars. `flex-start` because a centred row that
 * overflows a scroll container clips its leading edge unreachably.
 */
@media (max-width: 900px) {
	.ota-secnav {
		justify-content: flex-start;
		overflow-x: auto;
		gap: 24px;
		padding: 20px 24px;
	}

	.ota-secnav__list {
		gap: 24px;
	}

	/*
	 * A fade on the right edge while there are links off it, so the row reads
	 * as scrollable rather than ending at a cut-off label. Drawn on the widget,
	 * which does not scroll, so it stays put while the row moves under it; the
	 * script sets `has-more` and clears it at the end of the row. Inset 1px top
	 * and bottom to leave the hairlines whole. The list view never scrolls.
	 */
	.elementor-widget-ota_secondary_nav:not(.ota-secnav-view--list) {
		position: relative;
	}

	.elementor-widget-ota_secondary_nav:not(.ota-secnav-view--list)::after {
		content: "";
		position: absolute;
		inset-block: 1px;
		inset-inline-end: 0;
		inline-size: 56px;
		background: linear-gradient(to right, transparent, var(--ota-background, #fff));
		opacity: 0;
		pointer-events: none;
		transition: opacity 0.2s ease;
	}

	.elementor-widget-ota_secondary_nav:not(.ota-secnav-view--list):has(.ota-secnav.has-more)::after {
		opacity: 1;
	}
}

/*
 * THE STACKED LIST VIEW, for the news single's sidebar card ("In this page",
 * 404:9883). Same nav, same links, stood on end: the View control writes
 * `ota-secnav-view--list` onto the widget wrapper and these rules re-stack
 * what the bar laid out in a row. The label keeps its divider; the sticky
 * behaviour and the scrollspy are the bar's business and are not wanted here,
 * so nothing below touches position.
 */
.elementor-widget-ota_secondary_nav.ota-secnav-view--list .ota-secnav {
	flex-direction: column;
	align-items: stretch;
}

.elementor-widget-ota_secondary_nav.ota-secnav-view--list .ota-secnav__list {
	flex-direction: column;
	align-items: flex-start;
}

/* The theme's own li spacing rule outguns a bare class here, same fight the
   bar documents at its `#agendtheme-content` rule above. */
#agendtheme-content .elementor-widget-ota_secondary_nav.ota-secnav-view--list .ota-secnav .ota-secnav__list > .ota-secnav__item + .ota-secnav__item {
	margin-inline-start: 0;
}

/*
 * The list view sits INSIDE a card, so it brings no chrome of its own.
 *
 * The bar paints its own band: 24px by 56px of padding, the surface colour, and
 * a hairline along the bottom. In the sidebar the card
 * (assets/css/ota-news-single.css) already draws all three, so leaving them on
 * put a second padded, bordered box inside the card, which is what the sidebar
 * looked like before this block existed. 12px is the frame's gap from the
 * eyebrow to the first link.
 */
.elementor-widget-ota_secondary_nav.ota-secnav-view--list .ota-secnav {
	gap: 12px;
	padding: 0;
	background-color: transparent;
	border-bottom: 0;
}

/*
 * The eyebrow, matching every other card heading in the sidebar: 17px bold with
 * 1px of tracking in the accent, where the bar draws a 15px muted label. The
 * frame puts space between it and the first link, not a rule, so the bar's
 * hairline divider goes.
 */
.elementor-widget-ota_secondary_nav.ota-secnav-view--list .ota-secnav__label {
	font-size: 1.0625rem;
	font-weight: 700;
	line-height: 1.456;
	letter-spacing: 1px;
	color: var(--osn-accent);
	white-space: normal;
}

.elementor-widget-ota_secondary_nav.ota-secnav-view--list .ota-secnav__divider {
	display: none;
}

/*
 * THE ROWS
 *
 * The bar's links are bold, nowrap, and each carries a permanent underline,
 * because in a row that underline IS the link affordance. Stacked in a card the
 * frame draws them the other way round: light weight, no underline, and a 2px
 * rule down the left edge that only the current section lights up. So the
 * bottom border comes off and the left border comes on.
 *
 * `nowrap` has to go with it. A section title in a 257px column wraps, and left
 * as nowrap it would instead run out of the card.
 *
 * The gap is 0 rather than the 14px an earlier pass used: the frame spaces
 * these rows with 8px of padding inside each link, which keeps the whole row
 * clickable where a gap leaves dead stripes between them.
 */
.elementor-widget-ota_secondary_nav.ota-secnav-view--list .ota-secnav__list {
	gap: 0;
	align-self: stretch;
}

.elementor-widget-ota_secondary_nav.ota-secnav-view--list .ota-secnav__item {
	width: 100%;
	line-height: inherit;
}

.elementor-widget-ota_secondary_nav.ota-secnav-view--list .ota-secnav__link {
	display: block;
	padding: 8px 15px;
	font-size: 0.9375rem;
	font-weight: 300;
	line-height: 1.65;
	white-space: normal;
	border-bottom: 0;
	/* 1.904px in the frame. 2px: the frame's number is a scaled artefact and
	   no browser will draw the fraction. */
	border-left: 2px solid transparent;
}

/*
 * Hover is the underline arriving, not a second underline thickening, so the
 * bar's box-shadow trick is explicitly cancelled rather than inherited.
 */
.elementor-widget-ota_secondary_nav.ota-secnav-view--list a.ota-secnav__link:hover,
.elementor-widget-ota_secondary_nav.ota-secnav-view--list a.ota-secnav__link:focus-visible {
	color: var(--osn-text);
	text-decoration: underline;
	text-underline-position: from-font;
	box-shadow: none;
}

/*
 * The current section. Unlike the bar, the frame DOES draw an active variant
 * here (404:9883 marks the first link), and it is the text colour rather than
 * the accent: bold, underlined, with the left rule lit. The scrollspy still
 * runs in this view, so `.is-active` and `aria-current` arrive exactly as they
 * do on the bar.
 */
.elementor-widget-ota_secondary_nav.ota-secnav-view--list a.ota-secnav__link.is-active {
	color: var(--osn-text);
	font-weight: 700;
	text-decoration: underline;
	text-underline-position: from-font;
	border-left-color: var(--osn-text);
	box-shadow: none;
}

/*
 * THE BAR SITS FLUSH IN ITS WRAPPER, AND TAKES A TOP HAIRLINE WHEN IT SHARES
 * THE BANNER'S COLOUR.
 *
 * Elementor pads every widget in a column through the column's widget wrap
 * (10px from `.elementor-column-gap-default`), and a container through its
 * `--padding-*` variables (10px by default), so the bar ended 10px short of
 * each edge with a strip of the section showing under its hairline. The frame
 * (220:39887) has the bar full width and flush. Only when the bar is the sole
 * widget in its wrap: any sibling an editor adds beside it keeps its gutter.
 * A boxed container puts the widget inside `.e-con-inner`, hence both forms.
 */
.elementor-widget-wrap:has(> .elementor-widget-ota_secondary_nav:not(.ota-secnav-view--list):only-child) {
	padding: 0;
}

.e-con:has(> .elementor-widget-ota_secondary_nav:not(.ota-secnav-view--list):only-child),
.e-con:has(> .e-con-inner > .elementor-widget-ota_secondary_nav:not(.ota-secnav-view--list):only-child) {
	--padding-top: 0px;
	--padding-right: 0px;
	--padding-bottom: 0px;
	--padding-left: 0px;
}

/*
 * The frame draws the bar as its own white band under the hero, where the
 * colour change is the top edge. With no colour theme on any section or
 * container around it, the bar takes the page's theme, which is the hero's,
 * and runs straight on from the banner; that case gets the same hairline on
 * top. A colour theme on ANY wrapper above it, inner or outer, section or
 * container, makes it a band of its own, so it keeps the frame's bottom line
 * only. Tested on ancestors at every depth rather than the innermost wrapper,
 * because an unthemed inner section inside a themed outer one still renders
 * in the outer theme. `.elementor-element` keeps the body's site-theme class
 * out of it.
 */
.elementor-widget-ota_secondary_nav:not(.ota-secnav-view--list):not([class*="ota-theme--"]):not(.elementor-element[class*="ota-theme--"] *) .ota-secnav {
	border-top: 1px solid var(--osn-divider);
}
