/* ==========================================================================
   Grind Hog — HTML Sitemap
   --------------------------------------------------------------------------
   Styles the [sitemap]-style shortcode output rendered by
   inc/sitemap.php + inc/sitemap-pdfs.php. Sales staff use the PDF index in
   here as a daily lookup tool, so fast scanning + fast filtering are the
   priorities — not decoration.

   Every selector in this file is scoped under .gh-sitemap so nothing leaks
   into the rest of the site. The markup/class contract is owned by the PHP
   templates above — do not rename classes here without updating those files.

   Font family is intentionally NOT declared: it inherits GeneratePress's
   body font stack. Colors reuse the theme's existing custom properties
   (--base, --base-2, --base-3, --accent, --accent-2, already used elsewhere
   in this child theme's style.css) with hard-coded fallbacks in case the
   Customizer values are ever unset.

   Table of contents:
     1. Custom properties (retune here)
     2. Layout wrapper
     3. Filter bar (sticky search + live status region)
     4. Empty-state message
     5. Heading hierarchy (h2 section / h3 group / h4 subgroup)
     6. Lists, items, links, PDF badge, filename handle
     7. Filter visibility toggle (.is-hidden)
     8. Multi-column responsive layout
     9. Reduced motion
    10. Print
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Custom properties — retune here
   -------------------------------------------------------------------------- */
