/**
 * [resource-hub] shortcode. Markup: inc/resource-hub.php
 * Values follow Sketch "Design v1 - Resources Rethink", Option 3.
 *
 * Expects a full-width container: the sidebar has a fixed width and the results
 * take the rest, with --rh-gutter as the page margin.
 */

.resource-hub {
	--rh-navy: #0b243b;
	--rh-green: #1f9e67;
	--rh-blue: #18439f;
	--rh-sidebar-bg: #f7f8f9;
	--rh-subscribe-bg: #def3fd;
	--rh-image-bg: #d0d1db;
	--rh-pattern-top: 205px;
	--rh-gutter: 80px;

	position: relative;
	/* Keeps the dotted background above any Elementor container background. */
	isolation: isolate;
	color: var(--rh-navy);
}

/* Dotted background, full width behind the results, at 20% and fading in over
   the first ~74px as in Sketch. */
.resource-hub::before {
	content: "";
	position: absolute;
	z-index: -1;
	top: var(--rh-pattern-top);
	right: 0;
	bottom: 0;
	left: 0;
	background: url("resource-hub-dots.png") repeat;
	opacity: 0.2;
	-webkit-mask-image: linear-gradient(to bottom, transparent, #000 74px);
	mask-image: linear-gradient(to bottom, transparent, #000 74px);
	pointer-events: none;
}

.resource-hub *,
.resource-hub *::before,
.resource-hub *::after {
	box-sizing: border-box;
}

.resource-hub button {
	font-family: inherit;
	cursor: pointer;
}

.resource-hub :focus-visible {
	outline: 2px solid var(--rh-blue);
	outline-offset: 2px;
}

.resource-hub__toggle,
.resource-hub__backdrop {
	display: none;
}

/* ---------- Layout ---------- */

.resource-hub__layout {
	display: grid;
	grid-template-columns: calc(var(--rh-gutter) + 305px) minmax(0, 1fr);
	column-gap: 22px;
}

/* ---------- Sidebar ---------- */

.resource-hub__sidebar {
	position: relative;
	padding: 32px 24px 48px var(--rh-gutter);
	background: var(--rh-sidebar-bg);
}

/* `top` is set by resource-hub.js. */
.resource-hub__sidebar-inner {
	position: sticky;
	top: 118px;
}

.resource-hub .resource-hub__sidebar-title {
	margin: 0 0 24px;
	font-size: 20px;
	font-weight: 300;
	line-height: 30px;
	color: var(--rh-navy);
}

.resource-hub__search {
	position: relative;
}

.resource-hub .resource-hub__search input {
	width: 100%;
	height: 50px;
	margin: 0;
	padding: 0 51px 0 15px;
	border: 1px solid #d0d1db;
	border-radius: 4px;
	background: #fff;
	font-family: inherit;
	font-size: 14px;
	color: var(--rh-navy);
}

.resource-hub__search input::placeholder {
	color: var(--rh-navy);
	opacity: 1;
}

.resource-hub__search svg {
	position: absolute;
	top: 50%;
	right: 17px;
	transform: translateY(-50%);
	pointer-events: none;
}

.resource-hub__group {
	margin-top: 32px;
}

.resource-hub__group-title {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding-bottom: 15px;
	border-bottom: 1px solid var(--rh-green);
	font-size: 13px;
	line-height: 18px;
	cursor: pointer;
	list-style: none;
}

.resource-hub__group-title::-webkit-details-marker {
	display: none;
}

/* Plus when collapsed, minus when open. */
.resource-hub__group-title::after {
	content: "";
	width: 12px;
	height: 12px;
	background:
		linear-gradient(currentColor, currentColor) center / 12px 1px no-repeat,
		linear-gradient(currentColor, currentColor) center / 1px 12px no-repeat;
}

.resource-hub__group[open] .resource-hub__group-title::after {
	background-size: 12px 1px, 1px 0;
}

.resource-hub__group fieldset {
	display: grid;
	gap: 16px;
	min-width: 0;
	margin: 0;
	padding: 16px 0 8px;
	border: 0;
}

.resource-hub__option {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	font-size: 14px;
	font-weight: 400;
	line-height: 19px;
	cursor: pointer;
}

.resource-hub__option input {
	appearance: none;
	-webkit-appearance: none;
	display: grid;
	place-content: center;
	flex: none;
	width: 16px;
	height: 16px;
	margin: 0;
	border: 1px solid #d0d0d0;
	border-radius: 2px;
	background: #fff;
	cursor: pointer;
}

.resource-hub__option input:checked {
	border-color: var(--rh-blue);
	background: var(--rh-blue);
}

.resource-hub__option input:checked::before {
	content: "";
	width: 9px;
	height: 5px;
	margin-top: -2px;
	border-bottom: 2px solid #fff;
	border-left: 2px solid #fff;
	transform: rotate(-45deg);
}

/* ---------- Main column ---------- */

.resource-hub__main {
	min-width: 0;
	padding: 0 var(--rh-gutter) 72px 0;
}

.resource-hub-subscribe {
	display: flex;
	align-items: center;
	gap: 32px;
	margin-bottom: 40px;
	padding: 32px;
	background: var(--rh-subscribe-bg);
}

.resource-hub-subscribe__text {
	flex: 1 1 0;
}

.resource-hub .resource-hub-subscribe__title {
	margin: 0 0 8px;
	font-size: 18px;
	font-weight: 400;
	line-height: 26px;
	letter-spacing: -0.225px;
	color: var(--rh-navy);
}

.resource-hub-subscribe__text p {
	margin: 0;
	font-size: 14px;
	font-weight: 300;
	line-height: 22px;
}

.resource-hub-subscribe__form {
	display: flex;
	flex: 0 1 429px;
	align-items: center;
	gap: 8px;
	margin: 0;
}

.resource-hub .resource-hub-subscribe__form input {
	flex: 1 1 auto;
	min-width: 0;
	height: 49px;
	margin: 0;
	padding: 0 15px;
	border: 0;
	border-radius: 4px;
	background: #fff;
	font-family: inherit;
	font-size: 14px;
	color: var(--rh-navy);
}

.resource-hub-subscribe__form input::placeholder {
	color: var(--rh-navy);
	opacity: 1;
}

.resource-hub .resource-hub-subscribe__form button {
	flex: none;
	height: 46px;
	padding: 0 23px;
	border: 1px solid var(--rh-blue);
	border-radius: 4px;
	background: var(--rh-blue);
	font-size: 14px;
	font-weight: 400;
	line-height: 14px;
	color: #fff;
}

/* ---------- Active filter chips ---------- */

.resource-hub__active {
	display: flex;
	align-items: flex-start;
	gap: 11px;
	margin-bottom: 20px;
}

.resource-hub .resource-hub__active-label {
	flex: none;
	margin: 0;
	font-size: 20px;
	font-weight: 300;
	line-height: 30px;
}

.resource-hub__chips {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	/* Centers the first row on the 30px label. */
	padding-top: 2px;
}

.resource-hub .resource-hub__chip {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	height: 26px;
	margin: 0;
	padding: 0 7px;
	border: 1px solid var(--rh-blue);
	border-radius: 2px;
	background: #fff;
	font-size: 13px;
	font-weight: 400;
	line-height: 18px;
	color: var(--rh-blue);
	white-space: nowrap;
	transition: background-color 0.2s ease, color 0.2s ease;
}

/* Focus moves to the next chip after a removal, so only keyboard focus fills it. */
.resource-hub .resource-hub__chip:focus {
	background: #fff;
	color: var(--rh-blue);
}

.resource-hub .resource-hub__chip:hover,
.resource-hub .resource-hub__chip:focus-visible {
	background: var(--rh-blue);
	color: #fff;
}

.resource-hub .resource-hub__clear-all {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	margin: 0 0 0 8px;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	font-size: 14px;
	font-weight: 400;
	line-height: 14px;
	color: var(--rh-blue);
}

.resource-hub .resource-hub__clear-all:hover,
.resource-hub .resource-hub__clear-all:focus {
	background: none;
	color: var(--rh-blue);
	text-decoration: underline;
}

/* ---------- Results grid ---------- */

.resource-hub__grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 64px 22px;
	transition: opacity 0.2s ease;
}

.resource-hub.is-loading .resource-hub__grid {
	opacity: 0.5;
}

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

.resource-hub .resource-hub-card {
	display: block;
	padding-bottom: 41px;
	border-bottom: 1px solid var(--rh-green);
	color: inherit;
	text-decoration: none;
}

.resource-hub-card__image {
	position: relative;
	overflow: hidden;
	aspect-ratio: 303 / 203;
	margin-bottom: 16px;
	background: var(--rh-image-bg);
}

/* Extra specificity to beat Elementor's `.elementor img { height: auto }`. */
.resource-hub .resource-hub-card__image img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: filter 0.4s ease;
}

