/* ================================================================
   css3.css · CSS3 扩展专属样式
   ================================================================ */

.section-panel { display: none; animation: fadeIn 0.35s ease; }
.section-panel.active { display: block; }

.demo-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 24px;
    align-items: start;
}
@media (max-width: 1024px) {
    .demo-layout { grid-template-columns: 1fr; }
}

.css3-control-group { display: none; }
.css3-control-group.active { display: block; }

.css3-demo-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
}

/* 原始轮廓 */
.css3-original-outline {
    position: absolute;
    top: 50%; left: 50%;
    width: 220px; height: 220px;
    transform: translate(-50%, -50%);
    border: 2px dashed rgba(148, 163, 184, 0.5);
    border-radius: 0;
    pointer-events: none;
    z-index: 1;
}

/* 真正要设置 border-radius 的盒子 */
.css3-render-box {
    position: relative;
    width: 220px; height: 220px;
    background: #1e3a5f;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px; font-weight: 600;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0;
    border: 0 solid #ffffff;
    box-sizing: content-box;
    z-index: 2;
}

.css3-demo-text { position: relative; z-index: 3; pointer-events: none; }

/* 四个角圆 */
.radius-circle {
    position: absolute;
    border: 2px dashed rgba(6, 182, 212, 0.9);
    border-radius: 50%;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    z-index: 3;
    box-sizing: border-box;
    background: rgba(6, 182, 212, 0.05);
}

.radius-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--accent-cyan);
    font-size: 12px;
    font-weight: 800;
    font-family: var(--font-mono);
    background: rgba(15, 23, 42, 0.85);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--accent-cyan);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.radius-circle.active .radius-label { opacity: 1; }
.radius-circle.active { opacity: 1; }

.slice-area-title { font-size: 12px; font-weight: 600; color: var(--accent-cyan); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.slice-stage { display: flex; align-items: center; justify-content: center; padding: 20px 0; }
.slice-source-wrapper { position: relative; width: 200px; height: 200px; background: repeating-conic-gradient(rgba(100,116,139,.2) 0% 25%, transparent 0% 50%) 50% / 12px 12px; border: 1px solid var(--bg-tertiary); border-radius: 4px; overflow: visible; }
.slice-source-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; user-select: none; pointer-events: none; border-radius: 4px; }
.slice-line { position: absolute; background: rgba(236, 72, 153, 0.9); z-index: 3; transition: all 0.4s ease; pointer-events: none; box-shadow: 0 0 6px rgba(236, 72, 153, 0.6); }
.slice-line-top, .slice-line-bottom { left: 0; right: 0; height: 2px; }
.slice-line-left, .slice-line-right { top: 0; bottom: 0; width: 2px; }
.slice-line-top { top: 30px; }
.slice-line-bottom { bottom: 30px; }
.slice-line-left { left: 30px; }
.slice-line-right { right: 30px; }

