/* ==========================================================================
   Mẫu hồ sơ năng lực — lưới trưng bày và trình xem sách lật
   Vanilla CSS, không phụ thuộc framework của trang quản trị.
   ========================================================================== */

.ps-root {
    /* Kế thừa màu nhấn của theme (partial css-variable-declare), có màu lùi an toàn. */
    --ps-primary: var(--primary-color, #F7A400);
    --ps-ink: #1f2933;
    --ps-muted: #6b7280;
    --ps-border: #e5e7eb;
    --ps-bg-card: #fff;
    --ps-radius: 10px;
}

/* ---------- Lưới thẻ mẫu ---------- */
.ps-grid {
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 768px) {
    .ps-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .ps-grid--4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1100px) {
    .ps-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.ps-card {
    display: flex;
    flex-direction: column;
    background: var(--ps-bg-card);
    border: 1px solid var(--ps-border);
    border-radius: var(--ps-radius);
    overflow: hidden;
    transition: transform .18s ease, box-shadow .18s ease;
}

.ps-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(15, 23, 42, .12);
}

.ps-card__thumb {
    position: relative;
    display: block;
    background: #f3f4f6;
    /* aspect-ratio đặt inline theo tỉ lệ trang thật để không gây CLS. */
}

.ps-card__thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ps-card__badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(17, 24, 39, .78);
    color: #fff;
    font-size: 12px;
    line-height: 1.6;
}

.ps-card__body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px 18px;
    flex: 1;
}

.ps-card__title {
    margin: 0;
    font-size: 16px;
    line-height: 1.4;
    color: var(--ps-ink);
}

.ps-card__title a { color: inherit; text-decoration: none; }
.ps-card__title a:hover { color: var(--ps-primary); }

.ps-card__meta {
    font-size: 13px;
    color: var(--ps-muted);
}

.ps-card__actions { margin-top: auto; padding-top: 12px; }

.ps-btn {
    display: inline-block;
    padding: 9px 18px;
    border: 0;
    border-radius: 6px;
    background: var(--ps-primary);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.ps-btn:hover { filter: brightness(1.08); color: #fff; }

.ps-btn--ghost {
    background: transparent;
    border: 1px solid var(--ps-border);
    color: var(--ps-ink);
}

/* ---------- Tab lọc theo ngành ---------- */
.ps-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.ps-filter__item {
    padding: 7px 16px;
    border: 1px solid var(--ps-border);
    border-radius: 999px;
    background: #fff;
    color: var(--ps-ink);
    font-size: 14px;
    text-decoration: none;
}

.ps-filter__item[aria-current="true"] {
    background: var(--ps-primary);
    border-color: var(--ps-primary);
    color: #fff;
}

/* ---------- Khung sách lật ---------- */
.ps-book-wrap {
    position: relative;
    display: flex;
    justify-content: center;
    padding: 8px 0 26px;
}

.ps-book { margin: 0 auto; }

/* Bóng đổ dưới cuốn sách. */
.ps-book-wrap::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 8px;
    width: min(70%, 720px);
    height: 26px;
    transform: translateX(-50%);
    background: radial-gradient(ellipse at center, rgba(15, 23, 42, .34) 0%, rgba(15, 23, 42, 0) 72%);
    pointer-events: none;
}

.ps-page {
    background: #fff;
    overflow: hidden;
}

.ps-page img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
}

/* Gáy sách: dải tối chạy dọc giữa spread. Ẩn ở chế độ 1 trang. */
.ps-spine {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 56px;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 5;
    background: linear-gradient(
        to right,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, .16) 42%,
        rgba(0, 0, 0, .28) 50%,
        rgba(0, 0, 0, .16) 58%,
        rgba(0, 0, 0, 0) 100%
    );
}

.ps-viewer[data-portrait="true"] .ps-spine,
.ps-viewer[data-single="true"] .ps-spine { display: none; }

/* ---------- Thanh điều khiển ---------- */
.ps-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 0 0;
}

.ps-toolbar button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--ps-border);
    border-radius: 6px;
    background: #fff;
    color: var(--ps-ink);
    font-size: 15px;
    cursor: pointer;
}

