/* ==========================================================================
   NOVA ARCADE — shared styles
   Design tokens: night sky — solid violet-black panels, violet only for selection.
   Font: Onest (self-hosted, assets/fonts)
   ========================================================================== */
@font-face { font-family: 'Onest'; src: url('fonts/Onest.ttf') format('truetype'); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #000000;
  --bg-2: #0e0b16;
  --card: rgba(20, 16, 30, 0.86);
  --card-solid: #14101e;
  --muted: #221c30;
  --fg: #ece8f6;
  --fg-dim: #a79fbd;
  --fg-faint: #776f8c;
  --primary: #6c4cf0;
  --primary-2: #b6a4ff;
  --primary-glow: rgba(0, 0, 0, 0);
  --accent: #9d84ff;
  --accent-2: #c9bbff;
  --success: #9d84ff;
  --warn: #c9bbff;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 12px;
  --shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 0 1px var(--border), 0 20px 50px -24px rgba(0,0,0,.8);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --font-display: 'Onest', system-ui, sans-serif;
  --font-ui: 'Onest', system-ui, sans-serif;
  --font-mono: 'Onest', system-ui, sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  color: var(--fg);
  background: var(--bg);
  overflow-x: hidden;
}
img, svg, canvas { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--primary-2); text-decoration: none; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; margin: 0; line-height: 1.15; text-wrap: balance; }
p { margin: 0; }
::selection { background: var(--primary); color: #fff; }
:focus-visible { outline: 2px solid var(--primary-2); outline-offset: 3px; border-radius: 6px; }

.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }

/* ---------- Background layer ---------- */
#bg-canvas, .bg-image {
  position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: -2; pointer-events: none;
}
.bg-image { background-size: cover; background-position: center; z-index: -3; }
.bg-video { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: -2; pointer-events: none; object-fit: cover; background: #000; }
.bg-gl { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: -2; pointer-events: none; background: #000; display: none; }
.bg-vignette {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 0%, transparent 40%, rgba(5,5,15,.55) 100%),
    linear-gradient(180deg, rgba(11,11,29,0) 60%, rgba(11,11,29,.7) 100%);
}
:root[data-crt='on'] body::after {
  content: ''; position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}

/* ---------- Layout ---------- */
.container { width: min(1200px, 100% - 32px); margin-inline: auto; }
.section { padding: 88px 0; }
.section-head { display:flex; align-items:flex-end; justify-content:space-between; gap:16px; margin-bottom: 32px; flex-wrap: wrap; }
.eyebrow { font-size: 14px; font-weight: 500; color: var(--fg-dim); }
.section-title { font-size: clamp(28px, 4vw, 42px); margin-top: 6px; }
.section-sub { color: var(--fg-dim); max-width: 56ch; margin-top: 10px; }

/* ---------- Glass card ---------- */
.glass {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: var(--shadow);
}

/* ---------- Buttons ---------- */
.btn {
  --b-bg: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--b-bg);
  font-weight: 600; font-size: 15px; letter-spacing: .02em;
  cursor: pointer; white-space: nowrap;
  transition: transform .18s var(--ease-out), box-shadow .25s var(--ease-out), background .2s, border-color .2s, opacity .2s;
  position: relative; overflow: hidden; user-select: none;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.btn:active { transform: translateY(0) scale(.97); }
.btn[disabled], .btn.is-disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary {
  --b-bg: var(--primary);
  border-color: transparent; color: #fff;
  box-shadow: none;
}
.btn-primary:hover { box-shadow: 0 14px 40px -10px var(--primary-glow), inset 0 1px 0 rgba(255,255,255,.3); }
.btn-accent {
  --b-bg: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #fff;
  box-shadow: 0 8px 28px -8px rgba(244,63,94,.5);
}
.btn-ghost { --b-bg: transparent; }
.btn-ghost:hover { --b-bg: rgba(255,255,255,.05); }
.btn-lg { min-height: 50px; padding: 0 24px; font-size: 16px; border-radius: 10px; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn-block { width: 100%; }

.icon-btn {
  width: 44px; height: 44px; display: inline-grid; place-items: center;
  border-radius: 8px; border: 1px solid var(--border); background: rgba(255,255,255,.04);
  cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: rgba(255,255,255,.09); border-color: var(--border-strong); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.is-off { color: var(--fg-faint); }

/* ---------- Badges / chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500; white-space: nowrap;
  background: rgba(157,132,255,.14); color: var(--primary-2); border: 1px solid var(--border);
}
.badge svg { width: 13px; height: 13px; }
.badge-pro { background: rgba(139,92,246,.18); color: #d8b4fe; border-color: rgba(167,139,250,.45); }
.badge-free { background: rgba(52,211,153,.12); color: var(--success); border-color: rgba(52,211,153,.3); }
.chip {
  min-height: 38px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--border); background: rgba(255,255,255,.03);
  cursor: pointer; font-weight: 600; font-size: 14px; color: var(--fg-dim);
  transition: all .2s var(--ease-out);
}
.chip:hover { color: var(--fg); border-color: var(--border-strong); }
.chip[aria-pressed='true'] { background: var(--primary); border-color: transparent; color: #fff; box-shadow: 0 6px 20px -6px var(--primary-glow); }

/* ---------- Forms ---------- */
[hidden] { display: none !important; }
.field { display: grid; gap: 6px; }
.field label { font-size: 14px; font-weight: 600; color: var(--fg-dim); }
.input, .select {
  min-height: 48px; padding: 0 14px; width: 100%;
  border-radius: 12px; border: 1px solid var(--border); background: rgba(0,0,0,.25);
  transition: border-color .2s, box-shadow .2s;
}
.input:focus, .select:focus { outline: none; border-color: var(--primary-2); box-shadow: 0 0 0 4px var(--primary-glow); }
.input[aria-invalid='true'] { border-color: var(--accent); }
.field-error { color: var(--accent-2); font-size: 13px; min-height: 18px; }
.field-hint { color: var(--fg-faint); font-size: 13px; }

/* Toggle switch */
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; inset: 0; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--muted); border: 1px solid var(--border); transition: background .25s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .3s var(--ease-spring); box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--primary-2); outline-offset: 2px; }

