/* ============================================================
   Student Gallery — самодостаточные стили (всё под .sg-*)
   ============================================================ */

.sg-gallery {
	--sg-cols: 3;
	--sg-cols-mobile: 1;
	--sg-gap: 14px;
	--sg-radius: 16px;
	--sg-ease: cubic-bezier(0.16, 1, 0.3, 1);
	box-sizing: border-box;
	/* !important — чтобы тема сайта не сбила горизонтальный отступ между колонками */
	column-count: var(--sg-cols) !important;
	column-gap: var(--sg-gap) !important;
	margin: 0 auto !important;
	padding: 0 !important;
	max-width: 1280px;
}

/* Masonry-элемент: column-layout не разрывает фигуру между колонками */
.sg-gallery .sg-item {
	break-inside: avoid;
	-webkit-column-break-inside: avoid;
	page-break-inside: avoid;
	/* !important — многие темы обнуляют margin у figure, это вернёт вертикальный отступ */
	margin: 0 0 var(--sg-gap) !important;
	padding: 0 !important;
	/* стартовое состояние для появления при скролле */
	opacity: 0;
	transform: translateY(28px) scale(0.98);
	transition: opacity 0.7s var(--sg-ease), transform 0.7s var(--sg-ease);
	transition-delay: calc(var(--sg-i, 0) * 0ms);
}

.sg-item.sg-in {
	opacity: 1;
	transform: none;
}

.sg-link {
	position: relative;
	display: block;
	overflow: hidden;
	border-radius: var(--sg-radius);
	background: #ececec;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
	transition: box-shadow 0.5s var(--sg-ease), transform 0.5s var(--sg-ease);
	cursor: zoom-in;
	line-height: 0;
	-webkit-tap-highlight-color: transparent;
}

.sg-link:hover {
	box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.35);
	transform: translateY(-4px);
}

.sg-img {
	display: block;
	width: 100%;
	height: auto;
	transition: transform 0.9s var(--sg-ease), filter 0.6s var(--sg-ease);
	will-change: transform;
}

.sg-link:hover .sg-img {
	transform: scale(1.06);
}

/* Оверлей при наведении */
.sg-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(180deg, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.35) 100%);
	opacity: 0;
	transition: opacity 0.5s var(--sg-ease);
}

.sg-link:hover .sg-overlay {
	opacity: 1;
}

.sg-zoom {
	position: relative;
	width: 46px;
	height: 46px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.18);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	border: 1px solid rgba(255, 255, 255, 0.5);
	transform: scale(0.6);
	transition: transform 0.5s var(--sg-ease);
}

.sg-link:hover .sg-zoom {
	transform: scale(1);
}

.sg-zoom::before,
.sg-zoom::after {
	content: "";
	position: absolute;
	background: #fff;
	border-radius: 2px;
}

.sg-zoom::before { /* горизонтальная палочка плюса */
	top: 50%;
	left: 50%;
	width: 16px;
	height: 2px;
	transform: translate(-50%, -50%);
}

.sg-zoom::after { /* вертикальная палочка плюса */
	top: 50%;
	left: 50%;
	width: 2px;
	height: 16px;
	transform: translate(-50%, -50%);
}

.sg-caption {
	margin: 8px 4px 0;
	font-size: 13px;
	line-height: 1.4;
	color: #555;
	text-align: center;
}

/* ---------- Подгрузка партиями ---------- */
.sg-item.sg-hidden {
	display: none !important; /* пока скрыто — браузер не грузит эти фото */
}

.sg-more-wrap {
	text-align: center;
	margin-top: 28px;
}

.sg-more {
	appearance: none;
	-webkit-appearance: none;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 13px 30px;
	font-size: 15px;
	font-weight: 600;
	letter-spacing: 0.01em;
	color: #1a1a1a;
	background: #fff;
	border: 1.5px solid #1a1a1a;
	border-radius: 999px;
	cursor: pointer;
	transition: color 0.35s var(--sg-ease), background 0.35s var(--sg-ease), transform 0.35s var(--sg-ease), box-shadow 0.35s var(--sg-ease);
}

