/* ============================================================
   ANKH Markets — peer-to-peer marketplace for the ANKH network
   Shares the ANKH Cash palette so the two sites read as one family.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --gold:       #f5a623;
  --gold-light: #ffd175;
  --gold-dark:  #c47f10;
  --amber:      #ff8a00;
  --electric:   #00e5ff;
  --mint:       #0effa3;
  --violet:     #9b59ff;
  --rose:       #ff4f81;

  --surface-0: #050507;
  --surface-1: #0c0c10;
  --surface-2: #141418;
  --surface-3: #1c1c22;

  --text-primary:   #f0ede6;
  --text-secondary: #9a97a3;
  --text-tertiary:  #63616d;

  --border-subtle: rgba(245, 166, 35, 0.14);
  --border-hard:   rgba(255, 255, 255, 0.08);
  --glass:         rgba(255, 255, 255, 0.025);

  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 18px 50px rgba(0, 0, 0, 0.55);
  --ease:      cubic-bezier(0.16, 1, 0.3, 1);

  --max: 1220px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 620px at 12% -12%, rgba(245, 166, 35, 0.09), transparent 62%),
    radial-gradient(900px 560px at 92% 4%, rgba(155, 89, 255, 0.07), transparent 60%),
    var(--surface-0);
  color: var(--text-primary);
  font-family: 'Space Grotesk', ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-light); }

h1, h2, h3, h4 { margin: 0 0 0.5em; line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.85rem); }
h3 { font-size: 1.15rem; }
p  { margin: 0 0 1em; }

.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.muted { color: var(--text-secondary); }
.dim { color: var(--text-tertiary); }
.small { font-size: 0.85rem; }
.tiny { font-size: 0.78rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.stack > * + * { margin-top: 0.75rem; }
.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }

.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 20px; }

/* ── Header ───────────────────────────────────────────────── */

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(5, 5, 7, 0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-hard);
}
.header-inner { display: flex; align-items: center; gap: 1.1rem; height: 66px; }

.brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; font-size: 1.12rem; color: var(--text-primary); letter-spacing: -0.02em; }
.brand:hover { color: var(--text-primary); }
.brand-mark {
  width: 30px; height: 30px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--gold), var(--amber));
  border-radius: 9px; color: #120c02; font-weight: 700; font-size: 1.05rem;
}
.brand-suffix { color: var(--gold); }

.nav { display: flex; gap: 0.25rem; margin-left: 0.5rem; }
.nav a {
  padding: 0.45rem 0.75rem; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 0.93rem; font-weight: 500;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.nav a:hover { background: var(--glass); color: var(--text-primary); }
.nav a.active { color: var(--gold); background: rgba(245, 166, 35, 0.1); }

.header-actions { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }

.nav-toggle { display: none; background: none; border: 1px solid var(--border-hard); color: var(--text-primary);
  border-radius: var(--radius-sm); width: 38px; height: 38px; font-size: 1.1rem; cursor: pointer; }

/* ── Buttons ──────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.6rem 1.05rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-hard); background: var(--surface-2); color: var(--text-primary);
  font-family: inherit; font-size: 0.92rem; font-weight: 500; cursor: pointer;
  transition: transform 0.15s var(--ease), background 0.18s var(--ease), border-color 0.18s var(--ease), opacity 0.18s;
  text-align: center;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-subtle); color: var(--text-primary); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: linear-gradient(135deg, var(--gold), var(--amber)); border-color: transparent; color: #140d02; font-weight: 600; }
.btn-primary:hover { background: linear-gradient(135deg, var(--gold-light), var(--gold)); color: #140d02; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--rose); border-color: rgba(255, 79, 129, 0.3); background: rgba(255, 79, 129, 0.07); }
.btn-danger:hover { background: rgba(255, 79, 129, 0.14); color: var(--rose); }
.btn-sm { padding: 0.38rem 0.7rem; font-size: 0.83rem; }
.btn-lg { padding: 0.8rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; }

/* ── Forms ────────────────────────────────────────────────── */

label { display: block; font-size: 0.86rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 0.32rem; }
.field { margin-bottom: 1.05rem; }
.field-hint { font-size: 0.79rem; color: var(--text-tertiary); margin-top: 0.3rem; }

input[type="text"], input[type="search"], input[type="number"], input[type="password"], textarea, select {
  width: 100%; padding: 0.62rem 0.8rem;
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border-hard); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.94rem;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--gold); background: var(--surface-2);
}
input::placeholder, textarea::placeholder { color: var(--text-tertiary); }
textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%), linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 2rem; }

.inline-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 1rem; }