.gh-sitemap {
	/* Colors — reuse theme vars where they exist, with safe fallbacks */
	--gh-sitemap-border-color: var(--base, #d7d7d7);
	--gh-sitemap-bg: var(--base-3, #fff);
	--gh-sitemap-bg-muted: var(--base-2, #f5f5f5);
	--gh-sitemap-accent: var(--accent, #c0392b);
	--gh-sitemap-accent-2: var(--accent-2, #a83226);
	--gh-sitemap-accent-contrast: #fff;
	--gh-sitemap-text-muted: #6b7280;

	/* PDF affordance badge */
	--gh-sitemap-pdf-badge-bg: color-mix(in srgb, var(--gh-sitemap-accent) 12%, transparent);
	--gh-sitemap-pdf-badge-color: var(--gh-sitemap-accent);

	/* Type */
	--gh-sitemap-mono-font: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

	/* Spacing rhythm — the h2 gap is intentionally large; this page is long */
	--gh-sitemap-gap-section: 3.5rem;
	--gh-sitemap-gap-group: 2rem;
	--gh-sitemap-gap-subgroup: 1.25rem;
	--gh-sitemap-radius: 4px;

	/* Multi-column list layout */
	--gh-sitemap-column-width: 220px;

	/* Sticky filter bar offset — bump this if a sticky/floating site header
	   is enabled (e.g. via GP Premium's sticky header module) so the filter
	   bar doesn't end up underneath it. 0 assumes no sticky header. */
	--gh-sitemap-sticky-offset: 0px;

	/* Motion */
	--gh-sitemap-transition: 0.15s ease;

	display: block;
}

/* --------------------------------------------------------------------------
   2. Layout wrapper
   -------------------------------------------------------------------------- */
.gh-sitemap {
	max-width: 100%;
}

.gh-sitemap *,
.gh-sitemap *::before,
.gh-sitemap *::after {
	box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   3. Filter bar — sticky search + live status region
   -------------------------------------------------------------------------- */
.gh-sitemap__filter {
	position: sticky;
	top: var(--gh-sitemap-sticky-offset);
	z-index: 20;
	background: var(--gh-sitemap-bg);
	padding: 0.85rem 0;
	margin-bottom: 2rem;
	border-bottom: 1px solid var(--gh-sitemap-border-color);
}

/* WordPress admin toolbar is fixed at the top when logged in — keep the
   sticky filter bar below it instead of underneath it. */
body.admin-bar .gh-sitemap__filter {
	top: calc(var(--gh-sitemap-sticky-offset) + 32px);
}

@media screen and (max-width: 782px) {
	body.admin-bar .gh-sitemap__filter {
		top: calc(var(--gh-sitemap-sticky-offset) + 46px);
	}
}

.gh-sitemap__filter-input {
	display: block;
	width: 100%;
	max-width: 32rem;
	padding: 0.7rem 1rem;
	font-size: 1.05rem;
	line-height: 1.3;
	color: inherit;
	background: var(--gh-sitemap-bg);
	border: 2px solid var(--gh-sitemap-border-color);
	border-radius: var(--gh-sitemap-radius);
	appearance: none;
	-webkit-appearance: none;
	transition: border-color var(--gh-sitemap-transition), box-shadow var(--gh-sitemap-transition);
}

.gh-sitemap__filter-input::placeholder {
	color: var(--gh-sitemap-text-muted);
	opacity: 1;
}

.gh-sitemap__filter-input:hover {
	border-color: var(--gh-sitemap-accent);
}

.gh-sitemap__filter-input:focus,
.gh-sitemap__filter-input:focus-visible {
	outline: none;
	border-color: var(--gh-sitemap-accent);
	box-shadow: 0 0 0 3px var(--gh-sitemap-pdf-badge-bg);
}

/* Native "clear" (x) button on type=search inputs — keep it, just size it */
.gh-sitemap__filter-input::-webkit-search-cancel-button {
	appearance: auto;
	-webkit-appearance: auto;
}

/* Visually-hidden aria-live status region, created and appended by
   sitemap.js inside .gh-sitemap__filter. Class name is our own contract
   between the JS and CSS in this pair of files. */
.gh-sitemap__status {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* --------------------------------------------------------------------------
   4. Empty-state message
   -------------------------------------------------------------------------- */
.gh-sitemap__empty {
	display: none;
	padding: 1.5rem;
	margin-bottom: 2rem;
	text-align: center;
	color: var(--gh-sitemap-text-muted);
	background: var(--gh-sitemap-bg-muted);
	border: 1px dashed var(--gh-sitemap-border-color);
	border-radius: var(--gh-sitemap-radius);
}

.gh-sitemap__empty.is-visible {
	display: block;
}

/* --------------------------------------------------------------------------
   5. Heading hierarchy — h2 section / h3 group / h4 subgroup
   -------------------------------------------------------------------------- */

/* h2 — strong separation; this page is long, sections need to read as
   distinct "chapters" when skimming or using the browser's find-in-page. */
.gh-sitemap__section {
	margin-top: var(--gh-sitemap-gap-section);
}

.gh-sitemap__section:first-of-type {
	margin-top: 0;
}

.gh-sitemap__section-title {
	margin: 0 0 1.5rem;
	padding-bottom: 0.6rem;
	font-size: 1.75rem;
	font-weight: 800;
	line-height: 1.2;
	border-bottom: 3px solid var(--gh-sitemap-accent);
}

/* h3 — group within a section */
.gh-sitemap__group {
	margin-top: var(--gh-sitemap-gap-group);
}

.gh-sitemap__group:first-child {
	margin-top: 0;
}

.gh-sitemap__group-title {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.5rem;
	margin: 0 0 0.85rem;
	padding-bottom: 0.35rem;
	font-size: 1.25rem;
	font-weight: 700;
	color: var(--gh-sitemap-accent);
	border-bottom: 1px solid var(--gh-sitemap-border-color);
}

/* h4 — nested subgroup within a group */
.gh-sitemap__subgroup {
	margin-top: var(--gh-sitemap-gap-subgroup);
}

.gh-sitemap__subgroup:first-child {
	margin-top: 0;
}

.gh-sitemap__subgroup-title {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.5rem;
	margin: 0 0 0.6rem;
	font-size: 1rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: inherit;
	opacity: 0.85;
}

/* Item count — de-emphasized, appears next to group/subgroup titles */
.gh-sitemap__count {
	font-size: 0.8rem;
	font-weight: 400;
	text-transform: none;
	letter-spacing: normal;
	color: var(--gh-sitemap-text-muted);
}

/* --------------------------------------------------------------------------
   6. Lists, items, links, PDF badge, filename handle
   -------------------------------------------------------------------------- */
.gh-sitemap__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

/* A PDF item is NOT a single link: it can contain a .gh-sitemap__pdf-link,
   a .gh-sitemap__file filename span, AND an optional .gh-sitemap__link back
   to the referencing post, all side by side. Plain "Pages" style items
   contain only a single .gh-sitemap__link. The item itself is therefore the
   flex/layout container — anchors stay inline-level so several can share a
   row — and the row-level padding/hover affordance lives on the item, not
   on the anchors. */
.gh-sitemap__item {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.15rem 0.5rem;
	padding: 0.3rem 0.5rem;
	margin: 0 -0.5rem;
	border-radius: var(--gh-sitemap-radius);
	transition: background-color var(--gh-sitemap-transition);
	break-inside: avoid;
	-webkit-column-break-inside: avoid;
	page-break-inside: avoid;
}

.gh-sitemap__item:hover,
.gh-sitemap__item:focus-within {
	background: var(--gh-sitemap-bg-muted);
}

/* Anchors are inline-level with their own (small) padding so click targets
   stay generous without forcing a block layout — that would stack multiple
   anchors in the same item instead of letting them share a row. */
.gh-sitemap__link,
.gh-sitemap__pdf-link {
	display: inline-flex;
	align-items: center;
	padding: 0.15rem 0.3rem;
	color: inherit;
	text-decoration: none;
	border-radius: var(--gh-sitemap-radius);
	transition: color var(--gh-sitemap-transition);
}

.gh-sitemap__link:hover,
.gh-sitemap__pdf-link:hover {
	color: var(--gh-sitemap-accent);
	text-decoration: underline;
}

.gh-sitemap__link:focus-visible,
.gh-sitemap__pdf-link:focus-visible {
	outline: 2px solid var(--gh-sitemap-accent);
	outline-offset: 2px;
}

/* PDF affordance — small CSS-only badge, no icon font/external asset */
.gh-sitemap__pdf-link::before {
	content: "PDF";
	display: inline-block;
	flex-shrink: 0;
	margin-right: 0.5em;
	padding: 0.05em 0.4em;
	font-size: 0.68rem;
	font-weight: 700;
	font-family: var(--gh-sitemap-mono-font);
	letter-spacing: 0.03em;
	color: var(--gh-sitemap-pdf-badge-color);
	background: var(--gh-sitemap-pdf-badge-bg);
	border: 1px solid var(--gh-sitemap-pdf-badge-color);
	border-radius: 3px;
	vertical-align: middle;
}

/* Muted, monospace filename handle shown next to a PDF's human-readable
   label — this is the secondary string sales actually scan for, so it
   needs to stay legible, not purely decorative. It's a flex item alongside
   the link(s) in .gh-sitemap__item: flex-basis/grow lets it fill the rest
   of the row when there's space, min-width: 0 lets it actually shrink
   instead of forcing the row wider, and overflow-wrap keeps long filenames
   (e.g. "toiletseatboxstyle.pdf") from overflowing the column. */
.gh-sitemap__file {
	flex: 1 1 auto;
	min-width: 0;
	overflow-wrap: anywhere;
	word-break: break-word;
	font-family: var(--gh-sitemap-mono-font);
	font-size: 0.85em;
	color: var(--gh-sitemap-text-muted);
}

/* --------------------------------------------------------------------------
   7. Filter visibility toggle
   -------------------------------------------------------------------------- */
.gh-sitemap .is-hidden {
	display: none !important;
}

/* --------------------------------------------------------------------------
   8. Multi-column responsive layout — long flat PDF lists shouldn't become
      an endless single-column scroll.
   -------------------------------------------------------------------------- */
.gh-sitemap__list {
	columns: 1;
	column-gap: 2rem;
}

@media (min-width: 600px) {
	.gh-sitemap__list {
		columns: 2 var(--gh-sitemap-column-width);
	}
}

@media (min-width: 900px) {
	.gh-sitemap__list {
		columns: 3 var(--gh-sitemap-column-width);
	}
}

@media (min-width: 1200px) {
	.gh-sitemap__list {
		columns: 4 var(--gh-sitemap-column-width);
	}
}

/* --------------------------------------------------------------------------
   9. Reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
	.gh-sitemap * {
		transition: none !important;
	}
}

/* --------------------------------------------------------------------------
   10. Print — sales print this for offline reference
   -------------------------------------------------------------------------- */
@media print {
	.gh-sitemap__filter {
		display: none;
	}

	.gh-sitemap__list {
		columns: 1;
	}

	.gh-sitemap__link,
	.gh-sitemap__pdf-link {
		color: #000;
		margin: 0;
		padding: 0.15rem 0;
	}

	.gh-sitemap__link:after,
	.gh-sitemap__pdf-link:after {
		content: " (" attr(href) ")";
		font-size: 0.75em;
		color: #333;
		word-break: break-all;
	}

	.gh-sitemap__pdf-link::before {
		border-color: #000;
		color: #000;
		background: transparent;
	}

	.gh-sitemap__section {
		break-inside: avoid;
	}
}

/* --------------------------------------------------------------------------
   11. [gh_sitemap_v2]-only polish — scoped under .gh-sitemap--v2 so none of
       this touches the existing [gh_sitemap] output. Adds: a compact h5
       (the "Model Specifications" model-group level, one level deeper than
       [gh_sitemap] ever nests), and a little extra left indentation per
       nesting level since v2 goes one level deeper in Documents than v1 does.
       Everything else (filter, items, links, columns, print) is inherited
       unchanged from the rules above.
   -------------------------------------------------------------------------- */

/* Tighter rhythm than v1: the --gh-sitemap-gap-section custom property is
   set on .gh-sitemap and read by .gh-sitemap__section (shared, unscoped,
   section 1/5 above) — re-declaring it here on .gh-sitemap--v2 overrides the
   inherited value only inside the v2 tree (same element carries both
   classes), so v1's 3.5rem gap is untouched. */
.gh-sitemap--v2 {
	--gh-sitemap-gap-section: 1.75rem;
}

.gh-sitemap--v2 .gh-sitemap__subgroup {
	padding-left: 0.85rem;
	border-left: 2px solid var(--gh-sitemap-border-color);
}

/* Change 1 (Products): keeps a model-group's posts (base model + variants,
   e.g. "Model 16B" / "Model 16B S") contiguous within one CSS column instead
   of letting the multi-column layout (section 8 above) split them across a
   column boundary. No heading/label of its own — purely a break boundary.
   This is a real <ul> (nested inside the outer <div class="gh-sitemap__list">
   that now carries the multi-column CSS — a <div> can't be a direct child of
   <ul>, per HTML's content model), so the default browser list-item styling
   (margin, left padding, bullets) is reset here the same way the shared
   .gh-sitemap__list rule (section 6 above) does for the outer element;
   deliberately NOT given the .gh-sitemap__list class itself so it doesn't
   also pick up that rule's `columns` declaration and open a nested column
   context inside its own group. */
.gh-sitemap--v2 .gh-sitemap-v2__modelgroup-block {
	margin: 0;
	padding: 0;
	list-style: none;
	break-inside: avoid;
	-webkit-column-break-inside: avoid;
	page-break-inside: avoid;
}

/* Change 3b: tighter per-item spacing than v1 — document entries in v2 now
   always render their filename on a second line (see .gh-sitemap__file
   override below), so row padding is trimmed to keep the list compact. */
.gh-sitemap--v2 .gh-sitemap__item {
	padding: 0.18rem 0.4rem;
	margin: 0 -0.4rem;
}

/* Change 2: the filename always renders on its own line beneath the link,
   at every width — not just below 600px as in the shared base rule
   (section 6 above, still used by v1 via .gh-sitemap__file's own
   max-width:599px media query, section 11 below documents that v1 is
   unaffected). flex-basis:100% inside the flex-wrap row (the item is
   display:flex) pushes it down regardless of available width; the small
   top margin separates it from the link above now that it is never
   sharing a row with it. Safe wrapping for long/space-filled filenames is
   already provided by the shared overflow-wrap/word-break rule. */
.gh-sitemap--v2 .gh-sitemap__file {
	flex-basis: 100%;
	margin-top: 0.1rem;
}

.gh-sitemap--v2 .gh-sitemap-v2__modelgroup {
	margin-top: 0.75rem;
	padding-left: 0.85rem;
}

.gh-sitemap--v2 .gh-sitemap-v2__modelgroup:first-child {
	margin-top: 0.4rem;
}

.gh-sitemap-v2__modelgroup-title {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.5rem;
	margin: 0 0 0.4rem;
	font-size: 0.85rem;
	font-weight: 600;
	color: inherit;
	opacity: 0.7;
}

/* Unlinked "no document" marker (e.g. Arkansas, the two Worthington
   retrofits) — visually distinct from a real link, no underline affordance. */
.gh-sitemap-v2__nodoc {
	color: var(--gh-sitemap-text-muted);
	font-style: italic;
}

/* Heading label wrapper — sitemap-v2.php wraps each group/subgroup/
   model-group title's label text in <span class="gh-sitemap-v2__label">
   (v1's sitemap.php still emits a bare text node, so this class never
   appears there). Without its own flex sizing the label is a bare flex
   item with no min-width/flex basis of its own, so a long heading
   ("Slide Rail Systems – Wet Well – Auto Coupling") overflows the flex
   row instead of wrapping, orphaning the .gh-sitemap__count badge onto
   its own line. flex-shrink (not flex-grow — this is NOT .gh-sitemap__file,
   which deliberately fills remaining row width) plus min-width: 0 lets it
   compress and wrap only once the row is actually too narrow, so on a wide
   row the badge still sits snug against the label exactly as the old bare
   text node did. */
.gh-sitemap--v2 .gh-sitemap-v2__label {
	flex: 0 1 auto;
	min-width: 0;
	overflow-wrap: anywhere;
	word-break: break-word;
}

.gh-sitemap--v2 .gh-sitemap__count {
	flex-shrink: 0;
}

@media print {
	.gh-sitemap--v2 .gh-sitemap__subgroup {
		border-left: none;
	}
}
