/*
 * Bright Downloads — frontend styles.
 * BEM naming: .bright-downloads__<element>, modifiers as --<modifier>.
 * Only enqueued on pages that actually use a Bright Downloads shortcode.
 */

.bright-downloads__button {
	display: inline-flex;
	align-items: center;
	gap: 0.4em;
	padding: 0.6em 1.2em;
	border-radius: 4px;
	background: var(--bwdbl-button-background, #2271b1);
	color: var(--bwdbl-button-text, #fff);
	text-decoration: none;
	font-weight: 600;
}

.bright-downloads__button:is(:hover, :focus-visible) {
	background: var(--bwdbl-button-hover-background, var(--bwdbl-button-background, #2271b1)) !important;
	color: var(--bwdbl-button-hover-text, var(--bwdbl-button-text, #fff)) !important;
	filter: var(--bwdbl-button-hover-filter, brightness(0.9)) !important;
}

.bright-downloads__button-size {
	opacity: 0.8;
	font-weight: 400;
}

.bright-downloads__button--locked {
	display: inline-block;
	padding: 0.6em 1.2em;
	border-radius: 4px;
	background: #f0f0f1;
	color: #50575e;
	font-style: italic;
}

.bright-downloads__list {
	list-style: none;
	margin: 0;
	padding: 0 !important;
	font-size: 1rem;
}

.bright-downloads__list-item {
	display: flex;
	align-items: center;
	gap: 0.75em;
	padding: 0.6em 0;
	border-bottom: 1px solid #e0e0e0;
}

.bright-downloads__list-item:last-child {
	border-bottom: none;
}

/*
 * Everything except the icon (link, size, count, modified date, version
 * popover trigger) — its own flex context, separate from the icon, so it
 * can wrap onto multiple lines on narrow screens without affecting the
 * icon's fixed size/position. min-width: 0 lets a long file name actually
 * wrap/truncate instead of forcing the row wider than its container.
 */
.bright-downloads__list-content {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.4em 0.75em;
	flex: 1 1 auto;
	min-width: 0;
}

.bright-downloads__list-content {
	display: flex;
	gap: 0.5em;
	flex-grow: 1;
	justify-content: space-between;
	align-items: center;
}

.bright-downloads__list-link {
	font-weight: 600;
	text-decoration: none;
	color: var(--bwdbl-link-color, inherit);
	flex-grow: 1;
}

.bright-downloads__list-link:is(:hover, :focus-visible) {
	color: var(--bwdbl-link-hover-color, var(--bwdbl-link-color, inherit)) !important;
}

.bright-downloads__list-link--locked {
	color: #50575e;
	font-style: italic;
}

.bright-downloads__list-size,
.bright-downloads__list-count {
	font-size: 0.85em;
	opacity: 0.75;
}

.bright-downloads__count,
.bright-downloads__size {
	font-weight: 600;
}

/* Icon prefix (button, list item, grid card) */
.bright-downloads__icon {
	display: inline-flex;
	width: 1.1em;
	height: 1.1em;
	flex-shrink: 0;
}

.bright-downloads__icon svg {
	width: 100%;
	height: 100%;
}

/* Single-button wrapper: button + optional count/modified/version-dropdown */
.bright-downloads__button-wrap {
	display: inline-flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.35em;
}

.bright-downloads__button-count,
.bright-downloads__button-modified,
.bright-downloads__list-modified,
.bright-downloads__grid-modified {
	font-size: 0.85em;
	opacity: 0.75;
}

/* Grid layout: vertical cards */
.bright-downloads__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
	gap: 1em;
	font-size: 1rem;
}

.bright-downloads__grid-card {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.4em;
	padding: 1.25em 1em;
	border: 1px solid #e0e0e0;
	border-radius: 6px;
	text-align: center;
	position: relative;
	background-color: #fff;
	transition: .3s all ease-in-out;
}

.bright-downloads__grid-card .bright-downloads__icon {
	width: 1.5em;
	height: 1.5em;
}

.bright-downloads__grid-link {
	text-decoration: none;
	font-weight: 600;
	color: var(--bwdbl-link-color, inherit);
	flex-grow: 1;
}

.bright-downloads__grid-link:is(:hover, :focus-visible) {
	color: var(--bwdbl-link-hover-color, var(--bwdbl-link-color, inherit)) !important;
}

.bright-downloads__grid-link--locked {
	color: #50575e;
	font-style: italic;
}

/*
 * "Stretch card link" display setting — makes the whole card clickable
 * rather than just the file name. Relies on .bright-downloads__grid-card's
 * `position: relative` (above) as the positioning context.
 */
.bright-downloads__grid-card:has(.stretch-link:is(:hover, :focus-visible)) {
	box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.2);
}

.bright-downloads__grid-card .stretch-link {
	text-decoration: none !important;
}

.bright-downloads__grid-card .stretch-link::after {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 1;
	pointer-events: auto;
	content: "";
	background-color: rgba(0, 0, 0, 0);
}

.bright-downloads__grid-card .bright-downloads__versions {
	position: relative;
	z-index: 2;
}

.bright-downloads__grid-size,
.bright-downloads__grid-count {
	font-size: 0.85em;
	opacity: 0.75;
}

/* Category-grouped listing */
.bright-downloads__category-group {
	margin-bottom: 2em;
}

.bright-downloads__category-group:last-child {
	margin-bottom: 0;
}

.bright-downloads__category-heading {
	margin: 0 0 0.75em;
}

.bright-downloads__versions {
	font-size: 0.85em;
}

.bright-downloads__versions-toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.35em;
	cursor: pointer;
	background: none;
	font: inherit;
	color: inherit;
	border: 1px solid;
	padding: 0.25em 0.5em;
	text-decoration: none;
	border-radius: 0.5em;
	transition: .3s all ease-in-out;
}

.bright-downloads__versions-toggle .bright-downloads__icon {
	width: 0.9em;
	height: 0.9em;
}

.bright-downloads__versions-toggle:is(:hover, :focus-visible),
.bright-downloads__versions-toggle:has(+ :popover-open) {
	background: rgba(0, 0, 0, 0.1);
}

/* Popover */
.bright-downloads__versions-popover {
	margin: auto;
	padding: 1.25em;
	border: 1px solid #dcdcde;
	border-radius: 6px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
	width: 90vw;
	max-width: 660px;
	min-height: 200px;
	font-size: 1rem;
}

.bright-downloads__versions-popover::backdrop {
	background: rgba(0, 0, 0, 0.4);
	backdrop-filter: blur(6px);
}

.bright-downloads__versions-popover-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1em;
	margin: 0 0 0.75em;
}

.bright-downloads__versions-popover-title {
	font-weight: 600;
}

.bright-downloads__versions-item a {
	text-decoration: none;
	display: flex;
	align-items: center;
}

.bright-downloads__versions-item a:hover {
	opacity: 0.6;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.bright-downloads__versions-item a:before {
	content: '';
	height: 1em;
	width: 1em;
	display: inline-block;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg fill='%23000' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline fill='none' stroke='%23000' stroke-width='2' points='13,10 19,16 13,22 ' transform='translate(0, 0)'%3E%3C/polyline%3E%3C/g%3E%3C/svg%3E");
	background-size: contain;
}

.bright-downloads__versions-popover-close {
	background: none;
	border: none;
	padding: 0;
	line-height: 1;
	font-size: 1.4em;
	cursor: pointer;
	color: inherit;
	opacity: 0.6;
}

.bright-downloads__versions-popover-close:hover,
.bright-downloads__versions-popover-close:focus-visible {
	opacity: 1;
}

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

.bright-downloads__versions-item {
	display: flex;
	flex-direction: column;
	gap: 0.3em;
	padding: 0.5em 0;
	border-bottom: 1px solid #f0f0f1;
}

.bright-downloads__versions-item:last-child {
	border-bottom: none;
}

.bright-downloads__versions-item-main {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.75em;
}

.bright-downloads__versions-date {
	opacity: 0.7;
	white-space: nowrap;
}

.bright-downloads__versions-item-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5em 0.75em;
	font-size: 0.85em;
	opacity: 0.7;
}

.bright-downloads__versions-notes {
	margin: 0;
	font-size: 0.85em;
	opacity: 0.8;
}