/* assets/double-displacement/double-displacement.css */
:root{
  --ink:#0f172a;
  --muted:#64748b;
  --shadow: 0 18px 45px rgba(15,23,42,.12);
  --shadow2: 0 10px 24px rgba(15,23,42,.10);
  --r:24px;

  --purple: rgba(168,85,247,.18);
  --green: rgba(34,197,94,.18);
  --blue: rgba(59,130,246,.18);
  --orange: rgba(251,146,60,.18);
}

*{box-sizing:border-box}
body{
  margin:0;
  font-family: system-ui,-apple-system,Segoe UI,Roboto,Arial;
  color:var(--ink);
  background:
    radial-gradient(circle at 12% 12%, rgba(168,85,247,.18), transparent 45%),
    radial-gradient(circle at 88% 18%, rgba(34,197,94,.14), transparent 45%),
    radial-gradient(circle at 30% 92%, rgba(59,130,246,.14), transparent 45%),
    linear-gradient(180deg,#f6fbff,#fff7ff);
  min-height:100vh;
}

/* topbar */
.topbar{max-width:1100px;margin:0 auto;padding:18px 16px 10px;display:flex;gap:12px;align-items:flex-start}
.back{
  text-decoration:none;
  padding:10px 12px;
  border-radius:14px;
  background:rgba(15,23,42,.06);
  color:var(--ink);
  font-weight:900;
  border:1px solid rgba(15,23,42,.08);
}
.pill{
  display:inline-flex;
  padding:7px 10px;
  border-radius:999px;
  font-weight:1000;
  font-size:12px;
  color:#334155;
  background: rgba(15,23,42,.06);
  border:1px solid rgba(15,23,42,.08);
}
.title h1{margin:8px 0 0;font-size:clamp(24px,3.6vw,38px);letter-spacing:-.02em}
.subtitle{margin:6px 0 0;color:var(--muted);font-size:14px;font-weight:700}

/* layout */
.page{max-width:1100px;margin:0 auto;padding:0 16px 26px}
.panel{
  background: rgba(255,255,255,.78);
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 18px;
  backdrop-filter: blur(8px);
  margin-top: 10px;
}
.panelTop{display:flex;justify-content:space-between;align-items:baseline;gap:12px;flex-wrap:wrap}
.panelTop h2{margin:0}
.muted{margin:0;color:var(--muted);font-size:13px;font-weight:800}

.labGrid{margin-top:14px;display:grid;grid-template-columns:1fr;gap:12px}
@media(min-width:980px){.labGrid{grid-template-columns:1fr 1.15fr 1fr}}

.card{
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(15,23,42,.08);
  border-radius: var(--r);
  box-shadow: var(--shadow2);
  padding: 16px;
}
.cardTitle{margin:0 0 10px;font-size:16px}

/* reactants */
.tray{display:flex;gap:14px;justify-content:center;flex-wrap:wrap}
.compoundBtn{
  width:140px;
  height:120px;
  border-radius: 26px;
  border:1px solid rgba(15,23,42,.10);
  background: var(--purple);
  box-shadow: 0 12px 24px rgba(15,23,42,.10);
  cursor:grab;
  display:grid;
  place-items:center;
  gap:8px;
  font-weight:1000;
  transition: transform .12s ease, box-shadow .12s ease;
}
.compoundBtn:active{cursor:grabbing; transform: scale(.99)}
.compoundBtn:hover{transform: translateY(-2px)}
.compoundBtn small{opacity:.75;font-size:12px}

.pair{
  width:44px;height:44px;border-radius:16px;
  display:grid;place-items:center;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(15,23,42,.10);
  font-size:18px;
}
.compoundBtn .pair{display:inline-grid}
.compoundBtn{grid-auto-flow:row}
.compoundBtn > .pair:nth-child(1),
.compoundBtn > .pair:nth-child(2){display:inline-grid}
.compoundBtn{grid-template-columns:1fr 1fr}

/* note */
.note{
  margin-top:12px;
  padding:10px 12px;
  border-radius:18px;
  background: rgba(251,146,60,.12);
  border: 1px dashed rgba(251,146,60,.25);
  color:#7c2d12;
  font-weight:900;
  font-size:12px;
  text-align:center;
}

/* dance floor */
.mid{position:relative}
.danceFloor{
  position:relative;
  height: 260px;
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(168,85,247,.12), rgba(34,197,94,.08));
  border: 2px dashed rgba(168,85,247,.28);
  display:grid;
  place-items:center;
  text-align:center;
  overflow:hidden;
  transition: box-shadow .2s ease, border-color .2s ease;
}
.danceFloor.dragOver{
  border-color: rgba(34,197,94,.55);
  box-shadow: 0 18px 45px rgba(34,197,94,.18);
}

