/**
 * Skill page (Reading/Listening/Writing/Speaking) shared styles.
 * Applied to: page-template/{reading,listening,writing,speaking}-template.php
 * Per-skill color come from --skill-color CSS var on .page-skill.
 */

.page-skill {
    --skill-bg: #f5f5f7;
    --skill-text: #1d1d1f;
    --skill-muted: #86868b;
    --skill-card: #ffffff;
    --skill-border: #d2d2d7;
    background: var(--skill-bg);
    color: var(--skill-text);
}

/* ==========================================================================
   HERO (Compact)
   ========================================================================== */
.skill-hero {
    position: relative;
    padding: 16px 0 20px; /* Highly condensed padding */
    color: var(--skill-text);
    overflow: hidden;
    isolation: isolate;
    border-bottom: 1px solid var(--skill-border);
}

.skill-hero-bg {
    position: absolute;
    inset: 0;
    z-index: -1;
    background: color-mix(in srgb, var(--skill-color) 10%, #ffffff);
}

.skill-hero-bg::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--skill-color) 20%, transparent) 1.5px, transparent 0);
    background-size: 24px 24px;
    opacity: 0.4;
}

.skill-hero-inner {
    text-align: center;
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.skill-hero-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-bottom: 8px;
    background: color-mix(in srgb, var(--skill-color) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--skill-color) 20%, transparent);
    border-radius: 12px;
    font-size: 20px;
    color: var(--skill-color);
}

