/* ==========================================================================
   Сторінка проєкту портфоліо (single-portfolio.php)
   Підключається тільки на is_singular('portfolio'), див. inc/portfolio-case.php
   ========================================================================== */

.esf-case {
	--case-green: #00CE7D;
	--case-green-dark: #00b56e;
	--case-ink: #121212;
	--case-text: #4a4f57;
	--case-muted: #8a9099;
	--case-line: #e6e8eb;
	--case-dark: #17191d;
	position: relative;
	padding-bottom: 40px;
}
.esf-case > *:not(.okten-grid) { position: relative; z-index: 1; }
/* esfirum-speed загортає картинки в <picture> для WebP - для розкладки він не потрібен */
.esf-case picture { display: contents; }

/* Ширина контенту як у CTA "Є ідеї?": не заходить під бічні панелі */
.esf-case .esf-case-wrap {
	box-sizing: border-box;
	width: 100%;
	padding-left: max(100px, calc(50% - 612px));
	padding-right: max(100px, calc(50% - 612px));
}

/* легасі esfirum-style.css: h2 { font-size/weight: inherit !important } */
.esf-case .esf-case-h2 {
	font-size: clamp(24px, 2.4vw, 34px) !important;
	font-weight: 800 !important;
	line-height: 1.15;
	color: var(--case-ink);
	margin: 0 0 22px;
	text-transform: none;
}

/* --- Перший екран --- */
.esf-case-hero { padding: 150px 0 70px; }
.esf-case-hero-grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
	gap: 56px;
	align-items: center;
}
.esf-case-hero-grid.is-solo { grid-template-columns: minmax(0, 760px); }

.esf-case-crumbs {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: .14em;
	text-transform: uppercase;
	margin-bottom: 22px;
}
.esf-case-crumbs:before {
	content: '';
	width: 34px;
	height: 2px;
	background: var(--case-green);
}
.esf-case-crumbs a { color: var(--case-muted) !important; text-decoration: none !important; transition: color .2s ease; }
.esf-case-crumbs a:hover { color: var(--case-green) !important; }
.esf-case-crumbs span { color: #c3c7cd; }

.esf-case .esf-case-title {
	font-size: clamp(34px, 4.2vw, 58px);
	font-weight: 800;
	line-height: 1.04;
	letter-spacing: -.01em;
	color: var(--case-ink);
	margin: 0 0 18px;
	padding: 0 !important; /* легасі h1 має відступ зліва */
	text-transform: none;
}
.esf-case-lead {
	font-size: 18px;
	line-height: 1.6;
	color: var(--case-text);
	max-width: 540px;
	margin: 0 0 30px;
}

.esf-case-facts {
	display: flex;
	flex-wrap: wrap;
	gap: 0;
	margin: 0 0 26px;
	border-top: 1px solid var(--case-line);
	border-bottom: 1px solid var(--case-line);
}
.esf-case-facts > div { flex: 0 1 auto; padding: 16px 28px 16px 0; }
.esf-case-facts > div + div { padding-left: 28px; border-left: 1px solid var(--case-line); }
.esf-case-facts dt {
	font-size: 11px;
	font-weight: 600;
	letter-spacing: .12em;
	text-transform: uppercase;
	color: var(--case-muted);
	margin: 0 0 6px;
}
.esf-case-facts dd { font-size: 16px; font-weight: 700; color: var(--case-ink); margin: 0; }
.esf-case-facts dd a { color: var(--case-ink) !important; text-decoration: none !important; border-bottom: 2px solid var(--case-green); overflow-wrap: anywhere; }
.esf-case-facts dd a:hover { color: var(--case-green) !important; }

.esf-case-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 32px; }
.esf-case-tags-label {
	font-size: 11px;
	font-weight: 600;
	letter-spacing: .12em;
	text-transform: uppercase;
	color: var(--case-muted);
	margin-right: 4px;
}
.esf-case-tags a {
	display: inline-block;
	padding: 7px 15px;
	border: 1px solid var(--case-line);
	border-radius: 999px;
	font-size: 14px;
	font-weight: 500;
	color: var(--case-ink) !important;
	text-decoration: none !important;
	transition: border-color .2s ease, color .2s ease;
}
.esf-case-tags a:hover { border-color: var(--case-green); color: var(--case-green) !important; }

