/* ===================================================================
 * Download Grid â€” child theme Elementor widget
 * ===================================================================
 *
 * Layout:
 *   .he-dg                    Outer wrapper (CSS vars live here).
 *   .he-dg__bar               Top bar: filter + search.
 *   .he-dg__grid              Card grid; column count is set inline by
 *                             the widget controls (Elementor selectors).
 *   .he-dg__pagi              Numbered pagination.
 *   .he-dg__lightbox          Inline image preview.
 *
 * The card visual reproduces the brief: a tinted thumbnail with the file
 * type label (PDF / JPG / PNG / DOC ...) overlaid in oversized white
 * letters, and the post title underneath.
 *
 * Specificity strategy
 * --------------------
 * Every internal selector is qualified with the `.he-dg` ancestor (and,
 * for form elements, with the tag), so we land at (0,2,0) or (0,2,1)
 * and beat parent-theme selectors like `input[type="search"]` (0,1,1)
 * without resorting to `!important`.
 * =================================================================== */

 .he-dg {
	--he-dg-primary: #1565d8;
	--he-dg-primary-soft: #e8f0fe;
	--he-dg-card-bg: #f4f5f7;
	--he-dg-border: #e7e9ed;
	--he-dg-text: #222;
	--he-dg-muted: #8a8f98;
	--he-dg-radius: 6px;
	--he-dg-radius-sm: 4px;

	box-sizing: border-box;
	color: var(--he-dg-text);
	font-family: inherit;
	position: relative;
}
.he-dg.he-dg *,
.he-dg.he-dg *::before,
.he-dg.he-dg *::after {
	box-sizing: border-box;
}

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

.he-dg .he-dg__bar {
	display: flex;
	gap: 16px;
	align-items: stretch;
	margin-bottom: 24px;
}
.he-dg .he-dg-filter,
.he-dg .he-dg-search {
	flex: 1 1 0;
	min-width: 0;
	position: relative;
}

/* --- Filter dropdown ---------------------------------------------- */

.he-dg button.he-dg-filter__toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	min-height: 56px;
	margin: 0;
	padding: 12px 18px;
	background: #fff;
	border: 1px solid var(--he-dg-border);
	border-radius: var(--he-dg-radius);
	color: var(--he-dg-text);
	font: inherit;
	font-size: 15px;
	line-height: 1.3;
	text-align: left;
	cursor: pointer;
	box-shadow: none;
	transition: border-color 0.18s ease, box-shadow 0.18s ease;
	-webkit-appearance: none;
	appearance: none;
	border-radius: 0;
}
.he-dg button.he-dg-filter__toggle:hover {
	border-color: #cfd2d8;
	background: #fff;
}
.he-dg button.he-dg-filter__toggle:focus,
.he-dg button.he-dg-filter__toggle:focus-visible {
	outline: none;
	border-color: var(--he-dg-primary);
	box-shadow: 0 0 0 3px rgba(21, 101, 216, 0.18);
}

.he-dg .he-dg-filter__current {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	text-align: left;
}
.he-dg .he-dg-filter__chev {
	flex: 0 0 auto;
	width: 10px;
	height: 10px;
	margin-left: 12px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg) translate(-2px, -2px);
	transition: transform 0.18s ease;
	color: var(--he-dg-muted);
}
.he-dg .he-dg-filter[data-open='1'] .he-dg-filter__chev {
	transform: rotate(225deg) translate(-2px, -2px);
}

.he-dg ul.he-dg-filter__list {
	position: absolute;
	left: 0;
	right: 0;
	top: calc(100% + 6px);
	margin: 0;
	padding: 8px 0;
	list-style: none;
	background: #fff;
	border: 1px solid var(--he-dg-border);
	border-radius: var(--he-dg-radius);
	box-shadow: 0 12px 32px rgba(20, 30, 60, 0.12);
	max-height: 360px;
	overflow-y: auto;
	z-index: 50;

	opacity: 0;
	visibility: hidden;
	transform: translateY(-4px);
	pointer-events: none;
	transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}
.he-dg .he-dg-filter[data-open='1'] ul.he-dg-filter__list {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
	pointer-events: auto;
}

