/*
 * Single resource: the "Download" and "Open link" buttons under the content.
 * Used by templates/single-wprk_resource.html. Each button takes its link from
 * a field of the resource: wprk_file_url and wprk_external_url.
 */

/* The buttons sit under a hairline, in line with the text column. */
.wprk-single-resource {
	border-block-start: 1px solid var(--wprk-border);
	padding-block-start: var(--wp--preset--spacing--40);
}

/*
 * Two rows of buttons side by side: "Read online" (a PDF opens as a book when
 * the NetRhyme WP Flipbook plugin is active, hence the class nrfb-auto on that
 * row) and "Download" with "Open link".
 */
.wprk-single-resource {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--20);
}

.wprk-single-resource > .wp-block-buttons {
	gap: var(--wp--preset--spacing--20);
	margin-block: 0;
}

/* The cover or picture is shown whole. A tall cover is kept to a readable height. */
.wprk-article:has(.wprk-single-resource) > .wp-block-post-featured-image {
	text-align: center;
}

.wprk-article:has(.wprk-single-resource) > .wp-block-post-featured-image :where(img) {
	display: inline-block;
	height: auto;
	max-height: 36rem;
	max-width: 100%;
	width: auto;
}

/*
 * Front end only: a button whose field is empty has no href, or an empty one,
 * and is not shown. With both fields empty the whole row goes, hairline included.
 * In the editor a button never carries an href, so everything stays visible there.
 */
.wprk-single-resource:not(.block-editor-block-list__block):not(:has(.wp-block-button__link[href]:not([href=""]))) {
	display: none;
}

.wprk-single-resource .wp-block-button:not(.block-editor-block-list__block):has(> .wp-block-button__link:not([href])),
.wprk-single-resource .wp-block-button:not(.block-editor-block-list__block):has(> .wp-block-button__link[href=""]) {
	display: none;
}

/* The same for browsers that do not know :has(). */
.wprk-single-resource .wp-block-button:not(.block-editor-block-list__block) > .wp-block-button__link:not([href]),
.wprk-single-resource .wp-block-button:not(.block-editor-block-list__block) > .wp-block-button__link[href=""] {
	display: none;
}
