/*
 * AutoSEO Fixer – front-end styles (works with any theme)
 * Styles what AutoSEO adds to posts: table of contents, related posts,
 * "About this video" and the lazy YouTube player.
 * Colours come from the theme text colour, so light and dark themes both work.
 * Override any --asf-* variable in your theme to change the look.
 */

.asf-toc,
.asf-related,
.asf-video-about,
.asf-yt {
	--asf-accent: var(--wp--preset--color--primary, #1e73be);
	--asf-muted: rgba(0, 0, 0, .6);
	--asf-muted: color-mix(in srgb, currentColor 62%, transparent);
	--asf-border: rgba(0, 0, 0, .12);
	--asf-border: color-mix(in srgb, currentColor 14%, transparent);
	--asf-bg: rgba(0, 0, 0, .03);
	--asf-bg: color-mix(in srgb, currentColor 4%, transparent);
	--asf-radius: 8px;
	box-sizing: border-box;
}

/* ---------- Table of contents ---------- */

nav.asf-toc {
	margin-block: 1.75em;
	padding: 1.1em 1.4em 1.2em;
	background: var(--asf-bg);
	border: 1px solid var(--asf-border);
	border-left: 4px solid var(--asf-accent);
	border-radius: var(--asf-radius);
	font-size: .95em;
	line-height: 1.5;
}

nav.asf-toc .asf-toc-title {
	margin: 0 0 .6em;
	padding: 0;
	font-size: .78em;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var(--asf-muted);
}

nav.asf-toc ol {
	list-style: none;
	margin: 0;
	padding: 0;
	counter-reset: asf-toc;
}

nav.asf-toc li {
	position: relative;
	margin: 0 0 .4em;
	padding: 0 0 0 2em;
	counter-increment: asf-toc;
	break-inside: avoid;
}

nav.asf-toc li::before {
	content: counter(asf-toc) ".";
	position: absolute;
	left: 0;
	top: 0;
	color: var(--asf-accent);
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}

nav.asf-toc ol ol {
	margin: .4em 0 0;
	counter-reset: asf-toc-sub;
}

nav.asf-toc ol ol li {
	padding-left: 2.6em;
	font-size: .94em;
	counter-increment: asf-toc-sub;
}

nav.asf-toc ol ol li::before {
	content: counter(asf-toc) "." counter(asf-toc-sub);
	color: var(--asf-muted);
	font-weight: 500;
}

nav.asf-toc li a {
	color: inherit;
	text-decoration: none;
	box-shadow: none;
	border-bottom: 1px solid transparent;
	transition: color .15s, border-color .15s;
}

nav.asf-toc li a:hover,
nav.asf-toc li a:focus-visible {
	color: var(--asf-accent);
	border-bottom-color: currentColor;
}

/* Long lists split into two columns on wide screens */
@media (min-width: 768px) {
	nav.asf-toc > ol:has(> li:nth-child(8)) {
		columns: 2;
		column-gap: 2.5em;
	}
}

/* Headings reached from the contents list don't hide under sticky headers */
:is(h2, h3, h4)[id] {
	scroll-margin-top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--asf-scroll-offset, 24px));
}

@media (prefers-reduced-motion: no-preference) {
	html:has(.asf-toc) {
		scroll-behavior: smooth;
	}
}

/* ---------- About this video ---------- */

.asf-video-about {
	margin-block: 1.5em 2em;
	padding: 1.2em 1.4em;
	background: var(--asf-bg);
	border: 1px solid var(--asf-border);
	border-radius: var(--asf-radius);
}

.asf-video-about > :first-child { margin-top: 0; }
.asf-video-about > :last-child { margin-bottom: 0; }

.asf-video-about h2 {
	display: flex;
	align-items: center;
	gap: .5em;
	margin: 0 0 .5em;
	font-size: 1.15em;
}

.asf-video-about h2::before {
	content: "";
	flex: none;
	width: 1.15em;
	height: 1.15em;
	border-radius: 50%;
	background: var(--asf-accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M9 7.5v9l7.5-4.5z'/%3E%3C/svg%3E") center / 70% no-repeat;
}

/* ---------- Related posts ---------- */

.asf-related {
	margin-block: 2.5em 1em;
	padding-top: 1.5em;
	border-top: 1px solid var(--asf-border);
}

.asf-related h2 {
	margin: 0 0 .9em;
	font-size: 1.25em;
}

section.asf-related ul {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: .75em;
	list-style: none;
	margin: 0;
	padding: 0;
}

section.asf-related li {
	margin: 0;
	padding: 0;
}

section.asf-related li a {
	display: flex;
	align-items: flex-start;
	gap: .75em;
	height: 100%;
	box-sizing: border-box;
	padding: .85em 1em;
	background: var(--asf-bg);
	border: 1px solid var(--asf-border);
	border-radius: var(--asf-radius);
	color: inherit;
	font-weight: 500;
	line-height: 1.4;
	text-decoration: none;
	box-shadow: none;
	transition: border-color .15s, transform .15s, box-shadow .15s;
}

section.asf-related li a::after {
	content: "→";
	margin-left: auto;
	color: var(--asf-accent);
	transition: transform .15s;
}

section.asf-related li a:hover,
section.asf-related li a:focus-visible {
	border-color: var(--asf-accent);
	transform: translateY(-1px);
	box-shadow: 0 4px 14px rgba(0, 0, 0, .07);
}

section.asf-related li a:hover::after {
	transform: translateX(3px);
}

/* ---------- Lazy YouTube player ---------- */

.asf-yt {
	margin-block: 0 1.5em;
	border-radius: var(--asf-radius);
}

.asf-yt img {
	transition: filter .2s;
}

.asf-yt:hover img {
	filter: brightness(.88);
}

.asf-yt button {
	transition: transform .15s, background-color .15s;
}

.asf-yt:hover button {
	transform: scale(1.07);
}

.asf-yt button:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 3px;
}

/* ---------- Small screens and print ---------- */

@media (max-width: 600px) {
	nav.asf-toc,
	.asf-video-about {
		padding: .9em 1em;
	}
	nav.asf-toc {
		font-size: .93em;
	}
}

@media print {
	.asf-related,
	.asf-yt button {
		display: none;
	}
	nav.asf-toc,
	.asf-video-about {
		background: none;
		break-inside: avoid;
	}
}
