/*
 * CGM Author element.
 * :where() keeps specificity at zero, so Bricks Style controls (fonts, colours, spacing) always win.
 * Card, centered and list layouts respond to the width of their own column (container queries),
 * so the same element works in a full-width article, a sidebar or on a phone.
 */
:root {
	--cgm-author-ink: #111;
	--cgm-author-muted: #6b6b6b;
	--cgm-author-accent: #e5192c;
	--cgm-author-paper: #fff;
	--cgm-author-line: #e3e3e3;
	--cgm-author-font: inherit;
	--cgm-author-meta-font: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

:where(.cgm-author) {
	box-sizing: border-box;
	color: var(--cgm-author-ink);
	font-family: var(--cgm-author-font);
}
:where(.cgm-author *) { box-sizing: border-box; }
:where(.cgm-author--dark) {
	--cgm-author-ink: #f1f1f1;
	--cgm-author-muted: #a8a8a8;
	--cgm-author-paper: #161616;
	--cgm-author-line: #333;
}
:where(.cgm-author a) { color: inherit; text-decoration: none; }
:where(.cgm-author__link:hover, .cgm-author__more:hover) { text-decoration: underline; text-underline-offset: 2px; }
:where(.cgm-author a:focus-visible) { outline: 2px solid var(--cgm-author-accent); outline-offset: 2px; border-radius: 2px; }

:where(.cgm-author__heading) {
	margin: 0 0 12px;
	font-family: var(--cgm-author-meta-font);
	font-size: 12px;
	font-weight: 600;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--cgm-author-muted);
}

/* Avatar */
:where(.cgm-author__avatar-link) { display: inline-flex; flex: none; }
:where(.cgm-author__avatar) {
	position: relative;
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: var(--cgm-author-avatar, 48px);
	height: var(--cgm-author-avatar, 48px);
	overflow: hidden;
	border-radius: 50%;
	background: var(--cgm-author-line);
}
:where(.cgm-author--shape-rounded .cgm-author__avatar) { border-radius: 22%; }
:where(.cgm-author--shape-square .cgm-author__avatar) { border-radius: 0; }
:where(.cgm-author__avatar img) {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	border-radius: inherit;
	object-fit: cover;
}
:where(.cgm-author__initials) {
	font-size: calc(var(--cgm-author-avatar, 48px) * .38);
	font-weight: 700;
	line-height: 1;
	color: var(--cgm-author-muted);
}

/* Shared text */
:where(.cgm-author__name) { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.25; }
:where(.cgm-author__role) { display: block; margin-top: 2px; font-size: 13px; line-height: 1.35; color: var(--cgm-author-muted); }
:where(.cgm-author__bio) { margin-top: 8px; font-size: 14px; line-height: 1.55; }
:where(.cgm-author__bio p) { margin: 0 0 .6em; }
:where(.cgm-author__bio p:last-child) { margin-bottom: 0; }
:where(.cgm-author__foot) { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 10px; }
:where(.cgm-author__more) { font-size: 13px; font-weight: 600; color: var(--cgm-author-accent); }

/* Social links */
:where(.cgm-author__socials) { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; }
:where(.cgm-author__socials li) { margin: 0; padding: 0; }
:where(.cgm-author__socials li)::before, :where(.cgm-author__socials li)::marker { content: none; }
:where(.cgm-author__socials a) {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	color: var(--cgm-author-muted);
	transition: color .2s, background-color .2s;
}
:where(.cgm-author__socials a:hover) { color: var(--cgm-author-ink); background: var(--cgm-author-line); }
:where(.cgm-author__socials svg) { display: block; width: 16px; height: 16px; }

/* ---------------------------------------------------------------- *
 * Byline: By A, B and C
 * ---------------------------------------------------------------- */
/*
 * When a row stretches the element taller than its text (e.g. next to share icons), keep the text
 * vertically centred instead of stuck to the top. Bricks' "Vertical alignment" control overrides it.
 */
