/* ===========================
   CoreFormation — ui.css
=========================== */

/* ---- Modal Overlay ---- */
.modal {
  position: fixed; inset: 0;
  background: rgba(80,60,20,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  backdrop-filter: blur(3px);
  animation: fadeIn 0.15s ease;
}
.modal.hidden { display: none; }

@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

/* ---- Modal Box ---- */
.modal-box {
  background: linear-gradient(160deg, #fffef5 0%, #fff8dc 100%);
  border: 3px solid var(--border);
  border-radius: 24px;
  padding: 24px 28px;
  min-width: 340px;
  max-width: 560px;
  width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(80,60,20,0.25);
  animation: popIn 0.22s cubic-bezier(0.34,1.56,0.64,1);
}
.modal-box.wide { max-width: 640px; }

@keyframes popIn { from { transform:scale(0.85); opacity:0; } to { transform:scale(1); opacity:1; } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.modal-header h2 { font-family: var(--font-head); font-size: 1.5rem; color: #5a3e1b; }

.modal-close {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--border); background: white;
  font-size: 1rem; cursor: pointer; color: #a08040;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.modal-close:hover { background: #ffd93d; }

.modal-subtitle { color: #a08040; font-size: 0.88rem; font-weight: 600; margin-bottom: 14px; }

/* ---- Workbench Tabs ---- */
.wb-tabs {
  display: flex; gap: 6px; margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 10px;
}
.wb-tab {
  font-family: var(--font-body); font-weight: 700; font-size: 0.85rem;
  padding: 6px 16px; border-radius: 100px;
  border: 2px solid transparent; background: white;
  cursor: pointer; color: #a08040;
  transition: all 0.15s;
}
.wb-tab:hover { border-color: var(--border); color: #5a3e1b; }
.wb-tab.active { background: #ffd93d; border-color: #e6b800; color: #5a3e1b; }

.wb-content { min-height: 120px; }

/* ---- Craft Grid ---- */
.craft-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.craft-card {
  background: white; border: 2px solid var(--border); border-radius: 14px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 4px;
  cursor: pointer; transition: all 0.15s; position: relative; overflow: hidden;
}
.craft-card:hover:not(.disabled) {
  border-color: #e6b800; transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(180,140,40,0.18);
}
.craft-card.disabled { opacity: 0.5; cursor: not-allowed; }
.craft-icon { font-size: 1.8rem; }
.craft-name { font-family: var(--font-head); font-size: 0.95rem; color: #5a3e1b; }
.craft-desc { font-size: 0.76rem; color: #a08040; font-weight: 600; line-height: 1.3; }
.craft-cost { display: flex; align-items: center; gap: 4px; font-family: var(--font-head); font-size: 0.9rem; color: #c07800; margin-top: 2px; }

/* ---- Terrain Grid ---- */
.terrain-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-bottom: 14px;
}
.terrain-btn {
  border: 3px solid transparent; border-radius: 12px;
  padding: 10px 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: all 0.15s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.terrain-btn:hover { transform: scale(1.05); box-shadow: 0 4px 12px rgba(0,0,0,0.18); }
.terrain-btn.active { border-color: #ffd93d; box-shadow: 0 0 0 3px #ffd93d; }
.terrain-icon { font-size: 1.5rem; }
.terrain-name { font-size: 0.72rem; font-weight: 800; color: #1a1a2e; text-shadow: 0 1px 2px rgba(255,255,255,0.7); }

.terrain-effects { display: flex; flex-direction: column; gap: 4px; }
.effect-row {
  display: flex; justify-content: space-between;
  font-size: 0.82rem; font-weight: 600; color: #7a6030;
  padding: 4px 8px; background: rgba(255,243,196,0.5); border-radius: 6px;
}

/* ---- Upgrade Grid ---- */
.upgrade-section-title {
  font-family: var(--font-head); font-size: 1rem; color: #5a3e1b;
  margin: 14px 0 8px;
}
.upgrade-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-bottom: 6px;
}
.upgrade-card {
  background: white; border: 2px solid var(--border); border-radius: 12px;
  padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer; text-align: center; transition: all 0.15s;
}
.upgrade-card:hover:not(.disabled):not(.maxed) {
  border-color: #e6b800; transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(180,140,40,0.2);
}
.upgrade-card.disabled { opacity: 0.5; cursor: not-allowed; }
.upgrade-card.maxed { background: #fff9e6; border-color: #ffd93d; cursor: default; }
.upgrade-icon { font-size: 1.4rem; }
.upgrade-name { font-family: var(--font-head); font-size: 0.82rem; color: #5a3e1b; }
.upgrade-desc { font-size: 0.7rem; color: #a08040; font-weight: 600; line-height: 1.2; }
.upgrade-level { font-size: 0.85rem; color: #e6b800; letter-spacing: 1px; }
.upgrade-cost { font-family: var(--font-head); font-size: 0.82rem; color: #c07800; }

/* ---- Wave Banner ---- */
#wave-banner {
  position: fixed; top: 70px; left: 50%;
  transform: translateX(-50%) scale(0.8);
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  color: white; font-family: var(--font-head); font-size: 1.7rem;
  padding: 10px 36px; border-radius: 100px;
  box-shadow: 0 6px 30px rgba(238,90,36,0.45);
  opacity: 0; pointer-events: none; z-index: 150;
  transition: all 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
#wave-banner.show { opacity: 1; transform: translateX(-50%) scale(1); }

/* ---- Save Modal ---- */
#save-modal .modal-box { max-width: 480px; }
#save-output {
  width: 100%; height: 120px;
  border: 2px solid var(--border); border-radius: 12px;
  padding: 10px 14px; font-family: monospace; font-size: 0.8rem;
  resize: none; background: #fffef0; color: #5a3e1b; outline: none;
  margin: 12px 0;
}
.save-btn-row { display: flex; gap: 10px; justify-content: flex-end; }

.btn-primary {
  background: #ffd93d; border: 2px solid #e6b800; border-radius: 100px;
  padding: 9px 20px; font-family: var(--font-body); font-weight: 800;
  font-size: 0.88rem; color: #5a3e1b; cursor: pointer; transition: all 0.15s;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(230,184,0,0.3); }

.btn-secondary {
  background: white; border: 2px solid var(--border); border-radius: 100px;
  padding: 9px 20px; font-family: var(--font-body); font-weight: 700;
  font-size: 0.88rem; color: #a08040; cursor: pointer; transition: all 0.15s;
}
.btn-secondary:hover { background: #fff3c4; }
