/* ==========================================================================
   TraceMyLetter.com - Tracing Canvas & Pen Tools Stylesheet
   ========================================================================== */

.tracing-playground {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: var(--space-8);
  align-items: start;
}

@media (max-width: 960px) {
  .tracing-playground {
    grid-template-columns: 1fr;
  }
}

/* Main Tracing Board Card */
.tracing-board-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  position: relative;
}

.tracing-board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.instruction-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-brand);
}

/* Canvas Area Container */
.canvas-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #FCFDFF;
  border-radius: var(--radius-lg);
  border: 2px solid #E2E8F0;
  overflow: hidden;
  touch-action: none;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.03);
  user-select: none;
  -webkit-user-select: none;
}

/* 3-Line Handwriting Guide on Canvas */
.canvas-guidelines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.canvas-line-headline {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 16%;
  height: 0;
  border-top: 2px solid rgba(125, 211, 252, 0.7);
}

.canvas-line-midline {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 50%;
  height: 0;
  border-top: 2.5px dashed rgba(251, 191, 36, 0.75);
}

.canvas-line-baseline {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 84%;
  height: 0;
  border-top: 2.5px solid rgba(52, 211, 153, 0.75);
}

/* Background Dotted Letter SVG */
.canvas-target-glyph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
  opacity: 0.95;
}

.canvas-target-glyph svg {
  height: 82%;
  width: auto;
  max-width: 90%;
  overflow: visible;
}

/* The Interactive Drawing Surface */
.drawing-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  z-index: 5;
}

/* Confetti overlay */
.confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}

/* Pen & Tool Palette */
.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  padding-top: var(--space-2);
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Color Swatches */
.color-palette {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-surface-soft);
  padding: 4px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
}

.color-swatch {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  border: 2px solid white;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform var(--transition-bounce), box-shadow var(--transition-fast);
  position: relative;
}

.color-swatch:hover {
  transform: scale(1.2);
}

.color-swatch.active {
  transform: scale(1.25);
  box-shadow: 0 0 0 2.5px var(--color-primary), 0 2px 6px rgba(0,0,0,0.2);
}

/* Rainbow Magic Swatch */
.rainbow-swatch {
  background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
}

/* Brush size toggles */
.brush-sizes {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--color-surface-soft);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
}

.brush-size-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.brush-size-btn .dot {
  background: var(--color-text);
  border-radius: 50%;
}

.brush-size-btn.sm .dot { width: 6px; height: 6px; }
.brush-size-btn.md .dot { width: 12px; height: 12px; }
.brush-size-btn.lg .dot { width: 18px; height: 18px; }

.brush-size-btn:hover {
  background: rgba(255, 255, 255, 0.8);
}

.brush-size-btn.active {
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.brush-size-btn.active .dot {
  background: var(--color-primary);
}

/* Bottom Action Bar (Clear, Done, Prev/Next) */
.canvas-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-border);
}

.actions-nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Starting dot glow animation */
@keyframes startPulse {
  0% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.35); opacity: 0.5; }
  100% { transform: scale(1); opacity: 0.9; }
}

.start-guide-dot {
  animation: startPulse 1.8s infinite ease-in-out;
  transform-origin: center;
}
