/* HTML hidden attribute always wins, even over class display rules */
[hidden] { display: none !important; }

/* ============================================================
   akciali.memory — sci-fi immersive HUD
   Glassmorphism + neon gradients + scanlines + glowing edges
   ============================================================ */

:root {
  /* Palette — dark cinematic + neon */
  --bg-deep: #000003;        /* dev37: darker base */
  --bg-mid: #010210;         /* dev37: darker mid  */
  --ink: #d8e1f0;
  --ink-dim: #7a8aa5;
  --accent-cyan: #00e5ff;
  --accent-pink: #ff3da0;
  --accent-violet: #a259ff;
  --accent-green: #39ff14;
  --accent-amber: #ffb547;
  --glass-bg: rgba(8, 14, 28, 0.55);
  --glass-border: rgba(120, 180, 255, 0.18);
  --glass-glow: rgba(0, 229, 255, 0.06);

  --radius: 14px;
  --radius-sm: 8px;
  --shadow-glow: 0 0 18px rgba(0, 229, 255, 0.12), 0 0 60px rgba(162, 89, 255, 0.08);

  --font-mono: "JetBrains Mono", "Fira Code", "SF Mono", ui-monospace, Menlo, monospace;
  --font-ui: "Inter", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  background: var(--bg-deep);
  color: var(--ink);
  font-family: var(--font-ui);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

canvas#scene {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  position: fixed; inset: 0;
  display: block;
  z-index: 1;
}

/* ============== Animated background layers ============== */

.veil {
  pointer-events: none !important;
  position: fixed; inset: 0;
  z-index: 2;
  background:
    radial-gradient(ellipse at 20% 100%, rgba(162, 89, 255, 0.07), transparent 50%),
    radial-gradient(ellipse at 80% 0%, rgba(0, 229, 255, 0.05), transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(255, 61, 160, 0.02), transparent 70%);
  mix-blend-mode: screen;
  animation: veil-drift 22s ease-in-out infinite alternate;
}
@keyframes veil-drift {
  from { transform: translate3d(-2%, -1%, 0); }
  to   { transform: translate3d( 2%,  1%, 0); }
}

.scanline {
  pointer-events: none;
  position: fixed; inset: 0;
  z-index: 3;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.012) 0px,
    rgba(255, 255, 255, 0.012) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
  opacity: 0.35;
}

/* ============== Glass primitives ============== */

.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    0 8px 32px rgba(0,0,0,0.45),
    var(--shadow-glow);
  position: relative;
  overflow: hidden;
}
.glass::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(135deg, var(--glass-glow), transparent 40%);
}

.ghost-btn {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  background: rgba(8, 16, 30, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.18s ease;
  backdrop-filter: blur(8px);
}
.ghost-btn:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.25);
}
.ghost-btn:active { transform: translateY(1px); }

/* ============== HUD top ============== */

.hud-top {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 20;
  padding: 18px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: linear-gradient(to bottom, rgba(3, 6, 13, 0.7), transparent);
  pointer-events: none;
}
.hud-top > * { pointer-events: auto; }

.brand {
  display: flex; align-items: center; gap: 14px;
}
.brand-glyph {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--accent-cyan), var(--accent-violet) 70%, transparent 100%);
  box-shadow: 0 0 22px rgba(0,229,255,0.55), 0 0 40px rgba(162,89,255,0.4);
  animation: brand-pulse 3.6s ease-in-out infinite;
}
@keyframes brand-pulse {
  0%,100% { transform: scale(1); filter: hue-rotate(0deg); }
  50%     { transform: scale(1.08); filter: hue-rotate(20deg); }
}
.brand-text h1 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 18px;
  letter-spacing: 0.18em;
  font-weight: 500;
  text-transform: lowercase;
  background: linear-gradient(90deg, var(--accent-cyan), #ffffff 50%, var(--accent-pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-text p {
  margin: 2px 0 0 0;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.dim { opacity: 0.5; }

.hud-stats {
  display: flex; gap: 22px;
  font-family: var(--font-mono);
}
.stat {
  display: flex; flex-direction: column; align-items: flex-end;
  font-size: 10px;
}
.stat .k {
  text-transform: uppercase; letter-spacing: 0.2em;
  color: var(--ink-dim);
}
.stat .v {
  font-size: 16px;
  color: var(--ink);
  margin-top: 2px;
}

.hud-actions { display: flex; gap: 10px; }

/* ============== Side panels ============== */

.hud-side {
  position: fixed; top: 110px; bottom: 110px;
  width: 280px;
  z-index: 15;
  padding: 22px 22px 18px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-violet) transparent;
}
.hud-side::-webkit-scrollbar { width: 6px; }
.hud-side::-webkit-scrollbar-thumb { background: var(--accent-violet); border-radius: 3px; }
.hud-side-left  { left: 26px; }
.hud-side-right { right: 26px; width: 360px; }

