
.pf-wrap,
.pf-first,
.pf-modal {
	--pf-accent: #e6001d;
	--pf-title: #1e5486;
	--pf-ink: #0f1419;
	--pf-muted: #566070;
	--pf-line: rgba(15, 20, 25, .14);
	--pf-ease: cubic-bezier(.22, 1, .36, 1);
}

.pf-wrap *, .pf-wrap *::before, .pf-wrap *::after,
.pf-first *, .pf-first *::before, .pf-first *::after,
.pf-modal *, .pf-modal *::before, .pf-modal *::after { box-sizing: border-box; }

.pf-wrap { position: relative; width: 100%; max-width: none; margin: 0; }
.pf-wrap .pf-list { display: flex; flex-direction: column; gap: clamp(28px, 4vw, 56px); }
.pf-wrap .pf-sentinel { height: 1px; }
.pf-empty { text-align: center; color: #566070; }

.pf-wrap .pf-item {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
	background: #fff;
	border: 1px solid var(--pf-line);
	border-radius: 4px;
	padding: 0;
	margin: 0;
	overflow: hidden;
	cursor: pointer;
	transition: transform .45s var(--pf-ease), box-shadow .45s var(--pf-ease), border-color .3s;
}
.pf-wrap .pf-item.pf-pre { opacity: 0; }
.pf-wrap .pf-item--text { grid-template-columns: 1fr; }
.pf-wrap .pf-item--text .pf-text { max-width: 80ch; }

.pf-wrap .pf-media {
	position: relative;
	min-height: 360px;
	overflow: hidden;
	background: #e7eaf0;
}
.pf-wrap .pf-media img.pf-cover {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	object-fit: cover;
	transition: transform 1.2s var(--pf-ease);
}

.pf-wrap .pf-count {
	position: absolute;
	left: 0;
	bottom: 0;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px 16px;
	background: #fff;
	color: var(--pf-ink);
	font-size: .82rem;
	font-weight: 600;
	line-height: 1;
}
.pf-wrap .pf-count svg { width: 16px; height: 16px; }

.pf-wrap .pf-body {
	display: flex;
	flex-direction: column;
	min-width: 0;
	padding: clamp(24px, 4vw, 56px);
}
.pf-wrap .pf-title {
	position: relative;
	margin: 0 0 .7em;
	padding: 0 0 .5em;
	color: var(--pf-title);
	font-size: clamp(1.6rem, 2.8vw, 2.4rem);
	font-weight: 700;
	line-height: 1.12;
	letter-spacing: -.02em;
	text-transform: none;
}
.pf-wrap .pf-title::after {
	content: "";
	position: absolute;
	left: 0;
	bottom: 0;
	width: 44px;
	height: 4px;
	background: var(--pf-accent);
	transition: width .6s var(--pf-ease);
}
.pf-wrap .pf-text {
	max-width: 52ch;
	margin: 0 0 2em;
	color: var(--pf-muted);
	font-size: 1.02rem;
	line-height: 1.7;
}

.pf-wrap .pf-btn {
	position: relative;
	isolation: isolate;
	align-self: flex-end;
	margin-top: auto;
	display: inline-flex;
	align-items: center;
	gap: 12px;
	padding: 14px 18px 14px 24px;
	border: 0;
	border-radius: 2px;
	background: var(--pf-accent);
	color: #fff;
	font: inherit;
	font-size: .95rem;
	font-weight: 600;
	line-height: 1;
	letter-spacing: .01em;
	text-transform: none;
	cursor: pointer;
	overflow: hidden;
	-webkit-appearance: none;
	appearance: none;
}
.pf-wrap .pf-btn::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background: var(--pf-ink);
	transform: translateX(-101%);
	transition: transform .5s var(--pf-ease);
}
.pf-wrap .pf-btn svg { width: 16px; height: 16px; transition: transform .5s var(--pf-ease); }
.pf-wrap .pf-btn:focus-visible { outline: 3px solid var(--pf-ink); outline-offset: 3px; }
.pf-wrap .pf-btn:focus-visible::before { transform: none; }

@media (hover: hover) {
	.pf-wrap .pf-item:hover {
		transform: translate(-4px, -4px);
		border-color: var(--pf-ink);
		box-shadow: 10px 10px 0 var(--pf-accent);
	}
	.pf-wrap .pf-item:hover .pf-cover { transform: scale(1.05); }
	.pf-wrap .pf-item:hover .pf-title::after { width: 110px; }
	.pf-wrap .pf-item:hover .pf-btn::before { transform: none; }
	.pf-wrap .pf-item:hover .pf-btn svg { transform: rotate(90deg); }
}

