/*
 * Course page v2 · fold 2 "What you learn" (#what-you-learn). Prefix .cl-. Tokens only (base.css / skin.css), no hex.
 * Spec: docs/ux-discovery/course-page/direction.md section 4 (fold 2), fold-learn.json.
 * Desktop grid: "head head cta" / "who syl syl" (115fr 56fr 85fr: who ~460px, syllabus ~620px, head ~740px, CTA ~340px). DOM order head, who, syllabus, CTA; the CTA is placed by grid-area.
 * Hidden start states only under html.hv-motion .cv2-armed:not(.cv2-in) (page.js), so no-JS and crawlers never see blank content.
 */

.course-v2 .cl-section { position: relative; overflow: clip; }
.course-v2 .cl-section > .v3-wrap { position: relative; z-index: 1; }

/* Decorative dotted field, top left behind the heading (the .an-section recipe, mirrored) */
.course-v2 .cl-dots {
    position: absolute; top: 0; left: 0; width: min(420px, 60%); height: 360px; pointer-events: none; z-index: 0;
    background-image: radial-gradient(var(--l200) 1.3px, transparent 1.7px);
    background-size: 22px 22px;
    -webkit-mask-image: radial-gradient(ellipse at top left, rgba(31, 3, 45, 1), transparent 68%);
            mask-image: radial-gradient(ellipse at top left, rgba(31, 3, 45, 1), transparent 68%);
}

/* ---------- Grid (mobile first: one column in DOM order) ---------- */
.course-v2 .cl-grid { display: grid; grid-template-columns: minmax(0, 1fr); row-gap: 28px; }
.course-v2 .cl-grid > * { min-width: 0; }
.course-v2 .cl-syl { margin-top: 4px; }

/* ---------- Heading row ---------- */
.course-v2 .cl-head { max-width: 760px; }
.course-v2 .cl-head .v3-h2 { margin-top: 8px; font-size: 26px; line-height: 1.15; }
.course-v2 .cl-head .cl-lead { margin-top: 10px; font-size: 17px; line-height: 1.5; color: var(--mute); max-width: none; }

/* ---------- Who it is for (3px brand rule, no card) ---------- */
.course-v2 .cl-who { padding-left: 20px; border-left: 3px solid var(--brand); }
.course-v2 .cl-h3 { margin: 0; font-family: 'Outfit', sans-serif; font-weight: 600; font-size: 19px; line-height: 1.3; color: var(--ink); }
.course-v2 .cl-pre { margin-top: 12px; font-size: 16px; line-height: 1.5; color: var(--ink-2); }
.course-v2 .cl-pre p { margin: 0; }
.course-v2 .cl-pre-label { font-weight: 600; color: var(--ink); }
.course-v2 .cl-pre-list { display: grid; gap: 4px; margin: 8px 0 0; padding: 0; list-style: none; }
.course-v2 .cl-pre-list li { position: relative; padding-left: 16px; font-size: 16px; line-height: 1.5; }
.course-v2 .cl-pre-list li::before { content: ''; position: absolute; left: 0; top: .62em; width: 6px; height: 6px; border-radius: 999px; background: var(--brand); }
.course-v2 .cl-roles { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.course-v2 .cl-role { display: inline-flex; align-items: center; min-height: 36px; padding: 6px 12px; border-radius: 999px; background: var(--l100); color: var(--ink-2); font-size: 16px; font-weight: 500; line-height: 1.5; }
.course-v2 .cl-role:focus { outline: var(--focus-light); outline-offset: 2px; }
.course-v2 .cl-role-more-li { display: none; }
.course-v2 .cl-role-more { display: inline-flex; align-items: center; min-height: 44px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--l300); background: var(--white); color: var(--brand-deep); font: 600 16px/1.4 'Work Sans', sans-serif; cursor: pointer; transition: background-color 150ms ease, border-color 150ms ease; }
.course-v2 .cl-role-more:hover { background: var(--l50); border-color: var(--brand); }

