.mgm-gallery-widget {
	--mgm-columns: 4;
	--mgm-gap: 8px;
}

/* Grid layout: uniform squares, cropped - the original behavior, still
   available as an option for anyone who prefers a strict, tidy grid. */
.mgm-gallery-widget--grid .mgm-gallery-widget__grid {
	display: grid;
	grid-template-columns: repeat( var( --mgm-columns ), 1fr );
	gap: var( --mgm-gap );
}

.mgm-gallery-widget--grid .mgm-gallery-widget__item img {
	aspect-ratio: 1;
	object-fit: cover;
}

/* Masonry layout (default): each photo keeps its natural proportions,
   nothing gets cropped - a Pinterest-style column flow using CSS
   multi-column, which needs no JavaScript and no layout-shift risk. */
.mgm-gallery-widget--masonry .mgm-gallery-widget__grid {
	column-count: var( --mgm-columns );
	column-gap: var( --mgm-gap );
}

.mgm-gallery-widget--masonry .mgm-gallery-widget__item {
	break-inside: avoid;
	margin-bottom: var( --mgm-gap );
}

/* Once front-gallery.js has laid the photos out (in filename order, left
   to right), it positions each item itself - switch the multi-column
   flow off so the two don't fight. Without JS the columns above remain. */
.mgm-gallery-widget--masonry .mgm-gallery-widget__grid.is-masonry-js {
	column-count: auto;
	position: relative;
}

.mgm-gallery-widget--masonry .mgm-gallery-widget__grid.is-masonry-js .mgm-gallery-widget__item {
	position: absolute;
	top: 0;
	left: 0;
	margin-bottom: 0;
}

.mgm-gallery-widget__item {
	position: relative;
	overflow: hidden;
	line-height: 0;
}

.mgm-gallery-widget__item a,
.mgm-gallery-widget__item img {
	display: block;
	width: 100%;
	height: auto;
}