:where(.cgm-author--byline, .cgm-author--header) {
	display: flex;
	flex-direction: column;
	justify-content: center;
}
:where(.cgm-author--byline .cgm-author__byline) {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 8px;
	font-family: var(--cgm-author-meta-font);
	font-size: 12px;
	line-height: 1.4;
	text-transform: uppercase;
	color: var(--cgm-author-muted);
}
:where(.cgm-author--byline .cgm-author__name) { font-size: inherit; font-weight: inherit; line-height: inherit; }
:where(.cgm-author--byline .cgm-author__link) { color: var(--cgm-author-accent); }
:where(.cgm-author--byline .cgm-author__text) { min-width: 0; }
:where(.cgm-author--byline .cgm-author__sep) { white-space: pre; }
:where(.cgm-author--byline .cgm-author__person) { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; }
:where(.cgm-author--avatars-each .cgm-author__text) { line-height: calc(var(--cgm-author-avatar) + 6px); }
/* Date line under the byline: same mono, uppercase, grey look */
:where(.cgm-author--byline .cgm-author__meta) {
	margin-top: 2px;
	font-family: var(--cgm-author-meta-font);
	font-size: 12px;
	line-height: 1.4;
	letter-spacing: normal;
	text-transform: uppercase;
	color: var(--cgm-author-muted);
}
/* Date on the same line: PHILIP WATSON | DECEMBER 30, 2024 */
:where(.cgm-author--byline .cgm-author__meta--inline) { margin-top: 0; }
:where(.cgm-author__inline-sep) { color: var(--cgm-author-muted); }
.cgm-author__inline-sep.is-off { display: none; }
:where(.cgm-author--align-center.cgm-author--byline .cgm-author__meta) { text-align: center; }
:where(.cgm-author--align-end.cgm-author--byline .cgm-author__meta) { text-align: right; }

/* Overlapping avatar group */
:where(.cgm-author__stack) { display: inline-flex; flex: none; padding-left: 6px; }
:where(.cgm-author__stack > *) { margin-left: -6px; }
:where(.cgm-author__stack .cgm-author__avatar) { box-shadow: 0 0 0 2px var(--cgm-author-paper); }

/* ---------------------------------------------------------------- *
 * Header: avatar(s), names, then "Published … • 2 min read"
 * ---------------------------------------------------------------- */
:where(.cgm-author__header) { display: flex; align-items: center; gap: 10px; min-width: 0; }
:where(.cgm-author--header .cgm-author__main) { flex: 1; min-width: 0; }
:where(.cgm-author__names) { font-size: 14px; font-weight: 700; line-height: 1.3; }
:where(.cgm-author__names .cgm-author__name) { font-size: inherit; font-weight: inherit; }
:where(.cgm-author__names .cgm-author__sep) { font-weight: 400; white-space: pre; }
/* The meta line flows as plain inline text so it wraps like a sentence */
:where(.cgm-author__meta) {
	display: block;
	margin-top: 2px;
	font-size: 12px;
	line-height: 1.45;
	color: var(--cgm-author-muted);
}
/* Real specificity: must beat the date stylesheet whatever order the two load in */
.cgm-author__meta .cgm-date,
.cgm-author__meta .cgm-date__item,
.cgm-author__meta-part { display: inline; }
/* The date takes the line's own size and colour, whatever order the stylesheets load in. */
.cgm-author__meta .cgm-date { color: inherit; font-size: inherit; }
:where(.cgm-author__meta .cgm-date__label) { font-weight: inherit; }
:where(.cgm-author__meta-sep) { white-space: normal; }
:where(.cgm-author__readtime) { white-space: nowrap; }
:where(.cgm-author--header .cgm-author__stack) { padding-left: 0; }
:where(.cgm-author--header .cgm-author__stack > *) { margin-left: 0; }
:where(.cgm-author--header .cgm-author__stack > * + *) { margin-left: -10px; }
:where(.cgm-author--header.cgm-author--multi .cgm-author__avatar) { box-shadow: 0 0 0 2px var(--cgm-author-paper); }
@media (max-width: 600px) {
	/* Several authors on a phone: smaller, tighter avatar group */
	.cgm-author--header.cgm-author--multi .cgm-author__avatar {
		width: min(var(--cgm-author-avatar), 34px);
		height: min(var(--cgm-author-avatar), 34px);
	}
	.cgm-author--header.cgm-author--multi .cgm-author__initials { font-size: calc(min(var(--cgm-author-avatar), 34px) * .38); }
	.cgm-author--header.cgm-author--multi .cgm-author__stack > * + * { margin-left: -14px; }
	.cgm-author--header .cgm-author__header { align-items: flex-start; }
}

/* ---------------------------------------------------------------- *
 * Compact: avatar + name + role, in a row that wraps
 * ---------------------------------------------------------------- */
:where(.cgm-author--compact .cgm-author__people) { display: flex; flex-wrap: wrap; gap: 12px 24px; }
:where(.cgm-author--compact .cgm-author__person) { display: flex; align-items: center; gap: 10px; min-width: 0; }
:where(.cgm-author--compact .cgm-author__name) { font-size: 14px; }
:where(.cgm-author--compact .cgm-author__role) { font-size: 12px; }

