/*
 * LLC Lesson Notes: lesson page layout for the notes template.
 *
 * Every rule hangs on .llc-lesson-cols, which only this plugin's template prints, so no other
 * course or page is touched. If Thrive ever changes its markup, the worst case is a plain stacked
 * lesson page; nothing here can hide the video or the lesson.
 *
 * Layout (desktop): one grid.
 *   row 1  compact title + discussion button
 *   row 2  video (sets the row height) | notes panel (same height, scrolls inside)
 *   row 3  action bar: auto-play toggle (left) ... Previous / Mark complete / Next video (right)
 * The notes panel is absolutely filled into its cell, so it can never make the row taller than the
 * video, on any screen size. The whole block is capped so video + title + bar fit one screen.
 *
 * See CHANGELOG.md in the plugin folder for the history of this file.
 */

#theme-top-section .llc-lesson-cols {
	--llc-notes-w: clamp(280px, 24vw, 380px);
	--llc-gap: 24px;
	--llc-chrome: 280px; /* header + title + action bar + breathing room, in px */
	--llc-vh: 100vh;
	display: grid;
	grid-template-columns: minmax(0, 1fr) var(--llc-notes-w);
	column-gap: var(--llc-gap);
	row-gap: 0;
	align-items: start;
	box-sizing: border-box;
	width: 100%;
	max-width: min(1400px, max(640px, calc((var(--llc-vh) - var(--llc-chrome)) * 1.7778 + var(--llc-notes-w) + var(--llc-gap))));
	margin: 0 auto 28px;
	padding: 0;
}

@supports (height: 100dvh) {
	#theme-top-section .llc-lesson-cols { --llc-vh: 100dvh; }
}

/* The lesson page's top section ships 36px of top padding; a compact title needs less. */
html body #theme-top-section .section-content:has(> .llc-lesson-cols) {
	padding: 20px 24px 0 !important;
}

/* ---- Row 1: title ---- */
#theme-top-section .llc-lesson-cols .llc-lesson-head {
	grid-column: 1 / -1;
	grid-row: 1;
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: center;
	column-gap: 16px;
	margin: 0 0 14px;
	padding: 0;
}

#theme-top-section .llc-lesson-cols .llc-lesson-head .thrv_text_element {
	grid-column: 1;
	margin: 0;
	padding: 0;
	min-width: 0;
}

#theme-top-section .llc-lesson-cols .llc-lesson-head h1 {
	margin: 0;
	padding: 0;
	text-align: left;
	font-size: clamp(20px, 1.1vw + 12px, 30px);
	line-height: 1.2;
	letter-spacing: 0;
	text-transform: none;
}

/* The course's lesson design prints the week label above the title and a gold rule below it.
   Keep the label, shrink it, left-align it; drop the rule. */
#theme-top-section .llc-lesson-cols .llc-lesson-head h1::before {
	display: block;
	margin: 0 0 6px;
	text-align: left;
	font: 600 11px/1 Georgia, serif;
	letter-spacing: .32em;
}

#theme-top-section .llc-lesson-cols .llc-lesson-head h1::after {
	display: none;
}

/* "Join the discussion" is added by another snippet right after the title; sit it at the right. */
#theme-top-section .llc-lesson-cols .llc-lesson-head > .llc-join-discussion,
#theme-top-section .llc-lesson-cols .llc-lesson-head > .llc-btnrow {
	grid-column: 2;
	grid-row: 1;
	margin: 0 !important;
	max-width: none;
}

#theme-top-section .llc-lesson-cols .llc-lesson-head .llc-btnrow {
	flex-wrap: nowrap;
	gap: 10px;
}

#theme-top-section .llc-lesson-cols .llc-lesson-head .llc-join-discussion {
	padding: 8px 18px;
	font-size: 12px;
	white-space: nowrap;
}

/* The "Go to Next Item" pill that another snippet adds is replaced by the Next video button in the
   action bar below, so the two never show at once. */
#theme-top-section .llc-lesson-cols .llc-next-item,
#theme-top-section .llc-lesson-cols ~ .llc-next-item {
	display: none !important;
}

