/* ============================================================
   AMM DEX dApp — gold & sapphire "trading workbench" theme
   Layout v4: slim top bar · KPI row · swap terminal + right rail ·
   composition gauge + activity list.
   NO background animation: the backdrop is static. Motion lives
   ONLY on elements (entrances, count-ups, arrow rotation, gauge
   width, glows, pulses).
   ============================================================ */

:root {
  --bg: #0d1117;
  --bg-2: #121824;
  --card: rgba(20, 27, 40, 0.92);
  --card-border: rgba(148, 163, 184, 0.15);
  --text: #edf2f9;
  --muted: #8b98ad;
  --accent-1: #f59e0b;  /* gold */
  --accent-2: #2563eb;  /* sapphire */
  --accent-grad: linear-gradient(135deg, #f59e0b 0%, #2563eb 100%);
  --danger: #ef4444;
  --success: #34d399;
  --warning: #f59e0b;
  --radius: 14px;
  --font-ui: "Inter", system-ui, -apple-system, sans-serif;
  --font-display: "Space Grotesk", var(--font-ui);
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  /* static backdrop — deliberately not animated */
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(245, 158, 11, 0.07), transparent 60%),
    radial-gradient(900px 500px at 92% 8%, rgba(37, 99, 235, 0.09), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); font-size: 12px; }
.center { text-align: center; }

/* ===================== TOP BAR ===================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 26px;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 700;
  color: #111827;
  background: var(--accent-grad);
  /* entrance only — no looping background animation */
  animation: markIn 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}
@keyframes markIn {
  from { opacity: 0; transform: scale(0.6) rotate(-90deg); }
  to   { opacity: 1; transform: scale(1) rotate(0deg); }
}
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 16.5px; }
.brand-name .slash { color: var(--accent-1); }
.brand-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--accent-2);
  background: rgba(37, 99, 235, 0.15);
  padding: 3px 8px;
  border-radius: 999px;
  vertical-align: middle;
}

.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.chain-badge {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--muted);
}
.chain-badge.ok { color: var(--success); border-color: rgba(52, 211, 153, 0.35); }

/* ===================== WORKBENCH ===================== */

.workbench {
  max-width: 1060px;
  margin: 0 auto;
  padding: 24px 22px 0;
}

/* ===================== BUTTONS & FORMS ===================== */

.btn {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  cursor: pointer;
  color: #fff;
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.2s ease;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:not(:disabled):hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn:not(:disabled):active { transform: translateY(0) scale(0.99); }

.btn-primary { background: var(--accent-grad); color: #fff; box-shadow: 0 6px 18px rgba(37, 99, 235, 0.28); }
.btn-ghost { background: rgba(148, 163, 184, 0.1); border: 1px solid var(--card-border); color: var(--text); }
.btn-ghost:hover { background: rgba(148, 163, 184, 0.18); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 8px 14px; font-size: 13px; }

/* swap CTA glow pulses on hover only (element animation) */
.swap-btn:not(:disabled) { animation: ctaGlow 2.6s ease-in-out infinite; }
@keyframes ctaGlow {
  0%, 100% { box-shadow: 0 6px 18px rgba(37, 99, 235, 0.25); }
  50% { box-shadow: 0 6px 26px rgba(245, 158, 11, 0.4); }
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent-1);
  cursor: pointer;
  font-size: 12.5px;
  font-family: var(--font-ui);
}
.link-btn:hover { text-decoration: underline; }

input, select {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text);
  background: rgba(148, 163, 184, 0.07);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14); }
input[readonly] { opacity: 0.75; }

label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 12px 0 6px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* ===================== BANNER / SETTINGS ===================== */

.banner {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.banner-icon { font-size: 26px; }
.banner h3 { font-family: var(--font-display); margin-bottom: 4px; }
.banner p { font-size: 13.5px; color: var(--muted); margin-bottom: 12px; }
.banner code, .settings-panel code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(148, 163, 184, 0.12);
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--accent-1);
}

.settings-panel { margin-bottom: 20px; }
.settings-panel h3 { font-family: var(--font-display); margin-bottom: 14px; }
.settings-panel .row { margin-top: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  animation: cardIn 0.5s cubic-bezier(0.2, 0.9, 0.3, 1) both;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.card:hover { border-color: rgba(245, 158, 11, 0.3); }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h2 { font-family: var(--font-display); font-size: 20px; }
.card-head h3 { font-family: var(--font-display); font-size: 16px; }

/* ===================== KPI ROW ===================== */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 760px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }

