/* ── Read Aloud Widget ───────────────────────────────────────────────────────── */

.rd-read-aloud {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px;
	padding: 10px 14px;
	background: #f3f4f6;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	font-family: inherit;
	box-sizing: border-box;
}

/* ── Buttons ─────────────────────────────────────────────────────────────────── */

.rd-ra-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: var(--bde-brand-primary-color, #cd0000);
	color: #fff;
	cursor: pointer;
	flex-shrink: 0;
	transition: background 0.15s ease, opacity 0.15s ease;
}

.rd-ra-btn:hover:not(:disabled) {
	background: color-mix(in srgb, var(--bde-brand-primary-color, #cd0000) 82%, black);
}

.rd-ra-btn:focus-visible {
	outline: 3px solid color-mix(in srgb, var(--bde-brand-primary-color, #cd0000) 45%, white);
	outline-offset: 2px;
}

.rd-ra-btn:disabled {
	background: #9ca3af;
	cursor: not-allowed;
	opacity: 0.6;
}

.rd-ra-btn svg {
	width: 20px;
	height: 20px;
	fill: currentColor;
	display: block;
}

/* ── Play / Pause / Loading icon toggle ──────────────────────────────────────── */

.rd-ra-icon-pause,
.rd-ra-icon-loading {
	display: none;
}

.rd-ra-icon-play {
	display: block;
}

.rd-read-aloud[data-state="playing"] .rd-ra-icon-pause {
	display: block;
}

.rd-read-aloud[data-state="playing"] .rd-ra-icon-play,
.rd-read-aloud[data-state="loading"] .rd-ra-icon-play,
.rd-read-aloud[data-state="loading"] .rd-ra-icon-pause {
	display: none;
}

.rd-read-aloud[data-state="loading"] .rd-ra-icon-loading {
	display: block;
}

.rd-ra-icon-loading {
	width: 20px;
	height: 20px;
	border: 2px solid rgba(255, 255, 255, 0.35);
	border-top-color: #fff;
	border-radius: 50%;
	animation: rd-ra-spin 0.75s linear infinite;
	box-sizing: border-box;
}

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

/* ── Progress track ──────────────────────────────────────────────────────────── */

.rd-ra-progress-track {
	width: 100%;
	height: 6px;
	background: #d1d5db;
	border-radius: 3px;
	overflow: hidden;
	min-width: 0;
}

.rd-ra-progress-bar {
	height: 100%;
	width: 0%;
	background: var(--bde-brand-primary-color, #cd0000);
	border-radius: 3px;
	transition: width 0.15s ease;
}

.rd-read-aloud[data-state="loading"] .rd-ra-progress-bar {
	width: 35% !important;
	animation: rd-ra-progress-pulse 1.2s ease-in-out infinite;
}

.rd-read-aloud.rd-ra-downloading[data-state="loading"] .rd-ra-progress-bar {
	width: 0% !important;
	animation: none;
	transition: width 0.2s ease;
}

.rd-read-aloud.rd-ra-progress-indeterminate[data-state="loading"] .rd-ra-progress-bar {
	width: 35% !important;
	animation: rd-ra-progress-pulse 1.2s ease-in-out infinite;
}

.rd-ra-progress-wrap {
	flex: 1;
	min-width: 0;
}

.rd-ra-notice {
	display: block;
	width: 100%;
	flex-basis: 100%;
	font-size: 0.78rem;
	line-height: 1.35;
	border-radius: 6px;
	padding: 6px 10px;
	box-sizing: border-box;
}

.rd-ra-notice--idle {
	color: #374151;
	background: #f3f4f6;
	border: 1px solid #d1d5db;
}

.rd-ra-notice.rd-ra-notice--loading {
	color: #1e40af;
	background: #eff6ff;
	border: 1px solid #93c5fd;
}

.rd-ra-notice--playing {
	color: #166534;
	background: #ecfdf5;
	border: 1px solid #86efac;
}

.rd-ra-notice--paused {
	color: #92400e;
	background: #fffbeb;
	border: 1px solid #fcd34d;
}

.rd-ra-notice--warning {
	color: #92400e;
	background: #fef3c7;
	border: 1px solid #fcd34d;
}

.rd-ra-notice-text {
	display: block;
}

.rd-ra-notice-prep-progress {
	margin-top: 8px;
}

.rd-ra-notice-prep-track {
	height: 5px;
	background: rgba(0, 0, 0, 0.12);
	border-radius: 3px;
	overflow: hidden;
}

.rd-ra-notice--loading .rd-ra-notice-prep-track {
	background: rgba(30, 64, 175, 0.15);
}

.rd-ra-notice-prep-bar {
	height: 100%;
	width: 0%;
	background: var(--bde-brand-primary-color, #cd0000);
	border-radius: 3px;
	transition: width 0.35s ease-out;
}

.rd-ra-notice--loading .rd-ra-notice-prep-bar {
	background: #2563eb;
}

.rd-ra-notice-prep-progress[hidden] {
	display: none;
}

.rd-ra-seek:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.rd-ra-notice[hidden] {
	display: none;
}

.rd-ra-chunk-highlight {
	background-color: #dbeafe;
	outline: 2px solid #60a5fa;
	border-radius: 4px;
	transition: background-color 0.15s ease;
}

@keyframes rd-ra-progress-pulse {
	0%, 100% { opacity: 0.45; }
	50% { opacity: 1; }
}

/* ── Seek buttons ───────────────────────────────────────────────────────────── */

.rd-ra-seek {
	width: auto;
	padding: 0 10px;
	border-radius: 20px;
	gap: 4px;
	font-size: 0.78em;
	font-weight: 600;
	letter-spacing: 0.02em;
}

.rd-ra-seek svg {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
}

.rd-ra-seek-label {
	white-space: nowrap;
}

/* ── Word highlight ──────────────────────────────────────────────────────────── */

.rd-ra-word {
	display: inline;
}

.rd-ra-highlight {
	background-color: #fde68a;
	color: #78200a;
	border-radius: 2px;
	padding: 0 1px;
	outline: 1px solid #f59e0b;
}

/* ── Unsupported message ─────────────────────────────────────────────────────── */

.rd-ra-unsupported {
	font-size: 0.85em;
	color: var(--bde-brand-primary-color, #b91c1c);
}

.rd-ra-unsupported[hidden] {
	display: none;
}

/* ── Settings button ──────────────────────────────────────────────────────────── */

.rd-ra-settings {
	background: #6b7280;
}

.rd-ra-settings:hover:not(:disabled) {
	background: #4b5563;
}

/* ── Settings modal ───────────────────────────────────────────────────────────── */

.rd-ra-modal {
	position: fixed;
	inset: 0;
	z-index: 2147483647;
}

.rd-ra-modal:not([hidden]) {
	display: flex;
	align-items: center;
	justify-content: center;
}

.rd-ra-modal-overlay {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.55);
}

.rd-ra-modal-box {
	position: relative;
	z-index: 1;
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
	width: 90%;
	max-width: 400px;
	max-height: 85vh;
	overflow-y: auto;
	font-family: inherit;
	box-sizing: border-box;
}

.rd-ra-modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 20px 12px;
	border-bottom: 1px solid #e5e7eb;
}

.rd-ra-modal-title {
	margin: 0;
	font-size: 1rem;
	font-weight: 600;
	color: #111827;
}

.rd-ra-modal-close {
	background: none;
	border: none;
	font-size: 1.4rem;
	line-height: 1;
	color: #6b7280;
	cursor: pointer;
	padding: 4px 8px;
	border-radius: 4px;
	transition: color 0.1s;
}

.rd-ra-modal-close:hover {
	color: #111827;
}

.rd-ra-modal-close:focus-visible {
	outline: 2px solid var(--bde-brand-primary-color, #cd0000);
	outline-offset: 2px;
}

.rd-ra-modal-body {
	padding: 16px 20px 20px;
	display: flex;
	flex-direction: column;
	gap: 18px;
}

.rd-ra-field {
	display: flex;
	flex-direction: column;
	gap: 7px;
}

.rd-ra-field label {
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 0.85rem;
	font-weight: 600;
	color: #374151;
}

.rd-ra-field label span {
	font-weight: 400;
	color: var(--bde-brand-primary-color, #cd0000);
	font-size: 0.9em;
	min-width: 3.5em;
	text-align: right;
}

.rd-ra-select {
	width: 100%;
	padding: 8px 10px;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	font-family: inherit;
	font-size: 0.88rem;
	color: #111827;
	background: #fff;
	cursor: pointer;
	box-sizing: border-box;
}

.rd-ra-select:focus {
	outline: 2px solid var(--bde-brand-primary-color, #cd0000);
	outline-offset: 1px;
	border-color: transparent;
}

.rd-ra-range {
	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	height: 5px;
	border-radius: 3px;
	background: #d1d5db;
	cursor: pointer;
}

.rd-ra-range::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--bde-brand-primary-color, #cd0000);
	cursor: pointer;
	border: 2px solid #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.rd-ra-range::-moz-range-thumb {
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--bde-brand-primary-color, #cd0000);
	cursor: pointer;
	border: 2px solid #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.rd-ra-range:focus-visible {
	outline: 2px solid var(--bde-brand-primary-color, #cd0000);
	outline-offset: 3px;
}

/* ── Fixed dock player (tablet / mobile) ─────────────────────────────────────── */

.rd-ra-dock {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 2147483000;
	padding: 0 max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-right));
	pointer-events: none;
	transform: translateY(110%);
	opacity: 0;
	transition: transform 0.28s ease, opacity 0.28s ease;
}

.rd-ra-dock--visible {
	pointer-events: auto;
	transform: translateY(0);
	opacity: 1;
}

.rd-ra-dock > .rd-read-aloud {
	max-width: none;
	width: 100%;
	margin: 0;
	box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
	border-radius: 12px 12px 0 0;
}

@media (min-width: 1025px) {
	.rd-ra-dock {
		display: none !important;
	}
}
