/* TX Arena base styles (docs/specs/core.md §4, CONTRACT 3.4 / 3.5 / 4.3.2b).
   Global design tokens, the app grid, utilities, the shared .tx-pop popover, toasts, the donate dialog,
   the X link and the Copy CA pill. Module stylesheets load after this one. */

/* ---------------------------------------------------------------------------------------------------------
   Tokens. Axiom tokens are "R G B" triplets used as rgb(var(--x)) or rgb(var(--x) / alpha).
   --------------------------------------------------------------------------------------------------------- */
:root {
  --ax-bg: #06070b;
  --background-secondary: 16 17 22;
  --background-tertiary: 24 25 32;
  --primary-stroke: 34 36 46;
  --secondary-stroke: 44 46 58;
  --border-subtle: 26 28 36;
  --text-primary: 252 252 252;
  --text-secondary: 119 122 140;
  --text-tertiary: 74 77 92;
  --primary-color: 82 111 255;
  --primary-color-hover: 106 131 255;
  --increase: 47 227 172;
  --increase-hover: 80 235 188;
  --primary-green: 47 227 172;
  --chart-up: 47 227 172;
  --decrease: 236 57 122;
  --decrease-hover: 240 88 143;
  --primary-red: 236 57 122;
  --chart-down: 236 57 122;
  --primary-yellow: 247 196 51;
  --primary-orange: 255 138 61;
  --primary-light-blue: 95 190 255;

  /* J7 (plain colours) */
  --j7-bg: #1b1b1b;
  --j7-bg-2: #222222;
  --j7-bg-3: #2a2a2a;
  --j7-input: #161616;
  --j7-border: #333333;
  --j7-border-2: #3d3d3d;
  --j7-text: #ededed;
  --j7-text-2: #a3a3a3;
  --j7-text-3: #6b6b6b;
  --j7-accent: #6d6af5;
  --j7-green: #4ade80;
  --j7-yellow: #eab308;
  --j7-pink: #ec4899;
  --j7-red: #ef4444;
  --j7-blue: #1d9bf0;

  /* app */
  --j7-width: 430px; /* overridden inline on <html> by TX.layout */
  --font-ax: "Geist", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --font-j7: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --emoji: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;

  color-scheme: dark;
}

/* ---------------------------------------------------------------------------------------------------------
   Base
   --------------------------------------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
}
body {
  background: var(--ax-bg);
  color: rgb(var(--text-primary));
  font-family: var(--font-ax);
  font-size: 13px;
  line-height: 1.35;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}
img {
  display: block;
}
a {
  color: inherit;
  text-decoration: none;
}

/* utilities */
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.emoji {
  font-family: var(--emoji);
}
.hidden {
  display: none !important;
}
.truncate {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* scrollbars: thin, secondary-stroke thumb on a transparent track */
* {
  scrollbar-width: thin;
  scrollbar-color: rgb(var(--secondary-stroke)) transparent;
}
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgb(var(--secondary-stroke));
  border-radius: 6px;
}

/* the generic popover; the class doubles as the "a popover is open" marker (Escape owners step aside) */
.tx-pop {
  position: fixed;
  z-index: 800;
  min-width: 180px;
  padding: 6px;
  background: rgb(var(--background-tertiary));
  border: 1px solid rgb(var(--secondary-stroke));
  border-radius: 6px;
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.5);
}

/* ---------------------------------------------------------------------------------------------------------
   App grid: J7 | resizer | ANXIOM
   --------------------------------------------------------------------------------------------------------- */
#app {
  display: grid;
  height: 100vh;
  grid-template-columns: var(--j7-width) 4px minmax(0, 1fr);
  grid-template-areas: "j7 rz ax";
}
#app.j7-right {
  grid-template-columns: minmax(0, 1fr) 4px var(--j7-width);
  grid-template-areas: "ax rz j7";
}
/* 4.6 CORE-2 [FIX]: hidden J7 = one full-viewport ANXIOM area, whatever the side (the original collapsed) */
#app.j7-hidden {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 100vh;
  grid-template-areas: "ax";
}
#app.j7-hidden > #j7,
#app.j7-hidden > #j7-resizer {
  display: none;
}

