/* Consigno Gallery – rutenett og lysboks */

/* ---------- Rutenett ---------- */

.cg-gallery {
	--cg-columns: 3;
	--cg-columns-mobile: 2;
	--cg-gap: 8px;
	--cg-ratio: 1 / 1;

	display: grid;
	grid-template-columns: repeat(var(--cg-columns), minmax(0, 1fr));
	gap: var(--cg-gap);
	margin: 1.75em 0;
	padding: 0;
	list-style: none;
}

.cg-gallery .cg-gallery__item {
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Nokre tema legg til punkt/ikon før listeelement. */
.cg-gallery .cg-gallery__item::before,
.cg-gallery .cg-gallery__item::marker {
	content: none;
}

.cg-gallery .cg-gallery__link {
	display: block;
	overflow: hidden;
	aspect-ratio: var(--cg-ratio);
	background: rgba(128, 128, 128, 0.12);
	cursor: zoom-in;
	border: 0;
	box-shadow: none;
	text-decoration: none;
}

.cg-gallery .cg-gallery__link img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	object-fit: cover;
	border-radius: 0;
	transition: transform 0.4s ease;
}

.cg-gallery .cg-gallery__link:hover img {
	transform: scale(1.03);
}

.cg-gallery .cg-gallery__link:focus-visible {
	outline: 3px solid currentColor;
	outline-offset: 2px;
}

/* Skildring under bileta (global innstilling) */
.cg-gallery--captions {
	align-items: start;
}

.cg-gallery .cg-gallery__caption {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	overflow: hidden;
	margin: 0.4em 0 0;
	padding: 0;
	font-size: 0.75rem;
	line-height: 1.35;
	opacity: 0.75;
}

/* ratio="auto": originale proporsjonar */
.cg-gallery--natural {
	align-items: start;
}

.cg-gallery--natural .cg-gallery__link {
	aspect-ratio: auto;
}

.cg-gallery--natural .cg-gallery__link img {
	height: auto;
}

@media (max-width: 600px) {
	.cg-gallery {
		grid-template-columns: repeat(var(--cg-columns-mobile), minmax(0, 1fr));
	}
}

/* ---------- Lysboks ---------- */

html.cg-lightbox-lock {
	overflow: hidden;
}

.cg-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 3.5rem 4.5rem;
	background: rgba(8, 9, 11, 0.94);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease, visibility 0.2s ease;
	-webkit-tap-highlight-color: transparent;
}

.cg-lightbox.is-open {
	opacity: 1;
	visibility: visible;
}

.cg-lightbox__stage {
	position: relative;
	display: block;
	margin: 0;
	padding: 0;
	line-height: 0;
}

.cg-lightbox__img {
	display: block;
	width: auto;
	height: auto;
	max-width: calc(100vw - 9rem);
	max-height: calc(100vh - 7rem);
	max-height: calc(100dvh - 7rem);
	margin: 0;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
	transition: opacity 0.2s ease;
}

.cg-lightbox__img.is-loading {
	opacity: 0;
}

/* Biletskildringa ligg oppå biletet, nedst. */
.cg-lightbox__caption {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	margin: 0;
	padding: 0.85em 1.1em;
	background: rgba(0, 0, 0, 0.62);
	color: #fff;
	font-size: 0.95rem;
	line-height: 1.45;
	text-align: left;
	white-space: pre-line;
	max-height: 40%;
	overflow-y: auto;
}

.cg-lightbox__caption[hidden] {
	display: none;
}

/* Skildring øvst i biletet */
.cg-lightbox--caption-top .cg-lightbox__caption {
	top: 0;
	bottom: auto;
}

/* Skildring under biletet: tabell-triks held teksten like brei som biletet. */
.cg-lightbox--caption-below .cg-lightbox__stage {
	display: table;
}

.cg-lightbox--caption-below .cg-lightbox__caption {
	position: static;
	display: table-caption;
	caption-side: bottom;
	max-height: none;
	padding: 0.75em 0.1em 0;
	background: none;
	color: rgba(255, 255, 255, 0.9);
}

.cg-lightbox--caption-below .cg-lightbox__caption[hidden] {
	display: none;
}

.cg-lightbox--caption-below .cg-lightbox__img {
	max-height: calc(100vh - 11rem);
	max-height: calc(100dvh - 11rem);
}

.cg-lightbox__counter {
	position: absolute;
	top: 1.1rem;
	left: 1.25rem;
	color: rgba(255, 255, 255, 0.75);
	font-size: 0.875rem;
	line-height: 1;
	font-variant-numeric: tabular-nums;
}

/* Knappar – nullstill tema-stilar grundig. */
.cg-lightbox .cg-lightbox__btn {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 3rem;
	height: 3rem;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	box-shadow: none;
	color: #fff;
	line-height: 0;
	text-transform: none;
	cursor: pointer;
	opacity: 0.8;
	transition: opacity 0.15s ease, background-color 0.15s ease;
}

.cg-lightbox .cg-lightbox__btn:hover,
.cg-lightbox .cg-lightbox__btn:focus-visible {
	opacity: 1;
	background: rgba(255, 255, 255, 0.14);
}

.cg-lightbox .cg-lightbox__btn:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

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

.cg-lightbox__btn svg {
	width: 1.75rem;
	height: 1.75rem;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.cg-lightbox .cg-lightbox__close {
	top: 0.5rem;
	right: 0.75rem;
}

.cg-lightbox .cg-lightbox__fullscreen {
	top: 0.5rem;
	right: 4rem;
}

.cg-lightbox .cg-lightbox__fullscreen svg {
	width: 1.5rem;
	height: 1.5rem;
}

/* Fullskjerm: svart bakgrunn og meir plass til biletet */
.cg-lightbox.is-fullscreen {
	padding: 3rem 4rem;
	background: #000;
}

.cg-lightbox.is-fullscreen .cg-lightbox__img {
	max-width: calc(100vw - 8rem);
	max-height: calc(100vh - 6rem);
	box-shadow: none;
}

.cg-lightbox--caption-below.is-fullscreen .cg-lightbox__img {
	max-height: calc(100vh - 10rem);
}

.cg-lightbox .cg-lightbox__prev,
.cg-lightbox .cg-lightbox__next {
	top: 50%;
	transform: translateY(-50%);
}

.cg-lightbox .cg-lightbox__prev {
	left: 0.75rem;
}

.cg-lightbox .cg-lightbox__next {
	right: 0.75rem;
}

/* Mobil: biletet får heile breidda, pilene ligg oppå. */
@media (max-width: 700px) {
	.cg-lightbox {
		padding: 3.5rem 0;
	}

	.cg-lightbox__img {
		max-width: 100vw;
	}

	.cg-lightbox .cg-lightbox__prev,
	.cg-lightbox .cg-lightbox__next {
		background: rgba(0, 0, 0, 0.35);
	}

	.cg-lightbox .cg-lightbox__prev {
		left: 0.35rem;
	}

	.cg-lightbox .cg-lightbox__next {
		right: 0.35rem;
	}

	.cg-lightbox--caption-below .cg-lightbox__caption {
		padding: 0.75em 1em 0;
	}

	.cg-lightbox.is-fullscreen {
		padding: 3rem 0;
	}

	.cg-lightbox.is-fullscreen .cg-lightbox__img {
		max-width: 100vw;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cg-gallery .cg-gallery__link img,
	.cg-lightbox,
	.cg-lightbox__img,
	.cg-lightbox .cg-lightbox__btn {
		transition: none;
	}

	.cg-gallery .cg-gallery__link:hover img {
		transform: none;
	}
}
