/**
 * Thư viện đề IELTS — Landing page styles.
 * Áp dụng cho: page-template/library-template.php (.page-library)
 */

.page-library {
    --lib-bg: #f5f5f7;
    --lib-text: #1d1d1f;
    --lib-muted: #86868b;
    --lib-card: #ffffff;
    --lib-border: #d2d2d7;
    --lib-primary: #0071e3;

    background: var(--lib-bg);
    color: var(--lib-text);
}

/* ==========================================================================
   HERO
   ========================================================================== */
.lib-hero {
    position: relative;
    padding: 20px 0 30px;
    color: var(--lib-text);
    overflow: hidden;
    isolation: isolate;
}

.lib-hero-bg {
    position: absolute;
    inset: 0;
    z-index: -1;
    background: #ffffff;
}

.lib-hero-bg::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 1px 1px, rgba(0, 0, 0, 0.05) 1px, transparent 0);
    background-size: 24px 24px;
    opacity: 1;
}

.lib-hero-inner {
    text-align: center;
    max-width: 1400px;
    margin: 0 auto;
}

.lib-hero-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    background: rgba(0, 113, 227, 0.1);
    border: 1px solid rgba(0, 113, 227, 0.2);
    border-radius: 20px;
    font-size: 36px;
    color: var(--lib-primary);
}

.lib-hero-title {
    font-size: clamp(28px, 3.5vw, 42px);
    font-weight: 800;
    line-height: 1.15;
    margin: 0 0 16px;
    letter-spacing: -0.02em;
}

.lib-hero-sub {
    font-size: 16px;
    line-height: 1.6;
    margin: 0 auto 40px;
    max-width: 640px;
    color: var(--lib-muted);
}

/* STATS BAR */
/* Stats: 6 cards (Tổng + Reading + Listening + Writing + Speaking + LSWD).
   Dùng GRID wrap thay vì flex nowrap để mobile không bị che cards bên phải. */
.lib-stats {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr)); /* desktop: 6 cards / row */
    gap: 12px;
    max-width: 100%;
    margin: 0 auto;
    padding: 8px 4px 8px;       /* padding-top tạo room cho hover lift */
    overflow: visible;
    box-sizing: border-box;
}

@media (max-width: 1199px) {
    .lib-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr)); /* tablet/large mobile: 3×2 */
    }
}

@media (max-width: 575px) {
    .lib-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr)); /* small mobile: 2×3 */
        gap: 10px;
    }
}

.lib-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 16px 12px;
    background: var(--lib-card);
    border: 1px solid var(--lib-border);
    border-radius: 14px;
    text-decoration: none;
    color: var(--lib-text);
    transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
    min-width: 0; /* Allow shrink — quan trọng để grid không tràn */
    overflow: hidden; /* clip nội dung tràn (vd label dài) */
    box-sizing: border-box;
}

.lib-stat--skill:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
    border-color: var(--skill-color, var(--lib-primary));
}

.lib-stat-icon {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: color-mix(in srgb, var(--skill-color, var(--lib-primary)) 18%, transparent);
    font-size: 20px;
    color: var(--skill-color, var(--lib-primary));
}

.lib-stat--total .lib-stat-icon {
    color: var(--lib-primary);
    background: color-mix(in srgb, var(--lib-primary) 18%, transparent);
}

