/*
 * LPEN course list — the shared component.
 *
 * One stylesheet for every course list on the site. Layout is chosen per page
 * by a class on the list; the cards themselves never change shape, which is
 * what lets a page switch between grid and list without a rebuild.
 *
 * ⚠️ ANCHORED ON #lpen-cl, NEVER PREFIX-SCOPED.
 * `lpen-assets/` is enqueued on every page of the site, so a selector that
 * escapes this id repaints pages nobody asked to change. build_courses.py
 * fails the build on any selector here that does not contain "#lpen-cl",
 * checked brace-balanced and inside @media too. An id anchor is a fact you can
 * grep; prefix-scoping is a transformation you have to trust (CLAUDE.md §18k).
 */

#lpen-cl {
	/* LPEN design system §3.1, §4, §5. Declared locally so the component is
	   readable on its own and cannot be broken by a kit change. */
	--cl-navy-900: #012032;
	--cl-navy-800: #022E48;
	--cl-navy-50:  #E5EEF3;
	--cl-navy-25:  #F3F7F9;
	--cl-action:   #0F5C96;
	--cl-action-h: #0B4465;
	--cl-gold-700: #8A5A08;
	--cl-gold-100: #F7E4BD;
	--cl-ink:      #111820;
	--cl-muted:    #4A5666;
	--cl-subtle:   #6B7684;
	--cl-border:   #CFD6DD;
	--cl-border-s: #78848F;
	--cl-surface1: #F6F8FA;
	--cl-surface2: #EEF2F5;
	--cl-white:    #FFFFFF;
	--cl-focus:    #6A3FD4;

	--cl-r-sm: 2px;
	--cl-r-md: 4px;
	--cl-r-lg: 8px;
	--cl-r-pill: 999px;

	/* §4 elevation-1, BOTH layers. The near layer is what makes a card read as
	   lifted rather than as a card with a blur behind it (§18q). */
	--cl-e1: 0 1px 3px rgba(1,32,50,.08), 0 1px 2px rgba(1,32,50,.06);

	--cl-fast: 120ms cubic-bezier(.2,0,.2,1);

	display: block;
}

/* =====================================================================
   THE BAR — search, facets, view switch, count
   ================================================================== */
#lpen-cl .lpen-cl__bar {
	display: flex;
	flex-direction: column;
	gap: 16px;
	margin-bottom: 24px;
	padding-bottom: 20px;
	border-bottom: 1px solid var(--cl-border);
}

#lpen-cl .lpen-cl__row {
	display: flex;
	gap: 12px;
	align-items: center;
	flex-wrap: wrap;
}

/* The search field is CREATED BY SCRIPT. A server-rendered <input> is stripped
   by the html-widget sanitiser (§18b.1), so the markup cannot contain one. */
#lpen-cl .lpen-cl__search {
	position: relative;
	flex: 1 1 260px;
	min-width: 0;
}

#lpen-cl .lpen-cl__search input {
	width: 100%;
	min-height: 44px;                 /* §8 minimum hit area */
	padding: 10px 14px 10px 42px;
	font: inherit;
	font-size: 15px;
	color: var(--cl-ink);
	background: var(--cl-white);
	border: 1px solid var(--cl-border-s);
	border-radius: var(--cl-r-md);
}

#lpen-cl .lpen-cl__search input::placeholder { color: var(--cl-subtle); }

/* Tabler "search" as a mask, because inline SVG is stripped and no icon font
   should have to load for one glyph (§18b.1). currentColor keeps §18a's
   colour-inheritance rule intact. */
#lpen-cl .lpen-cl__search::before {
	content: "";
	position: absolute;
	left: 13px;
	top: 50%;
	width: 18px;
	height: 18px;
	transform: translateY(-50%);
	background-color: var(--cl-subtle);
	-webkit-mask: var(--cl-icon-search) center / contain no-repeat;
	mask: var(--cl-icon-search) center / contain no-repeat;
	pointer-events: none;
}

