/* ============ Base / Theme tokens ============ */
:root {
    --c-cyan: #22d3ee;
    --c-cyan-d: #06b6d4;
    --radius: 16px;
    --radius-sm: 10px;
    --maxw: 1100px;
    --ease: cubic-bezier(.4, 0, .2, 1);
    --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

html[data-theme="dark"] {
    --bg: #0b0f14;
    --bg-soft: #11161d;
    --card: #151b24;
    --card-hover: #1b232e;
    --border: #232c38;
    --text: #e7edf3;
    --text-dim: #8d9aab;
    --shadow: 0 8px 30px rgba(0, 0, 0, .35);
}

html[data-theme="light"] {
    --bg: #f6f8fb;
    --bg-soft: #ffffff;
    --card: #ffffff;
    --card-hover: #ffffff;
    --border: #e6eaf0;
    --text: #15202b;
    --text-dim: #5b6b7d;
    --shadow: 0 8px 24px rgba(20, 40, 70, .08);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background .3s var(--ease), color .3s var(--ease);
}

a { color: inherit; text-decoration: none; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* ============ Header ============ */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(140%) blur(12px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: 62px;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; flex-shrink: 0; letter-spacing: .5px; }
.brand-dot {
    width: 11px; height: 11px; border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, var(--c-cyan), var(--c-cyan-d));
    box-shadow: 0 0 14px var(--c-cyan);
}
.brand-name { white-space: nowrap; }
.brand-accent { color: var(--c-cyan); }

/* ----- Ô tìm kiếm ở giữa hero ----- */
.hero-search {
    position: relative;
    max-width: 520px;
    margin: 22px auto 0;
}
.hero-search input {
    width: 100%;
    height: 50px;
    padding: 0 44px 0 46px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    color: var(--text);
    font-size: 16px;
    font-family: inherit;
    outline: none;
    text-align: left;
    box-shadow: var(--shadow);
    transition: border-color .2s, box-shadow .2s;
}
.hero-search input::placeholder { text-align: center; }
.hero-search input:focus {
    border-color: var(--c-cyan);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--c-cyan) 20%, transparent);
}
.search-ico {
    position: absolute; left: 17px; top: 50%; transform: translateY(-50%);
    width: 19px; height: 19px; color: var(--text-dim); pointer-events: none;
}
.search-clear {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    width: 28px; height: 28px; border: none; border-radius: 50%;
    background: var(--border); color: var(--text); font-size: 18px; line-height: 1;
    cursor: pointer; display: none; align-items: center; justify-content: center;
}
.search-clear.show { display: flex; }

.icon-btn {
    width: 42px; height: 42px; flex-shrink: 0;
    border-radius: 50%; border: 1px solid var(--border);
    background: var(--bg-soft); color: var(--text);
    cursor: pointer; display: grid; place-items: center;
    transition: background .2s, border-color .2s;
}
.icon-btn:hover { border-color: var(--c-cyan); }
.icon-btn svg { width: 20px; height: 20px; }
html[data-theme="dark"] .ico-sun { display: none; }
html[data-theme="light"] .ico-moon { display: none; }

/* ============ Main / Hero ============ */
.main-content { padding: 22px 16px 60px; }

.hero { text-align: center; padding: 26px 0 10px; }
.hero h1 { font-size: clamp(24px, 5vw, 38px); margin: 0 0 8px; letter-spacing: -.5px; }
.hero p { color: var(--text-dim); margin: 0; font-size: 15px; }
.hero .accent { color: var(--c-cyan); }

/* ============ Tag chips ============ */
.tag-bar {
    display: flex; gap: 8px; overflow-x: auto; padding: 18px 0 10px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
    position: sticky; top: 62px; z-index: 40;
    background: color-mix(in srgb, var(--bg) 90%, transparent);
}
.tag-bar::-webkit-scrollbar { display: none; }
.chip {
    flex-shrink: 0;
    padding: 7px 14px; border-radius: 999px;
    border: 1px solid var(--border); background: var(--card);
    color: var(--text-dim); font-size: 13.5px; font-weight: 500;
    cursor: pointer; white-space: nowrap;
    transition: all .18s var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--c-cyan); }
.chip.active {
    background: var(--c-cyan); color: #04222a; border-color: var(--c-cyan);
    font-weight: 600;
}

/* ============ Category sections ============ */
.cat-section { margin-top: 30px; }
.cat-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.cat-head .cat-ico { font-size: 22px; }
.cat-head h2 { font-size: 19px; margin: 0; }
.cat-head .count { color: var(--text-dim); font-size: 13px; font-weight: 500; }
.cat-head .see-all {
    margin-left: auto; color: var(--c-cyan); font-size: 14px; font-weight: 600;
    white-space: nowrap;
}
.cat-head .see-all:hover { text-decoration: underline; }

/* ----- Phân trang ----- */
.pager {
    display: flex; align-items: center; justify-content: center; gap: 14px;
    margin: 30px 0 10px;
}
.pager-btn {
    padding: 9px 18px; border-radius: 999px;
    border: 1px solid var(--border); background: var(--card);
    color: var(--text); font-size: 14px; font-weight: 500;
    transition: border-color .2s, color .2s;
}
.pager-btn:hover:not(.disabled) { border-color: var(--c-cyan); color: var(--c-cyan); }
.pager-btn.disabled { opacity: .4; cursor: not-allowed; }
.pager-info { color: var(--text-dim); font-size: 13.5px; }