/* ── Cards & surfaces ─────────────────────────────────────── */

.card {
  background: linear-gradient(180deg, var(--surface-1), var(--surface-0));
  border: 1px solid var(--border-hard); border-radius: var(--radius);
  padding: 1.15rem;
}
.card-pad-lg { padding: 1.6rem; }
.panel { background: var(--surface-1); border: 1px solid var(--border-hard); border-radius: var(--radius); padding: 1.15rem; }

.section { padding: 2.2rem 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.section-head h2 { margin: 0; }

/* ── Badges & pills ───────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.55rem; border-radius: 999px;
  font-size: 0.74rem; font-weight: 600; letter-spacing: 0.02em;
  border: 1px solid var(--border-hard); background: var(--surface-2); color: var(--text-secondary);
}
.badge-human { color: var(--mint); border-color: rgba(14, 255, 163, 0.28); background: rgba(14, 255, 163, 0.08); }
.badge-gold  { color: var(--gold); border-color: rgba(245, 166, 35, 0.3); background: rgba(245, 166, 35, 0.1); }
.badge-buy   { color: var(--electric); border-color: rgba(0, 229, 255, 0.28); background: rgba(0, 229, 255, 0.08); }
.badge-sell  { color: var(--gold); border-color: rgba(245, 166, 35, 0.3); background: rgba(245, 166, 35, 0.1); }
.badge-warn  { color: var(--amber); border-color: rgba(255, 138, 0, 0.3); background: rgba(255, 138, 0, 0.09); }
.badge-danger{ color: var(--rose); border-color: rgba(255, 79, 129, 0.3); background: rgba(255, 79, 129, 0.09); }
.badge-ok    { color: var(--mint); border-color: rgba(14, 255, 163, 0.28); background: rgba(14, 255, 163, 0.08); }
.badge-violet{ color: var(--violet); border-color: rgba(155, 89, 255, 0.3); background: rgba(155, 89, 255, 0.1); }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  padding: 0.34rem 0.72rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-hard); background: var(--surface-1);
  color: var(--text-secondary); font-size: 0.83rem; font-family: inherit;
  transition: all 0.18s var(--ease);
}
.chip:hover { border-color: var(--border-subtle); color: var(--text-primary); }
.chip.active { background: rgba(245, 166, 35, 0.12); border-color: var(--gold); color: var(--gold); }

/* ── Listing grid ─────────────────────────────────────────── */

.listing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); gap: 1.05rem; }

.listing-card {
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--surface-1), var(--surface-0));
  border: 1px solid var(--border-hard); border-radius: var(--radius);
  overflow: hidden; color: inherit;
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.listing-card:hover { transform: translateY(-3px); border-color: var(--border-subtle); box-shadow: var(--shadow); color: inherit; }

.listing-thumb {
  aspect-ratio: 16 / 10; background: var(--surface-2); position: relative;
  display: grid; place-items: center; overflow: hidden;
}
.listing-thumb img { width: 100%; height: 100%; object-fit: cover; }
.listing-thumb .placeholder { font-size: 2rem; opacity: 0.22; }
.listing-thumb .side-tag { position: absolute; top: 9px; left: 9px; }

.listing-body { padding: 0.85rem 0.95rem 1rem; display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }
.listing-title { font-weight: 600; font-size: 1rem; line-height: 1.32; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.listing-price { font-family: 'JetBrains Mono', monospace; font-size: 1.12rem; font-weight: 600; color: var(--gold); }
.listing-price .unit { font-size: 0.74rem; color: var(--text-tertiary); margin-left: 0.2rem; }
.listing-meta { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; font-size: 0.79rem; color: var(--text-tertiary); }

/* ── Tables ───────────────────────────────────────────────── */

table.data { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.data th { text-align: left; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); padding: 0.5rem 0.65rem; border-bottom: 1px solid var(--border-hard); font-weight: 600; }
table.data td { padding: 0.7rem 0.65rem; border-bottom: 1px solid rgba(255, 255, 255, 0.045); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }

/* ── Modal ────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(3, 3, 5, 0.78); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 20px;
  animation: fade 0.18s var(--ease);
}
.modal {
  width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
  background: var(--surface-1); border: 1px solid var(--border-subtle);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem;
  animation: rise 0.22s var(--ease);
}
.modal-wide { max-width: 640px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; }
.modal-head h3 { margin: 0; }
.modal-close { background: none; border: none; color: var(--text-tertiary); font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 0 0.2rem; }
.modal-close:hover { color: var(--text-primary); }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* ── Toasts ───────────────────────────────────────────────── */

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 0.55rem; max-width: 380px; }
.toast {
  padding: 0.8rem 1rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border-hard);
  box-shadow: var(--shadow); font-size: 0.9rem; animation: rise 0.2s var(--ease);
}
.toast-ok { border-color: rgba(14, 255, 163, 0.32); }
.toast-error { border-color: rgba(255, 79, 129, 0.36); }
.toast-info { border-color: rgba(0, 229, 255, 0.28); }

