/* ============================================================
   Blocks-World Demo  —  Self-CriTeach
   Self-contained styles for the planning visualization
   ============================================================ */

#blocks-demo {
  position: relative;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1rem 1.5rem;
  box-sizing: border-box;
  font-family: 'Inter', 'Source Sans Pro', -apple-system, BlinkMacSystemFont,
               'Segoe UI', Roboto, sans-serif;
  color: #2d3748;
}

#blocks-demo .bw-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 500px;
  min-height: 220px;
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(102, 126, 234, 0.10), transparent 60%),
    radial-gradient(ellipse at 70% 100%, rgba(118, 75, 162, 0.10), transparent 60%),
    linear-gradient(180deg, #fbfcff 0%, #f1f4fb 100%);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 8px 32px rgba(49, 130, 206, 0.10),
    inset 0 0 0 1px rgba(49, 130, 206, 0.08);
}

#blocks-demo .bw-stage svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Top overlay: title + action chip */
#blocks-demo .bw-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 0.85rem 1rem 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  pointer-events: none;
  z-index: 3;
}

#blocks-demo .bw-title {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #4a5568;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(49, 130, 206, 0.18);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

#blocks-demo .bw-title-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3182ce;
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.18);
  animation: bw-pulse 1.8s ease-in-out infinite;
}

#blocks-demo .bw-chip {
  font-family: 'JetBrains Mono', 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: 0.82rem;
  font-weight: 600;
  color: #1a365d;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0.45rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(49, 130, 206, 0.25);
  box-shadow: 0 2px 12px rgba(49, 130, 206, 0.12);
  transition: opacity 0.35s ease, transform 0.35s ease;
  white-space: nowrap;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
}

#blocks-demo .bw-chip.bw-hidden {
  opacity: 0;
  transform: translateY(-6px);
}

#blocks-demo .bw-chip .bw-kw {
  color: #3182ce;
}

/* Top-right vertical stack (chip on top, goal beneath) */
#blocks-demo .bw-top-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
  max-width: 65%;
  min-width: 0;
}

/* Bottom overlay: progress only */
#blocks-demo .bw-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 1rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  pointer-events: none;
  z-index: 3;
}

#blocks-demo .bw-goal {
  font-size: 0.95rem;
  color: #1a365d;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  border: 1px solid rgba(49, 130, 206, 0.3);
  border-left: 4px solid #3182ce;
  font-weight: 600;
  line-height: 1.35;
  max-width: 100%;
  box-shadow: 0 2px 10px rgba(49, 130, 206, 0.1);
  text-align: right;
  white-space: normal;
  word-break: break-word;
}

#blocks-demo .bw-progress {
  display: flex;
  gap: 5px;
  align-items: center;
}

#blocks-demo .bw-progress-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(49, 130, 206, 0.22);
  transition: background 0.4s ease, transform 0.4s ease;
}

#blocks-demo .bw-progress-dot.bw-active {
  background: #3182ce;
  transform: scale(1.35);
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.18);
}

#blocks-demo .bw-progress-dot.bw-done {
  background: #38a169;
}

/* Thinking indicator between problems */
#blocks-demo .bw-thinking {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 4;
}

#blocks-demo .bw-thinking.bw-visible {
  opacity: 1;
}

#blocks-demo .bw-thinking-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  border: 1px solid rgba(49, 130, 206, 0.22);
  box-shadow: 0 6px 20px rgba(49, 130, 206, 0.18);
  font-size: 0.82rem;
  font-weight: 600;
  color: #1a365d;
  letter-spacing: 0.01em;
}

#blocks-demo .bw-thinking-dots {
  display: inline-flex;
  gap: 3px;
}

#blocks-demo .bw-thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3182ce;
  animation: bw-bounce 1.2s ease-in-out infinite;
}

#blocks-demo .bw-thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
#blocks-demo .bw-thinking-dots span:nth-child(3) { animation-delay: 0.30s; }

@keyframes bw-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40%           { transform: translateY(-5px); opacity: 1; }
}

@keyframes bw-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.18); }
  50%      { box-shadow: 0 0 0 6px rgba(49, 130, 206, 0.05); }
}

/* Responsive tweaks */
@media (max-width: 600px) {
  #blocks-demo { padding: 0.85rem 0.5rem 1rem; }
  #blocks-demo .bw-stage { border-radius: 14px; min-height: 200px; }
  #blocks-demo .bw-overlay { padding: 0.6rem 0.65rem 0; }
  #blocks-demo .bw-footer  { padding: 0 0.65rem 0.6rem; }
  #blocks-demo .bw-title   { font-size: 0.68rem; padding: 0.3rem 0.55rem; }
  #blocks-demo .bw-chip      { font-size: 0.72rem; padding: 0.35rem 0.55rem; }
  #blocks-demo .bw-goal      { font-size: 0.78rem; padding: 0.4rem 0.6rem; border-left-width: 3px; }
  #blocks-demo .bw-top-right { max-width: 72%; gap: 0.35rem; }
}

@media (max-width: 380px) {
  #blocks-demo .bw-goal { font-size: 0.72rem; }
}

/* Reduced-motion: hide thinking dots animations & block any motion */
@media (prefers-reduced-motion: reduce) {
  #blocks-demo .bw-title-dot,
  #blocks-demo .bw-thinking-dots span { animation: none; }
  #blocks-demo .bw-chip { transition: none; }
}