#j7 {
  grid-area: j7;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--j7-bg);
  font-family: var(--font-j7);
  color: var(--j7-text);
}
#j7-resizer {
  grid-area: rz;
  cursor: col-resize;
  background: #0d0d10;
  border-left: 1px solid #222;
  border-right: 1px solid #222;
  touch-action: none;
}
#j7-resizer:hover,
#j7-resizer.dragging {
  background: rgb(var(--primary-color) / 0.5);
}

#axiom {
  grid-area: ax;
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ax-bg);
}
#ax-nav,
#ax-bottom {
  flex: none;
}
#ax-body {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}
#ax-trades {
  flex: none;
}
#ax-view {
  flex: 1 1 auto;
  position: relative;
  min-width: 0;
  min-height: 0;
}

/* stacked layout: J7 on top (46vh), ANXIOM below (54vh), whatever the side */
@media (max-width: 900px) {
  #app,
  #app.j7-right {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 46vh 0 54vh;
    grid-template-areas: "j7" "rz" "ax";
  }
  #j7,
  #axiom {
    height: auto;
  }
  #j7-resizer {
    display: none;
  }
  #app.j7-hidden {
    grid-template-rows: 100vh;
    grid-template-areas: "ax";
  }
}

/* ---------------------------------------------------------------------------------------------------------
   Toasts (top centre of the ANXIOM pane; TX.toast writes left / top / max-width inline)
   --------------------------------------------------------------------------------------------------------- */
#toast-root {
  position: fixed;
  left: 50%;
  top: 92px;
  z-index: 900;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.toast {
  pointer-events: none;
  min-width: 220px;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgb(var(--background-tertiary));
  border: 1px solid rgb(var(--secondary-stroke));
  border-radius: 6px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.45);
  font-size: 13px;
  animation: toast-in 0.16s ease-out;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.t-icon {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  color: #000;
}
.toast.ok .t-icon {
  background: rgb(var(--increase));
}
.toast.err .t-icon {
  background: rgb(var(--decrease));
}
.toast.info .t-icon {
  background: rgb(var(--primary-color));
  color: #fff;
}
.t-msg {
  flex: 1;
  min-width: 0;
}
.t-ms {
  font-family: var(--font-mono);
  font-size: 12px;
  color: rgb(var(--primary-color));
}
.toast.out {
  opacity: 0;
  transform: translateY(-6px);
  transition: all 0.2s;
}

/* ---------------------------------------------------------------------------------------------------------
   Donate button + dialog (rendered only when TX.CONFIG.donateSol is set)
   --------------------------------------------------------------------------------------------------------- */
.dn-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  border-radius: 4px;
  border: 1px solid rgb(var(--decrease) / 0.45);
  color: rgb(var(--decrease));
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.dn-btn:hover {
  background: rgb(var(--decrease) / 0.1);
}
.dn-btn.lg {
  height: 34px;
  padding: 0 14px;
  border-radius: 6px;
  font-size: 13px;
}

