/**!
 * @file    ThemeRail.css
 * @desc    "Browse by Theme" rail component, extracted from the home page so it
 *          can be reused on other pages (e.g. esl_viewThemeLessons.php sidebar).
 *          Scoped to a `.theme-rail` wrapper instead of `body.home-page`, and
 *          carries its own copy of the green `--home-*` design tokens so it is
 *          self-contained on pages that don't load IndexHome.css.
 *          Markup classes (home-themes-rail, home-rail-theme, home-rail-tooltip)
 *          are kept identical to the home page so the PHP markup matches 1:1.
 * @version v6 2026-06-08 - Initial version (lifted from IndexHome.css rail rules).
 * @author  Charlie Samra <charles@samraworld.net>
 * @see      {@link students.samraworld.net }
 */

.theme-rail {
	--home-brand:       var(--sw-brand-color, #0e6630);
	--home-brand-dark:  #084a22;
	--home-brand-soft:  #e8f3ec;
	--home-ink:         #14211a;
	--home-ink-soft:    #4a5b51;
	--home-card:        #ffffff;
	--home-border:      #e0e8e3;
	--home-radius-sm:   12px;
	--home-shadow-tile: 0 1px 2px rgba(20, 50, 30, 0.04),
	                    0 4px 18px rgba(20, 50, 30, 0.06);

	background: var(--home-card);
	border-radius: var(--home-radius-sm);
	box-shadow: var(--home-shadow-tile);
}

.theme-rail .home-themes-rail__header {
	padding: 18px 20px 14px 20px;
	background: var(--home-brand-soft);
	border-bottom: 1px solid var(--home-border);
	border-radius: var(--home-radius-sm) var(--home-radius-sm) 0 0;
}

.theme-rail > .home-rail-theme:last-child {
	border-radius: 0 0 var(--home-radius-sm) var(--home-radius-sm);
}

.theme-rail .home-themes-rail__title {
	font-size: 1.05rem;
	font-weight: 700;
	margin: 0;
	color: var(--home-ink);
}

.theme-rail .home-themes-rail__subtitle {
	font-size: 0.82rem;
	color: var(--home-ink-soft);
	margin: 3px 0 0 0;
}

/* Rail-theme card: image + name as a compact header row at top,
   lesson links span the full card width below to give titles more room. */
.theme-rail .home-rail-theme {
	padding: 14px 14px 14px 14px;
	border-bottom: 1px solid var(--home-border);
	display: grid;
	grid-template-columns: 72px 1fr;
	grid-template-rows: auto auto;
	column-gap: 14px;
	row-gap: 10px;
	align-items: start;
}

.theme-rail .home-rail-theme:last-child {
	border-bottom: none;
}

.theme-rail .home-rail-theme__image {
	grid-column: 1;
	grid-row: 1;
	display: block;
	width: 72px;
	height: 72px;
	border-radius: 10px;
	overflow: hidden;
	background: var(--home-brand-soft);
	flex: 0 0 auto;
}

.theme-rail .home-rail-theme__image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.theme-rail .home-rail-theme__body {
	grid-column: 2;
	grid-row: 1;
	align-self: center;
	min-width: 0;
}

.theme-rail .home-rail-theme__name {
	font-size: 0.95rem;
	font-weight: 700;
	margin: 0;
	color: var(--home-ink);
	text-decoration: none;
	line-height: 1.3;
	display: block;
}

.theme-rail .home-rail-theme__name:hover {
	color: var(--home-brand-dark);
	text-decoration: underline;
}

.theme-rail .home-rail-theme__meta {
	font-size: 0.76rem;
	color: var(--home-brand-dark);
	font-weight: 600;
	margin: 2px 0 0 0;
}

.theme-rail .home-rail-theme__desc {
	font-size: 0.82rem;
	line-height: 1.5;
	color: var(--home-ink-soft);
	margin: 6px 0 0 0;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* Lessons row — spans the full card width so titles have room to wrap. */
.theme-rail .home-rail-theme__lessons {
	grid-column: 1 / -1;
	grid-row: 2;
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.theme-rail .home-rail-theme__lesson-link {
	position: relative;
	display: flex;
	align-items: flex-start;
	gap: 6px;
	padding: 5px 8px;
	border-radius: 5px;
	color: var(--home-ink);
	text-decoration: none;
	font-size: 0.88rem;
	line-height: 1.35;
	transition: background 0.12s ease, color 0.12s ease;
	cursor: help;
}

.theme-rail .home-rail-theme__lesson-link::before {
	content: "›";
	color: var(--home-brand);
	font-weight: 700;
	flex: 0 0 auto;
	line-height: 1.35;
}

.theme-rail .home-rail-theme__lesson-link:hover {
	background: var(--home-brand-soft);
	color: var(--home-brand-dark);
}

.theme-rail .home-rail-theme__lesson-text {
	flex: 1;
	min-width: 0;
	word-break: break-word;
}

.theme-rail .home-rail-theme__more {
	display: block;
	margin-top: 4px;
	padding: 4px 8px;
	font-size: 0.78rem;
	font-weight: 600;
	color: var(--home-brand-dark);
	text-decoration: none;
}

.theme-rail .home-rail-theme__more:hover {
	text-decoration: underline;
}

/* ------------------------------------------------------------------ */
/* RAIL LESSON TOOLTIP — Wikipedia-style hovercard with image + intro  */
/* Pops to the LEFT of the lesson link (rail is on the right of the    */
/* page, so left is into the main content area where it has room).     */
/* Touch devices and narrow viewports skip this entirely.              */
/* ------------------------------------------------------------------ */

.theme-rail .home-rail-tooltip {
	position: absolute;
	right: 100%;
	top: 50%;
	transform: translateY(-50%) translateX(8px);
	width: calc(340px + 14px);
	padding-right: 14px;
	font-size: 0.86rem;
	line-height: 1.55;
	text-align: left;
	color: var(--home-ink);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
	z-index: 100;
}

.theme-rail .home-rail-tooltip__card {
	position: relative;
	display: block;
	background: var(--home-card);
	border: 1px solid rgba(20, 50, 30, 0.1);
	border-radius: 10px;
	box-shadow: 0 14px 36px rgba(20, 50, 30, 0.18),
	            0 2px 6px rgba(20, 50, 30, 0.08);
}

.theme-rail .home-rail-tooltip__card::before,
.theme-rail .home-rail-tooltip__card::after {
	content: "";
	position: absolute;
	left: 100%;
	top: 50%;
	transform: translateY(-50%);
	border-top: 8px solid transparent;
	border-bottom: 8px solid transparent;
}

.theme-rail .home-rail-tooltip__card::before {
	border-left: 8px solid rgba(20, 50, 30, 0.12);
	margin-left: 0;
}

.theme-rail .home-rail-tooltip__card::after {
	border-left: 8px solid var(--home-card);
	margin-left: -1px;
}

.theme-rail .home-rail-tooltip__image {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 9;
	background: var(--home-brand-soft);
	overflow: hidden;
	border-radius: 10px 10px 0 0;
}

.theme-rail .home-rail-tooltip__image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.theme-rail .home-rail-tooltip__body {
	display: block;
	padding: 14px 16px 14px 16px;
}

.theme-rail .home-rail-tooltip__title {
	display: block;
	font-size: 1rem;
	font-weight: 700;
	color: var(--home-ink);
	margin-bottom: 6px;
	line-height: 1.3;
}

.theme-rail .home-rail-tooltip__intro {
	display: block;
	color: var(--home-ink-soft);
	font-size: 0.88rem;
	line-height: 1.55;
	display: -webkit-box;
	-webkit-line-clamp: 5;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.theme-rail .home-rail-tooltip__cta {
	display: inline-block;
	margin-top: 10px;
	font-size: 0.84rem;
	font-weight: 600;
	color: var(--home-brand-dark);
}

@media (hover: hover) {
	.theme-rail .home-rail-theme__lesson-link:hover .home-rail-tooltip {
		opacity: 1;
		visibility: visible;
		transform: translateY(-50%) translateX(0);
		transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s;
	}
}

/* At narrow widths the rail stacks below the main content and a tooltip
   popping to the LEFT would push off-screen, so hide tooltips there. */
@media (max-width: 1100px) {
	.theme-rail .home-rail-tooltip { display: none; }
	.theme-rail .home-rail-theme__lesson-link { cursor: pointer; }
}
