/**
 * Photoshop-style History panel for 404 pages.
 */

/* Immersive canvas: gray field, transparent header, no footer — no page scroll */
body.error404-history-page {
	height: 100dvh;
	max-height: 100dvh;
	margin: 0;
	overflow: hidden;
	overflow-y: hidden !important;
	background-color: #535353;
}

body.error404-history-page .nk-main {
	height: 100%;
	min-height: 0;
	margin: 0;
	padding: 0;
	overflow: hidden;
	background-color: #535353;
}

body.admin-bar.error404-history-page {
	height: calc(100dvh - 32px);
	max-height: calc(100dvh - 32px);
}

@media screen and (max-width: 782px) {
	body.admin-bar.error404-history-page {
		height: calc(100dvh - 46px);
		max-height: calc(100dvh - 46px);
	}
}

body.error404-history-page .nk-header,
body.error404-history-page .nk-header.nk-header-opaque {
	position: fixed;
	top: 0;
	right: 0;
	left: 0;
	background: transparent;
	z-index: 1000;
}

body.admin-bar.error404-history-page .nk-header,
body.admin-bar.error404-history-page .nk-header.nk-header-opaque {
	top: 32px;
}

@media screen and (max-width: 782px) {
	body.admin-bar.error404-history-page .nk-header,
	body.admin-bar.error404-history-page .nk-header.nk-header-opaque {
		top: 46px;
	}
}

/* Top bar only — do not make fullscreen menu (#nk-full) transparent */
body.error404-history-page .nk-navbar-top {
	background-color: transparent !important;
}

body.error404-history-page .nk-navbar-full {
	background-color: #252525 !important;
}

body.error404-history-page .nk-nav > li > a {
	color: #bfbfbf;
}

body.error404-history-page .nk-nav > li > a:hover,
body.error404-history-page .nk-nav > li.active > a,
body.error404-history-page .nk-nav-icons a,
body.error404-history-page .nk-icon-burger {
	color: #ffffff;
}

body.error404-history-page .nk-nav-logo .nk-nav-logo-onscroll {
	display: block;
}

body.error404-history-page .nk-nav-logo .nk-nav-logo-onscroll + img {
	display: none;
}

body.error404-history-page .nk-footer {
	display: none !important;
}

.error404-history {
	height: 100%;
	margin: 0;
	padding: 0;
	overflow: hidden;
}

.error404-history__backdrop {
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	height: 100dvh;
	padding: 0;
	background-color: #535353;
	box-sizing: border-box;
	overflow: hidden;
	z-index: 1;
}

.error404-history__backdrop.is-drop-target {
	background-color: #4a4a4a;
}

.error404-history__tagline {
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: 3;
	max-width: min(90vw, 28rem);
	margin: 0;
	padding: 0 1.5rem;
	font-family: "Montserrat", sans-serif;
	font-size: clamp(1.35rem, 4vw, 2.25rem);
	font-weight: 400;
	line-height: 1.35;
	letter-spacing: 0.02em;
	text-align: center;
	color: rgba(255, 255, 255, 0.42);
	transform: translate(-50%, -50%);
	pointer-events: none;
	user-select: none;
}

@media screen and (max-width: 640px) {
	.error404-history__tagline {
		top: 38%;
		font-size: 1.15rem;
		opacity: 0.85;
	}
}

/* Placed image layers (client-side only, never uploaded) */
.error404-history__layers {
	position: absolute;
	inset: 0;
	z-index: 2;
	pointer-events: none;
	overflow: hidden;
}

.error404-history__layer {
	position: absolute;
	pointer-events: auto;
	cursor: grab;
	touch-action: none;
	user-select: none;
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
	border: 1px solid #6a6a6a;
	background-color: #2a2a2a;
	z-index: 1;
}

.error404-history__layer.is-dragging {
	cursor: grabbing;
	z-index: 100;
}

.error404-history__layer img {
	display: block;
	max-width: min(480px, 55vw);
	max-height: min(480px, 55vh);
	width: auto;
	height: auto;
	pointer-events: none;
	-webkit-user-drag: none;
	user-drag: none;
}

.error404-history__drop-hint {
	position: absolute;
	left: 50%;
	top: 50%;
	z-index: 3;
	margin: 0;
	padding: 10px 16px;
	font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
	font-size: 13px;
	color: #e8e8e8;
	pointer-events: none;
	background-color: rgba(30, 30, 30, 0.85);
	border: 1px dashed #6a9fd4;
	transform: translate(-50%, -50%);
}

