/* La fábrica de Robo — shared layout lives in game.css. */

.factory {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 4px 0 var(--line);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ---------- Things to sort ---------- */
.thing {
  --size: 40px;
  width: var(--size);
  height: var(--size);
  flex: none;
  display: inline-block;
  position: relative;
}
.thing.circulo { border-radius: 50%; }
.thing.cuadrado { border-radius: 6px; }
.thing.triangulo { clip-path: polygon(50% 4%, 98% 96%, 2% 96%); }
.thing.rojo { background: var(--red); }
.thing.azul { background: var(--blue); }
.thing.amarillo { background: var(--yellow); }
.thing.wrong { outline: 4px solid var(--ink); outline-offset: 2px; animation: shake .45s ease 2; }

/* ---------- Belt + machine ---------- */
.belt-row { display: flex; align-items: flex-end; gap: 12px; }
.belt {
  flex: 1;
  min-height: 72px;
  display: flex;
  flex-direction: row-reverse; /* first item sits next to the machine */
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: 14px;
  background: repeating-linear-gradient(90deg, #cbd5e1 0 14px, #e2e8f0 14px 28px);
  overflow: hidden;
  position: relative;
}
.belt.moving { animation: belt .5s linear infinite; }
@keyframes belt { to { background-position: 28px 0; } }

.machine {
  width: 150px;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
}
.robo { font-size: 3.2rem; line-height: 1; }
.slot {
  width: 60px; height: 60px;
  border-radius: 14px;
  background: #eef2ff;
  border: 3px dashed #c7d2fe;
  display: flex; align-items: center; justify-content: center;
}
.bubble {
  font-size: .92rem;
  font-weight: 600;
  background: #eff5ff;
  border-radius: 12px;
  padding: 6px 10px;
  text-align: center;
  min-height: 2.6em;
  width: 100%;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Bins ---------- */
.bins { display: grid; grid-template-columns: repeat(var(--bins, 2), 1fr); gap: 12px; }
.bin {
  border: 4px solid #cbd5e1;
  border-top: none;
  border-radius: 0 0 18px 18px;
  min-height: 130px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f8fafc;
  transition: background .2s;
}
.bin h3 { margin: 0; text-align: center; font-size: 1.3rem; }
.bin .inside { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-content: flex-start; flex: 1; }
.bin.hit { background: #dcfce7; }
.bin.miss { background: #fee2e2; animation: shake .45s ease; }

/* ---------- Rules editor ---------- */
/* The rules scroll on their own so ▶ Encender never leaves the screen. */
.rules { display: flex; flex-direction: column; gap: 10px; flex-shrink: 1; overflow-y: auto; min-height: 120px; }
.rule {
  background: #f6f8fd;
  border-radius: 14px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 3px solid transparent;
  transition: border-color .15s, background .15s;
}
.rule.matched { border-color: var(--green); background: #dcfce7; }
.rule.bad { border-color: var(--red); background: #fee2e2; }
.kw {
  font-weight: 700;
  background: var(--wall);
  color: #fff;
  border-radius: 8px;
  padding: 2px 10px;
}
.kw.else { background: var(--pink); }
.kw.join { background: var(--yellow); color: var(--ink); }
.cond, .then { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-weight: 600; }
.cond .del, .then .del { margin-left: auto; }
.rules select {
  font: inherit;
  font-size: 1.05rem;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
.rules select:focus { outline: none; border-color: var(--blue); }
.rules select.missing { border-color: var(--red); background: #fee2e2; }
.joins { display: flex; gap: 6px; }
.joins button, .rules .del {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  min-height: 40px;
  min-width: 44px;
  padding: 4px 12px;
  cursor: pointer;
  background: #fef3c7;
}
.rules .del { background: transparent; color: #b4bdd3; }
@media (hover: hover) { .rules .del:hover { color: #fff; background: var(--red); } }
.rules .del:active { color: #fff; background: var(--red); }
.rules button:disabled, .rules select:disabled { opacity: .6; cursor: not-allowed; }
.add-rule { align-self: flex-start; }
.add-rule[hidden] { display: none; }
