/*
 * Publications shelf.
 *
 * Was a year-grouped Bootstrap accordion: nine entries behind five collapsed
 * panels, so the page opened essentially empty and finding anything took two
 * clicks. This is a bookshop shelf — every entry visible, with the cover doing
 * the work of the year heading.
 *
 * It is divided by type — Bücher, then Buchkapitel, then Fachartikel, each
 * newest first — and a filter on the title row narrows it to one of them.
 */

/* --- Filter, at the right end of the title row ---------------------------- */
.pub-filter {
	display: flex;
	align-items: center;
	gap: 10px;
	font-family: 'Open Sans', sans-serif;
	/*
	 * Clear of the rule below the title row.
	 *
	 * .hr-bar pulls itself 5px up into that row (margin-top:-5px, tuned for a
	 * line of text), and a 44px control hangs lower than the title's text does,
	 * so on a baseline the rule ran through the bottom of the select at every
	 * width. Centred instead, 12px below is that 5px pull plus 7px of air, and
	 * the 4px above balances it so the select stays level with the title. The
	 * margin box then matches the 60px title line on desktop, so the rule does
	 * not move there; on a phone, where the filter wraps under the title, the
	 * same margins keep it off both the title and the rule.
	 */
	align-self: center;
	margin-block: 4px 12px;
}

.pub-filter-label {
	/* Bootstrap's reboot gives every label a bottom margin, which would lift
	   this one off the select's centre line. */
	margin: 0;
	font-size: 14px;
	font-weight: 600;
	letter-spacing: 0.4px;
	color: #5d5d5d;
}

.pub-filter-select {
	appearance: none;
	min-height: var(--tap);
	padding: 0 40px 0 14px;
	font-family: inherit;
	font-size: 15px;
	font-weight: 600;
	color: #1c1c1c;
	/* The chevron stands in for the native arrow that appearance:none removes.
	   Its stroke is --brand-teal-ink written out, because a data URI cannot
	   read a custom property. */
	background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23058a6e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 14px center / 12px 8px;
	/* #8c8c8c is 3.4:1 on white. WCAG 1.4.11 wants 3:1 of a control's edge;
	   the light greys used for rules elsewhere on the page leave the box
	   barely there. */
	border: 1px solid #8c8c8c;
	border-radius: 6px;
	cursor: pointer;
	transition: border-color 0.2s ease;
}

.pub-filter-select:hover {
	border-color: var(--brand-teal-ink);
}

.pub-filter-select:focus-visible {
	outline: 3px solid var(--brand-teal-ink);
	outline-offset: 2px;
}

/* --- Groups -------------------------------------------------------------- */
.pub-group + .pub-group {
	margin-top: clamp(36px, 4vw, 56px);
}

/* Filtered, the group on screen is usually preceded by hidden ones, and the
   sibling rule above would still hold its gap open over the first row. */
.pub-library--filtered .pub-group {
	margin-top: 0;
}

.pub-group-title {
	margin: 0 0 clamp(14px, 1.4vw, 20px);
	font-family: 'DIN Alternate Bold';
	font-size: clamp(22px, 1.8vw, 26px);
	/* The face is bold in itself and declared at normal weight; Bootstrap's
	   500 on h2 would otherwise be a request it cannot meet. */
	font-weight: normal;
	line-height: 1.2;
	color: #1c1c1c;
}

/* The select already says which type is on screen, and with only one group
   showing there is nothing for a heading to separate. */
.pub-library--filtered .pub-group-title {
	display: none;
}

.pub-shelf {
	/* Shared by .pub-cover and the click overlay stretched over it. */
	--pub-cover-ratio: 0.7;

	display: grid;
	/* 210px lands on five columns at 1440 rather than six: at six, the titles
	   here (several of which run to a dozen words) wrapped to four lines. */
	grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
	gap: clamp(24px, 3vw, 40px) clamp(18px, 2.4vw, 32px);
	padding: 8px 0 4px;
	font-family: 'Open Sans', sans-serif;
}

.pub-card {
	display: flex;
	flex-direction: column;
	min-width: 0;
	/* The containing block for the stretched title link — see .pub-title-link. */
	position: relative;
}

/* --- Cover --------------------------------------------------------------- */
.pub-cover {
	position: relative;
	/* Fixed ratio so scans of different proportions still line up on the
	   shelf. Real covers hover around 0.70; this is the common denominator.
	   Held in a variable because .pub-title-link::after has to reproduce this
	   exact height to overlay the cover — see there. */
	aspect-ratio: var(--pub-cover-ratio);
	background-color: #f2f2f0;
	border-radius: 3px;
	overflow: hidden;
	box-shadow:
		0 2px 4px rgba(0, 0, 0, 0.10),
		0 8px 18px rgba(0, 0, 0, 0.16);
	transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s ease;
}

/*
 * The lift is scoped to cards that actually go somewhere.
 *
 * It used to fire on every card, which made a shelf of nine unclickable covers
 * animate under the cursor as though eight of them were buttons. Only a card
 * with a publisher link responds, so the motion means what it looks like it
 * means.
 *
 * The keyboard half is :has(:focus-visible), not :focus-within. :focus-within
 * also matches a mouse click — and these links open in a new tab, so clicking a
 * cover and coming back left the card focused and stuck in the raised position
 * until you clicked the page background. :focus-visible is set by keyboard
 * focus and not by a click, which is exactly the distinction wanted here, and
 * it matches the condition the focus ring below already uses.
 */
