/* ==========================================================================
   Smart Gadgets Reviews – content styles (homepage and shortcodes)
   --------------------------------------------------------------------------
   Loaded by functions.php (section 8). Does NOT touch the header or footer
   (those live in style.css).

   Section backgrounds, spacing, headings, buttons and the category card
   borders are set in Elementor and edited there. This file only styles
   output that Elementor cannot style itself:

     1. Shared variables
     2. [sgr_latest_posts] – post card grid
     3. [sgr_latest_posts] – empty state / auto-hide (class "sgr-auto-hide")
     4. [sgr_category_link] – links and whole-card click area
     5. Category cards (class "sgr-cat-card" on an Elementor container)
     6. Accessibility helper
   ========================================================================== */

/* 1. Shared variables ----------------------------------------------------- */
:root {
	--sgr-c-primary: var(--e-global-color-primary, #155EEF);
	--sgr-c-navy: var(--e-global-color-secondary, #101828);
	--sgr-c-text: var(--e-global-color-text, #344054);
	--sgr-c-border: var(--e-global-color-sgr_border, #EAECF0);
	--sgr-c-light: var(--e-global-color-sgr_light, #F5F7FA);
	--sgr-c-muted: #667085;
	--sgr-radius: 12px;
	--sgr-shadow: 0 1px 2px rgba(16, 24, 40, .05);
	--sgr-shadow-hover: 0 12px 24px -6px rgba(16, 24, 40, .10), 0 4px 8px -4px rgba(16, 24, 40, .06);
}

/* 2. Post card grid -------------------------------------------------------- */
.sgr-posts {
	display: grid;
	gap: 24px;
	grid-template-columns: repeat(var(--sgr-cols, 3), minmax(0, 1fr));
}
.sgr-posts--cols-1 { --sgr-cols: 1; }
.sgr-posts--cols-2 { --sgr-cols: 2; }
.sgr-posts--cols-3 { --sgr-cols: 3; }
.sgr-posts--cols-4 { --sgr-cols: 4; }

@media (max-width: 1024px) {
	.sgr-posts--cols-3,
	.sgr-posts--cols-4 { --sgr-cols: 2; }
}
@media (max-width: 767px) {
	.sgr-posts { --sgr-cols: 1 !important; gap: 20px; }
}

.sgr-card {
	display: flex;
	flex-direction: column;
	background: #FFFFFF;
	border: 1px solid var(--sgr-c-border);
	border-radius: var(--sgr-radius);
	box-shadow: var(--sgr-shadow);
	overflow: hidden;
	transition: box-shadow .2s ease, transform .2s ease;
}
.sgr-card:hover {
	box-shadow: var(--sgr-shadow-hover);
	transform: translateY(-2px);
}

.sgr-card__media {
	display: block;
	aspect-ratio: 16 / 10;
	background: var(--sgr-c-light);
	overflow: hidden;
}
.sgr-card__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.sgr-card__img--none {
	/* Post without a featured image: neutral tile, no fake picture. */
	background: var(--sgr-c-light);
}

.sgr-card__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 8px;
	padding: 20px;
}
.sgr-card__meta {
	margin: 0;
	font-size: 13px;
	color: var(--sgr-c-muted);
}
.sgr-card__title {
	margin: 0;
	font-size: 18px;
	font-weight: 700;
	line-height: 1.35;
	color: var(--sgr-c-navy);
}
.sgr-card__title a {
	color: inherit;
	text-decoration: none;
}
.sgr-card__title a:hover,
.sgr-card__title a:focus-visible {
	color: var(--sgr-c-primary);
}
.sgr-card__excerpt {
	margin: 0;
	font-size: 15px;
	line-height: 1.6;
	color: var(--sgr-c-text);
}
.sgr-card__link {
	margin-top: auto;
	padding-top: 8px;
	font-size: 15px;
	font-weight: 600;
	color: var(--sgr-c-primary);
	text-decoration: none;
}
.sgr-card__link::after,
.sgr-cat-link::after {
	content: " \2192";
}
.sgr-card__link:hover,
.sgr-card__link:focus-visible {
	color: var(--sgr-c-navy);
}

/* 3. Empty state / auto-hide ----------------------------------------------
   With no published posts, the shortcode prints an invisible marker
   (.sgr-posts-empty). An Elementor container with the CSS class
   "sgr-auto-hide" that contains the marker is hidden for visitors.
   In the Elementor editor a notice is printed instead of the marker. */
.sgr-auto-hide:has(.sgr-posts-empty) {
	display: none !important;
}
.sgr-posts-notice {
	margin: 0;
	padding: 16px 20px;
	border: 1px dashed #98A2B3;
	border-radius: 8px;
	background: var(--sgr-c-light);
	color: var(--sgr-c-text);
	font-size: 14px;
}

/* 4. Category links -------------------------------------------------------- */
.sgr-cat-link {
	font-weight: 600;
	color: var(--sgr-c-primary);
	text-decoration: none;
}
.sgr-cat-link:hover,
.sgr-cat-link:focus-visible {
	color: var(--sgr-c-navy);
}
/* Makes the closest positioned card fully clickable (one link, no JS). */
.sgr-link-stretched::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

/* 5. Category cards --------------------------------------------------------
   Border, radius, background and padding are set in Elementor; this adds
   the click area, hover state and keeps the image flush with the card. */
.sgr-cat-card {
	position: relative;
	transition: box-shadow .2s ease, transform .2s ease;
}
.sgr-cat-card:hover,
.sgr-cat-card:focus-within {
	box-shadow: var(--sgr-shadow-hover);
	transform: translateY(-2px);
}
.sgr-cat-card .elementor-widget-image img {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 10;
	object-fit: cover;
}
.sgr-cat-card:focus-within .sgr-link-stretched {
	outline: none;
}
.sgr-cat-card:has(.sgr-link-stretched:focus-visible) {
	outline: 2px solid var(--sgr-c-primary);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.sgr-card,
	.sgr-cat-card { transition: none; }
	.sgr-card:hover,
	.sgr-cat-card:hover,
	.sgr-cat-card:focus-within { transform: none; }
}

/* 6. Accessibility helper (visually hidden, read by screen readers) ------- */
.sgr-posts .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}
