/**
 * GPSubDeanery Resources, front-end styles.
 *
 * Deliberately minimal. Typography, button design and hover states come from
 * Divi via the generic classes on the markup. The only thing Divi does not
 * give us for free is the grey/white banding, which used to be a manual
 * per-row step on the old page. That is what this file is for.
 */

.gpsd-resources {
	/* Override these from the theme or Customiser to restyle the banding.
	   #f9f9f9 is the site's own grey: it is one of the client's registered
	   Divi global colours, and the most-used band on the page this replaces.
	   That page had drifted to two different greys and a run of rows with no
	   band at all, which is precisely the manual step this removes. */
	--gpsd-band: #f9f9f9;
	--gpsd-band-alt: transparent;
	--gpsd-row-gap: 20px;
	--gpsd-row-padding: 14px 18px;

	/* Resource titles. The page this replaces sets its <h5> titles to 18px in
	   #666666 per module. Divi's generic h5 is 16px in #333, so those two
	   values are restated here as variables rather than by reusing the numbered
	   per-instance classes the spec rules out. #666666 is not an arbitrary
	   choice either: it is the client's registered Divi global colour for both
	   headings and body text. Override these to restyle. */
	--gpsd-title-size: 18px;
	--gpsd-title-color: #666;
}

.gpsd-category {
	margin-bottom: 30px;
}

/* Centred, matching the page this replaces. */
.gpsd-category__title {
	margin-bottom: 10px;
	text-align: center;
}

.gpsd-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.gpsd-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--gpsd-row-gap);
	padding: var(--gpsd-row-padding);
	background-color: var(--gpsd-band-alt);
}

/* The banding, applied automatically so nobody has to do it by hand again. */
.gpsd-row:nth-child(odd) {
	background-color: var(--gpsd-band);
}

.gpsd-row__text {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-width: 0;
}

/* Divi gives every heading `padding-bottom: 10px` and `line-height: 1em`, both
   of which fight a flex row: the padding pushes the title off centre against
   the button, and the tight line-height clips descenders on a title that
   wraps. Weight is left to Divi's own 500. */
.gpsd-row__title {
	margin: 0;
	padding: 0;
	font-size: var(--gpsd-title-size);
	color: var(--gpsd-title-color);
	line-height: 1.4;
}

.gpsd-row__description {
	margin: 4px 0 0;
	padding: 0;
	font-size: 0.85em;
	font-style: italic;
	line-height: 1.4;
	opacity: 0.85;
}

.gpsd-row__action {
	flex: 0 0 auto;
}

/* Divi's button rules assume a block-level anchor with generous margins;
   inside a flex row it needs to sit tight and not stretch. */
.gpsd-row .gpsd-button {
	display: inline-block;
	margin: 0;
	white-space: nowrap;
}

.gpsd-coming-soon {
	display: inline-block;
	font-style: italic;
	opacity: 0.7;
	white-space: nowrap;
}

@media (max-width: 640px) {
	.gpsd-row {
		flex-direction: column;
		align-items: flex-start;
		gap: 10px;
	}

	.gpsd-row__action {
		width: 100%;
	}
}

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

/* The box carries the `hidden` attribute in the HTML and the script removes
   it, so a visitor without JavaScript is never shown a field that does
   nothing. */
.gpsd-search[hidden] {
	display: none;
}

.gpsd-search {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-end;
	gap: 8px 12px;
	margin-bottom: 24px;
}

.gpsd-search__label {
	font-size: 0.9em;
	font-weight: 600;
}

.gpsd-search__input {
	flex: 0 1 22em;
	min-width: 12em;
	max-width: 100%;
	padding: 8px 12px;
	border: 1px solid rgba(0, 0, 0, 0.15);
	border-radius: 3px;
	font: inherit;
	font-size: 0.95em;
}

.gpsd-search__input:focus {
	border-color: currentColor;
	outline: 2px solid transparent;
	outline-offset: 2px;
}

.gpsd-search__count {
	flex: 0 0 100%;
	margin: 0;
	font-size: 0.85em;
	text-align: right;
	opacity: 0.75;
}

.gpsd-search__count:empty {
	display: none;
}

.gpsd-search__empty {
	padding: 20px 0;
	font-style: italic;
	opacity: 0.8;
}

.gpsd-search__empty[hidden] {
	display: none;
}

/* Filtering -------------------------------------------------------------- */

/* .gpsd-row is display:flex and .gpsd-category is a block, so both need this:
   without it the `hidden` attribute the filter sets would have no effect. */
.gpsd-row[hidden],
.gpsd-category[hidden] {
	display: none;
}

/* Banding is nth-child, which keeps counting rows the filter has hidden. When
   the script is running it stripes the visible rows itself and these take over.
   They come after the nth-child rule on purpose: same specificity, later wins. */
.gpsd-list .gpsd-row--odd {
	background-color: var(--gpsd-band);
}

.gpsd-list .gpsd-row--even {
	background-color: var(--gpsd-band-alt);
}
