/* ==========================================================================
   Sisuleht külgmenüüga — section sidebar layout
   Visual language matches KKK / Hinnakiri sidebars.
   ========================================================================== */

.pv-section-page {
	background: var(--wp--preset--color--gray-01, #F0F4F8);

	/*
	 * Sticky offset: admin bar + measured site header + safe gap.
	 * Reuses theme tokens when present; page-section-sidebar.js may set
	 * --pv-section-sidebar-header-height from the live .site-header height.
	 */
	--pv-section-sidebar-gap: calc(24px * var(--pv-ui-scale));
	--pv-section-sidebar-admin-bar: 0px;
	--pv-section-sidebar-offset: calc(
		var(--pv-wp-admin-bar-height, var(--pv-section-sidebar-admin-bar))
		+ var(--pv-section-sidebar-header-height, var(--pv-site-header-height, calc(100px * var(--pv-ui-scale))))
		+ var(--pv-section-sidebar-gap)
	);
}

body.admin-bar .pv-section-page {
	--pv-section-sidebar-admin-bar: 32px;
}

@media screen and (max-width: 782px) {
	body.admin-bar .pv-section-page {
		--pv-section-sidebar-admin-bar: 46px;
	}
}

.pv-section-page__layout {
	display: flex;
	gap: calc(24px * var(--pv-ui-scale));
	align-items: flex-start;
	padding: calc(40px * var(--pv-ui-scale)) calc(58px * var(--pv-ui-scale)) calc(80px * var(--pv-ui-scale));
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
}

.pv-section-page__main {
	flex: 1;
	min-width: 0;
}

.pv-section-page--has-sidebar .pv-section-page__body {
	padding: 0;
}

/* --------------------------------------------------------------------------
   Sidebar (FAQ / Hinnakiri visual treatment)
   -------------------------------------------------------------------------- */

.pv-section-sidebar {
	box-sizing: border-box;
	flex-shrink: 0;
	width: calc(var(--pv-layout-sidebar-width, 320px) * var(--pv-ui-scale));
	min-width: 0;
	max-width: 100%;
	border-radius: calc(16px * var(--pv-ui-scale));
	padding: 0 calc(16px * var(--pv-ui-scale)) calc(32px * var(--pv-ui-scale));
	position: sticky;
	top: var(--pv-section-sidebar-offset);
	z-index: 10;
}

.pv-section-sidebar__label {
	/* Typography: shared .pv-*-sidebar__label rule in global.css (matches Hinnakiri) */
	box-sizing: border-box;
	/* Horizontal inset matches nav link padding; bottom gap matches Hinnakiri label */
	padding: 0 calc(16px * var(--pv-ui-scale)) calc(18px * var(--pv-ui-scale));
}

.pv-section-sidebar__toggle {
	display: none;
}

.pv-section-sidebar__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: calc(2px * var(--pv-ui-scale));
}

.pv-section-sidebar__item {
	border-radius: calc(12px * var(--pv-ui-scale));
	transition: background 0.18s;
}

.pv-section-sidebar__link {
	box-sizing: border-box;
	display: flex;
	align-items: center;
	gap: calc(10px * var(--pv-ui-scale));
	width: 100%;
	padding: calc(14px * var(--pv-ui-scale)) calc(16px * var(--pv-ui-scale));
	border: none;
	border-radius: calc(12px * var(--pv-ui-scale));
	background: transparent;
	color: var(--wp--preset--color--brand-01-dark, #102f5d);
	font-family: var(--wp--preset--font-family--inter, 'Inter', sans-serif);
	font-weight: 600;
	font-size: calc(15px * var(--pv-ui-scale));
	line-height: 1.5;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	text-decoration: none;
	text-align: left;
	white-space: normal;
	min-width: 0;
	overflow-wrap: anywhere;
	transition: color 0.18s, background 0.18s;
}

.pv-section-sidebar__link:hover {
	background: rgba(255, 255, 255, 0.55);
}

.pv-section-sidebar__link:focus-visible {
	outline: 2px solid var(--wp--preset--color--brand-01, #348695);
	outline-offset: -2px;
}

.pv-section-sidebar__item.is-active {
	background: var(--wp--preset--color--white, #fff);
	box-shadow: 0 calc(1px * var(--pv-ui-scale)) calc(4px * var(--pv-ui-scale)) rgba(0, 0, 0, 0.07);
}

.pv-section-sidebar__item.is-active .pv-section-sidebar__link {
	color: var(--wp--preset--color--brand-01-dark, #102f5d);
}

/* Anchored text-block sections — clear sticky header */
.pv-section-page .pv-text-block__section[id] {
	scroll-margin-top: var(--pv-section-sidebar-offset);
}

/* Hankimine ja projektid — fixed sidebar anchors */
.pv-hankimine-page #projektid,
.pv-hankimine-page #hankekord,
.pv-hankimine-page #hankeplaan-2026 {
	scroll-margin-top: var(--pv-section-sidebar-offset);
}

.pv-hankimine-page .pv-hankimine-projects-anchor {
	height: 0;
	margin: 0;
	padding: 0;
	overflow: hidden;
}

/* Match Hinnakiri page title scale on sidebar layout pages (desktop only) */
@media (min-width: 901px) {
	.pv-section-page .pv-text-block__intro-title {
		font-size: calc(var(--pv-layout-page-title-size, 56px) * var(--pv-ui-scale));
		letter-spacing: calc(var(--pv-layout-page-title-tracking, -1.68px) * var(--pv-ui-scale));
	}
}

/* --------------------------------------------------------------------------
   Responsive — match KKK/Hinnakiri breakpoint
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
	.pv-section-page__layout {
		flex-direction: column;
		padding: calc(24px * var(--pv-ui-scale)) calc(24px * var(--pv-ui-scale)) calc(60px * var(--pv-ui-scale));
	}

	.pv-section-sidebar {
		width: 100%;
		position: static;
		padding: 0 0 calc(8px * var(--pv-ui-scale));
	}

	.pv-section-sidebar__nav {
		width: 100%;
	}

	.pv-section-sidebar__list {
		flex-direction: row;
		flex-wrap: wrap;
		gap: calc(4px * var(--pv-ui-scale));
	}

	.pv-section-sidebar__item {
		flex: 1 1 auto;
	}

	.pv-section-sidebar__link {
		padding: calc(10px * var(--pv-ui-scale)) calc(14px * var(--pv-ui-scale));
		font-size: calc(14px * var(--pv-ui-scale));
	}

	/* Match Hinnakiri mobile sidebar heading padding (typography stays shared) */
	.pv-section-sidebar__label {
		padding: calc(8px * var(--pv-ui-scale)) calc(12px * var(--pv-ui-scale));
	}

	.pv-section-sidebar__toggle {
		display: none;
	}
}

@media (max-width: 640px) {
	.pv-section-page__layout {
		padding: calc(16px * var(--pv-ui-scale)) calc(16px * var(--pv-ui-scale)) calc(48px * var(--pv-ui-scale));
	}
}

@media (prefers-reduced-motion: reduce) {
	.pv-section-sidebar__item,
	.pv-section-sidebar__link {
		transition: none;
	}
}
