/**
 * SeoCraft Connector v1.7.0 — Reader-UX pack.
 * Prefix sc- toàn bộ, scoped chặt để không phá style theme.
 * Ngôn ngữ thiết kế đồng bộ card link-preview 1.5.x (trắng, viền nhạt, bóng mềm).
 */

/* ── Reading-time badge (render từ PHP, có sẵn trong HTML → 0 CLS) ─────────── */
.sc-reading-meta {
	margin: 0 0 14px;
	font-size: 13px;
	color: #6b7280;
}

.sc-read-time,
.sc-updated-time {
	display: inline-block;
	padding: 3px 10px;
	background: #f4f5f7;
	border-radius: 999px;
	line-height: 1.5;
}

/* ── Progress bar ──────────────────────────────────────────────────────────── */
.sc-progress {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	height: 3px;
	z-index: 99998;
	background: transparent;
	pointer-events: none;
}

.admin-bar .sc-progress {
	top: 32px;
}

.sc-progress-fill {
	height: 100%;
	background: #3366cc;
	transform: scaleX(0);
	transform-origin: left center;
}

/* ── FAQ accordion ─────────────────────────────────────────────────────────── */
.faq-item.sc-acc {
	border: 1px solid rgba(0, 0, 0, 0.1);
	border-radius: 8px;
	margin: 0 0 10px;
	overflow: hidden;
}

.faq-item.sc-acc .sc-acc-q {
	position: relative;
	margin: 0;
	padding: 12px 40px 12px 14px;
	font-size: 1em;
	cursor: pointer;
	user-select: none;
	background: #fafbfc;
}

.faq-item.sc-acc .sc-acc-q:hover {
	background: #f2f4f6;
}

/* Mũi tên ▾ xoay khi mở */
.faq-item.sc-acc .sc-acc-q::after {
	content: "";
	position: absolute;
	right: 16px;
	top: 50%;
	width: 8px;
	height: 8px;
	border-right: 2px solid #6b7280;
	border-bottom: 2px solid #6b7280;
	transform: translateY(-70%) rotate(45deg);
	transition: transform 0.2s;
}

.faq-item.sc-acc.sc-acc-open .sc-acc-q::after {
	transform: translateY(-30%) rotate(225deg);
}

/* Nội dung GIỮ trong DOM (máy đọc HTML vẫn thấy) — chỉ ẩn bằng CSS khi đóng */
.faq-item.sc-acc .sc-acc-body {
	display: none;
	padding: 12px 14px;
}

.faq-item.sc-acc.sc-acc-open .sc-acc-body {
	display: block;
}

/* ── TOC ───────────────────────────────────────────────────────────────────── */

/* Heading trong bài né sticky header của theme khi nhảy anchor */
.sc-anchor {
	scroll-margin-top: 90px;
}

/* Panel chung (desktop: hộp nổi mép trái; mobile: drawer toàn chiều cao) */
.sc-toc {
	position: fixed;
	z-index: 99995;
	background: #fff;
	border: 1px solid rgba(0, 0, 0, 0.12);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
	overflow-y: auto;
	font-size: 13.5px;
	line-height: 1.5;
	text-align: left;
	visibility: hidden;
	opacity: 0;
	transition: transform 0.22s ease, opacity 0.22s ease, visibility 0.22s;
}

body.sc-toc-is-open .sc-toc {
	visibility: visible;
	opacity: 1;
	transform: none;
}

.sc-toc-head {
	position: sticky;
	top: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 14px;
	background: #fff;
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
	font-weight: 600;
	font-size: 14px;
	color: #202122;
}

.sc-toc-close {
	border: 0;
	background: none;
	padding: 0 2px;
	font-size: 20px;
	line-height: 1;
	color: #6b7280;
	cursor: pointer;
}

.sc-toc-close:hover {
	color: #202122;
}

.sc-toc-list {
	list-style: none;
	margin: 6px 0 10px;
	padding: 0;
}

.sc-toc-list li {
	margin: 0;
	padding: 0;
}

.sc-toc-list li.sc-toc-sub a {
	padding-left: 28px;
	font-size: 12.5px;
}

.sc-toc-list a {
	display: block;
	padding: 6px 14px;
	color: #3f4550;
	text-decoration: none;
	border-left: 3px solid transparent;
}

.sc-toc-list a:hover {
	background: #f4f6f8;
	color: #202122;
}

.sc-toc-list a.is-active {
	border-left-color: #3366cc;
	background: #f0f4fb;
	color: #1a3f8f;
	font-weight: 600;
}

