/* ============================================
   css-lab.css —— CSS 动画实验室
   ============================================ */

.app-main {
    padding: calc(var(--topbar-h) + 1.25rem) 1.25rem 2rem;
}

.lab-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 1.25rem;
    max-width: 1320px;
    margin: 0 auto;
    align-items: start;
}

.control-panel {
    position: sticky;
    top: calc(var(--topbar-h) + 1.25rem);
}

.main-col {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-width: 0;
}

.form-row-inline {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 58%;
}

.form-row-inline input[type="range"] {
    flex: 1;
}

.w-58 {
    width: 58%;
}

.divider {
    height: 1px;
    background: var(--border-color);
    margin: 1rem 0;
}

.param-tip {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
}

.count {
    font-weight: 400;
    opacity: 0.7;
}

/* ===== 自定义贝塞尔 ===== */
.bezier-box {
    margin-top: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-secondary);
}

.bezier-inputs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
    margin-bottom: 0.6rem;
}

.bezier-inputs label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.68rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.bezier-inputs input {
    padding: 0.3rem 0.35rem;
    font-size: 0.75rem;
    text-align: center;
}

.bezier-preview {
    height: 90px;
    border-radius: 8px;
    background: var(--bg-secondary);
    overflow: hidden;
}

.bezier-preview svg {
    width: 100%;
    height: 100%;
}

.bz-grid {
    fill: none;
    stroke: rgba(15, 23, 42, 0.12);
    stroke-width: 0.6;
}

.bz-curve {
    fill: none;
    stroke: var(--accent-cyan);
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
}

/* ===== 舞台 ===== */
.stage-controls {
    display: flex;
    gap: 0.5rem;
}

.stage {
    position: relative;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-secondary);
}

.checker {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(45deg, rgba(15, 23, 42, 0.035) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(15, 23, 42, 0.035) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(15, 23, 42, 0.035) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(15, 23, 42, 0.035) 75%);
    background-size: 24px 24px;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

.demo-box {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary);
    box-shadow: var(--shadow-glow);
    will-change: transform, opacity;
}

.demo-box.shape-square {
    border-radius: 16px;
}

.demo-box.shape-circle {
    border-radius: 50%;
}

.demo-box.shape-rounded {
    border-radius: 40% 60% 55% 45% / 50% 45% 55% 50%;
}

.demo-box.shape-card {
    width: 200px;
    height: 120px;
    border-radius: 12px;
}

.demo-text {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 2px;
    color: #fff;
    text-shadow: 0 2px 8px rgba(15, 23, 42, 0.15);
}

.stage.paused .demo-box {
    animation-play-state: paused !important;
}

/* ===== 动画库网格 ===== */
.anim-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
    gap: 0.6rem;
}

.anim-cell {
    padding: 0.6rem 0.4rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
    overflow: hidden;
}

.anim-cell:hover {
    border-color: var(--border-hover);
    background: rgba(37, 99, 235, 0.07);
    transform: translateY(-2px);
}

.anim-cell.active {
    border-color: var(--accent-purple);
    background: rgba(37, 99, 235, 0.1);
    box-shadow: 0 0 0 1px var(--accent-primary);
}

.anim-demo {
    width: 34px;
    height: 34px;
    margin: 0 auto 0.45rem;
    border-radius: 7px;
    background: var(--gradient-secondary);
}

.anim-name {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.anim-cell.active .anim-name {
    color: var(--text-primary);
    font-weight: 600;
}

/* ===== 代码块 ===== */
.code-block {
    max-height: 320px;
    overflow: auto;
    padding: 0.9rem 1rem;
    background: var(--bg-secondary);
    border-radius: 10px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.75;
    color: var(--text-primary);
    white-space: pre;
    tab-size: 2;
}

.code-block::-webkit-scrollbar {
    height: 8px;
}

/* ===== 响应式 ===== */
@media (max-width: 968px) {
    .lab-layout {
        grid-template-columns: 1fr;
    }

    .control-panel {
        position: static;
        order: 2;
    }

    .main-col {
        order: 1;
    }

    .stage {
        min-height: 240px;
    }
}

@media (max-width: 480px) {
    .app-main {
        padding: calc(var(--topbar-h) + 0.75rem) 0.75rem 1.5rem;
    }

    .form-row-inline,
    .w-58 {
        width: 50%;
    }

    .anim-grid {
        grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    }

    .demo-box {
        width: 90px;
        height: 90px;
    }

    .demo-box.shape-card {
        width: 150px;
        height: 90px;
    }
}
