/* F14 chapters + „where am I". Variables from F01 only. One element (.ap-pogl), two layouts:
   narrow = a strip that stays under the header; wide (≥ 1200 px) = a left sidebar that stays in view. */

/* ---- the menu says where you are: top item of the current section ---- */
.ap-hdr-nav a.ap-ovdje { background: var(--ap-line-on-dark); box-shadow: inset 0 -4px 0 var(--ap-on-brand); }

/* ---- shared ---- */
.ap-pogl { font-size: var(--ap-fs-s); line-height: 1.4; }
.ap-pogl p { margin: 0; }
.ap-pogl-oznaka { font-size: var(--ap-fs-xs); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ap-muted); }
.ap-pogl-naslov { font-weight: 700; color: var(--ap-text); }
.ap-pogl-naslov a { color: var(--ap-brand); text-decoration: underline; text-underline-offset: 3px; }
.ap-pogl-popis { list-style: none; margin: 0; padding: 0; counter-reset: ap-pogl; }
.ap-pogl-popis li { margin: 0; counter-increment: ap-pogl; }
.ap-pogl-popis a {
	display: flex; gap: var(--ap-sp-2); padding: var(--ap-sp-2) var(--ap-sp-3);
	color: var(--ap-text); text-decoration: none; border-left: 4px solid var(--ap-line);
}
.ap-pogl-popis a::before { content: counter(ap-pogl) "."; min-width: 1.6em; color: var(--ap-muted); font-variant-numeric: tabular-nums; }
.ap-pogl-popis a:hover { color: var(--ap-brand-dark); text-decoration: underline; text-underline-offset: 3px; }
.ap-pogl-popis a:focus-visible { outline: 3px solid var(--ap-brand); outline-offset: -3px; }
.ap-pogl-popis a[aria-current] { border-left-color: var(--ap-brand); background: var(--ap-tint); color: var(--ap-brand-dark); font-weight: 800; }
.ap-pogl-popis a[aria-current]::before { color: var(--ap-brand-dark); }

/* ---- narrow screens: the strip ---- */
.ap-pogl {
	position: sticky; top: var(--ap-hdr-nav); z-index: 50;
	margin: 0 0 var(--ap-sp-4); background: var(--ap-card);
	border-radius: var(--ap-radius-sm); box-shadow: var(--ap-shadow-bar);
}
.ap-pogl-glava { display: grid; gap: 2px; padding: var(--ap-sp-2) var(--ap-sp-3); }
.ap-pogl-glava .ap-pogl-oznaka { display: none; }
.ap-pogl-naslov { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: var(--ap-fs-xs); }
.ap-pogl-gumb {
	display: none; align-items: center; gap: var(--ap-sp-2); width: 100%; margin: 0; padding: var(--ap-sp-1) 0;
	background: none; border: 0; color: var(--ap-brand-dark); font: inherit; font-weight: 800; text-align: left; cursor: pointer;
}
.ap-pogl .ap-pogl-gumb:hover, .ap-pogl .ap-pogl-gumb:focus, .ap-pogl .ap-pogl-gumb:active { background: none; color: var(--ap-brand-dark); }
.ap-pogl-gumb-oznaka { color: var(--ap-muted); font-weight: 700; white-space: nowrap; }
.ap-pogl-sada { flex: 1; min-width: 0; }
.ap-pogl-strelica { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 7px solid currentColor; transition: transform .15s ease; }
.ap-pogl-gumb[aria-expanded="true"] .ap-pogl-strelica { transform: rotate(180deg); }
.ap-pogl-gumb:focus-visible { outline: 3px solid var(--ap-brand); outline-offset: 2px; }
.ap-pogl-oznaka-popis { display: none; }
.ap-pogl-popis { padding: 0 var(--ap-sp-2) var(--ap-sp-2); }

/* with JavaScript: the button shows, the list folds away until opened (without JavaScript it stays open) */
.ap-pogl.ap-js .ap-pogl-gumb { display: flex; }
.ap-pogl.ap-js .ap-pogl-popis { display: none; max-height: calc(100vh - var(--ap-hdr-nav) - 140px); max-height: calc(100dvh - var(--ap-hdr-nav) - 140px); overflow-y: auto; }
.ap-pogl.ap-js.ap-otvoreno .ap-pogl-popis { display: block; }

/* ---- wide screens: the left sidebar ---- */
@media (min-width: 1200px) {
	body.single.ap-ima-poglavlja .site-main {
		max-width: calc(var(--ap-reading) + 17rem + var(--ap-gap));
		display: grid; grid-template-columns: 17rem minmax(0, var(--ap-reading)); column-gap: var(--ap-gap); align-items: start;
	}
	body.single.ap-ima-poglavlja .site-main > * { grid-column: 2; }
	body.single.ap-ima-poglavlja .site-main > .ap-putokaz { grid-row: 1; }
	body.single.ap-ima-poglavlja .site-main > .ap-pogl { grid-column: 1; grid-row: 2 / span 50; }

	.ap-pogl {
		top: calc(var(--ap-hdr-nav) + var(--ap-sp-4)); margin: 0;
		max-height: calc(100vh - var(--ap-hdr-nav) - var(--ap-sp-4) * 2); overflow-y: auto;
		background: transparent; box-shadow: none; border-radius: 0;
	}
	.ap-pogl-glava { gap: var(--ap-sp-1); padding: 0 0 var(--ap-sp-4); margin: 0 0 var(--ap-sp-3); border-bottom: 1px solid var(--ap-line); }
	.ap-pogl-glava .ap-pogl-oznaka, .ap-pogl-oznaka-popis { display: block; }
	.ap-pogl-oznaka-popis { margin: 0 0 var(--ap-sp-2); }
	.ap-pogl-naslov { white-space: normal; font-size: var(--ap-fs-s); }
	.ap-pogl.ap-js .ap-pogl-gumb { display: none; }
	.ap-pogl.ap-js .ap-pogl-popis { display: block; max-height: none; overflow: visible; }
	.ap-pogl-popis { padding: 0; }
}

@media (prefers-reduced-motion: no-preference) {
	html:has(body.ap-ima-poglavlja) { scroll-behavior: smooth; }
}