/* ── Notices ──────────────────────────────────────────────── */

.notice { padding: 0.85rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--border-hard); background: var(--surface-1); font-size: 0.89rem; }
.notice-warn { border-color: rgba(255, 138, 0, 0.3); background: rgba(255, 138, 0, 0.06); }
.notice-danger { border-color: rgba(255, 79, 129, 0.3); background: rgba(255, 79, 129, 0.06); }
.notice-ok { border-color: rgba(14, 255, 163, 0.28); background: rgba(14, 255, 163, 0.05); }
.notice-info { border-color: rgba(0, 229, 255, 0.24); background: rgba(0, 229, 255, 0.05); }

.empty { padding: 3rem 1rem; text-align: center; color: var(--text-tertiary); }
.empty-icon { font-size: 2.4rem; opacity: 0.35; display: block; margin-bottom: 0.6rem; }

/* ── Hero ─────────────────────────────────────────────────── */

.hero { padding: 3.2rem 0 2.2rem; }
.hero h1 { max-width: 16ch; }
.hero .lede { font-size: 1.1rem; color: var(--text-secondary); max-width: 58ch; }
.hero-actions { display: flex; gap: 0.7rem; flex-wrap: wrap; margin-top: 1.4rem; }

.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 0.8rem; margin-top: 2.2rem; }
.stat { background: var(--glass); border: 1px solid var(--border-hard); border-radius: var(--radius-sm); padding: 0.85rem 0.95rem; }
.stat .value { font-family: 'JetBrains Mono', monospace; font-size: 1.32rem; font-weight: 600; color: var(--gold); }
.stat .label { font-size: 0.75rem; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Profile ──────────────────────────────────────────────── */

.profile-head { display: flex; gap: 1.3rem; align-items: center; flex-wrap: wrap; }
.avatar {
  width: 74px; height: 74px; border-radius: 18px; flex: none;
  display: grid; place-items: center; font-size: 1.7rem; font-weight: 700; color: #140d02;
  background: linear-gradient(140deg, var(--gold), var(--amber));
}
.avatar-sm { width: 36px; height: 36px; border-radius: 10px; font-size: 0.92rem; }

.rating-stars { color: var(--gold); letter-spacing: 0.08em; font-size: 0.98rem; }
.rating-stars .off { color: var(--text-tertiary); }

.star-input { display: flex; gap: 0.25rem; }
.star-input button { background: none; border: none; font-size: 1.7rem; line-height: 1; color: var(--text-tertiary); cursor: pointer; padding: 0; transition: color 0.15s; }
.star-input button.on { color: var(--gold); }

/* ── Order thread ─────────────────────────────────────────── */

.thread { display: flex; flex-direction: column; gap: 0.7rem; max-height: 440px; overflow-y: auto; padding-right: 0.3rem; }
.msg { max-width: 82%; padding: 0.65rem 0.85rem; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border-hard); font-size: 0.9rem; }
.msg.mine { align-self: flex-end; background: rgba(245, 166, 35, 0.1); border-color: rgba(245, 166, 35, 0.22); }
.msg .who { font-size: 0.72rem; color: var(--text-tertiary); margin-bottom: 0.25rem; }

.steps { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.step { flex: 1 1 130px; padding: 0.65rem 0.8rem; border-radius: var(--radius-sm); border: 1px solid var(--border-hard); background: var(--surface-1); font-size: 0.83rem; color: var(--text-tertiary); }
.step.done { border-color: rgba(14, 255, 163, 0.3); color: var(--mint); background: rgba(14, 255, 163, 0.05); }
.step.current { border-color: var(--gold); color: var(--gold); background: rgba(245, 166, 35, 0.07); }
.step .n { font-family: 'JetBrains Mono', monospace; font-size: 0.72rem; opacity: 0.7; display: block; }

/* ── Wiki / prose ─────────────────────────────────────────── */

.layout-sidebar { display: grid; grid-template-columns: 250px 1fr; gap: 2rem; align-items: start; }
.sidebar { position: sticky; top: 86px; }
.sidebar-group { margin-bottom: 1.3rem; }
.sidebar-group h4 { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-tertiary); margin-bottom: 0.45rem; }
.sidebar a { display: block; padding: 0.35rem 0.55rem; border-radius: 7px; color: var(--text-secondary); font-size: 0.9rem; }
.sidebar a:hover { background: var(--glass); color: var(--text-primary); }
.sidebar a.active { color: var(--gold); background: rgba(245, 166, 35, 0.1); }