/* Nút mở TOC */
.sc-toc-tab {
	position: fixed;
	z-index: 99993;
	border: 1px solid rgba(0, 0, 0, 0.12);
	background: #fff;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
	cursor: pointer;
	color: #3f4550;
	font-size: 13px;
	line-height: 1;
}

.sc-toc-tab:hover {
	background: #f4f6f8;
}

.sc-toc-backdrop {
	position: fixed;
	inset: 0;
	z-index: 99994;
	background: rgba(0, 0, 0, 0.35);
	visibility: hidden;
	opacity: 0;
	transition: opacity 0.22s, visibility 0.22s;
}

/* ── Desktop ≥1024px: tab dọc neo mép trái, panel nổi cạnh mép ─────────────── */
@media (min-width: 1024px) {
	.sc-toc {
		left: 12px;
		top: 50%;
		width: 260px;
		max-height: 72vh;
		border-radius: 10px;
		transform: translateY(-50%) translateX(-16px);
	}

	body.sc-toc-is-open .sc-toc {
		transform: translateY(-50%);
	}

	.sc-toc-tab {
		left: 0;
		top: 50%;
		transform: translateY(-50%);
		padding: 12px 7px;
		border-left: 0;
		border-radius: 0 8px 8px 0;
		writing-mode: vertical-rl;
	}

	.sc-toc-tab-ico {
		display: block;
		margin-bottom: 6px;
	}

	/* Panel mở → giấu tab (panel đã che chỗ đó) */
	body.sc-toc-is-open .sc-toc-tab {
		visibility: hidden;
	}

	/* Desktop không cần backdrop — panel không chặn thao tác với trang */
	.sc-toc-backdrop {
		display: none;
	}
}