/* Filter option — baseline (used by both flat-row and pill variants).
 *
 * The visible/clickable target is the inner `<a class="he-dg-filter__opt-link">`,
 * so the whole padded box becomes a real link (good for middle-click,
 * "Open in new tab", keyboard tabbing, etc.). The `<li>` itself is just a
 * state/background container.
 */
.he-dg li.he-dg-filter__opt {
	display: block;
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: 14px;
	color: var(--he-dg-text);
	background: transparent;
	border: none;
	transition: background 0.15s ease, color 0.15s ease;
}
.he-dg li.he-dg-filter__opt::before,
.he-dg li.he-dg-filter__opt::marker {
	content: none;
	display: none;
}
.he-dg a.he-dg-filter__opt-link,
.he-dg a.he-dg-filter__opt-link:link,
.he-dg a.he-dg-filter__opt-link:visited {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 12px 18px;
	color: inherit;
	text-decoration: none;
	cursor: pointer;
	box-shadow: none;
	transition: color 0.15s ease;
}
.he-dg a.he-dg-filter__opt-link:hover,
.he-dg a.he-dg-filter__opt-link:focus,
.he-dg a.he-dg-filter__opt-link:focus-visible {
	color: inherit;
	text-decoration: none;
	outline: none;
}
.he-dg .he-dg-filter__opt-label {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Flat top-level row variant: full width, hover highlight. */
.he-dg li.he-dg-filter__opt--root {
	font-size: 15px;
}
.he-dg li.he-dg-filter__opt--root a.he-dg-filter__opt-link {
	padding: 14px 18px;
}
.he-dg li.he-dg-filter__opt--root:hover {
	background: #f5f7fb;
}
.he-dg li.he-dg-filter__opt--root.is-active {
	color: var(--he-dg-primary);
	background: var(--he-dg-primary-soft);
}
.he-dg li.he-dg-filter__opt--root.is-active a.he-dg-filter__opt-link {
	color: var(--he-dg-primary);
}

/* Group: wrapper for collapsible parent + children grid. */
.he-dg li.he-dg-filter__group {
	display: block;
	margin: 0;
	padding: 0;
	list-style: none;
	cursor: default;
	background: transparent;
}

/* Group header: clickable parent label + +/− glyph. */
.he-dg button.he-dg-filter__group-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	margin: 0;
	padding: 14px 18px;
	background: transparent;
	border: none;
	border-radius: 0;
	color: var(--he-dg-text);
	font: inherit;
	font-size: 15px;
	font-weight: 500;
	text-align: left;
	line-height: 1.3;
	cursor: pointer;
	box-shadow: none;
	-webkit-appearance: none;
	appearance: none;
	transition: background 0.15s ease;
}
.he-dg button.he-dg-filter__group-header:hover {
	background: #f5f7fb;
}
.he-dg button.he-dg-filter__group-header:focus,
.he-dg button.he-dg-filter__group-header:focus-visible {
	outline: none;
	background: #f5f7fb;
}

