/*
Theme Name: CodeHub
Theme URI: https://example.com/codehub
Author: CodeHub
Description: Theme cho site tổng hợp giftcode game (Roblox, mobile, PC). Mỗi game một trang code cố định, code có phần thưởng, ngày thêm, giờ đội ngũ nhập thử; cộng đồng bình chọn còn/hết hạn, gửi code chờ duyệt, theo dõi game qua email, điểm và hạng thợ săn. Tự noindex trang mỏng, tương thích Rank Math/Yoast.
Version: 1.3.0
Requires at least: 6.4
Tested up to: 6.8
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: codehub
Tags: custom-menu, custom-logo, featured-images, threaded-comments, translation-ready
*/

/* ---------- Biến màu ---------- */
:root {
	--bg: #f6f7fb;
	--surface: #ffffff;
	--surface-2: #f0f2f8;
	--ink: #111827;
	--muted: #5b6475;
	--line: #e3e6ef;
	--brand: #5b3df5;
	--brand-ink: #ffffff;
	--brand-soft: #eeeaff;
	--ok: #13804a;
	--ok-soft: #e3f6ec;
	--warn: #a85b00;
	--warn-soft: #fff1dc;
	--danger: #c62828;
	--code-bg: #fbfaff;
	--radius: 12px;
	--shadow: 0 1px 2px rgba(17, 24, 39, .06), 0 4px 16px rgba(17, 24, 39, .05);
	--font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0e1016;
		--surface: #161a23;
		--surface-2: #1d2230;
		--ink: #e8ebf3;
		--muted: #9aa3b5;
		--line: #2a3040;
		--brand: #8b74ff;
		--brand-ink: #0e1016;
		--brand-soft: #241e45;
		--ok: #4ade80;
		--ok-soft: #12321f;
		--warn: #fbbf24;
		--warn-soft: #3a2a0a;
		--danger: #f87171;
		--code-bg: #12151d;
		--shadow: none;
	}
}

/* ---------- Nền tảng ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--font); }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; height: auto; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.1rem); letter-spacing: -.01em; }
h2 { font-size: 1.25rem; }
code { font-family: var(--mono); }
.screen-reader-text { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(1px, 1px, 1px, 1px); white-space: nowrap; }
.skip-link:focus { position: fixed !important; top: 8px; left: 8px; width: auto; height: auto; clip: auto; z-index: 1000; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

.ch-wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.ch-main { padding: 20px 0 48px; }
.ch-muted { color: var(--muted); font-size: .9em; }
.ch-fineprint { color: var(--muted); font-size: .82rem; margin: .5em 0 0; }
.ch-hp { position: absolute; left: -9999px; }

/* ---------- Nút ---------- */
.ch-btn { white-space: nowrap; display: inline-flex; align-items: center; gap: .35em; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: .45em 1em; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, transform .05s; }
.ch-btn:hover { border-color: var(--brand); }
.ch-btn:active { transform: translateY(1px); }
.ch-btn:disabled { opacity: .6; cursor: wait; }
.ch-btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.ch-btn-primary:hover { filter: brightness(1.08); }
.ch-btn-ghost { background: transparent; }

/* ---------- Header ---------- */
.ch-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.ch-header-inner { display: flex; align-items: center; gap: 16px; min-height: 60px; }
.ch-site-name { font-weight: 800; font-size: 1.2rem; color: var(--ink); text-decoration: none; letter-spacing: -.02em; }
.ch-brand img { max-height: 40px; width: auto; display: block; }
.ch-nav { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.ch-nav ul { list-style: none; display: flex; gap: 14px; margin: 0; padding: 0; }
.ch-nav ul a { color: var(--ink); text-decoration: none; font-weight: 600; font-size: .95rem; }
.ch-nav ul a:hover { color: var(--brand); }
.ch-nav .sub-menu { display: none; }
.ch-search input { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); border-radius: 999px; padding: .45em 1em; font: inherit; font-size: .9rem; width: 180px; }
.ch-menu-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line); color: var(--ink); border-radius: 8px; font-size: 1.2rem; padding: 4px 10px; cursor: pointer; }
@media (max-width: 860px) {
	.ch-menu-toggle { display: block; }
	.ch-nav { display: none; position: absolute; top: 60px; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--line); flex-direction: column; align-items: stretch; padding: 12px 16px 16px; }
	.ch-nav.is-open { display: flex; }
	.ch-nav ul { flex-direction: column; gap: 10px; }
	.ch-search input { width: 100%; }
}