.lib-stat-label {
    /* Tránh label dài như "Chép chính tả" tràn ngang */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.lib-stat-value {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
}

.lib-stat-label {
    font-size: 14px;
    color: var(--lib-muted);
    margin-top: 4px;
}

/* ==========================================================================
   SECTION HEADERS
   ========================================================================== */
.lib-section-head {
    text-align: center;
    margin-bottom: 24px;
}

.lib-section-title {
    font-size: clamp(24px, 3vw, 36px);
    font-weight: 800;
    margin: 0 0 12px;
    color: var(--lib-text);
    letter-spacing: -0.01em;
}

.lib-section-desc {
    font-size: 16px;
    color: var(--lib-muted);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ==========================================================================
   SKILLS GRID — static 4-per-row, auto-wrap responsive
   ========================================================================== */
.lib-skills {
    padding: 30px 0 40px;
}

/* Section head centered for skills */
.lib-section-head--center {
    text-align: center;
    max-width: 760px;
    margin-left: auto;
    margin-right: auto;
}

/* New static grid replaces swiper carousel */
.lib-skills-grid--static {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 22px;
    align-items: stretch;
    justify-content: center;
}

/* When fewer than 4 cards remain on the last row, center them */
.lib-skills-wrapper--grid {
    padding: 0 !important;
}

/* Cards inside static grid override any swiper-fallback widths */
.lib-skills-grid--static .lib-skill-card {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
}

@media (max-width: 1199px) {
    .lib-skills-grid--static { grid-template-columns: repeat(3, 1fr); gap: 18px; }
}
@media (max-width: 991px) {
    .lib-skills-grid--static { grid-template-columns: repeat(2, 1fr); gap: 16px; }
}
@media (max-width: 575px) {
    .lib-skills-grid--static { grid-template-columns: 1fr; gap: 14px; }
}

/* Legacy swiper-only grid (kept for any other carousel that uses swiper-wrapper) */
.lib-skills-grid:not(.lib-skills-grid--static) {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
}

.lib-skill-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 28px 22px; /* roomier — page now uses container-fluid so cards are wider */
    background: var(--lib-card);
    border: 1px solid var(--lib-border);
    border-radius: 22px;
    transition: all .3s ease;
    overflow: hidden;
    height: 100%;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

.lib-skill-name {
    font-size: 19px;
    font-weight: 800;
    margin: 0 0 8px;
    line-height: 1.2;
    white-space: normal;
    word-break: break-word;
}

@media (max-width: 1200px) {
    .lib-skill-name { font-size: 17px; }
    .lib-skill-card { padding: 24px 18px; }
}

/* Full-width container — cards stretch edge-to-edge with safe gutter */
.lib-skills-container {
    padding: 0 40px;
}
@media (max-width: 991px) {
    .lib-skills-container { padding: 0 24px; }
}
@media (max-width: 575px) {
    .lib-skills-container { padding: 0 16px; }
}

/* Swiper Styles */
/* ====================================================================== */
/* SWIPER WRAPPERS + CONTROL BUTTONS (Skills + Featured)                  */
/* Match style /thi-nang-luc/ exam-cards-control                          */
/* ====================================================================== */

.lib-skills-wrapper,
.lib-featured-wrapper {
    position: relative;
    /* Reserve không gian 2 bên cho arrow buttons → KHÔNG đè lên cards */
    padding: 0 56px 8px;
}

@media (max-width: 991px) {
    .lib-skills-wrapper,
    .lib-featured-wrapper {
        padding: 0 48px 8px;
    }
}

@media (max-width: 575px) {
    .lib-skills-wrapper,
    .lib-featured-wrapper {
        padding: 0 0 8px;  /* mobile: buttons fall back inside, user thường swipe */
    }
}

.lib-skills-swiper,
.lib-featured-swiper {
    overflow: hidden;
    padding: 8px 4px 24px;
    margin: 0 -4px;
    position: relative;
}

/* swiper-wrapper inside (lib-skills-grid / lib-featured-grid) */
.lib-skills-swiper > .swiper-wrapper,
.lib-featured-swiper > .swiper-wrapper {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
}

/* swiper-slide override Swiper-bundle default 100% width */
.lib-skills-swiper .swiper-slide,
.lib-featured-swiper .swiper-slide {
    width: auto;
    flex: 0 0 auto;
    height: auto;
    box-sizing: border-box;
    display: flex;
}

/* Fallback width khi Swiper chưa init — Skills: 5 cards/row trên desktop (≥1200px) */
.lib-skills-swiper .lib-skill-card {
    width: calc((100% - 64px) / 5);
    min-width: 195px;
}

/* Featured: giữ nguyên 4 cards/row trên desktop */
.lib-featured-swiper .lib-featured-card {
    width: calc((100% - 72px) / 4);
    min-width: 220px;
}

@media (max-width: 1199px) {
    .lib-skills-swiper .lib-skill-card { width: calc((100% - 48px) / 4); }
    .lib-featured-swiper .lib-featured-card { width: calc((100% - 40px) / 3); }
}

@media (max-width: 991px) {
    .lib-skills-swiper .lib-skill-card { width: calc((100% - 28px) / 3); }
    .lib-featured-swiper .lib-featured-card { width: calc((100% - 16px) / 2); }
}

@media (max-width: 767px) {
    .lib-skills-swiper .lib-skill-card { width: calc((100% - 14px) / 2); }
}

@media (max-width: 575px) {
    .lib-skills-swiper .lib-skill-card,
    .lib-featured-swiper .lib-featured-card {
        width: 90%;
    }
}

/* Skills card khi hiển thị 5/row → padding giảm + font số đề nhỏ hơn 1 chút */
@media (min-width: 1200px) {
    .lib-skills-swiper .lib-skill-card { padding: 22px 14px; }
    .lib-skills-swiper .lib-skill-name { font-size: 16px; }
}

/* ---------------------------------------------------------------------- */
/* Control buttons — copy y chang style /thi-nang-luc/ .swiper-control-btn */
/* ---------------------------------------------------------------------- */
.lib-carousel-control {
    position: absolute;
    top: 50%;
    /* left:0/right:0 = sit ở wrapper's padded edges (56px outside swiper) */
    left: 0;
    right: 0;
    pointer-events: none;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    z-index: 5;
}

.lib-carousel-control .swiper-control-btn {
    pointer-events: auto;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    display: flex !important;            /* always show desktop + mobile */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #384259;
    font-size: 16px;
    border: none;
    padding: 0;
    transition: transform .2s ease, background .2s ease, color .2s ease;
}

.lib-carousel-control .swiper-control-btn:hover {
    background: #384259;
    color: #fff;
    transform: scale(1.05);
}

.lib-carousel-control .swiper-control-btn.swiper-button-disabled,
.lib-carousel-control .swiper-control-btn.swiper-button-lock {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

/* Mobile — slightly smaller buttons */
@media (max-width: 575px) {
    .lib-carousel-control {
        left: 0;
        right: 0;
    }
    .lib-carousel-control .swiper-control-btn {
        width: 36px;
        height: 36px;
    }
}

.lib-skill-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 28px;
    background: var(--lib-card);
    border: 1px solid var(--lib-border);
    border-radius: 20px;
    transition: transform .3s ease, box-shadow .3s ease, border-color .3s ease;
    overflow: hidden;
}

.lib-skill-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--skill-color, var(--lib-primary));
}

