/*
 * Me Learning Course Catalogue — mlcc.css
 * All rules scoped to #mlcc-catalogue to beat Kadence/WooCommerce specificity.
 * Colours pull from Kadence Global Palette vars — no hardcoded brand values.
 */

/* ── Custom properties ─────────────────────────────────────────────────────── */
#mlcc-catalogue {
    --mlcc-radius:       8px;
    --mlcc-radius-pill:  100px;
    --mlcc-gap:          20px;
    --mlcc-focus-ring:   color-mix(in srgb, var(--global-palette1) 22%, transparent);
    --mlcc-shadow:       0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
    --mlcc-shadow-hover: 0 8px 24px rgba(0,0,0,0.12);
    --mlcc-sidebar-w:    220px;
    font-family: var(--global-body-font-family, sans-serif);
    color: var(--global-palette4);

    /* ── Sidebar + main layout ── */
    display: flex;
    gap: 36px;
    align-items: flex-start;
}

/* ── Screen-reader utility ─────────────────────────────────────────────────── */
#mlcc-catalogue .mlcc-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
#mlcc-catalogue .mlcc-sidebar {
    width: var(--mlcc-sidebar-w);
    flex-shrink: 0;
    position: sticky;
    top: 24px;
}

/* ── Main content area ─────────────────────────────────────────────────────── */
#mlcc-catalogue .mlcc-main {
    flex: 1;
    min-width: 0; /* prevent flex overflow */
}

/* ── Category list (sidebar) ───────────────────────────────────────────────── */
#mlcc-catalogue .mlcc-categories {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 6px;
}

#mlcc-catalogue .mlcc-cat-btn {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    text-align: left;
    padding: 7px 12px;
    border: none;
    border-radius: var(--mlcc-radius);
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    font-family: var(--global-body-font-family, sans-serif);
    font-weight: 500;
    color: var(--global-palette4);
    line-height: 1.4;
    transition: background 0.12s, color 0.12s;
    box-shadow: none;
}
#mlcc-catalogue .mlcc-cat-btn:hover {
    background: var(--global-palette8);
    color: var(--global-palette1);
}
#mlcc-catalogue .mlcc-cat-btn.active {
    background: var(--global-palette1) !important;
    color: var(--global-palette9) !important;
    font-weight: 600;
}
#mlcc-catalogue .mlcc-cat-btn.active .mlcc-count {
    opacity: 0.75;
}
#mlcc-catalogue .mlcc-cat-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--mlcc-focus-ring);
}
#mlcc-catalogue .mlcc-count {
    flex-shrink: 0;
    opacity: 0.55;
    font-size: 12px;
    font-weight: 400;
    margin-left: 6px;
}

/* ── Sidebar separator items ───────────────────────────────────────────────── */
#mlcc-catalogue .mlcc-sidebar-divider {
    border: none;
    border-top: 1px solid var(--global-palette7);
    margin: 8px 4px;
}

#mlcc-catalogue .mlcc-sidebar-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--global-palette5);
    padding: 10px 12px 4px;
    margin: 0;
}

#mlcc-catalogue .mlcc-sidebar-spacer {
    height: 14px;
}

/* ── Toolbar ───────────────────────────────────────────────────────────────── */
#mlcc-catalogue .mlcc-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    align-items: center;
    flex-wrap: wrap;
}

#mlcc-catalogue .mlcc-search {
    flex: 1;
    min-width: 160px;
    padding: 9px 14px;
    border: 1.5px solid var(--global-palette6);
    border-radius: var(--mlcc-radius);
    font-size: 14px;
    font-family: var(--global-body-font-family, sans-serif);
    background: var(--global-palette9);
    color: var(--global-palette4);
    outline: none;
    box-shadow: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
#mlcc-catalogue .mlcc-search::placeholder {
    color: var(--global-palette5);
}
#mlcc-catalogue .mlcc-search:focus {
    border-color: var(--global-palette1);
    box-shadow: 0 0 0 3px var(--mlcc-focus-ring);
}

#mlcc-catalogue .mlcc-sort {
    padding: 9px 36px 9px 12px;
    border: 1.5px solid var(--global-palette6);
    border-radius: var(--mlcc-radius);
    font-size: 14px;
    font-family: var(--global-body-font-family, sans-serif);
    background-color: var(--global-palette9);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    color: var(--global-palette4);
    cursor: pointer;
    outline: none;
    box-shadow: none;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