.pf-wrap .pf-item.is-in { animation: pf-fade .5s ease backwards; }
.pf-wrap .pf-item.is-in .pf-media { animation: pf-wipe 1.1s var(--pf-ease) backwards; }
.pf-wrap .pf-item.is-in .pf-cover { animation: pf-zoom 1.6s var(--pf-ease) backwards; }
.pf-wrap .pf-item.is-in .pf-body > * { animation: pf-in .9s var(--pf-ease) backwards; }
.pf-wrap .pf-item.is-in .pf-title { animation-delay: .35s; }
.pf-wrap .pf-item.is-in .pf-text  { animation-delay: .45s; }
.pf-wrap .pf-item.is-in .pf-btn   { animation-delay: .55s; }

@keyframes pf-fade { from { opacity: 0; } }
@keyframes pf-wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes pf-zoom { from { transform: scale(1.3); } }
@keyframes pf-in   { from { opacity: 0; transform: translateX(28px); } }
@keyframes pf-rise { from { opacity: 0; transform: translateY(14px); } }

.pf-first { container-type: inline-size; width: 100%; max-width: none; margin: 0; }
.pf-first .pf-first__grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: clamp(14px, 2.2cqi, 28px);
}
.pf-first .pf-tile {
	position: relative;
	display: flex;
	padding: 0;
	margin: 0;
	flex-direction: column;
	min-width: 0;
	background: #fff;
	border: 1px solid var(--pf-line);
	border-radius: 4px;
	overflow: hidden;
	cursor: pointer;
	transition: transform .45s var(--pf-ease), box-shadow .45s var(--pf-ease), border-color .3s;
}
.pf-first .pf-tile.pf-pre { opacity: 0; }
.pf-first .pf-tile::after {
	content: "";
	position: absolute;
	left: 0;
	bottom: 0;
	width: 0;
	height: 4px;
	background: var(--pf-accent);
	transition: width .6s var(--pf-ease);
}
.pf-first .pf-tile__media { position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: #e7eaf0; }
.pf-first .pf-tile__img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	object-fit: cover;
	transition: transform 1.2s var(--pf-ease);
}
.pf-first .pf-tile__cap { flex: 1 1 auto; display: flex; padding: 14px 16px 18px; }
.pf-first .pf-tile__btn {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	width: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: var(--pf-title);
	font: inherit;
	font-size: clamp(1rem, 1.6vw, 1.2rem);
	font-weight: 700;
	line-height: 1.25;
	letter-spacing: -.01em;
	text-align: left;
	text-transform: none;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}
.pf-first .pf-tile__btn:hover, .pf-first .pf-tile__btn:focus { background: none; color: var(--pf-title); }
.pf-first .pf-tile__btn:focus-visible { outline: 3px solid var(--pf-accent); outline-offset: 4px; }
.pf-first .pf-tile__title { display: block; min-width: 0; overflow-wrap: break-word; }
.pf-first .pf-tile__btn svg {
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
	margin-top: .15em;
	color: var(--pf-accent);
	transition: transform .5s var(--pf-ease);
}

