/* ==========================================================================
   Patient video library — menu left, player right
   Neutral palette, built to be reused across practices: to rebrand, change
   --accent (and optionally --accent-soft). Nothing else needs touching.
   Sits inside a fixed-height Joomla iframe (scrolling="no"). .page fills the
   frame exactly, whatever its height, and is the only page-level scroller:
   desktop fits with no scrolling, phones scroll it with the player pinned.
   ========================================================================== */

:root {
	/* surfaces */
	--bg: #f5f5f5;			/* warm stone page */
	--surface: #ffffff;
	--surface-2: #f0eee9;		/* hover, inputs */
	--line: #e1ded7;

	/* text */
	--ink: #24282c;
	--muted: #6a6e72;

	/* the one brand colour — slate blue-grey */
	--accent: #163d8a;
	--accent-ink: #ffffff;
	--accent-soft: #e5ecee;

	/* category bars, cycled 1→5 */
	--cat-1: #163d8a;		/* slate */
	--cat-2: #7d8f74;		/* sage */
	--cat-3: #b08b6e;		/* clay */
	--cat-4: #8a7f99;		/* heather */
	--cat-5: #c2ab78;		/* sand */

	--radius: 10px;
	--shell: 1400px;
	--menu-w: 320px;
	--meta-h: 3.6rem;		/* title row under the player */
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font: 400 16px/1.55 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
	-webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }

.visually-hidden {
	position: absolute;
	width: 1px; height: 1px;
	margin: -1px; padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

:where(a, button, summary, input):focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
	border-radius: 4px;
}

/* ---------- page + layout ---------- */

.page {
	display: flex;
	flex-direction: column;
	height: 100%;			/* = the iframe's height */
	overflow-y: auto;		/* only kicks in if the frame is very short */
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
}

.layout {
	flex: 1 1 auto;
	min-height: 20rem;
	display: grid;
	grid-template-columns: var(--menu-w) minmax(0, 1fr);
	grid-template-rows: minmax(0, 1fr);
	gap: 24px;
	width: 100%;
	max-width: var(--shell);
	margin: 0 auto;
	padding: 20px 20px 14px;
}

/* ---------- library (left) ---------- */

.library {
	display: flex;
	flex-direction: column;
	min-height: 0;			/* fills its grid row; the list scrolls inside */
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: 0 1px 2px rgba(36, 40, 44, .04), 0 6px 20px rgba(36, 40, 44, .05);
	overflow: hidden;
}

.library__head {
	flex: 0 0 auto;
	padding: 14px 14px 12px;
	border-bottom: 1px solid var(--line);
}

.library__eyebrow {
	margin: 0 0 9px 2px;
	font-size: .68rem;
	font-weight: 700;
	letter-spacing: .14em;
	text-transform: uppercase;
	color: var(--accent);
}

.library__head input {
	width: 100%;
	padding: 9px 13px 9px 34px;
	font: inherit;
	font-size: .86rem;
	color: var(--ink);
	background: var(--surface-2) no-repeat 12px 50% / 14px
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236a6e72' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
	border: 1px solid transparent;
	border-radius: 6px;
	transition: border-color .18s, background-color .18s;
}

.library__head input::placeholder { color: var(--muted); }
.library__head input:focus { outline: none; border-color: var(--accent); background-color: var(--surface); }

/* the only thing that scrolls */
.library__scroll {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
	scrollbar-color: #cfcbc3 transparent;
}

.library__scroll::-webkit-scrollbar { width: 9px; }
.library__scroll::-webkit-scrollbar-thumb {
	background: #cfcbc3;
	border-radius: 9px;
	border: 2px solid var(--surface);
}

.library__empty {
	margin: 0;
	padding: 22px 16px;
	text-align: center;
	color: var(--muted);
	font-size: .86rem;
}

/* ---------- category ---------- */

.cat { border-bottom: 1px solid var(--line); }
.cat:last-of-type { border-bottom: 0; }

.cat__head {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 14px;
	cursor: pointer;
	list-style: none;
	font-weight: 600;
	font-size: .9rem;
	transition: background .18s;
}

.cat__head::-webkit-details-marker { display: none; }
.cat__head:hover { background: var(--surface-2); }

.cat__head::after {
	content: '';
	width: 7px; height: 7px;
	margin-left: auto;
	border-right: 2px solid var(--muted);
	border-bottom: 2px solid var(--muted);
	transform: rotate(45deg) translate(-2px, -2px);
	transition: transform .2s;
}

.cat[open] > .cat__head::after {
	transform: rotate(-135deg) translate(-2px, -2px);
	border-color: var(--accent);
}

.cat__name { position: relative; padding-left: 14px; }

