/**
 * IYG Listing Gallery - Frontend Styles
 *
 * Styles for the [iyg_listing_gallery] shortcode:
 * header, back button, 4:3 thumbnail grid, and notice states.
 */

/* ------------------------------------------------------------------ */
/* Wrapper & custom properties                                         */
/* ------------------------------------------------------------------ */
.iyg-gallery-wrapper {
	--gallery-primary:       #2271b1;
	--gallery-primary-hover: #135e96;
	--gallery-border:        #dcdcde;
	--gallery-radius:        8px;
	--gallery-gap:           12px;
	--gallery-font-size:     14px;

	font-size: var(--gallery-font-size);
	color: #1d2327;
	line-height: 1.5;
	max-width: 1200px;
	margin: 0 auto;
	padding: 0 16px 48px;
	box-sizing: border-box;
}

.iyg-gallery-wrapper *,
.iyg-gallery-wrapper *::before,
.iyg-gallery-wrapper *::after {
	box-sizing: inherit;
}

/* ------------------------------------------------------------------ */
/* Header                                                              */
/* ------------------------------------------------------------------ */
.iyg-gallery-header {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 24px 0 20px;
	border-bottom: 1px solid var(--gallery-border);
	margin-bottom: 24px;
}

@media ( min-width: 640px ) {
	.iyg-gallery-header {
		flex-direction: row;
		align-items: center;
		gap: 20px;
	}
}

.iyg-gallery-back-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	background: #f6f7f7;
	border: 1px solid var(--gallery-border);
	border-radius: var(--gallery-radius);
	color: #1d2327;
	font-size: 13px;
	font-weight: 500;
	text-decoration: none;
	white-space: nowrap;
	transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
	flex-shrink: 0;
}

.iyg-gallery-back-btn:hover,
.iyg-gallery-back-btn:focus {
	background: #e5f0fb;
	border-color: var(--gallery-primary);
	color: var(--gallery-primary);
	text-decoration: none;
	outline: none;
}

.iyg-gallery-back-btn svg {
	flex-shrink: 0;
}

.iyg-gallery-title-wrap {
	min-width: 0;
}

.iyg-gallery-title {
	margin: 0 0 4px;
	font-size: 1.5rem;
	line-height: 1.3;
	font-weight: 700;
	color: #1d2327;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.iyg-gallery-count {
	display: inline-block;
	font-size: 13px;
	color: #646970;
}

/* ------------------------------------------------------------------ */
/* Thumbnail grid                                                      */
/* ------------------------------------------------------------------ */
.iyg-gallery-grid {
	display: grid;
	grid-template-columns: repeat( auto-fill, minmax( 180px, 1fr ) );
	gap: var(--gallery-gap);
}

@media ( min-width: 480px ) {
	.iyg-gallery-grid {
		grid-template-columns: repeat( auto-fill, minmax( 200px, 1fr ) );
	}
}

@media ( min-width: 900px ) {
	.iyg-gallery-grid {
		grid-template-columns: repeat( auto-fill, minmax( 220px, 1fr ) );
	}
}

/* ------------------------------------------------------------------ */
/* Individual thumbnail item                                           */
/* ------------------------------------------------------------------ */
.iyg-gallery-item {
	display: block;
	overflow: hidden;
	border-radius: var(--gallery-radius);
	border: 1px solid var(--gallery-border);
	background: #f0f0f1;
	position: relative;
	text-decoration: none;
	transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.iyg-gallery-item:hover,
.iyg-gallery-item:focus {
	box-shadow: 0 4px 16px rgba( 0, 0, 0, 0.18 );
	transform: translateY( -2px );
	outline: none;
}

.iyg-gallery-item:focus-visible {
	outline: 2px solid var(--gallery-primary);
	outline-offset: 2px;
}

/* Zoom icon overlay on hover */
.iyg-gallery-item::after {
	content: '';
	position: absolute;
	inset: 0;
	background: rgba( 0, 0, 0, 0.22 )
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white' width='28' height='28'%3E%3Cpath d='M10.5 3a7.5 7.5 0 015.905 12.045l4.025 4.025a.75.75 0 01-1.06 1.06l-4.025-4.025A7.5 7.5 0 1110.5 3zm0 1.5a6 6 0 100 12 6 6 0 000-12zm.75 2.25v2.25H13.5a.75.75 0 010 1.5h-2.25V12.75a.75.75 0 01-1.5 0V10.5H7.5a.75.75 0 010-1.5h2.25V6.75a.75.75 0 011.5 0z'/%3E%3C/svg%3E")
		center / 28px no-repeat;
	opacity: 0;
	transition: opacity 0.2s ease;
	border-radius: var(--gallery-radius);
	pointer-events: none;
}

.iyg-gallery-item:hover::after,
.iyg-gallery-item:focus::after {
	opacity: 1;
}

/* 4:3 aspect-ratio thumbnail image */
.iyg-gallery-thumb {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	transition: transform 0.25s ease;
}

.iyg-gallery-item:hover .iyg-gallery-thumb,
.iyg-gallery-item:focus .iyg-gallery-thumb {
	transform: scale( 1.04 );
}

/* ------------------------------------------------------------------ */
/* Notices                                                             */
/* ------------------------------------------------------------------ */
.iyg-gallery-notice {
	padding: 14px 18px;
	border-radius: var(--gallery-radius);
	border-left: 4px solid transparent;
	margin: 20px 0;
}

.iyg-gallery-notice--info {
	background: #e5f0fb;
	border-color: var(--gallery-primary);
	color: #1d2327;
}

.iyg-gallery-notice--error {
	background: #fcf0f1;
	border-color: #d63638;
	color: #1d2327;
}
