/* Folder Gallery — frontend */

.fg-wrap {
	--fg-cols-desktop: 4;
	--fg-cols-tablet: 3;
	--fg-cols-mobile: 2;
	--fg-gap-desktop: 28px;

	/* გამოთვლილი მნიშვნელობები — ესენი იცვლება breakpoint-ებზე */
	--fg-cols: var(--fg-cols-desktop);
	--fg-gap: var(--fg-gap-desktop);
	--fg-ratio: 4 / 3;
	--fg-ink: #2c2a26;
	--fg-muted: #7d7870;
	--fg-line: rgba(0, 0, 0, .12);

	position: relative;
	color: var(--fg-ink);
}

/* ---------- ბადე ---------- */

.fg-wrap .fg-grid,
.fg-wrap .fg-album-grid {
	display: grid;
	grid-template-columns: repeat(var(--fg-cols), minmax(0, 1fr));
	gap: calc(var(--fg-gap) * 1.6) var(--fg-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

.fg-wrap .fg-album-grid {
	gap: var(--fg-gap);
}

.fg-card {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
	margin: 0;
	padding: 0;
	background: none;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	font: inherit;
	color: inherit;
	text-align: center;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.fg-card__media {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: var(--fg-ratio);
	overflow: hidden;
	background: rgba(0, 0, 0, .04);
}

.fg-card__media .fg-card__img,
.fg-card__media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform .6s cubic-bezier(.2, .7, .2, 1), opacity .3s ease;
}

.fg-card__placeholder {
	display: block;
	width: 100%;
	height: 100%;
	background: repeating-linear-gradient(45deg, rgba(0, 0, 0, .04) 0 10px, rgba(0, 0, 0, .07) 10px 20px);
}

.fg-card:hover .fg-card__img,
.fg-card:focus-visible .fg-card__img {
	transform: scale(1.045);
}

.fg-card__title {
	font-size: 12px;
	letter-spacing: .16em;
	text-transform: uppercase;
	line-height: 1.5;
	color: inherit;
}

.fg-card__count {
	margin-top: -8px;
	font-size: 12px;
	letter-spacing: .04em;
	color: var(--fg-muted);
}

.fg-card:focus {
	outline: none;
}

.fg-card:focus-visible,
.fg-photo:focus-visible,
.fg-back:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 4px;
}

/* ---------- ხედების გადართვა ---------- */

.fg-view {
	display: none;
}

.fg-view.is-active {
	display: block;
	animation: fg-fade .35s ease both;
}

@keyframes fg-fade {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: none; }
}

/* ---------- გახსნილი ალბომი ---------- */

.fg-album-bar {
	display: flex;
	align-items: center;
	gap: 18px;
	flex-wrap: wrap;
	margin-bottom: calc(var(--fg-gap) * 1.2);
	padding-bottom: 14px;
	border-bottom: 1px solid var(--fg-line);
}

.fg-back {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 16px 8px 12px;
	background: none;
	border: 1px solid var(--fg-line);
	border-radius: 999px;
	color: inherit;
	font: inherit;
	font-size: 13px;
	letter-spacing: .08em;
	text-transform: uppercase;
	cursor: pointer;
	transition: background-color .25s ease, transform .25s ease;
}

.fg-back:hover {
	background: rgba(0, 0, 0, .05);
}

.fg-back:active {
	transform: translateX(-2px);
}

.fg-back__icon {
	width: 18px;
	height: 18px;
	flex: none;
}

.fg-album-title {
	margin: 0;
	font-size: 15px;
	font-weight: 400;
	letter-spacing: .16em;
	text-transform: uppercase;
}

.fg-photo {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: var(--fg-ratio);
	padding: 0;
	margin: 0;
	overflow: hidden;
	background: rgba(0, 0, 0, .04);
	border: 0;
	cursor: zoom-in;
	-webkit-appearance: none;
	appearance: none;
}

.fg-wrap[data-lightbox="0"] .fg-photo {
	cursor: default;
}

.fg-photo img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform .6s cubic-bezier(.2, .7, .2, 1);
}

.fg-photo:hover img {
	transform: scale(1.04);
}

.fg-note {
	color: var(--fg-muted);
	font-size: 14px;
	margin: 0;
}

.fg-empty {
	color: var(--fg-muted);
	font-size: 14px;
}

/* ---------- ჩატვირთვა ---------- */

.fg-loader {
	display: flex;
	justify-content: center;
	gap: 6px;
	padding: 40px 0;
}

.fg-loader[hidden] {
	display: none;
}

.fg-loader__dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: currentColor;
	opacity: .35;
	animation: fg-bounce 1s infinite ease-in-out;
}

.fg-loader__dot:nth-child(2) { animation-delay: .15s; }
.fg-loader__dot:nth-child(3) { animation-delay: .3s; }

@keyframes fg-bounce {
	0%, 100% { transform: translateY(0); opacity: .3; }
	50%      { transform: translateY(-6px); opacity: .9; }
}

/* ---------- ლაითბოქსი ---------- */

.fg-lightbox {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(18, 17, 15, .94);
	opacity: 0;
	transition: opacity .25s ease;
}

.fg-lightbox.is-open {
	opacity: 1;
}

.fg-lightbox__img {
	max-width: min(92vw, 1400px);
	max-height: 86vh;
	object-fit: contain;
	user-select: none;
}

.fg-lightbox__caption {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 22px;
	text-align: center;
	color: rgba(255, 255, 255, .78);
	font-size: 13px;
	letter-spacing: .06em;
	padding: 0 20px;
}

.fg-lightbox__btn {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	background: rgba(255, 255, 255, .08);
	border: 0;
	border-radius: 50%;
	color: #fff;
	cursor: pointer;
	transition: background-color .2s ease;
}

.fg-lightbox__btn:hover {
	background: rgba(255, 255, 255, .2);
}

.fg-lightbox__btn svg {
	width: 22px;
	height: 22px;
}

.fg-lightbox__close { top: 18px; right: 18px; }
.fg-lightbox__prev  { left: 18px; top: 50%; transform: translateY(-50%); }
.fg-lightbox__next  { right: 18px; top: 50%; transform: translateY(-50%); }

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

/* ---------- ადაპტაცია ---------- */

@media (max-width: 1024px) {
	.fg-wrap {
		--fg-cols: var(--fg-cols-tablet, 3);
	}
}

@media (max-width: 767px) {
	.fg-wrap {
		--fg-cols: var(--fg-cols-mobile, 2);
		--fg-gap: calc(var(--fg-gap-desktop, 28px) * .55);
	}

	.fg-card__title {
		font-size: 11px;
		letter-spacing: .12em;
	}

	.fg-album-bar {
		gap: 12px;
	}

	.fg-back {
		padding: 7px 14px 7px 10px;
		font-size: 12px;
	}

	.fg-album-title {
		font-size: 13px;
	}

	.fg-lightbox__btn {
		width: 42px;
		height: 42px;
	}

	.fg-lightbox__prev { left: 8px; }
	.fg-lightbox__next { right: 8px; }
	.fg-lightbox__close { top: 10px; right: 10px; }
}

@media (prefers-reduced-motion: reduce) {
	.fg-view.is-active,
	.fg-card__img,
	.fg-photo img,
	.fg-lightbox {
		animation: none !important;
		transition: none !important;
	}
}