.cat__name::before {
	content: '';
	position: absolute;
	left: 0; top: 50%;
	width: 4px; height: 1.05em;
	transform: translateY(-50%);
	border-radius: 3px;
	background: var(--bar, var(--accent));
}

.cat[data-accent="1"] { --bar: var(--cat-1); }
.cat[data-accent="2"] { --bar: var(--cat-2); }
.cat[data-accent="3"] { --bar: var(--cat-3); }
.cat[data-accent="4"] { --bar: var(--cat-4); }
.cat[data-accent="5"] { --bar: var(--cat-5); }

.cat__count {
	padding: 2px 8px;
	font-size: .66rem;
	font-weight: 700;
	color: var(--muted);
	background: var(--surface-2);
	border-radius: 20px;
}

.cat__list {
	margin: 0;
	padding: 0 8px 8px;
	list-style: none;
}

/* ---------- video row ---------- */

.vid {
	display: flex;
	gap: 10px;
	align-items: baseline;
	padding: 7px 10px;
	font-size: .85rem;
	line-height: 1.4;
	color: var(--muted);
	border-radius: 6px;
	transition: color .18s, background .18s;
}

.vid::before {
	content: attr(data-n);
	flex: 0 0 auto;
	font-size: .7rem;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	color: #a3a6a9;
	transition: color .18s;
}

.vid:hover { color: var(--ink); background: var(--surface-2); }
.vid:hover::before { color: var(--accent); }

.vid.is-active {
	color: var(--accent-ink);
	background: var(--accent);
	font-weight: 600;
}

.vid.is-active::before { color: rgba(255, 255, 255, .7); }

/* ---------- player (right) ---------- */

/* The player column is a size container, so the video can be as large as
   the space allows in both directions without ever overflowing it. */
.player {
	min-height: 0;
	container-type: size;
}

.player__inner {
	width: min(100%, calc((100cqh - var(--meta-h)) * 16 / 9));
	margin-inline: auto;
}

.player__frame {
	position: relative;
	aspect-ratio: 16 / 9;
	background: #15181a;
	border-radius: var(--radius);
	box-shadow: 0 6px 24px rgba(36, 40, 44, .12);
	overflow: hidden;
}

.player__frame iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

.player__meta {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 16px;
	min-height: var(--meta-h);
	padding: 13px 2px 0;
}

.player__title {
	margin: 0;
	font-size: clamp(17px, 1.9vw, 21px);
	font-weight: 700;
	line-height: 1.25;
}

.player__cat {
	flex: 0 0 auto;
	margin: 0;
	padding: 3px 10px;
	font-size: .66rem;
	font-weight: 700;
	letter-spacing: .12em;
	text-transform: uppercase;
	color: var(--accent);
	background: var(--accent-soft);
	border-radius: 20px;
}

/* ---------- disclaimer ---------- */

.disclaimer {
	max-width: var(--shell);
	margin: 0 auto;
	flex: 0 0 auto;
	width: 100%;
	padding: 0 20px 16px;
	color: var(--muted);
}

.disclaimer > h2 {
	margin: 0;
	padding: 6px 0;
	font-size: .68rem;
	font-weight: 700;
	letter-spacing: .14em;
	text-transform: uppercase;
	color: var(--ink);
}

.disclaimer p {
	max-width: 100%;
	margin: 4px 0 0;
	font-size: .74rem;
	line-height: 1.6;
}

/* ---------- responsive ---------- */

@media (max-width: 1150px) {
	:root { --menu-w: 280px; }
	.layout { gap: 18px; }
}

/* Phones and narrow frames: one column. The player stays pinned at the top
   of .page while the menu and disclaimer scroll underneath it, so nothing is
   ever cut off by the fixed-height iframe. */
@media (max-width: 860px) {
	.layout {
		flex: 0 0 auto;
		min-height: 0;
		display: flex;
		flex-direction: column;
		gap: 12px;
		padding: 0 14px 12px;
	}

	.player {
		order: -1;
		container-type: normal;
		position: sticky;
		top: 0;
		z-index: 2;
		margin: 0 -14px;
		padding: 14px 14px 10px;
		background: var(--bg);
		box-shadow: 0 8px 12px -10px rgba(36, 40, 44, .25);
	}

	.player__inner { width: min(100%, calc(45vh * 16 / 9)); }
	.player__meta { flex-direction: column; gap: 6px; min-height: 0; padding-top: 10px; }
	.player__title { font-size: 16px; }

	.library { overflow: visible; }
	.library__scroll { overflow: visible; }

	.disclaimer { padding: 4px 14px 16px; }
}

@media (prefers-reduced-motion: reduce) {
	* { transition: none !important; animation: none !important; }
}
