/* SJ Learn Reading Ruler — optional unjust line gutter */

.sjl-reading-ruler-toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	margin: 0 0 12px;
	padding: 6px 12px;
	font-size: 0.8125rem;
	font-weight: 600;
	line-height: 1.2;
	color: var(--color-primary, #2563eb);
	background: var(--color-bg_secondary, #f1f5f9);
	border: 1px solid var(--color-border, #cbd5e1);
	border-radius: 6px;
	cursor: pointer;
}

.sjl-reading-ruler-toggle:hover,
.sjl-reading-ruler-toggle[aria-pressed="true"] {
	background: var(--color-primary, #2563eb);
	color: #fff;
	border-color: var(--color-primary, #2563eb);
}

.sjl-reading-ruler-layout {
	display: flex;
	align-items: flex-start;
	gap: 0;
	width: 100%;
}

.sjl-reading-ruler {
	flex: 0 0 2.75rem;
	width: 2.75rem;
	user-select: none;
	pointer-events: auto;
	border-right: 2px solid var(--color-border, #94a3b8);
	background: linear-gradient(
		to bottom,
		rgba(148, 163, 184, 0.08) 0%,
		rgba(148, 163, 184, 0.04) 100%
	);
}

.sjl-reading-ruler__inner {
	position: relative;
	width: 100%;
}

.sjl-reading-ruler__line {
	box-sizing: border-box;
	display: flex;
	align-items: flex-start;
	justify-content: flex-end;
	gap: 2px;
	padding-right: 4px;
	border-bottom: 1px solid rgba(148, 163, 184, 0.35);
	cursor: pointer;
}

.sjl-reading-ruler__line:hover {
	background: rgba(37, 99, 235, 0.08);
}

.sjl-reading-ruler__line.is-bookmarked {
	background: rgba(234, 179, 8, 0.18);
}

.sjl-reading-ruler__line.is-selected {
	background: rgba(37, 99, 235, 0.16);
}

.sjl-reading-ruler__mark {
	flex: 0 0 auto;
	font-size: 0.55rem;
	font-weight: 700;
	line-height: 1;
	color: #b45309;
	margin-top: 2px;
}

.sjl-reading-ruler__num {
	font-size: 0.65rem;
	font-weight: 600;
	line-height: 1;
	color: var(--color-text_secondary, #64748b);
	font-variant-numeric: tabular-nums;
}

.sjl-reading-ruler__content {
	flex: 1 1 auto;
	min-width: 0;
}

/*
 * Zoom-stable wrap: lock lesson text to a shared character measure while the ruler
 * is on so teacher/student wrapping (and line numbers) stay aligned across zoom.
 */
html.sjl-reading-ruler-active .sjl-reading-ruler__content,
html.sjl-reading-ruler-active .sjl-reading-ruler__content .lesson-description {
	max-width: 68ch;
	box-sizing: border-box;
}

/* Text size: center the ruler + lesson. The measure stays 68ch. */
.sjl-reading-size-slot {
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 100%;
}

.sjl-reading-size {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin: 0 0 10px;
	padding: 4px;
	border: 1px solid var(--color-border, #cbd5e1);
	border-radius: 999px;
	background: #fff;
}

.sjl-reading-size__btn {
	min-width: 36px;
	height: 28px;
	padding: 0 8px;
	border: 0;
	border-radius: 999px;
	background: var(--color-bg_secondary, #f1f5f9);
	color: var(--color-primary, #2563eb);
	font-size: 13px;
	font-weight: 700;
	line-height: 1;
	cursor: pointer;
}

.sjl-reading-size__btn:hover:not(:disabled) {
	background: var(--color-primary, #2563eb);
	color: #fff;
}

.sjl-reading-size__btn:disabled {
	opacity: 0.4;
	cursor: default;
}

.sjl-reading-size__value {
	min-width: 3.2em;
	text-align: center;
	font-size: 12px;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	color: #334155;
}

html.sjl-reading-ruler-active .sjl-reading-ruler-layout[data-sjl-size-mode="measure"] {
	width: max-content;
	max-width: none;
	margin-inline: auto;
}

html.sjl-reading-ruler-active .sjl-reading-ruler-layout[data-sjl-size-mode="measure"] .sjl-reading-ruler__content {
	flex: 0 0 auto;
	width: 68ch;
	max-width: 68ch;
}

/*
 * Teacher "match student" mode: when force-for-student is on, park Teaching Notes
 * (teacher-only) inside .lesson-description. Keep Paragraph Notes widgets visible —
 * students see those too, so hiding them skews numbers the other way.
 * Viewing-as / progress bars hooked before the summary are already outside this wrap.
 */
html.sjl-reading-ruler-match-student .lesson-description .sjl-teacher-lesson-notes-wrapper,
html.sjl-reading-ruler-match-student .sjl-reading-ruler__content .sjl-teacher-lesson-notes-wrapper {
	display: none !important;
}

/* Hide layout chrome when toggle off (content stays unwrapped) */
html:not(.sjl-reading-ruler-active) .sjl-reading-ruler-layout {
	display: block;
}

html:not(.sjl-reading-ruler-active) .sjl-reading-ruler {
	display: none;
}

@media (max-width: 640px) {
	.sjl-reading-ruler {
		flex: 0 0 2.25rem;
		width: 2.25rem;
	}

	.sjl-reading-ruler__num {
		font-size: 0.6rem;
	}

	/* Phones: do not force a wider measure than the viewport. */
	html.sjl-reading-ruler-active .sjl-reading-ruler-layout,
	html.sjl-reading-ruler-active .sjl-reading-ruler-layout[data-sjl-size-mode="measure"] {
		width: 100%;
		max-width: none;
	}

	html.sjl-reading-ruler-active .sjl-reading-ruler__content,
	html.sjl-reading-ruler-active .sjl-reading-ruler__content .lesson-description,
	html.sjl-reading-ruler-active .sjl-reading-ruler-layout[data-sjl-size-mode="measure"] .sjl-reading-ruler__content {
		width: auto;
		max-width: none;
		flex: 1 1 auto;
	}
}

/* Shared bookmarks panel (dock under Reading ruler) */
.sjl-ruler-bm {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 10px 12px;
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	background: #f8fafc;
}

.sjl-ruler-bm__title {
	font-size: 13px;
	font-weight: 700;
	color: #0f172a;
}

.sjl-ruler-bm__hint,
.sjl-ruler-bm__empty {
	margin: 0;
	font-size: 12px;
	line-height: 1.35;
	color: #64748b;
}

.sjl-ruler-bm__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
	max-height: 160px;
	overflow: auto;
}

.sjl-ruler-bm__pick {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 6px;
	width: 100%;
	padding: 6px 8px;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	background: #fff;
	cursor: pointer;
	text-align: left;
	font: inherit;
}

.sjl-ruler-bm__item.is-active .sjl-ruler-bm__pick,
.sjl-ruler-bm__pick:hover {
	border-color: #93c5fd;
	background: #eff6ff;
}

.sjl-ruler-bm__line {
	font-size: 12px;
	font-weight: 700;
	color: #2563eb;
}

.sjl-ruler-bm__preview {
	flex: 1 1 auto;
	font-size: 12px;
	color: #334155;
}

.sjl-ruler-bm__author {
	font-size: 11px;
	color: #94a3b8;
}

.sjl-ruler-bm__label {
	display: block;
	font-size: 12px;
	font-weight: 600;
	color: #475569;
	margin-bottom: 4px;
}

.sjl-ruler-bm__note {
	width: 100%;
	box-sizing: border-box;
	padding: 8px;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	font: inherit;
	font-size: 13px;
	resize: vertical;
	min-height: 64px;
}

.sjl-ruler-bm__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 8px;
}

.sjl-ruler-bm__btn {
	padding: 6px 10px;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	background: #fff;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
}

.sjl-ruler-bm__btn--primary {
	border-color: #2563eb;
	background: #2563eb;
	color: #fff;
}

.sjl-ruler-bm__btn--danger {
	border-color: #fecaca;
	color: #b91c1c;
}
