/* Просмотр сертификата — переписан с нуля на нативном <dialog> (правка по ревью).
   Диалог живёт в верхнем слое браузера, поэтому не нужны гонки z-index с панелью админки. */

/* плитка сертификата — кнопка */
.page-certificates .about-cert__zoom {
	display: block;
	width: 100%;
	padding: 0;
	border: 0;
	background: none;
	cursor: zoom-in;
	font: inherit;
	color: inherit;
	text-align: left;
}
.page-certificates .about-cert__zoom img { transition: transform .35s ease; }
.page-certificates .about-cert__zoom:hover img { transform: scale(1.03); }
.page-certificates .about-cert__zoom:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }

/* ---------- окно просмотра ---------- */
dialog.sf-lb {
	width: 100vw;
	max-width: 100vw;
	height: 100vh;
	max-height: 100vh;
	margin: 0;
	padding: 56px 24px 28px;
	border: 0;
	background: rgba(20, 26, 19, .95);
	color: #fcfcfc;
	overflow: hidden;
}
dialog.sf-lb::backdrop { background: rgba(20, 26, 19, .95); }

/* Прокрутка фона блокируется, пока окно открыто, и возвращается сама при закрытии
   любым способом. Раньше этим управлял JS по событию close — оно не всегда доходило,
   и страница оставалась заблокированной (правка по ревью). */
html:has(dialog.sf-lb[open]) { overflow: hidden; }
dialog.sf-lb[open] {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
}

/* область картинки занимает всё свободное место: клик по ней — это клик мимо, он закрывает */
.sf-lb__stage {
	position: relative;
	flex: 1;
	width: 100%;
	min-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	touch-action: none;
	cursor: zoom-out;
}
.sf-lb__img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	background: #fff;
	border-radius: 2px;
	cursor: zoom-in;
	transform-origin: center center;
	transition: transform .2s ease;
	user-select: none;
	-webkit-user-drag: none;
}
.sf-lb__img.is-zoomed { cursor: grab; transition: none; }
.sf-lb__img.is-zoomed:active { cursor: grabbing; }
.sf-lb__img:not(.is-ready) { visibility: hidden; }

/* индикатор, пока файл грузится */
.sf-lb__stage.is-loading::after {
	content: '';
	position: absolute;
	width: 34px;
	height: 34px;
	border: 2px solid rgba(252, 252, 252, .25);
	border-top-color: #fcfcfc;
	border-radius: 50%;
	animation: sf-lb-spin .7s linear infinite;
}
@keyframes sf-lb-spin { to { transform: rotate(360deg) } }

.sf-lb__cap {
	margin: 0;
	font-size: 15px;
	line-height: 1.4;
	text-align: center;
	color: #fcfcfc;
	max-width: 640px;
}

.sf-lb__close {
	position: fixed;
	top: 16px;
	right: 20px;
	width: 48px;
	height: 48px;
	border: 0;
	border-radius: 50%;
	background: rgba(252, 252, 252, .12);
	color: #fcfcfc;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
	transition: background .2s;
}
.sf-lb__close:hover { background: var(--green); }
.sf-lb__close:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* диалог и так поверх панели админки, но кнопку опускаем, чтобы не липла к её краю */
body.admin-bar dialog.sf-lb { padding-top: 84px; }
body.admin-bar .sf-lb__close { top: 44px; }

@media (max-width: 782px) {
	body.admin-bar dialog.sf-lb { padding-top: 92px; }
	body.admin-bar .sf-lb__close { top: 52px; }
}
@media (max-width: 767px) {
	dialog.sf-lb { padding: 52px 12px 20px; }
	.sf-lb__close { top: 10px; right: 12px; width: 44px; height: 44px; }
	.sf-lb__cap { font-size: 14px; }
}