.esf-case-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.esf-case-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 52px;
	padding: 0 28px;
	border-radius: 12px;
	font-size: 15px;
	font-weight: 600;
	text-decoration: none !important;
	transition: background .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
}
.esf-case-btn:active { transform: translateY(1px); }
.esf-case-btn-primary { background: var(--case-green); color: #fff !important; }
.esf-case-btn-primary:hover { background: var(--case-green-dark); }
.esf-case-btn-ghost { border: 1px solid var(--case-ink); color: var(--case-ink) !important; }
.esf-case-btn-ghost:after { content: '\2197'; margin-left: 8px; font-size: 15px; }
.esf-case-btn-ghost:hover { border-color: var(--case-green); color: var(--case-green) !important; }

/* --- Макети пристроїв --- */
.esf-case-devices { position: relative; padding: 0 0 34px; }
.esf-case-devices.has-phone { padding-right: 9%; }
.esf-device-laptop .esf-device-screen {
	background: var(--case-dark);
	border-radius: 14px 14px 0 0;
	padding: 12px 12px 14px;
	box-shadow: 0 30px 70px rgba(18, 18, 18, .18);
}
.esf-device-laptop .esf-device-screen img {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 10;
	height: auto;
	object-fit: cover;
	object-position: top center;
	border-radius: 3px;
}
/* Без case_desktop береться превью зі списку (часто ~2.1:1) - показуємо цілим, без обрізки боків */
.esf-device-laptop.is-natural .esf-device-screen img { aspect-ratio: auto; object-fit: fill; }
.esf-device-base {
	height: 16px;
	margin: 0 -7%;
	background: linear-gradient(#e9ebee, #c9cdd3);
	border-radius: 0 0 14px 14px;
	position: relative;
}
.esf-device-base:before {
	content: '';
	position: absolute;
	top: 0;
	left: 50%;
	width: 16%;
	height: 6px;
	transform: translateX(-50%);
	background: #b7bcc3;
	border-radius: 0 0 8px 8px;
}
.esf-device-phone {
	position: absolute;
	right: 0;
	bottom: 0;
	width: 26%;
	min-width: 120px;
	border: 7px solid var(--case-dark);
	border-radius: 26px;
	background: var(--case-dark);
	overflow: hidden;
	box-shadow: 0 24px 50px rgba(18, 18, 18, .28);
}
.esf-device-phone img {
	display: block;
	width: 100%;
	aspect-ratio: 375 / 760;
	height: auto;
	object-fit: cover;
	object-position: top center;
	border-radius: 19px;
}

/* --- Головне фото --- */
.esf-case-cover {
	margin: 0 0 80px;
	padding: 0 max(100px, calc(50% - 720px));
	box-sizing: border-box;
}
.esf-case-cover img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 21 / 9;
	object-fit: cover;
	border-radius: 18px;
}

/* --- Задача / що зроблено / результат --- */
.esf-case-about {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 40px 64px;
	margin: 0 0 90px;
}
.esf-case-about .esf-case-block:only-child { grid-column: 1 / -1; max-width: 820px; }
.esf-case-text, .esf-case-text p { font-size: 17px; line-height: 1.7; color: var(--case-text); }
.esf-case-done { list-style: none; margin: 0; padding: 0; columns: 1; }
.esf-case-about .esf-case-block:only-child .esf-case-done { columns: 2; column-gap: 48px; }
.esf-case-done li {
	position: relative;
	break-inside: avoid;
	padding: 0 0 14px 36px;
	font-size: 17px;
	line-height: 1.55;
	color: var(--case-ink);
}
.esf-case-done li:before {
	content: '';
	position: absolute;
	left: 0;
	top: 2px;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: rgba(0, 206, 125, .12) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%2300CE7D' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' d='M6 12.5l4 4 8-9'/%3E%3C/svg%3E") center / 13px no-repeat;
}
.esf-case-result {
	grid-column: 1 / -1;
	background: #f2fbf7;
	border-left: 4px solid var(--case-green);
	border-radius: 12px;
	padding: 28px 32px;
}

/* --- Галерея --- */
.esf-case-gallery-wrap { margin: 0 0 90px; }
.esf-case-gallery {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	grid-auto-rows: clamp(150px, 15vw, 240px);
	gap: 14px;
}
.esf-case-shot {
	display: block;
	position: relative;
	overflow: hidden;
	border-radius: 12px;
	background: #f1f2f4;
	cursor: zoom-in;
}
.esf-case-shot:first-child { grid-column: span 2; grid-row: span 2; }
/* Останнє фото добирає ряд, щоб не лишалось порожньої клітинки */
.esf-case-shot.is-span-2 { grid-column: span 2; }
.esf-case-shot.is-span-3 { grid-column: 1 / -1; }
.esf-case-shot img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform .6s ease;
}
.esf-case-shot:hover img { transform: scale(1.04); }
.esf-case-shot:focus-visible { outline: 3px solid var(--case-green); outline-offset: 3px; }

