/* Arocom Projects Grid — Elementor widget: Grid/List view, tab + dropdown filters */

.apg-wrap {
	/* General */
	--apg-link: #2563eb;
	--apg-muted: #666;      /* internal use only (empty state, editor notice) */
	--apg-cols: 3;          /* overridden per-breakpoint by the Grid Columns control */

	/* Filter tabs */
	--apg-tab-color: #444;
	--apg-tab-color-active: #fff;
	--apg-tab-bg: #fff;
	--apg-tab-bg-active: #111;
	--apg-tab-border: #eaeaea;

	/* Grid/List view icons */
	--apg-icon-color: #666;
	--apg-icon-color-active: #fff;
	--apg-icon-bg-active: #111;
	--apg-icon-border: #eaeaea;

	/* Card / row content area */
	--apg-content-bg: #fff;
	--apg-content-border: #eaeaea;

	/* Pagination */
	--apg-page-color: #444;
	--apg-page-color-active: #fff;
	--apg-page-bg: #fff;
	--apg-page-bg-active: #111;
	--apg-page-border: #eaeaea;

	/* max-width: 1200px; */
	margin: 0 auto;
}

/* ============================================================
   TOP — filter tabs / dropdown + Grid/List view toggle
   ============================================================ */
.apg-controls {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
	padding-bottom: 20px;
	margin-bottom: 28px;
	border-bottom: 1px solid var(--apg-content-border);
}