#mlcc-catalogue .mlcc-sort:focus {
    border-color: var(--global-palette1);
    box-shadow: 0 0 0 3px var(--mlcc-focus-ring);
}

/* ── Clear filters ─────────────────────────────────────────────────────────── */
#mlcc-catalogue .mlcc-clear-btn {
    padding: 8px 14px;
    border: 1.5px solid var(--global-palette6);
    border-radius: var(--mlcc-radius);
    background: var(--global-palette9);
    color: var(--global-palette4);
    font-size: 13px;
    font-family: var(--global-body-font-family, sans-serif);
    cursor: pointer;
    white-space: nowrap;
    box-shadow: none;
    transition: background 0.15s, border-color 0.15s;
    flex-shrink: 0;
}
#mlcc-catalogue .mlcc-clear-btn:hover {
    background: var(--global-palette8);
    border-color: var(--global-palette5);
}
#mlcc-catalogue .mlcc-clear-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--mlcc-focus-ring);
}

/* ── View toggle ───────────────────────────────────────────────────────────── */
#mlcc-catalogue .mlcc-view-toggle {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
#mlcc-catalogue .mlcc-view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1.5px solid var(--global-palette6);
    border-radius: var(--mlcc-radius);
    background: var(--global-palette9);
    color: var(--global-palette5);
    cursor: pointer;
    box-shadow: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#mlcc-catalogue .mlcc-view-btn:hover,
#mlcc-catalogue .mlcc-view-btn.active {
    background: var(--global-palette1) !important;
    border-color: var(--global-palette1) !important;
    color: var(--global-palette9) !important;
}
#mlcc-catalogue .mlcc-view-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--mlcc-focus-ring);
}

/* ── Status line ───────────────────────────────────────────────────────────── */
#mlcc-catalogue .mlcc-status {
    font-size: 13px;
    color: var(--global-palette5);
    margin-bottom: 16px;
    min-height: 1.4em;
}

/* ── Grid ──────────────────────────────────────────────────────────────────── */
#mlcc-catalogue .mlcc-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important;
    gap: var(--mlcc-gap) !important;
    position: relative;
    transition: opacity 0.2s;
    list-style: none;
    margin: 0;
    padding: 0;
}
#mlcc-catalogue .mlcc-grid.mlcc-loading {
    opacity: 0.45;
    pointer-events: none;
}

/* ── Card ──────────────────────────────────────────────────────────────────── */
#mlcc-catalogue .mlcc-card {
    display: flex !important;
    flex-direction: column !important;
    background: var(--global-palette9);
    border-radius: var(--mlcc-radius);
    border: 1px solid var(--global-palette7);
    overflow: hidden;
    position: relative;
    box-shadow: var(--mlcc-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    width: 100%;
    float: none;
    margin: 0;
    padding: 0;
}
#mlcc-catalogue .mlcc-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--mlcc-shadow-hover);
    border-color: var(--global-palette6);
}

#mlcc-catalogue .mlcc-card-img-link {
    display: block !important;
    overflow: hidden;
    flex-shrink: 0;
    padding: 0;
    margin: 0;
}
#mlcc-catalogue .mlcc-card-img-link img {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block !important;
    transition: transform 0.3s ease;
    max-width: none;
}
#mlcc-catalogue .mlcc-card:hover .mlcc-card-img-link img {
    transform: scale(1.03);
}

#mlcc-catalogue .mlcc-card-body {
    padding: 16px 18px 18px;
    display: flex !important;
    flex-direction: column !important;
    flex: 1;
}

/* ── Card title ────────────────────────────────────────────────────────────── */
#mlcc-catalogue .mlcc-card-title {
    font-family: var(--global-heading-font-family, sans-serif);
    font-size: 15px;
    font-weight: 600;
    color: var(--global-palette3);
    margin: 0 0 10px;
    line-height: 1.35;
}
#mlcc-catalogue .mlcc-card-title a {
    color: var(--global-palette3) !important;
    text-decoration: none !important;
    box-shadow: none !important;
}
#mlcc-catalogue .mlcc-card-title a:hover {
    color: var(--global-palette1) !important;
}

