/**
 * Custom Author Cards — frontend styles.
 *
 * Layout: four cards per row on desktop, two per row on mobile.
 * The popup is fullscreen and uses a translucent white background.
 */

.cac {
	--cac-gap: 2rem;
	--cac-gap-mobile: 1.5rem;
	--cac-avatar: 160px;
	--cac-avatar-mobile: 120px;
	--cac-modal-background: rgba(255, 255, 255, 0.96);
	--cac-accent: currentColor;

	box-sizing: border-box;
	margin-block: 0 2rem;
	font-size: inherit;
	line-height: 1.5;
}

.cac *,
.cac *::before,
.cac *::after {
	box-sizing: inherit;
}

/* -------------------------------------------------------------------------
 * Grid
 * ---------------------------------------------------------------------- */

.cac__grid,
.cac__modal__grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: var(--cac-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

/* -------------------------------------------------------------------------
 * Card
 * ---------------------------------------------------------------------- */

.cac__card {
	display: flex;
	margin: 0;
}

.cac__card__link {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.75rem;
	width: 100%;
	padding: 1.5rem 1rem;
	border-radius: 16px;
	background: #fff;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.06);
	color: inherit;
	text-align: center;
	text-decoration: none;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cac__card__link:hover,
.cac__card__link:focus-visible {
	transform: translateY(-4px);
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08), 0 16px 32px rgba(0, 0, 0, 0.12);
}

.cac__card__link:focus-visible {
	outline: 2px solid var(--cac-accent);
	outline-offset: 3px;
}

/* Card variants. */

.cac--plain .cac__card__link {
	padding: 0.5rem;
	background: transparent;
	box-shadow: none;
}

.cac--plain .cac__card__link:hover,
.cac--plain .cac__card__link:focus-visible {
	transform: none;
	box-shadow: none;
}

.cac--outline .cac__card__link {
	background: transparent;
	box-shadow: none;
	border: 1px solid rgba(0, 0, 0, 0.12);
}

/* Text alignment variants. Cards inside the popup are always centered. */

.cac--align-center .cac__card__link,
.cac__modal__grid .cac__card__link {
	text-align: center;
	align-items: center;
}

.cac--align-left .cac__card__link {
	text-align: start;
	align-items: flex-start;
}

.cac--align-right .cac__card__link {
	text-align: end;
	align-items: flex-end;
}

/* -------------------------------------------------------------------------
 * Round avatar
 * ---------------------------------------------------------------------- */

.cac__card__avatar {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: var(--cac-avatar);
	max-width: 100%;
	aspect-ratio: 1 / 1;
	border-radius: 50%;
	overflow: hidden;
	background: #f0f0f1;
	color: #6c7781;
	font-size: 3rem;
	font-weight: 600;
	line-height: 1;
	user-select: none;
}

/* Fallback for browsers without aspect-ratio. */
@supports not (aspect-ratio: 1 / 1) {
	.cac__card__avatar {
		height: var(--cac-avatar);
	}
}

.cac__card__image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center;
	margin: 0;
}

.cac__card__initial {
	line-height: 1;
	text-transform: uppercase;
}

/* -------------------------------------------------------------------------
 * Card text
 * ---------------------------------------------------------------------- */

.cac__card__name,
.cac__card__title {
	display: block;
	max-width: 100%;
	overflow-wrap: anywhere;
}

.cac__card__name {
	font-size: 1.125rem;
	font-weight: 700;
	line-height: 1.4;
	color: inherit;
}

.cac__card__title {
	font-size: 0.9375rem;
	font-weight: 400;
	line-height: 1.5;
	color: #6c7781;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* -------------------------------------------------------------------------
 * Buttons
 * ---------------------------------------------------------------------- */

.cac__footer,
.cac__modal__footer {
	display: flex;
	justify-content: center;
	margin-block-start: 1.75rem;
}

.cac__footer[hidden],
.cac__modal__footer[hidden],
.cac__button[hidden],
.cac__modal[hidden] {
	display: none;
}

.cac__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 0.875rem 2rem;
	border: 0;
	border-radius: 999px;
	background: #1e1e1e;
	color: #fff;
	font-family: inherit;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	transition: background-color 0.2s ease, opacity 0.2s ease;
}

