/* Speed Reader Relay */

.srr-overlay {
	--srr-bg: #000;
	--srr-fg: #fff;
	--srr-rule: #2c2c2c;
	--srr-muted: #6f6f6f;
	--srr-card: #121212;
	--srr-pivot: #e5483b;
	--srr-focus: 40%;
	--srr-progress: 0;
	--srr-speed: 0.2857;
	--srr-font: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;

	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	/* Above floating widgets such as ReaderRelay's player (99999). */
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 56px 16px 32px;
	box-sizing: border-box;
	background: var(--srr-bg);
	color: var(--srr-fg);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	-webkit-tap-highlight-color: transparent;
	overscroll-behavior: contain;
}

.srr-overlay[hidden] { display: none !important; }

.srr-overlay.srr-light {
	--srr-bg: #fff;
	--srr-fg: #141414;
	--srr-rule: #dcdcdc;
	--srr-muted: #8b8b8b;
	--srr-card: #f6f6f6;
}

.srr-overlay.srr-sans {
	--srr-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.srr-overlay *,
.srr-overlay *::before,
.srr-overlay *::after { box-sizing: border-box; }

.srr-overlay button {
	margin: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	cursor: pointer;
	line-height: 1;
	text-transform: none;
	letter-spacing: normal;
	box-shadow: none;
	min-height: 0;
}

.srr-overlay button:focus-visible,
.srr-overlay input:focus-visible {
	outline: 2px solid var(--srr-pivot);
	outline-offset: 3px;
}

/* ---- Close ---- */

.srr-close {
	position: absolute;
	top: 8px;
	right: 14px;
	width: 44px;
	height: 44px;
	display: grid;
	place-items: center;
	border-radius: 50%;
	color: var(--srr-muted) !important;
	transition: color 0.15s;
}

.srr-close:hover { color: var(--srr-fg) !important; }
.srr-close svg { width: 24px; height: 24px; }

/* ---- Stage ---- */

.srr-stage {
	width: 100%;
	max-width: 900px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 28px;
}

/* ---- The word frame: two rules with tick marks at the focus point ---- */

.srr-frame {
	position: relative;
	width: 100%;
	cursor: pointer;
	user-select: none;
	-webkit-user-select: none;
	touch-action: pan-y;
}

.srr-rule {
	position: relative;
	height: 3px;
	background: var(--srr-rule);
}

.srr-rule::after {
	content: '';
	position: absolute;
	left: var(--srr-focus);
	width: 3px;
	height: 22px;
	margin-left: -1.5px;
	background: var(--srr-rule);
}

.srr-rule-top::after { top: 3px; }
.srr-rule-bottom::after { bottom: 3px; }

/* Progress through the page fills the bottom rule. */
.srr-rule-bottom::before {
	content: '';
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: calc(var(--srr-progress) * 100%);
	background: var(--srr-pivot);
	opacity: 0.45;
	transition: width 0.2s linear;
}

.srr-word-line {
	position: relative;
	height: 2.7em;
	font-size: clamp(34px, 7vw, 68px);
	overflow: hidden;
}

.srr-word {
	position: absolute;
	top: 50%;
	left: 0;
	margin-top: -0.62em;
	white-space: nowrap;
	font-family: var(--srr-font);
	font-weight: 400;
	line-height: 1.2;
	letter-spacing: 0.01em;
	color: var(--srr-fg);
	will-change: transform;
}

.srr-pivot { color: var(--srr-pivot); }

.srr-word.srr-message {
	font-size: 0.4em;
	margin-top: -0.6em;
	color: var(--srr-muted);
}

.srr-where {
	position: absolute;
	right: 4px;
	bottom: -28px;
	font-size: 15px;
	font-style: italic;
	color: var(--srr-muted);
	white-space: nowrap;
}

/* ---- Controls ---- */

/* Play sits directly under the focus letter (the tick marks), gear beside it. */
.srr-controls {
	--srr-play: 84px;
	position: relative;
	width: 100%;
	height: var(--srr-play);
	margin-top: 18px;
}

.srr-controls > span { display: none; }

.srr-play {
	position: absolute;
	top: 0;
	left: calc(var(--srr-focus) - var(--srr-play) / 2);
	width: var(--srr-play);
	height: var(--srr-play);
	padding: 0;
	border-radius: 50%;
	color: var(--srr-fg) !important;
	transition: transform 0.12s ease, opacity 0.15s;
}

.srr-play:hover { transform: scale(1.05); }
.srr-play:active { transform: scale(0.96); }
.srr-play .srr-icon { width: 100%; height: 100%; display: block; }

.srr-gear {
	position: absolute;
	top: calc(50% - 22px);
	left: calc(var(--srr-focus) + var(--srr-play) / 2 + 24px);
	width: 44px;
	height: 44px;
	display: grid;
	place-items: center;
	border-radius: 50%;
	color: var(--srr-muted) !important;
	transition: color 0.15s, transform 0.3s;
}

.srr-gear:hover,
.srr-gear[aria-expanded="true"] { color: var(--srr-fg) !important; }
.srr-gear[aria-expanded="true"] { transform: rotate(45deg); }
.srr-gear svg { width: 28px; height: 28px; }

/* ---- Speed slider, with the value riding under the thumb ---- */

.srr-speed {
	position: relative;
	/* Centred on the focus letter too, as wide as fits either side of it. */
	align-self: flex-start;
	width: min(480px, calc(var(--srr-focus) * 2));
	margin-left: calc(var(--srr-focus) - min(240px, var(--srr-focus)));
	padding-bottom: 30px;
	--srr-thumb: 46px;
}

.srr-range {
	-webkit-appearance: none;
	appearance: none;
	display: block;
	width: 100%;
	height: 28px;
	margin: 0;
	padding: 0;
	background: transparent;
	cursor: pointer;
}

.srr-range::-webkit-slider-runnable-track {
	height: 14px;
	border-radius: 999px;
	background: var(--srr-rule);
}

.srr-range::-moz-range-track {
	height: 14px;
	border-radius: 999px;
	background: var(--srr-rule);
}

.srr-range::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: var(--srr-thumb);
	height: 26px;
	margin-top: -6px;
	border: 0;
	border-radius: 999px;
	background: var(--srr-fg);
}