/* Same hover as the existing resource grid cards: grayscale plus a gradient. */
.resource-hub-card:hover .resource-hub-card__image img,
.resource-hub-card:focus-visible .resource-hub-card__image img {
	filter: grayscale(100%);
}

.resource-hub-card__image::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(
		231deg,
		rgba(175, 233, 253, 1) 0%,
		rgba(175, 233, 253, 0.6) 50%,
		rgba(67, 197, 158, 1) 84%,
		rgba(67, 197, 158, 1) 100%
	);
	opacity: 0;
	transition: opacity 0.4s ease;
}

.resource-hub-card:hover .resource-hub-card__image::after,
.resource-hub-card:focus-visible .resource-hub-card__image::after {
	opacity: 0.5;
}

.resource-hub .resource-hub-card__type {
	margin: 0 0 12px;
	font-size: 15px;
	line-height: 15px;
}

.resource-hub .resource-hub-card__title {
	margin: 0 0 20px;
	font-size: 24px;
	font-weight: 400;
	line-height: 32px;
	letter-spacing: -0.3px;
	color: var(--rh-navy);
}

.resource-hub .resource-hub-card__date {
	margin: 0;
	font-size: 14px;
	font-weight: 300;
	line-height: 14px;
}

/* ---------- Empty state and "View more" ---------- */