/* Проект без снимка: плочка само със заглавие */
.pf-first .pf-tile--text .pf-tile__cap { align-items: center; min-height: 160px; padding: 20px; background: var(--pf-accent); }
.pf-first .pf-tile--text .pf-tile__btn { align-items: center; color: #fff; }
.pf-first .pf-tile--text .pf-tile__btn:hover, .pf-first .pf-tile--text .pf-tile__btn:focus { color: #fff; }
.pf-first .pf-tile--text .pf-tile__btn svg { color: #fff; }

@media (hover: hover) {
	.pf-first .pf-tile:hover {
		transform: translate(-4px, -4px);
		border-color: var(--pf-ink);
		box-shadow: 8px 8px 0 var(--pf-accent);
	}
	.pf-first .pf-tile:hover .pf-tile__img { transform: scale(1.06); }
	.pf-first .pf-tile:hover::after { width: 100%; }
	.pf-first .pf-tile:hover .pf-tile__btn svg { transform: rotate(90deg); }
}

/* Появяване (с лек каскаден ефект) */
.pf-first .pf-tile.is-in { animation: pf-fade .5s ease backwards; animation-delay: calc(var(--n, 0) * .09s); }
.pf-first .pf-tile.is-in .pf-tile__media { animation: pf-wipe 1s var(--pf-ease) backwards; animation-delay: calc(var(--n, 0) * .09s); }
.pf-first .pf-tile.is-in .pf-tile__img { animation: pf-zoom 1.5s var(--pf-ease) backwards; animation-delay: calc(var(--n, 0) * .09s); }
.pf-first .pf-tile.is-in .pf-tile__cap { animation: pf-rise .8s var(--pf-ease) backwards; animation-delay: calc(.25s + var(--n, 0) * .09s); }

/* Респонсив: 4 → 2 → 1 колони според ширината на мястото, където е сложен шорткодът */
@container (max-width: 899px) {
	.pf-first .pf-first__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container (max-width: 419px) {
	.pf-first .pf-first__grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Индикатор за зареждане ---------- */
.pf-dots { display: flex; justify-content: center; gap: 8px; padding: 22px 0; }
.pf-dots i {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--pf-accent);
	animation: pf-bounce 1s infinite ease-in-out;
}
.pf-dots i:nth-child(2) { animation-delay: .15s; }
.pf-dots i:nth-child(3) { animation-delay: .3s; }
.pf-wrap .pf-loader { opacity: 0; transition: opacity .25s; }
.pf-wrap.is-loading .pf-loader { opacity: 1; }
@keyframes pf-bounce { 0%, 80%, 100% { transform: scale(.45); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }

/* ---------- Мобилен изглед ---------- */
@media (max-width: 768px) {
	.pf-wrap .pf-item { grid-template-columns: 1fr; }
	.pf-wrap .pf-media { min-height: 0; aspect-ratio: 16 / 10; }
	.pf-wrap .pf-btn { margin-top: 0; }
}

/* ---------- Попъп на цял екран ---------- */
html.pf-lock, html.pf-lock body { overflow: hidden; }

.pf-modal {
	--x: 50%;
	--y: 50%;
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	grid-template-rows: auto minmax(0, 1fr);
	background: var(--pf-accent);
	color: #fff;
	visibility: hidden;
	clip-path: circle(0 at var(--x) var(--y));
	transition: clip-path .8s cubic-bezier(.7, 0, .2, 1), visibility 0s .8s;
}
.pf-modal.is-open {
	visibility: visible;
	clip-path: circle(150vmax at var(--x) var(--y));
	transition: clip-path .8s cubic-bezier(.7, 0, .2, 1), visibility 0s;
}

.pf-modal .pf-close {
	position: absolute;
	top: clamp(14px, 2.5vw, 28px);
	right: clamp(14px, 2.5vw, 28px);
	z-index: 5;
	display: grid;
	place-items: center;
	width: 52px;
	height: 52px;
	padding: 0;
	border: 2px solid #fff;
	border-radius: 50%;
	background: transparent;
	color: #fff;
	cursor: pointer;
	transition: transform .5s var(--pf-ease), background .25s, color .25s;
}
.pf-modal .pf-close svg { width: 22px; height: 22px; }
.pf-modal .pf-close:hover, .pf-modal .pf-close:focus-visible { background: #fff; color: var(--pf-accent); transform: rotate(90deg); }
.pf-modal .pf-close:focus-visible, .pf-modal .pf-nav:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

.pf-modal > * { min-width: 0; }

/* Горна част: текст */
.pf-modal .pf-modal__text {
	max-height: 44vh;
	overflow: auto;
	padding: clamp(72px, 8vw, 96px) clamp(20px, 6vw, 90px) 20px;
	scrollbar-width: thin;
	scrollbar-color: rgba(255, 255, 255, .5) transparent;
}
.pf-modal .pf-m-inner { max-width: 960px; }
.pf-modal .pf-m-title {
	margin: 0 0 .5em;
	color: #fff;
	font-size: clamp(1.9rem, 4.2vw, 3.4rem);
	font-weight: 800;
	line-height: 1.08;
	letter-spacing: -.025em;
	text-transform: none;
}
.pf-modal .pf-m-content { color: rgba(255, 255, 255, .92); font-size: 1.05rem; line-height: 1.75; }
.pf-modal .pf-m-content > :first-child { margin-top: 0; }
.pf-modal .pf-m-content > :last-child { margin-bottom: 0; }
.pf-modal .pf-m-content p { margin: 0 0 1em; }
.pf-modal .pf-m-content h1, .pf-modal .pf-m-content h2, .pf-modal .pf-m-content h3,
.pf-modal .pf-m-content h4, .pf-modal .pf-m-content h5, .pf-modal .pf-m-content h6 { color: #fff; }
.pf-modal .pf-m-content a { color: #fff; text-decoration: underline; }
.pf-modal .pf-m-content img { max-width: 100%; height: auto; }
.pf-modal .pf-m-err { margin: 0; font-size: 1.05rem; }
.pf-modal .pf-dots { justify-content: flex-start; }
.pf-modal .pf-dots i { background: #fff; }

/* Долна част: снимки хоризонтално */
.pf-modal .pf-modal__gallery { position: relative; min-height: 0; padding-bottom: 28px; }
.pf-modal .pf-track {
	display: flex;
	gap: clamp(12px, 1.6vw, 22px);
	height: 100%;
	padding: 0 clamp(20px, 6vw, 90px);
	overflow-x: auto;
	overflow-y: hidden;
	overscroll-behavior-x: contain;
	scroll-behavior: auto;
	scrollbar-width: none;
	cursor: grab;
}
.pf-modal .pf-track::-webkit-scrollbar { display: none; }
.pf-modal .pf-track.is-drag { cursor: grabbing; user-select: none; }
.pf-modal .pf-track img {
	flex: 0 0 auto;
	display: block;
	width: auto;
	height: 100%;
	max-width: none;
	margin: 0;
	border-radius: 2px;
	object-fit: cover;
	background: rgba(255, 255, 255, .12);
	-webkit-user-drag: none;
	user-select: none;
}

.pf-modal .pf-nav {
	position: absolute;
	top: calc(50% - 14px);
	z-index: 4;
	display: grid;
	place-items: center;
	width: 54px;
	height: 54px;
	padding: 0;
	margin-top: -27px;
	border: 0;
	border-radius: 50%;
	background: #fff;
	color: var(--pf-accent);
	cursor: pointer;
	transition: opacity .3s, transform .4s var(--pf-ease), background .25s, color .25s;
}
.pf-modal .pf-nav svg { width: 22px; height: 22px; }
.pf-modal .pf-nav:hover { background: var(--pf-ink); color: #fff; transform: scale(1.08); }
.pf-modal .pf-nav--prev { left: 18px; }
.pf-modal .pf-nav--next { right: 18px; }
.pf-modal .pf-nav[disabled] { opacity: 0; pointer-events: none; }
.pf-modal.no-scroll .pf-nav, .pf-modal.no-scroll .pf-progress { display: none; }

.pf-modal .pf-progress {
	position: absolute;
	left: clamp(20px, 6vw, 90px);
	right: clamp(20px, 6vw, 90px);
	bottom: 8px;
	height: 3px;
	background: rgba(255, 255, 255, .28);
	overflow: hidden;
}
.pf-modal .pf-progress span { display: block; width: 100%; height: 100%; background: #fff; transform-origin: left; transform: scaleX(0); }

/* Анимации в попъпа (реакция на клик) */
.pf-modal.is-open .pf-m-title   { animation: pf-up .8s var(--pf-ease) .4s backwards; }
.pf-modal.is-open .pf-m-content { animation: pf-up .8s var(--pf-ease) .52s backwards; }
.pf-modal.is-open .pf-track img { animation: pf-slide .9s var(--pf-ease) backwards; animation-delay: calc(.55s + min(calc(var(--i, 0) * .09s), 1s)); }
@keyframes pf-up    { from { opacity: 0; transform: translateY(26px); } }
@keyframes pf-slide { from { opacity: 0; transform: translateX(90px); } }

/* Проект без снимки: попъпът показва само текста */
.pf-modal.no-images { grid-template-rows: minmax(0, 1fr); }
.pf-modal.no-images .pf-modal__text { max-height: none; }
.pf-modal.no-images .pf-modal__gallery { display: none; }

@media (hover: none) { .pf-modal .pf-nav { display: none; } }
@media (max-width: 768px) { .pf-modal .pf-modal__text { max-height: 46vh; } }

/* ---------- Намалено движение ---------- */
@media (prefers-reduced-motion: reduce) {
	.pf-wrap *, .pf-first *, .pf-modal * { animation: none !important; transition-duration: .01ms !important; }
	.pf-modal { transition: none !important; }
}