/* --- Відео-відгук --- */
.esf-case-review {
	display: grid;
	grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
	gap: 56px;
	align-items: center;
	margin: 0 0 90px;
}
.esf-case-review-text p { font-size: 17px; line-height: 1.7; color: var(--case-text); }
.esf-yt {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 16 / 9;
	padding: 0;
	border: 0;
	border-radius: 16px;
	overflow: hidden;
	background: #000;
	cursor: pointer;
}
.esf-yt img { width: 100%; height: 100%; object-fit: cover; opacity: .88; transition: opacity .3s ease; }
.esf-yt:hover img { opacity: 1; }
.esf-yt-play {
	position: absolute;
	left: 50%;
	top: 50%;
	width: 78px;
	height: 78px;
	transform: translate(-50%, -50%);
	border-radius: 50%;
	background: var(--case-green);
	box-shadow: 0 10px 30px rgba(0, 206, 125, .45);
	transition: transform .3s ease;
}
.esf-yt-play:after {
	content: '';
	position: absolute;
	left: 31px;
	top: 25px;
	border-style: solid;
	border-width: 14px 0 14px 22px;
	border-color: transparent transparent transparent #fff;
}
.esf-yt:hover .esf-yt-play { transform: translate(-50%, -50%) scale(1.08); }
.esf-yt iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* --- Стара презентація --- */
.esf-case-presentation { margin: 0 0 90px; }
.esf-case-presentation summary {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	list-style: none;
	padding: 14px 24px;
	border: 1px solid var(--case-line);
	border-radius: 12px;
	font-size: 15px;
	font-weight: 600;
	color: var(--case-ink);
	transition: border-color .2s ease, color .2s ease;
}
.esf-case-presentation summary::-webkit-details-marker { display: none; }
.esf-case-presentation summary:after { content: '+'; font-size: 20px; line-height: 1; color: var(--case-green); }
.esf-case-presentation[open] summary:after { content: '\2212'; }
.esf-case-presentation summary:hover { border-color: var(--case-green); color: var(--case-green); }
.esf-case-presentation .ph-cont, .esf-case-presentation-open .ph-cont { margin-top: 24px; }
.esf-case-presentation-open { margin: 0 0 90px; }
.esf-case .ph-cont img { display: block; width: 100%; height: auto; margin: 0 auto; }

/* --- Схожі проєкти --- */
.esf-case-related { margin: 0 0 60px; }
.esf-case-related-head { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; }
.esf-case-related-head a {
	font-size: 14px;
	font-weight: 600;
	color: var(--case-ink) !important;
	text-decoration: none !important;
	border-bottom: 2px solid var(--case-green);
	white-space: nowrap;
}
.esf-case-related-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; }
.esf-case-card { display: block; text-decoration: none !important; color: inherit !important; }
.esf-case-card-img {
	display: block;
	overflow: hidden;
	border-radius: 12px;
	aspect-ratio: 4 / 3;
	background: #f1f2f4;
	margin-bottom: 16px;
}
.esf-case-card-img img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .6s ease; }
.esf-case-card:hover .esf-case-card-img img { transform: scale(1.04); }
.esf-case-card-title { display: block; font-size: 19px; font-weight: 700; color: var(--case-ink); margin-bottom: 6px; transition: color .2s ease; }
.esf-case-card:hover .esf-case-card-title { color: var(--case-green); }
.esf-case-card-desc { display: block; font-size: 14px; line-height: 1.5; color: var(--case-muted); }

