/* =============================================================================
 * AquaDynasty — components.css
 * Reusable UI: cards, buttons, bars, pills, modals, toasts, tooltips,
 * context menus, tabs, gauges.
 * ========================================================================== */

/* ---------- cards ---------- */

.card {
  background: linear-gradient(160deg, var(--glass-hi), var(--glass));
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.card.hoverable:hover {
  border-color: var(--line-hi);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.card-title { font-weight: 800; font-size: 15px; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.card-sub { color: var(--tx2); font-size: 12.5px; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--line-hi);
  background: var(--glass-hi);
  color: var(--tx0);
  font-size: 13.5px; font-weight: 700;
  cursor: pointer;
  transition: all 0.14s ease;
  white-space: nowrap;
  user-select: none;
}
.btn:hover { background: rgba(148, 190, 255, 0.16); border-color: rgba(148, 190, 255, 0.34); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, #1fb9e8, #2a6ef0);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 16px rgba(42, 130, 240, 0.35);
}
.btn-primary:hover { background: linear-gradient(135deg, #2fc9f5, #3a7ef8); box-shadow: 0 6px 22px rgba(42, 130, 240, 0.5); }

.btn-gold {
  background: linear-gradient(135deg, #f7c948, #f0a020);
  border-color: transparent; color: #422e00;
  box-shadow: 0 4px 16px rgba(240, 170, 32, 0.3);
}
.btn-gold:hover { box-shadow: 0 6px 22px rgba(240, 170, 32, 0.45); }

.btn-danger { background: rgba(255, 107, 122, 0.14); border-color: rgba(255, 107, 122, 0.4); color: var(--red); }
.btn-danger:hover { background: rgba(255, 107, 122, 0.24); }

.btn-ghost { background: transparent; border-color: var(--line); color: var(--tx1); }
.btn-ghost:hover { color: var(--tx0); }

.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 13px 26px; font-size: 15px; border-radius: 12px; }
.btn:disabled, .btn.disabled {
  opacity: 0.45; cursor: not-allowed; transform: none !important; box-shadow: none !important;
  pointer-events: none;
}
.btn .cost { font-family: var(--mono); font-weight: 600; font-size: 0.92em; opacity: 0.9; }

/* ---------- pills & badges ---------- */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--glass-hi);
  border: 1px solid var(--line);
  font-size: 11.5px; font-weight: 700;
  color: var(--tx1);
}
.pill.good { color: var(--green); border-color: rgba(61, 220, 151, 0.35); }
.pill.bad { color: var(--red); border-color: rgba(255, 107, 122, 0.35); }
.pill.gold { color: var(--gold); border-color: rgba(255, 209, 102, 0.35); }

.rarity-common { color: #9fb4d0; }
.rarity-uncommon { color: #3ddc97; }
.rarity-rare { color: #3aa2ff; }
.rarity-epic { color: #b78cff; }
.rarity-legendary {
  color: #ffd166;
  text-shadow: 0 0 12px rgba(255, 209, 102, 0.55);
  animation: legendary-pulse 2s ease-in-out infinite;
}
@keyframes legendary-pulse {
  0%, 100% { text-shadow: 0 0 8px rgba(255, 209, 102, 0.4); }
  50% { text-shadow: 0 0 18px rgba(255, 209, 102, 0.85); }
}

.gene-swatch {
  display: inline-block; width: 12px; height: 12px;
  border-radius: 4px; vertical-align: -1px;
  border: 1px solid rgba(255,255,255,0.25);
}

/* ---------- stat bars ---------- */

.bar {
  height: 7px;
  background: rgba(10, 20, 36, 0.8);
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}
.bar-fill {
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--acc), var(--acc2));
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  min-width: 0;
}
.bar-fill.green { background: linear-gradient(90deg, #3ddc97, #22b877); }
.bar-fill.gold { background: linear-gradient(90deg, #ffd166, #f0a020); }
.bar-fill.red { background: linear-gradient(90deg, #ff8a95, #ff5262); }
.bar-fill.purple { background: linear-gradient(90deg, #c9a6ff, #9a66ff); }
.bar-fill.striped {
  background-image: linear-gradient(45deg, rgba(255,255,255,0.16) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.16) 50%, rgba(255,255,255,0.16) 75%, transparent 75%);
  background-size: 14px 14px;
  animation: bar-stripes 0.8s linear infinite;
}
@keyframes bar-stripes { to { background-position: 14px 0; } }

.stat-row { display: flex; align-items: center; gap: 8px; font-size: 12px; margin: 5px 0; }
.stat-row .stat-label { width: 74px; flex-shrink: 0; color: var(--tx2); font-weight: 600; }
.stat-row .bar { flex: 1; }
.stat-row .stat-val { width: 44px; text-align: right; font-family: var(--mono); font-size: 11px; color: var(--tx1); }

/* ---------- toasts ---------- */

.toasts {
  position: fixed; top: 72px; right: 18px; z-index: 90;
  display: flex; flex-direction: column; gap: 9px;
  width: min(360px, calc(100vw - 30px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 14px;
  background: rgba(13, 24, 42, 0.92);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line-hi);
  border-left: 3px solid var(--acc);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  animation: toast-in 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
  cursor: pointer;
}
.toast.leaving { animation: toast-out 0.3s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(60px) scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(60px) scale(0.94); } }
.toast-icon { font-size: 19px; line-height: 1.2; flex-shrink: 0; }
.toast-body { flex: 1; color: var(--tx1); }
.toast-body b { color: var(--tx0); }
.toast.good { border-left-color: var(--green); }
.toast.bad { border-left-color: var(--red); }
.toast.epic {
  border-left-color: var(--gold);
  background: linear-gradient(135deg, rgba(60, 45, 12, 0.94), rgba(13, 24, 42, 0.94));
  box-shadow: 0 8px 30px rgba(255, 190, 60, 0.18);
}

/* ---------- modals ---------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(3, 7, 14, 0.72);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fade-in 0.22s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-backdrop.leaving { animation: fade-out 0.2s ease forwards; }
@keyframes fade-out { to { opacity: 0; } }

.modal {
  width: min(560px, 100%);
  max-height: min(84vh, 900px);
  display: flex; flex-direction: column;
  background: linear-gradient(165deg, #13233c, #0c1830);
  border: 1px solid var(--line-hi);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.32s cubic-bezier(0.34, 1.3, 0.64, 1);
  overflow: hidden;
}
.modal.wide { width: min(860px, 100%); }
@keyframes modal-in { from { opacity: 0; transform: translateY(26px) scale(0.96); } to { opacity: 1; transform: none; } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 17px 20px 13px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.modal-title { font-size: 17px; font-weight: 800; }
.modal-x {
  width: 30px; height: 30px; border-radius: 8px;
  border: none; background: var(--glass); color: var(--tx1);
  font-size: 15px; cursor: pointer;
  transition: all 0.15s ease;
}
.modal-x:hover { background: rgba(255, 107, 122, 0.2); color: var(--red); }

.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 9px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.modal-flavor { color: var(--tx1); font-size: 14px; font-style: italic; margin-bottom: 12px; }

/* ---------- tooltip ---------- */

.tooltip {
  position: fixed; z-index: 95;
  max-width: 280px;
  padding: 9px 12px;
  background: rgba(10, 18, 33, 0.97);
  border: 1px solid var(--line-hi);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-md);
  font-size: 12px; color: var(--tx1);
  pointer-events: none;
  animation: tip-in 0.15s ease;
}
.tooltip b { color: var(--tx0); }
@keyframes tip-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* ---------- context menu ---------- */

.ctx-menu {
  position: fixed; z-index: 96;
  min-width: 190px;
  padding: 6px;
  background: rgba(13, 24, 42, 0.97);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line-hi);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  animation: tip-in 0.14s ease;
}
.ctx-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 10px;
  border: none; background: transparent;
  border-radius: 6px;
  font-size: 13px; font-weight: 600; color: var(--tx1);
  cursor: pointer; text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}
.ctx-item:hover { background: var(--glass-hi); color: var(--tx0); }
.ctx-item.danger:hover { background: rgba(255, 107, 122, 0.15); color: var(--red); }
.ctx-sep { height: 1px; margin: 5px 8px; background: var(--line); }

/* ---------- tabs ---------- */

.tabs {
  display: flex; gap: 4px;
  padding: 4px;
  background: rgba(10, 20, 36, 0.6);
  border: 1px solid var(--line);
  border-radius: 11px;
  width: fit-content;
  margin-bottom: 16px;
}
.tab {
  padding: 7px 16px;
  border: none; background: transparent;
  border-radius: 8px;
  font-size: 13px; font-weight: 700; color: var(--tx2);
  cursor: pointer;
  transition: all 0.15s ease;
}
.tab:hover { color: var(--tx1); }
.tab.active { background: var(--glass-hi); color: var(--acc); box-shadow: var(--shadow-sm); }

/* ---------- misc ---------- */

.empty-note {
  padding: 34px 20px;
  text-align: center;
  color: var(--tx2);
  font-size: 13.5px;
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
}
.empty-note .big { font-size: 34px; display: block; margin-bottom: 10px; opacity: 0.7; }

.kv { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: 13px; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--tx2); font-weight: 600; }
.kv .v { font-weight: 700; text-align: right; }

.flex { display: flex; gap: 8px; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.mt { margin-top: 12px; }
.muted { color: var(--tx2); font-size: 12px; }

/* progress ring (research) */
.ring { position: relative; width: 46px; height: 46px; flex-shrink: 0; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-bg { stroke: rgba(148, 190, 255, 0.12); }
.ring .ring-fg { stroke: var(--acc); stroke-linecap: round; transition: stroke-dashoffset 0.4s ease; }
.ring .ring-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; color: var(--acc);
}
