/*
 * Header — top bar, header row, mega menu.
 * Design: TopBar / NavBurger / MegaPanel in src-v2/nav.jsx.
 *
 * Tokens and the .wrap, .eyebrow, .btn, .iconbtn, .link-arrow atoms come from
 * global.css; only header-specific layout lives here.
 */

/* ------------------------------------------------------- Admin bar ---- */

/*
 * WordPress pins its admin bar to the top of the viewport and pushes the
 * document down by the same amount: 32px, 46px below 782px, and below 600px it
 * turns absolute and scrolls away with the page. Everything sticky in the
 * header reads this one value rather than restating those breakpoints — which
 * is also what had stopped working: the mobile block came later in the file
 * than the 600px rule and silently overrode it.
 */
:root {
	--fmt-admin-bar: 0px;
}

.admin-bar {
	--fmt-admin-bar: 32px;
}

@media screen and (max-width: 782px) {
	.admin-bar {
		--fmt-admin-bar: 46px;
	}
}

@media screen and (max-width: 600px) {
	.admin-bar {
		--fmt-admin-bar: 0px;
	}
}

/* --------------------------------------------------------- Skip link ---- */

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

.skip-link:focus {
	background: var(--paper);
	clip-path: none;
	color: var(--ink);
	height: auto;
	left: 8px;
	padding: 12px 20px;
	top: 8px;
	width: auto;
	z-index: 100;
}

/* ------------------------------------------------------------ Top bar ---- */

.fmt-topbar {
	background: var(--bg);
	border-bottom: 1px solid var(--line);
	color: var(--ink-soft);
	font-size: 12px;
}

.fmt-topbar__inner {
	align-items: center;
	display: flex;
	height: 36px;
	justify-content: space-between;
}

.fmt-topbar__left {
	align-items: center;
	display: flex;
	gap: 18px;
}

.fmt-topbar__phone {
	align-items: center;
	display: inline-flex;
	gap: 6px;
}

.fmt-topbar__phone a {
	color: var(--ink);
}

.fmt-topbar__mute,
.fmt-topbar__sep {
	color: var(--ink-mute);
}

.fmt-topbar__dot {
	align-items: center;
	display: inline-flex;
	gap: 6px;
}

.fmt-topbar__dot::before {
	background: var(--red);
	border-radius: 50%;
	content: '';
	height: 6px;
	width: 6px;
}

/*
 * .fmt-topbar__phone and .fmt-topbar__dot set display, which outranks the
 * [hidden] rule in normalize — without this the ticker cannot hide them.
 */
.fmt-topbar__item[hidden] {
	display: none;
}

/* -------------------------------------------------------- Header row ---- */

.fmt-page-header {
	background: var(--bg);
	border-bottom: 1px solid var(--line);
	position: sticky;
	top: var(--fmt-admin-bar);
	z-index: 50;
}

/* Progressive blur — only where it does not cost the solid fallback. */
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
	.fmt-page-header {
		-webkit-backdrop-filter: blur(14px) saturate(140%);
		backdrop-filter: blur(14px) saturate(140%);
		background: rgba(251, 250, 246, .92);
	}
}

.fmt-header__row {
	align-items: center;
	display: flex;
	gap: 6px;
	height: 96px;
	position: relative;
}

/* 6px row gap + 12px = the 18px the design puts between burger and Baubuch. */
.fmt-burger {
	margin-right: 12px;
}

/* Everything after this is pushed to the right edge. */
.fmt-header__baubuch {
	margin-right: auto;
}

/* Burger */

