/* Customer Cloud Gallery frontend styles */

.ccgal-gallery {
	--ccgal-img-size: 300px;
	--ccgal-gap: 10px;
	--ccgal-accent: var(--ccgal-accent-override, var(--wp--preset--color--primary, var(--wp--preset--color--accent, var(--ast-global-color-0, #b08e5a))));
	--ccgal-accent-dark: var(--ccgal-hover-override, color-mix(in srgb, var(--ccgal-accent) 80%, #000));
	--ccgal-surface: #faf8f4;
	--ccgal-surface-alt: #f1ede3;
	--ccgal-border: var(--ccgal-border-override, #e6dfce);
	--ccgal-text: #2b2a28;
	--ccgal-muted: #7a756c;
	--ccgal-tile-bg: #ece8df;
	--ccgal-radius: 3px;
	--ccgal-shadow: 0 1px 2px rgba(20, 18, 14, 0.06), 0 6px 18px rgba(20, 18, 14, 0.06);
	max-width: 100%;
	margin: 0 auto;
	color: var(--ccgal-text);
	font-family: inherit;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

/* Toolbar */
.ccgal-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
	margin: 0 0 20px;
	padding: 0 0 16px;
	border-bottom: 1px solid var(--ccgal-border);
	justify-content: flex-start;
}

.ccgal-gallery[data-toolbar-align="center"] .ccgal-toolbar { justify-content: center; }
.ccgal-gallery[data-toolbar-align="right"]  .ccgal-toolbar { justify-content: flex-end; }

.ccgal-selection-controls {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.ccgal-selection-count {
	font-size: 0.9em;
	font-weight: 500;
	color: var(--ccgal-muted);
	letter-spacing: 0.02em;
}

/* Buttons */
.ccgal-btn {
	appearance: none;
	-webkit-appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 10px 18px;
	font: inherit;
	font-size: 0.92em;
	font-weight: 500;
	letter-spacing: 0.03em;
	line-height: 1.2;
	text-transform: none;
	color: var(--ccgal-text);
	background: #fff;
	border: 1px solid var(--ccgal-border);
	border-radius: var(--ccgal-radius);
	cursor: pointer;
	transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
	min-height: 44px;
}

.ccgal-btn:hover,
.ccgal-btn:focus-visible {
	background: var(--ccgal-surface);
	border-color: var(--ccgal-accent);
	color: var(--ccgal-accent-dark);
	outline: none;
}

.ccgal-btn:focus-visible {
	box-shadow: 0 0 0 3px rgba(176, 142, 90, 0.2);
}

/* Mouse-Click hinterlässt :focus (nicht :focus-visible). Manche Themes stylen
   button:focus mit ihrer CTA-Farbe — Reset hier, sonst „klebt" die Theme-Farbe
   bis zum nächsten Klick woanders. Keyboard-Fokus (:focus-visible) bleibt accessible. */
.ccgal-btn:focus:not(:focus-visible) {
	background: #fff;
	border-color: var(--ccgal-border);
	color: var(--ccgal-text);
	box-shadow: none;
	outline: none;
}

.ccgal-btn-primary:focus:not(:focus-visible),
.ccgal-btn.is-active:focus:not(:focus-visible) {
	background: var(--ccgal-accent);
	border-color: var(--ccgal-accent);
	color: #fff;
}

.ccgal-btn-ghost:focus:not(:focus-visible) {
	background: transparent;
}

.ccgal-btn[disabled] {
	opacity: 0.5;
	cursor: not-allowed;
}

.ccgal-btn-primary {
	background: var(--ccgal-accent);
	border-color: var(--ccgal-accent);
	color: #fff;
}

.ccgal-btn-primary:hover,
.ccgal-btn-primary:focus-visible {
	background: var(--ccgal-accent-dark);
	border-color: var(--ccgal-accent-dark);
	color: #fff;
}

.ccgal-btn-ghost {
	background: transparent;
}

.ccgal-btn.is-active {
	background: var(--ccgal-accent);
	border-color: var(--ccgal-accent);
	color: #fff;
}

/* Justified Rows: Lesereihenfolge strikt horizontal, jede Zeile füllt exakt 100 % */
.ccgal-grid {
	display: flex;
	flex-wrap: wrap;
	gap: var(--ccgal-gap);
	align-content: flex-start;
}

.ccgal-grid.is-filtered-favs .ccgal-tile:not(.is-favorited) {
	display: none;
}

.ccgal-tile {
	position: relative;
	overflow: hidden;
	background: var(--ccgal-tile-bg);
	cursor: pointer;
	border-radius: var(--ccgal-radius);
	display: block;
	flex: 0 0 auto;
	box-shadow: 0 1px 2px rgba(20, 18, 14, 0.04);
	transition: box-shadow 0.25s ease;
}

.ccgal-tile:hover {
	box-shadow: var(--ccgal-shadow);
}

.ccgal-tile::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.28) 0%, rgba(0, 0, 0, 0) 45%);
	opacity: 0;
	transition: opacity 0.25s ease;
	pointer-events: none;
}

.ccgal-tile:hover::after,
.ccgal-tile:focus-within::after {
	opacity: 1;
}

.ccgal-tile-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.6s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.ccgal-tile:hover .ccgal-tile-img {
	transform: scale(1.035);
}

.ccgal-tile.is-selected {
	outline: 2px solid var(--ccgal-accent);
	outline-offset: -2px;
	box-shadow: 0 0 0 4px rgba(176, 142, 90, 0.15);
}

.ccgal-tile-play {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
	color: #fff;
	filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
}

.ccgal-tile-fav,
.ccgal-tile-sel,
.ccgal-tile-dl {
	position: absolute;
	width: 38px;
	height: 38px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.94);
	color: #2b2a28;
	cursor: pointer;
	opacity: 0;
	transform: translateY(-2px);
	transition: opacity 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.18s ease;
	box-shadow: 0 2px 6px rgba(20, 18, 14, 0.18);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
	z-index: 1;
}

.ccgal-tile-fav svg,
.ccgal-tile-sel svg,
.ccgal-tile-dl svg {
	display: block;
}

.ccgal-tile:hover .ccgal-tile-fav,
.ccgal-tile:hover .ccgal-tile-sel,
.ccgal-tile:hover .ccgal-tile-dl,
.ccgal-tile:focus-within .ccgal-tile-fav,
.ccgal-tile:focus-within .ccgal-tile-sel,
.ccgal-tile:focus-within .ccgal-tile-dl,
.ccgal-tile-fav.is-active,
.ccgal-tile.is-selected .ccgal-tile-sel {
	opacity: 1;
	transform: translateY(0);
}

.ccgal-tile-fav:hover,
.ccgal-tile-sel:hover,
.ccgal-tile-dl:hover {
	background: #fff;
}

.ccgal-tile-fav:active,
.ccgal-tile-sel:active,
.ccgal-tile-dl:active {
	transform: scale(0.93);
}

.ccgal-tile-fav { top: 10px; right: 10px; }
.ccgal-tile-sel { top: 10px; left: 10px; }
.ccgal-tile-dl  { bottom: 10px; right: 10px; }

.ccgal-tile-fav.is-active {
	background: var(--ccgal-accent);
	color: #fff;
}

.ccgal-tile.is-selected .ccgal-tile-sel {
	background: var(--ccgal-accent);
	color: #fff;
}

/* Status- und Hinweis-Leiste */
.ccgal-status {
	margin: 24px 0 8px;
	text-align: center;
	font-size: 0.9em;
	letter-spacing: 0.04em;
	color: var(--ccgal-muted);
}

.ccgal-error {
	color: #b00020;
}

.ccgal-load-more-wrap {
	text-align: center;
	margin: 28px 0 8px;
}

.ccgal-scroll-sentinel {
	height: 1px;
}


/* Lightbox */
.ccgal-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99998;
	background: rgba(12, 10, 8, 0.96);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 48px;
	animation: ccgal-lb-fade 0.2s ease-out;
}

@keyframes ccgal-lb-fade {
	from { opacity: 0; }
	to { opacity: 1; }
}

.ccgal-lightbox[hidden] {
	display: none;
}

body.ccgal-lightbox-open {
	overflow: hidden;
}

.ccgal-lb-stage {
	max-width: 100%;
	max-height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
}

.ccgal-lb-img,
.ccgal-lb-video {
	max-width: 100%;
	max-height: calc(100vh - 140px);
	object-fit: contain;
	background: #0a0908;
	display: block;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.ccgal-lb-video {
	width: auto;
	height: auto;
}

.ccgal-lb-close,
.ccgal-lb-prev,
.ccgal-lb-next {
	position: absolute;
	background: rgba(255, 255, 255, 0.08);
	color: #fff;
	border: 1px solid rgba(255, 255, 255, 0.14);
	border-radius: 50%;
	width: 48px;
	height: 48px;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	z-index: 2;
	padding: 0;
	transition: background 0.18s ease, border-color 0.18s ease;
}

.ccgal-lb-close:hover,
.ccgal-lb-prev:hover,
.ccgal-lb-next:hover,
.ccgal-lb-close:focus-visible,
.ccgal-lb-prev:focus-visible,
.ccgal-lb-next:focus-visible {
	background: rgba(255, 255, 255, 0.18);
	border-color: rgba(255, 255, 255, 0.28);
	outline: none;
}

.ccgal-lb-close:focus:not(:focus-visible),
.ccgal-lb-prev:focus:not(:focus-visible),
.ccgal-lb-next:focus:not(:focus-visible) {
	background: rgba(255, 255, 255, 0.08);
	border-color: rgba(255, 255, 255, 0.14);
	color: #fff;
	box-shadow: none;
	outline: none;
}

.ccgal-lb-close { top: 20px; right: 20px; }
.ccgal-lb-prev  { left: 20px; top: 50%; transform: translateY(-50%); }
.ccgal-lb-next  { right: 20px; top: 50%; transform: translateY(-50%); }

.ccgal-lb-controls {
	position: absolute;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	gap: 12px;
	z-index: 2;
	padding: 6px;
	background: rgba(255, 255, 255, 0.06);
	border: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 999px;
}

.ccgal-lb-btn {
	appearance: none;
	-webkit-appearance: none;
	width: 44px;
	height: 44px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: transparent;
	color: #fff;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
	transition: background 0.18s ease, color 0.18s ease, transform 0.1s ease;
}

.ccgal-lb-btn svg { display: block; }

.ccgal-lb-btn:hover,
.ccgal-lb-btn:focus-visible {
	background: rgba(255, 255, 255, 0.14);
	outline: none;
}

.ccgal-lb-btn:focus:not(:focus-visible) {
	background: transparent;
	color: #fff;
	box-shadow: none;
	outline: none;
}

.ccgal-lb-favorite.is-active:focus:not(:focus-visible),
.ccgal-lb-select.is-active:focus:not(:focus-visible) {
	background: var(--ccgal-accent);
	color: #fff;
}

.ccgal-lb-btn:active { transform: scale(0.94); }

.ccgal-lb-favorite.is-active,
.ccgal-lb-select.is-active {
	background: var(--ccgal-accent);
	color: #fff;
}
.ccgal-lb-favorite.is-active:hover,
.ccgal-lb-select.is-active:hover {
	background: var(--ccgal-accent-dark);
}

/* Shimmer während Bilder laden */
.ccgal-tile-img:not([src]) {
	background: linear-gradient(90deg, #eae4d4 0%, #f2ecdd 50%, #eae4d4 100%);
	background-size: 200% 100%;
	animation: ccgal-shimmer 1.4s linear infinite;
}

@keyframes ccgal-shimmer {
	0% { background-position: 200% 0; }
	100% { background-position: -200% 0; }
}

/* Reduced Motion respektieren */
@media (prefers-reduced-motion: reduce) {
	.ccgal-tile-img,
	.ccgal-tile,
	.ccgal-tile-fav,
	.ccgal-tile-sel,
	.ccgal-tile-dl,
	.ccgal-lb-btn,
	.ccgal-btn {
		transition: none;
	}
	.ccgal-tile:hover .ccgal-tile-img { transform: none; }
	.ccgal-tile-img:not([src]) { animation: none; }
	.ccgal-lightbox { animation: none; }
}

/* Mobile */
@media (max-width: 600px) {
	.ccgal-gallery { --ccgal-gap: 6px; }

	.ccgal-toolbar {
		flex-direction: column;
		align-items: stretch;
		gap: 8px;
		padding-bottom: 14px;
	}
	.ccgal-toolbar > .ccgal-btn {
		width: 100%;
		padding: 12px 16px;
	}
	.ccgal-selection-controls {
		flex-direction: column;
		align-items: stretch;
		width: 100%;
	}
	.ccgal-selection-controls > .ccgal-btn {
		width: 100%;
	}
	.ccgal-selection-count {
		text-align: center;
	}

	.ccgal-tile-fav,
	.ccgal-tile-sel,
	.ccgal-tile-dl {
		opacity: 1;
		transform: none;
		width: 36px;
		height: 36px;
	}

	/* Hover-Scale auf Touch deaktivieren, sonst hängt der Zoom-Zustand */
	.ccgal-tile:hover .ccgal-tile-img {
		transform: none;
	}
	.ccgal-tile::after { display: none; }

	.ccgal-lightbox { padding: 12px; }

	.ccgal-lb-close,
	.ccgal-lb-prev,
	.ccgal-lb-next {
		width: 42px;
		height: 42px;
		font-size: 22px;
	}
	.ccgal-lb-close { top: 10px; right: 10px; }
	.ccgal-lb-prev  { left: 8px; }
	.ccgal-lb-next  { right: 8px; }

	.ccgal-lb-controls {
		bottom: 14px;
		gap: 6px;
		padding: 4px;
	}
	.ccgal-lb-btn {
		width: 42px;
		height: 42px;
	}
	.ccgal-lb-img,
	.ccgal-lb-video {
		max-height: calc(100vh - 150px);
	}
}

/* Bulk-Download Progress-Toast — nicht blockierend, Galerie bleibt nutzbar */
.ccgal-bulk-toast {
	position: fixed;
	bottom: 20px;
	right: 20px;
	background: #fff;
	color: #1f2937;
	border-radius: 10px;
	padding: 14px 16px 12px;
	width: 320px;
	max-width: calc(100vw - 40px);
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.05);
	z-index: 9999;
	font-family: inherit;
	pointer-events: auto;
	animation: ccgal-toast-in 220ms ease-out;
}
@keyframes ccgal-toast-in {
	from { transform: translateY(20px); opacity: 0; }
	to   { transform: translateY(0); opacity: 1; }
}
.ccgal-bulk-toast-title {
	margin: 0 0 4px;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.3;
	display: flex;
	align-items: center;
	gap: 6px;
}
.ccgal-bulk-toast-title::before {
	content: "";
	display: inline-block;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--ccgal-accent, #2563eb);
	animation: ccgal-toast-pulse 1.4s ease-in-out infinite;
}
@keyframes ccgal-toast-pulse {
	0%, 100% { opacity: 1; }
	50%      { opacity: 0.35; }
}
.ccgal-bulk-toast-status {
	margin: 0 0 8px;
	font-size: 12px;
	color: #4b5563;
	min-height: 1.1em;
}
.ccgal-bulk-progress {
	width: 100%;
	height: 6px;
	border-radius: 999px;
	background: #e5e7eb;
	overflow: hidden;
	margin-bottom: 8px;
}
.ccgal-bulk-progress-bar {
	height: 100%;
	width: 0%;
	background: var(--ccgal-accent, #2563eb);
	transition: width 200ms ease-out;
}
.ccgal-bulk-toast-current {
	margin: 0 0 8px;
	font-size: 11px;
	color: #6b7280;
	min-height: 1.1em;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.ccgal-bulk-toast-actions {
	display: flex;
	justify-content: flex-end;
}
.ccgal-bulk-toast-actions .ccgal-bulk-cancel {
	font-size: 12px;
	padding: 4px 10px;
}
@media (max-width: 600px) {
	.ccgal-bulk-toast {
		left: 12px;
		right: 12px;
		bottom: 12px;
		width: auto;
	}
}
@media (prefers-color-scheme: dark) {
	.ccgal-bulk-toast {
		background: #1f2937;
		color: #f3f4f6;
		box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
	}
	.ccgal-bulk-toast-status { color: #d1d5db; }
	.ccgal-bulk-toast-current { color: #9ca3af; }
	.ccgal-bulk-progress { background: #374151; }
}
