/* ════════════════════════════════════════════════════════════
   CraftCord AI — Design System (main.css)
   Theme: 80% black · 20% purple (#916ff7)
   ════════════════════════════════════════════════════════════ */

:root {
  /* Purple scale */
  --purple: #916ff7;
  --purple-bright: #a98bff;
  --purple-deep: #6d4fd6;
  --purple-soft: rgba(145, 111, 247, 0.14);
  --purple-glow: rgba(145, 111, 247, 0.45);

  /* Black / neutral scale */
  --black: #050507;
  --bg: #0a0a0f;
  --bg-2: #0e0e15;
  --surface: #121219;
  --surface-2: #16161f;
  --surface-3: #1c1c27;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);

  --text: #f4f4f7;
  --text-dim: #a9a9b8;
  --text-faint: #6c6c7e;

  --green: #36d399;
  --red: #f76f8e;
  --amber: #f7c96f;

  --radius: 14px;
  --radius-lg: 22px;
  --radius-xl: 30px;

  --shadow-soft: 0 10px 40px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 60px rgba(145, 111, 247, 0.25);

  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Space Grotesk', var(--font);
  --font-mono: 'JetBrains Mono', monospace;

  --maxw: 1200px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
img { max-width: 100%; display: block; }
ul { list-style: none; }
svg { width: 1em; height: 1em; }
::selection { background: var(--purple); color: #fff; }

.accent { color: var(--purple); }

/* ── Custom scrollbar ── */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: linear-gradient(var(--purple-deep), var(--purple));
  border-radius: 99px;
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--purple-bright); }
* { scrollbar-color: var(--purple) var(--bg); scrollbar-width: thin; }

/* ── Layout helpers ── */
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 1.5rem; }
.container--narrow { max-width: 820px; }

/* ════════ Animated background ════════ */
.bg-fx { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-fx__grid {
  position: absolute; inset: -50%;
  background-image:
    linear-gradient(rgba(145,111,247,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(145,111,247,0.05) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
  animation: grid-drift 30s linear infinite;
}
@keyframes grid-drift { to { transform: translateY(60px); } }

.bg-fx__orb {
  position: absolute; border-radius: 50%;
  filter: blur(90px); opacity: 0.5;
  animation: orb-float 18s ease-in-out infinite;
}
.bg-fx__orb--1 { width: 480px; height: 480px; background: radial-gradient(circle, var(--purple-glow), transparent 70%); top: -120px; left: -80px; }
.bg-fx__orb--2 { width: 560px; height: 560px; background: radial-gradient(circle, rgba(109,79,214,0.4), transparent 70%); top: 30%; right: -160px; animation-delay: -6s; }
.bg-fx__orb--3 { width: 400px; height: 400px; background: radial-gradient(circle, rgba(169,139,255,0.3), transparent 70%); bottom: -120px; left: 30%; animation-delay: -12s; }
@keyframes orb-float {
  0%,100% { transform: translate(0,0) scale(1); }
  50% { transform: translate(40px,-30px) scale(1.1); }
}
.bg-fx__particles { position: absolute; inset: 0; width: 100%; height: 100%; }
.bg-fx--app .bg-fx__grid { opacity: 0.5; }

/* ════════ Buttons ════════ */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.7rem 1.3rem;
  border-radius: 12px;
  font-weight: 600; font-size: 0.95rem;
  white-space: nowrap;
  transition: transform 0.25s var(--ease), box-shadow 0.3s var(--ease), background 0.25s, border-color 0.25s;
  overflow: hidden;
}
.btn svg { width: 1.15em; height: 1.15em; }
.btn:active { transform: scale(0.97); }
.btn--sm { padding: 0.5rem 0.95rem; font-size: 0.85rem; border-radius: 10px; }
.btn--lg { padding: 0.95rem 1.7rem; font-size: 1.02rem; border-radius: 14px; }
.btn--block { width: 100%; }

.btn--primary {
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  color: #fff;
  box-shadow: 0 8px 26px rgba(145,111,247,0.35);
}
.btn--primary:hover { transform: translateY(-2px); box-shadow: 0 12px 36px rgba(145,111,247,0.5); }
.btn__glow {
  position: absolute; top: 0; left: -120%; width: 60%; height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255,255,255,0.4), transparent);
  transform: skewX(-20deg); transition: left 0.6s var(--ease);
}
.btn--primary:hover .btn__glow { left: 160%; }

