/* ============================================================
   P.E.S.T Web App — core tokens, base, shell, common components
   Calmer take on the brand: same DNA, less grain/glitch, more clarity.
   ============================================================ */

:root {
  --c-cyan: #1b9df5;
  --c-violet: #7b3fe4;
  --c-magenta: #e0249a;

  --accent-grad: linear-gradient(150deg, var(--c-cyan) 0%, var(--c-violet) 52%, var(--c-magenta) 100%);
  --accent-grad-h: linear-gradient(90deg, var(--c-cyan) 0%, var(--c-violet) 50%, var(--c-magenta) 100%);

  /* Surfaces — near-black, faint cool cast, but a touch more lift than the landing page */
  --bg: #07070d;
  --bg-1: #0b0b14;
  --bg-2: #10101c;
  --bg-3: #16162552;
  --panel: #11111d;
  --panel-2: #15152300;
  --elev: #181826;

  --line: rgba(124, 112, 196, 0.14);
  --line-2: rgba(140, 122, 220, 0.26);
  --line-3: rgba(150, 132, 230, 0.4);

  --tx: #edeefb;
  --tx-dim: #a4a6c4;
  --tx-faint: #6b6d89;

  --ok: #16d39a;
  --warn: #ffb02e;
  --danger: #ff4d6d;

  --glow-cyan: 0 0 22px rgba(27, 157, 245, 0.32);
  --glow-violet: 0 0 22px rgba(123, 63, 228, 0.32);

  --sidebar-w: 248px;
  --topbar-h: 60px;
  --bottomnav-h: 64px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font-display: "Chakra Petch", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --r: 4px; /* small radius for inputs; cards use clip-path corners */
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--tx);
  font-family: var(--font-display);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; }
button { font-family: inherit; }
::selection { background: rgba(123, 63, 228, 0.4); }

/* faint ambient background, shared across the app */
.app-bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(50vw 40vh at 84% -6%, rgba(27, 157, 245, 0.07), transparent 60%),
    radial-gradient(46vw 40vh at 6% 106%, rgba(224, 36, 154, 0.06), transparent 60%),
    var(--bg);
}
.app-grid {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: 0.5;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 30%, #000 20%, transparent 80%);
}