.hud-side h2, .hud-side h3 {
  margin: 0 0 14px 0;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-cyan);
  font-weight: 500;
}
.hud-side h3 {
  font-size: 14px;
  color: var(--ink);
  letter-spacing: 0.05em;
  text-transform: none;
}

.collection-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.collection-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  transition: background 0.15s;
  border: 1px solid transparent;
}
.collection-list li:hover { background: rgba(255,255,255,0.04); border-color: var(--glass-border); }
.collection-list li.disabled { opacity: 0.35; }
.collection-list li .swatch {
  width: 10px; height: 10px; border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
}
.collection-list li .name { flex: 1; }
.collection-list li .count {
  font-size: 10px;
  color: var(--ink-dim);
}

.legend {
  margin-top: 22px;
  border-top: 1px dashed var(--glass-border);
  padding-top: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-dim);
  display: flex; flex-direction: column; gap: 8px;
}
.legend .dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
  margin-right: 8px;
  vertical-align: middle;
}
.legend .dot.pulse { background: var(--accent-pink); box-shadow: 0 0 12px var(--accent-pink); animation: pulse 1.4s ease-in-out infinite; }
.legend .line {
  display: inline-block; width: 24px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-violet), transparent);
  margin-right: 8px; vertical-align: middle;
}
@keyframes pulse {
  0%,100% { transform: scale(1); opacity: 1; }
  50%     { transform: scale(1.3); opacity: 0.6; }
}

/* ============== Inspector (right) ============== */

.close-btn {
  position: absolute; top: 12px; right: 14px;
  background: none; border: none;
  color: var(--ink-dim);
  font-size: 16px; cursor: pointer;
  transition: color 0.15s;
}
.close-btn:hover { color: var(--accent-pink); }

.inspector-header {
  display: flex; gap: 10px; margin-bottom: 8px;
  font-family: var(--font-mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.16em;
}
.inspector-coll {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0,229,255,0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(0,229,255,0.3);
}
.inspector-type { color: var(--ink-dim); padding: 3px 0; }

.inspector-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 10px 0 14px 0;
}
.inspector-tags span {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 8px;
  background: rgba(162, 89, 255, 0.12);
  color: var(--accent-violet);
  border: 1px solid rgba(162, 89, 255, 0.3);
  border-radius: 999px;
}
.inspector-preview {
  font-size: 13px; line-height: 1.55;
  color: var(--ink);
  padding: 14px;
  background: rgba(0, 0, 0, 0.28);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--accent-cyan);
  margin: 0 0 16px 0;
  max-height: 280px; overflow-y: auto;
}
.inspector-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  display: flex; flex-direction: column; gap: 6px;
  color: var(--ink-dim);
  margin-bottom: 16px;
}
.inspector-meta .k { color: var(--ink-dim); margin-right: 8px; text-transform: uppercase; letter-spacing: 0.14em; font-size: 9px; }
.inspector-meta code { color: var(--accent-amber); }
.inspector-actions { display: flex; gap: 8px; }

/* ============== Bottom search bar ============== */

.hud-bottom {
  position: fixed;
  bottom: 26px; left: 50%; transform: translateX(-50%);
  z-index: 18;
  width: min(640px, 80vw);
  display: flex; align-items: center;
  padding: 12px 18px;
  gap: 12px;
}
.search-glyph {
  font-size: 18px; color: var(--accent-cyan);
  text-shadow: 0 0 10px var(--accent-cyan);
}
#search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--ink);
  caret-color: var(--accent-pink);
}
#search-input::placeholder { color: var(--ink-dim); }
.search-hint {
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink-dim);
  padding: 3px 8px; border: 1px solid var(--glass-border);
  border-radius: 4px;
}

/* ============== Search results overlay ============== */