.srr-range::-moz-range-thumb {
	width: var(--srr-thumb);
	height: 26px;
	border: 0;
	border-radius: 999px;
	background: var(--srr-fg);
}

.srr-wpm {
	position: absolute;
	bottom: 0;
	left: calc(var(--srr-thumb) / 2 + var(--srr-speed) * (100% - var(--srr-thumb)));
	transform: translateX(-50%);
	font-size: 16px;
	font-variant-numeric: tabular-nums;
	color: var(--srr-muted);
	white-space: nowrap;
}

/* ---- Settings card ---- */

.srr-settings {
	/* Centred between 16px from the top and 18% from the bottom, so it sits
	   high on the screen; margin:auto + fit-content does the centring. */
	position: absolute;
	top: 16px;
	bottom: 18%;
	left: 0;
	right: 0;
	height: fit-content;
	margin: auto;
	width: min(440px, calc(100% - 32px));
	max-height: calc(82% - 16px);
	overflow-y: auto;
	padding: 18px 20px 14px;
	border: 1px solid var(--srr-rule);
	border-radius: 14px;
	background: var(--srr-card);
	color: var(--srr-fg);
	box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
	font-size: 15px;
}

.srr-settings[hidden] { display: none; }

.srr-settings-open .srr-stage { opacity: 0.25; pointer-events: none; }

.srr-settings-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 6px;
}

.srr-settings-head strong { font-size: 16px; }

.srr-settings-done {
	padding: 6px 12px !important;
	border-radius: 999px;
	background: var(--srr-fg) !important;
	color: var(--srr-bg) !important;
	font-size: 14px !important;
	font-weight: 600 !important;
}

.srr-field {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	padding: 11px 0;
	border-top: 1px solid var(--srr-rule);
	margin: 0;
	font-weight: 400;
	color: inherit;
}

.srr-field:first-child { border-top: 0; }

.srr-field-label {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.srr-field-label small {
	font-size: 12px;
	color: var(--srr-muted);
}

.srr-field-switch { cursor: pointer; }

.srr-num {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
	color: var(--srr-muted);
	font-size: 13px;
	white-space: nowrap;
}

.srr-num input {
	width: 64px;
	height: 34px;
	margin: 0;
	padding: 4px 8px;
	border: 1px solid var(--srr-rule);
	border-radius: 8px;
	background: var(--srr-bg);
	color: var(--srr-fg);
	font-size: 15px;
	text-align: center;
	box-shadow: none;
}

.srr-swatches {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-shrink: 0;
}

.srr-swatch {
	width: 22px;
	height: 22px;
	padding: 0 !important;
	border-radius: 50% !important;
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15) !important;
}