.lib-skill-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.15);
    border-color: var(--skill-color, var(--lib-primary));
}

.lib-skill-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.lib-skill-icon {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: color-mix(in srgb, var(--skill-color, var(--lib-primary)) 12%, transparent);
    color: var(--skill-color, var(--lib-primary));
    font-size: 24px;
}

.lib-skill-name {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0 0 4px;
    color: var(--lib-text);
}

.lib-skill-count {
    font-size: 14px;
    color: var(--lib-muted);
    font-weight: 600;
}

.lib-skill-desc {
    font-size: 15px;
    line-height: 1.55;
    color: var(--lib-muted);
    margin: 0 0 16px;
}

.lib-skill-parts {
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.lib-skill-parts li a {
    display: inline-block;
    padding: 6px 14px;
    background: color-mix(in srgb, var(--skill-color, var(--lib-primary)) 8%, transparent);
    color: var(--skill-color, var(--lib-primary));
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background .2s ease;
}

.lib-skill-parts li a:hover {
    background: var(--skill-color, var(--lib-primary));
    color: #fff;
}

.lib-skill-preview {
    border-top: 1px dashed var(--lib-border);
    padding-top: 14px;
    margin-bottom: 18px;
    flex: 1;
}

.lib-skill-preview-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--lib-muted);
    margin-bottom: 8px;
    font-weight: 700;
}

.lib-skill-preview ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.lib-skill-preview li {
    padding: 4px 0;
    font-size: 15px;
}

.lib-skill-preview li a {
    color: var(--lib-text);
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color .2s ease;
}

.lib-skill-preview li a:hover {
    color: var(--skill-color, var(--lib-primary));
}

.lib-skill-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: #1d1d1f;
    color: #fff !important;
    border-radius: 20px;
    font-weight: 600;
    font-size: 16px;
    text-decoration: none;
    margin-top: auto;
    transition: background .2s ease, transform .2s ease;
}

.lib-skill-cta:hover {
    background: #424245;
    transform: translateY(-1px);
}

/* ==========================================================================
   CLASSIC LIBRARY POSTCARD — pinned to lib-hero, links to /thi-nang-luc/
   "Nhớ VIBE cũ? — Click ngay vào IELTS CỔ ĐIỂN 1.0"
   Vintage postcard aesthetic: red push-pin, washi stamp, ruled paper bg,
   handwritten Patrick Hand font, yellow marker highlight.
   ========================================================================== */