.dn-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgb(0 0 0 / 0.6);
  display: grid;
  place-items: center;
  padding: 16px;
  animation: toast-in 0.14s ease-out;
}
.dn-card {
  position: relative;
  width: min(440px, 100%);
  padding: 26px 24px 20px;
  text-align: center;
  background: rgb(var(--background-tertiary));
  border: 1px solid rgb(var(--secondary-stroke));
  border-radius: 10px;
  box-shadow: 0 24px 60px rgb(0 0 0 / 0.6);
}
.dn-card h3 {
  margin: 10px 0 6px;
  font-size: 18px;
}
.dn-card p {
  margin: 0 0 18px;
  color: rgb(var(--text-secondary));
  font-size: 13px;
}
.dn-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  font-size: 22px;
  color: rgb(var(--decrease));
  background: rgb(var(--decrease) / 0.12);
}
.dn-x {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: rgb(var(--text-secondary));
  font-size: 18px;
}
.dn-x:hover {
  background: rgb(var(--secondary-stroke));
  color: rgb(var(--text-primary));
}
.dn-label {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgb(var(--text-tertiary));
  margin-bottom: 6px;
}
.dn-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.dn-addr {
  flex: 1;
  min-width: 0;
  padding: 10px;
  border-radius: 6px;
  background: var(--ax-bg);
  border: 1px solid rgb(var(--primary-stroke));
  font-size: 12px;
  word-break: break-all;
  text-align: left;
  user-select: all;
}
.dn-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 12px;
  border-radius: 6px;
  background: rgb(var(--primary-color));
  color: #fff;
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
}
.dn-copy:hover {
  background: rgb(var(--primary-color-hover));
}
.dn-open {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  color: rgb(var(--primary-color));
  font-weight: 600;
  font-size: 13px;
}
.dn-open:hover {
  text-decoration: underline;
}
.dn-note {
  margin-top: 12px;
  font-size: 11px;
  color: rgb(var(--text-tertiary));
}

/* ---------------------------------------------------------------------------------------------------------
   X link (rendered only when TX.CONFIG.xUrl is set)
   --------------------------------------------------------------------------------------------------------- */
.tx-x {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  flex-shrink: 0;
  color: rgb(var(--text-secondary));
  font-size: 13px;
  line-height: 1;
  text-decoration: none;
  border: 1px solid rgb(var(--secondary-stroke));
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tx-x:hover {
  color: rgb(var(--text-primary));
  border-color: rgb(var(--text-secondary) / 0.7);
  background: rgb(255 255 255 / 0.04);
}
.tx-x:focus-visible {
  outline: 2px solid rgb(var(--primary-color));
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------------------------------------------
   Copy CA button (CONTRACT 4.3.2b; rendered only when TX.CONFIG.token.ca is set): just the words "Copy CA"
   ("Copied" + .ok for 1.2 s after a copy). Base look = the X link pill of the ANXIOM bottom bar (24 px tall,
   4 px radius, secondary-stroke border); .gm-ca takes the quiet look of the game menu footer links.
   --------------------------------------------------------------------------------------------------------- */
.tx-ca {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1px solid rgb(var(--secondary-stroke));
  background: transparent;
  color: rgb(var(--text-secondary));
  font-family: var(--font-ax);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tx-ca-t {
  pointer-events: none;
}
.tx-ca:hover {
  color: rgb(var(--text-primary));
  border-color: rgb(var(--text-secondary) / 0.7);
  background: rgb(255 255 255 / 0.04);
}
.tx-ca:focus-visible {
  outline: 2px solid rgb(var(--primary-color));
  outline-offset: 2px;
}
.tx-ca.ok,
.tx-ca.ok:hover {
  color: rgb(var(--increase));
  border-color: rgb(var(--increase) / 0.5);
  background: rgb(var(--increase) / 0.08);
}

.tx-ca.gm-ca {
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  border-color: transparent;
  font-size: 13px;
  font-weight: 400;
}
.tx-ca.gm-ca:hover {
  color: rgb(var(--text-primary));
  border-color: transparent;
  background: rgb(var(--background-tertiary) / 0.8);
}
.tx-ca.gm-ca.ok,
.tx-ca.gm-ca.ok:hover {
  color: rgb(var(--increase));
  border-color: transparent;
  background: rgb(var(--increase) / 0.08);
}

/* fallback popover when both clipboard paths fail: the address selected, ready for Ctrl+C */
.tx-ca-pop {
  min-width: 220px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tx-ca-in {
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border-radius: 4px;
  background: var(--ax-bg);
  border: 1px solid rgb(var(--primary-stroke));
  color: rgb(var(--text-primary));
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
}
.tx-ca-in:focus {
  border-color: rgb(var(--primary-color));
}
.tx-ca-hint {
  font-size: 11px;
  color: rgb(var(--text-tertiary));
  text-align: center;
}
