/* ==========================================================================
   Course detail page — modern layout
   Everything is scoped under .cx-page so it cannot leak into other pages.
   Direction-agnostic: uses logical properties, so RTL works without overrides.
   Brand colour is injected inline from settings() as --cx-primary.
   ========================================================================== */

.cx-page {
    /* --cx-primary is overridden inline from settings('primary_color') so every
       deployment keeps its own branding. Hover states derive from it with a
       brightness filter, so no second colour needs configuring. */
    --cx-primary: #0066cc;
    --cx-hero-1: #232d3b;
    --cx-hero-2: #16202c;
    --cx-ink: #16202c;
    --cx-muted: #667085;
    --cx-line: #e6e9ef;
    --cx-bg: #f6f8fb;
    --cx-card: #fff;
    --cx-radius: 14px;
    --cx-shadow: 0 10px 30px -18px rgba(16, 32, 44, .35);

    background: var(--cx-bg);
    padding-bottom: 56px;
    color: var(--cx-ink);
}

.cx-container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ---------- breadcrumb ---------- */
.cx-crumbs {
    padding: 14px 0;
    font-size: .86rem;
}

.cx-crumbs ol {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.cx-crumbs a {
    color: var(--cx-muted);
    text-decoration: none;
}

.cx-crumbs a:hover {
    color: var(--cx-primary);
}

.cx-crumbs li+li::before {
    content: "›";
    color: #b9c0cc;
    margin-inline-end: 6px;
}

.cx-crumbs .is-current {
    color: var(--cx-ink);
    font-weight: 600;
}

/* ---------- hero ---------- */
.cx-hero {
    background: linear-gradient(135deg, var(--cx-hero-1) 0%, var(--cx-hero-2) 100%);
    color: #fff;
    border-radius: var(--cx-radius);
    padding: 30px 32px 92px;
    position: relative;
    overflow: hidden;
}

.cx-hero::after {
    content: "";
    position: absolute;
    inset-block-start: -40%;
    inset-inline-end: -10%;
    width: 380px;
    height: 380px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .07);
}

.cx-hero-inner {
    position: relative;
    z-index: 1;
    max-width: 68%;
}

.cx-title {
    font-size: clamp(1.5rem, 2.6vw, 2.15rem);
    font-weight: 800;
    line-height: 1.35;
    margin: 0 0 14px;
    color: #fff;
}

.cx-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 22px;
    font-size: .92rem;
}

.cx-meta span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: rgba(255, 255, 255, .92);
}

.cx-meta i {
    opacity: .85;
}

.cx-meta a {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ---------- layout ---------- */
.cx-grid {
    display: grid;
    grid-template-columns: 1fr 348px;
    gap: 24px;
    align-items: start;
    margin-top: -70px;
}

/* The enrol card is first in the markup, so without explicit placement it took
   the 1fr track and the content was squeezed into the 348px one — that is what
   blew the poster up to full width. Pinning the tracks puts the card in the
   narrow column and, since the page is RTL, column 2 lands on the left. */
.cx-main {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-top: 86px;
}

/* ---------- sticky enrol card ---------- */
.cx-aside {
    grid-column: 2;
    grid-row: 1;
    position: sticky;
    top: 16px;
}

.cx-card {
    background: var(--cx-card);
    border: 1px solid var(--cx-line);
    border-radius: var(--cx-radius);
    box-shadow: var(--cx-shadow);
    overflow: hidden;
}

/* `contain`, not `cover`: course posters are often portrait and carry the
   shaykh's name inside the artwork, so cropping to fill the 16/9 box cut the
   picture. The box keeps its ratio so every card stays the same height; the
   leftover space shows the neutral background instead. */
.cx-thumb {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: contain;
    background: #eef1f6;
}

.cx-card-body {
    padding: 18px;
}

.cx-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    padding: 13px 18px;
    margin-bottom: 10px;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
}

.cx-btn:last-child {
    margin-bottom: 0;
}

.cx-btn:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

.cx-btn-primary {
    background: var(--cx-primary);
    color: #fff;
    box-shadow: 0 8px 18px -8px var(--cx-primary);
}

.cx-btn-primary:hover {
    filter: brightness(.92);
    color: #fff;
}

.cx-btn-success {
    background: #12b886;
    color: #fff;
}

.cx-btn-success:hover {
    background: #0ca678;
    color: #fff;
}

.cx-btn-ghost {
    background: #fff;
    color: var(--cx-ink);
    border-color: var(--cx-line);
}