/* ---------- Syllabus ---------- */
.course-v2 .cl-syl-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 16px; }
.course-v2 .cl-modules { margin: 0; padding: 0; list-style: none; background: var(--white); border: 1px solid var(--l200); border-radius: 16px; box-shadow: var(--shadow-card); overflow: hidden; }
.course-v2 .cl-mod-li + .cl-mod-li { border-top: 1px solid var(--l200); }
.course-v2 .cl-mod-li[hidden] { display: none; }
.course-v2 .cl-mod { position: relative; }
.course-v2 .cl-mod::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand); transform: scaleY(0); transform-origin: top; transition: transform 280ms var(--ease); z-index: 1; }
.course-v2 .cl-mod[open]::before { transform: scaleY(1); }
.course-v2 .cl-sum, .course-v2 .cl-mod--plain {
    display: grid; grid-template-columns: 32px minmax(0, 1fr) 20px; align-items: center; gap: 14px;
    min-height: 64px; padding: 16px; list-style: none; cursor: pointer; transition: background-color 150ms ease;
}
.course-v2 .cl-mod--plain { grid-template-columns: 32px minmax(0, 1fr); cursor: default; }
.course-v2 .cl-sum::-webkit-details-marker { display: none; }
.course-v2 .cl-sum::marker { content: ''; }
.course-v2 .cl-sum:focus-visible { outline: var(--focus-light); outline-offset: -3px; border-radius: 12px; }
.course-v2 .cl-badge {
    display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 999px;
    background: var(--l100); color: var(--brand-deep); font-family: 'Outfit', sans-serif; font-weight: 600; font-size: 16px; line-height: 1;
    font-variant-numeric: tabular-nums; transition: background-color 240ms ease, color 240ms ease;
}
.course-v2 .cl-badge .v3-i { width: 18px; height: 18px; }
.course-v2 .cl-mtext { font-family: 'Work Sans', sans-serif; font-weight: 600; font-size: 16px; line-height: 1.35; color: var(--ink); overflow-wrap: anywhere; transition: color 200ms ease; }
.course-v2 .cl-plus { width: 20px; height: 20px; color: var(--brand-deep); transition: transform 320ms var(--ease); }
.course-v2 .cl-mod[open] .cl-badge { background: var(--brand); color: var(--white); }
.course-v2 .cl-mod[open] .cl-mtext { color: var(--brand-deep); }
.course-v2 .cl-mod[open] .cl-plus { transform: rotate(45deg); }
@media (hover: hover) and (pointer: fine) {
    .course-v2 .cl-sum:hover { background: var(--l50); }
}

/* Open panel */
.course-v2 .cl-mod-body { padding: 0 16px 16px 62px; }
.course-v2 .cl-mod-meta { margin: 0 0 6px; font-size: 16px; line-height: 1.5; color: var(--mute); }
.course-v2 .cl-topics-wrap { position: relative; }
.course-v2 .cl-topics { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 16px; line-height: 1.5; color: var(--ink-2); }
.course-v2 .cl-topics li { position: relative; padding-left: 16px; }
.course-v2 .cl-topics li::before { content: ''; position: absolute; left: 0; top: .62em; width: 6px; height: 6px; border-radius: 999px; background: var(--l300); }
.course-v2 .cl-topics .cl-group { padding-left: 0; }
.course-v2 .cl-topics .cl-group::before { display: none; }
.course-v2 .cl-group-label { display: block; font-weight: 600; color: var(--ink); }
.course-v2 .cl-group ul { display: grid; gap: 6px; margin: 6px 0 0; padding: 0; list-style: none; }
.course-v2 .cl-fade { display: none; }
.course-v2 .cl-topics-wrap.is-capped { max-height: 176px; overflow: hidden; }
.course-v2 .cl-topics-wrap.is-capped .cl-fade { display: block; position: absolute; left: 0; right: 0; bottom: 0; height: 56px; pointer-events: none; background: linear-gradient(to bottom, transparent, var(--white)); transition: opacity 200ms ease; }

.course-v2 .cl-more, .course-v2 .cl-all { min-height: 44px; margin-top: 4px; font-size: 16px; }
.course-v2 .cl-more[hidden], .course-v2 .cl-all[hidden] { display: none; }
.course-v2 .cl-all { margin-top: 8px; }