.mgm-gallery-widget__item img {
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.mgm-gallery-widget__item a:hover img {
	opacity: 0.88;
}

.mgm-gallery-widget__load-more {
	display: block;
	margin: 24px auto 0;
	padding: 12px 28px;
	background: #1d2327;
	color: #fff;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	font-size: 14px;
	transition: background 0.15s ease;
}

.mgm-gallery-widget__load-more:hover {
	background: #2c3338;
}

.mgm-gallery-widget__load-more:disabled {
	opacity: 0.6;
	cursor: default;
}

.mgm-gallery-widget__placeholder {
	padding: 24px;
	text-align: center;
	color: #8c8f94;
	border: 1px dashed #c3c4c7;
	border-radius: 4px;
}

.mgm-gallery-widget__download {
	margin-top: 20px;
	text-align: center;
}

.mgm-gallery-widget__download-button {
	display: inline-block;
	padding: 12px 28px;
	background: transparent;
	color: #1d2327;
	border: 1px solid #1d2327;
	border-radius: 4px;
	cursor: pointer;
	font-size: 14px;
	transition: background 0.15s ease, color 0.15s ease;
}

.mgm-gallery-widget__download-button:hover {
	background: #1d2327;
	color: #fff;
}

.mgm-gallery-widget__download-button:disabled {
	opacity: 0.6;
	cursor: default;
}

.mgm-gallery-widget__download-progress {
	max-width: 320px;
	margin: 0 auto;
}

.mgm-gallery-widget__download-bar {
	height: 6px;
	background: #e2e4e7;
	border-radius: 3px;
	overflow: hidden;
}

.mgm-gallery-widget__download-bar-fill {
	height: 100%;
	width: 0%;
	background: #1d2327;
	transition: width 0.2s ease;
}

.mgm-gallery-widget__download-status {
	display: block;
	width: fit-content;
	max-width: 90vw;
	margin: 8px auto 0;
	padding: 4px 12px;
	background: rgba( 255, 255, 255, 0.92 );
	color: #1d2327;
	border-radius: 4px;
	font-size: 13px;
	text-align: center;
	line-height: 1.4;
}

.mgm-gallery-widget__download-status:empty {
	display: none;
}

.mgm-download-trigger--busy {
	opacity: 0.6;
	pointer-events: none;
}

.mgm-download-trigger__status {
	width: max-content;
	max-width: 90vw;
	padding: 4px 12px;
	background: rgba( 255, 255, 255, 0.92 );
	color: #1d2327;
	border-radius: 4px;
	font-size: 12px;
	text-align: center;
	line-height: 1.4;
	z-index: 99999;
}

.mgm-download-trigger__status:empty {
	display: none;
}

.mgm-favorites-trigger--busy {
	opacity: 0.6;
	pointer-events: none;
}

.mgm-favorites-trigger__status {
	width: max-content;
	max-width: 90vw;
	padding: 4px 12px;
	background: rgba( 255, 255, 255, 0.92 );
	color: #1d2327;
	border-radius: 4px;
	font-size: 12px;
	text-align: center;
	line-height: 1.4;
	z-index: 99999;
}

.mgm-favorites-trigger__status:empty {
	display: none;
}

.mgm-gallery-widget__single-download {
	position: absolute;
	bottom: 8px;
	right: 8px;
	z-index: 2;
	width: 32px;
	height: 32px;
	line-height: 32px;
	text-align: center;
	padding: 0;
	background: rgba( 0, 0, 0, 0.45 );
	color: #fff;
	border: none;
	border-radius: 50%;
	font-size: 16px;
	cursor: pointer;
	transition: transform 0.1s ease, background 0.15s ease;
}

.mgm-gallery-widget__single-download:hover {
	background: rgba( 0, 0, 0, 0.65 );
	transform: scale( 1.08 );
}

.mgm-gallery-widget__favorite {
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 2;
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	background: rgba( 0, 0, 0, 0.45 );
	color: #fff;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	transition: transform 0.1s ease, background 0.15s ease, color 0.15s ease;
}

.mgm-gallery-widget__favorite svg {
	width: 16px;
	height: 16px;
}

.mgm-gallery-widget__favorite:hover {
	background: rgba( 0, 0, 0, 0.65 );
	transform: scale( 1.08 );
}

.mgm-gallery-widget__favorite.is-selected {
	background: rgba( 0, 0, 0, 0.75 );
	color: #fff;
}

.mgm-gallery-widget__favorites-toggle {
	text-align: center;
	margin-bottom: var( --mgm-gap, 16px );
}

.mgm-gallery-widget__favorites-button {
	display: inline-block;
	padding: 10px 22px;
	background: transparent;
	color: #1d2327;
	border: 1px solid #1d2327;
	border-radius: 4px;
	cursor: pointer;
	font-size: 13px;
	transition: background 0.15s ease, color 0.15s ease;
}

.mgm-gallery-widget__favorites-button:hover {
	background: #1d2327;
	color: #fff;
}

.mgm-gallery-widget__favorites-button:disabled {
	opacity: 0.6;
	cursor: default;
}

.mgm-gallery-widget__favorites-count {
	display: block;
	margin-top: 8px;
	font-size: 13px;
	color: #50575e;
}

.mgm-lightbox-favorite {
	position: absolute;
	z-index: 100000;
	width: 44px;
	height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	background: rgba( 0, 0, 0, 0.45 );
	color: #fff;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	transition: transform 0.1s ease, background 0.15s ease;
}

.mgm-lightbox-favorite svg {
	width: 22px;
	height: 22px;
}

.mgm-lightbox-favorite:hover {
	background: rgba( 0, 0, 0, 0.65 );
	transform: scale( 1.08 );
}

.mgm-lightbox-favorite.is-selected {
	background: rgba( 0, 0, 0, 0.75 );
}

@media ( max-width: 767px ) {
	.mgm-gallery-widget--grid .mgm-gallery-widget__grid,
	.mgm-gallery-widget--masonry .mgm-gallery-widget__grid {
		--mgm-columns: 2;
	}
}