/* ── New ribbon ────────────────────────────────────────────────────────────── */
#mlcc-catalogue .mlcc-ribbon {
    position: absolute;
    top: 12px;
    left: 0;
    z-index: 2;
    background: var(--global-palette1);
    color: var(--global-palette9);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 4px 10px 4px 8px;
    border-radius: 0 4px 4px 0;
    line-height: 1;
    pointer-events: none;
}

/* ── Accreditation badges ──────────────────────────────────────────────────── */
#mlcc-catalogue .mlcc-card-meta {
    margin-bottom: 10px;
}
#mlcc-catalogue .mlcc-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 7px;
}
#mlcc-catalogue .mlcc-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border: 1px solid var(--global-palette6);
    border-radius: var(--mlcc-radius-pill);
    font-size: 11px;
    color: var(--global-palette4);
    white-space: nowrap;
    line-height: 1.6;
    background: transparent;
}
#mlcc-catalogue .mlcc-badge::before {
    content: '✓';
    font-weight: 700;
    font-size: 10px;
    color: var(--global-palette1);
}

/* ── Duration ──────────────────────────────────────────────────────────────── */
#mlcc-catalogue .mlcc-duration {
    font-size: 12px;
    color: var(--global-palette5);
    margin: 0;
}
#mlcc-catalogue .mlcc-duration strong {
    color: var(--global-palette4);
    font-weight: 600;
}

/* ── Excerpt (hidden in grid, shown in list view) ──────────────────────────── */
#mlcc-catalogue .mlcc-card-excerpt {
    display: none;
    font-size: 13px;
    color: var(--global-palette5);
    line-height: 1.6;
    margin: 8px 0 0;
}

/* ── Price ─────────────────────────────────────────────────────────────────── */
#mlcc-catalogue .mlcc-card-price {
    margin-top: auto;
    padding-top: 10px;
    font-weight: 700;
    font-size: 15px;
    line-height: 1.4;
}
#mlcc-catalogue .mlcc-card-price del {
    font-weight: 400;
    opacity: 0.5;
    margin-right: 4px;
}
#mlcc-catalogue .mlcc-card-price ins {
    text-decoration: none !important;
    color: var(--global-palette1);
}

/* ── CTA / Add to cart button ──────────────────────────────────────────────── */
#mlcc-catalogue .mlcc-card-btn {
    display: block !important;
    margin-top: 12px;
    padding: 10px 18px !important;
    background: var(--global-palette1) !important;
    color: var(--global-palette9) !important;
    text-align: center !important;
    border-radius: var(--mlcc-radius) !important;
    font-family: var(--global-body-font-family, sans-serif) !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    text-decoration: none !important;
    border: none !important;
    box-shadow: none !important;
    cursor: pointer;
    line-height: 1.4 !important;
    transition: background 0.15s;
    box-sizing: border-box;
    width: 100%;
}
#mlcc-catalogue .mlcc-card-btn:hover {
    background: var(--global-palette2) !important;
    color: var(--global-palette9) !important;
    text-decoration: none !important;
}
#mlcc-catalogue .mlcc-card-btn:focus-visible {
    outline: none !important;
    box-shadow: 0 0 0 3px var(--mlcc-focus-ring) !important;
}

/* ── "View basket" injected by WooCommerce after AJAX add-to-cart ──────────── */
#mlcc-catalogue .added_to_cart {
    display: block !important;
    text-align: center;
    font-size: 12px;
    color: var(--global-palette1) !important;
    text-decoration: underline !important;
    margin-top: 6px;
    box-shadow: none !important;
}
#mlcc-catalogue .added_to_cart:hover {
    color: var(--global-palette2) !important;
}

/* ── No results ────────────────────────────────────────────────────────────── */
#mlcc-catalogue .mlcc-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 20px;
    color: var(--global-palette5);
    font-size: 15px;
}