.slice-cell { position: absolute; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; color: rgba(255,255,255,.95); border: 1px solid rgba(255,255,255,.4); border-radius: 3px; z-index: 4; transition: all 1.2s cubic-bezier(0.4,0,0.2,1); pointer-events: none; box-sizing: border-box; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
.slice-cell[data-cell="1"], .slice-cell[data-cell="3"], .slice-cell[data-cell="7"], .slice-cell[data-cell="9"] { background: rgba(236,72,153,.55); border-color: rgba(236,72,153,.9); }
.slice-cell[data-cell="2"], .slice-cell[data-cell="4"], .slice-cell[data-cell="6"], .slice-cell[data-cell="8"] { background: rgba(59,130,246,.55); border-color: rgba(59,130,246,.9); }
.slice-cell[data-cell="5"] { background: rgba(139,92,246,.55); border-color: rgba(139,92,246,.9); }

.slice-source-wrapper.animating .slice-cell { opacity: 0; transform: scale(0.7); }

.flying-piece { position: fixed; z-index: 9999; pointer-events: none; background: rgba(236,72,153,.75); border: 2px solid rgba(236,72,153,1); border-radius: 3px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; color: white; text-shadow: 0 1px 3px rgba(0,0,0,.8); box-sizing: border-box; transition: all 1s cubic-bezier(0.34,1.2,0.64,1); }

.shadow-controls { transition: opacity 0.3s ease; }
.shadow-controls.disabled { opacity: 0.35; pointer-events: none; }
.shadow-controls.disabled input, .shadow-controls.disabled button { cursor: not-allowed; }

.btn-sm { padding: 6px 14px; font-size: 12px; }

.gradient-panel { display: none; margin-top: 12px; padding: 14px; background: var(--bg-primary); border: 1px solid var(--bg-tertiary); border-radius: var(--radius-md); }
.gradient-panel.active { display: block; }
.gradient-param-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.gradient-param-row label { font-size: 12px; color: var(--text-secondary); min-width: 70px; }
.gradient-param-row select, .gradient-param-row input[type="range"] { flex: 1; background: var(--bg-secondary); color: var(--text-primary); border: 1px solid var(--bg-tertiary); border-radius: var(--radius-sm); padding: 5px 8px; font-size: 11px; font-family: inherit; }

/* 渐变区间数字输入框 */
.gradient-param-row input[type="number"] {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    outline: none;
}
.gradient-param-row input[type="number"]:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.15);
}

.live-code-wrapper { background: #0a0f1a; border-radius: var(--radius-md); border: 1px solid var(--bg-tertiary); overflow: hidden; }
.live-code-title { background: rgba(255,255,255,0.05); padding: 6px 12px; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; border-bottom: 1px solid var(--bg-tertiary); }
.live-code-wrapper .code-output { margin: 0; border: none; border-radius: 0; padding: 12px; font-size: 12px; max-height: 300px; overflow-y: auto; font-family: var(--font-mono); color: var(--text-primary); }
.live-code-wrapper .code-output pre { margin: 0; white-space: pre-wrap; }
.live-code-wrapper .sel { color: var(--accent-cyan); }
.live-code-wrapper .prop { color: var(--accent-pink); }
.live-code-wrapper .val { color: var(--accent-orange); }

/* 头部基础样式保持不变，仅追加缩放警告样式 */
#scaleWarning {
    animation: fadeIn 0.3s ease;
}

/* ================================================================
   四圆回归一圆 · 自动等比缩放动画
   ================================================================ */

/* 动画播放态：四个角圆进入汇聚模式 */
.css3-demo-box.scaling .radius-circle,
.css3-render-box.scaling .radius-circle {
    transition:
        width 0.9s cubic-bezier(0.34, 1.2, 0.64, 1),
        height 0.9s cubic-bezier(0.34, 1.2, 0.64, 1),
        left 0.9s cubic-bezier(0.34, 1.2, 0.64, 1),
        top 0.9s cubic-bezier(0.34, 1.2, 0.64, 1),
        right 0.9s cubic-bezier(0.34, 1.2, 0.64, 1),
        bottom 0.9s cubic-bezier(0.34, 1.2, 0.64, 1),
        opacity 0.5s ease,
        transform 0.9s cubic-bezier(0.34, 1.2, 0.64, 1);
    opacity: 0.78;
    border-color: rgba(245, 158, 11, 0.95);
    background: rgba(245, 158, 11, 0.08);
    left: 50% !important;
    top: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
}

/* 播放时隐藏圆上的半径文字 */
.css3-render-box.scaling .radius-label {
    opacity: 0 !important;
    transition: opacity 0.3s ease;
}

