/*
 * Downloads library, the /downloads/ page (inc/downloads.php,
 * page-downloads.php).
 *
 * A file row is the same component the product page's Downloads tab uses
 * (type badge, name, meta, accent CTA), but this page is not a WooCommerce
 * surface, so shop.css never loads here, the component is defined locally
 * rather than dragging the whole shop stylesheet onto an editorial page.
 *
 * Tokens come from tokens.css; only page-local values live here.
 */

.content-downloads {
	padding-bottom: var(--space-12, 128px);
}

/* ============================================================
 * Curated links at the top (editor-managed page content)
 * ============================================================ */

.downloads-intro {
	max-width: 860px;
	margin: 0 auto var(--space-9);
	padding-inline: var(--space-5);
}

.downloads-intro__inner {
	padding: var(--space-6) var(--space-7);
	border-radius: var(--radius-panel);
	background: var(--color-bg-elevated);
}

.downloads-intro__inner h5 {
	margin: 0 0 var(--space-3);
	font-size: var(--font-size-18);
	font-weight: 500;
}

.downloads-intro__inner h5:last-child {
	margin-bottom: 0;
}

/* ============================================================
 * Filter
 * ============================================================ */

.downloads-filter {
	max-width: 860px;
	margin: 0 auto var(--space-8);
	padding-inline: var(--space-5);
	display: flex;
	align-items: center;
	gap: var(--space-5);
	flex-wrap: wrap;
}

.downloads-filter__input {
	flex: 1 1 320px;
	box-sizing: border-box;
	padding: 14px 20px;
	border: 1px solid var(--color-border-hairline);
	border-radius: var(--radius-control);
	background: var(--color-bg-base);
	font-family: var(--font-sans);
	font-size: var(--font-size-16);
	color: var(--color-text-primary);
}

.downloads-filter__input:focus {
	outline: none;
	border-color: var(--color-link);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-link) 18%, transparent);
}

.downloads-filter__count {
	margin: 0;
	flex: 0 0 auto;
	font-size: var(--font-size-14);
	color: var(--color-text-muted);
	font-variant-numeric: tabular-nums;
}

/* ============================================================
 * Groups + file rows
 * ============================================================ */

.downloads-groups {
	max-width: 860px;
	margin: 0 auto;
	padding-inline: var(--space-5);
}

.downloads-group + .downloads-group {
	margin-top: var(--space-10);
}

.downloads-group__title {
	display: flex;
	align-items: baseline;
	gap: var(--space-3);
	margin: 0 0 var(--space-5);
	font-family: var(--font-display);
	font-size: var(--font-size-28);
	font-weight: 600;
	letter-spacing: var(--letter-spacing-tight);
	color: var(--color-text-primary);
}

.downloads-group__count {
	font-family: var(--font-sans);
	font-size: var(--font-size-14);
	font-weight: 500;
	color: var(--color-text-muted);
	font-variant-numeric: tabular-nums;
}

.downloads-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.downloads-list__row {
	display: flex;
	align-items: center;
	gap: var(--space-5);
	padding: var(--space-4) 0;
	border-bottom: 1px solid var(--color-border-hairline);
}

.downloads-list__badge {
	flex: 0 0 auto;
	min-width: 52px;
	padding: 6px 10px;
	border-radius: var(--radius-chip);
	background: color-mix(in srgb, var(--color-accent) 12%, transparent);
	color: var(--color-accent);
	font-size: var(--font-size-12);
	font-weight: 700;
	letter-spacing: var(--letter-spacing-wide);
	text-align: center;
	text-transform: uppercase;
}

.downloads-list__info {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
	flex: 1 1 auto;
}

.downloads-list__name {
	font-weight: 600;
	color: var(--color-text-primary);
	overflow-wrap: break-word;
}

.downloads-list__meta {
	font-size: var(--font-size-14);
	color: var(--color-text-muted);
}

.downloads-list__cta {
	flex: 0 0 auto;
	display: inline-block;
	padding: 10px 18px;
	border-radius: var(--radius-control);
	background: var(--color-cta);
	color: var(--color-cta-ink);
	font-size: var(--font-size-14);
	font-weight: 600;
	text-decoration: none;
	white-space: nowrap;
	transition: background-color var(--motion-duration-fast) var(--motion-ease-standard),
		transform var(--motion-duration-fast) var(--motion-ease-standard);
}

.downloads-list__cta:hover,
.downloads-list__cta:focus-visible {
	background: var(--color-cta-hover);
	color: var(--color-cta-ink);
	text-decoration: none;
}

/* Press on pointer-down (DESIGN-SPEC.md section 1); the duration sits
   inside :active so the press snaps while release keeps the hover ease. */
.downloads-list__cta:active {
	background: color-mix(in srgb, var(--color-cta) 88%, #000);
	transform: scale(0.97);
	transition-duration: var(--motion-duration-press);
}

.downloads-empty {
	margin: var(--space-8) 0 0;
	text-align: center;
	color: var(--color-text-secondary);
}

@media (max-width: 833px) {
	.downloads-list__row {
		flex-wrap: wrap;
		gap: var(--space-3);
	}

	.downloads-list__cta {
		margin-left: calc(52px + var(--space-3));
	}
}

/* Reduced motion: the scale press drops, the background shift keeps
   pointer-down feedback visible (DESIGN-SPEC.md section 7). */
@media (prefers-reduced-motion: reduce) {
	.downloads-list__cta {
		transition: none;
	}

	.downloads-list__cta:active {
		transform: none;
	}
}

/* The hidden attribute must beat the author display declarations above.
   Without this the whole filter is inert: downloads.js sets [hidden] on
   the rows and groups it filters out, the UA rule that would act on it
   loses to display: flex / block, and every file stays on screen while
   only the count changes. Same trap the catalog documents. */
.downloads-list__row[hidden],
.downloads-group[hidden] {
	display: none;
}