.ps-toolbar button:hover:not(:disabled) { border-color: var(--ps-primary); color: var(--ps-primary); }
.ps-toolbar button:disabled { opacity: .45; cursor: default; }

.ps-toolbar__counter {
    min-width: 96px;
    padding: 0 12px;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    text-align: center;
    color: var(--ps-muted);
}

/* Mũi tên hai bên sách. */
.ps-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 6;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .92);
    box-shadow: 0 2px 10px rgba(15, 23, 42, .2);
    color: var(--ps-ink);
    font-size: 20px;
    line-height: 44px;
    cursor: pointer;
}

.ps-nav[hidden] { display: none; }
.ps-nav--prev { left: 4px; }
.ps-nav--next { right: 4px; }

/* ---------- Lớp phủ toàn màn hình ---------- */
.ps-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Chừa chỗ phía trên cho nút đóng và phía dưới cho thanh công cụ. */
    padding: 60px 16px 24px;
    background: rgba(38, 42, 48, .92);
}

.ps-overlay[hidden] { display: none; }

.ps-overlay__inner {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1100px;
    /* Giới hạn theo chiều cao màn hình để toolbar không bị đẩy khỏi khung nhìn. */
    max-height: 100%;
    min-height: 0;
}

/* Khung sách co giãn trong phần không gian còn lại. */
.ps-overlay .ps-book-wrap {
    flex: 1 1 auto;
    min-height: 0;
    align-items: center;
    padding-bottom: 10px;
}

.ps-overlay .ps-toolbar { flex: 0 0 auto; }

.ps-overlay .ps-toolbar button {
    background: rgba(255, 255, 255, .94);
    border-color: transparent;
}

.ps-overlay__close {
    position: fixed;
    top: 14px;
    right: 16px;
    z-index: 2;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .92);
    color: #111827;
    font-size: 22px;
    line-height: 40px;
    cursor: pointer;
}

.ps-overlay__title {
    flex: 0 0 auto;
    margin: 0 0 8px;
    padding-right: 52px;
    color: #fff;
    font-size: 17px;
    font-weight: 600;
}

.ps-spinner {
    width: 42px;
    height: 42px;
    margin: 40px auto;
    border: 3px solid rgba(255, 255, 255, .3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ps-spin .8s linear infinite;
}

@keyframes ps-spin { to { transform: rotate(360deg); } }

.ps-error { color: #fff; text-align: center; padding: 28px 8px; }

/* ---------- Danh sách từng trang (SEO) ---------- */
.ps-pagelist {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
    padding: 0;
}

@media (min-width: 700px) {
    .ps-pagelist { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.ps-pagelist figure {
    margin: 0;
    border: 1px solid var(--ps-border);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.ps-pagelist img { display: block; width: 100%; height: auto; }

.ps-pagelist figcaption {
    padding: 7px 10px;
    background: #f9fafb;
    color: var(--ps-muted);
    font-size: 13px;
    text-align: center;
}

@media (prefers-reduced-motion: reduce) {
    .ps-card { transition: none; }
    .ps-spinner { animation-duration: 2s; }
}

/* ---------- Bối cảnh trang trong theme ---------- */
.ps-page-wrap { padding: 40px 0 64px; }
.ps-hero h1 { margin: 0 0 10px; line-height: 1.25; }
.ps-hero p { margin: 0 0 26px; color: var(--ps-muted); max-width: 70ch; }
.ps-section { margin-top: 48px; }
.ps-section > h2 { font-size: 21px; margin: 0 0 18px; }
.ps-section__summary { cursor: pointer; font-size: 21px; font-weight: 600; margin-bottom: 18px; }
.ps-shortcode__head { margin-bottom: 22px; }
.ps-shortcode__title { margin: 0 0 8px; }
.ps-shortcode__subtitle { margin: 0; color: var(--ps-muted); }
.ps-cta {
    background: #fff;
    border: 1px solid var(--ps-border);
    border-radius: var(--ps-radius);
    padding: 26px;
}
.ps-cta h2 { margin-top: 0; }
.ps-cta p { color: var(--ps-muted); }
.ps-grid__item.is-hidden { display: none; }
.ps-filter__item { cursor: pointer; font: inherit; }
.ps-pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 32px; }
