/* ============================================================
   描線模組
   互動模式 + 列印專用樣式
   ============================================================ */

/* ----------------------------------------------------------
   互動模式（Canvas 描線）
   ---------------------------------------------------------- */

.tracing-game {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--gradient-tracing);
}

.tracing-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  flex-shrink: 0;
  border-bottom: 1px solid #F3F4F6;
}

.tracing-type-label {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-primary);
}

.tracing-count {
  font-size: 13px;
  color: #9CA3AF;
  margin-left: 8px;
}

.tracing-actions {
  display: flex;
  gap: 8px;
}

.tracing-btn {
  padding: 8px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  -webkit-tap-highlight-color: transparent;
}

.tracing-btn-clear {
  background: #FDF2F8;
  color: #EC4899;
}

.tracing-btn-next {
  background: linear-gradient(135deg, #EC4899, #DB2777);
  color: #fff;
  box-shadow: 0 2px 8px rgba(236,72,153,0.3);
}

.tracing-canvas-wrap {
  flex: 1;
  position: relative;
  touch-action: none;
}

.tracing-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* 🏠 按鈕 — canvas 右上角 */
.tracing-exit-home {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.85);
  border: 1px solid #E5E7EB;
  border-radius: 12px;
  font-size: 22px;
  cursor: pointer;
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(4px);
}

/* Star float 動畫 */
.tracing-star-float {
  position: absolute;
  font-size: 16px;
  pointer-events: none;
  z-index: 20;
  animation: starFloat 800ms ease-out forwards;
}

@keyframes starFloat {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-48px) scale(0.5);
  }
}

/* ----------------------------------------------------------
   螢幕模式
   ---------------------------------------------------------- */

/* Grid 排列描線區塊 */
.tracing-grid {
  display: grid;
  grid-template-columns: repeat(var(--tracing-cols, 2), 1fr);
  grid-template-rows: repeat(var(--tracing-rows, 2), 1fr);
  gap: 16px;
  width: 100%;
  height: 100%;
  padding: 8px 0;
}

/* 單一描線區域 */
.tracing-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border: 2px dashed var(--color-gray-300);
  border-radius: var(--radius-md);
  background: var(--color-white);
}

/* 類型標籤 */
.tracing-item-label {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
  text-align: center;
}

/* SVG + emoji 容器 */
.tracing-item-body {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
  width: 100%;
}

/* SVG 容器 */
.tracing-svg {
  flex: 1;
  max-width: 100%;
  max-height: 100%;
  height: auto;
}

/* 裝飾 emoji */
.tracing-emoji {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}

.tracing-emoji--start {
  order: -1;
}

.tracing-emoji--end {
  order: 1;
}

/* ----------------------------------------------------------
   列印模式
   ---------------------------------------------------------- */
@media print {
  .tracing-grid {
    gap: 3mm;
    padding: 1mm 0;
  }

  .tracing-item {
    padding: 2mm;
    border: 0.5pt dashed #D1D5DB;
    border-radius: 3mm;
  }

  .tracing-item-label {
    font-size: 11pt;
  }

  .tracing-item-body {
    gap: 2mm;
  }

  .tracing-emoji {
    font-size: 18pt;
  }

  /* 列印時 SVG 線條用 mm 粗細 */
  .tracing-item[data-difficulty="easy"] .tracing-svg path {
    stroke-width: 1.2mm;
  }

  .tracing-item[data-difficulty="medium"] .tracing-svg path {
    stroke-width: 0.9mm;
  }

  .tracing-item[data-difficulty="hard"] .tracing-svg path {
    stroke-width: 0.6mm;
  }
}