/* ---- Row 2: video + notes ---- */
#theme-top-section .llc-lesson-cols .llc-lesson-cols__video {
	display: contents; /* its children take part in the grid directly */
}

#theme-top-section .llc-lesson-cols .llc-lesson-cols__video > .thrv_responsive_video {
	grid-column: 1;
	grid-row: 2;
	min-width: 0;
	margin: 0;
	border-radius: 10px;
	overflow: hidden;
}

#theme-top-section .llc-lesson-cols .llc-lesson-cols__notes {
	grid-column: 2;
	grid-row: 2;
	align-self: stretch; /* exactly as tall as the video row */
	position: relative;
	min-width: 0;
	min-height: 0;
	margin: 0;
}

/* ---- The notes panel: light, quiet, one hairline ---- */
/* It fills its cell without adding to the row height, so the video alone sets the height. */
#theme-top-section .llc-lesson-cols .llc-lesson-cols__notes .llcn {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	margin: 0;
	padding: 14px 14px 12px;
	background: #FBF9F4;
	border: 1px solid #E8E1CC;
	border-radius: 12px;
	box-shadow: none;
	overflow: hidden;
}

#theme-top-section .llc-lesson-cols .llcn__title {
	flex: none;
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 10px;
	font: 700 14px/1.2 "Libre Baskerville", Georgia, serif;
	letter-spacing: .01em;
	text-align: left;
	color: #152B42;
}

/* a small gold tick before the title: the only decoration */
#theme-top-section .llc-lesson-cols .llcn__title::before {
	content: "";
	flex: none;
	width: 3px;
	height: 14px;
	border-radius: 2px;
	background: #DEBC55;
}

#theme-top-section .llc-lesson-cols .llcn__text {
	flex: 1 1 0;
	height: auto;
	min-height: 0 !important; /* overrides the shortcode's inline min-height */
	padding: 10px 12px;
	border: 1px solid #ECE6D6;
	border-radius: 8px;
	background: #fff;
	color: #1C2530;
	font-size: 15px;
	line-height: 1.65;
	resize: none;
	overflow: auto;
	box-shadow: none;
}

#theme-top-section .llc-lesson-cols .llcn__text::placeholder {
	color: #7A808A;
}

#theme-top-section .llc-lesson-cols .llcn__text:focus {
	border-color: #DEBC55;
	outline: 2px solid rgba(222, 188, 85, .55);
	outline-offset: 0;
}

#theme-top-section .llc-lesson-cols .llcn__bar {
	flex: none;
	flex-wrap: nowrap;
	align-items: center;
	gap: 8px;
	margin-top: 10px;
}

#theme-top-section .llc-lesson-cols .llcn__status {
	flex: 1 1 auto;
	min-width: 0;
	font-size: 12px;
	letter-spacing: .02em;
	color: #5B6572 !important; /* the lesson design paints spans tan; keep real contrast here */
}

#theme-top-section .llc-lesson-cols .llcn[data-state="saved"] .llcn__status {
	color: #2C7549 !important;
}

#theme-top-section .llc-lesson-cols .llcn[data-state="error"] .llcn__status {
	color: #A12020 !important;
}

#theme-top-section .llc-lesson-cols .llcn__conflict {
	flex: none;
}

/* Buttons inside the panel: small, ghost-style pills. */
#theme-top-section .llc-lesson-cols .llcn__btn {
	flex: 0 0 auto;
	min-height: 34px;
	padding: 5px 13px;
	border: 1px solid #D9D2BD;
	border-radius: 999px;
	background: transparent;
	color: #1B4759;
	font-size: 12.5px;
	white-space: nowrap;
}

#theme-top-section .llc-lesson-cols .llcn__btn:hover,
#theme-top-section .llc-lesson-cols .llcn__btn:focus-visible {
	background: #F3EEDF;
	color: #1B4759;
}

#theme-top-section .llc-lesson-cols .llcn__download-docx::before {
	content: "\2193";
	margin-right: 6px;
}

