/*
Theme Name: TranKhacBlog
Theme URI: https://trankhacblog.com
Author: Trần Khắc
Author URI: https://trankhacblog.com
Description: Blog cá nhân về AI, tự động hoá và vận hành server.
Version: 1.0.1
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: trankhacblog
Tags: blog, minimal, dark-mode
*/

/* ==========================================================================
   TranKhacBlog — Theme stylesheet
   Plain CSS, no framework. Giữ nguyên 1:1 từ bộ static handoff.
   ========================================================================== */

/* ---- Design tokens ---- */
:root {
  --bg: #FFFFFF;
  --surface: #F8FAFC;
  --border: #E2E8F0;
  --text: #334155;
  --heading: #0F172A;
  --muted: #64748B;
  --accent: #2563EB;
  --accent-tint: color-mix(in srgb, var(--accent) 10%, transparent);
  --accent-border: color-mix(in srgb, var(--accent) 32%, transparent);
  --code-bg: #0F172A;
  --code-text: #E2E8F0;
  --header-bg: rgba(255, 255, 255, .78);
  --shadow: 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-hover: 0 10px 28px -10px rgba(15, 23, 42, .20);
  --container: 1200px;
  --section-y: 92px;
  --radius: 8px;
}

[data-theme="dark"] {
  --bg: #0B1120;
  --surface: #0F172A;
  --border: #1E293B;
  --text: #94A3B8;
  --heading: #F1F5F9;
  --muted: #64748B;
  --accent: #60A5FA;
  --code-bg: #020617;
  --code-text: #E2E8F0;
  --header-bg: rgba(11, 17, 32, .78);
  --shadow: 0 1px 3px rgba(0, 0, 0, .5);
  --shadow-hover: 0 10px 28px -10px rgba(0, 0, 0, .65);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
::selection { background: var(--accent-tint); }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }

.container { max-width: var(--container); margin: 0 auto; padding: 0 24px; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; }
.kicker {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 10px;
}

/* ==========================================================================
   HEADER  (→ header.php)
   ========================================================================== */
.site-header {
  position: sticky; top: 0; z-index: 60;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header__inner {
  max-width: var(--container); margin: 0 auto; padding: 0 24px;
  height: 64px; display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.brand__mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--heading); color: var(--bg);
  font-family: "JetBrains Mono", monospace; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; letter-spacing: -.02em;
}
.brand__name { font-size: 15px; font-weight: 700; color: var(--heading); }
.brand__name span { color: var(--accent); }
.nav { display: flex; align-items: center; gap: 2px; }
.nav__link {
  padding: 6px 11px; border-radius: 6px;
  font-size: 14px; font-weight: 500; color: var(--muted);
  transition: color .15s, background .15s;
}
.nav__link:hover, .nav__link.current-menu-item { color: var(--heading); background: var(--surface); }
.header__spacer { flex: 1; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 12px;
}
.search input {
  border: none; background: transparent; outline: none;
  font-size: 13px; color: var(--text); width: 160px;
  font-family: inherit;
}
.search input::placeholder { color: var(--muted); }
.btn-icon {
  width: 36px; height: 36px; border-radius: 8px;
  background: transparent; border: 1px solid transparent;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--muted); transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--surface); color: var(--heading); border-color: var(--border); }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
.nav-toggle { display: none; }

/* Mobile menu */
.mobile-menu {
  display: none; flex-direction: column; gap: 4px;
  padding: 12px 24px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.mobile-menu.is-open { display: flex; }
.mobile-menu .search { width: 100%; margin-bottom: 8px; }
.mobile-menu .search input { width: 100%; }
.m-group-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: 8px;
  background: var(--surface); border: none; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--heading); width: 100%;
}
.m-group {
  display: flex; flex-direction: column; gap: 2px;
  padding-left: 12px;
}
.m-group a, .mobile-menu__link {
  padding: 9px 12px; border-radius: 8px;
  font-size: 14px; color: var(--text);
  transition: background .15s;
}
.m-group a:hover, .mobile-menu__link:hover { background: var(--surface); }

