/**
 * Layout base for the Related Items "after content" zone (partial-related-items.php)
 * and for the photo gallery header and description (components/galleries.php).
 *
 * Since 2.1.8 the after-content zone is rendered as a direct child of
 * .single-wrapper, below the whole single item (content + side column). This
 * sheet only makes it span the full width of the wrapper, whatever its display
 * mode (block, flex or grid), and spaces it from the item and between blocks.
 * No decorative styling (typography, colours, headings): that stays in the theme,
 * as for mcvk-layout-tabs.css. The tabs layout follows the same zone rule.
 * Exception: the photo gallery download button, which takes the look of the
 * "Add to my calendar" button (end of this sheet).
 *
 * Layout selectors are wrapped in :where() so their specificity is zero and
 * the theme always wins, even though this sheet may be printed in the footer.
 *
 * Overridable custom properties (set them on the zone in the theme):
 *   --mcvk-related-items-after-gap  Space above the after-content zone
 *                                   (default: --mc-single-row-gap, then --mc-space-xl).
 *   --mcvk-related-items-block-gap  Space between stacked blocks
 *                                   (default: --mc-space-md).
 */

:where(.single-wrapper > .mc-related-items[data-area="after-content"]) {
	--mcvk-related-items-after-gap: var(--mc-single-row-gap, var(--mc-space-xl));
	--mcvk-related-items-block-gap: var(--mc-space-md);
	box-sizing: border-box;
	clear: both;
	width: 100%;
	flex-basis: 100%; /* Flex wrapper. */
	grid-column: 1 / -1; /* Grid wrapper. */
	margin-top: var(--mcvk-related-items-after-gap);
}

:where(.single-wrapper > .mc-related-items[data-area="after-content"] .mc-blocks__block + .mc-blocks__block) {
	margin-top: var(--mcvk-related-items-block-gap);
}

/*
 * Below-content zone (since 2.1.17): appended to the post content, inside the
 * main column, stacked blocks only. Spaced from the content and between blocks.
 *   --mcvk-related-items-below-gap  Space above the zone (default: --mc-space-lg).
 */
:where(.mc-related-items[data-area="below-content"]) {
	--mcvk-related-items-below-gap: var(--mc-space-lg);
	--mcvk-related-items-block-gap: var(--mc-space-md);
	box-sizing: border-box;
	clear: both;
	width: 100%;
	margin-top: var(--mcvk-related-items-below-gap);
}

:where(.mc-related-items[data-area="below-content"] .mc-blocks__block + .mc-blocks__block) {
	margin-top: var(--mcvk-related-items-block-gap);
}

/*
 * Photo gallery header (components/galleries.php): the gallery title and its
 * download button on one row, the button at the far right, baseline-aligned
 * with the title text.
 */
:where(.mcvk-gallery-header) {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--mc-space-2xs) var(--mc-space-sm);
}

:where(.mcvk-gallery-header > .related-items-heading) {
	flex: 1 1 auto;
	min-width: 0;
}

:where(.mcvk-gallery-header > .mcvk-gallery-download) {
	flex: 0 0 auto;
	margin-inline-start: auto;
}

/*
 * Photo gallery description (components/galleries.php): short text between
 * the gallery title row and the photos. Spacing only; typography stays in
 * the theme.
 */
:where(.mcvk-gallery__description) {
	margin-bottom: var(--mc-space-sm);
}

:where(.mcvk-gallery__description > :last-child) {
	margin-bottom: 0;
}

/*
 * No separator line under a gallery title: the theme's bottom padding and
 * border on .related-items-heading are removed; its bottom margin stays as
 * the space above the photos. One class above the theme's
 * .related-items-heading rule.
 */
.mcvk-gallery-header > .related-items-heading {
	padding-bottom: 0;
	border-bottom: 0;
}

/*
 * Download button: same size and colours as the "Add to my calendar" button
 * (.mcvk-atc defaults: --mc-button-* tokens when the theme defines them,
 * else --mc-color-2 / --mc-color-light, --mc-font-size-sm, --mc-space-2xs /
 * --mc-space-sm padding, --mc-border-radius). Scoped with an id that never
 * exists to win over Divi / theme link rules without !important.
 */
.mcvk-gallery-download:not(#mcvk-gallery-download-isolate) .mcvk-gallery-download__button {
	display: inline-flex;
	align-items: center;
	gap: var(--mc-space-3xs);
	box-sizing: border-box;
	margin: 0;
	padding: var(--mc-button-padding, var(--mc-space-2xs) var(--mc-space-sm));
	border: var(--mc-button-border, 0);
	border-radius: var(--mc-button-radius, var(--mc-border-radius));
	background-color: var(--mc-button-bg, var(--mc-color-2));
	color: var(--mc-button-color, var(--mc-color-light));
	font-family: inherit;
	font-size: var(--mc-button-font-size, var(--mc-font-size-sm));
	font-weight: var(--mc-button-font-weight, var(--mc-font-weight-bold));
	line-height: 1;
	white-space: nowrap;
	text-decoration: none;
	transition: background-color var(--mc-transition-duration, 0.3s);
}

.mcvk-gallery-download:not(#mcvk-gallery-download-isolate) .mcvk-gallery-download__button:hover,
.mcvk-gallery-download:not(#mcvk-gallery-download-isolate) .mcvk-gallery-download__button:focus-visible {
	background-color: var(--mc-button-bg-hover, color-mix(in srgb, var(--mc-color-2) 85%, var(--mc-color-dark)));
	color: var(--mc-button-color-hover, var(--mc-color-light));
}

.mcvk-gallery-download:not(#mcvk-gallery-download-isolate) .mcvk-gallery-download__button:focus-visible {
	outline: var(--mc-border-width) var(--mc-border-style) var(--mc-button-bg, var(--mc-color-2));
	outline-offset: var(--mc-space-3xs);
}

.mcvk-gallery-download:not(#mcvk-gallery-download-isolate) .mcvk-gallery-download__icon {
	color: inherit;
}

.mcvk-gallery-download:not(#mcvk-gallery-download-isolate) .mcvk-gallery-download__size {
	color: inherit;
	font-size: var(--mc-font-size-xs);
	font-weight: var(--mc-font-weight-regular, normal);
}
