/*
 * Auvrenth Text-to-Speech Reader player. Themes can restyle it through the custom properties below.
 */
.auvrenth-tts {
	--auvrenth-tts-accent: #1e40af;
	--auvrenth-tts-accent-text: #fff;
	--auvrenth-tts-surface: rgba(127, 127, 127, 0.05);
	--auvrenth-tts-border: rgba(127, 127, 127, 0.24);
	--auvrenth-tts-hover: rgba(127, 127, 127, 0.12);
	--auvrenth-tts-floating-bg: Canvas;
	--auvrenth-tts-floating-text: CanvasText;

	box-sizing: border-box;
	width: 100%;
	margin: 0 0 2em;
	overflow: hidden;
	border: 1px solid var(--auvrenth-tts-border);
	border-radius: 14px;
	background: var(--auvrenth-tts-surface);
	font-size: 0.9375rem;
	line-height: 1.3;
}

.auvrenth-tts *,
.auvrenth-tts *::before,
.auvrenth-tts *::after {
	box-sizing: border-box;
}

.auvrenth-tts[hidden],
.auvrenth-tts [hidden] {
	display: none !important;
}

.auvrenth-tts--after {
	margin: 2em 0 0;
}

/* Neutralise theme button styles so the player looks the same everywhere. */
.auvrenth-tts button {
	appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 0;
	border: 0;
	box-shadow: none;
	background: transparent;
	color: inherit;
	font: inherit;
	line-height: 1;
	letter-spacing: normal;
	text-transform: none;
	cursor: pointer;
	transition: background-color 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

.auvrenth-tts svg {
	display: block;
	width: 20px;
	height: 20px;
	fill: currentColor;
}

.auvrenth-tts button:focus-visible,
.auvrenth-tts select:focus-visible {
	outline: 2px solid var(--auvrenth-tts-accent);
	outline-offset: 2px;
}

.auvrenth-tts__bar {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 12px 12px 12px 14px;
}

/* Play / pause */
.auvrenth-tts__toggle {
	flex: none;
	width: 46px;
	height: 46px;
	border-radius: 50%;
	background: var(--auvrenth-tts-accent) !important;
	color: var(--auvrenth-tts-accent-text) !important;
	box-shadow: 0 2px 8px rgba(30, 64, 175, 0.25) !important;
	/* Follows the chosen color where the browser can mix colors; the line above is the fallback. */
	box-shadow: 0 2px 8px color-mix(in srgb, var(--auvrenth-tts-accent) 30%, transparent) !important;
}

.auvrenth-tts__toggle:hover {
	transform: scale(1.05);
}

.auvrenth-tts__toggle:active {
	transform: scale(0.96);
}

.auvrenth-tts__icon-pause,
.auvrenth-tts[data-state="playing"] .auvrenth-tts__icon-play {
	display: none !important;
}

.auvrenth-tts[data-state="playing"] .auvrenth-tts__icon-pause {
	display: block !important;
}

/* Title and time */
.auvrenth-tts__info {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 3px;
	min-width: 0;
}

.auvrenth-tts__title {
	overflow: hidden;
	font-weight: 600;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.auvrenth-tts__meta {
	font-size: 0.8125em;
	font-variant-numeric: tabular-nums;
	opacity: 0.68;
}

/* Stop, speed, settings */
.auvrenth-tts__actions {
	display: flex;
	flex: none;
	align-items: center;
	gap: 2px;
}

.auvrenth-tts__actions button {
	min-width: 36px;
	height: 36px;
	border-radius: 8px;
}

.auvrenth-tts__actions button:hover,
.auvrenth-tts__settings[aria-expanded="true"] {
	background: var(--auvrenth-tts-hover);
}

.auvrenth-tts__stop svg {
	width: 16px;
	height: 16px;
}

.auvrenth-tts[data-state="idle"] .auvrenth-tts__prev,
.auvrenth-tts[data-state="idle"] .auvrenth-tts__stop,
.auvrenth-tts[data-state="idle"] .auvrenth-tts__next {
	display: none;
}

/* Stopped or paused: the Stop button gives its place to a Resume button. */
.auvrenth-tts .auvrenth-tts__resume,
.auvrenth-tts[data-state="paused"] .auvrenth-tts__stop {
	display: none;
}

.auvrenth-tts[data-state="paused"] .auvrenth-tts__resume {
	display: inline-flex;
	color: var(--auvrenth-tts-accent);
}

/* Skip icons point the reading direction. */
[dir="rtl"] .auvrenth-tts__prev svg,
[dir="rtl"] .auvrenth-tts__next svg {
	transform: scaleX(-1);
}

.auvrenth-tts__speed {
	padding: 0 8px !important;
	font-size: 0.8125em !important;
	font-weight: 600 !important;
	font-variant-numeric: tabular-nums;
}

/* Language and voice panel */
.auvrenth-tts__panel {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: 12px;
	padding: 12px 14px 14px;
	border-top: 1px solid var(--auvrenth-tts-border);
}

.auvrenth-tts__field {
	display: block;
	min-width: 0;
	margin: 0;
}

.auvrenth-tts__field span {
	display: block;
	margin-bottom: 5px;
	font-size: 0.75em;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	opacity: 0.68;
}

.auvrenth-tts__field select {
	width: 100%;
	max-width: 100%;
	height: auto;
	margin: 0;
	padding: 8px 10px;
	border: 1px solid var(--auvrenth-tts-border);
	border-radius: 8px;
	background-color: Canvas;
	color: CanvasText;
	font: inherit;
	font-size: 0.875em;
	text-overflow: ellipsis;
	cursor: pointer;
}

.auvrenth-tts__field input[type="range"] {
	width: 100%;
	margin: 0;
	accent-color: var(--auvrenth-tts-accent);
}

.auvrenth-tts__download {
	align-self: end;
	justify-self: start;
	color: var(--auvrenth-tts-accent);
	font-size: 0.875em;
	font-weight: 600;
	text-decoration: underline;
}

/* Shown when reading finishes and "next post" is on. */
.auvrenth-tts__upnext {
	display: block;
	padding: 10px 14px;
	border-top: 1px solid var(--auvrenth-tts-border);
	color: var(--auvrenth-tts-accent);
	font-size: 0.875em;
	font-weight: 600;
	text-decoration: none;
}

.auvrenth-tts__upnext:hover {
	text-decoration: underline;
}

/* "Listen" button next to selected text. */
.auvrenth-tts-selection {
	position: absolute;
	z-index: 99999;
	padding: 7px 14px;
	border: 0;
	border-radius: 999px;
	background: #1e40af;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
	color: #fff;
	font: 600 14px/1 system-ui, sans-serif;
	cursor: pointer;
}

.auvrenth-tts-selection[hidden] {
	display: none;
}

/* Spans the whole panel under the lists. */
.auvrenth-tts__note {
	grid-column: 1 / -1;
	margin: 0;
	font-size: 0.8125em;
	opacity: 0.68;
}

/* Reading progress along the bottom edge; click to jump to a sentence. */
.auvrenth-tts__progress {
	position: relative;
	height: 3px;
	background: var(--auvrenth-tts-hover);
	cursor: pointer;
}

/* A taller hit area than the 3px bar itself. */
.auvrenth-tts__progress::before {
	content: "";
	position: absolute;
	inset: -8px 0 0;
}

.auvrenth-tts__progress span {
	display: block;
	width: 0;
	height: 100%;
	background: var(--auvrenth-tts-accent);
	transition: width 0.4s ease;
}

/* The block editor's picture of the player: looks like the real one, but clicks select the block. */
.auvrenth-tts--preview {
	margin-bottom: 0;
	pointer-events: none;
}

/* Mini player pinned to the bottom of the screen once the original scrolls out of view. */
.auvrenth-tts--floating {
	position: fixed;
	z-index: 99999;
	bottom: 16px;
	left: 50%;
	width: min(560px, calc(100% - 32px));
	margin: 0;
	transform: translateX(-50%);
	background: var(--auvrenth-tts-floating-bg);
	color: var(--auvrenth-tts-floating-text);
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
}

/* The sentence being read. Themes can set --auvrenth-tts-highlight on the content. */
::highlight(auvrenth-tts) {
	background-color: var(--auvrenth-tts-highlight, rgba(59, 130, 246, 0.25));
}

@media (max-width: 480px) {
	.auvrenth-tts__bar {
		gap: 10px;
		padding: 10px;
	}

	.auvrenth-tts__toggle {
		width: 42px;
		height: 42px;
	}

	.auvrenth-tts__actions button {
		min-width: 32px;
	}

	.auvrenth-tts--floating {
		bottom: 12px;
		width: calc(100% - 24px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.auvrenth-tts button,
	.auvrenth-tts__progress span {
		transition: none;
	}
}

/* Button style: shape and size chosen under Auvrenth Reader → Player. */
.auvrenth-tts--rounded .auvrenth-tts__toggle {
	border-radius: 14px;
}

.auvrenth-tts--square .auvrenth-tts__toggle {
	border-radius: 3px;
}

.auvrenth-tts--small .auvrenth-tts__toggle {
	width: 36px;
	height: 36px;
}

.auvrenth-tts--small .auvrenth-tts__toggle svg {
	width: 16px;
	height: 16px;
}

.auvrenth-tts--large .auvrenth-tts__toggle {
	width: 58px;
	height: 58px;
}

.auvrenth-tts--large .auvrenth-tts__toggle svg {
	width: 26px;
	height: 26px;
}
