/* ── Courses Map Block ──────────────────────────────────────────────────── */

.courses-map {
    padding: 64px 0;
    background: var(--wp--preset--color--white);
}

/* ── Header ─────────────────────────────────────────────────────────────── */

.cm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 40px;
    margin-bottom: 48px;
}

.cm-header__left {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cm-header__right {
    flex-shrink: 0;
}

.cm-header__btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.cm-header__btn svg {
    flex-shrink: 0;
}

/* ── 4-column newspaper layout ──────────────────────────────────────────── */

.cm-grid {
    columns: 4;
    column-gap: 24px;
}

/* ── Category card ──────────────────────────────────────────────────────── */

.cm-cat {
    break-inside: avoid;
    margin-bottom: 20px;
    background: #f5f5f7;
    border-radius: 6px;
    overflow: hidden;
}

/* Category header row */
.cm-cat__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    background: #e8e8ee;
    border: none;
    padding: 12px 16px;
    cursor: default;
    text-align: left;
    border-radius: 6px 6px 0 0;
}

/* Category name as link */
.cm-cat__name-link {
    font-size: 18px;
    font-weight: 700;
    color: var(--wp--preset--color--black);
    line-height: 1.3;
    text-decoration: none;
    flex: 1;
}

.cm-cat__name-link:hover {
    color: var(--wp--preset--color--purple-500);
}

.cm-cat__chevron {
    display: none;
    flex-shrink: 0;
    color: var(--wp--preset--color--neutral-300);
}

/* ── Category body ──────────────────────────────────────────────────────── */

.cm-cat__body {
    padding: 4px 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ── Subcategory ────────────────────────────────────────────────────────── */

.cm-subcat {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Subcategory name — medium, muted, link */
.cm-subcat__name {
    font-size: 16px;
    font-weight: 600;
    color: #4a4a5a;
    text-decoration: none;
    line-height: 1.4;
    display: block;
    margin-bottom: 2px;
}

.cm-subcat__name:hover {
    color: var(--wp--preset--color--purple-500);
}

/* ── Course list ────────────────────────────────────────────────────────── */

.cm-courses {
    list-style: none;
    padding: 0 0 0 10px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
    border-left: 2px solid #e0e0e8;
}

.cm-course__link {
    font-size: 14px;
    font-weight: 300;
    color: var(--wp--preset--color--dark);
    text-decoration: none;
    line-height: 1.5;
    display: block;
    padding: 1px 0;
    transition: color 0.15s;
}

.cm-course__link:hover {
    color: var(--wp--preset--color--purple-500);
}

/* ── Mobile footer button ───────────────────────────────────────────────── */

.cm-footer {
    display: none;
}

/* ── Mobile (1 column + accordions) ────────────────────────────────────── */

@media (max-width: 768px) {
    .courses-map {
        padding: 32px 0;
    }

    .cm-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
        margin-bottom: 24px;
    }

    .cm-header__right {
        display: none;
    }

    .cm-footer {
        display: flex;
        justify-content: center;
        margin-top: 24px;
    }

    .cm-grid {
        columns: 1;
        column-gap: 0;
    }

    .cm-cat {
        break-inside: auto;
        margin-bottom: 0;
        background: none;
        border-radius: 0;
        border-bottom: 1px solid #e4e4ea;
        overflow: visible;
    }

    .cm-cat:first-child {
        border-top: 1px solid #e4e4ea;
    }

    .cm-cat__head {
        padding: 16px 0;
        cursor: pointer;
    }

    .cm-cat__chevron {
        display: block;
        transition: transform 0.3s ease;
    }

    .cm-cat__head[aria-expanded="true"] .cm-cat__chevron {
        transform: rotate(180deg);
    }

    .cm-cat__body {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.4s ease;
        padding: 0;
        gap: 0;
    }

    .cm-cat__body.is-open {
        max-height: 6000px;
        padding-bottom: 20px;
        gap: 14px;
    }

    .cm-subcat__name {
        font-size: 14px;
    }

    .cm-course__link {
        font-size: 14px;
        padding: 2px 0;
    }
}

/* ── Dark mode ──────────────────────────────────────────────────────────── */

html[data-theme="dark"] .courses-map {
    background: var(--wp--preset--color--black, #1A1A25);
}

html[data-theme="dark"] .courses-map .sec-headline,
html[data-theme="dark"] .courses-map .sec-headline-icon {
    color: var(--wp--preset--color--yellow, #FFE500);
}

html[data-theme="dark"] .courses-map .sec-title {
    color: var(--wp--preset--color--white);
}

html[data-theme="dark"] .courses-map .sec-desc {
    color: rgba(255, 255, 255, .65);
}

html[data-theme="dark"] .cm-header__btn.btn-primary {
    border-color: var(--wp--preset--color--white);
    color: var(--wp--preset--color--white);
}

html[data-theme="dark"] .cm-header__btn.btn-primary:hover,
html[data-theme="dark"] .cm-header__btn.btn-primary:active {
    background: var(--wp--preset--color--white);
    color: var(--wp--preset--color--black, #1A1A25);
}

html[data-theme="dark"] .cm-cat {
    background: rgba(255, 255, 255, .05);
}

html[data-theme="dark"] .cm-cat__head {
    background: rgba(255, 255, 255, .08);
}

html[data-theme="dark"] .cm-cat__name-link {
    color: var(--wp--preset--color--white);
}

html[data-theme="dark"] .cm-cat__name-link:hover {
    color: var(--wp--preset--color--yellow, #FFE500);
}

html[data-theme="dark"] .cm-cat__chevron {
    color: rgba(255, 255, 255, .5);
}

html[data-theme="dark"] .cm-subcat__name {
    color: rgba(255, 255, 255, .8);
}

html[data-theme="dark"] .cm-subcat__name:hover {
    color: var(--wp--preset--color--yellow, #FFE500);
}

html[data-theme="dark"] .cm-courses {
    border-left-color: rgba(255, 255, 255, .15);
}

html[data-theme="dark"] .cm-course__link {
    color: rgba(255, 255, 255, .65);
}

html[data-theme="dark"] .cm-course__link:hover {
    color: var(--wp--preset--color--yellow, #FFE500);
}

@media (max-width: 768px) {
    html[data-theme="dark"] .cm-cat {
        background: none;
        border-bottom-color: rgba(255, 255, 255, .15);
    }

    html[data-theme="dark"] .cm-cat:first-child {
        border-top-color: rgba(255, 255, 255, .15);
    }
}