.prose { max-width: 74ch; font-size: 1.005rem; line-height: 1.72; color: #ddd9d2; }
.prose h2 { margin: 2rem 0 0.7rem; padding-bottom: 0.35rem; border-bottom: 1px solid var(--border-hard); }
.prose h3 { margin: 1.5rem 0 0.5rem; color: var(--gold-light); }
.prose ul, .prose ol { padding-left: 1.3rem; margin: 0 0 1.1rem; }
.prose li { margin-bottom: 0.4rem; }
.prose code { font-family: 'JetBrains Mono', monospace; font-size: 0.87em; background: var(--surface-2); border: 1px solid var(--border-hard); border-radius: 5px; padding: 0.1em 0.38em; color: var(--gold-light); }
.prose strong { color: var(--text-primary); font-weight: 600; }
.prose blockquote { margin: 0 0 1.1rem; padding: 0.6rem 1rem; border-left: 2px solid var(--gold); background: var(--glass); color: var(--text-secondary); }
.prose hr { border: none; border-top: 1px solid var(--border-hard); margin: 1.8rem 0; }

/* ── Directory ────────────────────────────────────────────── */

.dir-list { display: grid; gap: 0.8rem; }
.dir-entry { display: flex; gap: 1rem; align-items: flex-start; padding: 1.05rem; border: 1px solid var(--border-hard); border-radius: var(--radius); background: var(--surface-1); }
.dir-entry:hover { border-color: var(--border-subtle); }
.vote-btn { flex: none; width: 52px; display: flex; flex-direction: column; align-items: center; gap: 0.1rem; padding: 0.45rem 0; border-radius: var(--radius-sm); border: 1px solid var(--border-hard); background: var(--surface-2); color: var(--text-secondary); cursor: pointer; font-family: inherit; transition: all 0.18s var(--ease); }
.vote-btn:hover { border-color: var(--gold); color: var(--gold); }
.vote-btn.voted { border-color: var(--gold); background: rgba(245, 166, 35, 0.12); color: var(--gold); }
.vote-btn .count { font-family: 'JetBrains Mono', monospace; font-weight: 600; font-size: 0.95rem; }
.vote-btn .caret { font-size: 0.7rem; }

/* ── Footer ───────────────────────────────────────────────── */

.site-footer { margin-top: 3.5rem; border-top: 1px solid var(--border-hard); padding: 2rem 0 2.6rem; color: var(--text-tertiary); font-size: 0.87rem; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1.6rem; margin-bottom: 1.6rem; }
.footer-grid h4 { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-secondary); margin-bottom: 0.5rem; }
.footer-grid a { display: block; color: var(--text-tertiary); padding: 0.16rem 0; }
.footer-grid a:hover { color: var(--gold); }

/* ── Utility ──────────────────────────────────────────────── */

.addr { font-family: 'JetBrains Mono', monospace; font-size: 0.82rem; color: var(--text-secondary); word-break: break-all; }
.copy-btn { background: none; border: none; color: var(--text-tertiary); cursor: pointer; font-size: 0.8rem; padding: 0.1rem 0.3rem; font-family: inherit; }
.copy-btn:hover { color: var(--gold); }

.skeleton { background: linear-gradient(90deg, var(--surface-1), var(--surface-2), var(--surface-1)); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }

.divider { height: 1px; background: var(--border-hard); margin: 1.2rem 0; }

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 880px) {
  .layout-sidebar { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .nav {
    display: none; position: absolute; top: 66px; left: 0; right: 0;
    flex-direction: column; gap: 0; padding: 0.6rem 20px 1rem; margin: 0;
    background: rgba(5, 5, 7, 0.97); border-bottom: 1px solid var(--border-hard);
  }
  .nav.open { display: flex; }
  .nav a { padding: 0.7rem 0.6rem; }
  .nav-toggle { display: block; order: 3; }
  .header-actions { margin-left: auto; }
}

@media (max-width: 560px) {
  .wrap { padding: 0 15px; }
  .hero { padding: 2.2rem 0 1.6rem; }
  .listing-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; }
  .brand span.brand-text { font-size: 1rem; }
  .toasts { left: 15px; right: 15px; max-width: none; }
  .modal { padding: 1.15rem; }
  .dir-entry { padding: 0.85rem; gap: 0.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