#theme-top-section .llc-lesson-cols .llcn a {
	color: #1B4759 !important;
}

/* ---- Row 3: action bar ---- */
/* Fallback position of the auto-play toggle if the script has not moved it into the bar yet. */
#theme-top-section .llc-lesson-cols > .llc-aa-toggle,
#theme-top-section .llc-lesson-cols .llc-lesson-cols__video > .llc-aa-toggle {
	grid-column: 1;
	grid-row: 3;
	justify-self: start;
	align-self: center;
	justify-content: flex-start;
	margin: 14px 0 0;
	font-size: 11px;
}

#theme-top-section .llc-lesson-cols .llc-lesson-cols__action {
	grid-column: 1 / -1;
	grid-row: 3;
	justify-self: stretch;
	align-self: center;
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	align-items: center;
	gap: 10px;
	min-width: 0;
	margin: 14px 0 0;
	pointer-events: none; /* the empty part of the bar never blocks clicks */
}

#theme-top-section .llc-lesson-cols .llc-lesson-cols__action > * {
	pointer-events: auto;
}

/* the auto-play toggle, once moved into the bar: far left */
#theme-top-section .llc-lesson-cols .llc-lesson-cols__action .llc-aa-toggle {
	grid-column: auto;
	grid-row: auto;
	margin: 0 auto 0 0;
	font-size: 11px;
	justify-content: flex-start;
}

/* Mark complete (Thrive's own button): secondary outline by default; filled on the last lesson */
#theme-top-section .llc-lesson-cols .llc-lesson-cols__action .thrv-button {
	margin: 0 !important;
	padding: 0 !important;
	width: auto !important;
	min-width: 0 !important;
	float: none !important;
	background: none !important;
	border: 0 !important;
	box-shadow: none !important;
}

#theme-top-section .llc-lesson-cols .llc-lesson-cols__action .thrv-button a.tcb-button-link,
#theme-top-section .llc-lesson-cols .llc-lesson-cols__action .thrv-button a.tcb-button-link * {
	color: #DEBC55 !important;
	font: 600 13px/1.2 Georgia, serif !important;
	letter-spacing: .1em !important;
	text-transform: uppercase !important;
	text-decoration: none !important;
}

#theme-top-section .llc-lesson-cols .llc-lesson-cols__action .thrv-button a.tcb-button-link {
	display: inline-flex !important;
	align-items: center;
	gap: 8px;
	padding: 9px 20px !important;
	border: 2px solid #DEBC55 !important;
	border-radius: 999px !important;
	background: transparent !important;
	white-space: nowrap;
	transition: background .2s;
}

#theme-top-section .llc-lesson-cols .llc-lesson-cols__action .thrv-button a.tcb-button-link:hover {
	background: #DEBC55 !important;
}

#theme-top-section .llc-lesson-cols .llc-lesson-cols__action .thrv-button a.tcb-button-link:hover,
#theme-top-section .llc-lesson-cols .llc-lesson-cols__action .thrv-button a.tcb-button-link:hover * {
	color: #12283F !important;
}

/* last lesson (no next video): the Thrive button is the main action */
#theme-top-section .llc-lesson-cols .llc-lesson-cols__action .thrv-button.llc-primary a.tcb-button-link {
	background: #DEBC55 !important;
}

#theme-top-section .llc-lesson-cols .llc-lesson-cols__action .thrv-button.llc-primary a.tcb-button-link,
#theme-top-section .llc-lesson-cols .llc-lesson-cols__action .thrv-button.llc-primary a.tcb-button-link * {
	color: #12283F !important;
}

#theme-top-section .llc-lesson-cols .llc-lesson-cols__action .thrv-button.llc-primary a.tcb-button-link:hover {
	background: transparent !important;
}

#theme-top-section .llc-lesson-cols .llc-lesson-cols__action .thrv-button.llc-primary a.tcb-button-link:hover,
#theme-top-section .llc-lesson-cols .llc-lesson-cols__action .thrv-button.llc-primary a.tcb-button-link:hover * {
	color: #DEBC55 !important;
}