.pub-card--linked:hover .pub-cover,
.pub-card--linked:has(.pub-title-link:focus-visible) .pub-cover {
	transform: translateY(-4px);
	box-shadow:
		0 4px 8px rgba(0, 0, 0, 0.12),
		0 14px 28px rgba(0, 0, 0, 0.22);
}

.pub-cover-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* The spine highlight that makes a flat scan read as a physical book. */
.pub-cover::after {
	content: '';
	position: absolute;
	inset: 0 auto 0 0;
	width: 9px;
	background: linear-gradient(
		to right,
		rgba(0, 0, 0, 0.22) 0%,
		rgba(0, 0, 0, 0.05) 45%,
		rgba(255, 255, 255, 0.18) 75%,
		rgba(255, 255, 255, 0) 100%
	);
	pointer-events: none;
}

/* --- Sheet of paper, for articles and the dissertation ------------------- */
.pub-sheet {
	position: absolute;
	inset: 12% 14%;
	background-color: #fff;
	border: 1px solid #dcdcd6;
	border-radius: 2px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 11%;
	padding: 14% 16%;
}

/* Ruled lines. The short last one reads as the end of a paragraph rather than
   a truncated block. */
.pub-sheet-rule {
	display: block;
	height: 2px;
	border-radius: 1px;
	background-color: #d2d2ca;
}

.pub-sheet-rule:first-child {
	background-color: var(--brand-teal);
	height: 3px;
	width: 62%;
}

.pub-sheet-rule:last-child {
	width: 46%;
}

/* --- Kind ribbon --------------------------------------------------------- */
.pub-kind {
	position: absolute;
	left: 0;
	bottom: 12px;
	padding: 4px 10px 4px 13px;
	background-color: rgba(255, 255, 255, 0.96);
	color: #333;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 1.1px;
	text-transform: uppercase;
	border-radius: 0 3px 3px 0;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

/* A chapter's ribbon is the load-bearing one: it is what stops the host
   volume's cover being read as a book by the institute. */
.pub-card--chapter .pub-kind {
	background-color: var(--brand-yellow);
	color: #40391a;
}

/* --- Metadata ------------------------------------------------------------ */
.pub-meta {
	padding-top: 12px;
}

.pub-title {
	margin: 0;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.32;
	color: #1c1c1c;
	text-wrap: pretty;
}

/*
 * The publisher link.
 *
 * The <a> wraps only the title, so screen readers announce a link named after
 * the book rather than one long string of cover-alt + title + subtitle +
 * imprint. The ::after then stretches that same link across the cover, so the
 * cover is the large click target the hover lift has always implied.
 *
 * Deliberately the cover and not the whole card: an overlay swallows text
 * selection underneath it, and this is a bibliography — someone copying a
 * citation out of the imprint line is a use worth protecting. Title and cover
 * are clickable; the metadata below stays selectable.
 */
.pub-title-link {
	color: inherit;
	text-decoration: none;
}

.pub-title-link::after {
	content: '';
	position: absolute;
	/* Anchored to the card's top edge and full width, so this box is the cover:
	   both are as wide as the card, and sharing --pub-cover-ratio makes them
	   exactly as tall. Changing the ratio moves them together. */
	top: 0;
	left: 0;
	right: 0;
	aspect-ratio: var(--pub-cover-ratio);
	/* Above .pub-kind, which is absolutely positioned inside the cover and would
	   otherwise swallow clicks in the bottom-left corner. */
	z-index: 1;
}

.pub-card--linked:hover .pub-title-link,
.pub-title-link:focus-visible {
	color: var(--brand-teal-ink);
	text-decoration: underline;
	text-underline-offset: 2px;
}

/*
 * Focus lands on the title text, but the target is the whole card — so the ring
 * goes round the card. Without this the outline would trace a two-line heading
 * in the middle of a card that is entirely clickable, which reads as the wrong
 * thing being focused.
 */
.pub-title-link:focus-visible {
	outline: none;
}

.pub-card:has(.pub-title-link:focus-visible) {
	outline: 3px solid var(--brand-teal-ink);
	outline-offset: 6px;
	border-radius: 4px;
}

.pub-subtitle {
	margin: 3px 0 0;
	font-size: 13px;
	line-height: 1.4;
	color: #4a4a4a;
	text-wrap: pretty;
}

.pub-author {
	margin: 6px 0 0;
	font-size: 13px;
	font-weight: 600;
	color: var(--brand-teal-ink);
}

.pub-host {
	margin: 6px 0 0;
	font-size: 13px;
	line-height: 1.4;
	color: #3d3d3d;
}

.pub-host cite {
	font-style: italic;
}

.pub-editors {
	margin: 2px 0 0;
	font-size: 12px;
	line-height: 1.4;
	color: #6a6a6a;
}

.pub-imprint {
	margin: 7px 0 0;
	font-size: 12px;
	line-height: 1.4;
	color: #6a6a6a;
}

.pub-note {
	margin: clamp(28px, 3vw, 40px) 0 0;
	padding-top: 16px;
	border-top: 1px solid #e2e2e2;
	font-family: 'Open Sans', sans-serif;
	font-size: 14px;
	font-style: italic;
	color: #5d5d5d;
}

@media (prefers-reduced-motion: reduce) {
	.pub-cover {
		transition: none;
	}
	.pub-card:hover .pub-cover {
		transform: none;
	}
}
