/**
 * Styling for [cc_ugc_photo].
 *
 * Billedet fylder altid præcis det felt det får: er slidet eller gruppen sat til
 * 350px, bliver billedet 350px. Højden fra shortcoden (standard 312px) er
 * minimum – den bruges når ingen blok omkring billedet bestemmer en højde.
 * Selve billedet ligger absolut i feltet, så en procenthøjde altid kan
 * beregnes, og beskæres med object-fit: cover omkring fokuspunktet. Dermed er
 * alle billeder i en carousel lige høje, uanset orientering.
 *
 * Bemærk at der bruges >-selektorer hele vejen: WordPress erstatter emojis i
 * billedteksten med <img class="emoji">, og de må ikke rammes af billedreglerne.
 */

.cc-ugc-photo {
	position: relative;
	display: block;
	margin: 0;
	overflow: hidden;
	border-radius: 10px;
	background: var(--wp--preset--color--base, #f7f7f7);
}

.cc-ugc-photo > img,
.cc-ugc-photo > a > img {
	display: block;
	width: 100%;
	object-fit: cover;
	object-position: var(--cc-ugc-focus, 50% 50%);
}

/* Normaltilstand: fyld feltet, dog mindst højden fra shortcoden. */
.cc-ugc-photo[style*="--cc-ugc-height"] {
	height: 100%;
	min-height: var(--cc-ugc-height);
}

.cc-ugc-photo[style*="--cc-ugc-height"] > a {
	position: absolute;
	inset: 0;
	display: block;
}

.cc-ugc-photo[style*="--cc-ugc-height"] > img,
.cc-ugc-photo[style*="--cc-ugc-height"] > a > img {
	position: absolute;
	inset: 0;
	height: 100%;
}

/* height="auto": billedet beholder sit eget format. */
.cc-ugc-photo:not([style*="--cc-ugc-height"]) > img,
.cc-ugc-photo:not([style*="--cc-ugc-height"]) > a > img {
	height: auto;
}

/* Ratio låser formatet og vinder over højden. */
.cc-ugc-photo[style*="--cc-ugc-ratio"] {
	height: auto;
	min-height: 0;
}

.cc-ugc-photo[style*="--cc-ugc-ratio"] > a,
.cc-ugc-photo[style*="--cc-ugc-ratio"] > img,
.cc-ugc-photo[style*="--cc-ugc-ratio"] > a > img {
	position: static;
	height: auto;
}

.cc-ugc-photo[style*="--cc-ugc-ratio"] > img,
.cc-ugc-photo[style*="--cc-ugc-ratio"] > a > img {
	aspect-ratio: var(--cc-ugc-ratio);
}

/**
 * Carousel Slider Block giver hver slide `height: 100%` op mod et spor uden
 * fast højde. Procenten kan ikke beregnes, så slidet strækker sig aldrig, og
 * en enkelt høj slide efterlader tom luft i de andre. Med `height: auto` virker
 * flexboxens stretch igen: alle slides – og dermed alle billeder – bliver lige
 * høje som den højeste. Kun slides med et gæstebillede røres.
 */
.slick-track > .wp-block-cb-slide:has(.cc-ugc-photo) {
	height: auto;
}

.cc-ugc-photo__caption {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	display: flex;
	flex-direction: column;
	gap: 0.15em;
	padding: 2.5em 0.9em 0.75em;
	font-size: 0.9rem;
	line-height: 1.35;
	color: #fff;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
	pointer-events: none;
}

/* Emojis i billedteksten er <img class="emoji"> og skal opføre sig som tekst. */
.cc-ugc-photo__caption img {
	display: inline-block;
	width: 1em;
	height: 1em;
	min-height: 0;
	max-height: none;
	margin: 0 0.05em;
	object-fit: contain;
	vertical-align: -0.1em;
	border-radius: 0;
}

.cc-ugc-photo__desc {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	overflow: hidden;
}

.cc-ugc-photo__by {
	font-size: 0.8rem;
	opacity: 0.85;
}
