/* Downloads (Figma Resources "Weaver's Digest"): cover cards in a carousel or a grid. */

.s-downloads {
	overflow-x: clip; /* the carousel runs to the edge of the window */
}

.dl__head {
	display: grid;
	gap: 16px;
	max-width: 560px;
	margin-bottom: 32px;
}

.dl__heading {
	font-size: var(--t-title);
	line-height: var(--lh-title);
}

.dl__text {
	color: var(--c-text-2);
}

.dl__body {
	position: relative;
}

.dl__track {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 16px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.dl--carousel .dl__track {
	grid-template-columns: none;
	grid-auto-flow: column;
	grid-auto-columns: 368px;
	margin-right: calc((100% - 100vw) / 2);
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	overscroll-behavior-x: contain;
	scrollbar-width: none;
}

.dl--carousel .dl__track::-webkit-scrollbar {
	display: none;
}

/* Card: cover, dark fade, label, "Download a Copy". The link covers the card. */
.dl-card {
	position: relative;
	isolation: isolate;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	align-items: flex-start;
	gap: 8px;
	aspect-ratio: 1;
	padding: 16px;
	overflow: hidden;
	background: var(--c-dark);
	color: var(--c-light);
	scroll-snap-align: start;
}

.dl-card::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background: linear-gradient(to top, rgb(0 0 0 / 0.55), rgb(0 0 0 / 0) 70%);
}

.dl-card__cover {
	position: absolute;
	inset: 0;
	z-index: -2;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.dl-card__title {
	font-size: var(--t-title);
	line-height: var(--lh-title);
}

.dl-card__link {
	display: inline-flex;
	align-items: center;
	gap: 16px;
	font-size: var(--t-button);
	font-weight: 600;
	line-height: 1;
	color: inherit;
	text-decoration: none;
	text-underline-offset: 3px;
}

.dl-card__link::after {
	content: "";
	position: absolute;
	inset: 0;
}

.dl-card__link .icon {
	width: 24px;
	height: 24px;
}

.dl-card:hover .dl-card__link > span {
	text-decoration: underline;
}

.dl-card__link:focus-visible {
	outline-color: var(--c-light);
}

/* No file yet ("Coming soon"): the card is not a link. */
.dl-card__soon {
	font-size: var(--t-button);
	font-weight: 600;
	line-height: 24px;
}

/* No cover yet: Figma's empty issue cards, a black fade up a light card (a touch darker at the
   bottom than Figma's 50% so the white text stays readable). */
.dl-card--no-cover {
	background: linear-gradient(to top, rgb(0 0 0 / 0.6), rgb(0 0 0 / 0)), var(--c-line-2);
}

.dl-card--no-cover::before {
	display: none;
}

/* Nothing to show: render.php printed nothing, so drop the section's spacing too. */
.s-downloads:empty {
	display: none;
}

/* Carousel arrows: over the cards on desktop (Figma), in a row under a progress bar on mobile. */
.dl__progress {
	display: none;
}

.dl__arrow {
	position: absolute;
	z-index: 1;
	top: 50%;
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--c-light);
	color: var(--c-text);
	box-shadow: 0 2px 8px rgb(0 0 0 / 0.12);
	translate: 0 -50%;
}

.dl__arrow--prev {
	left: 0;
}

.dl__arrow--next {
	right: 0;
}

.dl__arrow:disabled {
	visibility: hidden;
}

.dl__arrow .icon {
	width: 24px;
	height: 24px;
}

@media (max-width: 1023px) {
	.dl__track {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 767px) {
	.dl__track {
		grid-template-columns: minmax(0, 1fr);
	}

	/* One card across the content column; the next one peeks in from the edge. */
	.dl--carousel .dl__track {
		grid-auto-columns: calc(100% - var(--gutter));
		gap: 8px;
	}

	.dl-card {
		aspect-ratio: 328 / 368;
	}

	.dl__controls {
		display: flex;
		flex-wrap: wrap;
		gap: 16px 8px;
		margin-top: 32px;
	}

	.dl__progress {
		display: block;
		flex: 0 0 100%;
		height: 2px;
		background: var(--c-line-2);
	}

	.dl__progress span {
		display: block;
		width: var(--dl-thumb, 25%);
		height: 100%;
		margin-left: var(--dl-offset, 0%);
		background: var(--c-muted);
	}

	.dl__arrow {
		position: static;
		width: 32px;
		height: 32px;
		border: 1.3px solid var(--c-line);
		background: none;
		color: var(--c-muted);
		box-shadow: none;
		translate: none;
	}

	.dl__arrow:disabled {
		visibility: visible;
		opacity: 0.4;
	}

	.dl__arrow .icon {
		width: 21px;
		height: 21px;
	}
}