/* ── Pagination ────────────────────────────────────────────────────────────── */
#mlcc-catalogue .mlcc-pagination {
    margin-top: 32px;
}
#mlcc-catalogue .mlcc-pages {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    align-items: center;
}
#mlcc-catalogue .mlcc-page a,
#mlcc-catalogue .mlcc-page span {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    border: 1.5px solid var(--global-palette6) !important;
    border-radius: var(--mlcc-radius);
    font-size: 14px;
    font-family: var(--global-body-font-family, sans-serif);
    text-decoration: none !important;
    color: var(--global-palette4) !important;
    background: var(--global-palette9) !important;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    line-height: 1;
    box-shadow: none !important;
}
#mlcc-catalogue .mlcc-page a:hover {
    border-color: var(--global-palette1) !important;
    color: var(--global-palette1) !important;
}
#mlcc-catalogue .mlcc-page.current span {
    background: var(--global-palette1) !important;
    border-color: var(--global-palette1) !important;
    color: var(--global-palette9) !important;
    font-weight: 700;
}
#mlcc-catalogue .mlcc-page-dots span {
    border: none !important;
    background: transparent !important;
    color: var(--global-palette5) !important;
    min-width: auto;
}

/* ── List view ─────────────────────────────────────────────────────────────── */
#mlcc-catalogue .mlcc-grid.mlcc-view-list {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
}
#mlcc-catalogue .mlcc-grid.mlcc-view-list .mlcc-card {
    flex-direction: row !important;
    height: 150px;
}
#mlcc-catalogue .mlcc-grid.mlcc-view-list .mlcc-card-img-link {
    width: 200px;
    flex-shrink: 0;
}
#mlcc-catalogue .mlcc-grid.mlcc-view-list .mlcc-card-img-link img {
    aspect-ratio: unset !important;
    height: 100% !important;
}
#mlcc-catalogue .mlcc-grid.mlcc-view-list .mlcc-card-body {
    padding: 10px 16px !important;
    overflow: hidden;
}
#mlcc-catalogue .mlcc-grid.mlcc-view-list .mlcc-card-meta {
    display: none;
}
#mlcc-catalogue .mlcc-grid.mlcc-view-list .mlcc-card-title {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0;
}
#mlcc-catalogue .mlcc-grid.mlcc-view-list .mlcc-card-excerpt {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
/* Hide the discount-plugin promo div injected inside price in list view */
#mlcc-catalogue .mlcc-grid.mlcc-view-list .mlcc-card-price div {
    display: none !important;
}
#mlcc-catalogue .mlcc-grid.mlcc-view-list .mlcc-ribbon {
    top: 10px;
}

/* ── Responsive — sidebar collapses to horizontal scroll row ──────────────── */
@media (max-width: 820px) {
    #mlcc-catalogue {
        flex-direction: column;
        gap: 20px;
    }
    #mlcc-catalogue .mlcc-sidebar {
        width: 100%;
        position: static;
    }
    #mlcc-catalogue .mlcc-categories {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 6px;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    #mlcc-catalogue .mlcc-categories::-webkit-scrollbar {
        display: none;
    }
    #mlcc-catalogue .mlcc-cat-btn {
        white-space: nowrap;
        flex-shrink: 0;
        width: auto !important;
        border: 1.5px solid var(--global-palette6);
        border-radius: var(--mlcc-radius-pill);
        padding: 6px 16px;
    }
    #mlcc-catalogue .mlcc-cat-btn:hover {
        border-color: var(--global-palette1);
        background: transparent;
    }
    #mlcc-catalogue .mlcc-cat-btn.active {
        border-color: var(--global-palette1) !important;
    }
    /* Separator items don't make sense in a horizontal row */
    #mlcc-catalogue .mlcc-sidebar-divider,
    #mlcc-catalogue .mlcc-sidebar-label,
    #mlcc-catalogue .mlcc-sidebar-spacer {
        display: none;
    }
}

@media (max-width: 680px) {
    #mlcc-catalogue .mlcc-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    #mlcc-catalogue .mlcc-search,
    #mlcc-catalogue .mlcc-sort {
        width: 100%;
        min-width: 0;
    }
    #mlcc-catalogue .mlcc-view-toggle {
        align-self: flex-end;
    }
    #mlcc-catalogue .mlcc-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 14px !important;
    }
    #mlcc-catalogue .mlcc-grid.mlcc-view-list .mlcc-card {
        flex-direction: column !important;
        height: auto;
    }
    #mlcc-catalogue .mlcc-grid.mlcc-view-list .mlcc-card-img-link {
        width: 100%;
    }
    #mlcc-catalogue .mlcc-grid.mlcc-view-list .mlcc-card-img-link img {
        aspect-ratio: 16 / 9 !important;
        height: auto !important;
    }
}

@media (max-width: 420px) {
    #mlcc-catalogue .mlcc-grid {
        grid-template-columns: 1fr !important;
    }
}
