/**
 * Photo gallery — admin meta box + front-end gallery.
 *
 * Front-end rules are all scoped under `.fos7ty-gallery` so nothing can leak,
 * and every colour comes from the plugin's CSS variables (with a fallback).
 * RTL first: the thumbnail strip flows right-to-left.
 */

/* ============================== Admin ============================== */

.fos7ty-gallery-metabox { direction: rtl; }
.fos7ty-gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin: 12px 0 4px; min-height: 30px; }
.fos7ty-gallery-grid:empty::after { content: attr(data-empty); color: #646970; font-style: italic; }
.fos7ty-gallery-item { position: relative; border: 1px solid #dcdcde; border-radius: 8px; overflow: hidden; background: #fff; cursor: move; }
.fos7ty-gallery-item:hover { border-color: #2271b1; }
.fos7ty-gallery-item img { display: block; width: 100%; height: auto; }
.fos7ty-gallery-remove { position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; padding: 0; line-height: 18px; font-size: 16px; color: #fff; background: #d63638; border: 0; border-radius: 50%; cursor: pointer; }
.fos7ty-gallery-remove:hover,
.fos7ty-gallery-remove:focus { color: #fff; background: #b32d2e; }
.fos7ty-gallery-placeholder { border: 2px dashed #c3c4c7; border-radius: 8px; background: #f6f7f7; }
.fos7ty-gallery-metabox .fos7ty-gallery-actions { margin: 10px 0 0; }

/* ============================ Front end ============================ */

.fos7ty-gallery {
	direction: rtl;
	margin: 0 0 28px;
	text-align: start;
}

.fos7ty-gallery * {
	box-sizing: border-box;
}

.fos7ty-gallery .fos7ty-gallery-main {
	margin: 0 0 12px;
	overflow: hidden;
	border: 1px solid var(--fos7ty-border, #e5e7eb);
	border-radius: 14px;
	background: var(--fos7ty-bg, #ffffff);
}

.fos7ty-gallery .fos7ty-gallery-main-img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 16 / 10;
	object-fit: cover;
}

.fos7ty-gallery .fos7ty-gallery-thumbs {
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: 104px;
	gap: 8px;
	justify-content: start;
	overflow-x: auto;
	padding: 2px 2px 6px;
	scrollbar-width: thin;
}

/* صورة واحدة = بدون شريط مصغّرات. */
.fos7ty-gallery.is-single .fos7ty-gallery-thumbs,
.fos7ty-gallery .fos7ty-gallery-thumbs:empty {
	display: none;
}

.fos7ty-gallery .fos7ty-gallery-thumb {
	display: block;
	width: 104px;
	height: 72px;
	margin: 0;
	padding: 0;
	overflow: hidden;
	cursor: pointer;
	background: var(--fos7ty-bg, #ffffff);
	border: 2px solid var(--fos7ty-border, #e5e7eb);
	border-radius: 10px;
	transition: border-color 0.2s ease, transform 0.2s ease;
}

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

.fos7ty-gallery .fos7ty-gallery-thumb:hover {
	border-color: var(--fos7ty-secondary, #007b8a);
	transform: translateY(-2px);
}

.fos7ty-gallery .fos7ty-gallery-thumb.is-active,
.fos7ty-gallery .fos7ty-gallery-thumb[aria-pressed="true"] {
	border-color: var(--fos7ty-primary, #004764);
	box-shadow: 0 0 0 2px var(--fos7ty-cta, #d32f2f);
}

.fos7ty-gallery .fos7ty-gallery-thumb:focus-visible {
	outline: 3px solid var(--fos7ty-warning, #f59e0b);
	outline-offset: 2px;
}

.fos7ty-gallery .fos7ty-gallery-counter {
	margin: 8px 0 0;
	font-size: 13px;
	color: var(--fos7ty-text-secondary, #555555);
}

@media (max-width: 600px) {
	.fos7ty-gallery .fos7ty-gallery-thumbs { grid-auto-columns: 84px; }
	.fos7ty-gallery .fos7ty-gallery-thumb { width: 84px; height: 60px; }
	.fos7ty-gallery .fos7ty-gallery-main-img { aspect-ratio: 4 / 3; }
}