.apg-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	flex: 1 1 auto;
}
.apg-tab {
	border: 1px solid var(--apg-tab-border);
	background: var(--apg-tab-bg);
	color: var(--apg-tab-color);
	font-size: 14px;
	line-height: 1;
	padding: 10px 18px;
	border-radius: 999px;
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.apg-tab:hover:not(.is-active) { border-color: color-mix(in srgb, var(--apg-tab-border) 50%, #999); }
.apg-tab.is-active {
	background: var(--apg-tab-bg-active);
	border-color: var(--apg-tab-bg-active);
	color: var(--apg-tab-color-active);
}

/* Mobile category dropdown — hidden on desktop, shown under 991px */
.apg-select {
	display: none;
	flex: 1 1 100%;
}
.apg-select__label {
	display: block;
	font-size: 13px;
	color: var(--apg-muted);
	margin-bottom: 8px;
}
.apg-select__field {
	width: 100%;
	border: 1px solid var(--apg-tab-border);
	background: var(--apg-tab-bg);
	color: var(--apg-tab-color);
	font-size: 15px;
	padding: 12px 14px;
	border-radius: 12px;
	cursor: pointer;
	appearance: none;
}

/* Grid/List view toggle — margin-left:auto keeps it pinned right whether
   it's sharing .apg-controls with the filter tabs or is the only child
   (filters hidden via the "Show Filter Tabs" switch). */
.apg-view-toggle {
	display: inline-flex;
	border: 1px solid var(--apg-icon-border);
	border-radius: 999px;
	padding: 4px;
	flex: 0 0 auto;
	margin-left: auto;
	gap: 2px;
}
.apg-view-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border: none;
	background: transparent;
	color: var(--apg-icon-color);
	border-radius: 999px;
	cursor: pointer;
	padding: 0;
	transition: background-color 0.2s ease, color 0.2s ease;
}
.apg-view-btn:hover:not(.is-active) { color: color-mix(in srgb, var(--apg-icon-color) 40%, #000); }
.apg-view-btn.is-active {
	background: var(--apg-icon-bg-active);
	color: var(--apg-icon-color-active);
}

/* ============================================================
   MIDDLE — the fetched posts (Grid or List)
   ============================================================ */

/* Grid view — column count set by the "Grid Columns" control
   (responsive per Elementor breakpoint) via the --apg-cols variable. */
.apg-items--grid {
	display: grid;
	grid-template-columns: repeat(var(--apg-cols, 3), 1fr);
	gap: 28px;
}
.apg-card {
	display: flex;
	flex-direction: column;
	background: var(--apg-content-bg);
	border: 1px solid var(--apg-content-border);
	border-radius: 14px;
	overflow: hidden;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
	transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.apg-card:hover {
	transform: translateY(-4px);
	box-shadow: 0 16px 32px -8px rgba(0, 0, 0, 0.12);
}
.apg-card__media {
	display: block;
	aspect-ratio: 16 / 9;
	background: #f2f2f2;
	overflow: hidden;
}
.apg-card__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.35s ease;
}
.apg-card:hover .apg-card__media img { transform: scale(1.05); }
.apg-card__body {
	display: flex;
	flex-direction: column;
	flex: 1;
	padding: 24px;
}
.apg-card__tag {
	display: inline-block;
	align-self: flex-start;
	font-size: 12px;
	letter-spacing: 0.04em;
	text-transform: none;
	font-weight: 600;
	color: #888;
	margin-bottom: 12px;
}
.apg-card__title {
	font-size: 19px;
	line-height: 1.35;
	font-weight: 600;
	margin: 0 0 10px;
}
.apg-card__title a { color: #111; text-decoration: none; transition: color 0.2s ease; }
.apg-card__excerpt {
	font-size: 15px;
	line-height: 1.6;
	color: #555;
	margin: 0 0 20px;
}
.apg-card__link {
	margin-top: auto; /* pin to bottom-left */
	display: inline-flex;
	align-items: center;
	gap: 6px;
	align-self: flex-start;
	font-size: 14px;
	font-weight: 600;
	color: var(--apg-link);
	text-decoration: none;
}

/* List view — horizontal row: image left, content right */
.apg-items--list {
	display: flex;
	flex-direction: column;
	gap: 20px;
}
.apg-row {
	display: flex;
	background: var(--apg-content-bg);
	border: 1px solid var(--apg-content-border);
	border-radius: 14px;
	overflow: hidden;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
	transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.apg-row:hover {
	transform: translateY(-2px);
	box-shadow: 0 16px 32px -8px rgba(0, 0, 0, 0.12);
}
.apg-row__media {
	flex: 0 0 300px;
	aspect-ratio: 4 / 3;
	background: #f2f2f2;
	overflow: hidden;
}
.apg-row__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.35s ease;
}
.apg-row:hover .apg-row__media img { transform: scale(1.05); }
.apg-row__body {
	display: flex;
	flex-direction: column;
	flex: 1;
	padding: 28px 32px;
	justify-content: center;
}
.apg-row__tag {
	display: inline-block;
	align-self: flex-start;
	font-size: 12px;
	letter-spacing: 0.04em;
	text-transform: none;
	font-weight: 600;
	color: #888;
	margin-bottom: 10px;
}
.apg-row__title {
	font-size: 22px;
	line-height: 1.35;
	font-weight: 600;
	margin: 0 0 10px;
}
.apg-row__title a { color: #111; text-decoration: none; transition: color 0.2s ease; }
.apg-row__excerpt {
	font-size: 15px;
	line-height: 1.6;
	color: #555;
	margin: 0 0 16px;
	max-width: 640px;
}
.apg-row__link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	align-self: flex-start;
	font-size: 14px;
	font-weight: 600;
	color: var(--apg-link);
	text-decoration: none;
}

/* Icon shared by both views — a dedicated class (rather than a bare `span`)
   so the hover-slide animation doesn't also catch the link-text span. */
.apg-card__link .apg-link-icon,
.apg-row__link .apg-link-icon {
	display: inline-flex;
	align-items: center;
	line-height: 1;
	transition: transform 0.2s ease;
}
.apg-card__link:hover .apg-link-icon,
.apg-row__link:hover .apg-link-icon { transform: translateX(3px); }
.apg-card__link .apg-link-icon svg,
.apg-row__link .apg-link-icon svg { width: 1em; height: 1em; fill: currentColor; }

/* Title/color controls target these directly (see widget PHP selectors);
   :hover reuses the same specificity so the Style-tab "Title Hover Color"
   control can override it. */
.apg-card__title a:hover,
.apg-row__title a:hover { color: var(--apg-link); }

/* Empty state */
.apg-empty {
	text-align: center;
	color: var(--apg-muted);
	padding: 48px 0;
}

/* ============================================================
   BOTTOM — Pagination
   ============================================================ */
.apg-pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 36px;
}
.apg-page {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 40px;
	height: 40px;
	padding: 0 8px;
	border: 1px solid var(--apg-page-border);
	background: var(--apg-page-bg);
	color: var(--apg-page-color);
	font-size: 14px;
	font-weight: 600;
	border-radius: 999px;
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.apg-page:hover:not(:disabled):not(.is-active) {
	border-color: color-mix(in srgb, var(--apg-page-border) 50%, #999);
}
.apg-page.is-active {
	background: var(--apg-page-bg-active);
	border-color: var(--apg-page-bg-active);
	color: var(--apg-page-color-active);
	cursor: default;
}
.apg-page:disabled:not(.is-active) {
	opacity: 0.4;
	cursor: default;
}
.apg-page--ellipsis {
	border-color: transparent;
	background: transparent;
	cursor: default;
	min-width: 24px;
}

/* AJAX in-flight state — the items area dims and ignores clicks until the
   requested page/filter has finished loading. */
.apg-wrap.apg-loading .apg-items { opacity: 0.4; pointer-events: none; transition: opacity 0.15s ease; }
.apg-wrap.apg-loading .apg-pagination { pointer-events: none; }

/* JS state */
.apg-hidden { display: none !important; }

/* Editor-only placeholder shown when the query returns nothing, so the
   widget isn't an invisible blank area inside the Elementor canvas. */
.ace-editor-notice {
	padding: 40px 24px;
	border: 1px dashed var(--apg-content-border);
	border-radius: 12px;
	text-align: center;
	color: var(--apg-muted);
	font-size: 14px;
	line-height: 1.6;
}

/* Responsive — structural only; grid column count is handled by Elementor's
   own responsive "Grid Columns" control, not a hardcoded rule here. */
@media (max-width: 991px) {
	.apg-tabs { display: none; }   /* swap tab bar for the compact dropdown */
	.apg-select { display: block; }
}
@media (max-width: 640px) {
	.apg-row { flex-direction: column; }
	.apg-row__media { flex: none; width: 100%; aspect-ratio: 16 / 9; }
	.apg-row__body { padding: 20px; }
	.apg-controls { flex-direction: column; align-items: stretch; }
	.apg-view-toggle { align-self: flex-end; }
}