.srr-swatches input[type="color"] {
	width: 30px;
	height: 26px;
	margin: 0;
	padding: 0;
	border: 1px solid var(--srr-rule);
	border-radius: 6px;
	background: none;
	cursor: pointer;
}

.srr-seg {
	display: inline-flex;
	flex-shrink: 0;
	padding: 3px;
	border-radius: 999px;
	background: var(--srr-bg);
	border: 1px solid var(--srr-rule);
}

.srr-seg button {
	padding: 6px 12px !important;
	border-radius: 999px;
	font-size: 13px !important;
	color: var(--srr-muted) !important;
}

.srr-seg button[aria-checked="true"] {
	background: var(--srr-fg) !important;
	color: var(--srr-bg) !important;
}

.srr-switch {
	-webkit-appearance: none;
	appearance: none;
	position: relative;
	flex-shrink: 0;
	width: 42px;
	height: 24px;
	margin: 0;
	border-radius: 999px;
	background: var(--srr-rule);
	cursor: pointer;
	transition: background 0.15s;
}

.srr-switch::after {
	content: '';
	position: absolute;
	top: 3px;
	left: 3px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #fff;
	transition: transform 0.15s;
}

.srr-switch:checked { background: var(--srr-pivot); }
.srr-switch:checked::after { transform: translateX(18px); }

.srr-settings-foot {
	padding-top: 8px;
	border-top: 1px solid var(--srr-rule);
	text-align: right;
}

.srr-link {
	padding: 4px 0 !important;
	font-size: 13px !important;
	color: var(--srr-muted) !important;
	text-decoration: underline !important;
}

/* ---- Small screens ---- */

@media (max-width: 600px) {
	.srr-overlay { padding: 52px 16px 24px; }
	.srr-stage { gap: 22px; }
	.srr-rule::after { height: 16px; }
	.srr-controls { --srr-play: 72px; margin-top: 12px; }
	.srr-where { font-size: 13px; bottom: -24px; }
}

@media (max-height: 460px) {
	.srr-overlay { padding-top: 44px; padding-bottom: 12px; }
	.srr-stage { gap: 12px; }
	.srr-controls { --srr-play: 60px; margin-top: 4px; }
	.srr-settings { bottom: 16px; max-height: calc(100% - 32px); }
}

/* ---- Where reading stopped, after closing ---- */

.srr-here {
	animation: srr-here 2.2s ease-out;
	border-radius: 4px;
}

@keyframes srr-here {
	0%, 35% { box-shadow: 0 0 0 6px rgba(229, 72, 59, 0.28); background-color: rgba(229, 72, 59, 0.10); }
	100% { box-shadow: 0 0 0 6px rgba(229, 72, 59, 0); background-color: transparent; }
}

/* ---- [speed_reader] button ---- */

.srr-start {
	display: inline-flex;
	align-items: center;
	gap: 0.5em;
	margin: 0 0 1em;
	padding: 0.45em 1em 0.45em 0.5em;
	border: 0;
	border-radius: 999px;
	background: #111;
	color: #fff;
	font: inherit;
	font-size: 0.95em;
	line-height: 1.2;
	cursor: pointer;
	text-transform: none;
	letter-spacing: normal;
	min-height: 0;
}

.srr-start:hover { background: #000; color: #fff; }
.srr-start .srr-icon { width: 1.7em; height: 1.7em; flex-shrink: 0; }

/* ---- "Speed read from here" chip on selected text ---- */

.srr-chip {
	position: absolute;
	z-index: 99980;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin: 0;
	padding: 6px 12px 6px 6px;
	border: 0;
	border-radius: 999px;
	background: #111;
	color: #fff;
	font: 600 13px/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
	cursor: pointer;
	text-transform: none;
	letter-spacing: normal;
	min-height: 0;
}

.srr-chip[hidden] { display: none; }
.srr-chip .srr-icon { width: 22px; height: 22px; }

/* ---- Lil Red Wagon: a verse number becomes a play button on hover ---- */

/* The pill is already absolutely positioned, so it anchors the icon. */
.srr-lrw-v1 #lrw-reading .lrw-verse > .lrw-verse-num {
	cursor: pointer;
}