.results-overlay {
  /* dev25: docked right column, grows upward — mirrors .hud-side-right */
  position: fixed;
  bottom: 90px; right: 26px; left: auto; top: auto; transform: none;
  z-index: 19;
  width: 360px;
  max-height: calc(100vh - 200px);  /* leaves room for top stats + searchbar */
  overflow-y: auto;
  padding: 18px;
  display: flex; flex-direction: column;
}
.results-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.results-header h3 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px; letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-pink);
}
#results-list {
  list-style: none; padding: 0; margin: 0;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
}
#results-list li {
  padding: 10px 12px;
  background: rgba(0,0,0,0.25);
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: all 0.15s;
}
#results-list li:hover {
  border-color: var(--accent-cyan);
  background: rgba(0, 229, 255, 0.06);
  transform: translateX(2px);
}
#results-list li .top {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--ink-dim);
  margin-bottom: 4px;
}
#results-list li .score { color: var(--accent-green); }


/* Featured (top hit) inside the activations panel */
#results-featured {
  padding: 12px 14px;
  background: rgba(0,0,0,0.32);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--accent-pink);
  margin-bottom: 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
#results-featured:hover {
  background: rgba(255,61,160,0.08);
  border-left-color: #ffffff;
}
.featured-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
  font-family: var(--font-mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.14em;
}
.featured-pill {
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid;
  font-weight: 500;
}
.featured-score { color: var(--accent-green); }
.featured-preview {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  /* dev17: no nested scroll — outer .results-overlay scrolls the whole card */
  white-space: pre-wrap;
}
.featured-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 10px;
}
.featured-tags span {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 7px;
  background: rgba(162, 89, 255, 0.12);
  color: var(--accent-violet);
  border: 1px solid rgba(162, 89, 255, 0.3);
  border-radius: 999px;
}
/* Compact rest-list: featured stays prominent, others reached via scroll */
#results-list { flex: 0 0 auto; padding-right: 4px; }  /* dev17: outer overlay scrolls — no inner scroll */
#results-list::-webkit-scrollbar { width: 4px; }
#results-list::-webkit-scrollbar-thumb { background: var(--accent-violet); border-radius: 2px; }
/* Visual hint: when there ARE more items, top edge of list catches the eye */
#results-list:not(:empty) { border-top: 1px dashed var(--glass-border); margin-top: 6px; padding-top: 8px; }

#results-list li .preview {
  font-size: 12px; line-height: 1.4;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============== Boot curtain ============== */

.boot-curtain {
  position: fixed; inset: 0;
  z-index: 100;
  background: radial-gradient(ellipse at center, var(--bg-mid), var(--bg-deep) 70%);
  display: flex; align-items: center; justify-content: center;
  opacity: 1;
  transition: opacity 0.8s ease;
}
.boot-curtain.fading { opacity: 0; pointer-events: none; }
.boot-frame {
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.boot-glyph {
  width: 78px; height: 78px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--accent-cyan), var(--accent-violet) 60%, transparent 100%);
  box-shadow: 0 0 50px rgba(0,229,255,0.6), 0 0 100px rgba(162,89,255,0.4);
  animation: brand-pulse 2.2s ease-in-out infinite;
}
.boot-title {
  font-family: var(--font-mono);
  font-size: 22px;
  letter-spacing: 0.32em;
  text-transform: lowercase;
  background: linear-gradient(90deg, var(--accent-cyan), #ffffff, var(--accent-pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 0;
}
.boot-subtitle {
  font-family: var(--font-mono);
  font-size: 11px; letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 0;
  min-height: 14px;
}
.boot-bar {
  width: 220px; height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px; overflow: hidden;
  margin-top: 6px;
}
.boot-bar span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-pink));
  width: 0%;
  box-shadow: 0 0 12px var(--accent-cyan);
  transition: width 0.4s ease;
}

/* ============== Toasts ============== */

.toasts {
  position: fixed; top: 100px; right: 26px;
  z-index: 50;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 10px 14px;
  background: rgba(8, 14, 28, 0.75);
  border: 1px solid var(--glass-border);
  border-left: 3px solid var(--accent-cyan);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(10px);
  color: var(--ink);
  animation: toast-in 0.3s ease, toast-out 0.3s ease 4.7s forwards;
  max-width: 320px;
}
.toast.err { border-left-color: var(--accent-pink); }
.toast.warn { border-left-color: var(--accent-amber); }
@keyframes toast-in  { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { to   { opacity: 0; transform: translateX(20px); } }

/* ============== Responsive ============== */

@media (max-width: 900px) {
  .hud-side-left { display: none; }
  .hud-side-right { width: 280px; }
  .hud-stats { display: none; }
}

/* dev26: hide regions panel + legend (color is now driven by age, not collection) */
.hud-side-left { display: none !important; }
