/*
 * The Remote 1.4.0: The Guide (full-day virtualised grid, list view, streaming drops, detail panel / dialog,
 * Tonight's highlights). Loads after theremote.css (enqueued by rmt_guide_enqueue()) and overrides its 1.3 Guide rules.
 * Tokens come from theremote.css (:root / html[data-theme="dark"]); Guide-only tokens are set on .rmt-gd.
 */

.rmt-gd {
	--gd-chan: 148px;
	--gd-row: 60px;
	--gd-headh: 40px;
	--gd-max: 560px;
	--gd-line: var(--red);
	--gd-feature: var(--red);
	--tint-drama: #EBCFC4;
	--tint-comedy: #F4E2A8;
	--tint-film: #D5D9EC;
	--tint-docs: #C9E0DC;
	--tint-unscripted: #E6DFD0;
	--tint-family: #DCE6C8;
	margin-top: 20px;
}
.rmt-gd--full { --gd-max: min(78vh, 980px); }
html[data-theme="dark"] .rmt-gd {
	--gd-line: #FF7A6E;
	--gd-feature: #FF7A6E;
	--tint-drama: #43281F;
	--tint-comedy: #3E3517;
	--tint-film: #232A4E;
	--tint-docs: #163834;
	--tint-unscripted: #2B2B33;
	--tint-family: #2A3519;
}

/* ---------- Controls ---------- */
.rmt-gd__filters { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-top: 14px; }
.rmt-gd__genres, .rmt-gd__quick { display: flex; flex-wrap: wrap; gap: 6px; }
.rmt-gd__chip--q[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: #FFFFFF; }
.rmt-gd__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 14px; }
.rmt-gd__bar .rmt-gd__dates { margin-top: 0; flex: 1 1 auto; min-width: 0; }
.rmt-gd__jumps { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.rmt-gd__jumps .rmt-pill[disabled] { opacity: .4; cursor: default; }
.rmt-gd__jumps .rmt-pill[hidden] { display: none; }
.rmt-gd__view { margin-left: 4px; }
.rmt-gd__count { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.rmt-gd__span[hidden], .rmt-gd__jumps[hidden], .rmt-gd__dates[hidden] { display: none; }
/* The List / Grid toggle is a phone affordance; wide screens always get the grid. */
@media (min-width: 720px) { .rmt-gd__view { display: none; } }

/* ---------- Tonight's highlights ---------- */
.rmt-gd__highlights { margin: 4px 0 22px; }
.rmt-gd__highlights[hidden] { display: none; }
.rmt-gd__hlhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border-top: 2px solid var(--ink); padding-top: 10px; }
.rmt-gd__hltitle { margin: 0; font-family: var(--serif); font-weight: 400; font-size: clamp(24px, 3vw, 30px); line-height: 1.1; }
.rmt-gd__hllist {
	list-style: none;
	margin: 12px 0 0;
	padding: 2px 2px 10px;
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: minmax(220px, 260px);
	gap: 14px;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x proximity;
	scrollbar-width: thin;
}
.rmt-gd__hl { scroll-snap-align: start; min-width: 0; }
.rmt-gd__hlbtn {
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--ink);
	text-align: left;
}
.rmt-gd__hlimg { position: relative; display: block; aspect-ratio: 16 / 10; border-radius: var(--radius); overflow: hidden; background: var(--midnight); box-shadow: inset 0 0 0 1px var(--rule); }
.rmt-gd__hlimg img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 25%; transition: transform .5s ease; }
.rmt-gd__hlimg .rmt-gd__ph { font-size: 22px; }
.rmt-gd__hlbtn:hover .rmt-gd__hlimg img, .rmt-gd__hlbtn:focus-visible .rmt-gd__hlimg img { transform: scale(1.04); }
.rmt-gd__hlbtn.is-sel .rmt-gd__hlimg { box-shadow: 0 0 0 3px var(--ink); }
.rmt-gd__hlbadge { position: absolute; left: 8px; top: 8px; z-index: 1; font-size: 9px; padding: 4px 7px; letter-spacing: .12em; text-transform: uppercase; }
.rmt-gd__hlbadge.is-quiet { background: var(--ink); color: var(--bg); }
.rmt-gd__hltext { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rmt-gd__hlwhen { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--red-text); }
.rmt-gd__hlshow { font-family: var(--serif); font-size: 21px; line-height: 1.1; }
.rmt-gd__hlbtn:hover .rmt-gd__hlshow { color: var(--red-text); }
.rmt-gd__hlse { font-family: var(--mono); font-size: 10px; letter-spacing: .08em; color: var(--muted); }