.srr-lrw-v1 #lrw-reading .lrw-verse > .lrw-verse-num::after {
	content: '';
	position: absolute;
	left: 50%;
	top: 50%;
	width: 1.6em;
	height: 1.6em;
	transform: translate(-50%, -50%) scale(0.6);
	opacity: 0;
	pointer-events: none;
	background: var(--lrw-accent, #c0392b);
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 1200'%3E%3Cpath d='M602.6,41.5C293.9,41.5,43.7,291.7,43.7,600.3s250.2,558.8,558.8,558.8,558.8-250.2,558.8-558.8S911.2,41.5,602.6,41.5ZM996.7,604.4c-2.7,12.9-12,24.9-24.4,31.8h0s-424.8,234.4-424.8,234.4c-8.6,4.8-18.1,6.6-26.6,5.3-8.6-1.3-15.7-5.8-20.1-12.6-4.4-6.8-5.8-15.5-3.9-24.4l15.5-73-189.9,104.8c-8.6,4.8-18.1,6.6-26.6,5.3-8.6-1.3-15.7-5.8-20.1-12.6-4.4-6.8-5.8-15.5-3.9-24.4l99.6-468.7c1.9-9,7-17.6,14.2-24.4,7.3-6.8,16.3-11.3,25.5-12.6,9.2-1.4,17.8.5,24.4,5.3l145.4,104.8,15.5-73c1.9-9,7-17.6,14.2-24.4,7.3-6.8,16.3-11.3,25.5-12.6,9.2-1.4,17.8.5,24.4,5.3l325.2,234.4c9.5,6.9,13.6,18.9,10.9,31.8Z'/%3E%3Cpolygon points='641.7 510.6 586.3 771.1 888.5 604.3 657.2 437.6 641.7 510.6'/%3E%3Cpolygon points='361.3 771.1 531.2 677.3 562.3 531.4 432.2 437.6 361.3 771.1'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 1200'%3E%3Cpath d='M602.6,41.5C293.9,41.5,43.7,291.7,43.7,600.3s250.2,558.8,558.8,558.8,558.8-250.2,558.8-558.8S911.2,41.5,602.6,41.5ZM996.7,604.4c-2.7,12.9-12,24.9-24.4,31.8h0s-424.8,234.4-424.8,234.4c-8.6,4.8-18.1,6.6-26.6,5.3-8.6-1.3-15.7-5.8-20.1-12.6-4.4-6.8-5.8-15.5-3.9-24.4l15.5-73-189.9,104.8c-8.6,4.8-18.1,6.6-26.6,5.3-8.6-1.3-15.7-5.8-20.1-12.6-4.4-6.8-5.8-15.5-3.9-24.4l99.6-468.7c1.9-9,7-17.6,14.2-24.4,7.3-6.8,16.3-11.3,25.5-12.6,9.2-1.4,17.8.5,24.4,5.3l145.4,104.8,15.5-73c1.9-9,7-17.6,14.2-24.4,7.3-6.8,16.3-11.3,25.5-12.6,9.2-1.4,17.8.5,24.4,5.3l325.2,234.4c9.5,6.9,13.6,18.9,10.9,31.8Z'/%3E%3Cpolygon points='641.7 510.6 586.3 771.1 888.5 604.3 657.2 437.6 641.7 510.6'/%3E%3Cpolygon points='361.3 771.1 531.2 677.3 562.3 531.4 432.2 437.6 361.3 771.1'/%3E%3C/svg%3E") center / contain no-repeat;
	transition: opacity 0.15s, transform 0.15s;
}

.srr-lrw-v1 #lrw-reading .lrw-verse > .lrw-verse-num:hover {
	color: transparent;
}

.srr-lrw-v1 #lrw-reading .lrw-verse > .lrw-verse-num:hover::after {
	opacity: 1;
	transform: translate(-50%, -50%) scale(1);
}

/* While open, the page underneath must not scroll behind it. Only the root:
   overflow on <body> too would make it a scroll container and un-stick
   sticky headers such as Lil Red Wagon's top bar. */
html.srr-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
	.srr-overlay *,
	.srr-here { transition: none !important; animation: none !important; }
}
