/* =========================================================
   Lesson player — tone colors (extend the shared palette
   from css/style.css without touching its variables)
   ========================================================= */
:root {
	--tone-info-bg: var(--blue-soft);
	--tone-info-border: var(--blue);
	--tone-info-text: var(--accent-text);

	--tone-warning-bg: #fdf3e0;
	--tone-warning-border: #c9861a;
	--tone-warning-text: #7a5210;

	--tone-success-bg: var(--teal-soft);
	--tone-success-border: var(--teal);
	--tone-success-text: var(--teal-dark);

	--tone-danger-bg: #fbe8e8;
	--tone-danger-border: #c94343;
	--tone-danger-text: #8a2323;
}

/* Pin the lesson page to the viewport height (scoped here, not in the
   shared body rule in style.css) so the flex column below has a real
   height to divide between the progress bar, the stage, and the nav
   buttons — that's what keeps the nav buttons on screen without scrolling.
   overflow-y stays auto as a safety net for a viewport too short to fit
   everything. The mobile breakpoint below undoes this in favor of normal
   page scrolling, since a phone-height 16:9 box is too cramped to use. */
body.lesson-page {
	height: 100vh;
	height: 100dvh;
	overflow-y: auto;
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ---- Compact lesson header ----
   Same brand sizing/height as the homepage .navbar so the two headers read
   as one site; only the link/control set on the right is simplified. */
.lesson-header-bar {
	padding: 0.1rem 1rem;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	flex-wrap: wrap;
}

.lesson-header-actions {
	display: flex;
	align-items: center;
	gap: 1.25rem;
	flex-wrap: wrap;
}

/* ---- Lesson main / stage shell ----
   align-items: center lets the progress bar and nav row be narrower than
   the full column (see .lesson-progress-section / .lesson-nav below) and
   sit centered instead of stretched — that's what keeps them lined up
   with the stage box's left/right edges once JS narrows them to match. */
.lesson-main {
	width: 100%;
	max-width: 100rem;
	margin: 0 auto;
	padding: clamp(1rem, 3vh, 2rem) 1.5rem;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0;
	flex: 1 1 auto;
	min-height: 0;
}

/* Default to full width so there's no flash-of-narrow before the
   ResizeObserver in lesson-player.js measures the stage and sets an
   inline px width to match it exactly (its own width is derived from
   available height, not knowable from CSS alone — see .lesson-stage). */
.lesson-progress {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	flex-shrink: 0;
	width: 100%;
	padding: 1.25rem 1.75rem;
	background: var(--card-bg);
	border: 1px solid var(--card-border);
	border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* [hidden] ties in specificity with the class rules above/below and loses to
   whichever was declared later, so it needs an explicit override here. */
.lesson-progress[hidden],
.lesson-nav[hidden] {
	display: none;
}

.lesson-progress-top {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
}

.lesson-title {
	margin: 0;
	font-family: var(--font-display);
	font-size: 1.3rem;
	font-weight: 500;
	letter-spacing: -0.015em;
	color: var(--text-primary);
}

.lesson-position {
	flex-shrink: 0;
	font-size: 0.8125rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	color: var(--text-secondary);
	background: var(--surface-soft);
	border: 1px solid var(--border-default);
	padding: 0.3rem 0.7rem;
	border-radius: var(--radius-pill);
}

.progress-track {
	height: 0.35rem;
	border-radius: 999px;
	background: var(--blue-soft);
	overflow: hidden;
}

.progress-fill {
	height: 100%;
	width: 0%;
	border-radius: inherit;
	background: var(--primary-button-bg);
	transition: width 0.25s ease;
}

/* ---- Slide stage ----
   Fixed 16:9 box that always fits on screen with the nav buttons, without
   scrolling the page. .lesson-stage is a flex item that grows/shrinks
   (flex: 1 1 auto) to fill whatever vertical space is left after the
   progress bar and nav row take theirs; align-self: center takes it out
   of the default stretch behavior so its width is "auto" and gets derived
   from that resolved height via aspect-ratio, capped by max-width so it
   never overflows a wide viewport either. The box's own size never
   depends on how much content is on the slide — content that doesn't fit
   scrolls inside the box (overflow-y) instead of growing it. The mobile
   breakpoint below drops all of this in favor of a full-width, natural-
   height card, since a phone-height 16:9 box is too cramped to use. */
.lesson-stage {
	background: var(--card-bg);
	border: 1px solid var(--card-border);
	border-top: 0;
	border-bottom: 0;
	box-shadow: var(--shadow-md);
	padding: clamp(1.5rem, 3vw, 2.5rem);
	scrollbar-width: thin;
	scrollbar-color: var(--border-default) transparent;
	box-sizing: border-box;
	flex: 1 1 auto;
	min-height: 0;
	align-self: center;
	width: auto;
	max-width: 100%;
	aspect-ratio: 16 / 9;
	overflow-y: auto;
}

.lesson-stage:focus-visible {
	outline: 3px solid var(--focus);
	outline-offset: 4px;
}

.lesson-loading {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	padding: 3rem 1rem;
	color: var(--text-muted);
	text-align: center;
}

.spinner {
	width: 2.5rem;
	height: 2.5rem;
	border-radius: 50%;
	border: 0.3rem solid var(--card-border);
	border-top-color: var(--blue);
	animation: spin 0.8s linear infinite;
}

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

/* ---- Fatal / inline error views ---- */
.lesson-error {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 1rem;
	text-align: center;
	padding: 2rem 1rem;
}

.lesson-error-icon {
	font-size: 2.5rem;
}

.lesson-error h2 {
	margin: 0;
	color: var(--blue-dark);
	font-family: var(--font-display);
}

.lesson-error p {
	margin: 0;
	max-width: 32rem;
	color: var(--text-muted);
}

.lesson-error-actions {
	display: flex;
	gap: 0.75rem;
	flex-wrap: wrap;
	justify-content: center;
	margin-top: 0.5rem;
}

.inline-notice {
	display: flex;
	align-items: flex-start;
	gap: 0.6rem;
	background: var(--tone-warning-bg);
	border: 1px solid var(--tone-warning-border);
	color: var(--tone-warning-text);
	border-radius: var(--radius-sm);
	padding: 0.85rem 1rem;
	font-size: 0.9375rem;
	margin: 0.75rem 0;
}

/* ---- Title slide ---- */
.slide-title-page {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: 1rem;
	min-height: 100%;
	justify-content: center;
}

.slide-cover {
	width: 100%;
	max-width: 22rem;
	aspect-ratio: 16 / 9;
	border-radius: var(--radius-md);
	overflow: hidden;
	background: var(--surface-soft);
	display: flex;
	align-items: center;
	justify-content: center;
	margin-bottom: 0.25rem;
}

.slide-cover img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.slide-cover.is-placeholder img {
	width: 5rem;
	height: 5rem;
	object-fit: contain;
}

.slide-title-page h2 {
	margin: 0;
	font-family: var(--font-display);
	font-size: clamp(1.7rem, 3.4vw, 2.4rem);
	font-weight: 500;
	letter-spacing: -0.025em;
	color: var(--text-primary);
	line-height: 1.15;
}

.slide-subtitle {
	margin: 0;
	max-width: 34rem;
	color: var(--text-muted);
	font-size: 1.0625rem;
}

.slide-meta {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.5rem;
	margin: 0.25rem 0 0.5rem;
}

.slide-meta-pill {
	background: var(--accent-soft);
	color: var(--accent-text);
	border-radius: var(--radius-pill);
	padding: 0.3rem 0.85rem;
	font-size: 0.8125rem;
	font-weight: 600;
	text-transform: capitalize;
}

/* ---- Content slide ---- */
.slide-content h2.slide-heading {
	margin: 0 0 0.5rem;
	font-family: var(--font-display);
	font-size: clamp(1.5rem, 2.6vw, 2rem);
	font-weight: 500;
	letter-spacing: -0.025em;
	line-height: 1.25;
	color: var(--text-primary);
	max-width: 38rem;
}

.slide-content {
	max-width: 40rem;
	margin: 0 auto;
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.block-heading {
	margin: 0.5rem 0 0;
	font-size: 1.125rem;
	font-weight: 700;
	color: var(--blue-dark);
}

.block-link {
	margin: 0;
	font-size: 1.0625rem;
}

.block-link-anchor {
	display: inline-flex;
	align-items: baseline;
	gap: 0.35rem;
	font-weight: 600;
	color: var(--accent-text);
	text-decoration: underline;
	text-underline-offset: 0.2em;
	overflow-wrap: anywhere;
}

.block-link-anchor:hover {
	text-decoration-thickness: 2px;
}

.block-link-icon {
	font-size: 0.9em;
	text-decoration: none;
}

.block-paragraph {
	margin: 0;
	font-size: 1.0625rem;
	line-height: 1.65;
}

.block-list {
	margin: 0;
	padding-left: 1.4rem;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	font-size: 1.0625rem;
	line-height: 1.55;
}

.block-callout {
	display: flex;
	gap: 0.65rem;
	align-items: flex-start;
	border-radius: var(--radius-sm);
	border: 0;
	border-left: 3px solid;
	padding: 1rem 1.25rem;
	font-size: 1rem;
	line-height: 1.55;
}

.block-callout .callout-icon {
	flex-shrink: 0;
	font-size: 1.15rem;
	line-height: 1;
	margin-top: 0.1rem;
}

.block-callout .callout-body {
	display: flex;
	flex-direction: column;
	gap: 0.2rem;
}

.block-callout .callout-label {
	font-weight: 700;
	font-size: 0.8125rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.tone-info {
	background: var(--tone-info-bg);
	border-color: var(--tone-info-border);
	color: var(--tone-info-text);
}

.tone-warning {
	background: var(--tone-warning-bg);
	border-color: var(--tone-warning-border);
	color: var(--tone-warning-text);
}

.tone-success {
	background: var(--tone-success-bg);
	border-color: var(--tone-success-border);
	color: var(--tone-success-text);
}

.tone-danger {
	background: var(--tone-danger-bg);
	border-color: var(--tone-danger-border);
	color: var(--tone-danger-text);
}

.block-figure {
	margin: 0;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	align-items: center;
}

.block-figure img,
.block-figure video {
	max-width: 100%;
	width: 100%;
	height: auto;
	border-radius: var(--radius-md);
	display: block;
	background: var(--blue-soft);
}

.block-figure figcaption {
	font-size: 0.875rem;
	color: var(--text-muted);
	text-align: center;
}

.video-embed {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 9;
	border-radius: var(--radius-md);
	overflow: hidden;
	background: var(--blue-soft);
}

.video-embed iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

/* ---- Knowledge check ---- */
.quiz-fieldset {
	border: none;
	margin: 0;
	padding: 0;
}

.slide-quiz-question {
	margin: 0 0 1rem;
	font-size: 1.0625rem;
	font-weight: 700;
	color: var(--text);
}

.quiz-choices {
	list-style: none;
	margin: 0 0 1.25rem;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.65rem;
}

.quiz-choice {
	display: flex;
	align-items: flex-start;
	gap: 0.85rem;
	border: 1px solid var(--border-card);
	border-radius: var(--radius-md);
	background: var(--surface-card);
	padding: 1rem 1.15rem;
	cursor: pointer;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

.quiz-choice:hover {
	border-color: var(--accent-border);
	background: var(--surface-soft);
}

/* Selected is carried by the border, the tint, and the radio itself, so it
   never depends on color alone. */
.quiz-choice.is-selected {
	border-color: var(--accent-text);
	background: var(--accent-soft);
	box-shadow: 0 0 0 1px var(--accent-text);
}

.quiz-choice input[type="radio"] {
	margin-top: 0.15rem;
	width: 1.15rem;
	height: 1.15rem;
	accent-color: var(--accent-text);
	flex-shrink: 0;
}

.quiz-choice-text {
	font-size: 1rem;
	line-height: 1.5;
}

.quiz-choice.is-disabled {
	cursor: default;
	opacity: 0.85;
}

.quiz-actions {
	display: flex;
	gap: 0.75rem;
	align-items: center;
	flex-wrap: wrap;
}

.quiz-feedback {
	margin-top: 1.1rem;
	border-radius: var(--radius-md);
	border: 1.5px solid;
	padding: 0.9rem 1.1rem;
	display: flex;
	gap: 0.65rem;
	align-items: flex-start;
}

.quiz-feedback .feedback-icon {
	font-size: 1.2rem;
	flex-shrink: 0;
}

.quiz-feedback .feedback-title {
	font-weight: 700;
	margin: 0 0 0.25rem;
}

.quiz-feedback .feedback-text {
	margin: 0;
	font-size: 0.9688rem;
	line-height: 1.5;
}

.quiz-feedback.is-correct {
	background: var(--tone-success-bg);
	border-color: var(--tone-success-border);
	color: var(--tone-success-text);
}

.quiz-feedback.is-incorrect {
	background: var(--tone-danger-bg);
	border-color: var(--tone-danger-border);
	color: var(--tone-danger-text);
}

/* ---- Completion screen ---- */
.slide-complete {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: 1rem;
	padding: 1rem 0;
}

.slide-complete .complete-icon {
	width: 4rem;
	height: 4rem;
	border-radius: 50%;
	background: var(--tone-success-bg);
	color: var(--tone-success-text);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 2rem;
}

.slide-complete h2 {
	margin: 0;
	font-family: var(--font-display);
	color: var(--blue-dark);
	font-size: 1.75rem;
}

.slide-complete p {
	margin: 0;
	max-width: 30rem;
	color: var(--text-muted);
}

.quiz-result-pass,
.quiz-result-fail {
	font-weight: 700;
}

.quiz-result-pass {
	color: var(--tone-success-text);
}

.quiz-result-fail {
	color: var(--tone-danger-text);
}

/* ---- Saved quiz result, shown on the lesson completion screen ---- */
.lesson-quiz-result {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.2rem;
	margin: 0.25rem 0 0;
	padding: 0.75rem 1.1rem;
	border-radius: var(--radius-sm);
	border: 1px solid var(--card-border);
	background: var(--blue-soft);
	max-width: 30rem;
}

.lesson-quiz-result-line {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0;
	font-size: 1rem;
	font-weight: 700;
	color: var(--text);
}

.lesson-quiz-result-detail {
	margin: 0;
	font-size: 0.9375rem;
	color: var(--text-muted);
}

.lesson-quiz-result-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.4rem;
	height: 1.4rem;
	flex-shrink: 0;
	border-radius: 50%;
	font-size: 0.875rem;
	line-height: 1;
	color: var(--card-bg);
}

.lesson-quiz-result.is-passed {
	background: var(--tone-success-bg);
	border-color: var(--tone-success-border);
}

.lesson-quiz-result.is-passed .lesson-quiz-result-line {
	color: var(--tone-success-text);
}

.lesson-quiz-result.is-passed .lesson-quiz-result-icon {
	background: var(--tone-success-border);
}

.lesson-quiz-result.is-failed {
	background: var(--tone-danger-bg);
	border-color: var(--tone-danger-border);
}

.lesson-quiz-result.is-failed .lesson-quiz-result-line {
	color: var(--tone-danger-text);
}

.lesson-quiz-result.is-failed .lesson-quiz-result-icon {
	background: var(--tone-danger-border);
}

/* ---- Footer navigation ---- */
.lesson-nav {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 1rem;
	padding: 1rem 1.75rem;
	background: var(--surface-soft);
	border: 1px solid var(--card-border);
	border-radius: 0 0 var(--radius-lg) var(--radius-lg);
	box-shadow: var(--shadow-md);
	flex-shrink: 0;
	width: 100%;
}

.lesson-nav-btn {
	min-width: 8rem;
	text-align: center;
	font-weight: 700;
}

.lesson-nav-btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
	transform: none !important;
	box-shadow: none !important;
}

/* ---- Modal (restart confirmation) ---- */
.modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(6, 10, 17, 0.55);
	backdrop-filter: blur(6px);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	z-index: 300;
}

.modal-dialog {
	background: var(--card-bg);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-md);
	padding: 1.5rem;
	max-width: 26rem;
	width: 100%;
	display: flex;
	flex-direction: column;
	gap: 0.85rem;
}

.modal-dialog h2 {
	margin: 0;
	color: var(--blue-dark);
	font-size: 1.25rem;
}

.modal-dialog p {
	margin: 0;
	color: var(--text-muted);
}

.modal-actions {
	display: flex;
	justify-content: flex-end;
	gap: 0.75rem;
	margin-top: 0.5rem;
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 640px) {
	body.lesson-page {
		height: auto;
		min-height: 100vh;
		overflow-y: visible;
	}

	.lesson-main {
		padding: 1rem 1rem 2rem;
		align-items: stretch;
		flex: 1 0 auto;
	}

	.lesson-stage {
		padding: 1.25rem;
		border-radius: 0;
		flex: 0 1 auto;
		align-self: stretch;
		width: 100%;
		aspect-ratio: auto;
		min-height: 16rem;
		overflow-y: visible;
	}

	.lesson-nav {
		padding: 1rem;
		gap: 0.75rem;
		flex-wrap: wrap;
	}

	.lesson-steps { order: -1; flex-basis: 100%; }

	.lesson-nav-btn {
		flex: 1;
		min-width: 0;
		padding: 0.75rem 1rem;
		font-size: 1.0625rem;
	}

	.quiz-choice {
		padding: 0.85rem 1rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.spinner {
		animation: none;
		border-top-color: var(--card-border);
	}

	.progress-fill {
		transition: none;
	}
}

/* Slide position markers complement the accessible progress label above. */
.lesson-steps {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 0.45rem;
}

.lesson-step {
	width: 0.4rem;
	height: 0.4rem;
	border-radius: 999px;
	background: var(--border-default);
	transition: background-color 0.2s ease, width 0.2s ease;
}

.lesson-step.is-visited { background: var(--accent-text); }
.lesson-step.is-current { width: 1.5rem; background: var(--blue); }

.lesson-nav-btn::before,
#btn-primary::after {
	content: "";
	width: 0.45rem;
	height: 0.45rem;
	border-top: 1.5px solid currentColor;
	border-right: 1.5px solid currentColor;
	transform: rotate(-135deg);
}

#btn-primary::before { content: none; }
#btn-primary::after { transform: rotate(45deg); }

.lesson-stage > :not(.lesson-loading) {
	animation: slide-appear 0.25s ease-out;
}

@keyframes slide-appear {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: translateY(0); }
}