.he-dg .he-dg-filter__group-name {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* +/− glyph (vertical bar rotates+fades to become −). */
.he-dg .he-dg-filter__group-icon {
	position: relative;
	display: inline-block;
	flex: 0 0 auto;
	width: 16px;
	height: 16px;
	margin-left: 12px;
	color: var(--he-dg-muted);
}
.he-dg .he-dg-filter__plus-h,
.he-dg .he-dg-filter__plus-v {
	position: absolute;
	background: currentColor;
	border-radius: 1px;
	transition: transform 0.2s ease, opacity 0.2s ease;
}
.he-dg .he-dg-filter__plus-h {
	left: 0;
	right: 0;
	top: 50%;
	height: 2px;
	transform: translateY(-50%);
}
.he-dg .he-dg-filter__plus-v {
	top: 0;
	bottom: 0;
	left: 50%;
	width: 2px;
	transform: translateX(-50%);
}
.he-dg li.he-dg-filter__group[data-open='1'] .he-dg-filter__plus-v {
	transform: translateX(-50%) rotate(90deg);
	opacity: 0;
}

/* Children panel (grey background card containing the pill grid). */
.he-dg .he-dg-filter__group-children {
	margin: 0 12px 8px;
	padding: 12px;
	background: #f3f5f7;
	border-radius: var(--he-dg-radius);
}
.he-dg .he-dg-filter__group-children[hidden] {
	display: none;
}
.he-dg ul.he-dg-filter__group-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Pill option — small grey button-like cell inside the grid. */
.he-dg li.he-dg-filter__opt--pill {
	display: flex;
	align-items: stretch;
	justify-content: stretch;
	padding: 0;
	background: #e9ecef;
	border-radius: 4px;
	font-size: 13.5px;
	text-align: center;
	color: var(--he-dg-text);
	transition: background 0.15s ease, color 0.15s ease;
	overflow: hidden;
}
.he-dg li.he-dg-filter__opt--pill a.he-dg-filter__opt-link {
	width: 100%;
	padding: 11px 12px;
	justify-content: center;
}
.he-dg li.he-dg-filter__opt--pill:hover {
	background: #dde1e6;
}
.he-dg li.he-dg-filter__opt--pill.is-active {
	background: var(--he-dg-primary);
	color: #fff;
}
.he-dg li.he-dg-filter__opt--pill.is-active a.he-dg-filter__opt-link {
	color: #fff;
}
.he-dg li.he-dg-filter__opt--pill .he-dg-filter__opt-label {
	flex: 0 1 auto;
	text-align: center;
}

/* Responsive: at narrow widths drop to 2 then 1 column. */
@media (max-width: 720px) {
	.he-dg ul.he-dg-filter__group-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}
@media (max-width: 480px) {
	.he-dg ul.he-dg-filter__group-grid {
		grid-template-columns: 1fr;
	}
}

/* --- Search ------------------------------------------------------- */

.he-dg .he-dg-search,
.he-dg form.he-dg-search {
	display: flex;
	align-items: center;
	margin: 0;
	padding: 0;
}
.he-dg input.he-dg-search__input,
.he-dg input[type='search'].he-dg-search__input,
.he-dg input[type='text'].he-dg-search__input {
	display: block;
	width: 100%;
	min-height: 56px;
	margin: 0;
	padding: 12px 48px 12px 18px;
	background: #fff;
	border: 1px solid var(--he-dg-border);
	border-radius: var(--he-dg-radius);
	color: var(--he-dg-text);
	font: inherit;
	font-size: 15px;
	line-height: 1.3;
	box-shadow: none;
	transition: border-color 0.18s ease, box-shadow 0.18s ease;
	-webkit-appearance: none;
	appearance: none;
	border-radius: 0;
}
.he-dg input.he-dg-search__input:focus,
.he-dg input[type='search'].he-dg-search__input:focus,
.he-dg input[type='text'].he-dg-search__input:focus {
	outline: none;
	border-color: var(--he-dg-primary);
	box-shadow: 0 0 0 3px rgba(21, 101, 216, 0.18);
}
/* Strip the WebKit/Edge default search-cancel + decoration buttons so
 * the icon we render stays the only affordance. */
.he-dg input.he-dg-search__input::-webkit-search-decoration,
.he-dg input.he-dg-search__input::-webkit-search-cancel-button,
.he-dg input.he-dg-search__input::-webkit-search-results-button,
.he-dg input.he-dg-search__input::-webkit-search-results-decoration {
	-webkit-appearance: none;
	appearance: none;
	display: none;
}

.he-dg .he-dg-search__ico,
.he-dg button.he-dg-search__ico {
	position: absolute;
	right: 8px;
	top: 50%;
	transform: translateY(-50%);
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: none;
	border-radius: 0;
	color: var(--he-dg-muted);
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: color 0.15s ease;
}
.he-dg button.he-dg-search__ico:hover,
.he-dg button.he-dg-search__ico:focus {
	color: var(--he-dg-primary);
	outline: none;
}

/* --- Sectioned archives (ACF `section_label`) --------------------- */

.he-dg .he-dg__sections {
	display: flex;
	flex-direction: column;
	gap: 40px;
}
.he-dg .he-dg__section {
	margin: 0;
	padding: 0;
}
.he-dg .he-dg__section-head {
	display: flex;
	align-items: center;
	gap: 16px;
	margin: 0 0 20px;
	padding: 0;
}
.he-dg .he-dg__section-line {
	flex: 1 1 auto;
	height: 1px;
	background: var(--he-dg-border);
	min-width: 24px;
}
.he-dg h2.he-dg__section-label {
	margin: 0;
	padding: 0;
	flex: 0 0 auto;
	font-size: clamp(18px, 2.4vw, 22px);
	font-weight: 600;
	letter-spacing: 0.02em;
	color: var(--he-dg-text);
	text-align: center;
	line-height: 1.25;
}
.he-dg .he-dg__section .he-dg__pagi-wrap {
	margin-top: 28px;
}

/* --- Grid --------------------------------------------------------- */

.he-dg .he-dg__grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 16px;
	min-height: 100px;
	position: relative;
}
.he-dg .he-dg__empty {
	grid-column: 1 / -1;
	padding: 60px 20px;
	text-align: center;
	color: var(--he-dg-muted);
	font-size: 15px;
}