body.admin-bar.error404-history-page .error404-history__backdrop {
	top: 32px;
	height: calc(100% - 32px);
	height: calc(100dvh - 32px);
}

@media screen and (max-width: 782px) {
	body.admin-bar.error404-history-page .error404-history__backdrop {
		top: 46px;
		height: calc(100% - 46px);
		height: calc(100dvh - 46px);
	}
}

/* Panel shell — portrait: taller than wide (~1.45:1); --hs scales all panel dimensions */
.error404-history__panel {
	--hs: 1.2;
	width: calc(168px * var(--hs));
	max-width: calc(100vw - 32px);
	font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
	font-size: calc(10px * var(--hs));
	line-height: 1.2;
	color: #b4b4b4;
	background-color: #383838;
	border: 1px solid #1e1e1e;
	box-shadow:
		0 0 0 1px #4a4a4a inset,
		0 calc(4px * var(--hs)) calc(16px * var(--hs)) rgba(0, 0, 0, 0.45);
	z-index: 10;
	touch-action: none;
}

.error404-history__panel--positioned {
	position: fixed;
	margin: 0;
}

.error404-history__panel.is-dragging {
	z-index: 1001;
}

/* Title bar + History tab */
.error404-history__chrome {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	min-height: calc(21px * var(--hs));
	padding: 0 calc(4px * var(--hs)) 0 0;
	background-color: #333333;
	border-bottom: 1px solid #1e1e1e;
	cursor: grab;
	touch-action: none;
	user-select: none;
}

.error404-history__chrome:active,
.error404-history__panel.is-dragging .error404-history__chrome {
	cursor: grabbing;
}

.error404-history__tab {
	display: inline-block;
	padding: calc(3px * var(--hs)) calc(8px * var(--hs)) calc(4px * var(--hs));
	font-size: calc(10px * var(--hs));
	font-weight: 400;
	color: #e8e8e8;
	background-color: #464646;
	border: 1px solid #1e1e1e;
	border-bottom: none;
	margin-bottom: -1px;
}

.error404-history__window-actions {
	display: flex;
	align-items: center;
	gap: calc(6px * var(--hs));
	padding: 0 calc(4px * var(--hs)) calc(3px * var(--hs)) 0;
	color: #a8a8a8;
}

.error404-history__window-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: calc(14px * var(--hs));
	height: calc(14px * var(--hs));
	line-height: 0;
}

.error404-history__window-btn svg {
	width: calc(8px * var(--hs));
	height: calc(8px * var(--hs));
}

/* History list */
.error404-history__list {
	margin: 0;
	padding: 0;
	list-style: none;
	background-color: #383838;
}

.error404-history__item {
	position: relative;
	display: flex;
	align-items: stretch;
	min-height: calc(22px * var(--hs));
	padding: 0;
	border-bottom: 1px solid #2e2e2e;
	color: #b4b4b4;
}

.error404-history__link {
	display: flex;
	flex: 1;
	align-items: center;
	gap: calc(2px * var(--hs));
	min-height: calc(22px * var(--hs));
	padding: calc(2px * var(--hs)) calc(3px * var(--hs)) calc(2px * var(--hs)) calc(2px * var(--hs));
	color: inherit;
	text-decoration: none;
}

.error404-history__link:hover,
.error404-history__link:focus-visible {
	color: #ffffff;
	background-color: #454545;
	outline: none;
}

.error404-history__item:last-child {
	border-bottom: none;
}

.error404-history__item--document {
	background-color: #404040;
	color: #d8d8d8;
}

.error404-history__item--active {
	display: flex;
	align-items: center;
	gap: calc(2px * var(--hs));
	padding: calc(2px * var(--hs)) calc(3px * var(--hs)) calc(2px * var(--hs)) calc(2px * var(--hs));
	background-color: #0964d1;
	color: #ffffff;
	font-weight: 600;
	font-size: calc(8.5px * var(--hs));
	letter-spacing: 0.02em;
	border-bottom-color: #0964d1;
}

.error404-history__item--active .error404-history__doc-icon,
.error404-history__item--active .error404-history__check--filled {
	color: #ffffff;
	border-color: rgba(255, 255, 255, 0.5);
}