/* equation badge */
.eqBadge{
  position:absolute;
  top:14px;
  left:50%;
  transform:translateX(-50%);
  padding:10px 14px;
  border-radius:999px;
  font-weight:1000;
  font-size:14px;
  letter-spacing:.02em;
  background: rgba(255,255,255,.86);
  border:1px solid rgba(15,23,42,.10);
  box-shadow: 0 12px 22px rgba(15,23,42,.10);
}

.floorHint{
  color:var(--muted);
  font-weight:1000;
  line-height:1.1;
}
.floorHint small{font-weight:900;opacity:.85}

.floorSlots{
  position:absolute;
  bottom: 14px;
  left: 0;
  right: 0;
  display:flex;
  justify-content:center;
  gap: 10px;
}
.slot{
  width:120px;height:48px;
  border-radius: 16px;
  display:grid;
  place-items:center;
  font-weight:1000;
  border:1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.82);
  opacity:.55;
  transition:.2s ease;
}
.slot.on{opacity:1; background: var(--green);}

.dancers{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 16px;
  pointer-events:none;
}
.dancer{
  width:120px;height:94px;
  border-radius: 30px;
  display:grid;
  place-items:center;
  font-weight:1000;
  font-size: 18px;
  border:1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.92);
  box-shadow: 0 18px 35px rgba(15,23,42,.12);
  opacity: 0;
  transform: translateY(14px) scale(.9);
  transition: opacity .25s ease, transform .25s ease;
}
.dancer.show{
  opacity:1;
  transform: translateY(0) scale(1);
}

/* dance animation */
.dance .dancer{
  animation: dance 1.1s ease-in-out forwards;
}
@keyframes dance{
  0%{transform: translateY(0) scale(1)}
  25%{transform: translateY(-10px) rotate(-6deg) scale(1.03)}
  50%{transform: translateY(6px) rotate(6deg) scale(1.00)}
  75%{transform: translateY(-8px) rotate(-5deg) scale(1.03)}
  100%{transform: translateY(0) rotate(0) scale(1)}
}

/* controls */
.controls{margin-top:12px;display:flex;gap:10px;flex-wrap:wrap;justify-content:center}
.btn{
  border:1px solid rgba(15,23,42,.10);
  background: rgba(15,23,42,.06);
  border-radius: 18px;
  padding:10px 14px;
  font-weight:1000;
  cursor:pointer;
}
.btn.primary{
  background: rgba(168,85,247,.16);
  border-color: rgba(168,85,247,.22);
  color:#581c87;
}
.btn:disabled{
  opacity:.45;
  cursor:not-allowed;
}
.status{
  margin-top:10px;
  padding:8px 10px;
  border-radius:999px;
  font-weight:1000;
  font-size:12px;
  background: rgba(15,23,42,.06);
  border:1px solid rgba(15,23,42,.10);
  text-align:center;
}

/* products */
.productsBox{
  height: 220px;
  border-radius: 24px;
  border: 1px solid rgba(15,23,42,.08);
  background: linear-gradient(180deg, rgba(34,197,94,.08), rgba(59,130,246,.06));
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 16px;
  overflow:hidden;
}
.productChip{
  width:92px;height:92px;
  border-radius:28px;
  display:grid;
  place-items:center;
  font-weight:1000;
  font-size: 30px;
  background: rgba(255,255,255,.92);
  border:1px solid rgba(15,23,42,.10);
  box-shadow: 0 18px 35px rgba(15,23,42,.12);
  opacity: 0;
  transform: translateY(14px) scale(.9);
  transition: opacity .25s ease, transform .25s ease;
}
.productChip.show{
  opacity: 1;
  transform: translateY(0) scale(1);
}

.miniExplain{
  margin-top:12px;
  padding:12px;
  border-radius:18px;
  background: rgba(168,85,247,.10);
  border: 1px dashed rgba(168,85,247,.22);
  color:#581c87;
  font-size:12px;
  font-weight:900;
  line-height:1.3;
}

/* sparks */
.fx{position:absolute;inset:0;pointer-events:none}
.spark{
  position:absolute;
  width:8px;height:8px;
  border-radius:999px;
  background: rgba(251,191,36,.95);
  box-shadow: 0 0 14px rgba(251,191,36,.65);
  animation: sparkUp .85s ease-out forwards;
}
@keyframes sparkUp{
  0%{transform: translate(0,0) scale(1); opacity:1;}
  100%{transform: translate(var(--dx), var(--dy)) scale(.2); opacity:0;}
}
