/**
 * Shaparak Elementor Widgets — shared styles.
 *
 * All colours/spacing come from Elementor controls; this file only defines
 * structure, layout and the responsive breakpoints.
 */

/* ------------------------------------------------------------------
 * Filter widget
 * --------------------------------------------------------------- */

.spw-filter {
	display: flex;
	flex-direction: column;
	gap: 16px;
	direction: rtl;
	text-align: right;
	font-family: inherit;
}

.spw-filter-title {
	margin: 0;
	font-size: 1.15rem;
	font-weight: 700;
	line-height: 1.4;
}

.spw-field {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.spw-field-label {
	font-size: 0.92rem;
	font-weight: 600;
}

/* ------------------------------------------------------------------
 * Map
 * --------------------------------------------------------------- */

.spw-map {
	width: 100%;
	height: 320px;
	overflow: hidden;
	border-radius: 10px;
	background-color: #f7fafc;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 8px;
	box-sizing: border-box;
}

.spw-map svg {
	width: 100%;
	height: 100%;
	display: block;
}

.spw-map .spw-prov {
	fill: #d9e2ef;
	stroke: #ffffff;
	stroke-width: 1;
	transition: fill 0.2s ease, stroke 0.2s ease;
	cursor: pointer;
	outline: none;
}

.spw-map .spw-prov:hover {
	fill: #b9cbe6;
}

.spw-map .spw-prov.is-selected {
	fill: #1f8a4c;
	stroke: #0f5c33;
}

.spw-map .spw-prov:focus-visible {
	stroke: #2563eb;
	stroke-width: 2;
}

/* ------------------------------------------------------------------
 * Searchable select (dropdown)
 * --------------------------------------------------------------- */

.spw-select {
	position: relative;
	direction: rtl;
}

.spw-select-btn {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	width: 100%;
	min-height: 44px;
	padding: 8px 14px;
	font: inherit;
	font-size: 0.95rem;
	text-align: right;
	background-color: #ffffff;
	color: #1f2937;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	cursor: pointer;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	box-sizing: border-box;
}

.spw-select-btn:focus-visible {
	border-color: #2563eb;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
	outline: none;
}

.spw-select-btn.is-placeholder .spw-select-value {
	color: #9ca3af;
}

.spw-select-value {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.spw-select-caret {
	flex: 0 0 auto;
	width: 9px;
	height: 9px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg) translate(-2px, -2px);
	opacity: 0.6;
	transition: transform 0.2s ease;
}

.spw-select-btn[aria-expanded="true"] .spw-select-caret {
	transform: rotate(-135deg) translate(-2px, -2px);
}

.spw-select-panel {
	position: absolute;
	z-index: 30;
	top: calc(100% + 6px);
	right: 0;
	left: 0;
	max-width: 100%;
	background-color: #ffffff;
	border: 1px solid #e5e7eb;
	border-radius: 8px;
	box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
	overflow: hidden;
	max-height: 320px;
	display: flex;
	flex-direction: column;
}

.spw-select-panel[hidden] {
	display: none;
}

.spw-select-search {
	padding: 8px;
	border-bottom: 1px solid #f3f4f6;
}

.spw-select-input {
	width: 100%;
	min-height: 38px;
	padding: 6px 10px;
	font: inherit;
	font-size: 0.92rem;
	color: inherit;
	background-color: #f9fafb;
	border: 1px solid #e5e7eb;
	border-radius: 6px;
	box-sizing: border-box;
}

.spw-select-input:focus-visible {
	border-color: #2563eb;
	outline: none;
}

.spw-select-list {
	list-style: none;
	margin: 0;
	padding: 4px;
	overflow-y: auto;
	flex: 1;
}

.spw-select-option {
	padding: 9px 12px;
	border-radius: 6px;
	font-size: 0.92rem;
	cursor: pointer;
	transition: background-color 0.12s ease;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.spw-select-option:hover {
	background-color: #f3f4f6;
}

.spw-select-option.is-active {
	background-color: #e8f5ee;
	color: #1f8a4c;
	font-weight: 600;
}

.spw-select-option.spw-select-child {
	padding-right: 26px;
	font-size: 0.88rem;
}

.spw-select-option[hidden] {
	display: none;
}

.spw-select-empty {
	padding: 14px;
	text-align: center;
	color: #9ca3af;
	font-size: 0.88rem;
}

/* ------------------------------------------------------------------
 * Category checkboxes
 * --------------------------------------------------------------- */

.spw-cats {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.spw-cat-item label {
	display: flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	font-size: 0.92rem;
}

.spw-cat-item input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

.spw-cat-box {
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
	border: 1.5px solid #d1d5db;
	border-radius: 4px;
	background-color: #ffffff;
	position: relative;
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.spw-cat-item input:checked + .spw-cat-box {
	background-color: #1f8a4c;
	border-color: #1f8a4c;
}

.spw-cat-item input:checked + .spw-cat-box::after {
	content: "";
	position: absolute;
	top: 2px;
	left: 5px;
	width: 4px;
	height: 9px;
	border-right: 2px solid #ffffff;
	border-bottom: 2px solid #ffffff;
	transform: rotate(45deg);
}

.spw-cat-item input:focus-visible + .spw-cat-box {
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22);
}

/* Base look mirrors the Elementor control defaults (transparent bg,
   light-red hover) so the button looks identical before/after the
   post CSS is regenerated; theme hover backgrounds are neutralised
   here and fully overridable from the controls. */
.spw-reset {
	align-self: flex-start;
	background-color: transparent;
	border: none;
	padding: 4px 0;
	font: inherit;
	font-size: 0.9rem;
	color: #dc2626;
	cursor: pointer;
	text-decoration: underline;
	transition: background-color 0.15s ease, color 0.15s ease;
}

/* No background on the reset button either (same theme-red guard). */
.spw-reset:hover,
.spw-reset:focus,
.spw-reset:active {
	background-color: transparent;
}

/* The theme also reddens the dropdown / drawer-close buttons on hover and
 * focus — keep each one's own colours. */
.spw-select-btn:hover,
.spw-select-btn:focus,
.spw-select-btn:active {
	background-color: #ffffff;
}

.spw-mf-close:focus,
.spw-mf-close:active {
	background-color: transparent;
	color: #1f2937;
}

/* ------------------------------------------------------------------
 * Article list + cards
 * --------------------------------------------------------------- */

.spw-list-widget {
	direction: rtl;
}

.spw-list {
	display: grid;
	gap: 20px;
}

.spw-cols-1 .spw-list {
	/* minmax(0, …) instead of 1fr: an auto minimum lets one wide card
	   (long word / big image) blow the track up and wrap the whole row. */
	grid-template-columns: minmax(0, 1fr);
}

.spw-cols-2 .spw-list {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.spw-cols-3 .spw-list {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

.spw-card {
	display: flex;
	min-width: 0;
	background-color: #ffffff;
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	overflow: hidden;
	transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.spw-card:hover {
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
	transform: translateY(-2px);
}

.spw-card.has-media.media-left {
	flex-direction: row-reverse;
}

.spw-card.has-media.media-right {
	flex-direction: row;
}

.spw-card-media {
	flex: 0 0 34%;
	min-width: 0;
	max-width: 34%;
	overflow: hidden;
	display: block;
	/* Anchor for the category badge overlay. */
	position: relative;
}

.spw-card-media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.3s ease;
}

.spw-card:hover .spw-card-media img {
	transform: scale(1.05);
}

.spw-card-body {
	flex: 1;
	min-width: 0;
	padding: 18px 20px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.spw-card-badge {
	align-self: flex-start;
	padding: 5px 12px;
	border-radius: 10px;
	font-size: 0.78rem;
	font-weight: 600;
	background-color: #ffffff;
	color: #111827;
}

/* Badge on the featured image: top-right corner (design mockup). */
.spw-card-media .spw-card-badge {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 2;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.spw-card-meta {
	font-size: 0.8rem;
	color: #9ca3af;
}

/* Date | time (enabled by the «نمایش ساعت» switcher). */
.spw-meta-sep {
	margin: 0 3px;
}

.spw-card-time {
	white-space: nowrap;
}

.spw-card-title {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 700;
	line-height: 1.5;
	overflow-wrap: break-word;
}

.spw-card-title a {
	color: inherit;
	text-decoration: none;
}

.spw-card-title a:hover {
	color: #1f8a4c;
}

.spw-card-excerpt {
	margin: 0;
	font-size: 0.9rem;
	line-height: 1.7;
	color: #6b7280;
	overflow-wrap: break-word;
}

.spw-card-more {
	margin-top: auto;
	/* Flex row so the icon (real <span> or the default ::before chevron)
	 * can be flipped left/right by the widget's flex-direction control. */
	display: inline-flex;
	align-items: center;
	gap: 6px;
	align-self: flex-start; /* overridable by the راست‌چین/چپ‌چین control */
	font-size: 0.88rem;
	font-weight: 600;
	color: #1f8a4c;
	text-decoration: none;
}

.spw-card-more::before {
	content: "\2039";
}

/* A chosen Elementor icon replaces the default chevron. */
.spw-card-more.has-icon::before {
	content: none;
}

.spw-card-more-icon {
	display: inline-flex;
	align-items: center;
}

.spw-card-more-icon i,
.spw-card-more-icon svg {
	width: 1em;
	height: 1em;
	font-size: 1em;
}

.spw-card-more:hover {
	text-decoration: underline;
}

.spw-empty {
	color: #9ca3af;
	text-align: center;
	padding: 20px;
}

/* ------------------------------------------------------------------
 * Pagination (3-up window by default)
 * --------------------------------------------------------------- */

.spw-pagination {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin-top: 24px;
	direction: rtl;
}

.spw-page {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 40px;
	height: 40px;
	padding: 0 6px;
	font-size: 0.95rem;
	font-weight: 600;
	text-decoration: none;
	color: #374151;
	background-color: #ffffff;
	border: 1px solid #e5e7eb;
	border-radius: 8px;
	transition: background-color 0.15s ease, border-color 0.15s ease;
	box-sizing: border-box;
}

.spw-page:hover:not(.is-active) {
	background-color: #f3f4f6;
}

.spw-page.is-active {
	background-color: #1f8a4c;
	border-color: #1f8a4c;
	color: #ffffff;
	cursor: default;
}

.spw-dots {
	color: #9ca3af;
	padding: 0 2px;
}

.spw-nav {
	font-size: 1.2rem;
	line-height: 1;
}

.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ------------------------------------------------------------------
 * Popular news + province news lists
 * --------------------------------------------------------------- */

.spw-popular,
.spw-province-news {
	direction: rtl;
	display: flex;
	flex-direction: column;
	gap: 14px;
	background-color: #ffffff;
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	padding: 18px;
}

.spw-widget-title {
	margin: 0;
	font-size: 1.1rem;
	font-weight: 700;
	color: #1f8a4c;
}

.spw-pop-list,
.spw-prov-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 14px;
	counter-reset: spw;
}

.spw-pop-item,
.spw-prov-item {
	display: flex;
	align-items: flex-start;
	gap: 12px;
}

.spw-pop-num,
.spw-prov-num {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 30px;
	height: 30px;
	border-radius: 8px;
	background-color: #f3f4f6;
	color: #9ca3af;
	font-size: 0.82rem;
	font-weight: 700;
}

.spw-pop-thumb,
.spw-prov-thumb {
	flex: 0 0 auto;
	width: 56px;
	height: 56px;
	border-radius: 8px;
	overflow: hidden;
	display: block;
}

.spw-pop-thumb img,
.spw-prov-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.spw-pop-body,
.spw-prov-body {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.spw-pop-item-title,
.spw-prov-item-title {
	font-size: 0.92rem;
	font-weight: 600;
	line-height: 1.6;
	color: #374151;
	text-decoration: none;
	/* Ellipsis after N lines: the limit itself (-webkit-line-clamp) comes
	 * from the widget control, so "بدون محدودیت" truly shows everything. */
	display: -webkit-box;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.spw-pop-item-title:hover,
.spw-prov-item-title:hover {
	color: #1f8a4c;
}

.spw-pop-date,
.spw-prov-date,
.spw-prov-meta {
	font-size: 0.78rem;
	color: #9ca3af;
}

.spw-pop-meta {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}

.spw-pop-views {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 0.75rem;
	font-weight: 600;
	color: #1f8a4c;
}

.spw-pop-views::before {
	content: "";
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background-color: currentColor;
	opacity: 0.7;
}

.spw-prov-meta {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

.spw-prov-chip {
	align-self: flex-start;
	padding: 3px 10px;
	border-radius: 999px;
	font-size: 0.78rem;
	font-weight: 600;
	background-color: #eff6ff;
	color: #2563eb;
}

.spw-prov-chip-sm {
	padding: 1px 8px;
	font-size: 0.72rem;
}

/* ------------------------------------------------------------------
 * Width & shrink rules
 *
 * A flex item refuses to shrink below its min-content width. When several
 * widget containers share one row, an unshrinkable widget makes Elementor
 * wrap the row (Wrap is on by default) and every widget then stretches to
 * full width. These rules keep our widgets bounded by their parent and
 * shrinkable inside Elementor containers.
 * --------------------------------------------------------------- */

.spw-filter,
.spw-list-widget,
.spw-popular,
.spw-province-news {
	box-sizing: border-box;
	min-width: 0;
	max-width: 100%;
	overflow-wrap: break-word;
}

/* Same for the Elementor widget wrapper itself (the actual flex item).
   :has() is unsupported on old browsers — those simply keep the old
   behaviour, so this is a safe progressive enhancement. */
.elementor-widget:has(> .elementor-widget-container > .spw-filter),
.elementor-widget:has(> .elementor-widget-container > .spw-list-widget),
.elementor-widget:has(> .elementor-widget-container > .spw-popular),
.elementor-widget:has(> .elementor-widget-container > .spw-province-news) {
	min-width: 0;
	max-width: 100%;
}

/* ---------------------------------------------------------------
 * First slot stays at the top (all widgets)
 *
 * The Elementor container that holds our widgets may be set to
 * "Align Items: center", in which case every child column is
 * vertically centred in the row. A short column then floats to
 * the middle: with a single post the list column shrinks and lands
 * in the centre instead of keeping the first post's slot at the
 * top (the tall columns merely *look* top-aligned).
 *
 * align-self on the item always wins over the parent's
 * align-items, so pinning the columns that host our widgets is
 * enough — no !important, and it does not touch pages whose
 * containers use any other alignment. Matches both structures:
 * boxed containers (.e-con-inner > …) and full-width ones
 * (.e-con-full > …), whether the child is a column or the widget.
 *
 * Same :has() progressive-enhancement note as above: browsers
 * without support simply keep the old centred behaviour.
 * --------------------------------------------------------------- */
.e-con-inner > *:has(.spw-filter),
.e-con-inner > *:has(.spw-list-widget),
.e-con-inner > *:has(.spw-popular),
.e-con-inner > *:has(.spw-province-news),
.e-con-full > *:has(.spw-filter),
.e-con-full > *:has(.spw-list-widget),
.e-con-full > *:has(.spw-popular),
.e-con-full > *:has(.spw-province-news) {
	align-self: flex-start;
}

.spw-map svg {
	min-width: 0;
	max-width: 100%;
}

.spw-select-btn {
	max-width: 100%;
}

/* ------------------------------------------------------------------
 * Mobile filter drawer (`.spw-mf` widget)
 *
 * Drawer mode is the CSS DEFAULT so nothing flashes while the page is
 * still loading (the old inline fallback appeared for a moment before JS
 * ran and looked like the menu suddenly closing). The widget renders a
 * <noscript> block that flips the panel back to an inline box when
 * JavaScript is disabled.
 * --------------------------------------------------------------- */

.spw-mf {
	position: relative;
}

.spw-mf-toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	min-height: 46px;
	padding: 10px 16px;
	font: inherit;
	font-weight: 600;
	color: #1f2937;
	/* No background colour at all — see the state rules below. */
	background-color: transparent;
	border: 1px solid #d1d5db;
	border-radius: 10px;
	cursor: pointer;
	transition: background-color 0.15s ease, border-color 0.15s ease;
	box-sizing: border-box;
}

/* The site's theme (reset.css) paints EVERY <button> with a red
 * background rgb(204, 51, 102) + white text on hover/focus — that is the
 * "red" appearing on the filter button, and no Elementor control can
 * reach it. Keep the toggle background-free in every interactive state;
 * the toggle_bg control output (higher specificity) still wins when set. */
.spw-mf-toggle:hover,
.spw-mf-toggle:focus,
.spw-mf-toggle:active {
	background-color: transparent;
}

.spw-mf-toggle:focus-visible {
	border-color: #2563eb;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
	outline: none;
}

.spw-mf-toggle-icon {
	display: block;
	flex: 0 0 auto;
}

.spw-mf-backdrop {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	background-color: rgba(0, 0, 0, 0.5);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.25s ease, visibility 0.25s ease;
	z-index: 10000;
}

.spw-mf-panel {
	position: fixed;
	top: 0;
	bottom: 0;
	width: 340px;
	max-width: 100%;
	z-index: 10001;
	background-color: #ffffff;
	border: none;
	border-radius: 0;
	/* Room for the × button pinned at the top. */
	padding: 64px 16px 32px;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	box-shadow: 0 0 40px rgba(0, 0, 0, 0.18);
	visibility: hidden;
	transition: transform 0.25s ease, visibility 0.25s ease;
	box-sizing: border-box;
}

.spw-mf[data-side="right"] .spw-mf-panel {
	right: 0;
	transform: translateX(100%);
}

.spw-mf[data-side="left"] .spw-mf-panel {
	left: 0;
	transform: translateX(-100%);
}

.spw-mf.is-open .spw-mf-panel {
	transform: translateX(0);
	visibility: visible;
}

.spw-mf.is-open .spw-mf-backdrop {
	opacity: 1;
	visibility: visible;
}

.spw-mf-close {
	display: flex;
	position: absolute;
	top: 12px;
	width: 40px;
	height: 40px;
	align-items: center;
	justify-content: center;
	font-size: 1.5rem;
	line-height: 1;
	color: #1f2937;
	background: transparent;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.spw-mf-close:hover {
	background-color: #f3f4f6;
}

/* Pin the × on the drawer's inner edge. */
.spw-mf[data-side="right"] .spw-mf-close {
	left: 12px;
}

.spw-mf[data-side="left"] .spw-mf-close {
	right: 12px;
}

/* Page scroll lock while the drawer is open. */
html.spw-drawer-open,
body.spw-drawer-open {
	overflow: hidden;
}

/* ------------------------------------------------------------------
 * Responsive breakpoints (all widgets)
 * --------------------------------------------------------------- */

@media (max-width: 1024px) {
	.spw-cols-3 .spw-list {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.spw-map {
		height: 280px;
	}
}

@media (max-width: 767px) {
	.spw-cols-2 .spw-list,
	.spw-cols-3 .spw-list {
		grid-template-columns: minmax(0, 1fr);
	}

	.spw-card {
		flex-direction: column !important;
	}

	/* Elementor's post CSS outputs `flex-basis: 34%` for the image_width
	 * control with higher specificity than this rule. In the mobile column
	 * layout that percentage resolves against the CARD HEIGHT (a circular
	 * percentage) and inflates the card — leaving a big void above
	 * «ادامه مطلب» (margin-top: auto then pins the link to the bottom).
	 * Force the mobile full-width box with !important to win. */
	.spw-card-media {
		flex: 0 0 auto !important;
		max-width: 100% !important;
		width: 100% !important;
		height: 180px !important;
	}

	.spw-map {
		height: 220px;
	}

	.spw-select-panel {
		max-height: 260px;
	}

	.spw-pop-item,
	.spw-prov-item {
		gap: 10px;
	}

	.spw-page {
		min-width: 34px;
		height: 34px;
		font-size: 0.88rem;
	}

	/* Hide first/last page labels on very small screens to keep the
	 * 3-up window readable; numbered window itself stays. */
	.spw-pagination {
		gap: 6px;
	}
}

@media (max-width: 480px) {
	.spw-filter {
		gap: 14px;
	}

	.spw-map {
		height: 180px;
	}

	.spw-card-body {
		padding: 14px 16px;
	}

	.spw-popular,
	.spw-province-news {
		padding: 14px;
	}
}

/* ------------------------------------------------------------------
 * Reduced motion
 * --------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.spw-map .spw-prov,
	.spw-card,
	.spw-card-media img,
	.spw-select-caret,
	.spw-mf-panel,
	.spw-mf-backdrop {
		transition: none !important;
	}

	.spw-card:hover {
		transform: none;
	}
}
