/* ==========================================================================
   微积分模块共享样式（fn/c1 ~ fn/c6）
   - .cl-* 课程页骨架：只被新页 c4 / c5 / c6 使用
   - .cq-* 必考题组件：c1 ~ c6 共用
   约束：全部类名带前缀，避免与 sim.css / stage-canvas.css 的通用类
   （.panel / .controls / .panel-header / .left / .g 等）相撞。
   ========================================================================== */

.cl-page {
    background: #f8fafc;
    border-top: 1px solid #e8edf3;
}

.cl-wrap {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 26px 20px 56px;
    box-sizing: border-box;
}

/* ---------- 1. 页头 ---------- */
.cl-hero {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    align-items: flex-start;
    justify-content: space-between;
}

.cl-hero-main {
    flex: 1 1 460px;
    min-width: 0;
}

.cl-level {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #4338ca;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 999px;
}

.cl-h1 {
    margin: 10px 0 8px;
    font-size: 26px;
    line-height: 1.35;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.01em;
}

.cl-lead {
    margin: 0;
    max-width: 760px;
    font-size: 14px;
    line-height: 1.85;
    color: #475569;
}

.cl-chain {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.cl-chain a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    font-size: 12.5px;
    color: #334155;
    text-decoration: none;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    transition: border-color .18s ease, color .18s ease;
}

.cl-chain a:hover {
    color: #4338ca;
    border-color: #c7d2fe;
}

/* ---------- 2. 交互舞台 ---------- */
.cl-stage {
    display: grid;
    grid-template-columns: 330px minmax(0, 1fr);
    gap: 18px;
    margin-top: 22px;
    align-items: start;
}

.cl-rail {
    padding: 18px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.cl-field {
    margin-bottom: 16px;
}

.cl-field:last-child {
    margin-bottom: 0;
}

.cl-field-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 7px;
}

.cl-label {
    font-size: 12.5px;
    font-weight: 600;
    color: #334155;
    letter-spacing: .01em;
}

.cl-val {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 13px;
    font-weight: 600;
    color: #4338ca;
    background: #eef2ff;
    border-radius: 6px;
    padding: 1px 8px;
    font-variant-numeric: tabular-nums;
}

.cl-range {
    width: 100%;
    height: 4px;
    margin: 8px 0 2px;
    border-radius: 999px;
    background: #e2e8f0;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.cl-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #4f46e5;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(79, 70, 229, .45);
}

.cl-range::-moz-range-thumb {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #4f46e5;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(79, 70, 229, .45);
}

.cl-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.cl-tab {
    padding: 5px 10px;
    font-size: 12px;
    color: #475569;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    cursor: pointer;
    user-select: none;
    transition: all .16s ease;
}

.cl-tab:hover {
    border-color: #c7d2fe;
    color: #4338ca;
}

.cl-tab.is-on {
    color: #fff;
    background: #4f46e5;
    border-color: #4f46e5;
    font-weight: 600;
}

.cl-tab:focus-visible,
.cq-q:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

.cl-hint {
    margin: 12px 0 0;
    padding: 9px 11px;
    font-size: 12px;
    line-height: 1.7;
    color: #64748b;
    background: #f8fafc;
    border: 1px dashed #e2e8f0;
    border-radius: 8px;
}

.cl-hint b {
    color: #334155;
}

/* ---------- 3. 画布卡片 ---------- */
.cl-stage-card {
    position: relative;
    padding: 10px 10px 6px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.cl-canvas {
    display: block;
    width: 100%;
    height: 520px;
}

.cl-canvas-tall {
    height: 600px;
}

.cl-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    padding: 2px 6px 8px;
    font-size: 12px;
    color: #64748b;
}

.cl-legend {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.cl-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
}

.cl-readout {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 10px 4px 4px;
}

.cl-stat {
    padding: 9px 11px;
    background: #f8fafc;
    border: 1px solid #eef2f7;
    border-radius: 10px;
}

.cl-stat b {
    display: block;
    font-size: 17px;
    font-weight: 600;
    color: #0f172a;
    font-variant-numeric: tabular-nums;
    line-height: 1.5;
}

.cl-stat span {
    display: block;
    font-size: 11.5px;
    color: #64748b;
    line-height: 1.6;
}

.cl-verdict {
    display: inline-block;
    margin-top: 2px;
    padding: 1px 8px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
}

.cl-ok {
    color: #166534;
    background: #dcfce7;
}

.cl-bad {
    color: #9a3412;
    background: #ffedd5;
}

.cl-info {
    color: #1e40af;
    background: #dbeafe;
}

/* ---------- 4. 正文区块 ---------- */
.cl-sec {
    margin-top: 30px;
}

.cl-h2 {
    margin: 0 0 10px;
    font-size: 17px;
    font-weight: 600;
    color: #0f172a;
}

.cl-prose {
    margin: 0;
    font-size: 14px;
    line-height: 1.9;
    color: #334155;
}

.cl-prose + .cl-prose {
    margin-top: 10px;
}

.cl-prose code {
    padding: 1px 5px;
    font-size: 13px;
    background: #f1f5f9;
    border-radius: 4px;
}

