/* Chapter reader — premium editorial layout: centered column, readable measure, scroll for wide tables */

.chapter-reader {
	--cr-muted: #64748b;
	--cr-ink: #0f172a;
	--cr-accent: #4f46e5;
	--cr-accent-soft: rgba(79, 70, 229, 0.08);
	/* Outer shell: comfortable column on large screens */
	--cr-shell-max: min(56rem, 100%);
	/* Inner prose measure (slightly wider than 65ch for tables) */
	--cr-read-max: min(46rem, 100%);
	width: 100%;
	max-width: var(--cr-shell-max);
	margin-inline: auto;
	padding: 0 0 3.5rem;
	box-sizing: border-box;
}

.chapter-reader--public {
	max-width: var(--cr-shell-max);
	width: 100%;
	margin-inline: auto;
	padding: 7rem clamp(1rem, 3vw, 1.75rem) 3.5rem;
	box-sizing: border-box;
}

.chapter-reader__top {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem 1.25rem;
	margin-bottom: 1.5rem;
	padding-bottom: 1rem;
	border-bottom: 1px solid rgba(226, 232, 240, 0.95);
}

.chapter-reader__back {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	font-size: 0.8125rem;
	font-weight: 600;
	color: var(--cr-muted);
	text-decoration: none;
	transition: color 0.15s ease;
}

.chapter-reader__back:hover {
	color: var(--cr-accent);
}

.student-hub-shell .chapter-reader__back {
	color: #0d9488;
}

.student-hub-shell .chapter-reader__back:hover {
	color: #0f766e;
}

.chapter-reader__progress {
	font-size: 0.6875rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--cr-muted);
}

.chapter-reader__title {
	margin: 0 0 1.25rem;
	max-width: var(--cr-read-max);
	font-size: clamp(1.375rem, 2.8vw, 1.875rem);
	font-weight: 800;
	letter-spacing: -0.035em;
	line-height: 1.18;
	color: var(--cr-ink);
}

.chapter-reader__status {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 0.75rem;
	margin-bottom: 1.5rem;
	max-width: var(--cr-read-max);
}

.chapter-reader__status .student-btn-primary,
.chapter-reader__status .student-btn-secondary {
	font-size: 0.8125rem;
	padding: 0.45rem 0.9rem;
}

.chapter-reader__banner {
	margin-bottom: 1.5rem;
	max-width: var(--cr-read-max);
	padding: 1rem 1.2rem;
	border-radius: 0.875rem;
	background: linear-gradient(135deg, #fffbeb 0%, #fff7ed 100%);
	border: 1px solid #fde68a;
	font-size: 0.875rem;
	line-height: 1.6;
	color: #78350f;
	box-shadow: 0 1px 0 rgba(255, 255, 255, 0.75) inset;
}

.chapter-reader__banner p {
	margin: 0;
}

.chapter-reader__banner p + p {
	margin-top: 0.5rem;
}

.chapter-reader__banner-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-top: 0.85rem;
}

.chapter-reader__article {
	margin-top: 0.25rem;
	padding: clamp(1.25rem, 2.4vw, 2rem) clamp(1rem, 2.5vw, 1.75rem);
	border-radius: 1rem;
	border: 1px solid #e2e8f0;
	background: #fff;
	box-shadow:
		0 1px 0 rgba(255, 255, 255, 0.92) inset,
		0 1px 2px rgba(15, 23, 42, 0.04),
		0 18px 48px -32px rgba(15, 23, 42, 0.14);
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.chapter-reader__article .ebook-prose {
	/* Restore editorial measure (chapter-reader loads after tutorial-content.css) */
	max-width: var(--cr-read-max);
	width: 100%;
	margin-inline: auto;
	font-size: 1.0625rem;
	line-height: 1.82;
	font-feature-settings: "kern" 1, "liga" 1;
}

/* Wide tables / pre from HTML editors: allow natural width; panel scrolls horizontally */
.chapter-reader__article .ebook-prose :where(table, pre) {
	max-width: none;
}

.chapter-reader__empty {
	text-align: center;
	padding: 3rem 1rem;
	font-size: 0.9375rem;
	color: var(--cr-muted);
}

.chapter-reader__nav {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.75rem;
	margin-top: 2.5rem;
	padding-top: 2rem;
	border-top: 1px solid #e2e8f0;
}

@media (min-width: 640px) {
	.chapter-reader__nav {
		gap: 1rem;
	}
}

.chapter-reader__nav-link {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	padding: 1rem 1.15rem;
	border-radius: 0.875rem;
	background: #f8fafc;
	border: 1px solid rgba(226, 232, 240, 0.9);
	text-decoration: none;
	color: var(--cr-ink);
	transition: background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
	min-height: 4.5rem;
	justify-content: center;
}

.chapter-reader__nav-link:hover {
	background: var(--cr-accent-soft);
	box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
	border-color: rgba(199, 210, 254, 0.8);
}

.chapter-reader__nav-link--next {
	text-align: end;
	align-items: flex-end;
	background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 100%);
	border-color: rgba(199, 210, 254, 0.5);
}

.chapter-reader__nav-link--next:hover {
	background: linear-gradient(135deg, #e0e7ff 0%, #eef2ff 100%);
}

.student-hub-shell .chapter-reader__nav-link--next {
	background: linear-gradient(135deg, #ecfdf5 0%, #f8fafc 100%);
	border-color: rgba(167, 243, 208, 0.55);
}

.student-hub-shell .chapter-reader__nav-link--next:hover {
	background: linear-gradient(135deg, #d1fae5 0%, #ecfdf5 100%);
}

.chapter-reader__nav-kicker {
	font-size: 0.6875rem;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--cr-muted);
}

.chapter-reader__nav-link--next .chapter-reader__nav-kicker {
	color: var(--cr-accent);
}

.student-hub-shell .chapter-reader__nav-link--next .chapter-reader__nav-kicker {
	color: #0d9488;
}

.chapter-reader__nav-title {
	font-size: 0.9375rem;
	font-weight: 600;
	line-height: 1.35;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.chapter-reader__nav-placeholder {
	grid-column: 1 / -1;
	text-align: center;
	font-size: 0.875rem;
	color: var(--cr-muted);
	padding: 0.5rem;
}

.chapter-reader__outline {
	display: block;
	text-align: center;
	margin-top: 1.5rem;
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--cr-muted);
	text-decoration: none;
	max-width: var(--cr-read-max);
	margin-inline: auto;
}

.chapter-reader__outline:hover {
	color: var(--cr-accent);
}

.student-hub-shell .chapter-reader__outline:hover {
	color: #0d9488;
}