/* --- Попередній / наступний --- */
.esf-case-nav {
	display: flex;
	justify-content: space-between;
	gap: 24px;
	padding-top: 28px !important;
	border-top: 1px solid var(--case-line);
}
.esf-case-nav a {
	display: flex;
	flex-direction: column;
	gap: 4px;
	max-width: 45%;
	font-size: 17px;
	font-weight: 700;
	color: var(--case-ink) !important;
	text-decoration: none !important;
	transition: color .2s ease;
}
.esf-case-nav a span { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--case-muted); }
.esf-case-nav a:hover { color: var(--case-green) !important; }
.esf-case-nav-next { margin-left: auto; text-align: right; }

/* --- Перегляд фото на весь екран --- */
.esf-lb {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(12, 13, 15, .94);
	opacity: 0;
	transition: opacity .25s ease;
}
.esf-lb.is-open { opacity: 1; }
.esf-lb img { max-width: 92vw; max-height: 86vh; border-radius: 8px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.esf-lb button {
	position: absolute;
	width: 52px;
	height: 52px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .1);
	color: #fff;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	transition: background .2s ease;
}
.esf-lb button:hover { background: var(--case-green, #00CE7D); }
.esf-lb-close { top: 22px; right: 22px; }
.esf-lb-prev { left: 22px; top: 50%; transform: translateY(-50%); }
.esf-lb-next { right: 22px; top: 50%; transform: translateY(-50%); }
.esf-lb-count { position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%); color: rgba(255, 255, 255, .7); font-size: 14px; }

/* --- Адаптив --- */
@media (max-width: 1199px) {
	.esf-case-hero-grid { grid-template-columns: minmax(0, 1fr); gap: 48px; }
	.esf-case-intro { max-width: 760px; }
	.esf-case-devices { max-width: 680px; }
}
@media (max-width: 991px) {
	.esf-case-hero { padding: 120px 0 50px; }
	.esf-case-review { grid-template-columns: minmax(0, 1fr); gap: 24px; }
	.esf-case-related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
	.esf-case .esf-case-wrap,
	.esf-case-cover { padding-left: 20px; padding-right: 20px; }
	.esf-case-hero { padding: 100px 0 40px; }
	.esf-case-lead { font-size: 16px; }
	.esf-case-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); }
	.esf-case-facts > div { padding-right: 18px; }
	.esf-case-facts > div + div { padding-left: 18px; }
	.esf-case-facts > div:nth-child(3) { grid-column: 1 / -1; border-left: 0; padding-left: 0; border-top: 1px solid var(--case-line); }
	.esf-case-actions .esf-case-btn { flex: 1 1 100%; }
	.esf-case-cover { margin-bottom: 50px; }
	.esf-case-cover img { aspect-ratio: 4 / 3; border-radius: 12px; }
	.esf-case-about { grid-template-columns: minmax(0, 1fr); gap: 36px; margin-bottom: 56px; }
	.esf-case-about .esf-case-block:only-child .esf-case-done { columns: 1; }
	.esf-case-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: clamp(120px, 32vw, 200px); gap: 10px; }
	.esf-case-shot:first-child { grid-column: 1 / -1; grid-row: span 2; }
	.esf-case-shot.is-span-2, .esf-case-shot.is-span-3 { grid-column: auto; }
	.esf-case-shot.is-tail-full { grid-column: 1 / -1; }
	.esf-case-gallery-wrap, .esf-case-review, .esf-case-presentation, .esf-case-presentation-open { margin-bottom: 56px; }
	.esf-case-related-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; }
	.esf-case-nav a { max-width: 48%; font-size: 15px; }
	.esf-lb-prev, .esf-lb-next { top: auto; bottom: 16px; transform: none; }
	.esf-lb-prev { left: 16px; }
	.esf-lb-next { right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
	.esf-case-shot img, .esf-case-card-img img, .esf-yt-play, .esf-lb { transition: none; }
}

/* Легасі .portfolio-image (картки портфоліо) має фіксовану ширину */
html body.esf-page .esf-case-card-img img.portfolio-image,
html body.esf-page .esf-case-card-img img {
	position: static !important;
	width: 100% !important;
	height: 100% !important;
	max-width: 100% !important;
	margin: 0 !important;
	object-fit: cover;
	object-position: top center;
}
