/**
 * Element Fusion Lab Stylesheet
 * Futuristic Alchemy Lab UI with Neon Particle Glow and Responsive iPad Touch Layout
 */

.fusion-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px;
  box-sizing: border-box;
  background: linear-gradient(135deg, #090d16 0%, #111827 50%, #030712 100%);
  border-radius: 20px;
  border: 1px solid rgba(59, 130, 246, 0.25);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6), inset 0 1px 2px rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

/* --- TOP HUD BAR --- */
.fusion-hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(12px);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 10px;
  gap: 12px;
}

.fusion-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fusion-title-icon {
  font-size: 24px;
}

.fusion-title-text {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #38bdf8, #818cf8, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.fusion-progress-container {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  max-width: 320px;
}

.fusion-progress-track {
  flex: 1;
  height: 10px;
  background: rgba(30, 41, 59, 0.8);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.fusion-progress-fill {
  height: 100%;
  width: 5%;
  background: linear-gradient(90deg, #38bdf8, #a855f7);
  border-radius: 8px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.6);
}

.fusion-progress-count {
  font-size: 13px;
  font-weight: 700;
  color: #94a3b8;
  white-space: nowrap;
}

.fusion-hud-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fusion-hud-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(30, 41, 59, 0.7);
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.2s ease;
}

.fusion-hud-btn:hover {
  background: rgba(51, 65, 85, 0.9);
  transform: translateY(-1px);
}

.fusion-hud-btn.hint {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  border: none;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

/* --- MAIN STAGE LAYOUT --- */
.fusion-stage-layout {
  display: flex;
  flex: 1;
  gap: 12px;
  overflow: hidden;
}

/* --- LEFT LIBRARY SIDEBAR --- */
.fusion-library-panel {
  width: 320px;
  display: flex;
  flex-direction: column;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px;
  box-sizing: border-box;
}

.fusion-search-box {
  margin-bottom: 8px;
}

.fusion-search-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(30, 41, 59, 0.6);
  color: #fff;
  font-size: 13px;
  box-sizing: border-box;
  outline: none;
}

.fusion-search-input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.fusion-category-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 8px;
  scrollbar-width: thin;
}

.fusion-cat-btn {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  background: rgba(30, 41, 59, 0.6);
  color: #94a3b8;
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: all 0.2s;
}

.fusion-cat-btn.active {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #0f172a;
  border-color: #38bdf8;
  font-weight: 800;
}

.fusion-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.fusion-library-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  cursor: grab;
  user-select: none;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-align: center;
}

.fusion-library-card:hover {
  background: rgba(51, 65, 85, 0.8);
  transform: translateY(-2px) scale(1.04);
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.2);
}

.fusion-library-card:active {
  cursor: grabbing;
  transform: scale(0.96);
}

.fusion-card-emoji {
  font-size: 26px;
  margin-bottom: 4px;
}

.fusion-card-name {
  font-size: 11px;
  font-weight: 700;
  color: #e2e8f0;
  line-height: 1.2;
  word-break: break-word;
}

.fusion-empty-hint {
  grid-column: 1 / -1;
  text-align: center;
  padding: 30px;
  color: #64748b;
  font-size: 13px;
}

/* --- RIGHT WORKBENCH CANVAS / AREA --- */
.fusion-workbench-area {
  flex: 1;
  position: relative;
  background: radial-gradient(circle at 50% 50%, rgba(30, 58, 138, 0.15) 0%, rgba(15, 23, 42, 0.8) 100%);
  border-radius: 16px;
  border: 2px dashed rgba(56, 189, 248, 0.3);
  overflow: hidden;
  touch-action: none;
}

.fusion-workbench-empty-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(148, 163, 184, 0.5);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
  max-width: 80%;
}

.fusion-workbench-item {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 2px solid rgba(56, 189, 248, 0.5);
  border-radius: 16px;
  cursor: move;
  user-select: none;
  touch-action: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.2);
  transition: box-shadow 0.2s, transform 0.15s;
  z-index: 10;
}

.fusion-workbench-item.selected {
  border-color: #f59e0b;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.8);
  transform: scale(1.12);
  z-index: 30;
  animation: itemSelectPulse 1.2s infinite ease-in-out;
}

@keyframes itemSelectPulse {
  0%, 100% { transform: scale(1.12); }
  50% { transform: scale(1.18); }
}

.fusion-workbench-item.dragging {
  z-index: 50;
  transform: scale(1.15);
  box-shadow: 0 12px 28px rgba(56, 189, 248, 0.5);
}

.workbench-item-emoji {
  font-size: 26px;
}

.workbench-item-name {
  font-size: 10px;
  font-weight: 700;
  color: #e2e8f0;
  margin-top: 2px;
  max-width: 66px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workbench-item-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  border: 1px solid #fff;
  font-size: 10px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.fusion-workbench-item:hover .workbench-item-remove {
  opacity: 1;
}

/* --- DISCOVERY CELEBRATION MODAL --- */
.fusion-discovery-card {
  text-align: center;
  padding: 24px;
}

.fusion-discovery-header {
  font-size: 14px;
  font-weight: 800;
  color: #38bdf8;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.fusion-discovery-emoji {
  font-size: 64px;
  margin: 12px 0;
  animation: emojiPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes emojiPop {
  0% { transform: scale(0) rotate(-20deg); }
  60% { transform: scale(1.25) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.fusion-discovery-title {
  font-size: 24px;
  font-weight: 900;
  color: #fbbf24;
  margin-bottom: 8px;
}

.fusion-discovery-desc {
  font-size: 14px;
  color: #cbd5e1;
  margin-bottom: 12px;
  line-height: 1.4;
}

.fusion-discovery-fact {
  background: rgba(30, 41, 59, 0.8);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  color: #93c5fd;
  border-left: 4px solid #38bdf8;
  margin-bottom: 18px;
  text-align: left;
  line-height: 1.4;
}

/* --- HINT MODAL --- */
.fusion-hint-card {
  text-align: center;
  padding: 12px;
}

.hint-header {
  font-size: 14px;
  font-weight: 800;
  color: #f59e0b;
  margin-bottom: 12px;
}

.hint-recipe {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
}

.hint-elem {
  background: rgba(30, 41, 59, 0.8);
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.hint-plus, .hint-arrow {
  color: #38bdf8;
  font-weight: 900;
}

.hint-mystery {
  color: #f59e0b;
  font-weight: 800;
}

.hint-clue {
  font-size: 13px;
  font-style: italic;
  color: #94a3b8;
}

/* --- RESPONSIVE IPAD & MOBILE BREAKPOINTS --- */
@media (max-width: 768px) {
  .fusion-stage-layout {
    flex-direction: column-reverse;
  }
  .fusion-library-panel {
    width: 100%;
    height: 180px;
  }
  .fusion-workbench-area {
    min-height: 280px;
  }
}