.btn--ghost {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-strong);
  color: var(--text);
  backdrop-filter: blur(8px);
}
.btn--ghost:hover { background: rgba(255,255,255,0.08); border-color: var(--purple); transform: translateY(-2px); }

/* ── Interactive particles (section-scoped, see js/interactive-particles.js) ──
   isolation creates a stacking context so the canvas (z-index -1) paints above
   the section's own background but below every piece of its content. */
.interactive-particles { position: relative; isolation: isolate; }
.ip-canvas {
  position: absolute; inset: 0; z-index: -1;
  width: 100%; height: 100%;
  display: block;
  pointer-events: none;
}

.btn--discord { background: #5865f2; color: #fff; box-shadow: 0 8px 26px rgba(88,101,242,0.4); }
.btn--discord:hover { background: #4752e0; transform: translateY(-2px); }

.btn--danger-ghost { background: rgba(247,111,142,0.08); border: 1px solid rgba(247,111,142,0.3); color: var(--red); }
.btn--danger-ghost:hover { background: rgba(247,111,142,0.16); }

.btn:disabled, .btn.is-loading { opacity: 0.65; pointer-events: none; }
.btn.is-loading::after {
  content: ''; width: 16px; height: 16px; margin-left: 0.4rem;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════ Inputs ════════ */
.input {
  width: 100%;
  padding: 0.8rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.input::placeholder { color: var(--text-faint); }
.input:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-soft); background: var(--surface-3); }

/* ════════ Badges / chips ════════ */
.badge {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.35rem 0.75rem; border-radius: 99px;
  font-size: 0.78rem; font-weight: 600;
  background: var(--surface-3); border: 1px solid var(--border); color: var(--text-dim);
}
.badge svg { width: 0.95em; height: 0.95em; }
.badge--live { color: var(--green); border-color: rgba(54,211,153,0.3); background: rgba(54,211,153,0.1); }
.badge--error { color: var(--red); border-color: rgba(247,111,142,0.3); background: rgba(247,111,142,0.1); }
.badge--idle { color: var(--text-dim); }
.badge--upgrade { color: var(--purple-bright); border-color: rgba(145,111,247,0.4); background: var(--purple-soft); }

.chip { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.6rem; border-radius: 99px; font-size: 0.72rem; font-weight: 600; background: var(--surface-3); color: var(--text-dim); text-transform: capitalize; }
.chip--live { background: rgba(54,211,153,0.14); color: var(--green); }
.chip--trial { background: rgba(145,111,247,0.16); color: var(--purple-bright); }

.dot-live { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 currentColor; animation: pulse-dot 1.8s infinite; }
@keyframes pulse-dot { 0% { box-shadow: 0 0 0 0 rgba(54,211,153,0.5); } 70% { box-shadow: 0 0 0 6px rgba(54,211,153,0); } 100% { box-shadow: 0 0 0 0 rgba(54,211,153,0); } }

/* ════════ Modals ════════ */
.modal-root {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  opacity: 0; visibility: hidden;
  transition: opacity 0.35s var(--ease), visibility 0.35s;
}
.modal-root.is-open { opacity: 1; visibility: visible; }
.modal-overlay { position: absolute; inset: 0; background: rgba(3,3,6,0.7); backdrop-filter: blur(10px); }

.modal {
  position: relative;
  width: 100%; max-width: 460px;
  /* Never exceed the viewport — the inner content scrolls so every field and
     button stays reachable, especially on short/mobile screens. */
  max-height: calc(100dvh - 3rem);
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft), var(--shadow-glow);
  transform: translateY(24px) scale(0.96);
  opacity: 0;
  transition: transform 0.45s var(--ease), opacity 0.4s var(--ease);
  overflow: hidden;
}
.modal--wide { max-width: 880px; }
/* The modal frame stays fixed (so the close button stays pinned); its content
   scrolls when it's taller than the viewport. */
.modal__body, .modal > .cbot, .modal > .sub {
  max-height: calc(100dvh - 3rem);
  overflow-y: auto;
  /* Explicitly clip the horizontal axis. Setting only overflow-y makes the
     browser compute overflow-x to `auto`, which produces a spurious horizontal
     scrollbar on mobile whenever any child is even slightly too wide. */
  overflow-x: hidden;
}
/* Grid columns must be allowed to shrink below their content width, otherwise a
   long token/URL forces the modal wider than the viewport (horizontal scroll). */
.modal > .cbot, .modal > .sub { max-width: 100%; }
.cbot__left, .cbot__right, .sub__left, .sub__right { min-width: 0; }
.cbot__requirements a, .cbot__token .input { overflow-wrap: anywhere; }
.modal__body::-webkit-scrollbar, .modal > .cbot::-webkit-scrollbar, .modal > .sub::-webkit-scrollbar { width: 7px; }
.modal__body::-webkit-scrollbar-thumb, .modal > .cbot::-webkit-scrollbar-thumb, .modal > .sub::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; }
.modal-root.is-open .modal { transform: translateY(0) scale(1); opacity: 1; }
.modal__glow { position: absolute; top: -50%; left: 50%; transform: translateX(-50%); width: 80%; height: 200px; background: radial-gradient(ellipse, var(--purple-glow), transparent 70%); filter: blur(50px); pointer-events: none; }
.modal__close {
  position: absolute; top: 1rem; right: 1rem; z-index: 3;
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border); color: var(--text-dim);
  transition: all 0.2s;
}
.modal__close:hover { background: rgba(255,255,255,0.1); color: var(--text); transform: rotate(90deg); }
.modal__body { position: relative; padding: 2.5rem 2rem 2rem; }
.modal__body--center { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.9rem; }
.modal__badge {
  width: 60px; height: 60px; border-radius: 18px;
  display: grid; place-items: center; font-size: 1.6rem;
  background: var(--purple-soft); border: 1px solid rgba(145,111,247,0.3); color: var(--purple-bright);
  box-shadow: var(--shadow-glow);
}
.modal__title { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; line-height: 1.2; }
.modal__desc { color: var(--text-dim); font-size: 0.98rem; max-width: 38ch; }
.modal__fineprint { display: flex; align-items: center; gap: 0.4rem; font-size: 0.82rem; color: var(--text-faint); margin-top: 0.4rem; }
.modal__fineprint svg { width: 0.95em; height: 0.95em; }
@media (max-width: 560px) {
  .modal-root { padding: 0.75rem; align-items: flex-start; overflow-y: auto; }
  .modal__body { padding: 2.25rem 1.4rem 1.6rem; }
}