.quiz-choice:focus-within {
	outline: 3px solid var(--focus);
	outline-offset: 3px;
}

@media (max-width: 640px) {
	.lesson-progress { padding: 1rem; }
	.lesson-progress-top { align-items: center; gap: 0.65rem; }
	.lesson-title { font-size: 1rem; }
	.lesson-position { padding: 0.25rem 0.5rem; }
}

/* Loading, completion, and error views use the stage without its chrome. */
.lesson-progress[hidden] + .lesson-stage {
	border: 1px solid var(--card-border);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-md);
}

.lesson-page .site-header,
.lesson-page .site-footer {
	flex-shrink: 0;
}

/* Player-specific controls. The palette comes from the shared tokens in
   style.css, so the player can never drift from the rest of the site. */
.lesson-main .btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.65rem;
	min-height: 44px;
	font-family: inherit;
	font-size: 0.9375rem;
	font-weight: 600;
	text-decoration: none;
	padding: 0.7rem 1.35rem;
	border-radius: var(--radius-pill);
	border: none;
	cursor: pointer;
}

.lesson-main .btn-secondary {
	background: transparent;
	color: var(--text-primary);
	border: 1px solid var(--border-default);
}

.lesson-main .btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
	transform: none;
	box-shadow: none;
}

/* =========================================================
   Dark theme: callout tones only. Surfaces, text, and accents come from the
   shared tokens in style.css.
   ========================================================= */
[data-theme="dark"] {
	--tone-info-bg: #16324a;
	--tone-info-border: #3f7fbd;
	--tone-info-text: #bcd9f2;

	--tone-warning-bg: #3a2f1a;
	--tone-warning-border: #c9942f;
	--tone-warning-text: #f0d49a;

	--tone-success-bg: #123430;
	--tone-success-border: #2f9d92;
	--tone-success-text: #8fdcd2;

	--tone-danger-bg: #3b1f22;
	--tone-danger-border: #cf5b5b;
	--tone-danger-text: #f3b2b2;
}

[data-theme="dark"] .lesson-nav {
	background: var(--card-bg);
}

[data-theme="dark"] .lesson-step {
	background: var(--border-default);
}

[data-theme="dark"] .lesson-position {
	border-color: var(--card-border);
}


