/* =====================================================================
   Embed Media — Bynder media-list grid + header button + lightbox theme.

   SCOPING: every rule below requires `.em-styled` on the widget div, so the
   plugin never restyles an embed it wasn't pointed at. The shortcode adds the
   class itself; raw embed code gets it from embed-media.js only when
   Admin → Advanced → "Style raw embeds" is set to every embed. Add class
   `em-raw` to any embed div (or an ancestor) to opt that one out.
   All colours/sizes come from CSS variables set by the plugin (admin page).
   Scoped to [data-bynder-widget="media-list"].em-styled (+ body classes for the
   optional header / lightbox theming) so nothing else is affected.
   ===================================================================== */

[data-bynder-widget="media-list"].em-styled {
	background: var(--em-bg, #050608);
	padding: var(--em-pad, 24px);
	border-radius: var(--em-radius, 10px);
}

[data-bynder-widget="media-list"].em-styled .bynder-widget,
[data-bynder-widget="media-list"].em-styled .bynder-widget-content {
	background: transparent !important;
	border: 0 !important;
	box-shadow: none !important;
	width: 100%;
}

/* --- Grid --------------------------------------------------------- */
[data-bynder-widget="media-list"].em-styled ul.bynder-widget-media-items {
	display: grid !important;
	grid-template-columns: repeat(var(--em-cols, 3), minmax(0, 1fr));
	gap: var(--em-gap, 24px);
	padding: 0 !important;
	margin: 0 !important;
	list-style: none;
}
[data-bynder-widget="media-list"].em-styled ul.bynder-widget-media-items::after {
	display: none !important;
	content: none !important;
}
[data-bynder-widget="media-list"].em-styled ul.bynder-widget-media-items li {
	display: block !important;
	position: relative;
	width: auto !important;
	margin: 0 !important;
	padding: 0 !important;
}

[data-bynder-widget="media-list"].em-styled ul.bynder-widget-media-items li a.bynder-widget-media-link,
[data-bynder-widget="media-list"].em-styled ul.bynder-widget-media-items li:hover a.bynder-widget-media-link {
	display: block !important;
	width: auto !important;
	max-width: none !important;
	margin: 0 !important;
	padding: 0 !important;
	background: transparent !important;
	border: 0 !important;
	border-radius: 0 !important;
	box-shadow: none !important;
	color: var(--em-title-color, #fff) !important;
	font-weight: 700;
	text-decoration: none !important;
	cursor: pointer;
}

/* --- Thumbnail (16:9 cover) -------------------------------------- */
[data-bynder-widget="media-list"].em-styled ul.bynder-widget-media-items li a .bynder-widget-mediaholder {
	width: 100% !important;
	height: auto !important;
	aspect-ratio: 16 / 9;
	background: var(--em-thumb-bg, #000) !important;
	border-radius: var(--em-radius, 10px);
	overflow: hidden;
	position: relative;
}
[data-bynder-widget="media-list"].em-styled ul.bynder-widget-media-items li a .bynder-widget-mediaholder img {
	position: absolute !important;
	inset: 0 !important;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	max-height: none !important;
	margin: 0 !important;
	object-fit: cover;
	transition: transform .4s ease;
}
[data-bynder-widget="media-list"].em-styled ul.bynder-widget-media-items li:hover a .bynder-widget-mediaholder img {
	transform: scale(1.05);
}

/* --- Play overlay (toggled per collection in the admin) ---------- */
[data-bynder-widget="media-list"].em-styled .bynder-widget-mediaholder::before {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	width: 54px;
	height: 54px;
	transform: translate(-50%, -50%);
	border: 2px solid rgba(255, 255, 255, .9);
	border-radius: 50%;
	background: rgba(0, 0, 0, .35);
	transition: background .3s ease, transform .3s ease;
	z-index: 2;
	pointer-events: none;
}
[data-bynder-widget="media-list"].em-styled .bynder-widget-mediaholder::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-40%, -50%);
	border-style: solid;
	border-width: 9px 0 9px 15px;
	border-color: transparent transparent transparent #fff;
	z-index: 3;
	pointer-events: none;
}
[data-bynder-widget="media-list"].em-styled li:hover .bynder-widget-mediaholder::before {
	background: rgba(0, 0, 0, .55);
	transform: translate(-50%, -50%) scale(1.08);
}

/* --- Title -------------------------------------------------------- */
[data-bynder-widget="media-list"].em-styled ul.bynder-widget-media-items li a p {
	width: 100% !important;
	margin: 12px 0 0 !important;
	padding: 0 !important;
	color: var(--em-title-color, #fff) !important;
	font-size: var(--em-title-size, 16px);
	line-height: 1.3;
	font-weight: 700;
	white-space: normal !important;
	overflow: visible !important;
	text-overflow: clip !important;
}

/* --- Responsive --------------------------------------------------- */
@media (max-width: 1024px) {
	[data-bynder-widget="media-list"].em-styled ul.bynder-widget-media-items { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
	[data-bynder-widget="media-list"].em-styled ul.bynder-widget-media-items { grid-template-columns: 1fr; }
}

/* --- Header "Download collection" button (optional) -------------- */
body.em-style-header [data-bynder-widget="media-list"].em-styled .bynder-widget-header {
	background: transparent !important;
	border: 0 !important;
	padding: 0 0 16px !important;
	color: var(--em-title-color, #fff) !important;
}
body.em-style-header [data-bynder-widget="media-list"].em-styled .bynder-widget-header a.bynder-widget-link {
	color: var(--em-title-color, #fff) !important;
}
body.em-style-header [data-bynder-widget="media-list"].em-styled .bynder-widget-header a.bynder-widget-btn {
	background: var(--em-accent, #1aa0e0) !important;
	color: #fff !important;
	border: 0 !important;
	border-radius: 6px !important;
	padding: 8px 14px !important;
	box-shadow: none !important;
	text-decoration: none !important;
}

/* --- Pop-up lightbox (optional) ---------------------------------- */
body.em-style-lightbox #bynder-widget-lightbox,
body.em-style-lightbox #bynder-widget-lightbox > .bynder-widget-figure {
	background: var(--em-lb-bg, #050608) !important;
}
body.em-style-lightbox #bynder-widget-lightbox .bynder-widget-table-wrapper,
body.em-style-lightbox #bynder-widget-lightbox .bynder-widget-overlay-detail {
	background: var(--em-lb-panel, #0c0e12) !important;
	color: var(--em-lb-text, #fff) !important;
}
body.em-style-lightbox #bynder-widget-lightbox .bynder-widget-overlay-detail,
body.em-style-lightbox #bynder-widget-lightbox .bynder-widget-overlay-detail b,
body.em-style-lightbox #bynder-widget-lightbox .bynder-widget-overlay-detail span,
body.em-style-lightbox #bynder-widget-lightbox .bynder-widget-overlay-detail a {
	color: var(--em-lb-text, #fff) !important;
}
body.em-style-lightbox #bynder-widget-lightbox .bynder-widget-overlay-detail a.bynder-widget-btn {
	background: var(--em-lb-accent, #1aa0e0) !important;
	color: #fff !important;
	border: 0 !important;
	border-radius: 6px !important;
}

/* =====================================================================
   App renderer ("app" mode) — Grid / List + language tabs + pop-up.
   Themed via: --em-app-bg, --em-card-bg, --em-card-fg, --em-accent.
   ===================================================================== */
.em-app {
	background: var(--em-app-bg, transparent);
	color: var(--em-card-fg, #16202e);
	/* Set explicitly rather than inherited: themes/Elementor style block-level
	   text in ways that leak into the cards (a serif turning up on the names).
	   Admin → Card font sets --em-font; blank there = inherit from the page. */
	font-family: var(--em-font, inherit);
}
/* Everything inside the app follows it — including elements the browser or the
   theme would otherwise style on their own (buttons, inputs, links). */
.em-app .em-name,
.em-app .em-ttl,
.em-app .em-desc,
.em-app .em-lang,
.em-app .em-chip,
.em-app .em-act,
.em-app .em-bar button {
	font-family: inherit;
}
.em-app .em-loading,
.em-app .em-error {
	padding: 32px;
	text-align: center;
	color: var(--em-card-fg, #16202e);
	opacity: .7;
}

.em-app .em-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px 18px;
	margin: 0 0 22px;
}
.em-app .em-views,
.em-app .em-langs,
.em-app .em-cats {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 6px;
}
.em-app .em-langs,
.em-app .em-cats { margin-left: auto; }
/* Folder tabs can be many — let them wrap and sit right of the view toggle. */
.em-app .em-cats { justify-content: flex-end; }
.em-app .em-bar button {
	appearance: none;
	cursor: pointer;
	font: inherit;
	font-size: 13px;
	line-height: 1;
	padding: 9px 18px;
	border-radius: var(--em-btn-radius, 999px);
	border: 1px solid var(--em-accent, #1aa0e0);
	background: transparent;
	color: var(--em-accent, #1aa0e0);
}
.em-app .em-bar button.on {
	background: var(--em-accent, #1aa0e0);
	color: #fff;
}

/* --- Grid ---
   Cards are full-bleed: the artwork runs edge to edge at the top of the card
   (no accent frame), then a white body with name / sub-heading / icons.
   Tunables: --em-card-radius, --em-card-border, --em-thumb-ratio,
   --em-thumb-fit, --em-thumb-pos, --em-body-pad. */
.em-app .em-cards {
	display: grid;
	grid-template-columns: repeat(var(--em-cols, 4), minmax(0, 1fr));
	gap: var(--em-gap, 24px);
}
/* Folder heading (Grouping = "Group by category" in App mode). Spans the full
   grid row so the cards below it stay on the normal column rhythm. */
.em-app .em-cat {
	grid-column: 1 / -1;
	margin: 18px 0 2px;
	padding-bottom: 8px;
	border-bottom: 1px solid var(--em-card-border, rgba(0, 0, 0, .12));
	color: var(--em-card-fg, #16202e);
	font-size: var(--em-cat-size, 20px);
	font-weight: 700;
	line-height: 1.2;
}
.em-app .em-cards > .em-cat:first-child {
	margin-top: 0;
}
.em-app .em-cards.em-list .em-cat {
	margin: 22px 0 10px;
}
.em-app .em-card {
	position: relative;
	background: var(--em-card-bg, #ffffff);
	border: 1px solid var(--em-card-border, rgba(0, 0, 0, .08));
	border-radius: var(--em-card-radius, 0);
	padding: 0;
	overflow: hidden;
	text-align: center;
	display: flex;
	flex-direction: column;
}
/* The feed's thumbnails are 16:9 (250×141), so a 16:9 box + `cover` fills the
   card edge to edge without cropping the artwork's own title text. */
.em-app .em-frame {
	position: relative;
	width: 100%;
	aspect-ratio: var(--em-thumb-ratio, 16 / 9);
	margin: 0;
	border: 0;
	background: var(--em-thumb-bg, #f3f4f6);
	overflow: hidden;
}
.em-app .em-frame img {
	width: 100%;
	height: 100%;
	object-fit: var(--em-thumb-fit, cover);
	object-position: var(--em-thumb-pos, center center);
	display: block;
}
.em-app .em-body {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: var(--em-body-pad, 18px 16px 22px);
}
/* Language badge, description, format detail and labelled download buttons:
   List view only — Grid stays minimal (artwork / name / sub-heading / icons). */
.em-app .em-lang,
.em-app .em-desc,
.em-app .em-meta,
.em-app .em-actions {
	display: none;
}
/* …except on the "All" tab of a multi-language collection, where the same
   speaker appears once per language and the cards are otherwise identical.
   Added by the JS (em-show-lang) only in that case. */
.em-app .em-cards.em-show-lang:not(.em-list) .em-lang {
	display: block;
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 2;
	padding: 4px 10px;
	border-radius: var(--em-btn-radius, 999px);
	background: rgba(255, 255, 255, .94);
	color: #16202e;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
}
/* hover Download button on the card thumbnail */
.em-app .em-dl {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 9px 8px;
	background: var(--em-accent, #1aa0e0);
	color: #fff;
	font-size: 13px;
	font-weight: 700;
	text-decoration: none;
	opacity: 0;
	transform: translateY(100%);
	transition: opacity .2s ease, transform .2s ease;
}
.em-app .em-card:hover .em-dl,
.em-app .em-card:focus-within .em-dl {
	opacity: 1;
	transform: translateY(0);
}
.em-app .em-name {
	color: var(--em-accent, #1aa0e0);
	font-size: 22px;
	font-weight: 700;
	line-height: 1.15;
	margin: 0 0 8px;
	overflow-wrap: break-word;
}
.em-app .em-ttl {
	color: var(--em-card-fg, #16202e);
	font-size: 16px;
	font-weight: var(--em-ttl-weight, 500);
	line-height: 1.3;
	margin: 0 0 14px;
	flex: 1 0 auto;
}
.em-app .em-icons {
	display: flex;
	justify-content: center;
	gap: 18px;
}
.em-app .em-ic {
	appearance: none;
	border: 0;
	background: transparent;
	cursor: pointer;
	color: var(--em-card-fg, #16202e);
	padding: 4px;
	line-height: 0;
	transition: color .2s ease, transform .2s ease;
}
.em-app .em-ic svg {
	width: var(--em-icon-size, 40px);
	height: var(--em-icon-size, 40px);
	display: block;
}
.em-app .em-ic:hover {
	color: var(--em-accent, #1aa0e0);
	transform: scale(1.1);
}

/* --- List view ---
   Wide row: artwork left, name / sub-heading / description / icons stacked on
   the right, language top-right. Tunables: --em-list-thumb, --em-list-pad. */
.em-app .em-cards.em-list {
	display: block;
}
.em-app .em-cards.em-list .em-card {
	flex-direction: row;
	align-items: center;
	text-align: left;
	gap: 22px;
	padding: var(--em-list-pad, 16px);
	margin-bottom: 14px;
}
.em-app .em-cards.em-list .em-frame {
	width: var(--em-list-thumb, 260px);
	flex: 0 0 auto;
	align-self: center;
}
.em-app .em-cards.em-list .em-body {
	align-items: flex-start;
	text-align: left;
	padding: 0 96px 0 0; /* room for the language badge */
}
.em-app .em-cards.em-list .em-name {
	font-size: var(--em-list-name, 28px);
	margin: 0 0 2px;
}
.em-app .em-cards.em-list .em-ttl {
	font-size: 17px;
	margin: 0;
	flex: 0 0 auto;
}
.em-app .em-cards.em-list .em-desc {
	display: block;
	font-size: 15px;
	font-weight: 400;
	line-height: 1.5;
	margin: 8px 0 0;
	opacity: .85;
}
.em-app .em-cards.em-list .em-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 10px 0 0;
}
.em-app .em-cards.em-list .em-chip {
	font-size: 12px;
	font-weight: 400;
	line-height: 1.2;
	padding: 5px 10px;
	border: 1px solid var(--em-card-border, rgba(0, 0, 0, .14));
	border-radius: var(--em-btn-radius, 999px);
	white-space: nowrap;
}
.em-app .em-cards.em-list .em-chip b {
	font-weight: 700;
}
.em-app .em-cards.em-list .em-icons {
	justify-content: flex-start;
	align-items: center;
	gap: 20px;
	margin-top: 14px;
}
.em-app .em-cards.em-list .em-actions {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-left: 6px;
}
.em-app .em-cards.em-list .em-act {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	font-weight: 700;
	line-height: 1;
	padding: 8px 14px;
	border-radius: var(--em-btn-radius, 999px);
	border: 1px solid var(--em-accent, #1aa0e0);
	color: var(--em-accent, #1aa0e0);
	text-decoration: none;
	white-space: nowrap;
}
.em-app .em-cards.em-list .em-act:hover {
	background: var(--em-accent, #1aa0e0);
	color: #fff;
}
.em-app .em-cards.em-list .em-lang {
	display: block;
	position: absolute;
	top: var(--em-list-pad, 16px);
	right: 20px;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--em-card-fg, #16202e);
}

@media (max-width: 1024px) {
	.em-app .em-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.em-app .em-cards.em-list .em-frame { width: var(--em-list-thumb-md, 200px); }
}
@media (max-width: 600px) {
	.em-app .em-cards { grid-template-columns: 1fr; }
	.em-app .em-langs { margin-left: 0; }
	/* List rows stack like grid cards on phones. */
	.em-app .em-cards.em-list .em-card {
		flex-direction: column;
		align-items: stretch;
		padding: 0;
		gap: 0;
	}
	.em-app .em-cards.em-list .em-frame { width: 100%; }
	.em-app .em-cards.em-list .em-body { padding: 16px; }
	.em-app .em-cards.em-list .em-lang { position: static; margin-bottom: 6px; }
}

/* --- Two-pane lightbox (app mode): media left, download details right --- */
.em-lb {
	position: fixed;
	inset: 0;
	z-index: 99999;
	background: var(--em-lb-bg, rgba(2, 4, 8, .92));
	display: flex;
	align-items: center;
	justify-content: center;
	/* The pop-up is appended to <body>, outside .em-app, so it needs the font
	   set on it directly — the variable is emitted for both selectors. */
	font-family: var(--em-font, inherit);
}
.em-lb button,
.em-lb input,
.em-lb table,
.em-lb label {
	font-family: inherit;
}
.em-lb-stage {
	display: flex;
	width: 100%;
	height: 100%;
	align-items: stretch;
}
.em-lb-media {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 3vh 2vw;
}
.em-lb-media img,
.em-lb-media video {
	max-width: 100%;
	max-height: 92vh;
	display: block;
	background: #000;
}
.em-lb-panel {
	flex: 0 0 360px;
	max-width: 42vw;
	background: var(--em-lb-panel, #0c0e12);
	color: var(--em-lb-text, #fff);
	padding: 28px 26px;
	overflow-y: auto;
	overscroll-behavior: contain;
	/* Transparent track so the scrollbar doesn't paint a grey strip over the
	   panel edge; slim overlay thumb instead. */
	scrollbar-width: thin;
	scrollbar-color: rgba(255, 255, 255, .28) transparent;
}
.em-lb-panel::-webkit-scrollbar {
	width: 8px;
}
.em-lb-panel::-webkit-scrollbar-track {
	background: transparent;
}
.em-lb-panel::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, .28);
	border-radius: 4px;
}
.em-lb-panel::-webkit-scrollbar-thumb:hover {
	background: rgba(255, 255, 255, .45);
}
.em-lb-name { font-size: 17px; font-weight: 700; line-height: 1.35; }
.em-lb-acct { opacity: .65; font-size: 14px; margin-top: 2px; }
.em-lb-brand { font-size: 14px; margin: 14px 0 12px; }
.em-lb-brand b { font-weight: 700; }
.em-lb-fmt { width: 100%; border-collapse: collapse; font-size: 13px; }
.em-lb-fmt td { padding: 9px 10px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.em-lb-fmt tr:nth-child(odd) td { background: rgba(255, 255, 255, .03); }
.em-lb-fmt td:first-child { font-weight: 700; }
.em-lb-choose {
	margin-top: 16px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}
.em-lb-opt {
	display: flex;
	align-items: center;
	gap: 9px;
	font-size: 14px;
	cursor: pointer;
}
.em-lb-opt input { width: 16px; height: 16px; cursor: pointer; }
.em-lb-opt.em-lb-off { opacity: .5; cursor: default; }
.em-lb-dl {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	margin-top: 16px;
	padding: 12px;
	border: 0;
	cursor: pointer;
	background: var(--em-lb-accent, #1aa0e0);
	color: #fff;
	font-weight: 700;
	font-size: 14px;
	text-decoration: none;
	border-radius: 6px;
}
.em-lb-x, .em-lb-prev, .em-lb-next {
	position: absolute;
	z-index: 2;
	border: 0;
	background: transparent;
	color: #fff;
	cursor: pointer;
	line-height: 1;
}
.em-lb-x { top: 14px; right: 18px; font-size: 30px; }
.em-lb-prev, .em-lb-next { top: 50%; transform: translateY(-50%); font-size: 48px; opacity: .8; padding: 8px 14px; }
.em-lb-prev { left: 8px; }
.em-lb-next { right: calc(360px + 8px); }
.em-lb-prev:hover, .em-lb-next:hover { opacity: 1; }
@media (max-width: 800px) {
	.em-lb-stage { flex-direction: column; }
	.em-lb-media { padding: 8px; flex: 0 0 auto; }
	.em-lb-media img, .em-lb-media video { max-height: 48vh; }
	.em-lb-panel { flex: 1 1 auto; max-width: none; }
	.em-lb-next { right: 8px; }
	.em-lb-prev, .em-lb-next { top: 40%; font-size: 36px; }
}
