/* Eventeny Schedule Grid
 * Override any --esg-* variable in your theme's Additional CSS to restyle, e.g.
 * .esg { --esg-accent: #7b2d8e; }
 */
.esg {
	--esg-ink: #1e2b33;
	--esg-muted: #5e6b74;
	--esg-line: #d9e0e5;
	--esg-line-soft: #edf1f4;
	--esg-surface: #ffffff;
	--esg-head: #f4f7f9;
	--esg-accent: #1f5c86;
	--esg-now: #c8332b;
	--esg-col: 184px;
	--esg-gutter: 64px;
	--esg-hour: 96px;

	color: var(--esg-ink);
	font: inherit;
	line-height: 1.4;
	margin: 1.5em 0;
}
.esg *,
.esg *::before,
.esg *::after { box-sizing: border-box; }

.esg [hidden] { display: none !important; }
.esg button { font: inherit; color: inherit; cursor: pointer; }
.esg :focus-visible { outline: 2px solid var(--esg-accent); outline-offset: 2px; }

/* ---------- Toolbar ---------- */
.esg-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 12px 24px;
	border-bottom: 1px solid var(--esg-line);
}
.esg-days { display: flex; flex-wrap: wrap; gap: 4px; }
.esg-day {
	background: none;
	border: 0;
	border-bottom: 3px solid transparent;
	padding: 10px 14px 9px;
	margin-bottom: -1px;
	font-weight: 600;
	color: var(--esg-muted);
}
.esg-day:hover { color: var(--esg-ink); }
.esg-day[aria-selected="true"] { color: var(--esg-accent); border-bottom-color: var(--esg-accent); }
.esg-day-count {
	display: inline-block;
	min-width: 1.6em;
	margin-left: 6px;
	padding: 0 6px;
	border-radius: 999px;
	background: var(--esg-line-soft);
	font-size: 0.8em;
	font-weight: 600;
	text-align: center;
}
.esg-day[aria-selected="true"] .esg-day-count { background: var(--esg-accent); color: #fff; }

.esg-tools { display: flex; gap: 8px; padding-bottom: 8px; flex: 1 1 280px; justify-content: flex-end; }
.esg-search {
	flex: 1 1 200px;
	max-width: 320px;
	min-width: 0;
	padding: 8px 12px;
	border: 1px solid var(--esg-line);
	border-radius: 6px;
	background: var(--esg-surface);
	font: inherit;
	color: inherit;
}
.esg-toggle {
	padding: 8px 14px;
	border: 1px solid var(--esg-line);
	border-radius: 6px;
	background: var(--esg-surface);
	white-space: nowrap;
}
.esg-toggle[aria-expanded="true"] { border-color: var(--esg-accent); color: var(--esg-accent); }

/* ---------- Filters ---------- */
.esg-filters { padding: 14px 0 4px; border-bottom: 1px solid var(--esg-line); }
.esg-filters[hidden] { display: none; }
.esg-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.esg-group-name { font-weight: 600; margin-right: 6px; font-size: 0.9em; }
.esg-chip {
	padding: 4px 12px;
	border: 1px solid var(--esg-line);
	border-radius: 999px;
	background: var(--esg-surface);
	font-size: 0.9em;
}
.esg-chip[aria-pressed="true"] { background: var(--esg-accent); border-color: var(--esg-accent); color: #fff; }
.esg-clear { background: none; border: 0; text-decoration: underline; color: var(--esg-accent); font-size: 0.9em; padding: 4px; }

/* ---------- Room slider ---------- */
.esg-nav {
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 10px;
	padding: 12px 0 8px;
}
.esg-nav[hidden] { display: none; }
.esg-step {
	width: 36px;
	height: 36px;
	border: 1px solid var(--esg-line);
	border-radius: 50%;
	background: var(--esg-surface);
	font-size: 18px;
	line-height: 1;
	display: grid;
	place-items: center;
}
.esg-step:disabled { opacity: 0.35; cursor: default; }
.esg-ruler {
	position: relative;
	height: 28px;
	border-radius: 6px;
	background: var(--esg-head);
	border: 1px solid var(--esg-line);
	cursor: pointer;
	touch-action: none;
}
.esg-tick {
	position: absolute;
	top: 7px;
	bottom: 7px;
	width: 2px;
	border-radius: 1px;
	background: var(--esg-line);
	pointer-events: none;
}
.esg-tick.is-match { background: var(--esg-muted); }
.esg-thumb {
	position: absolute;
	top: -1px;
	bottom: -1px;
	min-width: 28px;
	border: 2px solid var(--esg-accent);
	border-radius: 6px;
	background: color-mix(in srgb, var(--esg-accent) 14%, transparent);
	cursor: grab;
	touch-action: none;
}
.esg-thumb.is-dragging { cursor: grabbing; }
.esg-where { grid-column: 1 / -1; font-size: 0.85em; color: var(--esg-muted); text-align: center; }

/* ---------- Grid ---------- */
.esg-scroller {
	position: relative;
	height: var(--esg-height, 75vh);
	min-height: 320px;
	overflow: auto;
	border: 1px solid var(--esg-line);
	border-radius: 8px;
	background: var(--esg-surface);
	overscroll-behavior-x: contain;
}
.esg-grid { position: relative; }

.esg-head {
	position: sticky;
	top: 0;
	z-index: 3;
	display: flex;
	background: var(--esg-head);
	border-bottom: 1px solid var(--esg-line);
}
.esg-corner {
	position: sticky;
	left: 0;
	z-index: 4;
	flex: 0 0 var(--esg-gutter);
	background: var(--esg-head);
	border-right: 1px solid var(--esg-line);
}
.esg-room {
	flex: 0 0 auto;
	padding: 8px 10px;
	border-right: 1px solid var(--esg-line);
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
}
.esg-room-area { font-size: 0.75em; color: var(--esg-muted); }
.esg-room-name {
	font-weight: 700;
	font-size: 0.92em;
	line-height: 1.25;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	overflow: hidden;
}

.esg-body { display: flex; position: relative; }
.esg-times {
	position: sticky;
	left: 0;
	z-index: 2;
	flex: 0 0 var(--esg-gutter);
	background: var(--esg-surface);
	border-right: 1px solid var(--esg-line);
}
.esg-hour {
	position: absolute;
	right: 8px;
	transform: translateY(-50%);
	font-size: 0.75em;
	color: var(--esg-muted);
	white-space: nowrap;
}
.esg-col {
	position: relative;
	flex: 0 0 auto;
	border-right: 1px solid var(--esg-line-soft);
	background-image:
		linear-gradient(to bottom, var(--esg-line) 1px, transparent 1px),
		linear-gradient(to bottom, var(--esg-line-soft) 1px, transparent 1px);
	background-size: 100% var(--esg-hour), 100% calc(var(--esg-hour) / 2);
}

/* ---------- Sessions ---------- */
.esg-slot { position: absolute; }
.esg-slot:hover,
.esg-slot:focus-within { z-index: 1; }
.esg-session {
	position: absolute;
	inset: 0;
	width: 100%;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	overflow: clip;
	padding: 5px 8px;
	border: 0;
	border-radius: 5px;
	box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.12);
	text-align: left;
	font-size: 0.82em;
	line-height: 1.25;
}
.esg-session:hover { box-shadow: inset 0 0 0 2px rgb(0 0 0 / 0.35); }
/* Title stays in view while you scroll past a long block */
.esg-s-head {
	position: sticky;
	top: calc(var(--esg-head-h, 0px) + 5px);
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
	padding-right: 20px; /* room for the heart */
}
.esg-s-title { font-weight: 700; overflow-wrap: anywhere; }
.esg-s-time { opacity: 0.85; }
.esg-session.is-short { padding-top: 2px; }
.esg-session.is-short .esg-s-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.esg-session.is-short .esg-s-time { display: none; }
.esg-session.cb { border-top-left-radius: 0; border-top-right-radius: 0; }
.esg-session.ca { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.esg-session.is-cancelled {
	background-image: repeating-linear-gradient(135deg, rgb(255 255 255 / 0.55) 0 6px, transparent 6px 12px);
}
.esg-session.is-cancelled .esg-s-title { text-decoration: line-through; }
.esg-slot.is-dim { opacity: 0.18; }
.esg-slot.is-dim:hover,
.esg-slot.is-dim:focus-within { opacity: 0.6; }

/* ---------- Favorites ---------- */
.esg {
	--esg-fav: #d6336c;
}
.esg .esg-fav {
	position: absolute;
	top: 3px;
	right: 3px;
	width: 22px;
	height: 22px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	display: grid;
	place-items: center;
	background: rgb(255 255 255 / 0.7);
	color: var(--esg-fav);
}
.esg-fav svg { fill: none; stroke: currentColor; stroke-width: 2.4; }
.esg .esg-fav:hover { background: #fff; }
.esg-slot.is-short .esg-fav { top: 50%; transform: translateY(-50%); width: 18px; height: 18px; }
.esg-slot.is-fav .esg-fav { background: #fff; }
.esg-slot.is-fav .esg-fav svg,
.esg-favs[aria-pressed="true"] svg,
.esg-d-fav[aria-pressed="true"] svg { fill: currentColor; }
.esg-slot.is-fav .esg-session { box-shadow: inset 0 0 0 2px var(--esg-fav); }

.esg-favs { display: inline-flex; align-items: center; gap: 6px; }
.esg-favs svg,
.esg-d-fav svg { fill: none; stroke: currentColor; stroke-width: 2.2; }
.esg-favs svg { color: var(--esg-fav); }
.esg .esg-favs[aria-pressed="true"] { background: var(--esg-fav); border-color: var(--esg-fav); color: #fff; }
.esg-favs[aria-pressed="true"] svg { color: #fff; }

.esg .esg-d-fav {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin: 14px 0 0;
	padding: 7px 14px;
	border: 1px solid var(--esg-fav);
	border-radius: 999px;
	background: var(--esg-surface);
	color: var(--esg-fav);
	font-weight: 600;
}
.esg .esg-d-fav[aria-pressed="true"] { background: var(--esg-fav); color: #fff; }
.esg-d-fav + .esg-d-tags { margin-top: 12px; }

.esg-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--esg-now); z-index: 2; pointer-events: none; }
.esg-now-label {
	position: absolute;
	right: 4px;
	transform: translateY(-50%);
	padding: 1px 6px;
	border-radius: 4px;
	background: var(--esg-now);
	color: #fff;
	font-size: 0.7em;
	font-weight: 700;
}

.esg-empty { padding: 40px 16px; text-align: center; color: var(--esg-muted); }
.esg-empty[hidden] { display: none; }
.esg-updated { margin-top: 8px; font-size: 0.8em; color: var(--esg-muted); }

/* ---------- Details dialog ---------- */
.esg-dialog {
	width: min(560px, calc(100vw - 32px));
	max-height: calc(100vh - 64px);
	padding: 0;
	border: 0;
	border-radius: 10px;
	color: var(--esg-ink);
	background: var(--esg-surface);
	box-shadow: 0 20px 60px rgb(0 0 0 / 0.3);
}
.esg-dialog::backdrop { background: rgb(15 25 32 / 0.5); }
.esg-d-band { height: 8px; }
.esg-d-inner { padding: 20px 24px 24px; position: relative; }
.esg-d-close {
	position: absolute;
	top: 10px;
	right: 10px;
	width: 36px;
	height: 36px;
	border: 0;
	border-radius: 50%;
	background: var(--esg-line-soft);
	font-size: 20px;
	line-height: 1;
}
.esg-d-title { margin: 0 44px 10px 0; font-size: 1.3em; line-height: 1.25; }
.esg-d-meta { margin: 0 0 4px; }
.esg-d-loc { color: var(--esg-muted); }
.esg-d-status {
	display: inline-block;
	margin: 8px 0 0;
	padding: 2px 10px;
	border-radius: 999px;
	background: #fbe3e1;
	color: #8f1f17;
	font-weight: 700;
	font-size: 0.85em;
}
.esg-d-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 0; padding: 0; list-style: none; }
.esg-d-tags li { padding: 2px 10px; border-radius: 999px; background: var(--esg-line-soft); font-size: 0.85em; }
.esg-d-desc { margin: 16px 0 0; white-space: pre-line; max-width: 65ch; }

@media (max-width: 640px) {
	.esg { --esg-col: 152px; --esg-gutter: 52px; }
	.esg-tools { flex-basis: 100%; }
	.esg-days { flex-wrap: nowrap; overflow-x: auto; width: 100%; scrollbar-width: none; }
	.esg-day { padding: 10px 10px 9px; white-space: nowrap; }
	.esg-search { max-width: none; }
}
@media (prefers-reduced-motion: no-preference) {
	.esg-scroller { scroll-behavior: smooth; }
	.esg-scroller.is-dragging { scroll-behavior: auto; }
}