/* Thrive's own "next" button, hidden when our Next video button does the same job */
#theme-top-section .llc-lesson-cols .llc-lesson-cols__action .thrv-button.llc-hide {
	display: none !important;
}

#theme-top-section .llc-lesson-cols .llc-lesson-cols__action .thrv_icon {
	width: 16px !important;
	height: 16px !important;
	margin: 0 !important;
	font-size: 16px !important;
}

#theme-top-section .llc-lesson-cols .llc-lesson-cols__action .thrv_icon svg {
	width: 16px;
	height: 16px;
	fill: currentColor;
}

/* Previous: secondary outline pill */
#theme-top-section .llc-lesson-cols .llc-prev,
#theme-top-section .llc-lesson-cols .llc-next {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 9px 20px;
	border: 2px solid #DEBC55;
	border-radius: 999px;
	font: 600 13px/1.2 Georgia, serif;
	letter-spacing: .1em;
	text-transform: uppercase;
	text-decoration: none !important;
	white-space: nowrap;
	transition: background .2s, color .2s;
}

#theme-top-section .llc-lesson-cols .llc-prev {
	background: transparent;
	color: #DEBC55 !important;
}

#theme-top-section .llc-lesson-cols .llc-prev::before {
	content: "\2190";
}

#theme-top-section .llc-lesson-cols .llc-prev:hover,
#theme-top-section .llc-lesson-cols .llc-prev:focus-visible {
	background: #DEBC55;
	color: #12283F !important;
}

/* Next video: the one solid button, bottom right (the same job as Coursera's "Go to next item") */
#theme-top-section .llc-lesson-cols .llc-next {
	background: #DEBC55;
	color: #12283F !important;
}

#theme-top-section .llc-lesson-cols .llc-next::after {
	content: "\2192";
}

#theme-top-section .llc-lesson-cols .llc-next:hover,
#theme-top-section .llc-lesson-cols .llc-next:focus-visible {
	background: transparent;
	color: #DEBC55 !important;
}

#theme-top-section .llc-lesson-cols .llc-lesson-cols__action a:focus-visible {
	outline: 3px solid #F5F0E6;
	outline-offset: 2px;
}

/* ---- Narrow screens (and the course panel open on a small laptop): one column ---- */
@media (max-width: 1100px) {
	#theme-top-section .llc-lesson-cols {
		grid-template-columns: minmax(0, 1fr);
		max-width: 100%;
	}

	#theme-top-section .llc-lesson-cols .llc-lesson-cols__video > .thrv_responsive_video { grid-column: 1; grid-row: 2; }
	#theme-top-section .llc-lesson-cols .llc-lesson-cols__action { grid-column: 1; grid-row: 3; justify-content: center; }

	#theme-top-section .llc-lesson-cols .llc-lesson-cols__action .llc-aa-toggle {
		flex: 1 1 100%;
		justify-content: center;
		margin: 0;
	}

	#theme-top-section .llc-lesson-cols .llc-lesson-cols__notes {
		grid-column: 1;
		grid-row: 4;
		margin-top: 16px;
	}

	#theme-top-section .llc-lesson-cols .llc-lesson-cols__notes .llcn {
		position: static;
	}

	#theme-top-section .llc-lesson-cols .llcn__text {
		flex: none;
		min-height: 240px !important;
		resize: vertical;
	}
}

@media (max-width: 600px) {
	#theme-top-section .llc-lesson-cols .llc-lesson-head {
		grid-template-columns: minmax(0, 1fr);
		row-gap: 10px;
	}

	#theme-top-section .llc-lesson-cols .llc-lesson-head > .llc-join-discussion,
	#theme-top-section .llc-lesson-cols .llc-lesson-head > .llc-btnrow {
		grid-column: 1;
		grid-row: 2;
		justify-self: start;
	}
}

@media (prefers-reduced-motion: reduce) {
	#theme-top-section .llc-lesson-cols a { transition: none !important; }
}