.sg-more:hover {
	color: #fff;
	background: #1a1a1a;
	transform: translateY(-2px);
	box-shadow: 0 14px 28px -12px rgba(0, 0, 0, 0.5);
}

.sg-more:active {
	transform: translateY(0);
}

/* ---------- Адаптив ----------
   Десктоп — var(--sg-cols), мобильный — var(--sg-cols-mobile).
   Оба числа задаются в настройках галереи. */
@media (max-width: 600px) {
	.sg-gallery { column-count: var(--sg-cols-mobile); }
}

@media (prefers-reduced-motion: reduce) {
	.sg-item { opacity: 1; transform: none; transition: none; }
	.sg-img, .sg-link, .sg-overlay, .sg-zoom { transition: none; }
}

/* ============================================================
   Лайтбокс
   ============================================================ */
.sg-lb {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(12, 12, 14, 0.6);
	backdrop-filter: blur(14px) saturate(1.1);
	-webkit-backdrop-filter: blur(14px) saturate(1.1);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.4s ease, visibility 0.4s ease;
}

.sg-lb.sg-open {
	opacity: 1;
	visibility: visible;
}

.sg-lb-stage {
	position: relative;
	max-width: 92vw;
	max-height: 86vh;
	display: flex;
	align-items: center;
	justify-content: center;
}

.sg-lb-img {
	max-width: 92vw;
	max-height: 86vh;
	width: auto;
	height: auto;
	border-radius: 10px;
	box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
	transform: scale(0.92);
	opacity: 0;
	transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
}

.sg-lb.sg-shown .sg-lb-img {
	transform: scale(1);
	opacity: 1;
}

.sg-lb-caption {
	position: absolute;
	left: 0;
	right: 0;
	bottom: -38px;
	text-align: center;
	color: rgba(255, 255, 255, 0.85);
	font-size: 14px;
	letter-spacing: 0.02em;
}

/* Кнопки управления */
.sg-lb-btn {
	position: absolute;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 52px;
	border: 1px solid rgba(255, 255, 255, 0.25);
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.08);
	color: #fff;
	cursor: pointer;
	transition: background 0.3s ease, transform 0.3s ease, border-color 0.3s ease;
	-webkit-tap-highlight-color: transparent;
}

.sg-lb-btn:hover {
	background: rgba(255, 255, 255, 0.2);
	border-color: rgba(255, 255, 255, 0.6);
	transform: scale(1.08);
}

.sg-lb-btn svg { width: 22px; height: 22px; }

.sg-lb-close { top: 22px; right: 22px; }
.sg-lb-prev { left: 22px; top: 50%; transform: translateY(-50%); }
.sg-lb-next { right: 22px; top: 50%; transform: translateY(-50%); }
.sg-lb-prev:hover { transform: translateY(-50%) scale(1.08); }
.sg-lb-next:hover { transform: translateY(-50%) scale(1.08); }

.sg-lb-counter {
	position: absolute;
	top: 28px;
	left: 28px;
	color: rgba(255, 255, 255, 0.8);
	font-size: 14px;
	letter-spacing: 0.08em;
	font-variant-numeric: tabular-nums;
}

.sg-lb-spinner {
	position: absolute;
	width: 34px;
	height: 34px;
	border: 3px solid rgba(255, 255, 255, 0.25);
	border-top-color: #fff;
	border-radius: 50%;
	animation: sg-spin 0.8s linear infinite;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.sg-lb.sg-loading .sg-lb-spinner { opacity: 1; }

@keyframes sg-spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
	.sg-lb-prev { left: 10px; }
	.sg-lb-next { right: 10px; }
	.sg-lb-btn { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
	.sg-lb, .sg-lb-img { transition: opacity 0.2s ease; }
	.sg-lb-img { transform: none; }
}