.cl-callout {
    margin-top: 16px;
    padding: 14px 18px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #4f46e5;
    border-radius: 0 10px 10px 0;
}

.cl-callout p {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.85;
    color: #334155;
}

.cl-callout b {
    color: #312e81;
}

.cl-grid3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.cl-card {
    padding: 14px 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
}

.cl-card h3 {
    margin: 0 0 6px;
    font-size: 13.5px;
    font-weight: 600;
    color: #0f172a;
}

.cl-card p {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.8;
    color: #64748b;
}

/* ---------- 5. 上一页 / 下一页 ---------- */
.cl-pager {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 10px;
    margin-top: 30px;
}

.cl-pager a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    font-size: 13px;
    color: #334155;
    text-decoration: none;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    transition: border-color .18s ease, color .18s ease;
}

.cl-pager a:hover {
    color: #4338ca;
    border-color: #c7d2fe;
}

.cl-pager .cl-next {
    margin-left: auto;
}

/* ---------- 6. 必考题组件 ---------- */
.cq-section {
    max-width: 920px;
    margin: 36px auto 0;
    padding-top: 22px;
    border-top: 1px solid #e2e8f0;
}

.cq-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px 14px;
}

.cq-kicker {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #b91c1c;
}

.cq-kicker::before {
    content: "";
    width: 14px;
    height: 2px;
    background: #ef4444;
    border-radius: 2px;
}

.cq-title {
    margin: 6px 0 0;
    font-size: 18px;
    font-weight: 600;
    color: #0f172a;
}

.cq-sub {
    margin: 4px 0 0;
    font-size: 12.5px;
    color: #64748b;
}

.cq-all {
    display: inline-block;
    padding: 5px 11px;
    font-size: 12px;
    color: #4338ca;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 999px;
    cursor: pointer;
    user-select: none;
}

.cq-all:hover {
    background: #e0e7ff;
}

.cq-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.cq-item {
    overflow: hidden;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    transition: border-color .18s ease, box-shadow .18s ease;
}

.cq-item.is-open {
    border-color: #c7d2fe;
    box-shadow: 0 8px 22px -18px rgba(79, 70, 229, .8);
}

.cq-q {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    user-select: none;
}

.cq-q:hover {
    background: #f8fafc;
}

.cq-idx {
    flex: 0 0 auto;
    padding: 0 7px;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.9;
    color: #4f46e5;
    background: #eef2ff;
    border-radius: 6px;
}

.cq-qtext {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 14.5px;
    line-height: 1.8;
    color: #0f172a;
}

.cq-qtext .katex {
    font-size: 1.02em;
}

.cq-toggle {
    flex: 0 0 auto;
    padding-top: 3px;
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
}

.cq-item.is-open .cq-toggle {
    color: #4338ca;
}

.cq-a {
    padding: 14px 18px 16px 62px;
    background: #fbfcfe;
    border-top: 1px dashed #e2e8f0;
}

.cq-a[hidden] {
    display: none;
}

.cq-a-label {
    margin: 0 0 4px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #94a3b8;
}

.cq-steps {
    margin: 6px 0 0;
    padding-left: 20px;
    font-size: 14px;
    line-height: 1.95;
    color: #334155;
}

.cq-steps > li {
    margin-bottom: 7px;
}

.cq-steps > li::marker {
    color: #6366f1;
    font-weight: 600;
}

.cq-ans {
    margin-top: 12px;
    padding: 10px 14px;
    font-size: 13.5px;
    line-height: 1.85;
    color: #14532d;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 9px;
}

.cq-ans b {
    color: #166534;
}

/* ---------- 7. 响应式 ---------- */
@media (max-width: 1080px) {
    .cl-stage {
        grid-template-columns: 290px minmax(0, 1fr);
    }

    .cl-canvas {
        height: 460px;
    }

    .cl-canvas-tall {
        height: 520px;
    }
}

@media (max-width: 980px) {
    /* 站点侧栏固定 250px，窄屏会把正文压到几十像素；改为上下布局，菜单交由站点抽屉 */
    main.container {
        flex-direction: column;
        min-width: 0;
    }

    main.container > .menuwrap {
        display: none;
    }

    main.container > .contontwrap {
        flex: 1 1 auto;
        width: 100%;
    }

    .cl-stage {
        grid-template-columns: 1fr;
    }

    .cl-canvas {
        height: 400px;
    }

    .cl-canvas-tall {
        height: 460px;
    }

    .cl-grid3 {
        grid-template-columns: 1fr;
    }

    .cl-h1 {
        font-size: 22px;
    }
}

@media (max-width: 640px) {
    .cl-wrap {
        padding: 18px 14px 40px;
    }

    .cl-canvas {
        height: 330px;
    }

    .cl-canvas-tall {
        height: 380px;
    }

    .cl-readout {
        grid-template-columns: 1fr 1fr;
    }

    .cq-a {
        padding: 12px 14px 14px;
    }

    .cq-qtext {
        font-size: 13.5px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cl-tab,
    .cq-item,
    .cl-chain a,
    .cl-pager a {
        transition: none;
    }
}