.resource-hub__empty {
	padding: 64px 0;
	text-align: center;
}

.resource-hub__empty p {
	margin: 0 0 16px;
	font-size: 18px;
	color: var(--rh-navy);
}

.resource-hub__empty button {
	padding: 0;
	border: 0;
	background: none;
	font-size: 14px;
	color: var(--rh-blue);
	text-decoration: underline;
}

.resource-hub__more {
	margin-top: 64px;
	text-align: center;
}

.resource-hub .resource-hub__more button {
	padding: 15px 23px;
	border: 1px solid var(--rh-blue);
	border-radius: 4px;
	background: #fff;
	font-size: 14px;
	font-weight: 400;
	line-height: 14px;
	color: var(--rh-blue);
	transition: background-color 0.2s ease, color 0.2s ease;
}

.resource-hub .resource-hub__more button:hover {
	background: var(--rh-blue);
	color: #fff;
}

.resource-hub [hidden] {
	display: none !important;
}

/* ---------- Wide screens: four columns ---------- */

@media (min-width: 1651px) {
	.resource-hub__grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

/* ---------- Small laptops and tablets: two columns ---------- */

@media (max-width: 1200px) {
	.resource-hub-subscribe {
		flex-direction: column;
		align-items: stretch;
		gap: 24px;
	}

	.resource-hub-subscribe__form {
		flex: none;
	}

	.resource-hub__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

/* ---------- Tablet: narrower sidebar and margins ---------- */

@media (max-width: 1024px) {
	.resource-hub {
		--rh-gutter: 20px;
	}

	.resource-hub__layout {
		grid-template-columns: calc(var(--rh-gutter) + 240px) minmax(0, 1fr);
	}

	.resource-hub__sidebar {
		padding-right: 16px;
	}
}

/* ---------- Mobile: filters move into a drawer ---------- */

@media (max-width: 767px) {
	.resource-hub {
		--rh-gutter: 16px;
		--rh-pattern-top: 123px;
	}

	.resource-hub .resource-hub__toggle {
		display: flex;
		align-items: center;
		justify-content: center;
		gap: 8px;
		width: 100%;
		min-height: 61px;
		margin: 0;
		padding: 16px;
		border: 0;
		border-radius: 0;
		background: var(--rh-subscribe-bg);
		font-size: 16px;
		font-weight: 400;
		line-height: 20px;
		color: var(--rh-navy);
	}

	/* Sidebar, backdrop and results share one grid cell so the open drawer
	   overlays the results and the cell grows to whichever is taller. */
	.resource-hub__sidebar,
	.resource-hub__backdrop,
	.resource-hub__main {
		grid-area: 1 / 1;
	}

	/* Runs the full height of the results so the filters inside can stick. */
	.resource-hub__sidebar {
		display: none;
		z-index: 3;
		width: 301px;
		max-width: 85vw;
		padding: 24px var(--rh-gutter) 40px;
		box-shadow: 0 4px 12px 2px rgba(0, 0, 0, 0.12);
	}

	.resource-hub .resource-hub__sidebar-title {
		display: none;
	}

	.resource-hub .resource-hub__backdrop {
		z-index: 2;
		padding: 0;
		border: 0;
		border-radius: 0;
		background: rgba(11, 36, 59, 0.32);
	}

	.resource-hub.is-open .resource-hub__sidebar,
	.resource-hub.is-open .resource-hub__backdrop {
		display: block;
	}

	.resource-hub__main {
		padding: 32px var(--rh-gutter) 72px;
	}

	.resource-hub-subscribe {
		gap: 32px;
		margin-bottom: 32px;
		padding: 32px 32px 48px;
	}

	.resource-hub-subscribe__form {
		flex-direction: column;
		align-items: stretch;
		gap: 16px;
	}

	.resource-hub .resource-hub-subscribe__form input {
		flex: none;
	}

	/* Sits 24px under the subscribe card, which has 32px below it otherwise. */
	.resource-hub__active {
		display: block;
		margin: -8px 0 24px;
	}

	.resource-hub__chips {
		padding-top: 8px;
	}

	.resource-hub__layout,
	.resource-hub__grid {
		grid-template-columns: minmax(0, 1fr);
	}

	.resource-hub__grid {
		gap: 40px;
	}
}