/* Checkbox column */
.error404-history__check {
	flex-shrink: 0;
	width: calc(12px * var(--hs));
	height: calc(12px * var(--hs));
	border: 1px solid #555555;
	background-color: #2e2e2e;
	box-sizing: border-box;
}

.error404-history__check--brush {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	color: #c8c8c8;
	background-color: #3a3a3a;
	border-color: #4a4a4a;
}

.error404-history__check--brush svg {
	display: block;
	width: calc(12px * var(--hs));
	height: calc(12px * var(--hs));
}

.error404-history__check--filled {
	background-color: #074a9e;
	border-color: #3d8ee0;
}

.error404-history__item--document .error404-history__check {
	border-color: #5a5a5a;
	background-color: #353535;
}

/* Document icon */
.error404-history__doc-icon {
	display: inline-flex;
	flex-shrink: 0;
	align-items: center;
	justify-content: center;
	width: calc(12px * var(--hs));
	height: calc(12px * var(--hs));
	color: #9a9a9a;
}

.error404-history__doc-icon svg {
	width: calc(12px * var(--hs));
	height: calc(12px * var(--hs));
}

.error404-history__item--active .error404-history__doc-icon {
	color: #ffffff;
}

/* Thumbnail (StudioMo.tif row) */
.error404-history__thumb {
	flex-shrink: 0;
	width: calc(12px * var(--hs));
	height: calc(12px * var(--hs));
	background-color: #ffffff;
	border: 1px solid #666666;
	box-sizing: border-box;
}

.error404-history__label {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	padding-right: calc(2px * var(--hs));
}

/* Footer toolbar */
.error404-history__footer {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: flex-end;
	min-height: calc(22px * var(--hs));
	padding: calc(2px * var(--hs)) calc(6px * var(--hs));
	background-color: #333333;
	border-top: 1px solid #1e1e1e;
}

.error404-history__resize {
	position: absolute;
	left: 50%;
	bottom: calc(2px * var(--hs));
	width: calc(10px * var(--hs));
	height: calc(4px * var(--hs));
	margin-left: calc(-5px * var(--hs));
	background:
		repeating-linear-gradient(
			90deg,
			#6a6a6a 0,
			#6a6a6a 1px,
			transparent 1px,
			transparent 2px
		);
	opacity: 0.7;
}

.error404-history__footer-actions {
	display: flex;
	align-items: center;
	gap: calc(6px * var(--hs));
}

.error404-history__footer-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: calc(16px * var(--hs));
	height: calc(16px * var(--hs));
	padding: 0;
	color: #b8b8b8;
	font: inherit;
	line-height: 0;
	background: none;
	border: none;
	text-decoration: none;
	cursor: pointer;
}

.error404-history__footer-btn:disabled {
	opacity: 0.35;
	cursor: not-allowed;
}

.error404-history__footer-btn svg {
	width: calc(14px * var(--hs));
	height: calc(14px * var(--hs));
}

.error404-history__footer-btn:hover,
.error404-history__footer-btn:focus {
	color: #ffffff;
	outline: none;
}

.error404-history__footer-btn:focus-visible {
	outline: 1px solid #ffffff;
	outline-offset: 2px;
}

/* History panel tooltip positioning (visual base in adobe-tooltip.css) */
.error404-history__panel [data-tooltip]::after {
	left: calc(100% + 8px * var(--hs));
	top: 50%;
	max-width: calc(200px * var(--hs));
	padding: calc(4px * var(--hs)) calc(7px * var(--hs));
	font-size: calc(10px * var(--hs));
	transform: translateY(-50%);
}

.error404-history__item[data-tooltip]:hover {
	z-index: 5;
}

.error404-history__window-btn[data-tooltip]::after {
	left: auto;
	right: 0;
	top: calc(100% + 6px * var(--hs));
	transform: none;
}

.error404-history__footer-btn[data-tooltip]::after,
.error404-history__resize[data-tooltip]::after {
	left: auto;
	right: 0;
	top: auto;
	bottom: calc(100% + 6px * var(--hs));
	max-width: calc(180px * var(--hs));
	white-space: normal;
	transform: none;
}

.error404-history__panel.is-dragging [data-tooltip]::after {
	opacity: 0 !important;
	visibility: hidden !important;
}