/* ---------- Breadcrumb ---------- */
.ch-crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0 0 14px; font-size: .85rem; color: var(--muted); }
.ch-crumbs li + li::before { content: "›"; margin-right: 6px; }
.ch-crumbs a { color: var(--muted); }

/* ---------- Khối chung ---------- */
.ch-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 0 0 16px; box-shadow: var(--shadow); }
.ch-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.ch-box-title { font-size: 1.05rem; margin-bottom: .3em; }
.ch-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 0 0 16px; }
@media (max-width: 760px) { .ch-two-col { grid-template-columns: 1fr; } }
.ch-empty { background: var(--surface-2); border-radius: var(--radius); padding: 16px; }
.ch-notice { border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px; font-weight: 600; }
.ch-notice-ok { background: var(--ok-soft); color: var(--ok); }
.ch-notice-warn { background: var(--warn-soft); color: var(--warn); }

.ch-tag { display: inline-block; background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: .1em .65em; font-size: .78rem; font-weight: 600; }
.ch-tag-ok { background: var(--ok-soft); color: var(--ok); }
.ch-tag-warn { background: var(--warn-soft); color: var(--warn); }
.ch-tag-muted { opacity: .8; }
.ch-st-active { background: var(--ok-soft); color: var(--ok); }
.ch-st-pending { background: var(--brand-soft); color: var(--brand); }
.ch-st-suspect { background: var(--warn-soft); color: var(--warn); }

/* ---------- Trang game ---------- */
.ch-game-head { display: flex; gap: 16px; align-items: flex-start; margin: 0 0 16px; }
.ch-game-thumb img { width: 84px; height: 84px; border-radius: 18px; object-fit: cover; display: block; }
.ch-game-title { margin-bottom: .35em; }
.ch-status-line { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: 0; font-size: .92rem; }
.ch-status-count { background: var(--ok-soft); color: var(--ok); border-radius: 999px; padding: .2em .8em; font-weight: 700; }
.ch-status-warn { background: var(--warn-soft); color: var(--warn); border-radius: 999px; padding: .2em .8em; font-weight: 700; }
.ch-status-time { color: var(--muted); }
.ch-game-excerpt { color: var(--muted); margin: .6em 0 0; }

.ch-codes { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.ch-code { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: var(--code-bg); transition: opacity .2s; }
.ch-code.is-suspect { border-color: var(--warn); }
.ch-code.is-used { opacity: .62; }
.ch-code-top { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.ch-code-text { font-size: 1.15rem; font-weight: 700; letter-spacing: .03em; word-break: break-all; background: var(--surface); border: 1.5px dashed var(--brand); border-radius: 10px; padding: .3em .7em; flex: 1; }
.ch-copy { min-width: 92px; justify-content: center; font-size: .95rem; padding: .55em 1em; }
.ch-copy.is-done { background: var(--ok); border-color: var(--ok); }
.ch-code-reward { margin: .6em 0 .2em; }
.ch-label { color: var(--muted); font-size: .88em; }
.ch-code-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: .45em 0 0; }
.ch-code-warning { margin: .6em 0 0; color: var(--warn); font-weight: 600; font-size: .9rem; }
.ch-code-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: .7em; padding-top: .7em; border-top: 1px dashed var(--line); }
.ch-vote-q { color: var(--muted); font-size: .85rem; margin-right: 4px; }
.ch-vote { padding: .3em .8em; font-size: .85rem; }
.ch-vote b { font-weight: 700; color: var(--muted); }
.ch-vote.is-mine { border-color: var(--brand); background: var(--brand-soft); }
.ch-used { margin-left: auto; font-size: .82rem; }
@media (max-width: 520px) {
	.ch-code-top { flex-direction: column; align-items: stretch; }
	.ch-vote-q { flex-basis: 100%; }
	.ch-vote { flex: 1; justify-content: center; }
	.ch-used { margin-left: 0; flex-basis: 100%; justify-content: center; }
}