/* ════════ Toast ════════ */
.toast-stack {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 2000;
  display: flex; flex-direction: column; gap: 0.7rem;
  width: min(380px, calc(100vw - 3rem));
}
.toast {
  display: flex; align-items: flex-start; gap: 0.85rem;
  padding: 0.95rem 1.05rem; padding-right: 2.7rem;
  background: linear-gradient(160deg, rgba(30,26,46,0.88), rgba(13,12,20,0.92) 60%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: 0 18px 44px rgba(0,0,0,0.45);
  position: relative; overflow: hidden;
  transform: translateX(120%) scale(0.96); opacity: 0;
  transition: transform 0.5s var(--ease), opacity 0.4s;
}
.toast.is-visible { transform: translateX(0) scale(1); opacity: 1; }
/* Colored accent bar + soft tint wash from the accent side */
.toast::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--purple-bright), var(--purple));
}
.toast::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(130% 150% at 0% 50%, rgba(145,111,247,0.13), transparent 55%);
}
.toast--success::before { background: linear-gradient(180deg, #7ce8c0, var(--green)); }
.toast--success::after { background: radial-gradient(130% 150% at 0% 50%, rgba(54,211,153,0.11), transparent 55%); }
.toast--error::before { background: linear-gradient(180deg, #ffa4b8, var(--red)); }
.toast--error::after { background: radial-gradient(130% 150% at 0% 50%, rgba(247,111,142,0.11), transparent 55%); }
.toast__icon {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; position: relative; z-index: 1;
  background: rgba(145,111,247,0.14); color: var(--purple-bright);
  box-shadow: inset 0 0 0 1px rgba(145,111,247,0.28), 0 0 14px rgba(145,111,247,0.15);
}
.toast__icon svg { width: 16px; height: 16px; }
.toast--success .toast__icon {
  background: rgba(54,211,153,0.12); color: var(--green);
  box-shadow: inset 0 0 0 1px rgba(54,211,153,0.28), 0 0 14px rgba(54,211,153,0.12);
}
.toast--error .toast__icon {
  background: rgba(247,111,142,0.12); color: var(--red);
  box-shadow: inset 0 0 0 1px rgba(247,111,142,0.28), 0 0 14px rgba(247,111,142,0.12);
}
.toast__content { position: relative; z-index: 1; min-width: 0; padding-top: 0.1rem; }
.toast__content strong { display: block; font-size: 0.92rem; margin-bottom: 0.1rem; }
.toast__content span { font-size: 0.84rem; color: var(--text-dim); line-height: 1.45; }
.toast__close {
  position: absolute; top: 0.55rem; right: 0.55rem; z-index: 1;
  width: 24px; height: 24px; border-radius: 8px;
  display: grid; place-items: center; color: var(--text-faint);
  transition: background 0.2s, color 0.2s;
}
.toast__close svg { width: 13px; height: 13px; }
.toast__close:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.toast__bar {
  position: absolute; bottom: 0; left: 0; height: 2px; border-radius: 99px;
  background: linear-gradient(90deg, var(--purple-bright), var(--purple));
  box-shadow: 0 0 8px rgba(145,111,247,0.55);
  animation: toast-bar 4s linear forwards;
}
.toast--success .toast__bar { background: var(--green); box-shadow: 0 0 8px rgba(54,211,153,0.5); }
.toast--error .toast__bar { background: var(--red); box-shadow: 0 0 8px rgba(247,111,142,0.5); }
/* Hovering pauses the countdown (timer is paused in JS too) */
.toast.is-paused .toast__bar { animation-play-state: paused; }
/* Exit: fade + slide while the row collapses so the stack closes up smoothly */
.toast.is-hiding {
  opacity: 0;
  transform: translateX(35%) scale(0.94);
  padding-top: 0; padding-bottom: 0;
  margin-top: -0.7rem; /* cancels the stack gap */
  pointer-events: none;
  transition: transform 0.4s var(--ease), opacity 0.3s,
    height 0.4s var(--ease), margin 0.4s var(--ease), padding 0.4s var(--ease);
}
@keyframes toast-bar { to { width: 0; } }

/* ════════ Skeleton ════════ */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ════════ Context menu ════════ */
.ctx-menu {
  position: fixed; z-index: 1500; min-width: 180px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 12px; box-shadow: var(--shadow-soft); padding: 0.4rem;
  opacity: 0; transform: scale(0.95); transform-origin: top left; pointer-events: none;
  transition: opacity 0.15s, transform 0.15s var(--ease);
}
.ctx-menu.is-open { opacity: 1; transform: scale(1); pointer-events: auto; }
.ctx-menu__item { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.7rem; border-radius: 8px; font-size: 0.88rem; color: var(--text-dim); transition: background 0.15s, color 0.15s; width: 100%; }
.ctx-menu__item:hover { background: var(--purple-soft); color: var(--text); }
.ctx-menu__item--danger:hover { background: rgba(247,111,142,0.12); color: var(--red); }
.ctx-menu__sep { height: 1px; background: var(--border); margin: 0.3rem 0; }

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ── AOS no-flash fallback ── */
[data-aos] { will-change: transform, opacity; }

/* ════════ Footer language selector ════════ */
.lang-select { position: relative; display: inline-block; }
.lang-select__btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.75rem; border-radius: 11px; cursor: pointer;
  background: var(--surface, rgba(255,255,255,0.04));
  border: 1px solid var(--border, rgba(255,255,255,0.09));
  color: var(--text-dim, #b9b9c9); font-size: 0.86rem; font-weight: 600;
  font-family: inherit;
  transition: border-color 0.2s, color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.lang-select__btn:hover { color: var(--text, #fff); border-color: var(--purple, #6d4fd6); transform: translateY(-1px); }
.lang-select.is-open .lang-select__btn { color: var(--text, #fff); border-color: var(--purple, #6d4fd6); box-shadow: 0 0 0 3px var(--purple-soft, rgba(109,79,214,0.18)); }
.lang-select.is-busy { opacity: 0.6; pointer-events: none; }
.lang-select__flag { width: 24px; height: 18px; border-radius: 3px; object-fit: cover; box-shadow: 0 0 0 1px rgba(255,255,255,0.12); flex-shrink: 0; }
.lang-select__chev { width: 1em; height: 1em; transition: transform 0.25s ease; }
.lang-select.is-open .lang-select__chev { transform: rotate(180deg); }

/* Drop-UP menu (the selector lives in the footer) */
.lang-select__menu {
  position: absolute; bottom: calc(100% + 0.55rem); z-index: 90;
  inset-inline-end: 0;
  min-width: 218px; margin: 0; padding: 0.4rem; list-style: none;
  background: var(--surface-2, #14141d);
  border: 1px solid var(--border-strong, rgba(255,255,255,0.14));
  border-radius: 14px; box-shadow: 0 18px 44px rgba(0,0,0,0.5);
  opacity: 0; transform: translateY(8px) scale(0.97); transform-origin: bottom;
  pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease;
}
.lang-select.is-open .lang-select__menu { opacity: 1; transform: none; pointer-events: auto; }
.lang-select__title {
  padding: 0.35rem 0.6rem 0.5rem; font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-faint, #7a7a8c);
}
.lang-select__opt {
  display: flex; align-items: center; gap: 0.65rem; width: 100%;
  padding: 0.55rem 0.6rem; border-radius: 10px; cursor: pointer;
  background: transparent; border: 1px solid transparent;
  color: var(--text, #fff); font-family: inherit; text-align: start;
  transition: background 0.15s, border-color 0.15s;
}
.lang-select__opt:hover { background: rgba(255,255,255,0.05); }
.lang-select__opt.is-active { background: var(--purple-soft, rgba(109,79,214,0.18)); border-color: rgba(145,111,247,0.3); }
.lang-select__opt-name { display: flex; flex-direction: column; gap: 0.05rem; min-width: 0; flex: 1; }
.lang-select__opt-name strong { font-size: 0.88rem; font-weight: 600; }
.lang-select__opt-name small { font-size: 0.72rem; color: var(--text-faint, #7a7a8c); }
.lang-select__check { width: 1.05em; height: 1.05em; color: var(--green, #4ade80); flex-shrink: 0; }

/* Small screens: keep the sheet inside the viewport */
@media (max-width: 560px) {
  .lang-select__menu { position: fixed; inset-inline: 0.75rem; bottom: 0.75rem; min-width: 0; }
}
