/*
 * MyAuthor Box
 *
 * Theme-first, like MyRecipe Styles:
 * - Fonts, sizes and text colour are inherited from wherever the box sits
 *   (post content or a sidebar widget).
 * - Lines and tints are mixed from currentColor, so it works on light or dark.
 * - The accent resolves: --myauthor-accent -> Neve's --nv-primary-accent ->
 *   theme.json primary preset -> currentColor.
 * - Layout follows the box's own width (container query), not the screen:
 *   side by side at the end of a post, stacked in a narrow sidebar.
 */

.myauthor {
	--myauthor-accent-c: var(--myauthor-accent, var(--nv-primary-accent, var(--wp--preset--color--primary, currentColor)));
	--myauthor-line: color-mix(in srgb, currentColor 15%, transparent);
	--myauthor-tint: color-mix(in srgb, currentColor 4%, transparent);
	--myauthor-muted: color-mix(in srgb, currentColor 70%, transparent);
	--myauthor-radius: 0.5rem;
	--myauthor-pad: clamp(1rem, 4cqi, 1.75rem);

	container: myauthor / inline-size;
	box-sizing: border-box;
	margin-block: 2rem;
	color: inherit;
	font: inherit;
}

@supports not (color: color-mix(in srgb, red 50%, transparent)) {
	.myauthor {
		--myauthor-line: rgba(128, 128, 128, 0.25);
		--myauthor-tint: rgba(128, 128, 128, 0.06);
		--myauthor-muted: inherit;
	}
}

.myauthor *,
.myauthor *::before,
.myauthor *::after {
	box-sizing: border-box;
}

/* Widgets already sit in a spaced column. */
.widget .myauthor,
.wp-block-widget-area .myauthor {
	margin-block: 0;
}

/* ---------- Styles ---------- */

.myauthor-card {
	padding: var(--myauthor-pad);
	background: var(--myauthor-tint);
	border: 1px solid var(--myauthor-line);
	border-radius: calc(var(--myauthor-radius) * 2);
}

.myauthor-bordered {
	padding: var(--myauthor-pad);
	border: 2px solid var(--myauthor-accent-c);
	border-radius: calc(var(--myauthor-radius) * 2);
}

.myauthor-minimal {
	padding-block: var(--myauthor-pad);
	border-block: 1px solid var(--myauthor-line);
}

/* ---------- Parts ---------- */

.myauthor .myauthor-title {
	margin: 0 0 1rem;
}

/* In a sidebar, keep the heading at widget-title scale rather than a post h2/h3. */
.widget .myauthor .myauthor-title,
.widget-area .myauthor .myauthor-title,
.nv-sidebar-wrap .myauthor .myauthor-title {
	font-size: 1.25em;
	line-height: 1.3;
}

.myauthor-body {
	display: grid;
	gap: 1rem;
	justify-items: center;
	text-align: center;
}

.myauthor-avatar-link {
	display: block;
	line-height: 0;
	text-decoration: none;
	border: 0;
	box-shadow: none;
}

.myauthor .myauthor-avatar {
	display: block;
	width: var(--myauthor-avatar, 96px);
	max-width: none;
	height: var(--myauthor-avatar, 96px);
	margin: 0;
	object-fit: cover;
	border-radius: 50%;
	box-shadow: 0 0 0 3px var(--myauthor-accent-c);
	padding: 0;
}

.myauthor-text {
	min-width: 0;
}

.myauthor .myauthor-name {
	margin: 0 0 0.35rem;
	font-weight: 700;
	font-size: 1.15em;
	line-height: 1.3;
}

.myauthor .myauthor-name a {
	color: inherit;
	text-decoration: none;
}

.myauthor .myauthor-name a:hover,
.myauthor .myauthor-name a:focus-visible {
	color: var(--myauthor-accent-c);
}

.myauthor-bio > :first-child {
	margin-top: 0;
}

.myauthor-bio > :last-child {
	margin-bottom: 0;
}

.myauthor-bio p {
	margin: 0 0 0.75em;
}

.myauthor .myauthor-links {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
	justify-content: center;
	margin: 0.9rem 0 0;
	padding: 0;
	list-style: none;
}

.myauthor .myauthor-links li {
	margin: 0;
	padding: 0;
}

.myauthor .myauthor-links li::before {
	content: none;
}

.myauthor .myauthor-links a {
	display: inline-block;
	padding: 0.25em 0.75em;
	font-size: 0.85em;
	line-height: 1.5;
	color: inherit;
	text-decoration: none;
	border: 1px solid var(--myauthor-line);
	border-radius: 999px;
	transition: border-color 0.15s, color 0.15s;
}

