/* ============================================================
   Chi tiết bài viết — /bai-viet/{slug}  (themesieuviet / Win Ora)
   Namespace pd-*. Nạp KÈM posts.css để dùng chung ngôn ngữ thẻ với trang
   danh sách: .news-card, .news-tag, .news-btn, .news-meta, .news-category-list,
   .nw-h2, .nw-section-head — cùng token, cùng accent, không dựng lại từ đầu.

   Glass đồng bộ header/footer: alpha .55–.74, blur 16–20px, saturate 155–160%.
   Accent DUY NHẤT: var(--site-primary…). Không màu thứ hai.

   GIỮ NGUYÊN tên class mà nơi khác bám vào:
     .pd-hero        (header.css cấp padding-top 120px — nguồn duy nhất)
     .news-container (alias .site-container trong app.css)
   ============================================================ */

.pd-page {
    color: #0f172b;
    background: #fff;
    /* clip (không phải hidden): hidden biến thẻ này thành scroll container và
       position:sticky của sidebar sẽ chết. clip cắt tràn ngang mà không tạo
       scroll container nên sticky vẫn chạy. */
    overflow-x: clip;
}

.pd-page section,
.pd-page header {
    position: relative;
}

/* ---- Reveal (gate .pd-anim; no-JS / reduced-motion → hiện đủ) ---- */
.pd-anim [data-reveal] {
    opacity: 0;
    transform: translateY(22px);
    transition: opacity .55s cubic-bezier(.16, 1, .3, 1), transform .55s cubic-bezier(.16, 1, .3, 1);
}

.pd-anim [data-reveal].is-in {
    opacity: 1;
    transform: none;
}

@media (prefers-reduced-motion: reduce) {
    .pd-anim [data-reveal] {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }

    .pd-page * {
        animation: none !important;
        transition: none !important;
    }
}

/* ---- Focus ring (a11y) ---- */
.pd-page a:focus-visible,
.pd-page button:focus-visible,
.pd-page summary:focus-visible {
    outline: 3px solid rgba(var(--site-primary-rgb, 220, 38, 38), .45);
    outline-offset: 2px;
    border-radius: 8px;
}

/* =========================================================================
   1) HEADER BÀI VIẾT — breadcrumb + danh mục + H1 + meta + ảnh bìa
   ========================================================================= */
.pd-hero {
    /* padding-top do header.css (.pd-hero → 120px) quản lý — nguồn duy nhất.
       Wash tông site, fade về trắng ở mép dưới để không tạo đường kẻ với thân bài. */
    padding-bottom: 40px;
    background:
        linear-gradient(180deg,
            rgba(var(--site-primary-rgb, 220, 38, 38), .05) 0,
            rgba(var(--site-primary-rgb, 220, 38, 38), .05) calc(100% - 180px),
            rgba(var(--site-primary-rgb, 220, 38, 38), 0) 100%),
        #ffffff;
}

.pd-crumb {
    margin-bottom: 22px;
}

.pd-crumb ol {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
    color: #94a3b8;
    font-size: 13px;
    font-weight: 600;
}

.pd-crumb li+li::before {
    content: '/';
    margin-right: 6px;
    color: #cbd5e1;
}

.pd-crumb a {
    color: #64748b;
    text-decoration: none;
    transition: color .2s ease;
}

.pd-crumb a:hover {
    color: var(--site-primary, #dc2626);
}

.pd-crumb [aria-current='page'] {
    color: #0f172b;
    font-weight: 700;
}

.pd-hero__head {
    max-width: 860px;
}

.pd-hero__tag {
    text-decoration: none;
    transition: transform .2s ease;
}

.pd-hero__tag:hover {
    transform: translateY(-1px);
}

.pd-title {
    margin: 14px 0 0;
    color: #0f172b;
    font-size: clamp(27px, 3.5vw, 44px);
    font-weight: 900;
    line-height: 1.15;
    letter-spacing: -.022em;
    text-wrap: balance;
}

.pd-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 20px;
    margin-top: 20px;
    color: #94a3b8;
    font-size: 13px;
    font-weight: 600;
}

