/* PSC Insight – Smart Reader & Text-to-Speech | frontend */

/* ---------- Lesson text size (applied only after the learner changes it, or if an admin default is set) ---------- */
.psc-sr-sized { font-size: var(--psc-sr-fs) !important; line-height: 1.7 !important; }
.psc-sr-sized p, .psc-sr-sized li, .psc-sr-sized td, .psc-sr-sized th, .psc-sr-sized dd, .psc-sr-sized dt,
.psc-sr-sized blockquote, .psc-sr-sized span, .psc-sr-sized a, .psc-sr-sized strong, .psc-sr-sized em,
.psc-sr-sized b, .psc-sr-sized i, .psc-sr-sized u, .psc-sr-sized label, .psc-sr-sized figcaption,
.psc-sr-sized div, .psc-sr-sized section, .psc-sr-sized article { font-size: inherit !important; }
.psc-sr-sized h1 { font-size: 2em !important; }
.psc-sr-sized h2 { font-size: 1.6em !important; }
.psc-sr-sized h3 { font-size: 1.35em !important; }
.psc-sr-sized h4 { font-size: 1.15em !important; }
.psc-sr-sized h5, .psc-sr-sized h6 { font-size: 1em !important; }
.psc-sr-sized small { font-size: .875em !important; }
.psc-sr-sized code, .psc-sr-sized pre { font-size: .9em !important; }