.kpi {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: kpiIn 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
}
.kpi:nth-child(2) { animation-delay: 60ms; }
.kpi:nth-child(3) { animation-delay: 120ms; }
.kpi:nth-child(4) { animation-delay: 180ms; }
@keyframes kpiIn {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.kpi-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.9px; color: var(--muted); }
.kpi-value { font-family: var(--font-mono); font-size: 18px; font-weight: 600; }
.kpi-value.bump { animation: numBump 0.5s ease; }
@keyframes numBump {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); color: var(--accent-1); }
  100% { transform: scale(1); }
}

/* ===================== WORKBENCH GRID ===================== */

.workbench-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 860px) { .workbench-grid { grid-template-columns: 1fr; } }

.rail { display: flex; flex-direction: column; gap: 16px; }

/* ===================== SWAP TERMINAL ===================== */

.pool-chip {
  margin-left: auto;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.12);
  color: var(--accent-1);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.swap-box {
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: rgba(148, 163, 184, 0.04);
  padding: 6px;
}

.swap-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}
.swap-field { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.swap-field input {
  border: none;
  background: transparent;
  font-size: 24px;
  font-weight: 600;
  padding: 4px 0;
  box-shadow: none;
}
.swap-field input:focus { box-shadow: none; border: none; }
.swap-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); }

.token-pill {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.14);
  border: 1px solid rgba(37, 99, 235, 0.35);
  color: #93c5fd;
  white-space: nowrap;
}

.swap-mid {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 14px;
}
.dir-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--bg-2);
  color: var(--accent-1);
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.45s cubic-bezier(0.3, 0.9, 0.4, 1.3), border-color 0.2s ease;
}
.dir-btn:hover { border-color: var(--accent-1); }
.dir-btn.flipped { transform: rotate(180deg); }
.balance-hint { font-size: 12px; }

.swap-meta {
  border-top: 1px dashed var(--card-border);
  margin: 12px 4px 0;
  padding: 10px 8px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.meta-line { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.meta-line .mono { color: var(--text); }

.swap-btn { width: 100%; margin-top: 14px; padding: 13px; font-size: 15px; }

/* ===================== LIQUIDITY ===================== */

.seg {
  margin-left: auto;
  display: flex;
  background: rgba(148, 163, 184, 0.08);
  border-radius: 10px;
  padding: 3px;
}
.seg-btn {
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.seg-btn.active { background: var(--accent-grad); color: #fff; }

.hint { font-size: 12.5px; margin-top: 10px; }
#panel-add .btn, #panel-remove .btn { width: 100%; margin-top: 14px; }

/* ===================== GAUGE ===================== */

.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 16px;
  margin-top: 16px;
}
@media (max-width: 860px) { .bottom-grid { grid-template-columns: 1fr; } }

.gauge {
  height: 14px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.18);
  overflow: hidden;
  margin-top: 12px;
}
.gauge-gld {
  display: block;
  height: 100%;
  width: 50%;
  border-radius: 999px;
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
  transition: width 0.9s cubic-bezier(0.3, 0.8, 0.4, 1);
}
.gauge-labels { display: flex; justify-content: space-between; margin-top: 8px; }
#pair-addr { margin-top: 10px; word-break: break-all; }

/* ===================== EVENTS ===================== */

.ev-list { display: flex; flex-direction: column; gap: 8px; max-height: 240px; overflow-y: auto; }
.ev-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  font-size: 12.5px;
  animation: evIn 0.35s ease both;
}
@keyframes evIn {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}
.ev-item .ev-detail { flex: 1; }
.ev-item .mono { font-size: 11.5px; }
.ev-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.ev-Swap { background: rgba(37, 99, 235, 0.16); color: #93c5fd; }
.ev-Mint { background: rgba(52, 211, 153, 0.15); color: #6ee7b7; }
.ev-Burn { background: rgba(244, 63, 94, 0.14); color: #fda4af; }
.ev-Sync { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; }

/* ===================== FOOTER ===================== */

.site-footer {
  margin-top: 34px;
  padding: 18px 0 24px;
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--muted);
}
.site-footer a { color: var(--accent-1); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
#footer-address { font-family: var(--font-mono); }

/* ===================== TOASTS ===================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}

.toast {
  background: rgba(20, 27, 40, 0.97);
  border: 1px solid var(--card-border);
  border-right: 3px solid var(--accent-2);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.25);
  word-break: break-word;
}
.toast.success { border-right-color: var(--success); }
.toast.error { border-right-color: var(--danger); }
.toast.info { border-right-color: var(--accent-2); }
.toast a { color: #93c5fd; }
.toast.out { opacity: 0; transform: translateX(14px); transition: all 0.25s ease; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px) scale(0.92); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

/* ===================== MISC ===================== */

[hidden] { display: none !important; }

.spin {
  display: inline-block;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

::selection { background: rgba(245, 158, 11, 0.35); }