.cx-btn-ghost:hover {
    border-color: #c9d2e0;
    color: var(--cx-ink);
}

.cx-btn-danger {
    background: #fff;
    color: #c92a2a;
    border-color: #f3c6c6;
}

.cx-btn-danger:hover {
    background: #fff5f5;
    color: #c92a2a;
}

/* status strips */
.cx-note {
    padding: 12px 14px;
    border-radius: 10px;
    font-size: .9rem;
    line-height: 1.6;
    margin-bottom: 10px;
}

.cx-note-success {
    background: #e9f9f2;
    color: #0b6b4f;
    border: 1px solid #b7e6d2;
}

.cx-note-warn {
    background: #fff7e6;
    color: #8a5a00;
    border: 1px solid #f3dca7;
}

.cx-note-danger {
    background: #fdecec;
    color: #a82424;
    border: 1px solid #f3c6c6;
}

.cx-note-info {
    background: #eef4ff;
    color: #1d4ea8;
    border: 1px solid #c7d9f7;
}

.cx-note strong {
    font-weight: 700;
}

.cx-note a {
    color: inherit;
    text-decoration: none;
}

.cx-includes {
    list-style: none;
    margin: 16px 0 0;
    padding: 16px 0 0;
    border-top: 1px solid var(--cx-line);
}

.cx-includes li {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 7px 0;
    font-size: .92rem;
    color: #3d4a5c;
}

.cx-includes i {
    width: 18px;
    text-align: center;
    color: var(--cx-primary);
}

.cx-includes-title {
    font-weight: 700;
    font-size: .95rem;
    margin-bottom: 2px;
}

/* ---------- content cards ---------- */
.cx-block {
    background: var(--cx-card);
    border: 1px solid var(--cx-line);
    border-radius: var(--cx-radius);
    padding: 22px;
}

.cx-block-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.12rem;
    font-weight: 800;
    margin: 0 0 16px;
    color: var(--cx-ink);
}

.cx-block-title::before {
    content: "";
    width: 4px;
    height: 20px;
    border-radius: 3px;
    background: var(--cx-primary);
    flex: none;
}

.cx-prose {
    font-size: .96rem;
    line-height: 1.9;
    color: #3d4a5c;
    word-break: break-word;
}

.cx-prose img {
    max-width: 100%;
    height: auto;
}

/* ---------- collapsible ("show more") ----------
   Self-contained: does NOT use main.js viewMore(), which hardcodes Arabic
   labels. The button hides itself when the content is short enough to fit. */
.cx-collapsible {
    --cx-clamp: 190px;
}

.cx-collapsible-body {
    position: relative;
    max-height: var(--cx-clamp);
    overflow: hidden;
    transition: max-height .35s cubic-bezier(.4, 0, .2, 1);
}

/* fade-out mask, only while collapsed and only when there is more to reveal */
.cx-collapsible:not(.is-open):not(.is-static) .cx-collapsible-body::after {
    content: "";
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    height: 90px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, var(--cx-card) 85%);
    pointer-events: none;
}

.cx-collapsible.is-static .cx-collapsible-body {
    max-height: none;
}

.cx-more {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 14px auto 0;
    padding: 8px 20px;
    font: inherit;
    font-size: .88rem;
    font-weight: 700;
    color: var(--cx-primary);
    background: #fff;
    border: 1px solid var(--cx-line);
    border-radius: 999px;
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

.cx-more:hover {
    border-color: var(--cx-primary);
    box-shadow: 0 4px 12px -6px rgba(16, 32, 44, .4);
}

.cx-more:focus-visible {
    outline: 2px solid var(--cx-primary);
    outline-offset: 2px;
}

.cx-more i {
    font-size: .74rem;
    transition: transform .25s ease;
}

.cx-collapsible.is-open .cx-more i {
    transform: rotate(180deg);
}

.cx-more[hidden] {
    display: none;
}

/* ---------- instructor ---------- */
.cx-tutor {
    display: flex;
    gap: 18px;
    align-items: flex-start;
}

.cx-tutor+.cx-tutor {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--cx-line);
}

.cx-tutor-avatar {
    width: 92px;
    height: 92px;
    border-radius: 50%;
    object-fit: cover;
    flex: none;
    border: 3px solid #fff;
    box-shadow: 0 0 0 1px var(--cx-line);
}