.skill-hero-title {
    font-size: clamp(24px, 3vw, 32px);
    font-weight: 800;
    margin: 0 0 4px;
    letter-spacing: -0.02em;
    color: var(--skill-text);
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.skill-hero-sub {
    font-size: 15px;
    color: #444446; /* Darker than muted for better contrast */
    max-width: 650px;
    margin: 0 auto 12px;
    line-height: 1.4;
    font-weight: 500;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
}

.skill-hero-meta {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.skill-hero-count {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: #f5f5f7;
    border: 1px solid var(--skill-border);
    border-radius: 999px;
    font-weight: 600;
    font-size: 13px;
    color: var(--skill-muted);
}

/* ==========================================================================
   BODY LAYOUT
   ========================================================================== */
.skill-body {
    /* Padding is handled by .ss-pd of the theme now */
}

.container-fluid-skill {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}





/* ==========================================================================
   CONTENT (main grid)
   ========================================================================== */
.skill-content {
    min-width: 0;
}

/* Layout NATURAL — sidebar giữ height tự nhiên theo content (collapse/expand
   filter blocks). Cards row tự fetch thêm để bottom card cuối align với
   bottom sidebar (logic ở skill-filter.js auto-fill). KHÔNG dùng stretch
   vì sẽ kéo sidebar thẳng với pagination level (sai). */

.skill-active-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.skill-active-filters:empty {
    display: none;
    margin-bottom: 0;
}

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

.skill-tag {
    display: inline-block;
    padding: 4px 12px;
    background: color-mix(in srgb, var(--skill-color) 15%, transparent);
    color: var(--skill-color);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
}

.skill-clear-all {
    margin-left: auto;
    background: transparent;
    border: 1px solid var(--skill-border);
    padding: 4px 12px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 13px;
    color: var(--skill-muted);
    transition: all .2s ease;
}

.skill-clear-all:hover {
    border-color: var(--skill-color);
    color: var(--skill-color);
}

.skill-results {
    position: relative;
    min-height: 200px;
}

.skill-results.is-loading {
    opacity: 0.5;
    pointer-events: none;
}

.skill-results .exam-list.row {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    /* Reset Bootstrap .row negative margin */
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Reset Bootstrap .col / .col-4 fixed flex width — để grid template điều khiển */
.skill-results .exam-list.row > .col,
.skill-results .exam-list.row > [class*="col-"] {
    flex: unset !important;
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

/* Tablet 576-991 → 2 cols */
@media (max-width: 991px) {
    .skill-results .exam-list.row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
    }
}

/* Mobile ≤575 → 1 col full width (autofit, card hiển thị đầy đủ) */
@media (max-width: 575px) {
    .skill-results .exam-list.row {
        grid-template-columns: 1fr;
        gap: 14px;
    }
}

.skill-results .exam-list .col {
    width: auto;
    padding: 0;
    min-width: 0;
}

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE/TABLET CARD AUTO-RESIZE (≤991px) — clamp() fluid scaling.
   Dùng `html body` boost specificity để override mona-custom.css
   `text-align: -webkit-center !important` (làm block shrink-to-fit
   → title wrap từng ký tự).
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 991px) {
    html body .skill-results .exam-list .exq-it {
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }

    /* Image fill 100% (override `.b-image .inner { width:85% }`) */
    html body .skill-results .exam-list .exq-it .b-image,
    html body .skill-results .exam-list .exq-it .b-image .inner {
        width: 100% !important;
        max-width: 100% !important;
    }
    html body .skill-results .exam-list .exq-it .b-image.portrait-img .inner {
        width: clamp(50%, 50vw, 70%) !important;
    }
    html body .skill-results .exam-list .exq-it .b-image img {
        width: 100% !important;
        height: auto !important;
        display: block !important;
    }

    /* Content container — full width, text-align left (KILL -webkit-center) */
    html body .skill-results .exam-list .exq-it .b-ctn,
    html body .skill-results .exam-list .exq-it .b-head,
    html body .skill-results .exam-list .exq-it .b-bot {
        width: 100% !important;
        text-align: left !important;
        box-sizing: border-box !important;
    }
    html body .skill-results .exam-list .exq-it .b-ctn {
        padding: clamp(8px, 2vw, 14px) clamp(10px, 2.5vw, 16px) clamp(4px, 1vw, 8px) !important;
        flex: 1 !important;
    }

    /* Title — auto-scale + line-clamp + KILL -webkit-center */
    html body .skill-results .exam-list .exq-it .b-ctn .text,
    html body .skill-results .exam-list .exq-it .b-ctn h3.text {
        font-size: clamp(13px, 3.6vw, 18px) !important;
        line-height: 1.35 !important;
        margin: 0 !important;
        padding: 0 !important;
        text-align: left !important;
        text-justify: auto !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 4 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        word-break: normal !important;
        overflow-wrap: anywhere !important;
        white-space: normal !important;
        width: 100% !important;
        max-width: 100% !important;
        font-weight: 600 !important;
        color: inherit !important;
    }

    /* Meta row — horizontal wrap (KILL flex-direction:column) */
    html body .skill-results .exam-list .exq-it .b-bot {
        padding: clamp(4px, 1vw, 8px) clamp(10px, 2.5vw, 16px) clamp(8px, 2vw, 14px) !important;
    }
    html body .skill-results .exam-list .exq-it .b-bot .b-gr {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 4px 10px !important;
        align-items: center !important;
        justify-content: flex-start !important;
        width: 100% !important;
    }
    html body .skill-results .exam-list .exq-it .b-bot .t-gr {
        display: inline-flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 4px !important;
        width: auto !important;
        min-width: 0 !important;
    }
    html body .skill-results .exam-list .exq-it .b-bot .t-gr .icon {
        width: clamp(11px, 2.8vw, 14px) !important;
        height: clamp(11px, 2.8vw, 14px) !important;
        flex: 0 0 clamp(11px, 2.8vw, 14px) !important;
        display: inline-flex !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    html body .skill-results .exam-list .exq-it .b-bot .t-gr .icon img {
        width: 100% !important;
        height: auto !important;
        margin: 0 !important;
    }
    html body .skill-results .exam-list .exq-it .b-bot .t-gr .txt {
        font-size: clamp(9px, 2.5vw, 12px) !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Tag chips — compact */
    html body .skill-results .exam-list .exq-it .b-head {
        padding: clamp(6px, 1.5vw, 10px) clamp(8px, 2vw, 14px) clamp(2px, 0.8vw, 6px) !important;
    }
    html body .skill-results .exam-list .exq-it .b-head .tag-parts {
        gap: 3px !important;
        flex-wrap: wrap !important;
    }
    html body .skill-results .exam-list .exq-it .b-head .tag-part,
    html body .skill-results .exam-list .exq-it .b-head .tag {
        font-size: clamp(8px, 2.2vw, 11px) !important;
        padding: 2px 7px !important;
        border-radius: 999px !important;
        line-height: 1.3 !important;
    }
}

/* Tablet 576-991: 2-col, card hơi hẹp → ẩn avatar pile.
   Mobile ≤575: 1-col full width → avatar pile hiện. */
@media (min-width: 576px) and (max-width: 991px) {
    html body .skill-results .exam-list .exq-it .b-bot .par {
        display: none !important;
    }
}

.skill-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(2px);
    z-index: 10;
}

.skill-loading[hidden] {
    display: none !important;
}

.skill-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--skill-border);
    border-top-color: #5e5ce6; /* Premium Indigo */
    border-radius: 50%;
    animation: skill-spin .8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

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

.mona-empty-message {
    text-align: center;
    padding: 60px 20px;
    color: var(--skill-muted);
    background: var(--skill-card);
    border: 1px dashed var(--skill-border);
    border-radius: 12px;
}

/* 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);
}

/* ==========================================================================
   CARD BADGE TAG-PARTS (apply on .exq-it cards globally)
   ========================================================================== */
.exq-it .b-head .tag-parts {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
    z-index: 2;
}

.exq-it .b-head .tag-part {
    display: inline-block;
    padding: 5px 12px;
    color: #fff !important;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   PASSAGE / SECTION / TASK / PART BADGE — universal rule
   Applies on EVERY context where the badge is rendered: skill library cards,
   search-results cards, related-exams strips, archives, single overview page.
   The badge has class="tag tag-part" with background-color set inline (skill
   color). This rule overrides any global .tag color rules so the white text
   stays readable in light mode regardless of where the markup appears.
   ========================================================================== */
.tag.tag-part,
span.tag.tag-part {
    color: #fff !important;
    background-color: var(--tag-part-bg, #666); /* fallback if inline missing */
    border: none !important;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
    -webkit-text-fill-color: #fff !important; /* Safari fallback */
}
.tag.tag-part *,
span.tag.tag-part * {
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
}