.ch-inline { display: flex; gap: 8px; }
.ch-form label { display: block; font-size: .88rem; font-weight: 600; margin: 0 0 10px; }
.ch-form input[type="text"], .ch-form input[type="email"], .ch-form select { display: block; width: 100%; margin-top: 4px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); border-radius: 10px; padding: .55em .8em; font: inherit; }
.ch-inline input { margin-top: 0 !important; }
.ch-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .ch-grid-2 { grid-template-columns: 1fr; } }
.ch-form-msg { margin: .6em 0 0; font-size: .9rem; font-weight: 600; min-height: 1em; }
.ch-form-msg.is-ok { color: var(--ok); }
.ch-form-msg.is-error { color: var(--danger); }

.ch-guide ol, .ch-guide ul { padding-left: 1.3em; }
.ch-changelog ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.ch-changelog li { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .92rem; }
.ch-changelog time { color: var(--muted); min-width: 88px; }
.ch-expired summary { cursor: pointer; list-style: none; }
.ch-expired summary::-webkit-details-marker { display: none; }
.ch-expired summary h2 { display: inline; }
.ch-expired summary::after { content: " ▾"; color: var(--muted); }
.ch-expired details[open] summary::after { content: " ▴"; }

.ch-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.ch-table th, .ch-table td { text-align: left; padding: .55em .5em; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ch-table th { color: var(--muted); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
.ch-table img { vertical-align: middle; border-radius: 50%; margin-right: 6px; }

.ch-info { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.ch-info dt { color: var(--muted); }
.ch-info dd { margin: 0; }

/* ---------- Thẻ game ---------- */
.ch-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.ch-card-link { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); height: 100%; transition: border-color .15s, transform .15s; }
.ch-card-link:hover { border-color: var(--brand); transform: translateY(-1px); }
.ch-card-thumb img, .ch-initials { width: 52px; height: 52px; border-radius: 14px; object-fit: cover; display: grid; place-items: center; }
.ch-initials { background: var(--brand-soft); color: var(--brand); font-weight: 800; }
.ch-card-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ch-card-title { font-weight: 700; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ch-card-meta { color: var(--muted); font-size: .8rem; display: flex; flex-wrap: wrap; gap: 0 8px; }
.ch-card-count { text-align: center; font-size: .75rem; color: var(--ok); line-height: 1.1; }
.ch-card-count b { display: block; font-size: 1.3rem; }
.ch-card-count.is-zero { color: var(--muted); }

/* ---------- Trang chủ ---------- */
.ch-hero { text-align: center; padding: 28px 0 18px; }
.ch-hero p { color: var(--muted); max-width: 640px; margin: 0 auto 16px; }
.ch-search-lg { display: flex; gap: 8px; max-width: 560px; margin: 0 auto 14px; }
.ch-search-lg input { flex: 1; width: auto; font-size: 1rem; padding: .7em 1.1em; }
.ch-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; list-style: none; padding: 0; margin: 0; }
.ch-chips a, .ch-chips li { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: .3em .9em; font-size: .88rem; text-decoration: none; color: var(--ink); font-weight: 600; }
.ch-chips span { color: var(--muted); font-weight: 500; }
.ch-ranks { justify-content: flex-start; }
.ch-home-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 860px) { .ch-home-grid { grid-template-columns: 1fr; } }
.ch-feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ch-feed li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.ch-feed li:last-child { border-bottom: 0; }
.ch-feed-game { font-weight: 700; text-decoration: none; }
.ch-feed code { background: var(--brand-soft); color: var(--brand); padding: .05em .5em; border-radius: 6px; font-weight: 700; }
.ch-feed-reward { font-size: .88rem; }
.ch-board-mini { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
.ch-board-mini li span:first-child { font-weight: 600; }
.ch-posts { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.ch-post-card { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--ink); }
.ch-post-card img { border-radius: 10px; aspect-ratio: 16 / 9; object-fit: cover; }
.ch-post-title { font-weight: 700; }

/* ---------- Danh sách ---------- */
.ch-archive-head { margin: 0 0 16px; }
.ch-sort { display: flex; gap: 8px; flex-wrap: wrap; }
.ch-sort a { border: 1px solid var(--line); border-radius: 999px; padding: .25em .9em; text-decoration: none; color: var(--ink); font-size: .88rem; background: var(--surface); }
.ch-sort a.is-active { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.ch-list { display: grid; gap: 12px; }
.ch-list-item { display: flex; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.ch-list-item h2 { font-size: 1.1rem; margin: 0; }
.ch-list-item h2 a { color: var(--ink); text-decoration: none; }
.ch-list-thumb img { width: 140px; border-radius: 10px; aspect-ratio: 16 / 10; object-fit: cover; }
.nav-links { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 18px; }
.nav-links .page-numbers { border: 1px solid var(--line); background: var(--surface); padding: .3em .8em; border-radius: 8px; text-decoration: none; }
.nav-links .current { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* ---------- Bài viết ---------- */
.ch-article-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; }
.ch-article-layout:not(:has(.ch-sidebar)) { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 900px) { .ch-article-layout { grid-template-columns: minmax(0, 1fr); } }
.ch-article { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(16px, 3vw, 32px); max-width: 820px; }
.ch-byline { color: var(--muted); font-size: .9rem; }
.entry-content { font-size: 1.04rem; }
.entry-content table { width: 100%; border-collapse: collapse; }
.entry-content th, .entry-content td { border: 1px solid var(--line); padding: .5em; }
.ch-author-box { display: flex; gap: 12px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.ch-author-box img { border-radius: 50%; }
.ch-sidebar .widget { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }

/* ---------- Tài khoản ---------- */
.ch-rank-card { margin-bottom: 16px; }
.ch-rank-name { font-size: 1.4rem; font-weight: 800; color: var(--brand); margin: 0; }
.ch-progress { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 8px 0 4px; }
.ch-progress span { display: block; height: 100%; background: var(--brand); }
.ch-follow-list { list-style: none; padding: 0; display: grid; gap: 8px; }
.ch-follow-list li { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Bình luận ---------- */
.ch-comment-list { padding-left: 1.2em; }
.ch-comments textarea, .ch-comments input[type="text"], .ch-comments input[type="email"], .ch-comments input[type="url"] { width: 100%; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); border-radius: 10px; padding: .6em; font: inherit; }
.ch-comments .submit { background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 999px; padding: .55em 1.2em; font-weight: 700; cursor: pointer; }

/* ---------- Footer ---------- */
.ch-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 28px 0; color: var(--muted); font-size: .9rem; }
.ch-footer-nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: 14px; padding: 0; margin: 0 0 12px; }
.ch-footer-nav a { color: var(--ink); text-decoration: none; }
.ch-footer-widgets { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 16px; }

/* ---------- Đăng nhập Google ---------- */
.ch-google-btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: .55em 1.1em; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-weight: 600; font-size: .92rem; text-decoration: none; margin: 4px 0 12px; }
.ch-google-btn:hover { border-color: var(--brand); }
.ch-google-btn svg { flex: none; }

/* ---------- Toast ---------- */
.ch-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: .6em 1.1em; border-radius: 999px; font-weight: 600; z-index: 100; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); max-width: calc(100% - 32px); }

@media (prefers-reduced-motion: reduce) {
	* { transition: none !important; }
}