.cac__button:hover,
.cac__button:focus-visible {
	background: #000;
}

.cac__button:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 3px;
}

.cac__button[disabled] {
	cursor: default;
	opacity: 0.6;
}

.cac__button__spinner {
	display: none;
	width: 1em;
	height: 1em;
	border: 2px solid currentColor;
	border-block-start-color: transparent;
	border-radius: 50%;
	animation: cac-spin 0.7s linear infinite;
}

.cac__button.is-loading .cac__button__spinner {
	display: inline-block;
}

@keyframes cac-spin {
	to {
		transform: rotate(360deg);
	}
}

@media (prefers-reduced-motion: reduce) {
	.cac__button__spinner {
		animation-duration: 2s;
	}

	.cac__card__link {
		transition: none;
	}
}

.cac__empty {
	margin: 0;
	padding: 2rem 1rem;
	color: #6c7781;
	text-align: center;
}

/* -------------------------------------------------------------------------
 * Popup
 * ---------------------------------------------------------------------- */

.cac-modal-open {
	overflow: hidden;
}

.cac__modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: clamp(1rem, 4vw, 4rem);
	background: var(--cac-modal-background);
}

.cac__modal__inner {
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 1200px;
	min-height: 100%;
}

.cac__modal__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin-block-end: 2rem;
	/*
	 * The close button is fixed in the top right corner of the viewport, so it
	 * no longer takes part in this row. The padding reserves the room it
	 * occupies; it is physical because the button is pinned to the right in
	 * both left to right and right to left languages.
	 */
	padding-right: 4rem;
}

.cac__modal__title {
	margin: 0;
	font-size: clamp(1.25rem, 3vw, 1.75rem);
	font-weight: 700;
	line-height: 1.3;
}

.cac__modal__close {
	/*
	 * Fixed to the top right corner of the viewport so the popup can always be
	 * dismissed, however far the grid has been scrolled.
	 */
	position: fixed;
	top: clamp(0.75rem, 2.5vw, 1.75rem);
	right: clamp(0.75rem, 2.5vw, 1.75rem);
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.06);
	color: inherit;
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.cac__modal__close:hover,
.cac__modal__close:focus-visible {
	background: rgba(0, 0, 0, 0.12);
}

.cac__modal__close:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.cac__modal__close-icon {
	position: relative;
	display: block;
	width: 1.25rem;
	height: 1.25rem;
}

.cac__modal__close-icon::before,
.cac__modal__close-icon::after {
	content: "";
	position: absolute;
	inset-block-start: 50%;
	inset-inline-start: 0;
	width: 100%;
	height: 2px;
	border-radius: 2px;
	background: currentColor;
}

.cac__modal__close-icon::before {
	transform: translateY(-50%) rotate(45deg);
}

.cac__modal__close-icon::after {
	transform: translateY(-50%) rotate(-45deg);
}

.cac__modal__body {
	flex: 1 1 auto;
}

.cac__modal__footer {
	margin-block: 2rem;
}

.cac__endnote {
	margin: 0;
	color: #6c7781;
	text-align: center;
}

.cac__endnote.is-error {
	color: #b32d2e;
}

/* -------------------------------------------------------------------------
 * Responsive: four cards per row on desktop, two on mobile
 * ---------------------------------------------------------------------- */

@media (max-width: 782px) {
	.cac {
		--cac-gap: var(--cac-gap-mobile);
		--cac-avatar: var(--cac-avatar-mobile);
	}

	.cac__grid,
	.cac__modal__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.cac__card__name {
		font-size: 1rem;
	}

	.cac__card__title {
		font-size: 0.8125rem;
	}

	.cac__button {
		width: 100%;
	}
}