.fmt-burger {
	align-items: center;
	background: var(--paper);
	border: 1px solid var(--line);
	border-radius: 8px;
	box-shadow: 0 1px 2px rgba(20, 18, 12, .04);
	color: var(--ink);
	cursor: pointer;
	display: inline-flex;
	font-family: inherit;
	font-size: 14px;
	font-weight: 500;
	gap: 12px;
	line-height: 1;
	padding: 11px 18px 11px 14px;
	position: relative;
	transition: background .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.fmt-page-header.is-open .fmt-burger {
	background: var(--ink-2);
	border-color: var(--ink-2);
	box-shadow: none;
	color: #fff;
}

.fmt-burger__bars {
	display: inline-flex;
	flex-direction: column;
	gap: 4px;
	width: 18px;
}

.fmt-burger__bars span {
	background: currentColor;
	border-radius: 2px;
	height: 2px;
	transform-origin: 50% 50%;
	transition: transform .2s ease, opacity .15s ease;
}

.fmt-page-header.is-open .fmt-burger__bars span:nth-child(1) {
	transform: translateY(6px) rotate(45deg);
}

.fmt-page-header.is-open .fmt-burger__bars span:nth-child(2) {
	opacity: 0;
}

.fmt-page-header.is-open .fmt-burger__bars span:nth-child(3) {
	transform: translateY(-6px) rotate(-45deg);
}

/* Baubuch link */

.fmt-header__baubuch {
	align-items: center;
	color: var(--ink-soft);
	display: inline-flex;
	font-size: 14px;
	font-weight: 500;
	gap: 7px;
	transition: color .18s ease;
}

.fmt-header__baubuch:hover {
	color: var(--red);
}

/* Logo — centred over the row, so the two side groups can size freely. */

.fmt-header__logo {
	left: 50%;
	position: absolute;
	transform: translateX(-50%);
}

.fmt-header__logo img,
.fmt-header__logo .custom-logo {
	display: block;
	height: 56px;
	max-width: 100%;
	width: auto;
}

.fmt-logo-text {
	color: var(--ink);
	display: block;
	font-size: 20px;
	font-weight: 600;
	letter-spacing: -0.02em;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Actions */

.fmt-header__login,
.fmt-header__cta {
	flex: none;
	padding: 9px 14px;
	white-space: nowrap;
}

.fmt-header__search {
	flex: none;
}

/* Mobile-only overlay chrome. */
.fmt-mega__mobile-head,
.fmt-mega__mobile-foot {
	display: none;
}

/* The tab carries both affordances; each mode shows the one that fits. */
.fmt-mega__tab-arrow {
	display: inline-flex;
}

.fmt-mega__tab-chevron {
	display: none;
}

/* ---------------------------------------------------------- Mega menu ---- */

/*
 * Unscripted: the panel sits in normal flow, fully open, every category
 * visible. .fmt-js switches it to the overlay behaviour below.
 */
.fmt-mega__backdrop {
	display: none;
}

.fmt-js .fmt-mega__backdrop {
	background: rgba(20, 18, 12, .32);
	display: block;
	height: 100vh;
	left: 0;
	opacity: 0;
	pointer-events: none;
	position: absolute;
	right: 0;
	top: 100%;
	transition: opacity .22s ease;
	z-index: 1;
}

.fmt-page-header.is-open .fmt-mega__backdrop {
	opacity: 1;
	pointer-events: auto;
}

.fmt-mega {
	background: var(--paper);
	border-bottom: 1px solid var(--line);
}

.fmt-js .fmt-mega {
	box-shadow: 0 30px 60px -20px rgba(20, 18, 12, .25);
	left: 0;
	max-height: calc(100vh - var(--fmt-admin-bar) - 96px);
	opacity: 0;
	overflow-y: auto;
	pointer-events: none;
	position: absolute;
	right: 0;
	top: 100%;
	transform: translateY(-12px);
	transition: transform .25s ease, opacity .22s ease;
	z-index: 2;
}

.fmt-page-header.is-open .fmt-mega {
	opacity: 1;
	pointer-events: auto;
	transform: translateY(0);
}

.fmt-mega__inner {
	display: grid;
	gap: 72px;
	grid-template-columns: 260px 1fr;
	padding-bottom: 44px;
	padding-top: 36px;
}

/* Rail */

.fmt-mega__rail {
	border-right: 1px solid var(--line);
	padding-right: 20px;
}

.fmt-mega__rail-title {
	margin-bottom: 14px;
}

.fmt-mega__tabs {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

/* Shortcuts */

.fmt-mega__shortcuts {
	border-top: 1px solid var(--line);
	margin-top: 28px;
	padding-top: 20px;
}

.fmt-mega__shortcuts-title {
	margin-bottom: 10px;
}

.fmt-mega__shortcuts-list {
	display: flex;
	flex-direction: column;
	gap: 8px;
	list-style: none;
	margin: 0;
	padding: 0;
}

.fmt-mega__shortcuts-list a {
	color: var(--ink);
	font-size: 13.5px;
	transition: color .15s ease;
}

.fmt-mega__shortcuts-list a:hover {
	color: var(--red);
}

.fmt-mega__tab {
	align-items: center;
	background: transparent;
	border: 0;
	border-radius: 6px;
	color: var(--ink);
	cursor: pointer;
	display: flex;
	font-family: inherit;
	font-size: 15px;
	font-weight: 500;
	gap: 8px;
	justify-content: space-between;
	padding: 12px 14px;
	text-align: left;
	transition: background .15s ease, color .15s ease;
}

.fmt-mega__tab .icon {
	flex: none;
	opacity: .4;
}

.fmt-mega__tab:hover {
	background: var(--bg-2);
}

.fmt-mega__tab.is-active {
	background: var(--ink-2);
	color: #fff;
}

.fmt-mega__tab.is-active .icon {
	opacity: .9;
}

/* Panels */

.fmt-mega__panel-head {
	align-items: baseline;
	display: flex;
	gap: 24px;
	justify-content: space-between;
	margin-bottom: 26px;
}

.fmt-mega__panel-title {
	font-size: 34px;
	font-weight: 500;
	letter-spacing: -0.022em;
	line-height: 1.1;
	margin: 0;
}

.fmt-mega__panel-head .link-arrow {
	flex: none;
	text-decoration: none;
}

.fmt-mega__intro {
	color: var(--ink-soft);
	font-size: 15px;
	margin: 0 0 32px;
	max-width: 560px;
}

.fmt-mega__cols {
	display: grid;
	gap: 48px;
	grid-template-columns: 1fr 1fr;
}

.fmt-mega__col-title {
	border-bottom: 1px solid var(--line);
	margin-bottom: 14px;
	padding-bottom: 12px;
}

.fmt-mega__list {
	display: flex;
	flex-direction: column;
	gap: 4px;
	list-style: none;
	margin: 0;
	padding: 0;
}

.fmt-mega__list a,
.fmt-mega__list span {
	color: var(--ink);
	display: block;
	font-size: 15px;
	padding: 11px 0;
	transition: color .15s ease;
}

.fmt-mega__list a:hover {
	color: var(--red);
}

/* Unscripted fallback: stack the categories instead of overlapping them. */
.fmt-mega__panel + .fmt-mega__panel {
	border-top: 1px solid var(--line);
	margin-top: 40px;
	padding-top: 40px;
}

.fmt-js .fmt-mega__panel + .fmt-mega__panel {
	border-top: 0;
	margin-top: 0;
	padding-top: 0;
}

/* Closing band */

.fmt-mega__band {
	background: var(--bg-2);
	border-top: 1px solid var(--line);
	padding: 14px 0;
}

.fmt-mega__band-inner {
	align-items: center;
	color: var(--ink-soft);
	display: flex;
	font-size: 13px;
	gap: 24px;
	justify-content: space-between;
}

.fmt-mega__band-link {
	border-bottom: 1px solid var(--ink-mute);
	color: var(--ink);
}

.fmt-mega__legal {
	display: inline-flex;
	gap: 14px;
	list-style: none;
	margin: 0;
	padding: 0;
}

.fmt-mega__legal a {
	color: var(--ink-soft);
}

.fmt-mega__legal a:hover {
	color: var(--ink);
}

/* ------------------------------------------------------- Scroll lock ---- */

.fmt-nav-locked {
	overflow: hidden;
}

/* -------------------------------------------------------- Responsive ---- */

/*
 * Two layouts, one structure. The design draws them as separate pages
 * (Startseite.html vs Startseite Mobil.html), so this is where they meet:
 *
 *   901px and up   desktop panel — rail of tabs, one category shown at a time
 *                  (901–1100 keeps the panel but lays the rail out as a
 *                  horizontal tab row, since 260px of rail no longer fits)
 *   900px and down full screen overlay sliding in from the left, categories as
 *                  a single-open accordion
 *
 * header.js switches the widget semantics at the same 900px line and moves the
 * category buttons from the rail into their panels.
 */

@media (max-width: 1100px) {
	.fmt-mega__inner {
		display: block;
	}

	.fmt-mega__rail {
		border-bottom: 1px solid var(--line);
		border-right: 0;
		margin-bottom: 28px;
		padding-bottom: 20px;
		padding-right: 0;
	}

	.fmt-mega__tabs {
		flex-direction: row;
		flex-wrap: wrap;
	}

	.fmt-mega__tab {
		gap: 10px;
	}

	.fmt-mega__panel-title {
		font-size: 28px;
	}
}

@media (max-width: 900px) {

	/* --- Top bar: one rotating line instead of three side by side --- */

	.fmt-topbar {
		position: sticky;
		top: var(--fmt-admin-bar);
		z-index: 51;
	}

	.fmt-topbar__inner {
		gap: 8px;
		height: 34px;
		justify-content: flex-start;
	}

	/* Lift the items out of their two groups so the ticker can cycle them. */
	.fmt-topbar__left,
	.fmt-topbar__right {
		display: contents;
	}

	.fmt-topbar__sep {
		display: none;
	}

	.fmt-topbar__item {
		transition: opacity .3s ease, transform .3s ease;
	}

	.fmt-topbar__item.is-leaving {
		opacity: 0;
		transform: translateY(-4px);
	}

	/* --- Header row: 60px, actions as icon buttons --- */

	/* Sits directly under the sticky top bar, which is 34px tall here. */
	.fmt-page-header {
		top: calc(var(--fmt-admin-bar) + 34px);
	}

	/*
	 * backdrop-filter makes the header a containing block for fixed children,
	 * which would trap the overlay inside the 60px row. The mobile design has no
	 * blur anyway.
	 */
	.fmt-page-header {
		-webkit-backdrop-filter: none;
		backdrop-filter: none;
		background: var(--bg);
	}

	/*
	 * The rail survives here for the Kurzwege alone, so the column has to be
	 * orderable: panels first, shortcuts underneath.
	 */
	.fmt-mega__panels {
		order: 1;
	}

	.fmt-mega__rail {
		border-bottom: 0;
		margin-bottom: 0;
		order: 2;
		padding-bottom: 0;
	}

	.fmt-mega__rail-nav {
		display: none;
	}

	.fmt-mega__shortcuts {
		border-top: 0;
		margin-top: 22px;
		padding-top: 0;
	}

	.fmt-mega__shortcuts-title {
		margin-bottom: 12px;
	}

	.fmt-mega__shortcuts-list {
		gap: 12px;
	}

	.fmt-mega__shortcuts-list a {
		font-size: 15px;
	}

	/* 20px matches the design's mobile container (.mwrap). */
	.wrap.fmt-header__row {
		gap: 4px;
		height: 60px;
		padding: 0 20px;
	}

	.fmt-burger {
		margin-right: auto;
		order: 1;
		padding: 9px 14px 9px 11px;
	}

	.fmt-burger__bars {
		gap: 4px;
		width: 16px;
	}

	/*
	 * The logo is out of flow, so the row cannot reserve space for it. The real
	 * logo is 86px wide at 48px tall and fits easily; the text fallback does
	 * not, hence the cap — it shrinks rather than sliding under the buttons.
	 */
	.fmt-header__logo {
		max-width: calc(100% - 210px);
		order: 2;
	}

	.fmt-header__logo img,
	.fmt-header__logo .custom-logo {
		height: 48px;
	}

	.fmt-logo-text {
		font-size: 14px;
	}

	.fmt-header__baubuch {
		margin-right: 0;
		order: 3;
	}

	.fmt-header__login {
		order: 4;
	}

	.fmt-header__search {
		order: 5;
	}

	/* The red CTA moves into the overlay foot, where it gets full width. */
	.fmt-header__cta {
		display: none;
	}

	/* Baubuch and Anmelden become icon buttons; their labels stay for
	   assistive tech so both keep an accessible name. */
	.fmt-header__baubuch,
	.fmt-header__login {
		background: transparent;
		border: 0;
		border-radius: 6px;
		color: var(--ink);
		flex: none;
		height: 40px;
		justify-content: center;
		padding: 0;
		width: 40px;
	}

	.fmt-header__baubuch:hover,
	.fmt-header__login:hover {
		background: rgba(0, 0, 0, .06);
		box-shadow: none;
		color: var(--ink);
		transform: none;
	}

	.fmt-header__baubuch > span,
	.fmt-header__login > span {
		clip-path: inset(50%);
		height: 1px;
		overflow: hidden;
		position: absolute;
		white-space: nowrap;
		width: 1px;
	}

	/* --- Overlay --- */

	.fmt-page-header.is-open {
		z-index: 90;
	}

	/* The overlay fills the viewport, so there is nothing left to dim. */
	.fmt-js .fmt-mega__backdrop {
		display: none;
	}

	.fmt-js .fmt-mega {
		background: var(--bg);
		border-bottom: 0;
		bottom: 0;
		box-shadow: none;
		display: flex;
		flex-direction: column;
		left: 0;
		max-height: none;
		opacity: 1;
		overflow: hidden;
		position: fixed;
		right: 0;
		/* Cleared by the admin bar; header.js measures what is on screen. */
		top: var(--fmt-admin-offset, 0px);
		transform: translateX(-100%);
		transition: transform .3s cubic-bezier(.16, 1, .3, 1), visibility .3s;
		visibility: hidden;
		z-index: 90;
	}

	.fmt-page-header.is-open .fmt-mega {
		transform: translateX(0);
		visibility: visible;
	}

	.fmt-mega__mobile-head {
		align-items: center;
		border-bottom: 1px solid var(--line);
		display: flex;
		flex: none;
		justify-content: space-between;
		padding: 16px 20px;
	}

	.fmt-mega__mobile-logo img,
	.fmt-mega__mobile-logo .custom-logo {
		display: block;
		height: 38px;
		width: auto;
	}

	.fmt-mega__close {
		align-items: center;
		background: var(--paper);
		border: 1px solid var(--line);
		border-radius: 8px;
		color: var(--ink);
		cursor: pointer;
		display: flex;
		flex: none;
		height: 40px;
		justify-content: center;
		width: 40px;
	}

	.fmt-mega__scroll {
		flex: 1;
		overflow-y: auto;
	}

	.wrap.fmt-mega__inner {
		display: flex;
		flex-direction: column;
		/* The 72px column gap of the desktop grid carries over into flex. */
		gap: 0;
		padding: 8px 20px 24px;
	}

	/* --- Accordion --- */

	.fmt-mega__panel {
		border-bottom: 1px solid var(--line);
	}

	.fmt-mega__panel + .fmt-mega__panel {
		border-top: 0;
		margin-top: 0;
		padding-top: 0;
	}

	.fmt-mega__panel-head {
		display: none;
	}

	.fmt-mega__tab,
	.fmt-mega__tab:hover,
	.fmt-mega__tab.is-active {
		background: transparent;
		border-radius: 0;
		color: var(--ink);
	}

	.fmt-mega__tab {
		font-size: 17px;
		padding: 16px 0;
		width: 100%;
	}

	.fmt-mega__tab-arrow {
		display: none;
	}

	.fmt-mega__tab-chevron {
		color: var(--ink-mute);
		display: inline-flex;
		transition: transform .2s ease;
	}

	.fmt-mega__tab[aria-expanded="true"] .fmt-mega__tab-chevron {
		transform: rotate(180deg);
	}

	.fmt-mega__tab .icon {
		opacity: 1;
	}

	.fmt-mega__panel-body {
		padding-bottom: 14px;
	}

	.fmt-mega__intro {
		font-size: 13px;
		margin: 0 0 14px;
	}

	.fmt-mega__cols {
		display: block;
	}

	.fmt-mega__col {
		margin-bottom: 16px;
	}

	.fmt-mega__col-title {
		border-bottom: 0;
		margin-bottom: 8px;
		padding-bottom: 0;
	}

	.fmt-mega__list {
		gap: 2px;
	}

	.fmt-mega__list a,
	.fmt-mega__list span {
		color: var(--ink-soft);
		padding: 9px 0;
	}

	/* The closing band is desktop only — its links live in the footer too. */
	.fmt-mega__band {
		display: none;
	}

	.fmt-mega__mobile-foot {
		border-top: 1px solid var(--line);
		display: flex;
		flex: none;
		flex-direction: column;
		gap: 10px;
		padding: 16px 20px;
	}

	.fmt-mega__mobile-foot .btn {
		justify-content: center;
	}
}

/*
 * Narrow phones. A centred logo plus a burger plus three icon buttons does not
 * fit 375px, so two things give way: the burger label, and the search button —
 * the least load-bearing of the three actions.
 */
@media (max-width: 400px) {
	.fmt-header__search {
		display: none;
	}

	.fmt-burger {
		gap: 0;
		padding: 11px 13px;
	}

	.fmt-burger__label {
		clip-path: inset(50%);
		height: 1px;
		overflow: hidden;
		position: absolute;
		white-space: nowrap;
		width: 1px;
	}
}