.cx-tutor-name {
    font-size: 1.02rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.cx-tutor-name a {
    color: var(--cx-ink);
    text-decoration: none;
}

.cx-tutor-name a:hover {
    color: var(--cx-primary);
}

.cx-tutor-role {
    font-size: .86rem;
    color: var(--cx-muted);
    margin-bottom: 8px;
}

.cx-tutor-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    font-size: .86rem;
    color: var(--cx-muted);
    margin-bottom: 10px;
}

.cx-tutor-stats i {
    color: var(--cx-primary);
    margin-inline-end: 6px;
}

/* ---------- curriculum ---------- */
/* Title sits on its own line; the counts drop to a second line as chips. */
.cx-curriculum-head {
    margin-bottom: 18px;
}

.cx-curriculum-head .cx-block-title {
    margin-bottom: 12px;
}

.cx-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cx-stat {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 14px;
    border-radius: 999px;
    background: #f2f5f9;
    border: 1px solid var(--cx-line);
    font-size: .82rem;
    font-weight: 600;
    color: #4a5768;
    white-space: nowrap;
}

.cx-stat i {
    color: var(--cx-primary);
    font-size: .8rem;
}

.cx-section-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    background: #f8fafc;
    border: 1px solid var(--cx-line);
    border-radius: 10px;
    cursor: pointer;
    font-size: .96rem;
    transition: background .18s ease;
}

/* Stacked so the name can never butt against the counts, whichever way the
   page reads. */
.cx-section-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
}

.cx-section-name {
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cx-section-head:hover {
    background: #f1f5fa;
}

.cx-section+.cx-section {
    margin-top: 10px;
}

.cx-section-head .cx-chevron {
    transition: transform .2s ease;
    color: var(--cx-muted);
    flex: none;
}

.cx-section-head[aria-expanded="true"] .cx-chevron {
    transform: rotate(90deg);
}

.cx-section-head[aria-expanded="true"] {
    background: #eef4ff;
    border-color: #cfe0f8;
}

.cx-section-meta {
    font-size: .8rem;
    font-weight: 600;
    color: var(--cx-muted);
}

.cx-lessons {
    list-style: none;
    margin: 0;
    padding: 6px 0 0;
}

.cx-lesson a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 14px;
    border-radius: 9px;
    text-decoration: none;
    color: #33404f;
    font-size: .93rem;
    transition: background .15s ease;
}

.cx-lesson a:hover {
    background: #f4f7fb;
    color: var(--cx-primary);
    text-decoration: none;
}

.cx-lesson-icon {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .72rem;
    flex: none;
    background: #eef1f6;
    color: #5b6879;
}

.cx-lesson.is-quiz .cx-lesson-icon {
    background: #fff3e0;
    color: #b26a00;
}

.cx-lesson.is-done .cx-lesson-icon {
    background: #e6f7ef;
    color: #0ca678;
}

.cx-lesson-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cx-lesson-time {
    font-size: .8rem;
    color: var(--cx-muted);
    white-space: nowrap;
    flex: none;
}

.cx-chip {
    font-size: .7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: #e6f7ef;
    color: #0b7a55;
    white-space: nowrap;
    flex: none;
}

/* ---------- empty / gate ---------- */
.cx-gate {
    text-align: center;
    padding: 38px 22px;
    border: 1px dashed #cfd6e2;
    border-radius: 12px;
    background: #fbfcfe;
}

.cx-gate-icon {
    font-size: 30px;
    color: #9aa6b6;
    margin-bottom: 12px;
}

.cx-gate-title {
    font-weight: 700;
    margin-bottom: 6px;
}

.cx-gate-text {
    color: var(--cx-muted);
    font-size: .92rem;
    margin-bottom: 16px;
}

.cx-gate .cx-btn {
    display: inline-flex;
    width: auto;
}

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
    .cx-grid {
        grid-template-columns: 1fr;
        margin-top: -70px;
    }

    /* single column here — drop the pinned tracks, order alone decides */
    .cx-main {
        grid-column: auto;
        grid-row: auto;
        padding-top: 0;
        order: 2;
    }

    .cx-aside {
        grid-column: auto;
        grid-row: auto;
        position: static;
        order: 1;
    }

    .cx-hero {
        padding-bottom: 86px;
    }

    .cx-hero-inner {
        max-width: 100%;
    }
}

@media (max-width: 640px) {
    .cx-hero {
        padding: 22px 20px 78px;
        border-radius: 12px;
    }

    .cx-block {
        padding: 18px 16px;
    }

    .cx-tutor {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .cx-tutor-stats {
        justify-content: center;
    }

    .cx-section-head {
        padding: 12px 13px;
        font-size: .9rem;
    }

    .cx-lesson-time {
        display: none;
    }
}