/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Variables ── */
:root {
  --bg:       #08080f;
  --surface:  #0f0f1c;
  --surface2: #14142a;
  --border:   #1c1c30;
  --accent:   #b36eff;
  --accent2:  #7c3aed;
  --accent3:  #e040fb;
  --accent-d: #8b2fd4;
  --accent-l: #d4a0ff;
  --text:     #e8e8f0;
  --muted:    #6b6b8a;
  --muted2:   #3a3a58;
  --mono:     'DM Mono', monospace;
  --sans:     'Syne', sans-serif;
  --radius:   6px;
  --glow:     rgba(179, 110, 255, 0.10);
}

/* ── Base ── */
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Grid texture ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(255,255,255,0.012) 39px, rgba(255,255,255,0.012) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(255,255,255,0.012) 39px, rgba(255,255,255,0.012) 40px);
  pointer-events: none;
  z-index: 0;
}

/* ── Scanlines overlay ── */
.scanlines {
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.05) 3px,
    rgba(0,0,0,0.05) 4px
  );
  pointer-events: none;
  z-index: 2;
  animation: scanPan 12s linear infinite;
}

@keyframes scanPan {
  from { background-position: 0 0; }
  to   { background-position: 0 100vh; }
}

/* ── Ambient blobs ── */
.blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(130px);
  opacity: 0.13;
  pointer-events: none;
  z-index: 0;
}
.blob-1 {
  width: 600px; height: 600px;
  background: var(--accent2);
  top: -200px; right: -150px;
  animation: drift 14s ease-in-out infinite alternate;
}
.blob-2 {
  width: 400px; height: 400px;
  background: var(--accent3);
  bottom: -100px; left: -120px;
  animation: drift 18s ease-in-out infinite alternate-reverse;
}
.blob-3 {
  width: 280px; height: 280px;
  background: #3b82f6;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.055;
  animation: drift 22s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(30px, 20px) scale(1.08); }
}

/* ── Cursor glow ── */
.cursor-glow {
  position: fixed;
  top: 0; left: 0;
  width: 340px; height: 340px;
  margin: -170px 0 0 -170px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(179,110,255,0.11) 0%, transparent 70%);
  pointer-events: none;
  z-index: 9999;
  will-change: transform;
}

/* ── Layout wrapper ── */
.wrapper {
  position: relative;
  z-index: 1;
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* ── HEADER ── */
header {
  position: sticky; top: 0; z-index: 200;
  height: 66px;
  background: rgba(8,8,15,0.85);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2rem;
}

.logo-link {
  display: flex; align-items: center; gap: 0.6rem;
  text-decoration: none;
}

.logo-img {
  width: 36px; height: 36px;
  object-fit: contain;
  border-radius: 6px;
  filter: drop-shadow(0 0 10px rgba(179,110,255,0.45));
  animation: logoPulse 3s ease-in-out infinite;
}

.logo-text {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  display: flex; align-items: center;
}

.logo-text em {
  font-style: normal;
  color: var(--accent);
}

.logo-weed-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.85em;
  height: 0.85em;
  position: relative;
  top: 0.05em;
  margin: 0 0.01em;
}

.logo-weed {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(179,110,255,0.6));
  animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
  0%, 100% { filter: drop-shadow(0 0 5px rgba(179,110,255,0.45)); }
  50%       { filter: drop-shadow(0 0 12px rgba(179,110,255,0.85)); }
}

/* ── Socials ── */
.socials {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-right: 1.2rem;
}

.socials a {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, filter 0.2s;
}

.socials a:hover {
  transform: translateY(-3px) scale(1.12);
  filter: brightness(1.2) drop-shadow(0 0 10px rgba(179,110,255,0.7));
}

.socials img {
  width: 22px; height: 22px;
  object-fit: contain;
  border-radius: 4px;
}

.header-right {
  display: flex; align-items: center; gap: 1.2rem;
}

.file-count {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.file-count strong { color: var(--accent); }

/* ── HERO ── */
.hero {
  padding: 5rem 2rem 3.5rem;
  max-width: 860px;
  margin: 0 auto;
  position: relative;
  animation: fadeUp 0.5s ease both;
}

.hero-eyebrow {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.1rem;
}

.hero h1 {
  font-family: var(--sans);
  font-size: clamp(2.4rem, 5vw, 3.8rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.04em;
  margin-bottom: 1.2rem;
}

.hero h1 em {
  font-style: normal;
  color: var(--accent);
}

/* Tagline */
.tagline {
  font-family: var(--mono);
  font-size: 1rem;
  color: var(--muted);
  margin-bottom: 1.4rem;
}

.blank {
  color: var(--accent);
  transition: opacity 0.3s ease;
}

.blank.fade-out { opacity: 0; }

.hero-sub {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--muted);
  max-width: 520px;
  line-height: 1.75;
}

/* cross-hatch deco */
.hero::before {
  content: '';
  position: absolute;
  top: 3rem; right: 0;
  width: 200px; height: 200px;
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 8px,
    rgba(179,110,255,0.04) 8px,
    rgba(179,110,255,0.04) 9px
  );
  pointer-events: none;
  mask-image: radial-gradient(ellipse at 80% 30%, black 30%, transparent 70%);
}