/* Range */
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 99px; background: var(--muted); outline: none; cursor: pointer; }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--primary-2); border: 3px solid #fff; box-shadow: 0 0 12px var(--primary-glow); }
.range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--primary-2); border: 3px solid #fff; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center; padding: 16px;
  background: rgba(5, 5, 15, .6); backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .25s var(--ease-out);
}
.modal-backdrop.is-open { opacity: 1; }
.modal {
  width: min(480px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: linear-gradient(180deg, rgba(36,33,66,.96), rgba(22,20,44,.97));
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.8), 0 0 60px -30px var(--primary-glow);
  padding: 28px; position: relative;
  transform: translateY(16px) scale(.97); transition: transform .35s var(--ease-spring);
}
.modal-wide { width: min(640px, 100%); }
.modal-backdrop.is-open .modal { transform: none; }
.modal-close { position: absolute; top: 14px; right: 14px; }
.modal h2 { font-size: 26px; margin-bottom: 6px; }
.modal .modal-sub { color: var(--fg-dim); margin-bottom: 22px; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(0,0,0,.3); margin-bottom: 22px; }
.tab { min-height: 42px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; font-weight: 600; color: var(--fg-dim); transition: all .2s; }
.tab[aria-selected='true'] { background: var(--muted); color: var(--fg); box-shadow: 0 2px 10px rgba(0,0,0,.3); }

/* Settings panel */
.settings-group { padding: 18px 0; border-top: 1px solid var(--border); }
.settings-group:first-of-type { border-top: 0; padding-top: 0; }
.settings-group h3 { font-family: var(--font-ui); font-weight: 600; font-size: 15px; color: var(--fg); margin-bottom: 12px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; }
.setting-row + .setting-row { margin-top: 8px; }
.setting-row .label { font-weight: 600; }
.setting-row .desc { font-size: 13px; color: var(--fg-faint); }
.setting-row .range { max-width: 200px; }

.bg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.bg-tile {
  position: relative; aspect-ratio: 16/10; border-radius: 12px; overflow: hidden; cursor: pointer;
  border: 2px solid transparent; background: var(--muted); padding: 0;
  transition: transform .2s var(--ease-out), border-color .2s;
}
.bg-tile canvas, .bg-tile .bg-tile-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background-size: cover; background-position: center; }
.bg-tile:hover { transform: translateY(-2px); }
.bg-tile[aria-pressed='true'] { border-color: var(--primary-2); box-shadow: 0 0 0 3px var(--primary-glow); }
.bg-tile .bg-tile-name {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 8px 6px;
  font-size: 12px; font-weight: 700; text-align: left;
  background: linear-gradient(transparent, rgba(0,0,0,.75));
}
.bg-tile .lock { position: absolute; top: 6px; right: 6px; }
.bg-tile.is-locked { cursor: not-allowed; }
.bg-tile.is-locked canvas, .bg-tile.is-locked .bg-tile-img { filter: grayscale(.6) brightness(.6); }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; transition: transform .2s var(--ease-spring); }
.swatch:hover { transform: scale(1.1); }
.swatch[aria-pressed='true'] { border-color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.15); }

/* ---------- Toasts ---------- */
.toast-wrap { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 2000; display: grid; gap: 8px; pointer-events: none; width: min(420px, calc(100% - 32px)); }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-radius: 14px; background: rgba(30,28,53,.95); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow); font-weight: 600; pointer-events: auto;
  animation: toast-in .4s var(--ease-spring);
}
.toast svg { width: 20px; height: 20px; color: var(--primary-2); flex: none; }
.toast.is-leaving { animation: toast-out .25s var(--ease-out) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.95); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.97); } }

/* ---------- Avatar ---------- */
.avatar {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  font-family: var(--font-display); font-size: 16px; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 4px 14px -4px var(--primary-glow);
}

/* ---------- Dropdown ---------- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 10px); min-width: 230px; padding: 8px;
  border-radius: 16px; background: rgba(30,28,53,.97); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow); z-index: 50;
  opacity: 0; transform: translateY(-6px) scale(.98); transform-origin: top right; pointer-events: none;
  transition: opacity .2s, transform .25s var(--ease-out);
}
.dropdown.is-open .dropdown-menu { opacity: 1; transform: none; pointer-events: auto; }
.dropdown-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; text-align: left; font-weight: 500; }
.dropdown-item:hover { background: rgba(255,255,255,.06); }
.dropdown-item svg { width: 18px; height: 18px; color: var(--fg-dim); }
.dropdown-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }

/* ---------- Reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s var(--ease-out), transform .7s var(--ease-out); }
.reveal.is-in { opacity: 1; transform: none; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
}
:root[data-reduced-motion='on'] *, :root[data-reduced-motion='on'] *::before, :root[data-reduced-motion='on'] *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
:root[data-reduced-motion='on'] .reveal { opacity: 1; transform: none; }
