/* --- Phonics Trace (Letter Tracing) --- */

.trace-info-bar {
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  gap: clamp(0.85rem, 2.5vw, 1.3rem);
  flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 18px;
  padding: clamp(0.75rem, 2vw, 1.1rem);
  box-shadow: 0 10px 28px rgba(255, 111, 183, 0.24);
  margin-bottom: clamp(0.7rem, 2.4vw, 1.2rem);
}

.trace-letter-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: clamp(62px, 11vw, 100px);
  aspect-ratio: 1;
  background: linear-gradient(135deg, var(--paula-primary), var(--paula-accent));
  border-radius: 20px;
  box-shadow: 0 12px 26px rgba(255, 111, 183, 0.34);
  color: #fff;
}

.trace-letter-display {
  font-family: 'Fredoka One', cursive;
  font-size: clamp(2.1rem, 12vw, 3.6rem);
  line-height: 1;
}

.trace-details {
  flex: 1;
  min-width: min(260px, 100%);
  display: flex;
  flex-direction: column;
  gap: clamp(0.4rem, 2vw, 0.65rem);
}

.trace-letter-title {
  font-weight: 700;
  font-size: clamp(1.05rem, 2.4vw, 1.3rem);
  color: var(--paula-text);
  margin: 0;
}

.trace-progress-info {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.trace-progress-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  color: var(--paula-text-muted);
  background: rgba(255, 111, 183, 0.24);
  padding: 0.45rem 0.75rem;
  border-radius: 12px;
}

.trace-progress-item::before {
  content: '•';
  font-size: 1.1em;
  color: var(--paula-primary);
}

.trace-progress-track {
  position: relative;
  width: 100%;
  height: 0.65rem;
  background: rgba(255, 111, 183, 0.28);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.2rem;
}

.trace-progress-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--paula-primary) 0%, var(--paula-accent) 45%, var(--paula-secondary) 100%);
  border-radius: inherit;
  transition: width 0.4s ease;
}

.trace-board {
  position: relative;
  background: #fbe3e6; /* soft pink like the example */
  border-radius: 18px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
  width: 100%;
  height: min(70vh, 620px);
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: clamp(0.75rem, 2vw, 1.25rem);
}

@supports (height: 100dvh) {
  .trace-board { height: min(70dvh, 620px); }
}

.trace-svg {
  width: 100%;
  height: 100%;
  touch-action: none; /* allow smooth pointer events */
}

#traceGuide {
  fill: none;
  stroke: rgba(255,255,255,0.5);
  stroke-width: 22;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#traceProgress {
  fill: none;
  stroke-width: 22;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

#traceDot {
  fill: var(--paula-primary);
  stroke: #ffffff;
  stroke-width: 3;
  r: 10;
  pointer-events: none;
  transform-box: fill-box;
  transform-origin: center;
}

#traceSpeakBtn {
  position: absolute;
  right: 12px;
  bottom: 12px;
}

.trace-dot-start {
  animation: traceDotPulse 1.2s ease-in-out infinite;
}

@keyframes traceDotPulse {
  0%, 100% { transform: scale(1); fill: var(--paula-primary); }
  50% { transform: scale(1.2); fill: var(--paula-primary-dark); }
}

.trace-tip {
  margin-top: clamp(0.75rem, 2vw, 1.1rem);
  font-weight: 600;
  color: var(--paula-text-muted);
  text-align: center;
}

.trace-board.completed {
  animation: traceCelebrate 0.6s ease;
  box-shadow: 0 10px 28px rgba(183, 222, 140, 0.4);
}

.trace-board.completed #traceProgress {
  stroke: rgba(255, 255, 255, 0.9);
}

.trace-board.completed #traceGuide {
  stroke: rgba(255, 255, 255, 0.75);
}

.trace-board.demoing {
  box-shadow: 0 12px 28px rgba(216, 134, 60, 0.25);
}

.trace-board.demoing #traceProgress {
  stroke: rgba(255, 255, 255, 0.9);
}

.trace-board.demoing #traceGuide {
  stroke: rgba(255, 255, 255, 0.35);
}

@keyframes traceCelebrate {
  0% { transform: scale(1); }
  40% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

@media (max-width: 600px) {
  .trace-info-bar { padding: 0.6rem 0.75rem; }
  .trace-board { height: min(60vh, 520px); border-radius: 16px; }
}

@media (max-width: 480px) {
  .trace-info-bar { flex-direction: column; align-items: stretch; }
  .trace-progress-info { width: 100%; }
  .trace-progress-item { justify-content: center; }
  .trace-letter-title { text-align: center; }
  .trace-board { height: min(55vh, 460px); padding: clamp(0.6rem, 4vw, 1rem); }
  #traceSpeakBtn { right: 8px; bottom: 8px; }
}

@media (max-width: 360px) {
  .trace-board { height: min(50vh, 420px); padding: 0.6rem; }
}