/* ---- Button text colours ----
   The course's lesson design colours the LAST link or span in this section gold with !important
   (specificity 1,2,3). Without this block the solid Next video button, being last, got gold text on
   a gold fill. These selectors are deliberately stronger. */
html body #theme-top-section .llc-lesson-cols .llc-lesson-cols__action a.llc-prev {
	color: #DEBC55 !important;
}

html body #theme-top-section .llc-lesson-cols .llc-lesson-cols__action a.llc-prev:hover,
html body #theme-top-section .llc-lesson-cols .llc-lesson-cols__action a.llc-prev:focus-visible {
	color: #12283F !important;
}

html body #theme-top-section .llc-lesson-cols .llc-lesson-cols__action a.llc-next {
	color: #12283F !important;
}

html body #theme-top-section .llc-lesson-cols .llc-lesson-cols__action a.llc-next:hover,
html body #theme-top-section .llc-lesson-cols .llc-lesson-cols__action a.llc-next:focus-visible {
	color: #DEBC55 !important;
}
/* 1.3.0 Word download: Word is the main button, .txt is a small fallback link. */
html body #theme-top-section .llc-lesson-cols .llcn__download-docx {
	background: #12283F;
	border-color: #12283F;
	color: #fff !important;
	font-weight: 600;
}
html body #theme-top-section .llc-lesson-cols .llcn__download-docx:hover,
html body #theme-top-section .llc-lesson-cols .llcn__download-docx:focus-visible {
	background: #1B3A57;
	color: #fff !important;
}
html body #theme-top-section .llc-lesson-cols .llcn__download-docx:disabled {
	opacity: .55;
}
html body #theme-top-section .llc-lesson-cols .llcn__txtlink {
	flex: 0 0 auto;
	margin: 0;
	padding: 6px 4px;
	border: 0;
	background: transparent;
	color: #6B7280 !important;
	font-size: 12px;
	text-decoration: underline;
	cursor: pointer;
	white-space: nowrap;
}
html body #theme-top-section .llc-lesson-cols .llcn__txtlink:hover {
	color: #12283F !important;
	background: transparent;
}
html body #theme-top-section .llc-lesson-cols .llcn__txtlink:disabled {
	opacity: .5;
	cursor: default;
}

/* Rich-text toolbar (1.4.0) inside the lesson layout */
#theme-top-section .llc-lesson-cols .llcn__richwrap { flex: 1 1 0; min-height: 0; }
#theme-top-section .llc-lesson-cols .llcn .llcn__rich { flex: 1 1 0; height: auto; min-height: 0 !important; padding: 10px 12px; border: 1px solid #ECE6D6; border-radius: 8px; background: #fff; color: #1C2530; font-size: 15px; line-height: 1.65; resize: none; overflow: auto; box-shadow: none; }
#theme-top-section .llc-lesson-cols .llcn .llcn__rich:focus { border-color: #DEBC55; outline: 2px solid rgba(222, 188, 85, .55); outline-offset: 0; }
@media (max-width: 1100px) {
#theme-top-section .llc-lesson-cols .llcn__richwrap { flex: none; }
#theme-top-section .llc-lesson-cols .llcn .llcn__rich { flex: none; min-height: 240px !important; resize: vertical; }
}

/* 1.6.3 audio lessons: the audio player takes the video's place */
#theme-top-section .llc-lesson-cols .llc-lesson-cols__video > .thrv_audio {
	grid-column: 1;
	grid-row: 2;
	min-width: 0;
	margin: 0;
	border-radius: 10px;
	overflow: hidden;
	box-sizing: border-box;
	min-height: clamp(300px, 34vh, 420px);
	padding: 24px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #12283F;
}
#theme-top-section .llc-lesson-cols .llc-lesson-cols__video > .thrv_audio > * { width: 100%; max-width: 100%; }
#theme-top-section .llc-lesson-cols .llc-lesson-cols__video > .thrv_audio audio, #theme-top-section .llc-lesson-cols .llc-lesson-cols__video > .thrv_audio .wp-audio-shortcode { width: 100%; max-width: 100%; display: block; }
