/*
 * The collection front end.
 *
 * Layout only. Every colour is currentColor or a custom property whose fallback
 * is the theme's own value — because the entire reason to run a collection
 * inside WordPress rather than behind a hosted add-on is that it looks like the
 * museum's website, and a stylesheet with a palette in it gives that away.
 *
 * No fonts, no font sizes, no palette, no JavaScript.
 */

/* ── The wrapper ──────────────────────────────────────────────────────────── */

/*
 * Width and side padding, deferring to the theme wherever the theme has said
 * something and refusing to be unreadable where it has not.
 *
 * min() rather than a plain custom property: a theme that sets a real content
 * width gets that width, because it is the smaller value. A theme that sets
 * `100%` — which plenty do, leaving width to each block — would otherwise
 * produce a collection running the full width of a 27-inch monitor, with facet
 * labels at one edge and their counts at the other. min() reads that 100% as
 * "no opinion" and caps it.
 *
 * max() on the padding for the same reason in the other direction: the theme's
 * own root padding when it has one, and never less than 1rem, because text
 * against the window edge is the single most obvious sign that a plugin has
 * bolted its own pages onto a site.
 */
.gwc-mc-collection {
	box-sizing: border-box;
	/*
	 * Three answers in order of how much they are worth trusting: the width the
	 * museum measured off their own theme and typed into Settings; the width the
	 * theme published in theme.json; and a cap, for the themes that publish
	 * `100%` and keep their real width to themselves.
	 */
	max-width: var( --gwc-mc-collection-width, min( var( --wp--style--global--wide-size, 75rem ), 75rem ) );
	margin-inline: auto;
	padding-inline: max( var( --wp--style--root--padding-left, 0px ), 1rem );
}

/* ── Grid ─────────────────────────────────────────────────────────────────── */

.gwc-mc-grid {
	list-style: none;
	margin: 1.5rem 0;
	padding: 0;
	display: grid;

	/* auto-fill, not auto-fit: a collection with three results should show three
	   cards at their proper size, not three cards stretched across the viewport
	   like a banner. */
	grid-template-columns: repeat(auto-fill, minmax(min(14rem, 100%), 1fr));
	gap: 1.5rem;
}

.gwc-mc-card {
	margin: 0;
}

.gwc-mc-card__link {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	text-decoration: none;
	color: inherit;
	height: 100%;
}

.gwc-mc-card__media {
	display: block;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	background: rgba(0, 0, 0, 0.04);
}

.gwc-mc-card__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* A record with no photograph keeps its place in the grid rather than making a
   staircase of the row. Museums photograph what they have time to photograph. */
.gwc-mc-card__media--empty {
	border: 1px dashed currentColor;
	opacity: 0.25;
}

.gwc-mc-card__title {
	font-weight: 600;
}

.gwc-mc-card__number {
	opacity: 0.7;
	font-variant-numeric: tabular-nums;
}

/* ── Search ───────────────────────────────────────────────────────────────── */

.gwc-mc-search__form {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	align-items: flex-end;
	margin-bottom: 1rem;
}

.gwc-mc-search__form input[type="search"] {
	flex: 1 1 16rem;
}

.gwc-mc-search__label {
	flex: 1 0 100%;
}

.gwc-mc-active-filters {
	list-style: none;
	margin: 0 0 1rem;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.gwc-mc-chip {
	display: inline-flex;
	gap: 0.35rem;
	align-items: baseline;
	padding: 0.15rem 0.6rem;
	border: 1px solid currentColor;
	border-radius: 2em;
	text-decoration: none;
	color: inherit;
}

/* The × is decorative and generated, so it is never read out twice — the link
   already carries "(remove this filter)" for a screen reader. */
.gwc-mc-chip::after {
	content: "\00d7";
	opacity: 0.7;
}

.gwc-mc-chip__label {
	opacity: 0.7;
}

/* ── Facets ───────────────────────────────────────────────────────────────── */

.gwc-mc-facets {
	display: grid;

	/* auto-fill, not auto-fit, for the same reason the results grid says so: a
	   record with two facets should show two lists at their proper size, not two
	   lists stretched half a screen wide each — which puts every count so far
	   from its label that the pair stops reading as one row. */
	grid-template-columns: repeat(auto-fill, minmax(min(12rem, 100%), 1fr));
	gap: 1.5rem;
	margin-bottom: 1.5rem;
}

.gwc-mc-facet ul {
	list-style: none;
	margin: 0.25rem 0 0;
	padding: 0;
}

.gwc-mc-facet__option a {
	display: flex;
	justify-content: space-between;
	gap: 0.5rem;
	text-decoration: none;
	color: inherit;
	padding: 0.1rem 0;
}

.gwc-mc-facet__option a:hover,
.gwc-mc-facet__option a:focus {
	text-decoration: underline;
}

.gwc-mc-facet__option.is-selected > a {
	font-weight: 700;
}

.gwc-mc-facet__count {
	opacity: 0.6;
	font-variant-numeric: tabular-nums;
}

.gwc-mc-facet__more {
	opacity: 0.6;
}

/* ── Results ──────────────────────────────────────────────────────────────── */

.gwc-mc-results__count {
	opacity: 0.7;
}

.gwc-mc-sort ul,
.gwc-mc-pagination ul {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
}

.gwc-mc-sort {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	align-items: baseline;
}

.gwc-mc-sort__label {
	opacity: 0.7;
}

.gwc-mc-pagination {
	margin-top: 1.5rem;
}

.gwc-mc-pagination__current {
	font-weight: 700;
}

/* ── A record ─────────────────────────────────────────────────────────────── */

.gwc-mc-record__number {
	opacity: 0.7;
	font-variant-numeric: tabular-nums;
}

.gwc-mc-record__media,
.gwc-mc-media {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(18rem, 100%), 1fr));
	gap: 1rem;
	margin: 1.5rem 0;
}

.gwc-mc-record__image,
.gwc-mc-media__item {
	margin: 0;
}

.gwc-mc-record__image img,
.gwc-mc-media__item img {
	max-width: 100%;
	height: auto;
	display: block;
}

.gwc-mc-fields {
	margin: 1.5rem 0;
}

.gwc-mc-fields__row {
	display: grid;

	/* The label column sizes to the longest label and stops. minmax with a max
	   of max-content keeps "Dimensions" and "Place of origin" in one column
	   without a 180-field catalog pushing the values off the page. */
	grid-template-columns: minmax(8rem, max-content) 1fr;
	gap: 0.25rem 1.5rem;
	padding: 0.35rem 0;
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

@media (max-width: 40rem) {
	.gwc-mc-fields__row {
		grid-template-columns: 1fr;
	}
}

.gwc-mc-fields__label {
	font-weight: 600;
}

.gwc-mc-fields__value {
	margin: 0;
	white-space: pre-line;
}

/* "Available on request" is information, not an absence — a researcher needs to
   know there is something to ask the registrar about. Italic and dimmed says
   that without needing another sentence. */
.gwc-mc-fields__value--redacted {
	font-style: italic;
	opacity: 0.7;
}

/* ── One field, and related records ───────────────────────────────────────── */

.gwc-mc-field__label {
	font-weight: 600;
}

.gwc-mc-related {
	margin: 2rem 0;
}