/* ── TOOLBAR ── */
.toolbar {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 2rem 1.6rem;
  display: flex; align-items: center; justify-content: center; gap: 1rem;
  flex-wrap: wrap;
}

.search-wrap {
  min-width: 220px; max-width: 420px; width: 100%;
  position: relative;
}

.search-wrap svg {
  position: absolute; left: 0.9rem; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}

.search-wrap input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem 0.6rem 2.4rem;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-wrap input::placeholder { color: var(--muted2); }
.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(179,110,255,0.12);
}

.tag-filters {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
}

.tag-btn {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  padding: 0.4rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}

.tag-btn:hover { border-color: var(--accent-l); color: var(--accent-l); }
.tag-btn.active {
  background: rgba(179,110,255,0.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── GRID ── */
.grid-section {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 2rem 6rem;
}

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

/* ── CARD ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color 0.22s, transform 0.25s cubic-bezier(.22,.68,0,1.2), box-shadow 0.22s;
  animation: fadeUp 0.4s ease both;
  position: relative;
}

.card-scan {
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 40%, rgba(179,110,255,0.03) 100%);
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.3s;
}

.card:hover {
  border-color: rgba(179,110,255,0.45);
  transform: translateY(-4px);
  box-shadow: 0 16px 48px rgba(0,0,0,0.55), 0 0 0 1px rgba(179,110,255,0.14);
}

.card:hover .card-scan { opacity: 1; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* STL viewer */
.card-viewer {
  width: 100%; height: 220px;
  background: var(--surface2);
  position: relative;
  cursor: grab;
  overflow: hidden;
  z-index: 1;
}

.card-viewer:active { cursor: grabbing; }
.card-viewer canvas { display: block; width: 100% !important; height: 100% !important; }

.viewer-hint {
  position: absolute; bottom: 0.6rem; right: 0.7rem;
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  color: var(--muted2);
  pointer-events: none;
  transition: opacity 0.3s;
}

.card-viewer.interacted .viewer-hint { opacity: 0; }

.viewer-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 0.6rem;
  background: var(--surface2);
}

.spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.viewer-loading span {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.viewer-error {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 0.5rem;
}

.viewer-error svg { color: var(--muted2); }

.viewer-error span {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted2);
  letter-spacing: 0.06em;
}

/* Card body */
.card-body {
  padding: 1.1rem 1.2rem 1.2rem;
  display: flex; flex-direction: column; gap: 0.7rem;
  flex: 1;
  z-index: 1;
}

.card-name {
  font-family: var(--sans);
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--text);
}

.card-desc {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.65;
  flex: 1;
}

.card-tags {
  display: flex; gap: 0.35rem; flex-wrap: wrap;
}

.tag {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.22rem 0.6rem;
  border-radius: 4px;
  background: rgba(179,110,255,0.07);
  border: 1px solid rgba(179,110,255,0.18);
  color: var(--accent);
}

.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.8rem 1.2rem;
  border-top: 1px solid var(--border);
  gap: 0.8rem;
  z-index: 1;
}

.file-size {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--muted2);
  letter-spacing: 0.05em;
}

.btn-download {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.5rem 1rem;
  background: rgba(179,110,255,0.13);
  border: 1px solid rgba(179,110,255,0.30);
  color: var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.18s, border-color 0.18s, transform 0.12s, box-shadow 0.18s;
  white-space: nowrap;
}

.btn-download:hover {
  background: rgba(179,110,255,0.22);
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(179,110,255,0.25);
}

.btn-download:active { transform: scale(0.97); }

/* ── EMPTY / NO-FILES STATES ── */
.empty-state {
  display: none;
  grid-column: 1 / -1;
  text-align: center;
  padding: 5rem 2rem;
}

.empty-state.visible { display: block; }

.empty-state p {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
}

.no-files {
  display: none;
  max-width: 560px;
  margin: 4rem auto;
  padding: 3rem 2rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.no-files.visible { display: block; }

.no-files h2 {
  font-family: var(--mono);
  font-size: 1rem;
  margin-bottom: 0.8rem;
  color: var(--muted);
}

.no-files p {
  font-size: 0.85rem;
  color: var(--muted2);
  line-height: 1.7;
}

.no-files code {
  font-family: var(--mono);
  font-size: 0.8rem;
  background: var(--surface2);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  color: var(--accent-l);
}

/* ── FOOTER ── */
footer {
  border-top: 1px solid var(--border);
  padding: 2rem;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--muted2);
  position: relative;
  z-index: 1;
}

footer a { color: var(--accent); text-decoration: none; }
footer a:hover { opacity: 0.75; }

/* ── ANIMATIONS ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .cursor-glow { display: none; }
  header { padding: 0 1rem; }
  .hero { padding: 3rem 1rem 2rem; }
  .hero::before { display: none; }
  .toolbar { padding: 0 1rem 1.2rem; }
  .grid-section { padding: 0 1rem 4rem; }
  .tagline { white-space: normal; }
}