/* --- Card --------------------------------------------------------- */

.he-dg a.he-dg__card,
.he-dg a.he-dg__card:link,
.he-dg a.he-dg__card:visited {
	display: block;
	text-decoration: none;
	color: inherit;
	border-radius: 0;
	overflow: hidden;
	background: #fff;
	box-shadow: none;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.he-dg a.he-dg__card:hover,
.he-dg a.he-dg__card:focus-visible {
	transform: translateY(-2px);
	box-shadow: 0 12px 24px rgba(20, 30, 60, 0.08);
	outline: none;
	color: inherit;
	text-decoration: none;
}

/* Square thumbnail. Cards use <span> for inner elements, so we force
 * `display: block` here â€” otherwise `width:100%` and `padding-bottom:100%`
 * won't apply (inline boxes can't take percentage height/padding).
 */
.he-dg .he-dg__thumb {
	display: block;
	position: relative;
	width: 100%;
	padding-bottom: 100%;
	background-color: var(--he-dg-tint-bg, var(--he-dg-card-bg));
	background-position: center;
	background-size: cover;
	background-repeat: no-repeat;
	overflow: hidden;
}

/* Colored translucent veil over the featured image, so the file-type
 * badge stays legible on any background and each bucket gets its own
 * recognizable hue (matches the brief: PDF=lavender, JPG=tan,
 * PNG=mint, DOC=lilac).
 */
.he-dg .he-dg__thumb::before {
	content: '';
	position: absolute;
	inset: 0;
	background: var(--he-dg-tint, rgba(216, 210, 255, 0.78));
	z-index: 1;
}

/* Per-bucket / per-extension tint colors. The bucket rule is the
 * baseline; specific extensions override it for finer hues.
 */
.he-dg a.he-dg__card--pdf      { --he-dg-tint: rgba(199, 192, 240, 0.80); --he-dg-tint-bg: #d8d2ff; }
.he-dg a.he-dg__card--image    { --he-dg-tint: rgba(229, 213, 175, 0.78); --he-dg-tint-bg: #efe4cf; }
.he-dg a.he-dg__card--doc      { --he-dg-tint: rgba(190, 192, 226, 0.80); --he-dg-tint-bg: #c9cbe6; }
.he-dg a.he-dg__card--archive  { --he-dg-tint: rgba(173, 222, 192, 0.78); --he-dg-tint-bg: #cdebd6; }
.he-dg a.he-dg__card--file     { --he-dg-tint: rgba(206, 211, 220, 0.80); --he-dg-tint-bg: #e2e6ec; }

.he-dg a.he-dg__card[data-ext='png']  { --he-dg-tint: rgba(150, 220, 192, 0.78); --he-dg-tint-bg: #b9e9d4; }
.he-dg a.he-dg__card[data-ext='gif']  { --he-dg-tint: rgba(244, 200, 165, 0.78); --he-dg-tint-bg: #f6d4b3; }
.he-dg a.he-dg__card[data-ext='webp'] { --he-dg-tint: rgba(176, 218, 240, 0.78); --he-dg-tint-bg: #c2e3f3; }

.he-dg .he-dg__type {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	font-weight: 900;
	font-size: clamp(38px, 6vw, 84px);
	letter-spacing: 0.02em;
	color: #ffffff;
	text-shadow: 0 2px 8px rgba(20, 30, 60, 0.18);
	pointer-events: none;
	z-index: 2;
	line-height: 1;
}

.he-dg .he-dg__title {
	display: block;
	margin: 0;
	padding: 20px;
	font-size: 15px;
	line-height: 1.4;
	color: inherit;
	background: #fff;
	border-top: 1px solid var(--he-dg-border);
	overflow: hidden;
}

/* --- Pagination --------------------------------------------------- */

.he-dg .he-dg__pagi-wrap {
	margin-top: 28px;
}
.he-dg nav.he-dg__pagi {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
}
/* Pagination "buttons" are now real `<a>` links (or `<span>` placeholders
 * for the current/disabled slots). The selectors are intentionally
 * tag-agnostic so both render identically. */
.he-dg .he-dg__pagi-btn,
.he-dg a.he-dg__pagi-btn,
.he-dg a.he-dg__pagi-btn:link,
.he-dg a.he-dg__pagi-btn:visited,
.he-dg span.he-dg__pagi-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 36px;
	height: 36px;
	margin: 0;
	padding: 0 10px;
	background: transparent;
	border: 1px solid transparent;
	border-radius: var(--he-dg-radius-sm);
	color: var(--he-dg-text);
	font: inherit;
	font-size: 14px;
	line-height: 1;
	text-decoration: none;
	box-shadow: none;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.he-dg a.he-dg__pagi-btn:hover,
.he-dg a.he-dg__pagi-btn:focus,
.he-dg a.he-dg__pagi-btn:focus-visible {
	background: #f0f2f6;
	color: var(--he-dg-text);
	text-decoration: none;
	outline: none;
}
.he-dg .he-dg__pagi-btn.is-disabled,
.he-dg span.he-dg__pagi-btn.is-disabled {
	color: var(--he-dg-muted);
	cursor: not-allowed;
	opacity: 0.55;
	background: transparent;
}
.he-dg .he-dg__pagi-num.is-current,
.he-dg span.he-dg__pagi-num.is-current {
	background: var(--he-dg-primary);
	color: #fff;
	cursor: default;
}
.he-dg .he-dg__pagi-prev,
.he-dg .he-dg__pagi-next {
	font-size: 18px;
	color: var(--he-dg-muted);
}
.he-dg a.he-dg__pagi-prev:hover,
.he-dg a.he-dg__pagi-next:hover {
	color: var(--he-dg-text);
}
.he-dg .he-dg__pagi-gap {
	color: var(--he-dg-muted);
	padding: 0 4px;
	user-select: none;
}

/* --- Lightbox (JPG / PNG preview) --------------------------------- */

.he-dg .he-dg__lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	background: rgba(15, 18, 30, 0.86);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 32px;

	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease, visibility 0.2s;
}
.he-dg .he-dg__lightbox[hidden] {
	display: none;
}
.he-dg .he-dg__lightbox.is-open {
	opacity: 1;
	visibility: visible;
}
.he-dg .he-dg__lightbox-figure {
	margin: 0;
	max-width: min(94vw, 1200px);
	max-height: 90vh;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
}
.he-dg img.he-dg__lightbox-img {
	display: block;
	max-width: 100%;
	max-height: 80vh;
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: var(--he-dg-radius);
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
	background: #fff;
}
.he-dg .he-dg__lightbox-caption {
	color: #fff;
	font-size: 14px;
	opacity: 0.85;
	text-align: center;
	max-width: 90%;
}
.he-dg button.he-dg__lightbox-close {
	position: absolute;
	top: 16px;
	right: 20px;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	border: none;
	background: rgba(255, 255, 255, 0.1);
	color: #fff;
	border-radius: 50%;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: background 0.15s ease;
}
.he-dg button.he-dg__lightbox-close:hover {
	background: rgba(255, 255, 255, 0.22);
}

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

@media (max-width: 1024px) {
	.he-dg .he-dg__bar {
		flex-direction: column;
		gap: 12px;
	}
}
@media (max-width: 600px) {
	.he-dg .he-dg__type {
		font-size: clamp(22px, 9vw, 44px);
	}
	.he-dg .he-dg__title {
		padding: 10px;
		font-size: 13.5px;
		min-height: calc(2 * 1.4em + 24px);
	}
}
