/* ==========================================================
 * Interactive Shapes — 交互图形画板样式
 * ========================================================== */

/* ── 页面与画布 ─────────────────────────────────────────── */
body.immersive-canvas {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: #f0f0f2;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

.shapes-canvas {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at center, #fcfcfd 0%, #eef0f3 100%);
}

/* Figma 风格的高级画板网格背景线 */
.canvas-grid {
  position: absolute;
  inset: 0;
  background-size: 30px 30px;
  background-image: 
    linear-gradient(to right, rgba(0, 0, 0, 0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.04) 1px, transparent 1px);
  pointer-events: none;
}

/* ── 色彩系统（莫兰迪半透明配色） ───────────────────────── */
:root {
  --color-shape-blue:   rgba(122, 162, 187, 0.85);  /* #7aa2bb */
  --color-shape-green:  rgba(142, 172, 143, 0.85);  /* #8eac8f */
  --color-shape-orange: rgba(220, 155, 126, 0.85);  /* #dc9b7e */
  --color-shape-purple: rgba(160, 143, 178, 0.85);  /* #a08fbt */
  --color-shape-yellow: rgba(226, 198, 137, 0.85);  /* #e2c689 */
  --color-shape-red:    rgba(214, 137, 137, 0.85);  /* #d68989 */
  --color-shape-teal:   rgba(115, 175, 169, 0.85);  /* #73afa9 */
  --color-shape-rose:   rgba(224, 154, 171, 0.85);  /* #e09aab */
  
  --color-active-border: #007aff;
}

/* ── 控制面板（半透明玻璃拟态） ─────────────────────────── */
.canvas-control-panel {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 1000;
  width: 200px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 12px;
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.panel-header {
  margin-bottom: 16px;
}

.panel-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #1a1a1a;
  letter-spacing: 0.1em;
}

.panel-subtitle {
  font-size: 10px;
  color: #888;
}

.panel-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-actions button {
  width: 100%;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.8);
  color: #333;
  cursor: pointer;
  transition: all 0.2s ease;
}

.panel-actions button:hover {
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.15);
}

.panel-actions button:active {
  transform: scale(0.98);
}

#btn-scramble {
  background: #1a1a1a;
  color: #fff;
  border: none;
}

#btn-scramble:hover {
  background: #333;
}

/* ── 图形项目 ───────────────────────────────────────────── */
.shapes-container {
  width: 100%;
  height: 100%;
  position: relative;
}

.shape-item {
  position: absolute;
  cursor: grab;
  display: inline-block;
  padding: 10px; /* 缓冲区域以容纳旋转手柄 */
  box-sizing: content-box;
  transform-origin: center center;
  transition: box-shadow 0.2s ease;
  touch-action: none; /* 针对移动端的防滚动机制 */
}

.shape-item:active {
  cursor: grabbing;
}

.shape-item svg {
  display: block;
  pointer-events: none; /* 防止 SVG 内部干扰拖动 */
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.05));
  transition: transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.shape-item:hover svg {
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.08));
}

/* ── 激活状态与旋转控制手柄 ────────────────────────────── */

/* 默认隐藏激活框 */
.shape-item::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px dashed transparent;
  border-radius: 8px;
  pointer-events: none;
  transition: border-color 0.2s ease;
}

.shape-item.is-active::before,
.shape-item:hover::before {
  border-color: var(--color-active-border);
}

.rotate-handle {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  background: #fff;
  border: 2px solid var(--color-active-border);
  border-radius: 50%;
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38l5.67-5.67'/></svg>") 8 8, crosshair;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* 连接线 */
.rotate-handle::after {
  content: "";
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  height: 9px;
  background: var(--color-active-border);
  z-index: -1;
}

.shape-item.is-active .rotate-handle,
.shape-item:hover .rotate-handle {
  opacity: 1;
  pointer-events: auto;
}

.rotate-handle:hover {
  transform: translateX(-50%) scale(1.3);
  background: var(--color-active-border);
}
