/* ── Courses Related ────────────────────────────────────────────── */

.courses-related {
    padding-top: 96px;
    padding-bottom: 96px;
    background: var(--wp--preset--color--white);
    overflow: hidden;
}

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

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

.cr-header-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cr-header-right {
    flex-shrink: 0;
}

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

.cr-btn svg {
    flex-shrink: 0;
}

/* ── Footer button (mobile only) ────────────────────────────────── */

.cr-footer {
    display: none;
}

/* ── Card ────────────────────────────────────────────────────────── */

.cr-card {
    display: flex;
    flex-direction: column;
    background: var(--wp--preset--color--white);
    border-radius: 4px;
    box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    height: 100%;
    box-sizing: border-box;
    transition: box-shadow 0.2s ease;
}

.cr-card:hover {
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.15);
}

/* ── Card image wrapper ─────────────────────────────────────────── */

.cr-card-img-wrap {
    padding: 16px 16px 0;
}

/* ── Card image ─────────────────────────────────────────────────── */

.cr-card-image {
    position: relative;
    width: 100%;
    aspect-ratio: 416 / 224;
    overflow: hidden;
    background: var(--wp--preset--color--neutral-100);
    border-radius: 4px;
}

.cr-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Book cover — never crop, letterbox on a neutral bg instead */
.cr-card--book .cr-card-image img {
    object-fit: contain;
    padding: 16px;
    box-sizing: border-box;
    background: var(--wp--preset--color--neutral-100, #f5f5fc);
}

.cr-card-image::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.40);
    transition: opacity 0.3s ease;
    pointer-events: none;
}

@media (hover: hover) {
    .cr-card:hover .cr-card-image::after {
        opacity: 0;
    }
}

/* Shared flex row instead of independently absolutely-positioned corners -
   .cr-card-cat can now truncate against .cr-card-promo's actual rendered
   width (which varies with its own padding/icon/text) instead of a guessed
   fixed offset, so they never overlap at any card width. */
.cr-card-badges {
    position: absolute;
    top: 24px;
    left: 24px;
    right: 24px;
    z-index: 1;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.cr-card-cat {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    backdrop-filter: blur(2px);
    background: rgba(26, 26, 37, 0.5);
    border: 1px solid var(--wp--preset--color--neutral-300);
    color: var(--wp--preset--color--white);
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    padding: 8px 12px;
    border-radius: 4px;
}

/* margin-left: auto (not justify-content: space-between on the parent) so
   this still sticks to the right edge when it's the only badge in the row
   (no category) - space-between would collapse a lone flex item to the
   start instead. */
.cr-card-promo {
    flex-shrink: 0;
    margin-left: auto;
}

/* ── Card body ──────────────────────────────────────────────────── */

.cr-card-body {
    padding: 32px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── Tags ───────────────────────────────────────────────────────── */

.cr-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.cr-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 4px;
    background: rgba(236, 72, 153, 0.05);
    color: var(--wp--preset--color--pink);
    border: 1px solid var(--wp--preset--color--pink-light);
}

.cr-tag::before {
    content: '';
    display: block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--wp--preset--color--pink);
}

.cr-tag--nowosc {
    background: rgba(139, 92, 246, 0.05);
    color: var(--wp--preset--color--purple);
    border-color: #e0d7f6;
}

.cr-tag--nowosc::before {
    background: var(--wp--preset--color--purple);
}

/* ── Card title ─────────────────────────────────────────────────── */

.cr-card-title {
    margin: 0;
    font-size: 24px;
    font-weight: 400;
    line-height: 1.2;
    color: var(--wp--preset--color--black);
}

/* ── Card meta ──────────────────────────────────────────────────── */