/* ---------- Highlight of the sentence being read ---------- */
::highlight(psc-sr-current) { background-color: var(--psc-sr-hl, #ffe58f); color: inherit; }
.psc-sr-hl-block { background-color: var(--psc-sr-hl, #ffe58f); border-radius: 4px; box-shadow: 0 0 0 3px var(--psc-sr-hl, #ffe58f); }

/* ---------- Toolbar ---------- */
.psc-sr {
	--psc-accent: var(--psc-sr-accent, #1a73e8);
	--psc-bg: #ffffff;
	--psc-fg: #1f2937;
	--psc-muted: #5b6472;
	--psc-border: rgba(15, 23, 42, .14);
	--psc-hover: rgba(15, 23, 42, .07);
	--psc-shadow: 0 10px 30px rgba(15, 23, 42, .22);
	position: fixed;
	z-index: var(--psc-sr-z, 9990);
	bottom: calc(12px + env(safe-area-inset-bottom, 0px));
	box-sizing: border-box;
	max-width: calc(100vw - 24px);
	font: 14px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", "Mukta", sans-serif;
	color: var(--psc-fg);
	-webkit-text-size-adjust: 100%;
}
.psc-sr[hidden] { display: none !important; }
.psc-sr *, .psc-sr *::before, .psc-sr *::after { box-sizing: border-box; }

.psc-sr[data-theme="dark"] {
	--psc-bg: #1b2230; --psc-fg: #eef1f6; --psc-muted: #aab3c2;
	--psc-border: rgba(255, 255, 255, .16); --psc-hover: rgba(255, 255, 255, .1);
	--psc-shadow: 0 10px 30px rgba(0, 0, 0, .55);
}
@media (prefers-color-scheme: dark) {
	.psc-sr[data-theme="auto"] {
		--psc-bg: #1b2230; --psc-fg: #eef1f6; --psc-muted: #aab3c2;
		--psc-border: rgba(255, 255, 255, .16); --psc-hover: rgba(255, 255, 255, .1);
		--psc-shadow: 0 10px 30px rgba(0, 0, 0, .55);
	}
}

.psc-sr[data-pos="bottom-center"] { left: 50%; transform: translateX(-50%); }
.psc-sr[data-pos="bottom-left"] { left: max(12px, env(safe-area-inset-left, 0px)); }
.psc-sr[data-pos="bottom-right"] { right: max(12px, env(safe-area-inset-right, 0px)); }

/* Inline modes: sits in the page flow directly under the lesson title */
.psc-sr[data-pos^="top"] { position: static; bottom: auto; max-width: none; margin: 10px 0 20px; transform: none; }
.psc-sr[data-pos="top-sticky"] { position: sticky; top: calc(8px + var(--wp-admin--admin-bar--height, 0px)); z-index: var(--psc-sr-z, 9990); }
.psc-sr[data-pos^="top"] .psc-sr__bar { width: 100%; max-width: 100%; border-radius: 14px; box-shadow: 0 2px 10px rgba(15, 23, 42, .12); }
.psc-sr[data-pos^="top"] .psc-sr__timeline { flex-basis: 220px; }
.psc-sr[data-pos^="top"] .psc-sr__fab,
.psc-sr[data-pos^="top"] .psc-sr__close { display: none !important; }
.psc-sr[data-pos^="top"] .psc-sr__status { position: static; margin-top: 6px; }

.psc-sr__bar {
	display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
	padding: 8px 10px;
	width: max-content; max-width: calc(100vw - 24px);
	background: var(--psc-bg); color: var(--psc-fg);
	border: 1px solid var(--psc-border); border-radius: 18px;
	box-shadow: var(--psc-shadow);
}
.psc-sr.is-collapsed .psc-sr__bar { display: none; }
.psc-sr:not(.is-collapsed) .psc-sr__fab { display: none; }

.psc-sr__fab {
	display: grid; place-items: center;
	width: 52px; height: 52px; padding: 0; border: 0; border-radius: 50%;
	background: var(--psc-accent); color: #fff; cursor: pointer;
	box-shadow: var(--psc-shadow);
}
.psc-sr__fab svg { width: 26px; height: 26px; fill: currentColor; }
.psc-sr.is-active .psc-sr__fab { animation: psc-sr-pulse 1.6s ease-out infinite; }
@keyframes psc-sr-pulse { 0% { box-shadow: 0 0 0 0 rgba(26, 115, 232, .55), var(--psc-shadow); } 100% { box-shadow: 0 0 0 16px rgba(26, 115, 232, 0), var(--psc-shadow); } }

.psc-sr__size { display: flex; align-items: center; gap: 2px; }
.psc-sr__sep { width: 1px; align-self: stretch; min-height: 26px; background: var(--psc-border); margin: 0 2px; }

.psc-sr__btn {
	display: inline-grid; place-items: center;
	min-width: 38px; height: 38px; padding: 0 8px; margin: 0;
	border: 1px solid transparent; border-radius: 10px;
	background: transparent; color: inherit; cursor: pointer;
	font: inherit; font-weight: 600; line-height: 1;
	-webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.psc-sr__btn:hover { background: var(--psc-hover); }
.psc-sr__btn svg { width: 22px; height: 22px; fill: currentColor; }
.psc-sr__btn:disabled, .psc-sr__btn.is-disabled { opacity: .4; cursor: not-allowed; }
.psc-sr__btn:disabled:hover, .psc-sr__btn.is-disabled:hover { background: transparent; }
.psc-sr__txt { font-size: 15px; }
.psc-sr__reset { font-size: 13px; font-weight: 500; color: var(--psc-muted); }

.psc-sr__play { width: 42px; height: 42px; border-radius: 50%; background: var(--psc-accent); color: #fff; }
.psc-sr__play:hover { background: var(--psc-accent); filter: brightness(1.1); }
.psc-sr__play svg { width: 24px; height: 24px; }
.psc-sr__spin { animation: psc-sr-spin 0.9s linear infinite; }
@keyframes psc-sr-spin { to { transform: rotate(360deg); } }

.psc-sr__timeline { display: flex; align-items: center; gap: 8px; flex: 1 1 200px; min-width: 150px; }
.psc-sr__time { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--psc-muted); min-width: 34px; text-align: center; }
.psc-sr__seek { flex: 1; min-width: 70px; height: 28px; margin: 0; accent-color: var(--psc-accent); cursor: pointer; }
.psc-sr__seek:disabled { cursor: default; opacity: .5; }

.psc-sr__speed { min-width: 50px; font-variant-numeric: tabular-nums; border-color: var(--psc-border); }
.psc-sr__lang {
	height: 38px; max-width: 108px; padding: 0 8px; margin: 0;
	border: 1px solid var(--psc-border); border-radius: 10px;
	background: var(--psc-bg); color: inherit; font: inherit; font-size: 13px; cursor: pointer;
}
.psc-sr__close { color: var(--psc-muted); }

.psc-sr :focus-visible { outline: 3px solid var(--psc-accent); outline-offset: 2px; }
.psc-sr__fab:focus-visible { outline-color: var(--psc-fg); }

.psc-sr__status {
	position: absolute; left: 0; right: 0; bottom: calc(100% + 8px);
	display: none; justify-content: center; pointer-events: none;
}
.psc-sr__status.is-on { display: flex; }
.psc-sr__status.is-on::before { content: none; }
.psc-sr__status { text-align: center; }
.psc-sr__status.is-on {
	width: max-content; max-width: min(92vw, 520px); margin: 0 auto;
	padding: 8px 12px; border-radius: 12px;
	background: var(--psc-fg); color: var(--psc-bg);
	font-size: 13px; line-height: 1.35; box-shadow: var(--psc-shadow);
}

/* ---------- Small screens: two compact rows ---------- */
@media (max-width: 720px) {
	.psc-sr__bar { width: calc(100vw - 24px); gap: 6px; padding: 8px; }
	.psc-sr__size { order: 1; margin-right: auto; }
	.psc-sr__sep { order: 4; flex: 0 0 100%; width: 100%; min-height: 0; height: 0; margin: -3px 0 0; background: none; }
	.psc-sr__lang { order: 2; }
	.psc-sr__close { order: 3; }
	.psc-sr__play { order: 5; }
	.psc-sr__stop { order: 6; }
	.psc-sr__timeline { order: 7; flex: 1 1 0; min-width: 0; gap: 4px; }
	.psc-sr__speed { order: 8; }
	.psc-sr[data-pos^="top"] .psc-sr__timeline { flex: 1 1 0; min-width: 0; }
	.psc-sr__btn { min-width: 40px; height: 40px; }
	.psc-sr__play { width: 44px; height: 44px; }
	.psc-sr__lang { height: 40px; }
	.psc-sr__time { min-width: 30px; }
}
@media (max-width: 380px) {
	.psc-sr__reset { padding: 0 4px; font-size: 12px; }
	.psc-sr__time[data-el="tot"] { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.psc-sr *, .psc-sr *::before { animation: none !important; transition: none !important; }
}
@media (forced-colors: active) {
	.psc-sr__bar, .psc-sr__fab { border: 1px solid CanvasText; }
	.psc-sr__play { background: ButtonFace; color: ButtonText; border: 1px solid ButtonText; }
}
@media print { .psc-sr { display: none !important; } }
