/* Sơ đồ SVG và ảnh trong bài viết, tài liệu: nền thẻ trắng cho sơ đồ ở cả hai chế độ sáng/tối, nút phóng to,
 * khung zoom có nút xoay ngang/dọc (diagram-viewer.js, inc/media-zoom.php). */

/* Sơ đồ vẽ chữ tối trên nền trong suốt: luôn đặt trên thẻ trắng để không chìm vào nền tối. */
.fox40-docs .betterdocs-entry-content figure svg[viewBox],
.wp-block-post-content figure svg[viewBox] {
	background-color: #ffffff;
	border-radius: var(--f-radius);
}

:root[data-theme="dark"] .fox40-docs .betterdocs-entry-content figure svg[viewBox],
:root[data-theme="dark"] .wp-block-post-content figure svg[viewBox] {
	box-shadow: 0 0 0 1px var(--f-border);
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .fox40-docs .betterdocs-entry-content figure svg[viewBox],
	:root:not([data-theme="light"]) .wp-block-post-content figure svg[viewBox] {
		box-shadow: 0 0 0 1px var(--f-border);
	}
}

/* Chú thích sơ đồ có màu cố định trong bài (#64748B) quá mờ trên nền tối: dùng màu chữ phụ của theme. */
.fox40-docs .betterdocs-entry-content figcaption[style] {
	color: var(--f-muted) !important;
}

.fox40-dv-wrap {
	position: relative;
}

.fox40-dv-svg {
	cursor: zoom-in;
}

.fox40-dv-open {
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: var(--f-radius-sm);
	background: rgba(11, 18, 32, 0.78);
	color: #ffffff;
	cursor: pointer;
	opacity: 0.85;
	transition: opacity 0.15s ease, background-color 0.15s ease;
}

.fox40-dv-open:hover,
.fox40-dv-open:focus-visible {
	opacity: 1;
	background: rgba(11, 18, 32, 0.92);
}

.fox40-dv-open:focus-visible,
.fox40-dv__btn:focus-visible {
	outline: 2px solid var(--f-accent);
	outline-offset: 2px;
}

.fox40-dv-open[hidden] {
	display: none;
}

/* Khung phóng to: luôn tối để sơ đồ (thẻ trắng) nổi lên, không phụ thuộc chế độ sáng/tối của trang. */
html.fox40-dv-lock {
	overflow: hidden;
}

.fox40-dv {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	flex-direction: column;
	background: rgba(5, 8, 15, 0.94);
	color: #e6edf7;
}

.fox40-dv[hidden] {
	display: none;
}

.fox40-dv__bar {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 16px;
}

.fox40-dv__title {
	flex: 1;
	min-width: 0;
	margin: 0;
	overflow: hidden;
	font-size: 0.9375rem;
	font-weight: 600;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.fox40-dv__tools {
	display: flex;
	flex: none;
	align-items: center;
	gap: 6px;
}

.fox40-dv__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 1px solid rgba(255, 255, 255, 0.18);
	border-radius: var(--f-radius-sm);
	background: rgba(255, 255, 255, 0.08);
	color: #ffffff;
	cursor: pointer;
}

.fox40-dv__btn:hover {
	background: rgba(255, 255, 255, 0.18);
}

.fox40-dv__close {
	margin-left: 6px;
}

.fox40-dv__pct {
	min-width: 3.5em;
	font-size: 0.8125rem;
	font-variant-numeric: tabular-nums;
	text-align: center;
}

.fox40-dv__stage {
	position: relative;
	flex: 1;
	min-height: 0;
	margin: 0 16px 16px;
	overflow: hidden;
	border-radius: var(--f-radius);
	background: #ffffff;
	cursor: grab;
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
}

.fox40-dv__stage.is-dragging {
	cursor: grabbing;
}

.fox40-dv__stage > svg {
	display: block;
	width: 100%;
	height: 100%;
}

/* Ảnh: không có thẻ trắng phía sau, hai bên ảnh thấy nền tối của khung */
.fox40-dv__stage.is-image {
	background: transparent;
}

@media (max-width: 640px) {
	.fox40-dv__bar {
		padding: 8px 10px;
	}

	.fox40-dv__title {
		display: none;
	}

	.fox40-dv__tools {
		width: 100%;
		justify-content: flex-end;
	}

	.fox40-dv__stage {
		margin: 0 8px 8px;
	}

}

/* Nút xoay ngang/dọc: chỉ có nghĩa trên điện thoại, máy tính bảng. */
@media (hover: hover) and (pointer: fine) {
	.fox40-dv__rotate {
		display: none;
	}
}

.fox40-dv__rotate[aria-pressed="true"] {
	background: rgba(255, 122, 41, 0.25);
	border-color: rgba(255, 122, 41, 0.6);
}

/* Trình duyệt không cho khóa hướng màn hình (iPhone): xoay cả khung 90° theo chiều kim đồng hồ, khung rộng bằng
 * chiều cao màn hình và cao bằng chiều rộng màn hình. diagram-viewer.js đổi tọa độ chạm theo hướng này. */
.fox40-dv.is-rot {
	inset: auto;
	top: 0;
	left: 0;
	width: 100vh;
	width: 100dvh;
	height: 100vw;
	transform-origin: top left;
	transform: rotate(90deg) translateY(-100%);
}

.fox40-dv.is-rot .fox40-dv__title {
	display: block;
}