.cr-card-meta {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.cr-card-date,
.cr-card-days,
.cr-card-loc {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    color: var(--wp--preset--color--neutral-300);
}

.cr-card-date svg,
.cr-card-days svg,
.cr-card-loc svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

/* ── Card price ─────────────────────────────────────────────────── */

.cr-card-price {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.cr-price__netto,
.cr-price__brutto {
    font-size: 20px;
    font-weight: 400;
    line-height: 28px;
    color: var(--wp--preset--color--dark);
    white-space: nowrap;
}

.cr-price__netto del,
.cr-price__brutto del {
    color: #8f8fa8;
    text-decoration: line-through;
    margin-right: 2px;
}

.cr-price__sep {
    color: var(--wp--preset--color--neutral-200);
    font-size: 16px;
    line-height: 1;
    user-select: none;
}

/* ── Desktop: CSS grid (992px+) ─────────────────────────────────── */

@media (min-width: 992px) {
    .cr-swiper.swiper {
        overflow: visible;
    }

    .cr-grid.swiper-wrapper {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr);
        gap: 32px;
        transform: none !important;
        will-change: auto;
    }

    .cr-swiper .swiper-slide {
        width: auto !important;
        margin: 0 !important;
    }

    .cr-pagination {
        display: none;
    }
}

/* ── Mobile: Swiper (≤991px) ────────────────────────────────────── */

@media (max-width: 991px) {
    .courses-related {
        padding-top: 80px;
        padding-bottom: 56px;
    }

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

    .cr-header-left {
        gap: 12px;
    }

    .cr-header-right {
        display: none;
    }

    .cr-footer {
        display: block;
        margin-top: 24px;
    }

    .cr-footer .cr-btn {
        width: 100%;
        justify-content: center;
    }

    .cr-swiper.swiper {
        overflow: visible;
    }

    .cr-swiper .swiper-wrapper {
        align-items: stretch;
    }

    .cr-swiper .swiper-slide {
        height: auto;
    }

    .cr-pagination {
        position: static !important;
        margin-top: 32px;
        display: flex !important;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }

    .cr-pagination .swiper-pagination-bullet {
        width: 12px;
        height: 12px;
        background-color: var(--wp--preset--color--neutral-200);
        opacity: 1;
        border-radius: 50%;
        transform: scale(0.667);
        transition: transform 0.2s ease, background-color 0.2s ease;
        margin: 0 !important;
    }

    .cr-pagination .swiper-pagination-bullet-active {
        transform: scale(1);
        background-color: var(--wp--preset--color--black);
    }
}

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

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

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

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

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

html[data-theme="dark"] .courses-related .cr-btn {
    border-color: var(--wp--preset--color--white);
    color: var(--wp--preset--color--white);
}

html[data-theme="dark"] .courses-related .cr-btn:hover,
html[data-theme="dark"] .courses-related .cr-btn:active {
    background: var(--wp--preset--color--white);
    color: var(--wp--preset--color--dark, #2E2E39);
}

html[data-theme="dark"] .cr-card {
    background: var(--wp--preset--color--dark, #2E2E39);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}

html[data-theme="dark"] .cr-card:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, .35);
}

html[data-theme="dark"] .cr-card-image,
html[data-theme="dark"] .cr-card--book .cr-card-image img {
    background: rgba(255, 255, 255, .06);
}

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

html[data-theme="dark"] .cr-card-date,
html[data-theme="dark"] .cr-card-days,
html[data-theme="dark"] .cr-card-loc {
    color: rgba(255, 255, 255, .6);
}

html[data-theme="dark"] .cr-price__netto,
html[data-theme="dark"] .cr-price__brutto {
    color: var(--wp--preset--color--white);
}

html[data-theme="dark"] .cr-price__netto del,
html[data-theme="dark"] .cr-price__brutto del {
    color: rgba(255, 255, 255, .4);
}

html[data-theme="dark"] .cr-price__sep {
    color: rgba(255, 255, 255, .3);
}

html[data-theme="dark"] .cr-tag {
    background: rgba(236, 72, 153, 0.12);
    border-color: rgba(236, 72, 153, 0.35);
}

html[data-theme="dark"] .cr-tag--nowosc {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.4);
}

html[data-theme="dark"] .cr-pagination .swiper-pagination-bullet {
    background-color: rgba(255, 255, 255, .2);
}

html[data-theme="dark"] .cr-pagination .swiper-pagination-bullet-active {
    background-color: var(--wp--preset--color--white);
}