@media (max-width: 859px) {
  .nav { display: none; }
  .search { display: none; }
  .nav-toggle { display: flex; }
}

/* ==========================================================================
   HERO
   ========================================================================== */
.hero {
  padding: var(--section-y) 0 calc(var(--section-y) * .8);
  border-bottom: 1px solid var(--border);
}
.hero__inner {
  max-width: var(--container); margin: 0 auto; padding: 0 24px;
}
.hero__col { max-width: 680px; }
.hero h1 {
  font-size: clamp(28px, 4.5vw, 46px); font-weight: 800;
  line-height: 1.15; letter-spacing: -.03em;
  color: var(--heading); margin: 0 0 20px;
}
.hero__lead { font-size: 17px; line-height: 1.75; color: var(--muted); margin: 0 0 28px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 6px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 13px; font-weight: 500; color: var(--text);
  transition: border-color .15s, color .15s;
}
.chip:hover, .chip.is-active { border-color: var(--accent); color: var(--accent); }

/* ==========================================================================
   SECTIONS
   ========================================================================== */
.section { padding: var(--section-y) 0; border-bottom: 1px solid var(--border); }
.section--surface { background: var(--surface); }
.section__head { margin-bottom: 40px; }
.section__head h2 { font-size: 26px; font-weight: 700; color: var(--heading); margin: 0; }
.section__head--row { display: flex; align-items: flex-end; justify-content: space-between; }

/* ==========================================================================
   CATEGORY GRID
   ========================================================================== */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.cat-card {
  display: flex; align-items: flex-start; gap: 16px; padding: 20px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); transition: box-shadow .2s, border-color .2s;
}
.cat-card:hover { box-shadow: var(--shadow-hover); border-color: var(--accent-border); }
.cat-card__icon {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--accent-tint); color: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.cat-card__body { flex: 1; min-width: 0; }
.cat-card__title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.cat-card__title h3 { font-size: 16px; font-weight: 700; color: var(--heading); margin: 0; }
.cat-card__count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.cat-card__body p { font-size: 14px; line-height: 1.6; color: var(--muted); margin: 0; }

/* ==========================================================================
   POST GRID / CARDS
   ========================================================================== */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}
.post-card {
  display: block; padding: 0; overflow: hidden;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); transition: box-shadow .2s, border-color .2s;
}
.post-card:hover { box-shadow: var(--shadow-hover); border-color: var(--accent-border); }
.post-card__thumb {
  width: 100%;
  height: clamp(180px, 22vw, 230px);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 4%, #fff), var(--surface));
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.post-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  transition: transform .25s ease;
}
.post-card:hover .post-card__image { transform: scale(1.03); }
.post-card__body { display: flex; flex-direction: column; gap: 12px; padding: 20px 24px 24px; }
.post-card__meta-top { display: flex; align-items: center; gap: 10px; }
.post-card__cat { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.post-card__title { font-size: 17px; font-weight: 700; color: var(--heading); line-height: 1.4; margin: 0; }
.post-card__excerpt { font-size: 14px; line-height: 1.65; color: var(--muted); margin: 0; }
.post-card__meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 4px; }
.dot { opacity: .5; }
.no-results { padding: 40px; text-align: center; color: var(--muted); font-size: 15px; }

/* ==========================================================================
   BADGE
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  background: var(--surface); color: var(--muted); border: 1px solid var(--border);
}
.badge--case {
  background: var(--accent-tint); color: var(--accent); border-color: var(--accent-border);
}

/* ==========================================================================
   ABOUT SECTION
   ========================================================================== */