/* ── Mobile <1024px: nút tròn góc trái dưới + drawer trượt từ trái ─────────── */
@media (max-width: 1023px) {
	.sc-toc {
		left: 0;
		top: 0;
		bottom: 0;
		width: 82vw;
		max-width: 320px;
		max-height: none;
		border-radius: 0;
		border-top: 0;
		border-bottom: 0;
		border-left: 0;
		transform: translateX(-100%);
	}

	.sc-toc-tab {
		left: 14px;
		bottom: 18px;
		width: 48px;
		height: 48px;
		border-radius: 50%;
		font-size: 20px;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.sc-toc-tab-txt {
		display: none;
	}

	body.sc-toc-is-open .sc-toc-backdrop {
		visibility: visible;
		opacity: 1;
	}
}

/* ── v1.8.0: Bảng responsive + sortable ────────────────────────────────────── */
/* 2 lớp: .sc-tablewrap (relative — giữ gradient đứng yên ở mép nhìn thấy)
   + .sc-tw-in (overflow-x:auto — cuộn thật). Gradient bật/tắt bằng class
   fade-l/fade-r do JS tính theo scrollLeft. */
.sc-tablewrap {
	position: relative;
	margin: 1em 0;
}

.sc-tablewrap .sc-tw-in {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.sc-tablewrap .sc-tw-in > table {
	margin: 0;
}

.sc-tablewrap::before,
.sc-tablewrap::after {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	width: 18px;
	z-index: 2;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.15s;
}

.sc-tablewrap::before {
	left: 0;
	background: linear-gradient(to right, rgba(0, 0, 0, 0.13), transparent);
}

.sc-tablewrap::after {
	right: 0;
	background: linear-gradient(to left, rgba(0, 0, 0, 0.13), transparent);
}

.sc-tablewrap.fade-l::before {
	opacity: 1;
}

.sc-tablewrap.fade-r::after {
	opacity: 1;
}

/* Header sort được: con trỏ + indicator ↕/▲/▼ theo aria-sort */
.sc-tablewrap th.sc-sortable {
	cursor: pointer;
	user-select: none;
	white-space: nowrap;
}

.sc-tablewrap th.sc-sortable::after {
	content: " ↕";
	opacity: 0.35;
	font-size: 0.85em;
}

.sc-tablewrap th.sc-sortable[aria-sort="ascending"]::after {
	content: " ▲";
	opacity: 0.8;
}

.sc-tablewrap th.sc-sortable[aria-sort="descending"]::after {
	content: " ▼";
	opacity: 0.8;
}

/* ── v1.9.0: Glossary term (span.sc-glo, gắn bởi sc-overlay.js) ────────────── */
span.sc-glo {
	border-bottom: 1px dotted #8a8f98;
	cursor: help;
	text-decoration: none;
}

span.sc-glo:hover {
	border-bottom-color: #3366cc;
}

/* Nội dung card khi hover — biến thể của .seocraft-lp-body (card dùng chung) */
.seocraft-lp-body.sc-glo-body {
	font-size: 13.5px;
	color: #202122;
}

.sc-glo-def {
	margin: 0 0 8px;
	color: #202122;
}

.sc-glo-facts {
	margin: 0 0 8px;
	padding: 0;
	list-style: none;
	font-size: 12.5px;
	color: #54595d;
}

.sc-glo-facts li {
	padding: 3px 0;
	border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.sc-glo-facts li:first-child {
	border-top: 0;
}

.sc-glo-more {
	display: inline-block;
	margin-top: 2px;
	color: #3366cc;
	text-decoration: none;
	font-weight: 600;
	font-size: 13px;
}

.sc-glo-more:hover {
	text-decoration: underline;
}

/* ── v1.9.0: Product Preview Card — dòng giá + badge tồn kho ────────────────── */
.sc-lp-price {
	margin-top: 6px;
	font-size: 14px;
	font-weight: 600;
	color: #202122;
}

/* price_html của Woo tự có <del>/<ins> khi sale — chỉ style nhẹ, không đổi cấu trúc */
.sc-lp-price del {
	color: #9aa0a6;
	font-weight: 400;
	margin-right: 6px;
}

.sc-lp-price ins {
	text-decoration: none;
	color: #c0392b;
}

.sc-lp-stock {
	display: inline-block;
	margin-top: 4px;
	padding: 2px 8px;
	border-radius: 999px;
	font-size: 11.5px;
	font-weight: 600;
}

.sc-lp-stock.is-in {
	background: #e6f4ea;
	color: #1e7e34;
}

.sc-lp-stock.is-out {
	background: #fdecea;
	color: #c0392b;
}

/* Footer luôn hiện — link về Glossary Hub /thuat-ngu/, phụ hơn "Đọc bài đầy đủ" */
.sc-glo-hub {
	display: block;
	margin-top: 6px;
	padding-top: 6px;
	border-top: 1px solid rgba(0, 0, 0, 0.08);
	color: #6b7280;
	text-decoration: none;
	font-size: 12px;
}

.sc-glo-hub:hover {
	color: #3366cc;
	text-decoration: underline;
}

/* ── v1.8.0: Related-by-cluster block "📚 Trong cùng chuyên đề" ─────────────── */
/* Render server-side (PHP append vào the_content) — CSS chỉ trang trí; thiếu CSS
   block vẫn là link thường đọc được (Level 0). */
.sc-related {
	margin: 28px 0;
	padding: 16px 18px;
	background: #fafbfc;
	border: 1px solid rgba(0, 0, 0, 0.1);
	border-radius: 10px;
}

.sc-rel-head {
	margin: 0 0 12px;
	font-weight: 700;
	font-size: 15px;
	color: #202122;
}

.sc-rel-pillar {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	margin: 0 0 10px;
	padding: 10px 12px;
	background: #fff;
	border: 1px solid rgba(0, 0, 0, 0.1);
	border-radius: 8px;
	text-decoration: none;
}

.sc-rel-pillar:hover {
	border-color: #3366cc;
}

/* Thumbnail hộp cố định (object-fit cover) → 0 CLS bất kể kích thước ảnh gốc */
.sc-rel-thumb {
	flex: 0 0 112px;
	width: 112px;
	height: 63px;
	object-fit: cover;
	border-radius: 6px;
	margin: 0;
}

.sc-rel-pillar-body {
	min-width: 0;
}

.sc-rel-pillar-title {
	display: block;
	margin-bottom: 3px;
	font-weight: 600;
	font-size: 14.5px;
	color: #202122;
}

.sc-rel-pillar:hover .sc-rel-pillar-title {
	text-decoration: underline;
}

.sc-rel-pillar-exc {
	display: -webkit-box;
	-webkit-line-clamp: 1;
	-webkit-box-orient: vertical;
	overflow: hidden;
	font-size: 13px;
	color: #54595d;
}

.sc-rel-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.sc-rel-list li {
	position: relative;
	margin: 0;
	padding: 5px 0 5px 18px;
}

.sc-rel-list li::before {
	content: "›";
	position: absolute;
	left: 4px;
	color: #3366cc;
}

.sc-rel-list a {
	color: #3366cc;
	font-size: 14px;
	text-decoration: none;
}

.sc-rel-list a:hover {
	text-decoration: underline;
}

@media (max-width: 480px) {
	.sc-rel-thumb {
		flex-basis: 88px;
		width: 88px;
		height: 50px;
	}
}

/* ── v1.9.0: Lightbox ảnh ─────────────────────────────────────────────────── */
img.sc-lb-trigger {
	cursor: zoom-in;
}

.sc-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99997;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 28px;
	box-sizing: border-box;
	background: rgba(0, 0, 0, 0.85);
	visibility: hidden;
	opacity: 0;
	transition: opacity 0.2s, visibility 0.2s;
}

.sc-lightbox.is-open {
	visibility: visible;
	opacity: 1;
}

.sc-lb-img {
	max-width: 92vw;
	max-height: 82vh;
	object-fit: contain;
	box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
	margin: 0;
}

.sc-lb-cap {
	max-width: 80vw;
	color: #f1f1f1;
	font-size: 13.5px;
	text-align: center;
}

.sc-lb-close {
	position: absolute;
	top: 14px;
	right: 18px;
	border: 0;
	background: none;
	color: #fff;
	font-size: 32px;
	line-height: 1;
	cursor: pointer;
	padding: 4px 10px;
}

body.sc-lb-lock {
	overflow: hidden;
}

/* ── v1.9.0: Anchor icon trên heading (copy link section) ───────────────────── */
h2.sc-anchor,
h3.sc-anchor {
	position: relative;
}

.sc-anchor-ico {
	margin-left: 8px;
	opacity: 0;
	color: #9aa0a6;
	text-decoration: none;
	font-size: 0.75em;
	font-weight: 400;
	vertical-align: middle;
	transition: opacity 0.15s;
}

h2.sc-anchor:hover .sc-anchor-ico,
h3.sc-anchor:hover .sc-anchor-ico,
.sc-anchor-ico:focus {
	opacity: 1;
}

/* Touch: không có hover — hiện mờ sẵn để vẫn bấm được */
@media (hover: none) {
	.sc-anchor-ico {
		opacity: 0.5;
	}
}

.sc-copy-toast {
	position: fixed;
	left: 50%;
	bottom: 28px;
	z-index: 99999;
	transform: translateX(-50%) translateY(8px);
	background: #202122;
	color: #fff;
	font-size: 13px;
	padding: 8px 16px;
	border-radius: 6px;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.18s, transform 0.18s;
}

.sc-copy-toast.is-visible {
	opacity: 1;
	transform: translateX(-50%) translateY(0);
}

/* ── v1.10.0: Feedback widget "Bài viết có hữu ích?" ─────────────────────────── */
.sc-fb {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px;
	margin: 32px 0;
	padding: 14px 16px;
	background: #fafbfc;
	border: 1px solid rgba(0, 0, 0, 0.1);
	border-radius: 10px;
	font-size: 14px;
}

.sc-fb-q {
	color: #202122;
	font-weight: 600;
	margin-right: 4px;
}

.sc-fb-btn {
	border: 1px solid rgba(0, 0, 0, 0.12);
	background: #fff;
	border-radius: 999px;
	padding: 5px 12px;
	font-size: 15px;
	line-height: 1;
	cursor: pointer;
}

.sc-fb-btn:hover {
	background: #f4f6f8;
}

/* Honeypot — off-screen, không dùng display:none (1 số bot bỏ qua field ẩn kiểu đó) */
.sc-fb-hp {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	opacity: 0;
	pointer-events: none;
}

.sc-fb-note {
	display: flex;
	flex: 1 1 100%;
	gap: 8px;
	flex-wrap: wrap;
	margin-top: 4px;
}

.sc-fb-note textarea {
	flex: 1 1 220px;
	min-height: 54px;
	padding: 8px 10px;
	border: 1px solid rgba(0, 0, 0, 0.15);
	border-radius: 6px;
	font: inherit;
	resize: vertical;
}

.sc-fb-note-submit {
	border: 1px solid #3366cc;
	background: #3366cc;
	color: #fff;
	border-radius: 6px;
	padding: 6px 14px;
	cursor: pointer;
	font-size: 13px;
	align-self: flex-start;
}

.sc-fb-thanks {
	color: #1e7e34;
	font-weight: 600;
}

/* ── v1.10.0: Author hover card ──────────────────────────────────────────────── */
/* Cue trên tên trong author box — chỉ gắn khi entry sống (JS quyết định lúc load) */
.author-box-name.sc-author-live {
	border-bottom: 1px dotted #8a8f98;
	cursor: help;
	display: inline-block;
}

.author-box-name.sc-author-live:hover {
	border-bottom-color: #3366cc;
}

.seocraft-lp-body.sc-author-body {
	font-size: 13.5px;
	color: #202122;
	text-align: center;
}

.sc-author-avatar {
	display: flex;
	justify-content: center;
	margin-bottom: 8px;
}

.sc-author-avatar img {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	object-fit: cover;
	margin: 0;
}

.sc-author-name {
	font-weight: 700;
	font-size: 14.5px;
}

.sc-author-title {
	color: #54595d;
	font-size: 12.5px;
	margin-top: 2px;
}

.sc-author-bio {
	margin: 8px 0;
	text-align: left;
}

.sc-author-links {
	display: flex;
	justify-content: center;
	gap: 8px;
	margin: 6px 0;
	font-size: 16px;
}

.sc-author-link {
	text-decoration: none;
	line-height: 1;
}

.sc-author-more {
	display: inline-block;
	margin-top: 4px;
	color: #3366cc;
	text-decoration: none;
	font-weight: 600;
	font-size: 13px;
}

.sc-author-more:hover {
	text-decoration: underline;
}

/* ── Khác ──────────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
	.sc-toc,
	.sc-toc-backdrop,
	.faq-item.sc-acc .sc-acc-q::after {
		transition: none;
	}
}

@media print {
	.sc-toc,
	.sc-toc-tab,
	.sc-toc-backdrop,
	.sc-progress,
	.sc-lightbox,
	.sc-anchor-ico,
	.sc-copy-toast {
		display: none !important;
	}

	.faq-item.sc-acc .sc-acc-body {
		display: block !important;
	}
}

/* ── (i) v1.11.0 — Thu gọn content danh mục sản phẩm ─────────────────────────
 * .sc-tc-collapsed che bằng max-height (JS set px) + gradient mờ dần ở đáy —
 * nội dung vẫn nguyên trong DOM. Nền gradient mặc định trắng, theme nền khác
 * chỉnh qua biến --sc-tc-bg. Print: bung toàn bộ, giấu nút. */
.sc-tc {
	position: relative;
	overflow: hidden;
	transition: max-height .4s ease;
}

.sc-tc.sc-tc-collapsed::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 96px;
	background: linear-gradient(to bottom, rgba(255, 255, 255, 0), var(--sc-tc-bg, #fff) 92%);
	pointer-events: none;
}

.sc-tc-toggle {
	display: block;
	margin: 6px auto 24px;
	padding: 8px 26px;
	border: 1px solid #d8d8d8;
	border-radius: 999px;
	background: #fff;
	color: #333;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.4;
	cursor: pointer;
	transition: border-color .15s, background .15s;
}

.sc-tc-toggle:hover {
	border-color: #9a9a9a;
	background: #f7f7f7;
}

.sc-tc-toggle::after {
	content: " ↓";
}

.sc-tc-toggle.sc-tc-open::after {
	content: " ↑";
}

@media (prefers-reduced-motion: reduce) {
	.sc-tc {
		transition: none;
	}
}

@media print {
	.sc-tc {
		max-height: none !important;
	}

	.sc-tc.sc-tc-collapsed::after,
	.sc-tc-toggle {
		display: none !important;
	}
}

/* ── v1.13.0: Living Data Blocks — fact box ──────────────────────────────────
 * Bảng số liệu render server-side từ kho seocraft_facts. Style khớp .sc-related
 * (nền nhạt, bo góc, border mảnh); bảng 2 cột term|value không sortable. */
.sc-factbox {
	margin: 24px 0;
	padding: 14px 16px 12px;
	background: #fafbfc;
	border: 1px solid rgba(0, 0, 0, 0.1);
	border-radius: 10px;
}

.sc-factbox-head {
	margin: 0 0 10px;
	font-weight: 700;
	font-size: 15px;
	color: #202122;
}

.sc-factbox-asof {
	font-weight: 400;
	font-size: 12px;
	color: #54595d;
	white-space: nowrap;
}

.sc-factbox .sc-factbox-table {
	width: 100%;
	margin: 0;
	border-collapse: collapse;
	font-size: 14px;
}

.sc-factbox .sc-factbox-table td {
	padding: 7px 10px;
	border: 0;
	border-bottom: 1px solid rgba(0, 0, 0, 0.07);
	vertical-align: top;
}

.sc-factbox .sc-factbox-table tr:last-child td {
	border-bottom: 0;
}

.sc-factbox-term {
	width: 42%;
	color: #54595d;
}

.sc-factbox-val {
	font-weight: 600;
	color: #202122;
}

.sc-factbox-foot {
	margin-top: 8px;
	font-size: 12px;
	color: #54595d;
}

@media (max-width: 600px) {
	.sc-factbox .sc-factbox-table td {
		display: block;
		width: auto;
	}
	.sc-factbox-term {
		padding-bottom: 0;
		border-bottom: 0 !important;
	}
	.sc-factbox-val {
		padding-top: 2px;
	}
}