/* utility */
.grad-text {
  background: var(--accent-grad-h);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.mono { font-family: var(--font-mono); }
.eyebrow {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.26em; text-transform: uppercase; color: var(--tx-faint);
}
.cut {
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%);
}
.cut-sm {
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 11px 18px;
  font-family: var(--font-mono); font-size: 12px; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--tx); background: rgba(255,255,255,0.025);
  border: 1px solid var(--line-2); cursor: pointer; text-decoration: none;
  transition: all 0.24s var(--ease);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { border-color: var(--line-3); background: rgba(123,63,228,0.12); transform: translateY(-1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent-grad-h); color: #fff; border: none; }
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 8px 24px rgba(123,63,228,0.4); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-danger { border-color: rgba(255,77,109,0.4); color: #ff8298; }
.btn-danger:hover { background: rgba(255,77,109,0.12); border-color: var(--danger); }
.btn-sm { padding: 8px 12px; font-size: 11px; }
.btn-block { width: 100%; }

/* ---------- Pills / chips / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; cursor: pointer;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em;
  color: var(--tx-dim); background: rgba(255,255,255,0.015);
  border: 1px solid var(--line-2); text-decoration: none;
  transition: all 0.2s var(--ease);
}
.pill svg { width: 14px; height: 14px; }
.pill:hover { color: var(--tx); border-color: var(--line-3); box-shadow: var(--glow-cyan); transform: translateY(-1px); }

.chip {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  padding: 5px 10px; border: 1px solid var(--line-2); color: var(--tx-dim);
  background: transparent; cursor: pointer; transition: all 0.2s var(--ease); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip svg { width: 13px; height: 13px; flex: none; }
.chip:hover { color: var(--tx); border-color: var(--line-3); }
.chip.on { background: var(--accent-grad-h); border-color: transparent; color: #fff; }
/* Pinned filter chip keeps a distinct cyan glow when active (P.E.S.T feature) */
.chip-pin.on { box-shadow: 0 0 0 1px var(--c-cyan, #2ec5ff), 0 4px 14px -4px rgba(46, 197, 255, 0.55); }

.tag {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  padding: 3px 8px; color: var(--tx-dim); border: 1px solid var(--line-2);
}

/* category accent dots */
.catdot { width: 7px; height: 7px; flex: none; }
.cat-NFTs { color: #1b9df5; } .cat-DeFi { color: #16d39a; }
.cat-Gaming { color: #7b3fe4; } .cat-Gambling { color: #e0249a; }
.cat-Bridges { color: #ff9f1c; } .cat-Security { color: #2ec5ff; }
.cat-Exchanges { color: #c46bff; }

/* ---------- Inputs ---------- */
.field { display: grid; gap: 7px; }
.field > label {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--tx-faint);
}
.input, .select, textarea.input {
  width: 100%; padding: 12px 14px;
  background: var(--bg); border: 1px solid var(--line-2); color: var(--tx);
  font-family: var(--font-display); font-size: 14px; font-weight: 300;
  transition: border-color 0.2s, box-shadow 0.2s; border-radius: var(--r);
}
.input::placeholder { color: var(--tx-faint); }
.input:focus, .select:focus, textarea.input:focus {
  outline: none; border-color: var(--c-violet); box-shadow: var(--glow-violet);
}
.input.mono { font-family: var(--font-mono); font-size: 13px; }
textarea.input { resize: vertical; min-height: 84px; line-height: 1.5; }
.select {
  appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--tx-faint) 50%), linear-gradient(135deg, var(--tx-faint) 50%, transparent 50%);
  background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.select option { background: var(--panel); }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-2); border: 1px solid var(--line);
  transition: border-color 0.26s var(--ease), transform 0.26s var(--ease), box-shadow 0.26s var(--ease);
}
.card:hover { border-color: var(--line-2); }

/* ---------- Logo tiles (projects) ---------- */
.logo-tile {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 700; color: #fff;
  overflow: hidden; flex: none; position: relative;
  border: 1px solid rgba(255,255,255,0.08);
}
.logo-tile img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed; left: 50%; bottom: calc(var(--bottomnav-h) + 18px); transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
}
@media (min-width: 921px) { .toast-wrap { bottom: 24px; } }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; background: var(--elev); border: 1px solid var(--line-3);
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.04em; color: var(--tx);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5); animation: toastIn 0.3s var(--ease);
}
.toast .tk { color: var(--ok); display: flex; }
.toast.err .tk { color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(3,3,7,0.82); backdrop-filter: blur(7px);
  display: flex; align-items: center; justify-content: center; padding: 22px;
  animation: fade 0.22s var(--ease);
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(540px, 100%); max-height: 90vh; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line-2);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%);
  animation: pop 0.28s var(--ease); overflow: hidden;
}
@keyframes pop { from { opacity: 0; transform: scale(0.96) translateY(8px); } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px 22px; border-bottom: 1px solid var(--line); flex: none;
}
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 600; }
.modal-body { padding: 22px; overflow-y: auto; }
.icon-x {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: transparent; color: var(--tx-dim); cursor: pointer; transition: all 0.2s;
}
.icon-x:hover { color: var(--tx); border-color: var(--danger); }
.icon-x svg { width: 16px; height: 16px; }

/* ============================================================
   SHELL — sidebar (desktop) + topbar + bottom nav (mobile)
   ============================================================ */
.shell { position: relative; z-index: 1; min-height: 100svh; }