.pd-meta__item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.pd-meta__item svg {
    width: 15px;
    height: 15px;
}

.pd-meta time {
    font-variant-numeric: tabular-nums;
}

.pd-meta__author {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding-right: 20px;
    border-right: 1px solid rgba(15, 23, 43, .1);
    color: #0f172b;
    font-weight: 800;
}

.pd-meta__author img {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    object-fit: contain;
    background: #fff;
    border: 1px solid rgba(15, 23, 43, .08);
    padding: 2px;
}

.pd-cover {
    margin: 32px 0 0;
    overflow: hidden;
    border-radius: 24px;
    aspect-ratio: 16 / 8;
    background: #f1f5f9;
    box-shadow: 0 24px 60px rgba(15, 23, 43, .14), 0 0 0 1px rgba(255, 255, 255, .7);
}

.pd-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* =========================================================================
   2) THÂN BÀI — 2 cột (nội dung + sidebar dính)
   ========================================================================= */
.pd-body {
    padding: 40px 0 24px;
}

.pd-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 36px;
    align-items: start;
}

.pd-main {
    min-width: 0;
}

@media (min-width: 1080px) {
    .pd-layout {
        grid-template-columns: minmax(0, 1fr) minmax(0, 320px);
        gap: 48px;
    }

    .pd-sidebar {
        /* align-self: start là BẮT BUỘC — mặc định grid item bị kéo cao bằng hàng,
           sticky hết chỗ trượt và đứng im. */
        position: sticky;
        top: 100px;
        align-self: start;
        max-height: calc(100dvh - 132px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

@media (max-width: 1079px) {

    /* Dưới 1080px lưới sập về 1 cột nên sidebar xếp XUỐNG DƯỚI bài. Mục lục sidebar
       phải tắt, nếu không trang có HAI mục lục (accordion ở đầu + list ở cuối). */
    .pd-toc {
        display: none;
    }

    /* Cột nội dung ghìm ở 68ch (~720px); trong container 960px của tablet nó sẽ
       dạt hẳn sang trái. Căn giữa cả khối cho cân. */
    .pd-main,
    .pd-sidebar {
        width: 100%;
        margin-inline: auto;
        padding-left: 16px;
        padding-right: 16px;
    }
}

/* ---- Mục lục thu gọn (mobile) ---- */
.pd-toc-mobile {
    margin-bottom: 26px;
    border-radius: 16px;
    background: rgba(255, 255, 255, .6);
    border: 1px solid rgba(255, 255, 255, .74);
    box-shadow: 0 10px 26px rgba(15, 23, 43, .07), inset 0 1px 0 rgba(255, 255, 255, .86);
    -webkit-backdrop-filter: blur(16px) saturate(158%);
    backdrop-filter: blur(16px) saturate(158%);
}

.pd-toc-mobile summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 18px;
    cursor: pointer;
    list-style: none;
    color: #0f172b;
    font-size: 14.5px;
    font-weight: 800;
}

.pd-toc-mobile summary::-webkit-details-marker {
    display: none;
}

.pd-toc-mobile summary::after {
    content: '';
    width: 9px;
    height: 9px;
    flex-shrink: 0;
    border-right: 2px solid #94a3b8;
    border-bottom: 2px solid #94a3b8;
    transform: rotate(45deg) translateY(-2px);
    transition: transform .25s ease;
}

.pd-toc-mobile[open] summary::after {
    transform: rotate(-135deg) translateY(-2px);
}

.pd-toc-mobile__count {
    margin-left: auto;
    color: var(--site-primary, #dc2626);
    font-size: 12px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.pd-toc-mobile .pd-toc__list {
    padding: 0 18px 16px;
}

/* Ẩn cả thẻ <nav> bao ngoài, không chỉ <details> — bỏ sót thì desktop còn lại một
   <nav> rỗng trong cây accessibility. */
@media (min-width: 1080px) {
    .pd-toc-m {
        display: none;
    }
}

/* ---- Mục lục sidebar + scrollspy ---- */
.pd-side {
    border-radius: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, .62);
    border: 1px solid rgba(255, 255, 255, .74);
    box-shadow: 0 12px 32px rgba(15, 23, 43, .07), inset 0 1px 0 rgba(255, 255, 255, .86);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    backdrop-filter: blur(18px) saturate(160%);
}

.pd-side+.pd-side {
    margin-top: 20px;
}

.pd-side__title {
    margin: 0 0 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(15, 23, 43, .07);
    color: #0f172b;
    font-size: 15px;
    font-weight: 900;
    letter-spacing: -.01em;
}

.pd-toc__list {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: pd-toc;
    display: grid;
    gap: 2px;
}

.pd-toc__list a {
    position: relative;
    display: block;
    padding: 8px 10px 8px 26px;
    border-radius: 9px;
    color: #64748b;
    font-size: 13.4px;
    font-weight: 600;
    line-height: 1.5;
    text-decoration: none;
    counter-increment: pd-toc;
    transition: color .2s ease, background .2s ease;
}

.pd-toc__list a::before {
    /* Vạch chỉ mục — vào/ra bằng transform (GPU), không animate width/background. */
    content: '';
    position: absolute;
    left: 10px;
    top: 9px;
    bottom: 9px;
    width: 2px;
    border-radius: 2px;
    background: var(--site-primary, #dc2626);
    transform: scaleY(0);
    transform-origin: top center;
    transition: transform .28s cubic-bezier(.16, 1, .3, 1);
}

.pd-toc__list a:hover {
    color: #0f172b;
    background: rgba(var(--site-primary-rgb, 220, 38, 38), .05);
}

.pd-toc__list a.is-active {
    color: var(--site-primary, #dc2626);
    font-weight: 800;
    background: rgba(var(--site-primary-rgb, 220, 38, 38), .07);
}

.pd-toc__list a.is-active::before {
    transform: scaleY(1);
}

/* =========================================================================
   3) CHIA SẺ
   ========================================================================= */
.pd-share {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 30px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(15, 23, 43, .07);
}

.pd-share__label {
    margin-right: 4px;
    color: #94a3b8;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.pd-share__btn {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, .74);
    border-radius: 999px;
    background: rgba(255, 255, 255, .6);
    box-shadow: 0 6px 18px rgba(15, 23, 43, .08), inset 0 1px 0 rgba(255, 255, 255, .85);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    backdrop-filter: blur(16px) saturate(160%);
    color: #475569;
    cursor: pointer;
    transition: transform .2s ease, color .2s ease, box-shadow .2s ease;
}

.pd-share__btn svg {
    width: 17px;
    height: 17px;
}

.pd-share__btn:hover {
    transform: translateY(-2px);
    color: var(--site-primary, #dc2626);
    box-shadow: 0 12px 26px rgba(var(--site-primary-rgb, 220, 38, 38), .22), inset 0 1px 0 rgba(255, 255, 255, .9);
}

.pd-share__copy.is-copied {
    color: var(--site-primary, #dc2626);
}

.pd-share__copied {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    padding: 0 10px;
    border-radius: 8px;
    background: #0f172b;
    color: #fff;
    font-size: 11.5px;
    font-weight: 700;
    line-height: 24px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}

.pd-share__copy.is-copied .pd-share__copied {
    opacity: 1;
}

/* =========================================================================
   4) NỘI DUNG BÀI — typography ưu tiên KHẢ NĂNG ĐỌC
   ========================================================================= */
.pd-content {
    /* Cột nội dung rộng ~880px trên desktop là quá dài để đọc thoải mái.
       Ghìm về ~68 ký tự/dòng. */
    /* max-width: 68ch; */
    color: #334155;
    font-size: 16.8px;
    line-height: 1.85;
}

.pd-content>*:first-child {
    margin-top: 0;
}

.pd-content h2 {
    /* scroll-margin-top: header nổi cao ~96px sẽ che mất heading khi nhảy
       anchor từ mục lục nếu không chừa khoảng này. */
    scroll-margin-top: 116px;
    margin: 46px 0 14px;
    color: #0f172b;
    font-size: clamp(21px, 2.1vw, 27px);
    font-weight: 900;
    line-height: 1.25;
    letter-spacing: -.015em;
    text-wrap: balance;
}

.pd-content h3 {
    scroll-margin-top: 116px;
    margin: 32px 0 10px;
    color: #0f172b;
    font-size: clamp(17.5px, 1.6vw, 20px);
    font-weight: 800;
    line-height: 1.35;
}

.pd-content h4,
.pd-content h5,
.pd-content h6 {
    scroll-margin-top: 116px;
    margin: 26px 0 8px;
    color: #0f172b;
    font-size: 16.5px;
    font-weight: 800;
}

.pd-content p {
    margin: 0 0 18px;
}

.pd-content ul,
.pd-content ol {
    margin: 0 0 20px;
    padding-left: 22px;
}

.pd-content li {
    margin-bottom: 9px;
}

.pd-content li::marker {
    color: var(--site-primary, #dc2626);
    font-weight: 700;
}

.pd-content strong {
    color: #0f172b;
    font-weight: 700;
}

.pd-content a {
    color: var(--site-primary, #dc2626);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}

.pd-content a:hover {
    text-decoration-thickness: 2px;
}

.pd-content img {
    width: 100%;
    margin: 26px 0;
    border-radius: 18px;
    box-shadow: 0 16px 40px rgba(15, 23, 43, .1);
}

.pd-content blockquote {
    margin: 26px 0;
    padding: 18px 22px;
    border-left: 3px solid var(--site-primary, #dc2626);
    border-radius: 0 14px 14px 0;
    background: rgba(var(--site-primary-rgb, 220, 38, 38), .05);
    color: #0f172b;
    font-size: 17px;
}

.pd-content blockquote p:last-child {
    margin-bottom: 0;
}

.pd-content table {
    width: 100%;
    margin: 24px 0;
    border-collapse: collapse;
    font-size: 15px;
}

.pd-content th,
.pd-content td {
    padding: 11px 14px;
    border: 1px solid rgba(15, 23, 43, .1);
    text-align: left;
}

.pd-content th {
    background: rgba(var(--site-primary-rgb, 220, 38, 38), .06);
    color: #0f172b;
    font-weight: 800;
}

.pd-content pre {
    margin: 24px 0;
    padding: 18px;
    overflow-x: auto;
    border-radius: 14px;
    background: #0f172b;
    color: #e2e8f0;
    font-size: 14px;
    line-height: 1.7;
}

.pd-content hr {
    margin: 34px 0;
    border: 0;
    border-top: 1px solid rgba(15, 23, 43, .1);
}

/* =========================================================================
   5) TÁC GIẢ (E-E-A-T)
   ========================================================================= */
.pd-author {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 18px;
    align-items: start;
    /* max-width: 68ch; */
    margin-top: 48px;
    padding: 24px;
    border-radius: 20px;
    background: rgba(255, 255, 255, .62);
    border: 1px solid rgba(255, 255, 255, .74);
    box-shadow: 0 14px 36px rgba(15, 23, 43, .08), inset 0 1px 0 rgba(255, 255, 255, .86);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    backdrop-filter: blur(18px) saturate(160%);
}

.pd-author__avatar {
    width: 72px;
    height: 72px;
    border-radius: 999px;
    object-fit: contain;
    padding: 6px;
    background: #fff;
    border: 1px solid rgba(15, 23, 43, .08);
    box-shadow: 0 6px 16px rgba(15, 23, 43, .08);
}

.pd-author__name {
    margin: 0;
    color: #0f172b;
    font-size: 17px;
    font-weight: 900;
    letter-spacing: -.01em;
}

.pd-author__role {
    margin: 3px 0 10px;
    color: var(--site-primary, #dc2626);
    font-size: 12.5px;
    font-weight: 800;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.pd-author__bio {
    margin: 0;
    color: #64748b;
    font-size: 14.5px;
    line-height: 1.7;
}

/* =========================================================================
   6) CTA sau nội dung
   ========================================================================= */
.pd-cta {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    align-items: center;
    /* max-width: 68ch; */
    margin-top: 26px;
    padding: 28px;
    border-radius: 22px;
    background:
        radial-gradient(460px 260px at 100% 0, rgba(var(--site-primary-rgb, 220, 38, 38), .14), transparent 65%),
        rgba(255, 255, 255, .66);
    border: 1px solid rgba(255, 255, 255, .74);
    box-shadow: 0 20px 46px rgba(15, 23, 43, .1), inset 0 1px 0 rgba(255, 255, 255, .9);
    -webkit-backdrop-filter: blur(20px) saturate(158%);
    backdrop-filter: blur(20px) saturate(158%);
}

.pd-cta__body h2 {
    margin: 0;
    color: #0f172b;
    font-size: clamp(19px, 2vw, 23px);
    font-weight: 900;
    line-height: 1.3;
    letter-spacing: -.015em;
    text-wrap: balance;
}

.pd-cta__body p {
    margin: 8px 0 0;
    color: #64748b;
    font-size: 14.5px;
    line-height: 1.65;
}

.pd-cta__btn {
    align-self: start;
    white-space: nowrap;
}

.pd-cta__btn svg {
    width: 17px;
    height: 17px;
    transition: transform .2s ease;
}

.pd-cta__btn:hover svg {
    transform: translateX(3px);
}

@media (min-width: 720px) {
    .pd-cta {
        grid-template-columns: minmax(0, 1fr) auto;
        padding: 30px 32px;
    }

    .pd-cta__btn {
        align-self: center;
    }
}

/* =========================================================================
   7) BÀI VIẾT LIÊN QUAN — 1 lớn + 2 nhỏ (KHÔNG "3 card đều một hàng")
   ========================================================================= */
.pd-related {
    padding: 56px 0 76px;
    background:
        linear-gradient(180deg,
            rgba(var(--site-primary-rgb, 220, 38, 38), 0) 0,
            rgba(var(--site-primary-rgb, 220, 38, 38), .045) 110px,
            rgba(var(--site-primary-rgb, 220, 38, 38), .045) calc(100% - 110px),
            rgba(var(--site-primary-rgb, 220, 38, 38), 0) 100%),
        #ffffff;
}

.pd-related__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.pd-related__grid.is-even {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}

@media (min-width: 860px) {

    /* 2 cột × 2 hàng: thẻ lớn chiếm trọn cột trái, 2 thẻ nhỏ xếp cột phải.
       Đúng 3 ô cho 3 bài — lưới khít, không ô trống. */
    .pd-related__grid.is-feature {
        grid-template-columns: 1.32fr 1fr;
        grid-auto-rows: minmax(0, 1fr);
    }

    .pd-related__grid.is-feature>.pd-related__card:first-child {
        grid-row: span 2;
    }

    /* Hai thẻ nhỏ đổi sang dạng ngang (ảnh trái, chữ phải) để khác hình dạng
       với thẻ lớn — cùng token .news-card, khác bố cục. */
    .pd-related__grid.is-feature>.pd-related__card:not(:first-child) {
        display: grid;
        grid-template-columns: 148px minmax(0, 1fr);
    }

    .pd-related__grid.is-feature>.pd-related__card:not(:first-child) .news-card-img {
        height: 100%;
        aspect-ratio: auto;
    }

    .pd-related__grid.is-feature>.pd-related__card:not(:first-child) .news-card-body {
        padding: 16px 18px;
    }

    .pd-related__grid.is-feature>.pd-related__card:first-child .news-card-img {
        aspect-ratio: 16 / 9;
    }

    .pd-related__grid.is-feature>.pd-related__card:first-child .news-card-body h3 {
        font-size: 19px;
    }
}

/* ---- Fallback khi trình duyệt không hỗ trợ backdrop-filter ---- */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {

    .pd-side,
    .pd-toc-mobile,
    .pd-share__btn,
    .pd-author {
        background: rgba(255, 255, 255, .93);
    }

    .pd-cta {
        background: rgba(255, 255, 255, .95);
    }
}
