/* ==========================================================================
   PIAR - Scratch Blocks Renderer (scratchblocks SVG + fallback)
   Estética de laboratorio tecnológico futurista: limpio, preciso y legible
   ========================================================================== */

/* Bloques vectoriales oficiales (scratchblocks) */
pre.blocks {
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  font-family: inherit;
  overflow-x: auto;
  max-width: 100%;
}

svg.scratchblocks {
  display: block;
  vertical-align: middle;
  filter: drop-shadow(0 2px 5px rgba(15, 29, 46, 0.08));
}

code.blocks svg.scratchblocks {
  display: inline-block;
  vertical-align: -0.28em;
  filter: none;
}

/* Contenedor de código Scratch */
.scratch-code {
  background: var(--bg-surface-panel, #f8fafc);
  border: 1px solid var(--border-tech, #cbd8e6);
  border-radius: var(--radius-md, 10px);
  padding: 1.25rem 1.5rem;
  margin: 1.25rem 0;
  overflow-x: auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  user-select: none;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(15, 29, 46, 0.04));
  transition: var(--transition, all 0.18s ease);
}

.scratch-code:hover {
  border-color: var(--border-accent, rgba(6, 182, 212, 0.45));
  box-shadow: var(--shadow-md, 0 3px 8px -1px rgba(15, 29, 46, 0.05));
}

.scratch-stack {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  filter: drop-shadow(0 2px 5px rgba(15, 29, 46, 0.1));
}

/* Bloque individual base */
.sb {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1;
  padding: 0.4rem 0.65rem;
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), inset 0 -1px 0 rgba(0, 0, 0, 0.12);
  margin-bottom: -1px;
  white-space: nowrap;
}

/* Bloque "Hat" (Sombrero de inicio) */
.sb-hat {
  border-radius: 16px 16px 5px 5px;
  padding-top: 0.55rem;
  padding-bottom: 0.45rem;
  position: relative;
}

/* Paleta de bloques Scratch equilibrada */
.sb-motion {
  background-color: #0284c7;
  border-color: #0369a1;
}

.sb-looks {
  background-color: #7c3aed;
  border-color: #6d28d9;
}

.sb-sound {
  background-color: #9333ea;
  border-color: #7e22ce;
}

.sb-events {
  background-color: #d97706;
  border-color: #b45309;
  color: #ffffff;
}

.sb-control {
  background-color: #ea580c;
  border-color: #c2410c;
  color: #ffffff;
}

.sb-sensing {
  background-color: #0891b2;
  border-color: #0e7490;
}

.sb-operators {
  background-color: #059669;
  border-color: #047857;
}

.sb-variables {
  background-color: #d97706;
  border-color: #b45309;
}

/* Bloques C (Bucles: Repetir, Por siempre) */
.sb-c-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: -1px;
}

.sb-c-header {
  border-radius: 5px 5px 0 0;
  width: 100%;
}

.sb-c-body {
  padding-left: 0.1rem;
  border-left: 12px solid #ea580c;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-top: -1px;
  margin-bottom: -1px;
  background-clip: padding-box;
}

.sb-control-border {
  border-left-color: #ea580c;
}

.sb-c-footer {
  height: 10px;
  width: 48px;
  border-radius: 0 0 5px 5px;
}

.sb-control-footer {
  background-color: #ea580c;
  border: 1px solid #c2410c;
  border-top: none;
}

/* Entradas / Inputs */
.sb-input-number, .sb-input-text {
  background-color: #ffffff;
  color: #0f1d2e;
  border-radius: 10px;
  padding: 0.18rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid rgba(15, 29, 46, 0.18);
  display: inline-block;
  min-width: 1.4rem;
  text-align: center;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
}

.sb-dropdown {
  background-color: rgba(0, 0, 0, 0.18);
  color: #ffffff;
  border-radius: 10px;
  padding: 0.18rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.sb-dropdown::after {
  content: "▼";
  font-size: 0.55rem;
  opacity: 0.85;
}

/* Iconos dentro de bloques */
.sb-icon-flag {
  display: inline-block;
  width: 13px;
  height: 13px;
  background-color: #22c55e;
  clip-path: polygon(0 0, 100% 30%, 0 60%);
  border-left: 2px solid #15803d;
  vertical-align: middle;
  margin-right: 2px;
}

.sb-icon-turn-cw::before {
  content: "↻";
  font-size: 1rem;
  font-weight: bold;
}

.sb-icon-turn-ccw::before {
  content: "↺";
  font-size: 1rem;
  font-weight: bold;
}

/* Bloques en línea dentro del texto explicativo */
.sb-inline {
  display: inline-flex;
  vertical-align: middle;
  padding: 0.18rem 0.45rem;
  font-size: 0.78rem;
  margin: 0 0.12rem;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(15, 29, 46, 0.08);
}