#lpen-cl .lpen-cl__facets { display: flex; flex-direction: column; gap: 10px; }

#lpen-cl .lpen-cl__facet {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	align-items: center;
}

#lpen-cl .lpen-cl__facet-label {
	font-size: 12px;
	font-weight: 600;
	letter-spacing: .05em;
	text-transform: uppercase;
	color: var(--cl-muted);
	margin-right: 4px;
}

#lpen-cl .lpen-cl__chip {
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	line-height: 1;
	min-height: 36px;
	padding: 8px 14px;
	cursor: pointer;
	color: var(--cl-navy-800);
	background: var(--cl-white);
	/* 2px in the NORMAL state, colour-matched. The kit adds a 2px border on
	   :hover to every button with none, so a button without this grows 4px the
	   instant the pointer touches it (§18q). Hover changes colour only. */
	border: 2px solid var(--cl-border);
	border-radius: var(--cl-r-pill);
	transition: background var(--cl-fast), border-color var(--cl-fast), color var(--cl-fast);
}

#lpen-cl .lpen-cl__chip:hover { border-color: var(--cl-action); color: var(--cl-action); }

#lpen-cl .lpen-cl__chip[aria-pressed="true"] {
	background: var(--cl-action);
	border-color: var(--cl-action);
	color: var(--cl-white);
}

#lpen-cl .lpen-cl__chip .n { font-weight: 400; opacity: .65; margin-left: 5px; }
#lpen-cl .lpen-cl__chip[aria-pressed="true"] .n { opacity: .8; }

#lpen-cl .lpen-cl__views { display: flex; gap: 6px; margin-left: auto; }

#lpen-cl .lpen-cl__view {
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	min-height: 36px;
	padding: 8px 14px;
	cursor: pointer;
	color: var(--cl-muted);
	background: var(--cl-white);
	border: 2px solid var(--cl-border);
	border-radius: var(--cl-r-md);
	transition: background var(--cl-fast), border-color var(--cl-fast), color var(--cl-fast);
}

#lpen-cl .lpen-cl__view:hover { border-color: var(--cl-action); color: var(--cl-action); }

#lpen-cl .lpen-cl__view[aria-pressed="true"] {
	background: var(--cl-navy-50);
	border-color: var(--cl-action);
	color: var(--cl-navy-800);
}

#lpen-cl .lpen-cl__count {
	margin: 0;
	font-size: 14px;
	color: var(--cl-muted);
	font-variant-numeric: tabular-nums;
}

/* =====================================================================
   CARD FIELDS — identical in every layout
   ================================================================== */
#lpen-cl .lpen-cl__list { list-style: none; margin: 0; padding: 0; }

#lpen-cl .lpen-cl__item { position: relative; }

/* ⚠️ `hidden` is only a user-agent rule, so ANY author `display` on the same
   element beats it. The layouts below give items `display: flex`, which would
   silently disable every filter without this companion (§18n). */
#lpen-cl .lpen-cl__item[hidden] { display: none !important; }

#lpen-cl .lpen-cl__card {
	position: relative;
	display: flex;
	flex-direction: column;
	height: 100%;
	background: var(--cl-white);
	border: 1px solid var(--cl-border);
	border-radius: var(--cl-r-lg);
	overflow: hidden;
	transition: box-shadow var(--cl-fast), border-color var(--cl-fast);
}

#lpen-cl .lpen-cl__card:hover {
	box-shadow: var(--cl-e1);
	border-color: var(--cl-border-s);
}

#lpen-cl .lpen-cl__cover {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 9;
	object-fit: cover;
	background: var(--cl-surface2);
}

#lpen-cl .lpen-cl__body {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 20px;
	flex: 1;
}

#lpen-cl .lpen-cl__meta {
	margin: 0;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: .05em;
	text-transform: uppercase;
	color: var(--cl-action);
	font-variant-numeric: tabular-nums;
}

