/* =========================================================================
   Home: تالار افتخارات (client logo wall)
   Markup: modules/main-parts/brand.tpl   Behaviour: js/brands.js (jQuery 4)
   Rule: logos grey at rest, full colour on hover / focus (touch: colour).
   ========================================================================= */
.rp-br {
	--br-red: #fb4848;
	--br-ink: #29292B;
	--br-line: #e8e8ec;
	--br-ease: cubic-bezier(.22, 1, .36, 1);
	position: relative; /* keeps the .sr-only list inside the clipped box */
	padding: 84px 0 90px;
	background: #fff;
	direction: rtl;
	font-family: 'IranSans', sans-serif;
	overflow: hidden;
}
.rp-br button { font-family: inherit; }

.rp-br-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 34px; }
.rp-br-head .sec-title { margin-bottom: 0; padding-bottom: 0; }
.rp-br-head .rp-h1 { text-wrap: balance; }
.rp-br-toggle {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 11px 20px;
	border: 1px solid var(--br-line);
	border-radius: 999px;
	background: #fff;
	color: var(--br-ink);
	font-family: 'IranSansMedium', 'IranSans', sans-serif;
	font-size: 14px;
	transition: background-color .25s, border-color .25s, color .25s;
}
.rp-br-toggle:hover { background: var(--br-ink); border-color: var(--br-ink); color: #fff; }
.rp-br-toggle:focus-visible { outline: 2px solid var(--br-red); outline-offset: 3px; }

/* ---- marquee rows */
.rp-br-wall { display: flex; flex-direction: column; gap: 14px; }
.rp-br-row {
	direction: ltr; /* the loop math assumes the track starts at the left edge */
	position: relative;
	overflow: hidden;
	-webkit-mask-image: linear-gradient(90deg, transparent 0, #000 9%, #000 91%, transparent 100%);
	mask-image: linear-gradient(90deg, transparent 0, #000 9%, #000 91%, transparent 100%);
}
.rp-br-track {
	display: flex;
	gap: 14px;
	width: max-content;
	margin: 0;
	padding: 4px 0;
	list-style: none;
	direction: ltr;
}
.rp-br-track li { flex: 0 0 auto; margin: 0; }
.rp-br.is-running .rp-br-track { animation: rp-br-move var(--br-dur, 60s) linear infinite; }
.rp-br.is-running .rp-br-row[data-dir="ltr"] .rp-br-track { animation-direction: reverse; }
.rp-br-row:hover .rp-br-track, .rp-br-row:focus-within .rp-br-track { animation-play-state: paused; }
@keyframes rp-br-move { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ---- logo card */
.rp-br-logo {
	position: relative;
	display: grid;
	place-items: center;
	width: 178px;
	height: 96px;
	padding: 10px 16px;
	border: 1px solid var(--br-line);
	border-radius: 18px;
	background: #fff;
	text-decoration: none !important;
	transition: border-color .3s, box-shadow .4s var(--br-ease), transform .4s var(--br-ease);
}
.rp-br-logo img {
	max-width: 100%;
	max-height: 64px;
	width: auto;
	height: auto;
	filter: grayscale(1);
	opacity: .55;
	transition: filter .35s, opacity .35s, transform .4s var(--br-ease);
}
.rp-br-logo:hover, .rp-br-logo:focus-visible {
	border-color: transparent;
	box-shadow: 0 18px 34px -18px rgba(25, 25, 30, .35), 0 0 0 1px rgba(25, 25, 30, .04);
	transform: translateY(-3px);
}
.rp-br-logo:hover img, .rp-br-logo:focus-visible img { filter: none; opacity: 1; transform: scale(1.04); }
.rp-br-logo:focus-visible { outline: 2px solid var(--br-red); outline-offset: 2px; }
/* clients with a portfolio post: small red corner + label on hover */
a.rp-br-logo::before { content: ""; position: absolute; top: 10px; left: 10px; width: 6px; height: 6px; border-radius: 50%; background: var(--br-red); box-shadow: 0 0 0 3px rgba(251, 72, 72, .18); }
.rp-br-tip {
	position: absolute;
	bottom: 6px;
	left: 50%;
	padding: 2px 10px;
	border-radius: 999px;
	background: var(--br-ink);
	color: #fff;
	font-family: 'IranSansMedium', 'IranSans', sans-serif;
	font-size: 10.5px;
	white-space: nowrap;
	direction: rtl;
	opacity: 0;
	transform: translate(-50%, 4px);
	transition: opacity .25s, transform .35s var(--br-ease);
	pointer-events: none;
}
a.rp-br-logo:hover .rp-br-tip, a.rp-br-logo:focus-visible .rp-br-tip { opacity: 1; transform: translate(-50%, 0); }
a.rp-br-logo:hover img, a.rp-br-logo:focus-visible img { transform: translateY(-6px) scale(1.02); }

/* ---- grid view ("همه برندها") */
.rp-br.is-grid .rp-br-wall { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 12px; max-width: 1200px; margin: 0 auto; padding: 0 15px; direction: rtl; }
.rp-br.is-grid .rp-br-row, .rp-br.is-grid .rp-br-track { display: contents; } /* both rows flow as one grid */
.rp-br.is-grid .rp-br-clone { display: none; }
.rp-br.is-grid .rp-br-logo { width: 160px; height: 88px; }

@media (hover: none) {
	.rp-br-logo img { filter: none; opacity: 1; }
}
@media (max-width: 767px) {
	.rp-br { padding: 56px 0 60px; }
	.rp-br-head { flex-direction: column; align-items: flex-start; gap: 14px; margin-bottom: 22px; }
	.rp-br-toggle { padding: 9px 16px; font-size: 13px; }
	.rp-br-wall, .rp-br-track { gap: 10px; }
	.rp-br-logo { width: 132px; height: 74px; padding: 8px 12px; border-radius: 14px; }
	.rp-br-logo img { max-height: 50px; }
	.rp-br.is-grid .rp-br-wall { gap: 8px; }
	.rp-br.is-grid .rp-br-logo { width: calc((100vw - 46px) / 3); height: 64px; padding: 6px 8px; }
	.rp-br-tip { display: none; }
}

/* ---- touch screens (no hover): tell at a glance which clients have a project to see.
   Logos with a portfolio post stay in colour, with a pulsing red dot and a small red "view project" label;
   the others are grey and turn to colour only while touched. */
@media (hover: none) {
	.rp-br-logo img { filter: grayscale(1); opacity: .5; }
	.rp-br-logo:active img { filter: none; opacity: 1; }
	a.rp-br-logo { border-color: rgba(251, 72, 72, .3); }
	a.rp-br-logo img { filter: none; opacity: 1; transform: translateY(-7px); }
	a.rp-br-logo::before { top: 8px; left: 8px; width: 8px; height: 8px; animation: rpBrDot 1.8s ease-out infinite; }
	a.rp-br-logo .rp-br-tip {
		display: block; bottom: 5px; padding: 1px 8px; background: var(--br-red); color: #fff; font-size: 9.5px; line-height: 1.6;
		opacity: 1; transform: translate(-50%, 0);
	}
	html[data-theme="dark"] .rp-br-logo img { filter: grayscale(1) invert(1); mix-blend-mode: screen; opacity: .5; }
	html[data-theme="dark"] a.rp-br-logo { background: #fff; }
	html[data-theme="dark"] a.rp-br-logo img { filter: none; mix-blend-mode: normal; opacity: 1; }
	html[data-theme="dark"] a.rp-br-logo .rp-br-tip { background: var(--br-red); color: #fff; }
	.rp-br.is-grid a.rp-br-logo img { transform: translateY(-6px); max-height: 38px; }
	.rp-br.is-grid a.rp-br-logo .rp-br-tip { bottom: 3px; font-size: 8.5px; padding: 0 6px; }
}
@keyframes rpBrDot { 0% { box-shadow: 0 0 0 0 rgba(251, 72, 72, .55); } 100% { box-shadow: 0 0 0 9px rgba(251, 72, 72, 0); } }
@media (hover: none) and (prefers-reduced-motion: reduce) { a.rp-br-logo::before { animation: none; } }

/* ---- motion driven by js/brands.js (.is-js): the script moves the tracks (drift + scroll push), so the CSS loop is off */
.rp-br.is-js .rp-br-track { animation: none !important; will-change: transform; }
.rp-br.is-js.is-grid .rp-br-track { will-change: auto; }

/* ---- entrance, the first time the section comes into view (.has-intro -> .is-in): the heading rises, the two rows
   slide in from opposite sides and the logos sharpen into view one after another */
.rp-br.has-intro .rp-br-head { opacity: 0; translate: 0 24px; transition: opacity .8s ease, translate .9s var(--br-ease); }
.rp-br.has-intro .rp-br-row { opacity: 0; transition: opacity .9s ease, translate 1.2s var(--br-ease); }
.rp-br.has-intro .rp-br-row:nth-child(1) { translate: 90px 0; }
.rp-br.has-intro .rp-br-row:nth-child(2) { translate: -90px 0; transition-delay: .12s; }
.rp-br.has-intro .rp-br-track > li {
	opacity: 0; filter: blur(6px); translate: 0 14px;
	transition: opacity .6s ease, filter .7s ease, translate .8s var(--br-ease);
	transition-delay: calc(var(--i, 0) * 55ms + 180ms);
}
.rp-br.has-intro .rp-br-row:nth-child(2) .rp-br-track > li { transition-delay: calc(var(--i, 0) * 55ms + 320ms); }
.rp-br.has-intro.is-in .rp-br-head, .rp-br.has-intro.is-in .rp-br-row { opacity: 1; translate: 0 0; }
.rp-br.has-intro.is-in .rp-br-track > li { opacity: 1; filter: none; translate: 0 0; }
.rp-br.has-intro.is-grid .rp-br-track > li { transition-delay: 0s; }
