/**
 * Aoife Gallery Studio — Frontend Layouts, Hover Effects & Cinema Lightbox / Popover
 * Syncs automatically with Aoife Diller Portfolio theme CSS custom properties when present.
 */

.ags-gallery {
	--ags-accent: var(--adp-accent, #0d3b73);
	--ags-accent-soft: var(--adp-accent-soft, rgba(13, 59, 115, 0.1));
	--ags-surface: var(--adp-card-bg, #ffffff);
	--ags-border-color: var(--adp-border, rgba(15, 23, 42, 0.1));
	--ags-text: var(--adp-text, #0f172a);
	--ags-muted: var(--adp-muted, #64748b);
	--ags-cols: var(--ags-cols-sm, 2);
	width: 100%;
	margin: 0 0 2rem;
	box-sizing: border-box;
}

.ags-gallery *,
.ags-gallery *::before,
.ags-gallery *::after {
	box-sizing: border-box;
}

@media (min-width: 640px) {
	.ags-gallery { --ags-cols: var(--ags-cols-md, 2); }
}
@media (min-width: 992px) {
	.ags-gallery { --ags-cols: var(--ags-cols-lg, 3); }
}
@media (min-width: 1280px) {
	.ags-gallery { --ags-cols: var(--ags-cols-xl, 3); }
}

/* Filter Bar */
.ags-filter-bar {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 18px;
}

.ags-filter-pill {
	appearance: none;
	border: 1px solid var(--ags-border-color);
	background: transparent;
	color: var(--ags-muted);
	padding: 6px 14px;
	border-radius: 999px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s ease;
}

.ags-filter-pill:hover,
.ags-filter-pill.is-active {
	background: var(--ags-accent);
	border-color: var(--ags-accent);
	color: #ffffff;
}

/* Stage Layouts */
.ags-stage {
	position: relative;
	width: 100%;
}

/* 1. Uniform Grid & Circle Grid */
.ags-layout-grid .ags-stage,
.ags-layout-circle .ags-stage {
	display: grid;
	grid-template-columns: repeat(var(--ags-cols, 3), minmax(0, 1fr));
	gap: var(--ags-gutter, 14px);
}

/* 2. Balanced Masonry (CSS Grid fallback before JS balances exact heights, so zero layout jump / FOUC!) */
.ags-layout-masonry .ags-stage:not(.is-masonry-ready) {
	display: grid;
	grid-template-columns: repeat(var(--ags-cols, 3), minmax(0, 1fr));
	gap: var(--ags-gutter, 14px);
	align-items: start;
}

.ags-layout-masonry .ags-stage.is-masonry-ready {
	display: block;
	position: relative;
}

.ags-layout-masonry .ags-stage.is-masonry-ready .ags-item {
	position: absolute;
	top: 0;
	left: 0;
	margin: 0;
	transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
}

/* 3. Editorial Justified Rows */
.ags-layout-justified .ags-stage {
	display: flex;
	flex-wrap: wrap;
	gap: var(--ags-gutter, 14px);
}

.ags-layout-justified .ags-item {
	flex-grow: 1;
	margin: 0;
}

.ags-layout-justified .ags-media-frame {
	height: 100%;
}

.ags-layout-justified .ags-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Aspect Ratios for Clean Uniform Grid */
.ags-ratio-3-2 .ags-media-frame  { aspect-ratio: 3 / 2; }
.ags-ratio-4-5 .ags-media-frame  { aspect-ratio: 4 / 5; }
.ags-ratio-1-1 .ags-media-frame  { aspect-ratio: 1 / 1; }
.ags-ratio-16-9 .ags-media-frame { aspect-ratio: 16 / 9; }

.ags-ratio-3-2 .ags-img,
.ags-ratio-4-5 .ags-img,
.ags-ratio-1-1 .ags-img,
.ags-ratio-16-9 .ags-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Circle Layout */
.ags-layout-circle .ags-media-frame {
	aspect-ratio: 1 / 1;
	border-radius: 50% !important;
}

.ags-layout-circle .ags-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Card & Image Base — Explicitly neutralize legacy theme img shadows */
.ags-item {
	margin: 0;
	padding: 0;
}

.ags-item.is-filtered-out {
	display: none !important;
}

.ags-card-inner {
	padding: var(--ags-pad, 0px);
	border-radius: var(--ags-radius, 6px);
	background: transparent;
	transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.32s ease, border-color 0.25s ease;
}

.ags-has-border .ags-card-inner {
	background: var(--ags-surface);
	border: 1px solid var(--ags-border-color);
}

.ags-item-link {
	display: block;
	text-decoration: none !important;
	color: inherit;
	box-shadow: none !important;
	outline-offset: 3px;
}

.ags-media-frame {
	position: relative;
	overflow: hidden;
	border-radius: max(0px, calc(var(--ags-radius, 6px) - (var(--ags-pad, 0px) * 0.35)));
	background: rgba(15, 23, 42, 0.04);
}

.ags-img {
	display: block;
	width: 100%;
	height: auto;
	border: 0 !important;
	box-shadow: none !important;
	transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1), filter 0.45s ease;
	backface-visibility: hidden;
}

/* Grayscale to Color */
.ags-has-grayscale .ags-img {
	filter: grayscale(var(--ags-gray, 85%));
}

.ags-has-grayscale .ags-card-inner:hover .ags-img {
	filter: grayscale(0%);
}

/* Hover Effects */
.ags-hover-lift .ags-card-inner:hover {
	transform: translateY(-4px);
	box-shadow: 0 16px 34px -10px rgba(13, 35, 68, 0.2);
}

.ags-hover-zoom .ags-card-inner:hover .ags-img {
	transform: scale(1.045);
}

.ags-hover-glow .ags-card-inner:hover {
	box-shadow: 0 0 0 1px var(--ags-glow, #1a4a85), 0 14px 32px -6px var(--ags-glow, #1a4a85);
}

.ags-hover-frame .ags-card-inner {
	border: 1px solid transparent;
}

.ags-hover-frame .ags-card-inner:hover {
	border-color: var(--ags-accent);
}

/* Video Play Button & Source Badge */
.ags-play-circle {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 52px;
	height: 52px;
	border-radius: 50%;
	background: rgba(11, 20, 36, 0.76);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	border: 1.5px solid rgba(255, 255, 255, 0.75);
	color: #ffffff;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.25s ease, background 0.25s ease;
	pointer-events: none;
	z-index: 2;
}

.ags-card-inner:hover .ags-play-circle {
	transform: translate(-50%, -50%) scale(1.1);
	background: var(--ags-accent);
}

.ags-source-badge {
	position: absolute;
	top: 10px;
	right: 10px;
	background: rgba(11, 20, 36, 0.74);
	backdrop-filter: blur(4px);
	color: #ffffff;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	padding: 3px 8px;
	border-radius: 999px;
	pointer-events: none;
	z-index: 2;
}

/* Overlay & Below Captions */
.ags-overlay-caption {
	position: absolute;
	inset: auto 0 0 0;
	padding: 28px 14px 12px;
	background: linear-gradient(to top, rgba(7, 11, 18, 0.82) 0%, rgba(7, 11, 18, 0.35) 60%, transparent 100%);
	color: #ffffff;
	display: flex;
	flex-direction: column;
	gap: 2px;
	pointer-events: none;
	transition: opacity 0.28s ease, transform 0.28s ease;
	z-index: 2;
}

.ags-titles-hover .ags-overlay-caption {
	opacity: 0;
	transform: translateY(6px);
}

.ags-titles-hover .ags-card-inner:hover .ags-overlay-caption,
.ags-titles-hover .ags-item-link:focus-visible .ags-overlay-caption {
	opacity: 1;
	transform: translateY(0);
}

.ags-below-caption {
	padding: 8px 2px 4px;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.ags-item-title {
	font-size: 13.5px;
	font-weight: 600;
	line-height: 1.3;
}

.ags-below-caption .ags-item-title {
	color: var(--ags-text);
}

.ags-item-sub {
	font-size: 12px;
	opacity: 0.82;
	line-height: 1.35;
}

.ags-below-caption .ags-item-sub {
	color: var(--ags-muted);
}

/* AJAX Load More Pagination */
.ags-pagination-wrap {
	display: flex;
	justify-content: center;
	margin-top: 28px;
}

.ags-load-more-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 11px 24px;
	border-radius: 999px;
	border: 1px solid var(--ags-accent);
	background: transparent;
	color: var(--ags-accent);
	font-size: 13.5px;
	font-weight: 600;
	letter-spacing: 0.02em;
	cursor: pointer;
	transition: all 0.2s ease;
}

.ags-load-more-btn:hover {
	background: var(--ags-accent);
	color: #ffffff;
}

.ags-load-more-count {
	font-size: 12px;
	opacity: 0.72;
}

.ags-spinner {
	display: none;
	width: 14px;
	height: 14px;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: agsSpin 0.65s linear infinite;
}

.ags-load-more-btn.is-loading .ags-spinner {
	display: inline-block;
}

@keyframes agsSpin {
	to { transform: rotate(360deg); }
}

/* ==========================================================================
   CINEMA LIGHTBOX & POPOVER VIEWER (Zero-Dependency Vanilla JS)
   ========================================================================== */

.ags-viewer-backdrop {
	position: fixed;
	inset: 0;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.25s ease, visibility 0.25s ease;
	user-select: none;
	font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Inter, sans-serif;
}

.ags-viewer-backdrop.is-open {
	opacity: 1;
	visibility: visible;
}

/* Popover Window Variant */
.ags-viewer-backdrop.is-popover {
	justify-content: center;
	align-items: center;
	padding: 24px;
}

.ags-popover-shell {
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
}

.ags-viewer-backdrop.is-popover .ags-popover-shell {
	max-width: 980px;
	max-height: 86vh;
	background: #0c1220;
	border: 1px solid rgba(255, 255, 255, 0.14);
	border-radius: 16px;
	box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65);
	overflow: hidden;
}

/* Top Bar */
.ags-viewer-topbar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 14px 20px;
	color: rgba(255, 255, 255, 0.9);
	z-index: 5;
}

.ags-viewer-counter {
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.05em;
	font-variant-numeric: tabular-nums;
	opacity: 0.85;
}

.ags-viewer-actions {
	display: flex;
	align-items: center;
	gap: 6px;
}

.ags-vbtn {
	appearance: none;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: 1px solid rgba(255, 255, 255, 0.14);
	background: rgba(255, 255, 255, 0.07);
	color: #ffffff;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background 0.18s ease, transform 0.18s ease;
	padding: 0;
}

.ags-vbtn:hover {
	background: rgba(255, 255, 255, 0.18);
}

/* Main Stage */
.ags-viewer-stage {
	position: relative;
	flex: 1;
	min-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 6px 64px;
	overflow: hidden;
}

@media (max-width: 700px) {
	.ags-viewer-stage {
		padding: 6px 12px;
	}
}

.ags-viewer-media-wrap {
	position: relative;
	max-width: 100%;
	max-height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity var(--ags-lb-speed, 280ms) ease, transform var(--ags-lb-speed, 280ms) cubic-bezier(0.22, 1, 0.36, 1);
}

.ags-viewer-media-wrap.is-switching-fade {
	opacity: 0;
}

.ags-viewer-media-wrap.is-switching-zoom {
	opacity: 0;
	transform: scale(0.93);
}

.ags-viewer-media-wrap.is-switching-slide {
	opacity: 0;
	transform: translateX(28px);
}

.ags-viewer-img {
	max-width: 100%;
	max-height: calc(100vh - 190px);
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: 4px;
	display: block;
	box-shadow: 0 20px 55px rgba(0, 0, 0, 0.45);
	transition: transform 0.28s ease;
	cursor: zoom-in;
}

.ags-viewer-backdrop.is-no-thumbs .ags-viewer-img {
	max-height: calc(100vh - 125px);
}

.ags-viewer-backdrop.is-popover .ags-viewer-img {
	max-height: calc(86vh - 175px);
}

.ags-viewer-img.is-zoomed {
	transform: scale(1.65);
	cursor: zoom-out;
}

.ags-viewer-video-box {
	width: min(92vw, 1080px);
	aspect-ratio: 16 / 9;
	max-height: calc(100vh - 190px);
	background: #000000;
	border-radius: 8px;
	overflow: hidden;
	box-shadow: 0 20px 55px rgba(0, 0, 0, 0.55);
}

.ags-viewer-video-box iframe,
.ags-viewer-video-box video {
	width: 100%;
	height: 100%;
	border: 0;
	margin: 0 !important;
	display: block;
}

/* Prev / Next Arrows */
.ags-nav-arrow {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: 1px solid rgba(255, 255, 255, 0.16);
	background: rgba(10, 15, 26, 0.58);
	backdrop-filter: blur(6px);
	color: #ffffff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	z-index: 6;
	transition: background 0.18s ease, transform 0.18s ease;
}

.ags-nav-arrow:hover {
	background: rgba(255, 255, 255, 0.2);
}

.ags-nav-prev { left: 16px; }
.ags-nav-next { right: 16px; }

/* Bottom Info + Filmstrip */
.ags-viewer-footer {
	padding: 8px 20px 14px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	z-index: 5;
}

.ags-viewer-meta {
	text-align: center;
	color: #ffffff;
	max-width: 760px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
}

.ags-viewer-title {
	font-size: 14.5px;
	font-weight: 600;
	letter-spacing: 0.01em;
}

.ags-viewer-caption {
	font-size: 13px;
	color: rgba(255, 255, 255, 0.72);
}

.ags-viewer-exif {
	display: inline-block;
	font-size: 11px;
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	letter-spacing: 0.03em;
	color: rgba(255, 255, 255, 0.78);
	background: rgba(255, 255, 255, 0.1);
	border: 1px solid rgba(255, 255, 255, 0.14);
	padding: 2px 10px;
	border-radius: 999px;
}

.ags-filmstrip {
	display: flex;
	gap: 6px;
	max-width: 100%;
	overflow-x: auto;
	padding: 2px 4px;
	scrollbar-width: thin;
}

.ags-film-thumb {
	flex: 0 0 auto;
	width: 54px;
	height: 40px;
	border-radius: 4px;
	overflow: hidden;
	border: 2px solid transparent;
	opacity: 0.48;
	cursor: pointer;
	padding: 0;
	background: #111827;
	transition: opacity 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.ags-film-thumb:hover {
	opacity: 0.85;
}

.ags-film-thumb.is-active {
	opacity: 1;
	border-color: #ffffff;
	transform: translateY(-2px);
}

.ags-film-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.ags-empty-notice,
.ags-block-placeholder {
	padding: 24px;
	text-align: center;
	border: 1px dashed rgba(15, 23, 42, 0.25);
	border-radius: 8px;
	font-size: 14px;
	color: #64748b;
}