/* sidebar */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column;
  background: var(--bg-1); border-right: 1px solid var(--line);
  padding: 22px 16px 16px;
}
.sb-brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 22px; }
.sb-brand img { height: 30px; }
.sb-brand .wm { font-weight: 600; letter-spacing: 0.26em; font-size: 16px; }
.sb-nav { display: flex; flex-direction: column; gap: 4px; }
.sb-item {
  display: flex; align-items: center; gap: 13px; padding: 12px 12px;
  font-family: var(--font-mono); font-size: 12.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--tx-dim); cursor: pointer; border: 1px solid transparent; position: relative;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease); text-align: left; background: none; width: 100%;
}
.sb-item svg { width: 19px; height: 19px; flex: none; }
.sb-item:hover { color: var(--tx); background: rgba(255,255,255,0.03); }
.sb-item.on { color: var(--tx); background: rgba(123,63,228,0.1); border-color: var(--line); }
.sb-item.on::before {
  content: ""; position: absolute; left: -1px; top: 8px; bottom: 8px; width: 3px; background: var(--accent-grad);
}
.sb-item .nt { margin-left: auto; font-size: 9px; padding: 2px 6px; border: 1px solid var(--line-2); color: var(--tx-faint); }
.sb-spacer { flex: 1; }
.sb-user {
  display: flex; align-items: center; gap: 11px; padding: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-2); transition: all 0.2s var(--ease);
}
.sb-user:hover { border-color: var(--line-2); }
.sb-user .av { width: 38px; height: 38px; flex: none; overflow: hidden; border: 1px solid var(--line-2); }
.sb-user .av img { width: 100%; height: 100%; object-fit: cover; }
.sb-user .nm { min-width: 0; }
.sb-user .nm b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user .nm span { font-family: var(--font-mono); font-size: 10px; color: var(--tx-faint); letter-spacing: 0.08em; }
.sb-logout {
  display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; padding: 9px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; white-space: nowrap;
  color: var(--tx-faint); background: none; border: 1px solid transparent; cursor: pointer; transition: all 0.2s; width: 100%;
}
.sb-logout:hover { color: var(--danger); border-color: rgba(255,77,109,0.3); }
.sb-logout svg { width: 15px; height: 15px; }

/* main content area */
.main { margin-left: var(--sidebar-w); min-height: 100svh; display: flex; flex-direction: column; }
.content { flex: 1; padding: 34px 38px 60px; max-width: 1180px; width: 100%; margin: 0 auto; }
.page-head { margin-bottom: 28px; }
.page-head h1 { margin: 6px 0 0; font-size: clamp(26px, 3.4vw, 38px); font-weight: 600; letter-spacing: 0.01em; }
.page-head .sub { color: var(--tx-dim); margin-top: 8px; font-size: 14px; line-height: 1.55; max-width: 60ch; }

/* mobile topbar + bottom nav (hidden on desktop) */
.topbar, .bottomnav { display: none; }

@media (max-width: 920px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .content { padding: calc(var(--topbar-h) + 20px) 18px calc(var(--bottomnav-h) + 28px); }
  .topbar {
    position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: 40;
    display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px;
    background: rgba(7,7,13,0.9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  }
  .topbar .tb-brand { display: flex; align-items: center; gap: 9px; }
  .topbar .tb-brand img { height: 26px; }
  .topbar .tb-brand .wm { font-weight: 600; letter-spacing: 0.24em; font-size: 14px; }
  .topbar .tb-av { width: 36px; height: 36px; overflow: hidden; border: 1px solid var(--line-2); cursor: pointer; }
  .topbar .tb-av img { width: 100%; height: 100%; object-fit: cover; }
  .bottomnav {
    position: fixed; left: 0; right: 0; bottom: 0; height: var(--bottomnav-h); z-index: 40;
    display: flex; align-items: stretch; background: rgba(8,8,15,0.94); backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
  }
  .bn-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    background: none; border: none; cursor: pointer; color: var(--tx-faint); position: relative;
    font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase;
    transition: color 0.2s;
  }
  .bn-item svg { width: 21px; height: 21px; }
  .bn-item.on { color: var(--tx); }
  .bn-item.on::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 2px; background: var(--accent-grad-h); }
  .bn-item .av { width: 23px; height: 23px; overflow: hidden; border: 1px solid currentColor; }
  .bn-item .av img { width: 100%; height: 100%; object-fit: cover; }
}

/* reveal */
.rv { opacity: 0; transform: translateY(16px); animation: rvIn 0.5s var(--ease) forwards; }
@keyframes rvIn { to { opacity: 1; transform: none; } }