.lib-classic {
    position: absolute;
    top: 30px;
    right: 30px;
    width: 300px;
    background: #fefce8;
    border: 1px solid #d4d4d8;
    padding: 22px 18px 20px;
    transform: rotate(-2deg);
    box-shadow:
        0 1px 2px rgba(0,0,0,.08),
        0 6px 12px -4px rgba(0,0,0,.12),
        0 16px 24px -8px rgba(0,0,0,.1);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
    z-index: 10;
    transition: transform .35s ease;
    background-image: linear-gradient(rgba(0,0,0,.02) 1px, transparent 1px);
    background-size: 100% 14px;
    font-family: 'Patrick Hand', 'Plus Jakarta Sans', cursive;
}
.lib-classic:hover {
    transform: rotate(0deg) translateY(-3px);
    text-decoration: none;
    color: inherit;
}

/* Push-pin */
.lib-classic-pin {
    position: absolute;
    top: -8px; left: 50%;
    transform: translateX(-50%);
    width: 26px; height: 26px;
    background: radial-gradient(circle at 35% 35%, #f87171 0%, #b91c1c 70%);
    border-radius: 50%;
    box-shadow:
        inset 2px 2px 4px rgba(255,255,255,.4),
        inset -2px -2px 4px rgba(0,0,0,.3),
        0 4px 8px rgba(185,28,28,.5);
    z-index: 2;
}
.lib-classic-pin::before {
    content: "";
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 5px; height: 5px;
    background: rgba(255,255,255,.7);
    border-radius: 50%;
}

/* VINTAGE stamp */
.lib-classic-stamp {
    position: absolute;
    top: 12px; right: 12px;
    width: 50px; height: 56px;
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    border: 1px dashed #dc2626;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 9px;
    font-weight: 700;
    color: #991b1b;
    letter-spacing: 0.08em;
    font-family: 'Plus Jakarta Sans', sans-serif;
}
.lib-classic-stamp-emoji { font-size: 22px; }

/* Header tag */
.lib-classic-header {
    display: block;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 10px;
    color: #92400e;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-bottom: 12px;
    border-bottom: 1.5px dashed #d4d4d8;
    padding-bottom: 8px;
    width: 60%;
}

/* Title */
.lib-classic-title {
    display: block;
    font-size: 26px;
    font-weight: 400;
    line-height: 1.05;
    color: #1d1d1f;
    margin-bottom: 8px;
    text-align: center;
}
.lib-classic-title em {
    font-style: normal;
    color: #dc2626;
    background: linear-gradient(transparent 60%, #fde68a 60%);
    padding: 0 4px;
}

/* Sub: "Click ngay vào thư viện kho đề" + line break + IELTS CỔ ĐIỂN 1.0 */
.lib-classic-sub {
    display: block;
    font-size: 15px;
    color: #4b5563;
    line-height: 1.4;
    margin-bottom: 14px;
    text-align: center;
}
.lib-classic-sub strong {
    display: inline-block;
    margin-top: 4px;
    background: linear-gradient(transparent 55%, #fde68a 55%);
    color: #dc2626;
    padding: 0 6px;
    font-weight: 700;
    font-size: 17px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    transform: rotate(-1deg);
    font-family: 'Plus Jakarta Sans', sans-serif;
}

/* Arrow line */
.lib-classic-arrow {
    display: block;
    color: #1d1d1f;
    font-size: 19px;
    margin-bottom: 8px;
    text-align: center;
}

/* CTA pill */
.lib-classic-cta {
    display: block;
    background: #1d1d1f;
    color: #fff;
    padding: 10px 18px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0,0,0,.2);
    transform: rotate(-1deg);
    transition: all .25s ease;
    text-align: center;
    width: fit-content;
    margin: 0 auto;
    font-family: 'Plus Jakarta Sans', sans-serif;
}
.lib-classic:hover .lib-classic-cta {
    transform: rotate(0deg) scale(1.05);
    background: #dc2626;
}

/* ── Medium desktop (1280-1599): shrink postcard so it never overlaps hero title ── */
@media (max-width: 1599px) and (min-width: 1280px) {
    .lib-classic {
        width: 260px;
        top: 20px;
        right: 20px;
        padding: 18px 14px 16px;
    }
    .lib-classic-title    { font-size: 22px; }
    .lib-classic-sub      { font-size: 14px; }
    .lib-classic-sub strong { font-size: 15px; }
    .lib-classic-cta      { padding: 9px 16px; font-size: 12px; }
    .lib-classic-stamp    { width: 42px; height: 48px; }
    .lib-classic-stamp-emoji { font-size: 18px; }
}

/* ── Tablet / small laptop (<1280px): drop absolute → render as block under hero ── */
@media (max-width: 1279px) {
    .lib-classic {
        position: static;
        margin: 24px auto 0;
        max-width: 340px;
        transform: rotate(0deg);
    }
    .lib-classic:hover { transform: translateY(-3px); }
}
@media (max-width: 480px) {
    .lib-classic { padding: 20px 14px 16px; max-width: 100%; }
    .lib-classic-title { font-size: 22px; }
    .lib-classic-sub strong { font-size: 15px; }
}

/* ==========================================================================
   AI SPEAKING CARD — distinct purple gradient, "AI Powered" badge
   ========================================================================== */
.lib-skill-card--ai {
    background: linear-gradient(135deg, #faf5ff 0%, #f5f3ff 50%, #fdf4ff 100%);
    border-color: #c4b5fd;
}

.lib-skill-card--ai::before {
    background: linear-gradient(90deg, #7c3aed 0%, #a855f7 50%, #d946ef 100%);
    height: 5px;
}

.lib-skill-card--ai:hover {
    border-color: #7c3aed;
    box-shadow: 0 24px 50px -16px rgba(124, 58, 237, 0.35);
}

.lib-skill-card--ai .lib-skill-icon {
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    color: #fff;
    box-shadow: 0 8px 16px -4px rgba(124, 58, 237, 0.4);
}

.lib-skill-card--ai .lib-skill-name {
    background: linear-gradient(90deg, #7c3aed 0%, #d946ef 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.lib-skill-card--ai .lib-skill-count {
    color: #7c3aed;
    font-weight: 700;
}

.lib-skill-ai-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: linear-gradient(135deg, #7c3aed 0%, #d946ef 100%);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-radius: 999px;
    box-shadow: 0 4px 12px -2px rgba(124, 58, 237, 0.45);
    z-index: 2;
}

.lib-skill-ai-badge i {
    font-size: 11px;
    animation: lib-ai-sparkle 2.4s ease-in-out infinite;
}

@keyframes lib-ai-sparkle {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
    50%      { transform: scale(1.2) rotate(15deg); opacity: 0.85; }
}

.lib-skill-parts--ai li a {
    background: rgba(124, 58, 237, 0.1);
    color: #6d28d9;
}

.lib-skill-parts--ai li a:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    color: #fff;
}

.lib-skill-preview--ai {
    border-top-color: rgba(124, 58, 237, 0.3);
}

.lib-skill-preview--ai ul li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    color: var(--lib-text);
    font-weight: 500;
}

.lib-skill-preview--ai ul li i {
    color: #7c3aed;
    margin-top: 4px;
    flex-shrink: 0;
}

.lib-skill-cta--ai {
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 50%, #d946ef 100%);
    background-size: 200% 100%;
    background-position: 0% 50%;
    box-shadow: 0 8px 20px -6px rgba(124, 58, 237, 0.45);
}

.lib-skill-cta--ai:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 50%, #d946ef 100%);
    background-size: 200% 100%;
    background-position: 100% 50%;
    transform: translateY(-2px);
    box-shadow: 0 12px 28px -8px rgba(124, 58, 237, 0.55);
}

/* ==========================================================================
   AI GRAMMAR CARD — teal/cyan palette matching /luyen-grammar/ page
   (Grammar page uses --gr-teal #0891B2 as primary, NOT violet)
   ========================================================================== */
.lib-skill-card--ai-grammar {
    background: linear-gradient(135deg, #ecfeff 0%, #cffafe 50%, #e0f7fa 100%);
    border-color: #67e8f9;
}
.lib-skill-card--ai-grammar::before {
    background: linear-gradient(90deg, #0e7490 0%, #06b6d4 50%, #22d3ee 100%);
    height: 5px;
}
.lib-skill-card--ai-grammar:hover {
    border-color: #0891b2;
    box-shadow: 0 24px 50px -16px rgba(8, 145, 178, 0.35);
}
.lib-skill-card--ai-grammar .lib-skill-icon {
    background: linear-gradient(135deg, #0e7490 0%, #06b6d4 100%);
    color: #fff;
    box-shadow: 0 8px 16px -4px rgba(8, 145, 178, 0.4);
}
.lib-skill-card--ai-grammar .lib-skill-name {
    background: linear-gradient(90deg, #0e7490 0%, #06b6d4 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.lib-skill-card--ai-grammar .lib-skill-count {
    color: #0891b2;
    font-weight: 700;
}
.lib-skill-card--ai-grammar .lib-skill-ai-badge {
    background: linear-gradient(135deg, #0e7490 0%, #06b6d4 100%);
    box-shadow: 0 4px 12px -2px rgba(8, 145, 178, 0.45);
}
.lib-skill-card--ai-grammar .lib-skill-parts--ai li a {
    background: rgba(6, 182, 212, 0.12);
    color: #0e7490;
}
.lib-skill-card--ai-grammar .lib-skill-parts--ai li a:hover {
    background: linear-gradient(135deg, #0891b2 0%, #06b6d4 100%);
    color: #fff;
}
.lib-skill-card--ai-grammar .lib-skill-preview--ai {
    border-top-color: rgba(8, 145, 178, 0.3);
}
.lib-skill-card--ai-grammar .lib-skill-preview--ai ul li i {
    color: #0891b2;
}
.lib-skill-card--ai-grammar .lib-skill-cta--ai {
    background: linear-gradient(135deg, #0e7490 0%, #0891b2 50%, #06b6d4 100%);
    background-size: 200% 100%;
    background-position: 0% 50%;
    box-shadow: 0 8px 20px -6px rgba(8, 145, 178, 0.45);
}
.lib-skill-card--ai-grammar .lib-skill-cta--ai:hover {
    background: linear-gradient(135deg, #0e7490 0%, #0891b2 50%, #06b6d4 100%);
    background-size: 200% 100%;
    background-position: 100% 50%;
    box-shadow: 0 12px 28px -8px rgba(8, 145, 178, 0.55);
}

/* ==========================================================================
   IELTS MOCK TEST CARD — orange/red palette (distinct from AI cards)
   Two CTAs: Familiarisation (light) + Premium Mock (gold)
   ========================================================================== */
.lib-skill-card--mock {
    background: linear-gradient(135deg, #FFF7ED 0%, #FFEDD5 50%, #FECACA 100%);
    border-color: #FB923C;
}
.lib-skill-card--mock::before {
    background: linear-gradient(90deg, #DC2626 0%, #F97316 50%, #FBBF24 100%);
    height: 5px;
}
.lib-skill-card--mock:hover {
    border-color: #DC2626;
    box-shadow: 0 24px 50px -16px rgba(220, 38, 38, 0.35);
}
.lib-skill-card--mock .lib-skill-icon {
    background: linear-gradient(135deg, #DC2626 0%, #F97316 100%);
    color: #fff;
    box-shadow: 0 8px 16px -4px rgba(220, 38, 38, 0.4);
}
.lib-skill-card--mock .lib-skill-name {
    background: linear-gradient(90deg, #DC2626 0%, #F97316 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.lib-skill-card--mock .lib-skill-count {
    color: #DC2626;
    font-weight: 700;
}
.lib-skill-card--mock .lib-skill-ai-badge {
    background: linear-gradient(135deg, #DC2626 0%, #F97316 100%);
    box-shadow: 0 4px 12px -2px rgba(220, 38, 38, 0.45);
}

.lib-skill-parts--mock li a {
    background: rgba(220, 38, 38, 0.10);
    color: #B91C1C;
    display: flex;
    align-items: center;
    gap: 6px;
}
.lib-skill-parts--mock li a:hover {
    background: linear-gradient(135deg, #DC2626 0%, #F97316 100%);
    color: #fff;
}
.lib-skill-preview--mock {
    border-top-color: rgba(220, 38, 38, 0.3);
}
.lib-skill-preview--mock ul li {
    display: grid;
    grid-template-columns: 18px max-content 1fr;
    column-gap: 10px;
    row-gap: 2px;
    align-items: start;
    color: var(--lib-text);
    font-weight: 500;
    line-height: 1.5;
    padding: 6px 0;
}
.lib-skill-preview--mock ul li i {
    color: #DC2626;
    flex-shrink: 0;
    align-self: start;
    line-height: 1.5;
    font-size: 14px;
    padding-top: 3px;
}
.lib-skill-preview--mock ul li strong {
    color: #DC2626;
    font-weight: 700;
    white-space: nowrap;
}
.lib-skill-preview--mock ul li span {
    color: var(--lib-text);
    font-weight: 500;
}
@media (max-width: 540px) {
    .lib-skill-preview--mock ul li {
        grid-template-columns: 18px 1fr;
    }
    .lib-skill-preview--mock ul li span {
        grid-column: 2;
    }
}

/* Two-button CTA row */
.lib-skill-mock-cta-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: auto;
    padding-top: 12px;
}
.lib-skill-cta--mock-fam,
.lib-skill-cta--mock-prem {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 13px;
    text-decoration: none;
    transition: all .18s ease;
    border: 2px solid transparent;
    box-sizing: border-box;
    min-height: 42px;
    line-height: 1;
}
.lib-skill-cta--mock-fam,
.lib-skill-cta--mock-fam:visited,
.lib-skill-cta--mock-fam:link {
    background: #fff !important;
    color: #B91C1C !important;
    border: 2px solid #FB923C !important;
}
.lib-skill-cta--mock-fam span,
.lib-skill-cta--mock-fam i {
    color: #B91C1C !important;
}
.lib-skill-cta--mock-fam:hover {
    background: #FFEDD5 !important;
    color: #B91C1C !important;
    border-color: #DC2626 !important;
    transform: translateY(-2px);
}
.lib-skill-cta--mock-fam:hover span,
.lib-skill-cta--mock-fam:hover i { color: #B91C1C !important; }
.lib-skill-cta--mock-prem,
.lib-skill-cta--mock-prem:visited,
.lib-skill-cta--mock-prem:link {
    color: #fff !important;
}
.lib-skill-cta--mock-prem span,
.lib-skill-cta--mock-prem i { color: #fff !important; }

/* Dark-mode safety — keep contrast */
html.ae-dark-mode .lib-skill-cta--mock-fam,
html.ae-dark-mode .lib-skill-cta--mock-fam:visited {
    background: #1F1410 !important;
    color: #FCA5A5 !important;
    border-color: #F97316 !important;
}
html.ae-dark-mode .lib-skill-cta--mock-fam span,
html.ae-dark-mode .lib-skill-cta--mock-fam i { color: #FCA5A5 !important; }
.lib-skill-cta--mock-prem {
    background: linear-gradient(135deg, #DC2626 0%, #F97316 50%, #FBBF24 100%);
    background-size: 200% 100%;
    background-position: 0% 50%;
    color: #fff;
    box-shadow: 0 6px 16px -4px rgba(220, 38, 38, 0.45);
}
.lib-skill-cta--mock-prem:hover {
    background-position: 100% 50%;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 10px 22px -6px rgba(220, 38, 38, 0.55);
}

/* ==========================================================================
   FEATURED CATEGORIES
   ========================================================================== */
.lib-featured {
    padding: 60px 0;
    background: #f8f9fa;
    border-top: 1px solid var(--lib-border);
}

/* lib-featured-grid is swiper-wrapper — flex row, no grid */
.lib-featured-grid {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0; /* Swiper space-between handles spacing */
}

.lib-featured-card {
    display: flex;
    flex-direction: row; /* Horizontal on mobile stack */
    background: #fff;
    border: 1px solid #e1e1e1;
    border-radius: 16px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: all .3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

@media (min-width: 768px) {
    .lib-featured-card {
        flex-direction: column; /* Back to vertical card on desktop grid */
    }
}

.lib-featured-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
    border-color: #384259;
}

/* ====================================================================== */
/* FEATURED CARD IMAGE — Smart fit                                        */
/*                                                                         */
/* Logic: dùng `object-fit: contain` để KHÔNG crop ảnh (portrait/landscape */
/* /square đều hiện full). Aspect-ratio 4:5 cân bằng — không bị hở gap to. */
/* No-img placeholder dùng gradient + icon to + skill color → đẹp, có style*/
/* ====================================================================== */

.lib-featured-img {
    position: relative;
    flex: 0 0 120px;
    aspect-ratio: 4 / 5;                 /* 0.8 — thoáng, không bị hở gap như 9:16 */
    background: linear-gradient(135deg, #f1f5fb 0%, #e6ecf5 100%);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

@media (min-width: 768px) {
    .lib-featured-img {
        flex: none;
        width: 100%;
        aspect-ratio: 4 / 5;
    }
}

/* Has image — contain để full image hiện không crop */
.lib-featured-img.has-img {
    background: #0f172a;                 /* nền tối làm nổi ảnh portrait có background đen như Thunder */
    padding: 0;
}

.lib-featured-img.has-img::before {
    /* Gradient mờ overlay để bottom đỡ thô khi ảnh cao hơn 4:5 */
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,0.25) 100%);
    pointer-events: none;
    z-index: 1;
}

.lib-featured-img.has-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;                   /* portrait poster fill 100% — Thunder kiểu này */
    object-position: center;
    position: relative;
    z-index: 0;
}

/* No image — beautiful placeholder với gradient + icon to center */
.lib-featured-img.no-img {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
    color: #fff;
    overflow: hidden;
}

.lib-featured-img.no-img::before {
    content: "\f02d";                     /* fa-book */
    font-family: "Font Awesome 6 Pro";
    font-weight: 300;
    font-size: 56px;
    color: rgba(255, 255, 255, 0.85);
    z-index: 2;
    position: relative;
    text-shadow: 0 4px 12px rgba(0,0,0,0.18);
}

.lib-featured-img.no-img::after {
    /* Decorative glow blob */
    content: "";
    position: absolute;
    top: -40%;
    right: -30%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255,255,255,0.25) 0%, transparent 60%);
    pointer-events: none;
    z-index: 1;
}

.lib-featured-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
}

.lib-featured-name {
    font-size: 17px;
    font-weight: 800;
    margin: 0 0 6px;
    color: #1d1d1f;
    line-height: 1.3;
}

.lib-featured-desc {
    font-size: 13px;
    color: #666;
    margin-bottom: 12px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.lib-featured-count {
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: #384259;
    padding: 4px 12px;
    border-radius: 999px;
    width: fit-content;
}

/* (rule .lib-featured-img.no-img::before duplicate đã xoá — định nghĩa beautiful placeholder ở trên) */

.lib-featured-body {
    padding: 16px 18px;
}

.lib-featured-name {
    font-size: 1.25rem;
    font-weight: 800;
    margin: 0 0 6px;
    color: var(--lib-text);
}

.lib-featured-desc {
    font-size: 14px;
    color: var(--lib-muted);
    margin: 0 0 10px;
    line-height: 1.5;
}

.lib-featured-count {
    display: inline-block;
    padding: 4px 12px;
    background: var(--lib-primary);
    color: #fff;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
}

/* ==========================================================================
   PAGE CONTENT (admin editor)
   ========================================================================== */
.lib-content {
    padding: 60px 0;
}

.lib-content-inner {
    max-width: 100%;
    line-height: 1.7;
    color: var(--lib-text);
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 768px) {
    .lib-hero {
        padding: 30px 0 40px;
    }
    .lib-hero-icon {
        width: 60px;
        height: 60px;
        font-size: 28px;
    }
    .lib-stats {
        flex-wrap: wrap;
        gap: 8px;
        overflow-x: visible;
    }
    .lib-stat {
        min-width: calc(33.33% - 6px);
        flex: 0 0 auto;
        padding: 12px 8px;
    }
    .lib-stat-value {
        font-size: 20px;
    }
    .lib-stat-label {
        font-size: 12px;
    }
    .lib-skills,
    .lib-featured {
        padding: 40px 0;
    }
    .lib-skill-card {
        padding: 22px;
        height: auto;
    }
}
/* Pagination - Restored Circular Original Style */
.pagination-wrapper {
    margin-top: 40px;
    display: flex;
    justify-content: center;
}

.pagination-wrapper ul.page-numbers {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 10px;
}

.pagination-wrapper ul.page-numbers li span.page-numbers,
.pagination-wrapper ul.page-numbers li a.page-numbers {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #e1e1e1;
    color: #333;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s ease;
}

.pagination-wrapper ul.page-numbers li span.page-numbers.current {
    background: #384259;
    border-color: #384259;
    color: #fff;
}

.pagination-wrapper ul.page-numbers li a.page-numbers:hover {
    border-color: #384259;
    color: #fff;
    background: #384259;
    box-shadow: 0 4px 12px rgba(56, 66, 89, 0.25);
    transform: translateY(-2px);
}
