/*
Theme Name: TopChiaSe Library
Theme URI: https://topchiase.com
Author: TopChiaSe
Description: Theme thư viện kiến thức phong cách bento hiện đại: card bo lớn, nền xám sáng, màu pastel theo chuyên mục, header dạng viên thuốc nổi, mục lục dính bên cạnh bài viết.
Version: 2.0.0
Requires at least: 6.0
Requires PHP: 7.4
License: GPL-2.0-or-later
Text Domain: topchiase-library
*/

:root {
  --bg: #f5f5f7;
  --card: #fff;
  --ink: #14141a;
  --soft: #5b5b6b;
  --line: #e6e6ec;
  --brand: #ff5a1f;
  --brand-dk: #c2410c;
  --t1: #ffe3d6; --t2: #e4e0ff; --t3: #d6f2e2; --t4: #d9ebff; --t5: #fff0b3; --t6: #ffd8e8;
  --r-lg: 28px; --r-md: 20px; --r-sm: 12px;
  --shadow: 0 1px 2px rgba(20, 20, 26, .04), 0 8px 24px rgba(20, 20, 26, .06);
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --wrap: 1240px;
  --gut: clamp(16px, 3.5vw, 32px);
  --ease: cubic-bezier(.2, .7, .2, 1);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.6 var(--font); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
img, svg, video, iframe { max-width: 100%; display: block; }
img { height: auto; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { font-weight: 800; line-height: 1.22; margin: 0; letter-spacing: -.012em; word-spacing: .08em; }
p { margin: 0 0 1em; }
::selection { background: var(--brand); color: #fff; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 8px; }
.screen-reader-text, .skip-link:not(:focus) { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link:focus { position: fixed; top: 8px; left: 8px; z-index: 999; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 99px; }
.wrap { width: min(100% - var(--gut) * 2, var(--wrap)); margin-inline: auto; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* tones */
.t1 { background: var(--t1); } .t2 { background: var(--t2); } .t3 { background: var(--t3); }
.t4 { background: var(--t4); } .t5 { background: var(--t5); } .t6 { background: var(--t6); }

/* ---------- Header (floating pill) ---------- */
.site-header { position: sticky; top: 12px; z-index: 50; margin: 12px auto 0; }
.pill { display: flex; align-items: center; gap: 8px; min-height: 64px; padding: 8px 8px 8px 12px; background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-radius: 99px; box-shadow: var(--shadow); border: 1px solid rgba(255, 255, 255, .8); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.25rem; letter-spacing: -.02em; white-space: nowrap; padding-right: 8px; }
.brand__mark { width: 40px; height: 40px; display: grid; place-items: center; background: var(--brand); color: #fff; border-radius: 14px; font-size: 1.15rem; transform: rotate(-6deg); transition: transform .3s var(--ease); }
.brand:hover .brand__mark { transform: rotate(4deg) scale(1.05); }
.brand span b { color: var(--brand-dk); font-weight: 800; }
.nav { margin-left: 8px; flex: 1; min-width: 0; }
.nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 2px; flex-wrap: nowrap; }
.nav ul ul { display: none; }
.nav a { display: flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 99px; font-weight: 600; font-size: 14.5px; color: var(--soft); transition: background .2s, color .2s; white-space: nowrap; }
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav .current-cat > a, .nav .current-menu-item > a { background: var(--ink); color: #fff; }
.icon-btn { width: 48px; height: 48px; display: grid; place-items: center; background: var(--bg); border: 0; border-radius: 50%; color: var(--ink); cursor: pointer; transition: background .2s, transform .2s var(--ease); flex: none; }
.icon-btn:hover { background: var(--ink); color: #fff; transform: scale(1.06); }
.menu-toggle { display: none; }
.sheet { display: none; margin-top: 8px; background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 16px; }
.sheet.is-open { display: block; }
.searchform { display: flex; gap: 8px; }
.searchform input { flex: 1; min-width: 0; height: 52px; padding: 0 22px; border: 2px solid transparent; background: var(--bg); border-radius: 99px; font: inherit; color: var(--ink); }
.searchform input:focus { outline: none; border-color: var(--ink); background: #fff; }
.searchform button { display: inline-flex; align-items: center; gap: 8px; height: 52px; padding: 0 26px; border: 0; border-radius: 99px; background: var(--ink); color: #fff; font: 700 15px var(--font); cursor: pointer; transition: background .2s; }
.searchform button:hover { background: var(--brand); color: var(--ink); }
.sheet .menu-list { list-style: none; margin: 12px 0 0; padding: 0; display: none; flex-wrap: wrap; gap: 8px; }
.sheet .menu-list a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border-radius: 99px; background: var(--bg); font-weight: 600; }

/* ---------- Shared ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 99px; font: 700 12px/1.3 var(--font); color: var(--ink); background: var(--t1); }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--soft); font-weight: 500; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 72px 0 24px; }
.sec-head h2 { font-size: clamp(1.5rem, 3.4vw, 2.2rem); display: flex; align-items: center; gap: 12px; }
.sec-head h2 i { width: 14px; height: 14px; border-radius: 50%; background: var(--brand); flex: none; }
.sec-head a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border-radius: 99px; background: var(--card); box-shadow: var(--shadow); font-weight: 700; font-size: 14px; white-space: nowrap; transition: background .2s, color .2s; }
.sec-head a:hover { background: var(--ink); color: #fff; }
.thumb { position: relative; display: block; overflow: hidden; background: var(--bg); aspect-ratio: 3 / 2; border-radius: var(--r-md); }
.thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--ease); }
.ph { width: 100%; height: 100%; display: grid; place-items: center; font-weight: 800; font-size: 56px; color: rgba(20, 20, 26, .18); }
.btn { display: inline-flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 28px; background: var(--ink); color: #fff; border-radius: 99px; font: 700 15px var(--font); border: 0; cursor: pointer; transition: background .2s, color .2s, transform .2s var(--ease); }
.btn:hover { background: var(--brand); color: var(--ink); transform: translateY(-2px); }

/* ---------- Intro ---------- */
.intro { padding: 56px 0 8px; text-align: center; }
.intro h1 { font-size: clamp(2.1rem, 6.4vw, 4.4rem); max-width: 20ch; margin-inline: auto; text-wrap: balance; }
.intro h1 em { white-space: nowrap; font-style: normal; background: var(--t5); padding: 0 .18em; border-radius: .22em; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.intro p { color: var(--soft); font-size: clamp(1rem, 2vw, 1.15rem); max-width: 52ch; margin: 18px auto 0; }
.topics { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 28px; }
.topics a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 99px; font-weight: 700; font-size: 14px; transition: transform .2s var(--ease), box-shadow .2s; }
.topics a:hover { transform: translateY(-3px) rotate(-1.5deg); box-shadow: var(--shadow); }
.topics small { font-weight: 600; opacity: .6; }

/* ---------- Bento ---------- */
.bento { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: minmax(210px, auto); gap: 16px; margin-top: 40px; }
.b { position: relative; border-radius: var(--r-lg); overflow: hidden; transition: transform .3s var(--ease), box-shadow .3s; }
.b:hover { transform: translateY(-4px) scale(1.01); box-shadow: 0 16px 40px rgba(20, 20, 26, .14); }
.b a.cover { position: absolute; inset: 0; z-index: 3; border-radius: inherit; }
.b--lead { grid-column: span 2; grid-row: span 2; min-height: 440px; background: var(--ink); color: #fff; display: flex; align-items: flex-end; }
.b--lead img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .8s var(--ease); }
.b--lead:hover img { transform: scale(1.05); }
.b--lead::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, rgba(10, 10, 14, .88), rgba(10, 10, 14, .25) 55%, transparent); }
.b--lead .b__body { position: relative; z-index: 2; padding: clamp(20px, 3vw, 36px); }
.b--lead h2 { font-size: clamp(1.6rem, 3.2vw, 2.5rem); margin: 14px 0 10px; text-wrap: balance; }
.b--lead .meta { color: rgba(255, 255, 255, .8); }
.b--lead .chip { background: #fff; }
.b--sm { padding: 22px; display: flex; flex-direction: column; justify-content: space-between; gap: 14px; }
.b--sm h3 { font-size: 1.2rem; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; margin-top: 12px; }
.b--wide { grid-column: span 2; display: grid; grid-template-columns: 1fr 1fr; }
.b--wide .b__body { padding: 22px; display: flex; flex-direction: column; justify-content: space-between; gap: 14px; }
.b--wide h3 { font-size: 1.3rem; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; margin-top: 12px; }
.b--wide .pic { position: relative; min-height: 180px; }
.b--wide .pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--ease); }
.b--wide:hover .pic img { transform: scale(1.06); }

/* ---------- Topic tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 16px; }
.tile { position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 150px; padding: 20px; border-radius: var(--r-md); transition: transform .25s var(--ease); }
.tile:hover { transform: translateY(-4px) rotate(-1deg); }
.tile b { font-size: 1.15rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.tile span { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; }
.tile .go { width: 36px; height: 36px; display: grid; place-items: center; background: rgba(255, 255, 255, .7); border-radius: 50%; }

/* ---------- Cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); gap: 20px; }
.grid--3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); }
.card { position: relative; display: flex; flex-direction: column; gap: 14px; padding: 12px 12px 20px; background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow); transition: transform .3s var(--ease), box-shadow .3s; }
.card:hover { transform: translateY(-5px); box-shadow: 0 16px 40px rgba(20, 20, 26, .12); }
.card:hover .thumb img, .row:hover .thumb img { transform: scale(1.06); }
.card__body { padding: 0 10px; display: flex; flex-direction: column; gap: 10px; flex: 1; align-items: flex-start; }
.card__title { font-size: 1.1rem; line-height: 1.32; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card__title a::after, .row__title a::after { content: ''; position: absolute; inset: 0; border-radius: inherit; z-index: 2; }
.card .meta { margin-top: auto; }

.rows { display: grid; gap: 12px; }
.row { position: relative; display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: center; padding: 12px; background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow); transition: transform .25s var(--ease), box-shadow .25s; }
.row:hover { transform: translateX(4px); box-shadow: 0 12px 32px rgba(20, 20, 26, .1); }
.row__body { padding: 8px 16px 8px 0; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.row__title { font-size: 1.35rem; }
.row__excerpt { color: var(--soft); margin: 0; font-size: .95rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Pagination / empty / page head ---------- */
.pagination { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 40px 0 0; }
.pagination .page-numbers { min-width: 48px; height: 48px; display: grid; place-items: center; padding: 0 16px; border-radius: 99px; background: var(--card); box-shadow: var(--shadow); font-weight: 700; transition: background .2s, color .2s; }
.pagination a.page-numbers:hover { background: var(--t5); }
.pagination .current { background: var(--ink); color: #fff; }
.page-head { margin: 56px 0 32px; }
.page-head h1 { font-size: clamp(2.2rem, 6vw, 3.8rem); }
.page-head p { color: var(--soft); margin: 12px 0 0; max-width: 60ch; }
.empty { text-align: center; padding: 72px 20px; background: var(--card); border-radius: var(--r-lg); margin-top: 32px; }
.empty .big { font-weight: 800; font-size: clamp(5rem, 20vw, 9rem); line-height: 1; letter-spacing: -.05em; }
.empty h2 { margin: 8px 0; }
.empty p { color: var(--soft); }
.empty .btn { margin-top: 12px; }
.empty .searchform { max-width: 480px; margin: 20px auto 0; }

/* ---------- Article ---------- */
.progress { position: fixed; top: 0; left: 0; height: 4px; width: 0; background: var(--brand); z-index: 100; border-radius: 0 4px 4px 0; }
.article { margin: 32px 0 56px; }
.article__head { max-width: 860px; margin: 0 auto 28px; text-align: center; }
.article__head .chip { margin-bottom: 18px; }
.article__title { font-size: clamp(2rem, 5.5vw, 3.6rem); text-wrap: balance; margin-bottom: 18px; }
.article__head .meta { justify-content: center; }
.article__cover { max-width: 1040px; margin: 0 auto 40px; border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); background: var(--card); }
.article__cover img { width: 100%; }
.article__layout { display: grid; grid-template-columns: minmax(0, 720px); justify-content: center; gap: 40px; }
.article__side { display: none; }
.sheet-card { background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: clamp(22px, 4vw, 48px); }
.entry { font-size: 1.08rem; line-height: 1.85; overflow-wrap: anywhere; }
.entry > * { margin-top: 0; margin-bottom: 1.15em; }
.entry > *:last-child { margin-bottom: 0; }
.entry h2 { font-size: 1.75rem; margin-top: 1.9em; scroll-margin-top: 100px; }
.entry h3 { font-size: 1.35rem; margin-top: 1.5em; scroll-margin-top: 100px; }
.entry h4 { font-size: 1.1rem; }
.entry a { color: var(--brand-dk); font-weight: 600; text-decoration: underline; text-decoration-color: rgba(194, 65, 12, .35); text-decoration-thickness: 2px; text-underline-offset: 3px; transition: text-decoration-color .2s; }
.entry a:hover { text-decoration-color: var(--brand-dk); }
.entry img { margin: 1.6em auto; border-radius: var(--r-md); height: auto; max-width: 100%; }
.entry .wp-caption, .entry figure, .entry div, .entry p, .entry table { max-width: 100% !important; }
.entry .wp-caption, .entry figure { width: auto !important; }
.entry .wp-caption img { width: 100%; }
.entry figure { margin: 1.6em 0; }
.entry figcaption { font-size: 13px; color: var(--soft); text-align: center; margin-top: 8px; }
.entry blockquote { margin: 1.6em 0; padding: 22px 26px; background: var(--t5); border-radius: var(--r-md); font-weight: 600; }
.entry blockquote p:last-child { margin: 0; }
.entry ul, .entry ol { padding-left: 1.4em; }
.entry li { margin-bottom: .45em; }
.entry li::marker { color: var(--brand); font-weight: 800; }
.entry table { display: block; max-width: 100%; overflow-x: auto; border-collapse: separate; border-spacing: 0; font-size: .95rem; }
.entry th, .entry td { border-bottom: 1px solid var(--line); padding: 12px 16px; text-align: left; }
.entry th { background: var(--bg); font-weight: 800; }
.entry code, .entry pre { font: .88em ui-monospace, Menlo, monospace; background: var(--bg); border-radius: 8px; }
.entry code { padding: 2px 7px; }
.entry pre { padding: 16px; overflow-x: auto; }
.entry iframe { width: 100%; border-radius: var(--r-md); }
.toc { background: var(--card); border-radius: var(--r-md); box-shadow: var(--shadow); }
.toc summary { cursor: pointer; padding: 14px 20px; min-height: 52px; font-weight: 800; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.toc summary::-webkit-details-marker { display: none; }
.toc summary::after { content: '+'; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--bg); font-size: 18px; }
.toc[open] summary::after { content: '–'; }
.toc ol { list-style: none; margin: 0; padding: 0 12px 14px; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc li.sub { padding-left: 18px; }
.toc a { display: flex; gap: 10px; padding: 8px 10px; border-radius: 12px; font-size: 14.5px; font-weight: 600; line-height: 1.4; color: var(--soft); transition: background .2s, color .2s; }
.toc li:not(.sub) a::before { content: counter(toc); flex: none; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--t1); color: var(--ink); font-size: 12px; font-weight: 800; }
.toc a:hover, .toc a.on { background: var(--bg); color: var(--ink); }
.article__main > .toc { margin-bottom: 20px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; }
.tags a { padding: 6px 14px; border-radius: 99px; background: var(--bg); font-size: 13px; font-weight: 600; }
.tags a:hover { background: var(--t5); }

/* ---------- Comments ---------- */
.comments { max-width: 720px; margin: 0 auto 56px; background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: clamp(22px, 4vw, 40px); }
.comments h2, .comment-reply-title { font-size: 1.5rem; margin-bottom: 20px; }
.comment-list { list-style: none; padding: 0; }
.comment-list .children { list-style: none; padding-left: 20px; }
.comment-body { padding: 16px 0; border-bottom: 1px solid var(--line); }
.comment-author .avatar { float: left; margin-right: 12px; border-radius: 50%; }
.comment-metadata { font-size: 12px; color: var(--soft); }
.comment-form label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.comment-form input[type="text"], .comment-form input[type="email"], .comment-form input[type="url"], .comment-form textarea { width: 100%; padding: 14px 18px; border: 2px solid transparent; background: var(--bg); border-radius: var(--r-sm); font: inherit; }
.comment-form input:focus, .comment-form textarea:focus { outline: none; border-color: var(--ink); background: #fff; }
.comment-form .submit { min-height: 52px; padding: 0 28px; background: var(--ink); color: #fff; border: 0; border-radius: 99px; font: 700 15px var(--font); cursor: pointer; }
.comment-form .submit:hover { background: var(--brand); color: var(--ink); }

/* ---------- Footer ---------- */
.site-footer { margin: 80px 0 16px; }
.foot { background: var(--ink); color: #c9c9d3; border-radius: 40px; padding: clamp(28px, 5vw, 56px); display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 40px; }
.foot .brand { color: #fff; font-size: 1.6rem; }
.foot .brand span b { color: var(--brand); }
.foot p { color: #9a9aa8; max-width: 40ch; margin: 16px 0 0; }
.foot h3 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: #fff; margin-bottom: 12px; }
.foot ul { list-style: none; margin: 0; padding: 0; }
.foot li a { display: inline-flex; align-items: center; min-height: 38px; color: #9a9aa8; transition: color .2s, transform .2s; }
.foot li a:hover { color: var(--brand); transform: translateX(4px); }
.copy { text-align: center; font-size: 13px; color: var(--soft); margin: 20px 0 0; }

/* ---------- Responsive ---------- */
@media (min-width: 1180px) {
  .article__layout { grid-template-columns: 260px minmax(0, 720px); justify-content: center; align-items: start; }
  .article__side { display: block; position: sticky; top: 100px; order: -1; }
  .article__main > .toc { display: none; }
}
@media (max-width: 960px) {
  .nav { display: none; }
  .menu-toggle { display: grid; }
  .pill { padding-left: 12px; }
  .brand { margin-right: auto; }
  .sheet .menu-list { display: flex; }
  .bento { grid-template-columns: repeat(2, 1fr); }
  .b--lead { grid-column: span 2; min-height: 380px; }
  .foot { grid-template-columns: 1fr 1fr; border-radius: 32px; }
  .foot > :first-child { grid-column: span 2; }
}
@media (max-width: 600px) {
  .bento { grid-template-columns: 1fr; grid-auto-rows: auto; }
  .b--lead, .b--wide { grid-column: auto; }
  .b--wide { grid-template-columns: 1fr; }
  .b--wide .pic { order: -1; min-height: 180px; }
  .row { grid-template-columns: 112px 1fr; gap: 14px; padding: 10px; }
  .row .thumb { border-radius: 16px; }
  .row__title { font-size: 1.02rem; }
  .row__excerpt { display: none; }
  .row__body { padding: 0 6px 0 0; }
  .foot { grid-template-columns: 1fr; }
  .foot > :first-child { grid-column: auto; }
  .intro { padding-top: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .b:hover, .card:hover, .row:hover, .tile:hover, .topics a:hover { transform: none; }
}
.b--sm .chip, .b--wide .chip { background: rgba(255, 255, 255, .78); }
.ph.t1 { background: var(--t1); } .ph.t2 { background: var(--t2); } .ph.t3 { background: var(--t3); } .ph.t4 { background: var(--t4); } .ph.t5 { background: var(--t5); } .ph.t6 { background: var(--t6); }
.sheet #dot, .sheet .ping { display: none; }