#lpen-cl .lpen-cl__title {
	margin: 0;
	font-size: 17px;
	line-height: 1.32;
	font-weight: 600;
	color: var(--cl-navy-800);
}

#lpen-cl .lpen-cl__title a {
	color: inherit;
	text-decoration: none;   /* the theme underlines every <a> (§18i) */
}

/* The WHOLE card is one link, one accessible name (design system §9.5).
   A stretched pseudo-element rather than a wrapper anchor, because `tabindex`
   is stripped by the sanitiser, so an aria-hidden wrapper link would become a
   second, nameless tab stop on every card (§18b.1). */
#lpen-cl .lpen-cl__title a::after {
	content: "";
	position: absolute;
	inset: 0;
}

#lpen-cl .lpen-cl__card:hover .lpen-cl__title a { color: var(--cl-action); }

#lpen-cl .lpen-cl__title a:focus-visible {
	outline: none;
}

/* The ring goes on the CARD, not on the inline anchor, so it frames what the
   link actually is. Two layers, per design system §3.2. */
#lpen-cl .lpen-cl__card:has(a:focus-visible) {
	outline: 3px solid var(--cl-focus);
	outline-offset: 2px;
	border-color: var(--cl-action);
}

#lpen-cl .lpen-cl__summary {
	margin: 0;
	font-size: 14px;
	line-height: 1.5;
	color: var(--cl-muted);
}

#lpen-cl .lpen-cl__badges { display: flex; gap: 6px; flex-wrap: wrap; }

#lpen-cl .lpen-cl__tag {
	display: inline-block;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: .04em;
	text-transform: uppercase;
	padding: 3px 9px;
	border-radius: var(--cl-r-pill);
	background: var(--cl-navy-50);
	color: var(--cl-navy-800);
}

/* Gold is reserved for accreditation (§3.1), and CPD hours are exactly that.
   Nothing else in this component uses it. */
#lpen-cl .lpen-cl__cpd {
	display: inline-block;
	font-size: 12px;
	font-weight: 600;
	padding: 3px 9px;
	border-radius: var(--cl-r-sm);
	background: var(--cl-gold-100);
	color: var(--cl-gold-700);
	font-variant-numeric: tabular-nums;
}

#lpen-cl .lpen-cl__instructors {
	margin: 0;
	font-size: 13px;
	color: var(--cl-subtle);
}

#lpen-cl .lpen-cl__foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 0 20px 20px;
	margin-top: auto;
}

#lpen-cl .lpen-cl__price {
	font-size: 16px;
	font-weight: 700;
	color: var(--cl-ink);
	font-variant-numeric: tabular-nums;
}

#lpen-cl .lpen-cl__cta {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 40px;
	padding: 0 18px;
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
	color: var(--cl-white);
	background: var(--cl-action);
	border: 2px solid var(--cl-action);
	border-radius: var(--cl-r-md);
	transition: background var(--cl-fast), border-color var(--cl-fast);
}

#lpen-cl .lpen-cl__card:hover .lpen-cl__cta {
	background: var(--cl-action-h);
	border-color: var(--cl-action-h);
}

/* Marked in after the page loads, from the per-learner request. Additive and
   space-reserving, so nothing shifts when it arrives. */
#lpen-cl .lpen-cl__owned {
	display: none;
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 2;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: .04em;
	text-transform: uppercase;
	padding: 4px 10px;
	border-radius: var(--cl-r-pill);
	background: #125E26;
	color: var(--cl-white);
}

#lpen-cl .lpen-cl__item.is-owned .lpen-cl__owned { display: inline-block; }

/* =====================================================================
   LAYOUTS — the cards do not change, only how they are placed
   ================================================================== */

/* --- grid ---------------------------------------------------------- */
#lpen-cl .lpen-cl--grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 24px;
}

