/* =====================================================
   GALERIA FREY – FRONTEND
===================================================== */

/* ---------- Strona galerii ---------- */

.frey-gallery-page {
	padding: 3rem 0 5rem;
}

.frey-gallery-page__title {
	font-size: clamp( 1.6rem, 3vw, 2.4rem );
	font-weight: 800;
	margin: 0 0 2rem;
	color: var( --af-text );
}

/* ---------- Zakładki kategorii ---------- */

.frey-gallery-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-bottom: 2rem;
	padding-bottom: 1.25rem;
	border-bottom: 2px solid var( --af-border );
}

.frey-gallery-tab {
	background: none;
	border: 2px solid var( --af-border );
	border-radius: 999px;
	padding: 0.45rem 1.2rem;
	font: inherit;
	font-size: 0.9rem;
	font-weight: 600;
	cursor: pointer;
	color: var( --af-text );
	transition: border-color 0.2s, color 0.2s, background 0.2s;
	white-space: nowrap;
}

.frey-gallery-tab:hover {
	border-color: var( --af-primary );
	color: var( --af-primary );
}

.frey-gallery-tab.active {
	background: var( --af-primary );
	border-color: var( --af-primary );
	color: #fff;
}

/* ---------- Siatka zdjęć ---------- */

.frey-gallery__grid {
	display: grid;
	grid-template-columns: repeat( 4, 1fr );
	gap: 0.625rem;
	transition: opacity 0.25s;
}

@media ( max-width: 1023px ) {
	.frey-gallery__grid { grid-template-columns: repeat( 3, 1fr ); }
}

@media ( max-width: 639px ) {
	.frey-gallery__grid { grid-template-columns: repeat( 2, 1fr ); }
}

@media ( max-width: 380px ) {
	.frey-gallery__grid { grid-template-columns: 1fr; }
}

/* Kafelek zdjęcia */
.frey-gallery__item {
	position: relative;
	aspect-ratio: 1;
	overflow: hidden;
	cursor: zoom-in;
	border-radius: 4px;
	background: var( --af-border );
}

.frey-gallery__item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.4s ease;
}

.frey-gallery__item:hover img,
.frey-gallery__item:focus img {
	transform: scale( 1.07 );
}

.frey-gallery__item:focus {
	outline: 3px solid var( --af-primary );
	outline-offset: 2px;
}

/* Nakładka hover */
.frey-gallery__overlay {
	position: absolute;
	inset: 0;
	background: transparent;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.3s;
}

.frey-gallery__item:hover .frey-gallery__overlay,
.frey-gallery__item:focus .frey-gallery__overlay {
	background: rgba( 0, 0, 0, 0.32 );
}

/* Ikona lupy (CSS-only) */
.frey-gallery__zoom {
	display: block;
	width: 46px;
	height: 46px;
	border: 2.5px solid rgba( 255, 255, 255, 0.85 );
	border-radius: 50%;
	opacity: 0;
	transform: scale( 0.6 );
	transition: opacity 0.3s, transform 0.3s;
	position: relative;
}

.frey-gallery__zoom::before,
.frey-gallery__zoom::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	background: rgba( 255, 255, 255, 0.85 );
	border-radius: 2px;
}

.frey-gallery__zoom::before {
	width: 18px;
	height: 2px;
	transform: translate( -50%, -50% );
}

.frey-gallery__zoom::after {
	width: 2px;
	height: 18px;
	transform: translate( -50%, -50% );
}

.frey-gallery__item:hover .frey-gallery__zoom,
.frey-gallery__item:focus .frey-gallery__zoom {
	opacity: 1;
	transform: scale( 1 );
}

/* Pusta kategoria */
.frey-gallery__empty {
	grid-column: 1 / -1;
	text-align: center;
	color: var( --af-muted );
	padding: 4rem 1rem;
	font-size: 1.05rem;
}

/* ---------- Wskaźnik ładowania ---------- */

.frey-gallery__loading {
	display: flex;
	justify-content: center;
	padding: 2.5rem 0;
}

.frey-gallery__loading[hidden] {
	display: none;
}

.frey-spinner {
	width: 40px;
	height: 40px;
	border: 3px solid var( --af-border );
	border-top-color: var( --af-primary );
	border-radius: 50%;
	animation: frey-spin 0.75s linear infinite;
}

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

/* ---------- Lightbox ---------- */

.frey-lightbox {
	position: fixed;
	inset: 0;
	z-index: 9999;
	background: rgba( 0, 0, 0, 0.93 );
	display: flex;
	align-items: center;
	justify-content: center;
}

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

/* Zawartość */
.frey-lightbox__content {
	display: flex;
	flex-direction: column;
	align-items: center;
	max-width: 92vw;
	max-height: 92vh;
	position: relative;
}

.frey-lightbox__content img {
	display: block;
	max-width: 90vw;
	max-height: 86vh;
	object-fit: contain;
	opacity: 0;
	transition: opacity 0.3s;
}

.frey-lightbox--loaded .frey-lightbox__content img {
	opacity: 1;
}

/* Spinner w lightboxie (przed załadowaniem img) */
.frey-lightbox__spinner {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate( -50%, -50% );
	width: 44px;
	height: 44px;
	border: 3px solid rgba( 255, 255, 255, 0.2 );
	border-top-color: #fff;
	border-radius: 50%;
	animation: frey-spin 0.75s linear infinite;
}

.frey-lightbox--loaded .frey-lightbox__spinner {
	display: none;
}

/* Podpis */
.frey-lightbox__caption {
	color: rgba( 255, 255, 255, 0.6 );
	font-size: 0.85rem;
	margin: 0.6rem 0 0;
	text-align: center;
	min-height: 1.2em;
}

/* Przyciski */
.frey-lightbox__close,
.frey-lightbox__prev,
.frey-lightbox__next {
	position: fixed;
	border: none;
	background: rgba( 255, 255, 255, 0.1 );
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s;
	font-size: 1.4rem;
	line-height: 1;
}

.frey-lightbox__close:hover,
.frey-lightbox__prev:hover,
.frey-lightbox__next:hover {
	background: rgba( 255, 255, 255, 0.22 );
}

.frey-lightbox__close {
	top: 1rem;
	right: 1rem;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	font-size: 1.1rem;
}

.frey-lightbox__prev,
.frey-lightbox__next {
	top: 50%;
	transform: translateY( -50% );
	width: 52px;
	height: 90px;
}

.frey-lightbox__prev {
	left: 0;
	border-radius: 0 4px 4px 0;
}

.frey-lightbox__next {
	right: 0;
	border-radius: 4px 0 0 4px;
}

@media ( max-width: 480px ) {
	.frey-lightbox__prev,
	.frey-lightbox__next {
		width: 40px;
		height: 70px;
	}
}
