/* ====================================================
   Adsplus Ebooks — frontend
   Cùng bảng màu với widget tuyển dụng: cam #FF7F27 chỉ
   xuất hiện ở chỗ người dùng chạm vào (chip đang chọn,
   nút CTA khi hover), phần còn lại giữ im lặng.
   Mọi selector đều nằm dưới .ebk- để không đụng theme.
   ==================================================== */

.ebk-wrap {
    --ebk-ember: #ff7f27;
    --ebk-ember-deep: #b34a06;
    --ebk-ember-wash: #fff1e6;
    --ebk-ink: #1a1512;
    --ebk-surface: #ffffff;
    --ebk-line: #ebdfd5;
    --ebk-muted: #6e5c50;

    color: var(--ebk-ink);
    box-sizing: border-box;
}
.ebk-wrap *,
.ebk-wrap *::before,
.ebk-wrap *::after {
    box-sizing: border-box;
}

/* ---------- Tab lọc ---------- */
.ebk-tabs-wrap {
    position: relative;
    margin-bottom: 28px;
    border-bottom: 1px solid var(--ebk-line);
}
/* Trên mobile thanh tab cuộn ngang thay vì xuống dòng — xuống dòng làm
   thanh cao 3 hàng và đẩy hết nội dung xuống dưới màn hình. */
.ebk-tabs {
    position: relative;
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
}
.ebk-tabs::-webkit-scrollbar {
    display: none;
}
.ebk-tab {
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.2;
    color: var(--ebk-muted);
    background: none;
    border: none;
    border-radius: 0;
    padding: 12px 16px 14px;
    cursor: pointer;
    white-space: nowrap;
    flex: none;
    transition: color 0.15s ease;
}
.ebk-tab:hover {
    color: var(--ebk-ink);
}
.ebk-tab[aria-selected="true"] {
    color: var(--ebk-ink);
    font-weight: 600;
}
.ebk-tab:focus-visible {
    outline: 2px solid var(--ebk-ember-deep);
    outline-offset: -2px;
    border-radius: 4px;
}
.ebk-tab-n {
    font-size: 12px;
    color: var(--ebk-muted);
    margin-left: 6px;
    vertical-align: 1px;
}
.ebk-tab[aria-selected="true"] .ebk-tab-n {
    color: var(--ebk-ember-deep);
}
/* Chỉ báo trượt: dùng transform nên chạy trên compositor, không layout lại */
.ebk-tab-marker {
    position: absolute;
    bottom: -1px;
    left: 0;
    height: 2px;
    width: 0;
    background: var(--ebk-ember);
    transition:
        transform 0.25s cubic-bezier(0.2, 0.7, 0.3, 1),
        width 0.25s cubic-bezier(0.2, 0.7, 0.3, 1);
    pointer-events: none;
}

/* ---------- Chip lọc ---------- */
.ebk-filter {
    margin-bottom: 26px;
}
.ebk-filter-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ebk-muted);
    margin-bottom: 12px;
}
.ebk-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.ebk-chip {
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    color: var(--ebk-ink);
    background: var(--ebk-surface);
    border: 1px solid var(--ebk-line);
    border-radius: 999px;
    padding: 9px 18px;
    cursor: pointer;
    transition:
        background 0.15s ease,
        border-color 0.15s ease;
}
.ebk-chip:hover {
    background: var(--ebk-ember-wash);
    border-color: var(--ebk-ember);
}
.ebk-chip[aria-pressed="true"] {
    background: var(--ebk-ember);
    border-color: var(--ebk-ember);
    font-weight: 600;
}
.ebk-chip-n {
    font-size: 12px;
    color: var(--ebk-muted);
    margin-left: 7px;
}
.ebk-chip[aria-pressed="true"] .ebk-chip-n {
    color: rgba(26, 21, 18, 0.62);
}

/* ---------- Lưới ---------- */
/* Số cột lấy thẳng từ --ebk-cols (đặt inline theo thuộc tính columns).
   Trước đây dùng auto-fill + minmax nên số cột do bề rộng container quyết
   định, còn columns="4" chỉ đổi bề rộng tối thiểu — không phải điều bạn
   yêu cầu. Các breakpoint bên dưới chỉ HẠ số cột, không bao giờ tăng. */
.ebk-grid {
    display: grid;
    grid-template-columns: repeat(var(--ebk-cols, 3), minmax(0, 1fr));
    gap: 20px;
}
@media (max-width: 1080px) {
    .ebk-wrap[data-columns="4"] .ebk-grid {
        --ebk-cols: 3;
    }
}
@media (max-width: 820px) {
    .ebk-wrap[data-columns="3"] .ebk-grid,
    .ebk-wrap[data-columns="4"] .ebk-grid {
        --ebk-cols: 2;
    }
}

/* [hidden] của trình duyệt là display:none nhưng độ ưu tiên thấp hơn
   .ebk-card { display: flex } — thiếu rule này thì lọc chạy đúng trong JS
   mà thẻ vẫn hiện nguyên. */
.ebk-card[hidden] {
    display: none;
}

.ebk-card {
    background: var(--ebk-surface);
    border: 1px solid var(--ebk-line);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition:
        border-color 0.18s ease,
        transform 0.18s ease;
}
.ebk-card:hover {
    border-color: var(--ebk-ember);
    transform: translateY(-2px);
}

