/* =========================================================================
   Home: نمونه‌کارها (bento grid + service filter)
   Markup: main.tpl (#rp-portfolio) + modules/functions/projects-home.tpl   Behaviour: js/portfolio-home.js
   Rule: photos are grey and dark at rest, full colour on hover / focus (touch screens: colour always).
   ========================================================================= */
.rp-pf {
	--pf-red: #fb4848;
	--pf-row: 230px;
	--pf-gap: 14px;
	--pf-ease: cubic-bezier(.22, 1, .36, 1);
	position: relative;
	padding: 90px 0 80px;
	background:
		radial-gradient(900px 420px at 85% 0%, rgba(251, 72, 72, .10), transparent 70%),
		#151517;
	color: #fff;
	direction: rtl;
	font-family: 'IranSans', sans-serif;
}
.rp-pf button { font-family: inherit; }

/* ---- head */
.rp-pf-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.rp-pf-head .sec-title { margin-bottom: 0; padding-bottom: 0; }
.rp-pf-head .sec-title p { color: rgba(255, 255, 255, .6); }
.rp-pf-head .sec-title .rp-h1 { color: #fff; text-wrap: balance; }
.rp-pf-all {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 11px 20px;
	border: 1px solid rgba(255, 255, 255, .22);
	border-radius: 999px;
	color: #fff !important;
	font-family: 'IranSansMedium', 'IranSans', sans-serif;
	font-size: 14px;
	text-decoration: none !important;
	transition: background-color .25s, border-color .25s;
}
.rp-pf-all i { transition: transform .3s var(--pf-ease); }
.rp-pf-all:hover { background: var(--pf-red); border-color: var(--pf-red); }
.rp-pf-all:hover i { transform: translateX(-4px); }

/* ---- filters */
.rp-pf-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.rp-pf-filters button {
	padding: 9px 18px;
	border: 1px solid rgba(255, 255, 255, .14);
	border-radius: 999px;
	background: rgba(255, 255, 255, .04);
	color: rgba(255, 255, 255, .72);
	font-family: 'IranSansMedium', 'IranSans', sans-serif;
	font-size: 13.5px;
	transition: background-color .25s, border-color .25s, color .25s;
}
.rp-pf-filters button:hover { color: #fff; border-color: rgba(255, 255, 255, .4); }
.rp-pf-filters button.is-active { background: #fff; border-color: #fff; color: #151517; }
.rp-pf-filters button:focus-visible { outline: 2px solid var(--pf-red); outline-offset: 3px; }

/* ---- grid */
.rp-pf-grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	grid-auto-rows: var(--pf-row);
	gap: var(--pf-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}
.rp-pf-item { min-width: 0; margin: 0; animation: rp-pf-in .55s var(--pf-ease) both; }
.rp-pf-item.is-out { display: none; }
@keyframes rp-pf-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
/* "همه": bento, first 8 only (2x2 + 2x1 + 6 singles = 3 rows) */
.rp-pf-grid.is-all .rp-pf-item:nth-child(n+10) { display: none; } /* child 1 is the <meta> */
.rp-pf-grid.is-all .rp-pf-item:nth-child(2) { grid-column: span 2; grid-row: span 2; }
.rp-pf-grid.is-all .rp-pf-item:nth-child(3) { grid-column: span 2; }

.rp-pf-card {
	position: relative;
	display: block;
	height: 100%;
	border-radius: 18px;
	overflow: hidden;
	background: #232326;
	color: #fff !important;
	text-decoration: none !important;
	isolation: isolate;
}
.rp-pf-card img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	filter: grayscale(1) brightness(.72);
	transform: scale(1.01);
	transition: filter .6s ease, transform 1.1s var(--pf-ease);
}
.rp-pf-card::after { /* readable text */
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	background: linear-gradient(0deg, rgba(12, 12, 14, .92) 0%, rgba(12, 12, 14, .45) 38%, rgba(12, 12, 14, 0) 64%);
	transition: opacity .5s;
}
.rp-pf-card:hover img, .rp-pf-card:focus-visible img { filter: none; transform: scale(1.06); }
.rp-pf-card:focus-visible { outline: 2px solid var(--pf-red); outline-offset: 3px; }

.rp-pf-info { position: absolute; z-index: 2; right: 0; left: 0; bottom: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 20px 22px; }
.rp-pf-tags { display: flex; flex-wrap: wrap; align-items: center; font-family: 'IranSansMedium', 'IranSans', sans-serif; font-size: 12px; color: rgba(255, 255, 255, .78); }
.rp-pf-tags::before { content: ""; width: 7px; height: 7px; margin-left: 8px; border-radius: 50%; background: var(--pf-red); box-shadow: 0 0 0 4px rgba(251, 72, 72, .25); }
.rp-pf-tags span + span::before { content: "·"; margin: 0 6px; color: rgba(255, 255, 255, .5); }
.rp-pf-title {
	margin: 0;
	font-family: 'IranSansBold', 'IranSans', sans-serif;
	font-weight: normal;
	font-size: 16px;
	line-height: 1.6;
	color: #fff;
	text-wrap: pretty;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.rp-pf-client {
	font-size: 12.5px;
	color: rgba(255, 255, 255, .62);
	max-height: 0;
	opacity: 0;
	transition: max-height .45s var(--pf-ease), opacity .35s;
}
.rp-pf-card:hover .rp-pf-client, .rp-pf-card:focus-visible .rp-pf-client { max-height: 24px; opacity: 1; }
.rp-pf-go {
	position: absolute;
	z-index: 2;
	top: 16px;
	left: 16px;
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: var(--pf-red);
	color: #fff;
	font-size: 15px;
	opacity: 0;
	transform: scale(.6) rotate(-45deg);
	transition: opacity .3s, transform .45s var(--pf-ease);
}
.rp-pf-card:hover .rp-pf-go, .rp-pf-card:focus-visible .rp-pf-go { opacity: 1; transform: none; }
/* the big card gets a bigger title */
.rp-pf-grid.is-all .rp-pf-item:nth-child(2) .rp-pf-title { font-size: clamp(19px, 1.7vw, 24px); }
.rp-pf-grid.is-all .rp-pf-item:nth-child(2) .rp-pf-info { padding: 28px 30px; }

.rp-pf-empty { margin: 20px 0 0; color: rgba(255, 255, 255, .6); text-align: center; }

/* ---- call to action */
.rp-pf-cta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 20px;
	margin-top: 26px;
	padding: 20px 24px 20px 20px;
	border: 1px dashed rgba(255, 255, 255, .22);
	border-radius: 18px;
	background: rgba(255, 255, 255, .03);
}
.rp-pf-cta strong { display: block; font-family: 'IranSansBold', 'IranSans', sans-serif; font-weight: normal; font-size: 18px; color: #fff; }
.rp-pf-cta span { font-size: 14px; color: rgba(255, 255, 255, .66); }
.rp-pf-call {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	height: 50px;
	padding: 0 24px;
	border-radius: 14px;
	background: var(--pf-red);
	color: #fff !important;
	font-family: 'IranSansMedium', 'IranSans', sans-serif;
	font-size: 15px;
	text-decoration: none !important;
	box-shadow: 0 14px 30px -14px rgba(251, 72, 72, .9);
	transition: background-color .25s, transform .25s;
}
.rp-pf-call:hover { background: #e53d3d; transform: translateY(-2px); }

/* touch screens: no hover, so show colour and details */
@media (hover: none) {
	.rp-pf-card img { filter: none; }
	.rp-pf-client { max-height: 24px; opacity: 1; }
}

/* ---- tablet */
@media (max-width: 991px) {
	.rp-pf { --pf-row: 200px; padding: 70px 0 64px; }
	.rp-pf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.rp-pf-grid.is-all .rp-pf-item:nth-child(3) { grid-column: span 2; }
	.rp-pf-filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -15px; padding-inline: 15px; }
	.rp-pf-filters::-webkit-scrollbar { display: none; }
	.rp-pf-filters button { flex: 0 0 auto; }
}
/* ---- phones */
@media (max-width: 767px) {
	.rp-pf { --pf-row: 190px; --pf-gap: 10px; padding: 56px 0 52px; }
	.rp-pf-head { flex-direction: column; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
	.rp-pf-all { padding: 9px 16px; font-size: 13px; }
	/* two columns: one wide card on top, then small cards; 7 projects in "همه" */
	.rp-pf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 168px; }
	.rp-pf-grid.is-all .rp-pf-item:nth-child(2) { grid-column: span 2; grid-row: span 1; }
	.rp-pf-grid.is-all .rp-pf-item:nth-child(3) { grid-column: auto; }
	.rp-pf-grid.is-all .rp-pf-item:nth-child(n+9) { display: none; }
	.rp-pf-card { border-radius: 14px; }
	.rp-pf-item .rp-pf-info { padding: 12px; gap: 4px; }
	.rp-pf-item .rp-pf-title { font-size: 13px; line-height: 1.55; }
	.rp-pf-item .rp-pf-tags { font-size: 10.5px; }
	.rp-pf-item .rp-pf-tags::before { width: 6px; height: 6px; margin-left: 6px; box-shadow: 0 0 0 3px rgba(251, 72, 72, .25); }
	.rp-pf-item .rp-pf-client { display: none; }
	.rp-pf-grid.is-all .rp-pf-item:nth-child(2) .rp-pf-info { padding: 16px 18px; }
	.rp-pf-grid.is-all .rp-pf-item:nth-child(2) .rp-pf-title { font-size: 17px; }
	.rp-pf-grid.is-all .rp-pf-item:nth-child(2) .rp-pf-client { display: block; }
	.rp-pf-cta { flex-direction: column; align-items: stretch; text-align: center; padding: 18px; }
	.rp-pf-call { justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
	.rp-pf-item { animation: none; }
	.rp-pf-card img, .rp-pf-go, .rp-pf-client { transition: none; }
}

/* ---- homepage service links (same look as the filter buttons) */
.rp-pf-filters a {
	padding: 9px 18px;
	border: 1px solid rgba(255, 255, 255, .14);
	border-radius: 999px;
	background: rgba(255, 255, 255, .04);
	color: rgba(255, 255, 255, .72) !important;
	font-family: 'IranSansMedium', 'IranSans', sans-serif;
	font-size: 13.5px;
	text-decoration: none !important;
	white-space: nowrap;
	transition: background-color .25s, border-color .25s, color .25s;
}
.rp-pf-filters a:hover { background: #fff; border-color: #fff; color: #151517 !important; }
.rp-pf-filters a:focus-visible { outline: 2px solid var(--pf-red); outline-offset: 3px; }
@media (max-width: 991px) { .rp-pf-filters a { flex: 0 0 auto; } }

/* =========================================================================
   /portfolio/ archive page: all projects, uniform grid, filter with counts
   ========================================================================= */
.rp-pf--archive { padding: 70px 0 80px; }
.rp-pf--archive .rp-pf-head { margin-bottom: 14px; }
.rp-pf-lead { max-width: 760px; margin: 0 0 26px; font-size: 15px; line-height: 2; color: rgba(255, 255, 255, .66); }
.rp-pf-filters button b {
	display: inline-grid;
	place-items: center;
	min-width: 22px;
	height: 22px;
	margin-right: 6px;
	padding: 0 6px;
	border-radius: 999px;
	background: rgba(255, 255, 255, .1);
	font-family: 'IranSansMedium', 'IranSans', sans-serif;
	font-weight: normal;
	font-size: 11.5px;
}
.rp-pf-filters button.is-active b { background: var(--pf-red); color: #fff; }
.rp-pf-filters button b:empty { display: none; }
.rp-pf-grid--archive { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 250px; }
.rp-pf-grid--archive #dle-content { display: contents; }
.rp-pf-grid--archive .navigation, .rp-pf-grid--archive .pagination { grid-column: 1 / -1; }
.rp-pf-grid--archive .rp-pf-client { max-height: 24px; opacity: 1; }
/* full rows: js/portfolio-home.js marks the leftover items of the current filter (is-fill3-1 / is-fill3-2 / is-fill2-1);
   wide screens use 6 tracks (each item 2), so 1 leftover spans the row and 2 leftovers take half each */
@media (min-width: 992px) {
	.rp-pf-grid--archive { grid-template-columns: repeat(6, minmax(0, 1fr)); }
	.rp-pf-grid--archive .rp-pf-item { grid-column: span 2; }
	.rp-pf-grid--archive .rp-pf-item.is-fill3-1 { grid-column: span 6; }
	.rp-pf-grid--archive .rp-pf-item.is-fill3-2 { grid-column: span 3; }
}
@media (max-width: 991px) {
	.rp-pf-grid--archive .rp-pf-item.is-fill2-1 { grid-column: span 2; }
}
@media (max-width: 991px) {
	.rp-pf-grid--archive { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 210px; }
}
@media (max-width: 767px) {
	.rp-pf--archive { padding: 44px 0 52px; }
	.rp-pf-lead { font-size: 14px; }
	.rp-pf-grid--archive { grid-auto-rows: 168px; }
}

/* homepage showcase: no service chips (filtering is on /portfolio/), so the head sits right above the grid */
#rp-portfolio:not(.rp-pf--archive) .rp-pf-head { margin-bottom: 30px; }

/* =========================================================================
   Homepage showcase ending: the 4th row of projects fades into the dark under a centred call to action
   (all projects -> /portfolio/, free consultation -> the contact form on this page)
   ========================================================================= */
.rp-pf-stage { position: relative; }
.rp-pf-grid.is-all .rp-pf-item:nth-child(n+10) { display: block; }           /* undo the old 8-item cap */
.rp-pf-grid.is-all .rp-pf-item:nth-child(n+14) { display: none; }
.rp-pf-grid.is-all .rp-pf-item:nth-child(n+10) .rp-pf-card { pointer-events: none; }
.rp-pf-grid.is-all .rp-pf-item:nth-child(n+10) .rp-pf-info { opacity: 0; }
.rp-pf-veil {
	position: absolute;
	right: -2px; left: -2px; bottom: -2px;
	height: calc(var(--pf-row) * 1.3 + var(--pf-gap));
	background: linear-gradient(180deg, rgba(21, 21, 23, 0) 0%, rgba(21, 21, 23, .7) 25%, rgba(21, 21, 23, .94) 55%, #151517 80%);
	pointer-events: none;
}
.rp-pf-more {
	position: absolute;
	right: 0; left: 0; bottom: -12px;
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	padding: 0 20px;
}
.rp-pf-more-eyebrow { font-family: 'IranSansMedium', 'IranSans', sans-serif; font-size: 13px; color: rgba(255, 255, 255, .55); }
.rp-pf-more h3 { margin: 6px 0 8px; font-family: 'IranSansBlack', 'IranSans', sans-serif; font-weight: normal; font-size: clamp(24px, 2.6vw, 36px); line-height: 1.45; color: #fff; }
.rp-pf-more p { max-width: 520px; margin: 0 0 22px; font-size: 14.5px; line-height: 1.9; color: rgba(255, 255, 255, .62); }
.rp-pf-more-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.rp-pf-allbtn {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	height: 52px;
	padding: 0 26px;
	border-radius: 14px;
	background: #fff;
	color: #151517 !important;
	font-family: 'IranSansMedium', 'IranSans', sans-serif;
	font-size: 15px;
	text-decoration: none !important;
	transition: transform .25s, box-shadow .25s;
}
.rp-pf-allbtn i { transition: transform .3s var(--pf-ease); }
.rp-pf-allbtn:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -14px rgba(255, 255, 255, .45); }
.rp-pf-allbtn:hover i { transform: translateX(-4px); }
/* consult button: same hover as the services / callback buttons (red square grows to fill, label slides) */
.rp-pf-consult {
	--ct-red: #fb4848;
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	min-width: 196px;
	height: 52px;
	padding: 0 20px 0 7px;
	border-radius: 14px;
	background: rgba(255, 255, 255, .05);
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16);
	color: #fff !important;
	font-family: 'IranSansMedium', 'IranSans', sans-serif;
	font-size: 15px;
	text-decoration: none !important;
	overflow: hidden;
	isolation: isolate;
}
.rp-pf-consult .rp-fx-fill { left: 7px; top: 7px; }
.rp-pf-consult .rp-fx-alt { white-space: nowrap; }
.rp-pf-consult:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
@media (max-width: 767px) {
	.rp-pf-grid.is-all .rp-pf-item:nth-child(n+9) { display: block; }
	.rp-pf-grid.is-all .rp-pf-item:nth-child(n+11) { display: none; }             /* phones: 7 + one faded row of 2 */
	.rp-pf-grid.is-all .rp-pf-item:nth-child(n+9) .rp-pf-card { pointer-events: none; }
	.rp-pf-grid.is-all .rp-pf-item:nth-child(n+9) .rp-pf-info { opacity: 0; }
	.rp-pf-veil { height: calc(168px * 2.2); background: linear-gradient(180deg, rgba(21, 21, 23, 0) 0%, rgba(21, 21, 23, .85) 30%, #151517 55%); }
	.rp-pf-more { position: relative; bottom: auto; margin-top: -150px; padding: 0; }
	.rp-pf-more-actions { flex-direction: column; align-self: stretch; }
	.rp-pf-allbtn { justify-content: center; width: 100%; }
	.rp-pf-consult { width: 100%; }
}