/* ---------------------------------------------------------------- *
 * List: one author per line
 * ---------------------------------------------------------------- */
:where(.cgm-author--list) { container-type: inline-size; }
:where(.cgm-author--list .cgm-author__people) { display: flex; flex-direction: column; gap: 14px; }
:where(.cgm-author--list .cgm-author__person) { display: flex; align-items: center; gap: 12px; }
:where(.cgm-author--list .cgm-author__main) { display: flex; flex: 1; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; min-width: 0; }
:where(.cgm-author--list .cgm-author__foot) { margin-top: 0; }

/* ---------------------------------------------------------------- *
 * Card: avatar beside name, role, bio, links
 * ---------------------------------------------------------------- */
:where(.cgm-author--card, .cgm-author--centered) { container-type: inline-size; }
:where(.cgm-author--card .cgm-author__people, .cgm-author--centered .cgm-author__people) {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
	gap: 16px;
}
:where(.cgm-author--cols-1 .cgm-author__people) { grid-template-columns: 1fr; }
:where(.cgm-author--cols-2 .cgm-author__people) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
:where(.cgm-author--cols-3 .cgm-author__people) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* A single card always spans the full width */
:where(.cgm-author--card:not(.cgm-author--multi) .cgm-author__people, .cgm-author--centered:not(.cgm-author--multi) .cgm-author__people) { grid-template-columns: 1fr; }

:where(.cgm-author--card .cgm-author__person) {
	display: flex;
	align-items: flex-start;
	gap: 18px;
	padding: 20px;
	border: 1px solid var(--cgm-author-line);
	border-radius: 8px;
	background: var(--cgm-author-paper);
}
:where(.cgm-author--card .cgm-author__main) { flex: 1; min-width: 0; }
:where(.cgm-author--card .cgm-author__name) { font-size: 18px; }

/* Centered */
:where(.cgm-author--centered .cgm-author__person) {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	padding: 24px 20px;
	border: 1px solid var(--cgm-author-line);
	border-radius: 8px;
	background: var(--cgm-author-paper);
	text-align: center;
}
:where(.cgm-author--centered .cgm-author__name) { font-size: 18px; }
:where(.cgm-author--centered .cgm-author__foot) { justify-content: center; }
:where(.cgm-author--centered .cgm-author__socials) { justify-content: center; }

/* Alignment (byline, compact, list) */
:where(.cgm-author--align-center .cgm-author__byline, .cgm-author--align-center.cgm-author--compact .cgm-author__people) { justify-content: center; }
:where(.cgm-author--align-end .cgm-author__byline, .cgm-author--align-end.cgm-author--compact .cgm-author__people) { justify-content: flex-end; }
:where(.cgm-author--align-center .cgm-author__heading) { text-align: center; }
:where(.cgm-author--align-end .cgm-author__heading) { text-align: right; }

/* ---------------------------------------------------------------- *
 * Narrow columns and phones
 * ---------------------------------------------------------------- */
@container (max-width: 640px) {
	.cgm-author--cols-2 .cgm-author__people,
	.cgm-author--cols-3 .cgm-author__people { grid-template-columns: 1fr; }
}
@container (max-width: 480px) {
	/* Card: smaller avatar beside the name; bio and links use the full width below */
	.cgm-author--card .cgm-author__person {
		display: grid;
		grid-template-columns: auto minmax(0, 1fr);
		align-items: center;
		gap: 12px 14px;
		padding: 16px;
	}
	.cgm-author--card .cgm-author__avatar {
		width: min(var(--cgm-author-avatar), 64px);
		height: min(var(--cgm-author-avatar), 64px);
	}
	.cgm-author--card .cgm-author__main { display: contents; }
	.cgm-author--card .cgm-author__bio,
	.cgm-author--card .cgm-author__foot { grid-column: 1 / -1; margin-top: 0; }
	.cgm-author--card .cgm-author__name,
	.cgm-author--centered .cgm-author__name { font-size: 16px; }

	.cgm-author--centered .cgm-author__avatar {
		width: min(var(--cgm-author-avatar), 96px);
		height: min(var(--cgm-author-avatar), 96px);
	}

	/* List: links drop under the name */
	.cgm-author--list .cgm-author__main { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
	:where(.cgm-author__socials a) { transition: none; }
}