/* 中心汇聚闪光 */
.css3-scale-flash {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: radial-gradient(circle, #fff, var(--accent-orange));
    transform: translate(-50%, -50%) scale(0);
    pointer-events: none;
    z-index: 10;
    opacity: 0;
}
.css3-scale-flash.active {
    animation: scaleFlash 0.6s ease-out forwards;
}
@keyframes scaleFlash {
    0%   { transform: translate(-50%, -50%) scale(0);  opacity: 1; }
    60%  { transform: translate(-50%, -50%) scale(6);  opacity: 0.8; }
    100% { transform: translate(-50%, -50%) scale(10); opacity: 0; }
}

/* 缩放警告条 */
.scale-warning-bar {
    display: none;
    margin-top: 16px;
    padding: 10px 16px;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid var(--accent-orange);
    border-radius: var(--radius-md);
    color: var(--accent-orange);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}
.scale-warning-bar.show {
    display: flex;
}
.scale-warning-bar .btn-play-scale {
    padding: 4px 14px;
    font-size: 12px;
    background: var(--accent-orange);
    color: #0f172a;
    border: none;
    border-radius: 20px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease;
}
.scale-warning-bar .btn-play-scale:hover {
    transform: scale(1.05);
}
.scale-warning-bar .btn-play-scale:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* 渐变圆心位置关键词按钮 */
.gradient-param-row .preset-btn[data-grad-pos] {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
}
.gradient-param-row .preset-btn[data-grad-pos].active {
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
    color: #0a0f1a;
}

/* ================================================================
   多背景图像 · 左侧大屏内嵌区
   ================================================================ */
.multi-bg-left-section {
    width: 100%;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px dashed var(--bg-tertiary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* 3D 分层舞台 */
.multi-bg-stage-wrapper {
    width: 100%;
    max-width: 520px;
    background: #0a0f1a;
    border: 1px solid var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 16px;
    position: relative;
}
.multi-bg-stage {
    height: 280px;
    position: relative;
    perspective: 1200px;
    perspective-origin: 50% 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image:
        radial-gradient(circle at 50% 40%, rgba(59, 130, 246, 0.06) 0%, transparent 60%),
        radial-gradient(circle at 80% 70%, rgba(139, 92, 246, 0.04) 0%, transparent 50%);
    border-radius: var(--radius-sm);
}
.multi-bg-stage::before {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 50%;
    background-image:
        linear-gradient(rgba(59, 130, 246, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59, 130, 246, 0.05) 1px, transparent 1px);
    background-size: 30px 30px;
    transform: rotateX(65deg);
    transform-origin: bottom;
    pointer-events: none;
    mask-image: linear-gradient(to top, black, transparent);
    -webkit-mask-image: linear-gradient(to top, black, transparent);
}
.multi-bg-scene {
    position: relative;
    width: 200px;
    height: 200px;
    transform-style: preserve-3d;
    transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1);
}
.multi-bg-scene.isometric {
    transform: rotateX(18deg) rotateY(-14deg);
}
.multi-bg-scene.flat {
    transform: rotateX(0deg) rotateY(0deg);
}
.multi-bg-plane {
    position: absolute;
    inset: 0;
    border-radius: 6px;
    overflow: hidden;
    transform-style: preserve-3d;
    transition: all 1.1s cubic-bezier(0.34, 1.2, 0.64, 1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
}
.multi-bg-plane::after {
    content: attr(data-label);
    position: absolute;
    left: 6px;
    bottom: 6px;
    background: rgba(15, 23, 42, 0.85);
    color: var(--accent-cyan);
    font-size: 10px;
    font-weight: 700;
    font-family: var(--font-mono);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(6, 182, 212, 0.4);
    white-space: nowrap;
}
.multi-bg-plane.hidden-before-insert {
    opacity: 0;
    transform: translateZ(0) scale(0.9);
}
.multi-bg-plane.inserting {
    opacity: 1;
    transform: translateZ(var(--z-offset)) scale(1);
}
.multi-bg-stage-controls {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    justify-content: center;
}

/* ================================================================
   多背景图层控制卡片（右侧控制面板）
   ================================================================ */
.multi-bg-layer {
    background: var(--bg-primary);
    border: 1px solid var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 12px;
    transition: border-color 0.25s ease;
}
.multi-bg-layer.is-top {
    border-color: rgba(6, 182, 212, 0.55);
    box-shadow: 0 0 0 1px rgba(6, 182, 212, 0.25);
}
.multi-bg-layer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-cyan);
    margin-bottom: 10px;
}
.multi-bg-layer-header .layer-order {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(6, 182, 212, 0.15);
    color: var(--accent-cyan);
    font-weight: 700;
}
.multi-bg-layer-header .layer-order.top-layer {
    background: var(--accent-cyan);
    color: #0a0f1a;
}
.multi-bg-layer-row {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.multi-bg-layer-row label {
    font-size: 11px;
    color: var(--text-secondary);
    min-width: 54px;
    margin: 0;
}
.multi-bg-layer-row select,
.multi-bg-layer-row input[type="range"] {
    flex: 1;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-size: 11px;
    font-family: inherit;
    min-width: 0;
}
.multi-bg-layer-row .mini-value {
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--accent-cyan);
    min-width: 40px;
    text-align: right;
}
.multi-bg-layer-thumb {
    width: 100%;
    height: 40px;
    border-radius: var(--radius-sm);
    margin-top: 6px;
    border: 1px solid var(--bg-tertiary);
    background-color: var(--bg-secondary);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* ================================================================
   拼图动态案例（左侧大屏下方）
   ================================================================ */
.multi-bg-puzzle-section {
    width: 100%;
    max-width: 520px;
    padding-top: 16px;
    border-top: 1px dashed var(--bg-tertiary);
}
.multi-bg-puzzle-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #0a0f1a;
    border-radius: var(--radius-md);
    border: 1px solid var(--bg-tertiary);
    min-height: 260px;
}
.multi-bg-puzzle-box {
    width: 200px;
    height: 200px;
    border-radius: 8px;
    background-color: #1e293b;
    border: 1px solid var(--bg-tertiary);
    position: relative;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    /* 十字分割线 */
    background-image:
        linear-gradient(to right, transparent calc(50% - 1px), rgba(6, 182, 212, 0.6) calc(50% - 1px), rgba(6, 182, 212, 0.6) calc(50% + 1px), transparent calc(50% + 1px)),
        linear-gradient(to bottom, transparent calc(50% - 1px), rgba(6, 182, 212, 0.6) calc(50% - 1px), rgba(6, 182, 212, 0.6) calc(50% + 1px), transparent calc(50% + 1px));
    background-repeat: no-repeat;
    background-size: 100% 100%, 100% 100%;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.multi-bg-puzzle-box .puzzle-piece {
    position: absolute;
    width: 50%;
    height: 50%;
    background-size: 200px 200px;
    background-repeat: no-repeat;
    background-color: #0f172a;
    opacity: 0;
    transform: scale(0.6) translateZ(0);
    transition: all 0.5s ease;
    border: 1px solid rgba(6, 182, 212, 0.25);
}
.multi-bg-puzzle-box .puzzle-piece.tl {
    top: 0; left: 0;
    background-position: 0 0;
}
.multi-bg-puzzle-box .puzzle-piece.tr {
    top: 0; right: 0;
    background-position: -100px 0;
}
.multi-bg-puzzle-box .puzzle-piece.bl {
    bottom: 0; left: 0;
    background-position: 0 -100px;
}
.multi-bg-puzzle-box .puzzle-piece.br {
    bottom: 0; right: 0;
    background-position: -100px -100px;
}

.multi-bg-puzzle-box.puzzle-play .puzzle-piece {
    animation: puzzlePieceIn 0.6s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
}
.multi-bg-puzzle-box.puzzle-play .puzzle-piece.tl { animation-delay: 0s; }
.multi-bg-puzzle-box.puzzle-play .puzzle-piece.tr { animation-delay: 0.25s; }
.multi-bg-puzzle-box.puzzle-play .puzzle-piece.bl { animation-delay: 0.5s; }
.multi-bg-puzzle-box.puzzle-play .puzzle-piece.br { animation-delay: 0.75s; }

@keyframes puzzlePieceIn {
    0%   { opacity: 0; transform: scale(0.6) translateZ(0) rotate(-8deg); }
    60%  { opacity: 1; transform: scale(1.08) translateZ(20px) rotate(2deg); }
    100% { opacity: 1; transform: scale(1) translateZ(0) rotate(0); }
}