.ebk-cover {
    position: relative;
    aspect-ratio: 3 / 4;
    max-height: 300px;
    background: #fff;
    overflow: hidden;
}
/* contain thay vì cover: bìa ebook thường có chữ sát mép, cover sẽ cắt mất.
   Đổi thành cover nếu bạn muốn ảnh lấp đầy khung và chấp nhận bị xén. */
.ebk-cover-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.ebk-cover-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: 700;
    color: var(--ebk-ember);
}
.ebk-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--ebk-ember);
    background: var(--ebk-ink);
    border-radius: 999px;
    padding: 4px 11px;
}

.ebk-body {
    padding: 16px 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    flex: 1;
}
.ebk-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    margin: 0;
    color: var(--ebk-ink);
}
/* Clamp để một mô tả dài không kéo cao cả hàng thẻ */
.ebk-desc {
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--ebk-muted);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.ebk-cta {
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--ebk-ink);
    background: var(--ebk-ember-wash);
    border: 1px solid var(--ebk-line);
    border-radius: 6px;
    padding: 11px 14px;
    margin-top: auto;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition:
        background 0.18s ease,
        border-color 0.18s ease;
}
.ebk-cta span {
    transition: transform 0.18s ease;
}
.ebk-card:hover .ebk-cta {
    background: var(--ebk-ember);
    border-color: var(--ebk-ember);
}
.ebk-card:hover .ebk-cta span {
    transform: translateX(4px);
}

.ebk-empty {
    padding: 48px 0;
    text-align: center;
    color: var(--ebk-muted);
}

/* ---------- Modal ---------- */
.ebk-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.ebk-modal[hidden] {
    display: none;
}
.ebk-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(26, 21, 18, 0.55);
}
.ebk-dialog {
    position: relative;
    background: #fff;
    color: #1a1512;
    border-radius: 12px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px 28px 28px;
    box-shadow: 0 24px 60px -20px rgba(26, 21, 18, 0.45);
}
.ebk-close {
    position: absolute;
    top: 12px;
    right: 14px;
    font-size: 26px;
    line-height: 1;
    background: none;
    border: none;
    color: #6e5c50;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
}
.ebk-close:hover {
    background: #fff1e6;
    color: #1a1512;
}

.ebk-modal-head {
    margin-bottom: 20px;
    padding-right: 30px;
}
.ebk-modal-kicker {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #b34a06;
    margin: 0 0 8px;
}
.ebk-modal-title {
    font-size: 21px;
    font-weight: 700;
    line-height: 1.25;
    margin: 0 0 8px;
}
.ebk-modal-desc {
    font-size: 14px;
    line-height: 1.55;
    color: #6e5c50;
    margin: 0;
}
.ebk-loading {
    color: #6e5c50;
    font-size: 14px;
    padding: 24px 0;
    text-align: center;
}

/* ---------- Form dự phòng ---------- */
.ebk-fallback-note {
    font-size: 13.5px;
    line-height: 1.55;
    color: #b34a06;
    background: #fff1e6;
    border-radius: 8px;
    padding: 12px 14px;
    margin: 0 0 18px;
}
.ebk-field {
    display: block;
    margin-bottom: 14px;
}
.ebk-field span {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
}
.ebk-field input {
    width: 100%;
    font: inherit;
    font-size: 15px;
    padding: 11px 13px;
    border: 1px solid #ebdfd5;
    border-radius: 7px;
    background: #fff;
    color: #1a1512;
}
.ebk-field input:focus {
    outline: 2px solid #ff7f27;
    outline-offset: 1px;
    border-color: #ff7f27;
}
.ebk-hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
.ebk-error {
    font-size: 13.5px;
    color: #b3210b;
    margin: 0 0 12px;
}
.ebk-submit {
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    color: #1a1512;
    background: #ff7f27;
    border: none;
    border-radius: 7px;
    padding: 13px 22px;
    width: 100%;
    cursor: pointer;
    transition: background 0.15s ease;
}
.ebk-submit:hover {
    background: #f06d12;
}
.ebk-submit:disabled {
    opacity: 0.6;
    cursor: default;
}

/* ---------- Thành công ---------- */
.ebk-success {
    text-align: center;
    padding: 16px 4px 4px;
}
.ebk-success:focus {
    outline: none;
}
.ebk-success-mark {
    width: 52px;
    height: 52px;
    margin: 0 auto 18px;
    border-radius: 999px;
    background: #fff1e6;
    color: #b34a06;
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ebk-success-title {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.35;
    margin: 0 0 12px;
}
.ebk-success-note {
    font-size: 14px;
    line-height: 1.6;
    color: #6e5c50;
    margin: 0 0 8px;
}
.ebk-success-close {
    margin-top: 20px;
    width: auto;
    min-width: 140px;
}

@media (prefers-reduced-motion: reduce) {
    .ebk-tabs {
        scroll-behavior: auto;
    }
    .ebk-tab-marker,
    .ebk-card,
    .ebk-chip,
    .ebk-cta,
    .ebk-cta span,
    .ebk-submit {
        transition: none;
    }
}

@media (max-width: 600px) {
    .ebk-tabs-wrap {
        margin-bottom: 22px;
    }
    .ebk-tab {
        font-size: 14px;
        padding: 11px 13px 13px;
    }
    .ebk-grid {
        --ebk-cols: 1;
        gap: 16px;
    }
    .ebk-dialog {
        padding: 28px 20px 22px;
        max-height: 94vh;
    }
}