/* ---------- Layout: listings + detail panel ---------- */
.rmt-gd__body { display: block; margin-top: 14px; }
.rmt-gd__main { min-width: 0; }
@media (min-width: 1100px) {
	.rmt-gd__body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
	/* 1.9.1: beat the base .rmt-gd__detail rule below (it set position: relative and overflow: hidden, so the panel
	   kept the max-height but lost the scroll, and the bottom of a long programme was clipped). */
	.rmt-gd__body > .rmt-gd__detail { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: hidden auto; scrollbar-width: thin; overscroll-behavior: contain; }
	.rmt-gd__detail[hidden] { display: block; visibility: hidden; }
	.rmt-gd__dclose { display: none; }
}

/* ---------- Broadcast grid (virtualised: rows are absolutely placed; only those in view exist) ---------- */
.rmt-gd__scroll {
	position: relative;
	overflow: auto;
	max-height: var(--gd-max);
	overscroll-behavior: contain;
	border: 1px solid var(--rule);
	border-radius: 6px;
	background: var(--paper);
	scrollbar-width: thin;
	-webkit-overflow-scrolling: touch;
}
.rmt-gd__scroll:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.rmt-gd__grid, .rmt-gd__grid--day { position: relative; min-width: 0; width: calc(var(--gd-chan) + var(--gd-track)); }
.rmt-gd__head {
	position: sticky;
	top: 0;
	z-index: 5;
	display: flex;
	height: var(--gd-headh);
	border-bottom: 1px solid var(--rule);
	background: var(--paper);
}
.rmt-gd__day {
	position: sticky;
	left: 0;
	z-index: 6;
	flex: none;
	width: var(--gd-chan);
	display: flex;
	align-items: center;
	padding: 0 12px;
	border-right: 1px solid var(--rule);
	background: var(--paper);
}
.rmt-gd__slots { display: flex; flex: none; width: var(--gd-track); }
.rmt-gd__slot { flex: none; width: var(--gd-slot); display: flex; align-items: center; padding: 0 6px; border-left: 1px solid var(--rule); font-family: var(--mono); font-size: 11px; color: var(--ink); white-space: nowrap; overflow: hidden; }
.rmt-gd__slot.is-half { color: var(--muted); font-size: 10px; }
.rmt-gd__rows { position: relative; }
.rmt-gd__row {
	position: absolute;
	left: 0;
	right: 0;
	display: flex;
	height: var(--gd-row);
	border-bottom: 1px solid var(--rule);
}
.rmt-gd__chan {
	position: sticky;
	left: 0;
	z-index: 3;
	flex: none;
	width: var(--gd-chan);
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 1px;
	padding: 0 12px;
	min-width: 0;
	border-right: 1px solid var(--rule);
	background: var(--paper);
}
.rmt-gd__row.is-featured .rmt-gd__chan { box-shadow: inset 3px 0 0 var(--gd-feature); }
.rmt-gd__channame { font-weight: 700; font-size: 14px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rmt-gd__chankind { font-family: var(--mono); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rmt-gd__track {
	position: relative;
	flex: none;
	width: var(--gd-track);
	margin: 5px 0;
	background-image: repeating-linear-gradient(to right, transparent 0, transparent calc(var(--gd-slot) - 1px), var(--rule) calc(var(--gd-slot) - 1px), var(--rule) var(--gd-slot));
	background-size: auto;
}
.rmt-gd__prog { border-radius: 5px; }
/* guide.js pads a programme that began left of the view so its title stays readable beside the channel column. */
.rmt-gd__prog.is-cut { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.rmt-gd__prog.is-sel { background: var(--ink); color: var(--bg); opacity: 1; }
.rmt-gd__prog:focus-visible { outline: 2px solid var(--red); outline-offset: -2px; z-index: 2; }
.rmt-gd__now { --f: 0; left: 0; z-index: 2; width: 2px; background: var(--gd-line); }
.rmt-gd__nowlabel { position: sticky; top: calc(var(--gd-headh) + 4px); left: auto; display: inline-block; margin-left: 4px; background: var(--gd-line); color: #FFFFFF; }
.rmt-gd__now[hidden] { display: none; }

/* ---------- List view (phones) ---------- */
.rmt-gd__lv { border: 1px solid var(--rule); border-radius: 6px; background: var(--paper); }
.rmt-gd__lvbar {
	position: sticky;
	top: 0;
	z-index: 4;
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 10px;
	padding: 10px 14px;
	background: var(--ink);
	color: var(--bg);
	border-radius: 6px 6px 0 0;
}
.rmt-gd__lvnow { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #FF7A6E; }
.rmt-gd__lvclock { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; }
.rmt-gd__lvg { border-top: 1px solid var(--rule); }
.rmt-gd__lvg:first-child { border-top: 0; }
.rmt-gd__lvch {
	position: sticky;
	top: 38px;
	z-index: 2;
	margin: 0;
	padding: 8px 14px;
	background: var(--paper);
	font-family: var(--sans);
	font-size: 14px;
	font-weight: 700;
	border-bottom: 1px solid var(--rule);
}
.rmt-gd__lvg.is-featured .rmt-gd__lvch { box-shadow: inset 3px 0 0 var(--gd-feature); }
.rmt-gd__lvitems { list-style: none; margin: 0; padding: 0; }
.rmt-gd__li + .rmt-gd__li { border-top: 1px dashed var(--rule); }
.rmt-gd__libtn {
	width: 100%;
	display: flex;
	align-items: baseline;
	gap: 12px;
	min-height: 48px;
	padding: 8px 14px;
	border: 0;
	background: transparent;
	color: var(--ink);
	text-align: left;
}
.rmt-gd__libtn.is-on { background: var(--chip); }
.rmt-gd__libtn.is-on .rmt-gd__litime { color: var(--red-text); font-weight: 500; }
.rmt-gd__libtn.is-pick .rmt-gd__lishow { color: var(--red-text); }
.rmt-gd__libtn.is-sel { background: var(--ink); color: var(--bg); }
.rmt-gd__libtn.is-sel .rmt-gd__litime, .rmt-gd__libtn.is-sel .rmt-gd__lich { color: inherit; }
.rmt-gd__litime { flex: none; width: 66px; font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.rmt-gd__litext { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.rmt-gd__lishow { font-weight: 600; font-size: 15px; line-height: 1.25; }
.rmt-gd__lich { font-size: 12px; color: var(--muted); }
.rmt-gd__lvmore { display: block; width: 100%; min-height: 40px; padding: 0 14px 0 92px; border: 0; background: transparent; color: var(--red-text); font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-align: left; }
.rmt-gd__more { display: flex; margin: 14px auto; }

/* ---------- Streaming drops ---------- */
.rmt-gd__dropsfor { margin: 0 0 4px; font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.rmt-gd__plat.is-featured .rmt-gd__platname { color: var(--ink); }
.rmt-badge.is-finale { background: var(--ink); color: var(--bg); }

/* ---------- Detail panel (wide) / dialog (narrow) ---------- */
.rmt-gd__detail { position: relative; border-radius: 6px; background: var(--band); color: var(--band-ink); overflow: hidden; }
.rmt-gd__dclose {
	position: absolute;
	right: 10px;
	top: 10px;
	z-index: 3;
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 50%;
	background: rgba(10, 15, 34, .72);
	color: #F5F1E8;
	font-size: 26px;
	line-height: 1;
}
.rmt-gd__dclose:hover { background: var(--red); }
.rmt-gd__dtitle a { color: inherit; }
.rmt-gd__dtitle a:hover { color: #FF7A6E; }
.rmt-gd__dwhen a, .rmt-gd__dgenres a, .rmt-gd__dnch { color: inherit; text-decoration: underline; text-decoration-color: rgba(245, 241, 232, .35); text-underline-offset: 3px; }
.rmt-gd__dwhen a:hover, .rmt-gd__dgenres a:hover, .rmt-gd__dnch:hover { color: #FF7A6E; }
.rmt-gd__dtype { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: #FF7A6E; }
.rmt-gd__dlabel { margin: 18px 0 8px; font-family: var(--mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; opacity: .7; }
.rmt-gd__dcast { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
.rmt-gd__dcast--sk { margin-top: 18px; }
.rmt-gd__dcast--sk .rmt-gd__dperson { display: block; height: 40px; border-radius: 20px; background: rgba(245, 241, 232, .08); animation: rmtPulse 1.6s ease-in-out infinite; }
.rmt-gd__dpersonlink { display: flex; align-items: center; gap: 8px; min-width: 0; color: inherit; }
.rmt-gd__dpersonlink:hover .rmt-gd__dname { color: #FF7A6E; }
.rmt-gd__dhead { flex: none; width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: rgba(245, 241, 232, .12); display: grid; place-items: center; font-family: var(--mono); font-size: 12px; }
.rmt-gd__dhead img { width: 100%; height: 100%; object-fit: cover; }
.rmt-gd__dpname { min-width: 0; display: flex; flex-direction: column; }
.rmt-gd__dname { font-size: 13px; font-weight: 600; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rmt-gd__dchar { font-size: 11px; opacity: .7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rmt-gd__dnext { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.rmt-gd__dnext li { display: flex; flex-wrap: wrap; gap: 2px 10px; padding: 6px 0; border-top: 1px solid rgba(245, 241, 232, .12); }
.rmt-gd__dnwhen { font-family: var(--mono); font-size: 11px; min-width: 128px; opacity: .85; }
.rmt-gd__dnse { font-family: var(--mono); font-size: 11px; opacity: .65; }
.rmt-gd__full {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 52px;
	margin-top: 16px;
	padding: 0 20px;
	border-radius: 999px;
	background: #F5F1E8;
	color: #15161D;
	font-weight: 700;
	font-size: 16px;
	letter-spacing: .01em;
}
.rmt-gd__full:hover { background: #FF7A6E; color: #15161D; }
.rmt-gd__backdrop { display: none; }

@media (max-width: 1099.98px) {
	.rmt-gd__detail { display: none; }
	.rmt-gd__detail.is-open {
		display: block;
		position: fixed;
		z-index: 1000;
		left: 0;
		right: 0;
		bottom: 0;
		max-height: 88vh;
		max-width: 560px;
		margin: 0 auto;
		overflow-y: auto;
		border-radius: 12px 12px 0 0;
		box-shadow: 0 -12px 40px rgba(10, 15, 34, .35);
		animation: rmtGdUp .22s ease-out;
	}
	.rmt-gd.has-modal .rmt-gd__backdrop { display: block; position: fixed; inset: 0; z-index: 999; background: rgba(10, 15, 34, .55); }
	.rmt-gd__dmedia { aspect-ratio: 16 / 9; }
}
@media (min-width: 720px) and (max-width: 1099.98px) {
	.rmt-gd__detail.is-open { top: 50%; bottom: auto; transform: translateY(-50%); border-radius: 10px; animation: none; }
}
html.rmt-gd-lock, html.rmt-gd-lock body { overflow: hidden; }
@keyframes rmtGdUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Phones ---------- */
@media (max-width: 719.98px) {
	.rmt-gd { --gd-chan: 104px; --gd-max: 70vh; }
	.rmt-gd__chan { padding: 0 8px; }
	.rmt-gd__channame { font-size: 13px; }
	.rmt-gd__day { padding: 0 8px; font-size: 10px; }
	.rmt-gd__filters { flex-wrap: nowrap; flex-direction: column; align-items: stretch; }
	.rmt-gd__genres, .rmt-gd__quick { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
	.rmt-gd__genres::-webkit-scrollbar, .rmt-gd__quick::-webkit-scrollbar { display: none; }
	.rmt-gd__bar .rmt-gd__dates { flex: 1 1 100%; }
	.rmt-gd__jumps { width: 100%; }
	.rmt-gd__view { margin-left: auto; }
	.rmt-gd__hllist { grid-auto-columns: 76%; }
	.rmt-gd__search { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
	.rmt-gd__hlimg img { transition: none; }
	.rmt-gd__hlbtn:hover .rmt-gd__hlimg img, .rmt-gd__hlbtn:focus-visible .rmt-gd__hlimg img { transform: none; }
	.rmt-gd__detail.is-open { animation: none; }
	.rmt-gd__dcast--sk .rmt-gd__dperson { animation: none; }
}