.myauthor .myauthor-links a:hover,
.myauthor .myauthor-links a:focus-visible {
	color: var(--myauthor-accent-c);
	border-color: var(--myauthor-accent-c);
}

.myauthor .myauthor-more {
	margin: 0.9rem 0 0;
	font-size: 0.9em;
	font-weight: 600;
}

.myauthor .myauthor-more a {
	color: var(--myauthor-accent-c);
	text-decoration: none;
}

.myauthor .myauthor-more a:hover,
.myauthor .myauthor-more a:focus-visible {
	text-decoration: underline;
}

/* ---------- Photo shape ---------- */

.myauthor-shape-rounded .myauthor-avatar {
	border-radius: calc(var(--myauthor-radius) * 2);
}

.myauthor-shape-square .myauthor-avatar {
	border-radius: 0;
}

/* ---------- Logos ---------- */

.myauthor .myauthor-icon {
	display: block;
	flex: none;
	width: 1.1em;
	height: 1.1em;
}

.myauthor-icons-logo .myauthor-links a {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.4em;
	height: 2.4em;
	padding: 0;
	font-size: 0.9em;
}

.myauthor-icons-both .myauthor-links a {
	display: inline-flex;
	align-items: center;
	gap: 0.45em;
}

.myauthor-brand .myauthor-icon {
	color: var(--myauthor-brand, currentColor);
}

.myauthor.myauthor-brand .myauthor-links a:hover,
.myauthor.myauthor-brand .myauthor-links a:focus-visible {
	border-color: var(--myauthor-brand, var(--myauthor-accent-c));
}

/* ---------- Layout ---------- */

/* Stacked (and auto when narrow) centres by default. */
.myauthor-layout-stacked .myauthor-title,
.myauthor-layout-auto .myauthor-title {
	text-align: center;
}

/* Side by side: photo, then text. */
.myauthor-layout-row .myauthor-body {
	grid-template-columns: auto 1fr;
	gap: 1.25rem;
	align-items: start;
	justify-items: start;
	text-align: left;
}

.myauthor-layout-row .myauthor-links {
	justify-content: flex-start;
}

/* auto: side by side once the box is wide enough (end of a post). */
@container myauthor (min-width: 30rem) {
	.myauthor-layout-auto .myauthor-body {
		grid-template-columns: auto 1fr;
		gap: 1.25rem;
		align-items: start;
		justify-items: start;
		text-align: left;
	}

	.myauthor-layout-auto .myauthor-links {
		justify-content: flex-start;
	}

	.myauthor-layout-auto .myauthor-title {
		text-align: left;
	}
}

.myauthor-no-avatar .myauthor-body {
	grid-template-columns: 1fr !important;
}

.myauthor-layout-row .myauthor-title {
	text-align: left;
}

/*
 * align: one switch for the whole contents (heading, photo, text, logos).
 * It only moves things; padding and margins stay as they are.
 * - left:   everything to the left (photo on the left when side by side).
 * - right:  everything to the right (photo on the right when side by side).
 * - center: everything centred, photo above the text.
 */
.myauthor.myauthor-align-left .myauthor-title,
.myauthor.myauthor-align-left .myauthor-body {
	text-align: left;
}

.myauthor.myauthor-align-left .myauthor-body {
	justify-items: start;
}

.myauthor.myauthor-align-left .myauthor-links {
	justify-content: flex-start;
}

.myauthor.myauthor-align-right .myauthor-title,
.myauthor.myauthor-align-right .myauthor-body {
	text-align: right;
}

.myauthor.myauthor-align-right .myauthor-body {
	justify-items: end;
}

.myauthor.myauthor-align-right .myauthor-links {
	justify-content: flex-end;
}

.myauthor-layout-row.myauthor-align-right .myauthor-body {
	grid-template-columns: 1fr auto;
}

.myauthor-layout-row.myauthor-align-right .myauthor-avatar-link {
	order: 2;
}

@container myauthor (min-width: 30rem) {
	.myauthor-layout-auto.myauthor-align-right .myauthor-body {
		grid-template-columns: 1fr auto;
	}

	.myauthor-layout-auto.myauthor-align-right .myauthor-avatar-link {
		order: 2;
	}
}

.myauthor.myauthor-align-center .myauthor-title,
.myauthor.myauthor-align-center .myauthor-body {
	text-align: center;
}

.myauthor.myauthor-align-center .myauthor-body {
	grid-template-columns: 1fr;
	justify-items: center;
}

.myauthor.myauthor-align-center .myauthor-links {
	justify-content: center;
}

@media print {
	.myauthor-links,
	.myauthor-more {
		display: none;
	}
}