.about { display: flex; align-items: flex-start; gap: 28px; }
.about__avatar {
  width: 80px; height: 80px; border-radius: 50%; flex-shrink: 0;
  background: var(--heading); color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-family: "JetBrains Mono", monospace; font-size: 18px; font-weight: 700;
}
.about__body h2 { font-size: 22px; font-weight: 700; color: var(--heading); margin: 8px 0 12px; }
.about__body p { font-size: 15px; line-height: 1.75; color: var(--muted); margin: 0 0 20px; }
.about__links { display: flex; gap: 20px; }
.about__links a { font-size: 14px; font-weight: 600; color: var(--accent); }
.about__links a:hover { text-decoration: underline; }

/* ==========================================================================
   FOOTER  (→ footer.php)
   ========================================================================== */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); }
.site-footer__inner { max-width: var(--container); margin: 0 auto; padding: 56px 24px 32px; }
.footer-cols {
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 40px;
  padding-bottom: 40px; border-bottom: 1px solid var(--border); margin-bottom: 28px;
}
.footer-brand p { font-size: 14px; line-height: 1.7; color: var(--muted); margin: 12px 0 0; max-width: 280px; }
.footer-col__title { font-size: 13px; font-weight: 700; color: var(--heading); margin-bottom: 14px; text-transform: uppercase; letter-spacing: .06em; }
.footer-col__links { display: flex; flex-direction: column; gap: 10px; }
.footer-col__links a { font-size: 14px; color: var(--muted); }
.footer-col__links a:hover { color: var(--heading); }
.footer-bottom { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
@media (max-width: 859px) {
  .footer-cols { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 540px) {
  .footer-cols { grid-template-columns: 1fr; }
  .footer-bottom { flex-direction: column; gap: 6px; }
}

/* ==========================================================================
   ARCHIVE / CATEGORY  (→ archive.php)
   ========================================================================== */
.archive-head {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 56px 0 40px;
}
.archive-head__inner { max-width: var(--container); margin: 0 auto; padding: 0 24px; }
.archive-head h1 { font-size: clamp(24px, 4vw, 40px); font-weight: 800; color: var(--heading); margin: 8px 0 10px; }
.archive-head p { font-size: 16px; color: var(--muted); margin: 0 0 16px; }
.archive-head__count { font-size: 13px; color: var(--muted); }
.cat-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 32px; }

/* ==========================================================================
   SINGLE POST  (→ single.php)
   ========================================================================== */
.article { padding: 56px 0 80px; }
.article__inner { max-width: 720px; margin: 0 auto; padding: 0 24px; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 24px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--heading); }
.breadcrumb .sep { opacity: .4; }
.breadcrumb .current { color: var(--heading); }
.article__inner > .badge { margin-bottom: 16px; }
.article__inner > h1 { font-size: clamp(24px, 4vw, 38px); font-weight: 800; line-height: 1.2; letter-spacing: -.02em; color: var(--heading); margin: 0 0 24px; }

.byline { display: flex; align-items: center; gap: 12px; margin-bottom: 40px; padding-bottom: 32px; border-bottom: 1px solid var(--border); }
.byline__avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: var(--heading); color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-family: "JetBrains Mono", monospace; font-size: 13px; font-weight: 700;
}
.byline__name { font-size: 14px; font-weight: 600; color: var(--heading); }
.byline__meta { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* Entry content typography */
.entry-content { font-size: 17px; line-height: 1.8; color: var(--text); }
.entry-content p { margin: 0 0 1.5em; }
.entry-content p.lead { font-size: 19px; color: var(--heading); font-weight: 500; }
.entry-content h2 { font-size: 22px; font-weight: 700; color: var(--heading); margin: 2.2em 0 .8em; }
.entry-content h3 { font-size: 18px; font-weight: 700; color: var(--heading); margin: 2em 0 .6em; }
.entry-content ul, .entry-content ol { padding-left: 1.6em; margin: 0 0 1.5em; }
.entry-content li { margin-bottom: .5em; }
.entry-content a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; }
.entry-content code {
  font-family: "JetBrains Mono", monospace; font-size: .88em;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 6px;
}
.entry-content hr { border: none; border-top: 1px solid var(--border); margin: 2.5em 0; }
.entry-content blockquote {
  border-left: 3px solid var(--accent); margin: 1.5em 0;
  padding: .6em 1.2em; background: var(--accent-tint); border-radius: 0 6px 6px 0;
}
.entry-content blockquote p { margin: 0; }