.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);   /* PC: 4 mục / hàng */
    gap: 14px;
}

/* Mục vượt quá 8 -> ẩn, xổ ra bằng nút "Xem thêm" */
.card.is-extra { display: none; }
[data-section].expanded .card.is-extra { display: flex; }
.grid { align-items: stretch; }   /* các thẻ cùng hàng cao bằng nhau */

.show-more {
    display: block;
    margin: 16px auto 0;
    padding: 9px 22px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color .2s, color .2s;
}
.show-more:hover { border-color: var(--c-cyan); color: var(--c-cyan); }
.show-more.hidden { display: none; }

.section-empty { color: var(--text-dim); font-size: 14.5px; }
.section-empty a { color: var(--c-cyan); }

/* ============ Card (text-only, không icon) ============ */
.card {
    display: flex; flex-direction: column;
    padding: 18px 20px; border-radius: var(--radius);
    background: var(--card); border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: transform .18s var(--ease), border-color .18s, background .18s;
    position: relative; overflow: hidden; height: 100%;
}
.card::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: var(--c-cyan); opacity: 0; transition: opacity .18s var(--ease);
}
.card:hover { transform: translateY(-3px); border-color: var(--c-cyan); background: var(--card-hover); }
.card:hover::before { opacity: 1; }
.card:active { transform: translateY(-1px); }

.card-title {
    font-size: 16px; font-weight: 600; line-height: 1.4; margin: 0 0 6px;
    color: var(--text); letter-spacing: -.2px;
}
.card-desc {
    color: var(--text-dim); font-size: 13.5px; line-height: 1.55; margin: 0;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-tags {
    display: flex; gap: 6px; margin-top: auto; padding-top: 12px;
    overflow: hidden; flex-wrap: nowrap;       /* tag gọn 1 dòng */
}
.tag-pill {
    flex-shrink: 0;
    font-size: 11.5px; padding: 2px 9px; border-radius: 999px;
    background: var(--bg-soft); border: 1px solid var(--border); color: var(--text-dim);
    white-space: nowrap;
}

/* badge dùng ở trang chi tiết bài viết */
.badge {
    font-size: 12px; padding: 3px 10px; border-radius: 999px;
    background: var(--bg-soft); border: 1px solid var(--border); color: var(--text-dim);
}

/* ============ Empty state ============ */
.empty-state { text-align: center; padding: 60px 16px; color: var(--text-dim); display: none; }
.empty-state.show { display: block; }
.empty-state .big { font-size: 40px; margin-bottom: 8px; }

/* ============ Article page ============ */
.article { max-width: 760px; margin: 0 auto; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: 14px; margin-bottom: 18px; }
.back-link:hover { color: var(--c-cyan); }
.article h1 { font-size: clamp(24px, 4.5vw, 34px); line-height: 1.25; margin: 6px 0 12px; letter-spacing: -.5px; }
.article-meta { display: flex; gap: 10px; flex-wrap: wrap; color: var(--text-dim); font-size: 13.5px; margin-bottom: 22px; align-items: center; }
.article-cover { width: 100%; border-radius: var(--radius); margin-bottom: 24px; border: 1px solid var(--border); }
.article-body { font-size: 16.5px; }
.article-body h2 { font-size: 22px; margin: 28px 0 10px; }
.article-body h3 { font-size: 18px; margin: 22px 0 8px; }
.article-body p { margin: 0 0 16px; }
.article-body img { max-width: 100%; height: auto; border-radius: var(--radius-sm); display: block; margin: 10px 0; }
.article-body iframe { width: 100%; aspect-ratio: 16 / 9; height: auto; border: 0; border-radius: var(--radius-sm); margin: 12px 0; }
.article-body a { color: var(--c-cyan); text-decoration: underline; }
.article-body ul, .article-body ol { padding-left: 22px; margin: 0 0 16px; }
.article-body pre { background: var(--bg-soft); padding: 14px; border-radius: var(--radius-sm); overflow-x: auto; border: 1px solid var(--border); }
.article-body code { background: var(--bg-soft); padding: 2px 6px; border-radius: 6px; font-size: .9em; }

.tag-list { display: flex; gap: 8px; flex-wrap: wrap; margin: 26px 0; }

.related { margin-top: 40px; border-top: 1px solid var(--border); padding-top: 24px; }
.related h3 { font-size: 18px; margin: 0 0 14px; }

/* ============ Footer ============ */
.site-footer { border-top: 1px solid var(--border); padding: 24px 0; color: var(--text-dim); font-size: 13.5px; text-align: center; }

/* ============ Responsive ============ */
@media (max-width: 640px) {
    .header-inner { gap: 8px; }
    .grid { grid-template-columns: 1fr; }   /* mobile: 1 cột */
    .tag-bar { top: 62px; }
    .hero h1 { font-size: 26px; }
}
@media (min-width: 641px) and (max-width: 920px) {
    .grid { grid-template-columns: repeat(2, 1fr); }   /* tablet: 2 cột */
}
@media (min-width: 921px) and (max-width: 1080px) {
    .grid { grid-template-columns: repeat(3, 1fr); }   /* desktop nhỏ: 3 cột */
}