#lpen-cl .lpen-cl--grid .lpen-cl__item { display: flex; }

/* --- list ---------------------------------------------------------- */
#lpen-cl .lpen-cl--list { display: flex; flex-direction: column; }

#lpen-cl .lpen-cl--list .lpen-cl__item { display: block; }

#lpen-cl .lpen-cl--list .lpen-cl__card {
	flex-direction: row;
	align-items: center;
	gap: 20px;
	border: 0;
	border-bottom: 1px solid var(--cl-border);
	border-radius: 0;
	padding: 18px 4px;
	background: transparent;
}

#lpen-cl .lpen-cl--list .lpen-cl__item:first-child .lpen-cl__card {
	border-top: 1px solid var(--cl-border);
}

#lpen-cl .lpen-cl--list .lpen-cl__card:hover {
	box-shadow: none;
	background: var(--cl-surface1);
}

#lpen-cl .lpen-cl--list .lpen-cl__cover { display: none; }

#lpen-cl .lpen-cl--list .lpen-cl__body {
	padding: 0 0 0 16px;
	flex: 1;
	gap: 6px;
	min-width: 0;
}

/* Owner, 2026-09-10: the list row has room for it. Clamped to two lines so a
   long description cannot make one row twice the height of its neighbours. */
#lpen-cl .lpen-cl--list .lpen-cl__summary {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

#lpen-cl .lpen-cl--list .lpen-cl__foot {
	flex-direction: column;
	align-items: flex-end;
	padding: 0;
	margin: 0;
	flex: 0 0 auto;
	gap: 8px;
}

/* The date, pulled out as a calendar block. Only rendered in list view. */
#lpen-cl .lpen-cl__when {
	display: none;
	flex: 0 0 84px;
	text-align: center;
	padding-right: 16px;
	border-right: 1px solid var(--cl-border);
	font-variant-numeric: tabular-nums;
}

#lpen-cl .lpen-cl--list .lpen-cl__when { display: block; }

#lpen-cl .lpen-cl__when .d {
	display: block;
	font-size: 22px;
	font-weight: 700;
	line-height: 1.1;
	color: var(--cl-navy-800);
}

#lpen-cl .lpen-cl__when .m {
	display: block;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: .07em;
	text-transform: uppercase;
	color: var(--cl-muted);
}

#lpen-cl .lpen-cl__when .y { display: block; font-size: 11px; color: var(--cl-subtle); }

#lpen-cl .lpen-cl--list .lpen-cl__meta { display: none; }

/* =====================================================================
   EMPTY STATE
   ================================================================== */
#lpen-cl .lpen-cl__empty {
	padding: 48px 0;
	text-align: center;
	color: var(--cl-muted);
	font-size: 15px;
}

#lpen-cl .lpen-cl__empty[hidden] { display: none !important; }

/* =====================================================================
   RESPONSIVE
   ================================================================== */
@media (max-width: 767px) {
	#lpen-cl .lpen-cl__views { margin-left: 0; }

	#lpen-cl .lpen-cl--list .lpen-cl__card {
		flex-wrap: wrap;
		align-items: flex-start;
	}

	#lpen-cl .lpen-cl--list .lpen-cl__when { flex: 0 0 62px; }

	#lpen-cl .lpen-cl--list .lpen-cl__foot {
		flex-direction: row;
		align-items: center;
		width: 100%;
		padding-left: 78px;
		justify-content: flex-start;
	}
}

/* =====================================================================
   MOTION
   ================================================================== */
@media (prefers-reduced-motion: reduce) {
	/* Only the named decorative transitions. A blanket `transform: none` here
	   would also cancel transforms doing LAYOUT work — the mistake that left
	   the header's skip link parked on screen (§18c). */
	#lpen-cl .lpen-cl__card,
	#lpen-cl .lpen-cl__chip,
	#lpen-cl .lpen-cl__view,
	#lpen-cl .lpen-cl__cta {
		transition-duration: 1ms !important;
	}
}