/* Height animation, CSS first (Chrome 131+): ::details-content. learn.js animates with WAAPI where unsupported. */
.course-v2 { interpolate-size: allow-keywords; }
@supports selector(::details-content) {
    html.hv-motion .course-v2 .cl-mod::details-content {
        block-size: 0; overflow: clip;
        transition: block-size 360ms var(--ease), content-visibility 360ms allow-discrete;
    }
    html.hv-motion .course-v2 .cl-mod[open]::details-content { block-size: auto; }
}

/* ---------- CTA ---------- */
.course-v2 .cl-cta { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.course-v2 .cl-cta .v3-btn { width: 100%; min-height: 52px; justify-content: center; }
.course-v2 .cl-note { margin: 0; font-size: 16px; line-height: 1.5; color: var(--mute); text-align: center; }

/* ---------- Reveal stagger inside the fold (modules 70ms, roles 40ms), page.js arms folds below the viewport ---------- */
html.hv-motion .course-v2 .cl-section .cl-mod-li,
html.hv-motion .course-v2 .cl-section .cl-role { transition: opacity 520ms var(--ease), transform 600ms var(--ease); }
html.hv-motion .course-v2 .cl-section .cl-mod-li { transition-delay: calc(220ms + var(--cl-i, 0) * 70ms); }
html.hv-motion .course-v2 .cl-section .cl-role { transition-delay: calc(160ms + var(--cl-i, 0) * 40ms); }
html.hv-motion .course-v2 .cv2-armed:not(.cv2-in) .cl-mod-li { opacity: 0; transform: translate3d(0, 14px, 0); }
html.hv-motion .course-v2 .cv2-armed:not(.cv2-in) .cl-role { opacity: 0; transform: translate3d(0, 8px, 0) scale(.96); }
html.hv-motion .course-v2 .cl-section.cv2-done .cl-mod-li,
html.hv-motion .course-v2 .cl-section.cv2-done .cl-role { transition-delay: 0ms; }

/* ---------- Phones ---------- */
@media (max-width: 1023px) {
    .course-v2 .cl-section { padding: 56px 0; }
    .course-v2 .cl-grid { row-gap: 28px; }
    .course-v2 .cl-syl { margin-top: 4px; }
}
@media (max-width: 767px) {
    .course-v2 .cl-dots { width: 70%; height: 260px; }
}

/* ---------- Desktop: two columns, CTA in the heading row ---------- */
@media (min-width: 1024px) {
    .course-v2 .cl-grid {
        grid-template-columns: minmax(0, 115fr) minmax(0, 56fr) minmax(0, 85fr);
        grid-template-areas: "head head cta" "who syl syl";
        column-gap: 56px; row-gap: 28px; align-items: start;
    }
    .course-v2 .cl-head { grid-area: head; align-self: end; }
    .course-v2 .cl-who { grid-area: who; }
    .course-v2 .cl-syl { grid-area: syl; margin-top: 0; }
    .course-v2 .cl-cta { grid-area: cta; align-self: end; align-items: flex-end; gap: 6px; }
    .course-v2 .cl-cta .v3-btn { width: auto; min-width: 220px; }
    .course-v2 .cl-note { text-align: right; white-space: nowrap; }
    .course-v2 .cl-head .v3-h2 { font-size: clamp(1.75rem, .5rem + 3.3vh, 2.375rem); }
    .course-v2 .cl-h3 { font-size: 20px; }
    .course-v2 .cl-mtext { font-size: 16px; }   /* 16px (not 17) keeps 57-character DB titles on one line in the ~620px syllabus column */
    /* Rows are 60px at 768px tall and tighten on shorter laptop screens (real 1366x768 Chrome is about 657px inner height) */
    .course-v2 .cl-sum, .course-v2 .cl-mod--plain { grid-template-columns: 36px minmax(0, 1fr) 20px; gap: 12px; min-height: clamp(48px, 7.8vh, 60px); padding: clamp(8px, 1.8vh, 14px) 16px; }
    .course-v2 .cl-mod--plain { grid-template-columns: 36px minmax(0, 1fr); }
    .course-v2 .cl-badge { width: 36px; height: 36px; }
    .course-v2 .cl-mod-body { padding: 0 16px 16px 64px; }
    .course-v2 .cl-section[data-cl-count="6"] .cl-sum, .course-v2 .cl-section[data-cl-count="7"] .cl-sum,
    .course-v2 .cl-section[data-cl-count="8"] .cl-sum, .course-v2 .cl-section[data-cl-count="9"] .cl-sum,
    .course-v2 .cl-section[data-cl-count="10"] .cl-sum { padding-block: clamp(6px, 1.3vh, 10px); min-height: clamp(46px, 6.8vh, 52px); }
    .course-v2 .cl-grid { row-gap: clamp(16px, 3.6vh, 28px); }
    .course-v2 .cl-syl-head { margin-bottom: clamp(10px, 2vh, 16px); }
    .course-v2 .cl-all { min-height: 44px; margin-top: clamp(2px, .8vh, 8px); }
    /* Long prerequisite list: who and syllabus share the width equally (who ~540px, CTA ~396px) */
    .course-v2 .cl-grid--wide-who { grid-template-columns: minmax(0, 540fr) minmax(0, 144fr) minmax(0, 396fr); }
    /* Fallbacks: one column spans the width */
    .course-v2 .cl-grid--who { grid-template-areas: "head head cta" "who who who"; }
    .course-v2 .cl-grid--who .cl-who { max-width: 720px; }
    .course-v2 .cl-grid--syl { grid-template-areas: "head head cta" "syl syl syl"; }
    .course-v2 .cl-grid--syl .cl-syl { max-width: 760px; }
}
/* One-screen fold mode: the eyebrow drops when the H2 takes 2 lines (direction: imposed to meet the 540px cap) */
@media (min-width: 1024px) and (min-height: 620px) {
    .course-v2 .cl-head--long .cl-eyebrow { display: none; }
    .course-v2 .cl-head--long .v3-h2 { margin-top: 0; }
}
@media (min-width: 1024px) and (max-width: 1279px) {
    .course-v2 .cl-grid { column-gap: 40px; }
    /* Long H2 (3 lines): roles cap at 5 plus "+n more" */
    .course-v2 .cl-roles-cappable:not(.is-all) .cl-role-extra { display: none; }
    .course-v2 .cl-roles-cappable:not(.is-all) .cl-role-more-li { display: inline-flex; }
}

/* ---------- Reduced motion, forced colours, print ---------- */
@media (prefers-reduced-motion: reduce) {
    .course-v2 .cl-mod::before, .course-v2 .cl-plus, .course-v2 .cl-badge, .course-v2 .cl-mtext, .course-v2 .cl-sum,
    .course-v2 .cl-mod-li, .course-v2 .cl-role, .course-v2 .cl-fade { transition: none !important; }
    .course-v2 .cl-mod-li, .course-v2 .cl-role { opacity: 1 !important; transform: none !important; }
    .course-v2 .cl-mod::details-content { transition: none !important; }
}
@media (forced-colors: active) {
    .course-v2 .cl-who { border-left-color: CanvasText; }
    .course-v2 .cl-modules, .course-v2 .cl-role, .course-v2 .cl-badge { border: 1px solid CanvasText; }
    .course-v2 .cl-mod[open]::before { background: Highlight; }
}
@media print {
    .course-v2 .cl-dots, .course-v2 .cl-more, .course-v2 .cl-all, .course-v2 .cl-role-more-li { display: none !important; }
    .course-v2 .cl-mod-li[hidden] { display: block !important; }
    .course-v2 .cl-topics-wrap.is-capped { max-height: none; }
}

/* "At a glance" (no audience list in the CMS): three facts and one plain line under "Before you start" */
.course-v2 .cl-glance { margin-top: 20px; padding-top: 18px; border-top: var(--cv2-border); grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.course-v2 .cl-glance-note { margin-top: 14px; font-size: 16px; line-height: 1.5; color: var(--ink-2); }
.course-v2 .cl-glance-note::first-letter { text-transform: uppercase; }