/* Code block */
.code-block { border-radius: var(--radius); overflow: hidden; margin: 1.8em 0; border: 1px solid var(--border); }
.code-block__bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: #1E293B;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.code-block__square { width: 12px; height: 12px; border-radius: 50%; background: #EF4444; flex-shrink: 0; }
.code-block__name { font-family: "JetBrains Mono", monospace; font-size: 12px; color: #94A3B8; flex: 1; }
.code-block__lang { font-family: "JetBrains Mono", monospace; font-size: 11px; color: #475569; text-transform: uppercase; letter-spacing: .08em; }
.code-block pre {
  margin: 0; padding: 20px;
  background: var(--code-bg); overflow-x: auto;
}
.code-block pre code {
  font-family: "JetBrains Mono", monospace; font-size: 13.5px; line-height: 1.75;
  color: var(--code-text); background: none; border: none; padding: 0;
  white-space: pre;
}
/* Prism / highlight.js overrides — map to our palette */
.tok-key, .token.keyword, .token.property { color: #60A5FA; }
.tok-str, .token.string { color: #4ADE80; }
.tok-com, .token.comment { color: #475569; font-style: italic; }
.tok-num, .token.number { color: #FBBF24; }
/* wp-block-code compat */
.wp-block-code { padding: 0 !important; }
.entry-content .wp-block-code pre { padding: 20px; background: var(--code-bg); border-radius: var(--radius); overflow-x: auto; }
.entry-content .wp-block-code code { font-size: 13.5px; color: var(--code-text); background: none; border: none; padding: 0; }

/* Callout */
.callout {
  border-left: 3px solid var(--accent); background: var(--accent-tint);
  border-radius: 0 var(--radius) var(--radius) 0; padding: 14px 18px;
  margin: 1.8em 0;
}
.callout__label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); display: block; margin-bottom: 6px; }
.callout p { margin: 0; font-size: 15px; }

/* Tags */
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 40px 0; padding-top: 32px; border-top: 1px solid var(--border); }
.tag {
  padding: 5px 12px; border-radius: 6px;
  font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border);
}
.tag:hover { color: var(--accent); border-color: var(--accent-border); }

/* Author card */
.author-card {
  display: flex; gap: 18px; align-items: flex-start;
  padding: 24px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  margin-top: 48px;
}
.author-card__avatar {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  background: var(--heading); color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-family: "JetBrains Mono", monospace; font-size: 15px; font-weight: 700;
}
.author-card__name { font-size: 15px; font-weight: 700; color: var(--heading); margin-bottom: 8px; }
.author-card p { font-size: 14px; line-height: 1.65; color: var(--muted); margin: 0; }
.author-card a { color: var(--accent); }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 8px; padding: 40px 0 0; }
.pagination a, .pagination span {
  padding: 8px 14px; border-radius: 8px; font-size: 14px;
  border: 1px solid var(--border); color: var(--text);
}
.pagination a:hover { background: var(--surface); }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Search page */
.search-header { padding: 48px 0 32px; border-bottom: 1px solid var(--border); }
.search-header__inner { max-width: var(--container); margin: 0 auto; padding: 0 24px; }
.search-header h1 { font-size: 28px; font-weight: 800; color: var(--heading); margin: 0 0 8px; }
.search-header p { color: var(--muted); margin: 0; }


@media (max-width: 767px) {
  .post-card__thumb {
    height: 200px;
  }
}