/* =====================================================================
   CALENDAR
   ================================================================== */
#lpen-cl.is-calendar .lpen-cl__list { display: none; }
#lpen-cl .lpen-cl__cal { display: none; }
#lpen-cl.is-calendar .lpen-cl__cal { display: block; }

#lpen-cl .lpen-cl__cal-bar {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-bottom: 16px;
}

#lpen-cl .lpen-cl__cal-bar h3 {
	margin: 0;
	font-size: 19px;
	font-weight: 600;
	color: var(--cl-navy-800);
}

#lpen-cl .lpen-cl__cal-nav {
	width: 38px;
	height: 38px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font: inherit;
	font-size: 17px;
	cursor: pointer;
	color: var(--cl-navy-800);
	background: var(--cl-white);
	border: 2px solid var(--cl-border-s);
	border-radius: var(--cl-r-md);
}

#lpen-cl .lpen-cl__cal-nav:hover:not(:disabled) {
	background: var(--cl-navy-50);
	border-color: var(--cl-action);
	color: var(--cl-action);
}

#lpen-cl .lpen-cl__cal-nav:disabled { opacity: .35; cursor: default; }

#lpen-cl .lpen-cl__cal-grid {
	display: grid;
	grid-template-columns: repeat(7, minmax(0, 1fr));
	gap: 1px;
	background: var(--cl-border);
	border: 1px solid var(--cl-border);
	border-radius: var(--cl-r-lg);
	overflow: hidden;
}

#lpen-cl .lpen-cl__cal-wd {
	background: var(--cl-surface2);
	padding: 9px 10px;
	text-align: center;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--cl-muted);
}

#lpen-cl .lpen-cl__cal-day {
	background: var(--cl-white);
	min-height: 104px;
	padding: 8px;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

#lpen-cl .lpen-cl__cal-day.is-out { background: var(--cl-surface1); }

#lpen-cl .lpen-cl__cal-day .dnum {
	font-size: 12px;
	font-weight: 600;
	color: var(--cl-subtle);
	font-variant-numeric: tabular-nums;
}

#lpen-cl .lpen-cl__cal-ev {
	display: block;
	text-decoration: none;
	background: var(--cl-navy-25);
	border-left: 3px solid var(--cl-action);
	border-radius: var(--cl-r-sm);
	padding: 6px 8px;
}

#lpen-cl .lpen-cl__cal-ev:hover { background: var(--cl-navy-50); }
#lpen-cl .lpen-cl__cal-ev.is-owned { border-left-color: #125E26; }

#lpen-cl .lpen-cl__cal-ev .n {
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
	font-size: 12.5px;
	line-height: 1.32;
	font-weight: 600;
	color: var(--cl-navy-800);
}

#lpen-cl .lpen-cl__cal-ev:hover .n { color: var(--cl-action); }
#lpen-cl .lpen-cl__cal-ev .h { display: block; font-size: 11px; color: var(--cl-subtle); margin-top: 2px; }

/* "My courses" reads as a state, not a subject, so it is green rather than
   action blue and sits in its own row above the subjects. */
#lpen-cl .lpen-cl__chip--owned[aria-pressed="true"] {
	background: #125E26;
	border-color: #125E26;
}

/* A month grid is unusable on a phone, so below 720px it becomes an agenda:
   one row per day that has something on it, empty days dropped. */
@media (max-width: 719px) {
	#lpen-cl .lpen-cl__cal-grid { grid-template-columns: 1fr; }
	#lpen-cl .lpen-cl__cal-wd { display: none; }
	#lpen-cl .lpen-cl__cal-day:not(.has) { display: none; }
	#lpen-cl .lpen-cl__cal-day { min-height: 0; padding: 12px; }
}

/* GENERATED */
#lpen-cl { --cl-icon-search: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"/><path d="M21 21l-6 -6"/></svg>'); }
