/* =========================================================
   PIXEL·DROP — 像素颗粒模块化图片投放站
   视觉系统：有限高对比色板 + 像素网格 + 颗粒叠层
   ========================================================= */

:root {
  --bg:        #0d0b1a;
  --bg-soft:   #161229;
  --panel:     #1d1838;
  --line:      #322a5e;
  --ink:       #f4f1ff;
  --ink-dim:   #a99fd6;

  --pink:   #ff5277;
  --cyan:   #2ce8f5;
  --yellow: #f9f871;
  --purple: #7c5cff;
  --green:  #2bff88;

  --px: 4px;                 /* 基础像素单位 */
  --radius: 0px;            /* 像素风：硬边角 */
  --shadow: 6px 6px 0 #000; /* 硬投影 */
  --maxw: 1340px;

  --font-pixel: 'Press Start 2P', monospace;
  --font-body:  'Space Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; }

/* 像素颗粒 / 网格叠层（全局） */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image:
    /* 细网格 */
    linear-gradient(rgba(124,92,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124,92,255,0.06) 1px, transparent 1px),
    /* 颗粒噪点 */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.35'/%3E%3C/svg%3E");
  background-size: 28px 28px, 28px 28px, 120px 120px;
}

/* 随机呼吸闪烁的像素颗粒背景层 */
.grain-field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  display: block;
  opacity: 0.95;  /* 颗粒已足够稀疏（≤1%），提高亮度使闪烁更醒目 */
}

/* ===================== 导航 ===================== */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: rgba(13,11,26,0.86);
  backdrop-filter: blur(6px);
  border-bottom: var(--px) solid var(--line);
}
.nav__brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.nav__logo {
  width: 18px; height: 18px;
  background:
    conic-gradient(var(--pink) 0 25%, var(--cyan) 0 50%, var(--yellow) 0 75%, var(--purple) 0);
  image-rendering: pixelated;
  box-shadow: 0 0 0 2px #000;
}
.nav__name { font-family: var(--font-pixel); font-size: 12px; letter-spacing: 1px; }
.nav__links { margin-left: auto; display: flex; gap: 18px; }
.nav__links a {
  text-decoration: none; color: var(--ink-dim); font-weight: 500; font-size: 14px;
  padding: 4px 2px; border-bottom: 2px solid transparent; transition: .15s;
}
.nav__links a:hover { color: var(--ink); border-color: var(--cyan); }

/* 像素按钮 */
.pixel-btn {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: #0d0b1a;
  background: var(--yellow);
  border: var(--px) solid #000;
  padding: 12px 16px;
  text-decoration: none;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  transition: transform .08s, box-shadow .08s;
  image-rendering: pixelated;
}
.pixel-btn:hover { transform: translate(-2px,-2px); box-shadow: 8px 8px 0 #000; }
.pixel-btn:active { transform: translate(2px,2px); box-shadow: 2px 2px 0 #000; }
.pixel-btn--ghost { background: transparent; color: var(--ink); border-color: var(--cyan); box-shadow: 6px 6px 0 var(--cyan); }
.pixel-btn--sm { font-size: 9px; padding: 9px 11px; box-shadow: 4px 4px 0 #000; }
.pixel-btn .dot { width: 8px; height: 8px; background: var(--green); box-shadow: 0 0 0 2px #000; }
body:not(.pixel-mode) .pixel-btn .dot { background: var(--ink-dim); }

/* ===================== 主视觉 ===================== */
.hero {
  position: relative;
  z-index: 2;
  padding: 86px 20px 96px;
  text-align: center;
  overflow: hidden;
  border-bottom: var(--px) solid var(--line);
  background:
    radial-gradient(circle at 20% 20%, rgba(124,92,255,0.25), transparent 40%),
    radial-gradient(circle at 80% 30%, rgba(44,232,245,0.18), transparent 40%),
    var(--bg);
}
.hero__pixels {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, 32px);
  gap: 0;
  opacity: 0.5;
  pointer-events: none;
}
.hero__pixels span {
  width: 32px; height: 32px;
  animation: floaty 6s infinite ease-in-out;
}
@keyframes floaty {
  0%,100% { transform: translateY(0); opacity: .25; }
  50%     { transform: translateY(-10px); opacity: .8; }
}
.hero__inner { position: relative; max-width: 760px; margin: 0 auto; }
.hero__kicker { font-family: var(--font-pixel); font-size: 9px; color: var(--cyan); letter-spacing: 2px; margin: 0 0 18px; }
.hero__title {
  font-family: var(--font-pixel);
  font-size: clamp(20px, 5vw, 40px);
  line-height: 1.5;
  margin: 0 0 22px;
  text-shadow: 4px 4px 0 var(--pink), 8px 8px 0 #000;
}
.hero__sub { color: var(--ink-dim); font-size: 16px; max-width: 520px; margin: 0 auto 30px; }
.hero__cta { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

/* ===================== 区块通用 ===================== */
main { position: relative; z-index: 2; }
.gallery-section, .submit-section, .about-section {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 64px 20px;
}
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 16px; margin-bottom: 28px;
}
.section-title {
  font-family: var(--font-pixel);
  font-size: clamp(14px, 3vw, 20px);
  margin: 0;
  color: var(--ink);
  text-shadow: 3px 3px 0 var(--purple);
}

/* 筛选 chips */
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--ink-dim);
  background: var(--panel);
  border: var(--px) solid var(--line);
  padding: 9px 12px;
  cursor: pointer;
  transition: .12s;
}
.chip:hover { color: var(--ink); border-color: var(--cyan); }
.chip.is-active { color: #0d0b1a; background: var(--cyan); border-color: #000; }

/* ===================== 画廊网格 ===================== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 26px;
}
.cell {
  background: var(--panel);
  border: calc(var(--px) * 1.5) solid var(--line);
  box-shadow: 8px 8px 0 #000;
  overflow: hidden;
  transition: transform .14s, box-shadow .14s, border-color .14s;
  cursor: pointer;
}
.cell:hover { transform: translate(-5px,-5px) scale(1.015); box-shadow: 12px 12px 0 var(--pink); border-color: var(--pink); }
.cell__media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #0a0818;
  overflow: hidden;
  border-bottom: calc(var(--px) * 1.5) solid var(--line);
}
.cell__canvas, .cell__img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.cell__canvas { image-rendering: pixelated; }
/* 清晰模式下显示原图，隐藏 canvas */
body:not(.pixel-mode) .cell__canvas { display: none; }
body.pixel-mode .cell__img { display: none; }

.cell__tag {
  position: absolute; top: 8px; left: 8px;
  font-family: var(--font-pixel); font-size: 8px;
  background: #000; color: var(--yellow);
  padding: 5px 7px; border: 2px solid var(--yellow);
}
.cell__meta { padding: 12px 14px 16px; }
.cell__title { font-size: 17px; margin: 0 0 4px; font-weight: 700; letter-spacing: .5px; }
.cell__desc { font-size: 13px; color: var(--ink-dim); margin: 0; }

.empty { text-align: center; color: var(--ink-dim); padding: 40px 0; font-family: var(--font-pixel); font-size: 11px; }

/* ===================== 投稿 ===================== */
.dropzone {
  border: var(--px) dashed var(--cyan);
  background: var(--bg-soft);
  padding: 48px 20px;
  text-align: center;
  cursor: pointer;
  transition: .15s;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.is-drag {
  border-color: var(--pink);
  background: #221a3f;
  outline: none;
}
.dropzone__icon { font-size: 40px; color: var(--cyan); display: block; margin-bottom: 12px; }
.dropzone__text { font-family: var(--font-pixel); font-size: 13px; margin: 0 0 8px; }
.dropzone__hint { color: var(--ink-dim); font-size: 13px; margin: 0; }
.note { color: var(--ink-dim); font-size: 13px; margin-top: 16px; }

/* ===================== 关于 ===================== */
.about-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 18px; }
.about-card {
  background: var(--panel);
  border: var(--px) solid var(--line);
  box-shadow: var(--shadow);
  padding: 22px 20px;
}
.about-card__n { font-family: var(--font-pixel); color: var(--pink); font-size: 18px; }
.about-card h3 { font-size: 16px; margin: 12px 0 8px; }
.about-card p { color: var(--ink-dim); font-size: 14px; margin: 0; }

/* ===================== 页脚 ===================== */
.footer {
  position: relative; z-index: 2;
  border-top: var(--px) solid var(--line);
  background: var(--bg-soft);
  text-align: center;
  padding: 36px 20px;
  color: var(--ink-dim);
  font-size: 13px;
}
.footer a { color: var(--cyan); }
.footer__pixels {
  height: 24px;
  background: repeating-linear-gradient(90deg,
    var(--pink) 0 12px, var(--cyan) 12px 24px, var(--yellow) 24px 36px, var(--purple) 36px 48px);
  margin-bottom: 20px;
  image-rendering: pixelated;
}

/* ===================== 灯箱 ===================== */
.lightbox {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5,3,12,0.92);
  display: flex; align-items: center; justify-content: center;
  gap: 12px; padding: 20px;
}
.lightbox[hidden] { display: none; }
.lightbox__figure { margin: 0; max-width: min(86vw, 760px); text-align: center; }
.lightbox__canvas, .lightbox__img {
  max-width: 100%; max-height: 76vh;
  border: var(--px) solid var(--line);
  box-shadow: 10px 10px 0 #000;
  image-rendering: pixelated;
  background: var(--bg-soft);
}
body:not(.pixel-mode) .lightbox__canvas { display: none; }
body.pixel-mode .lightbox__img { display: none; }
.lightbox__caption { margin-top: 14px; font-family: var(--font-pixel); font-size: 11px; color: var(--ink); }
.lightbox__close {
  position: absolute; top: 16px; right: 16px;
  font-family: var(--font-pixel); font-size: 14px;
  background: var(--pink); color: #000;
  border: var(--px) solid #000; width: 40px; height: 40px; cursor: pointer;
}
.lightbox__nav {
  font-family: var(--font-pixel); font-size: 28px;
  background: var(--panel); color: var(--ink);
  border: var(--px) solid var(--line); width: 48px; height: 64px; cursor: pointer;
}
.lightbox__nav:hover { border-color: var(--cyan); color: var(--cyan); }

/* ===================== 响应式 ===================== */
@media (max-width: 640px) {
  .nav__links { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
  .hero { padding: 64px 16px 72px; }
  .gallery-section, .submit-section, .about-section { padding: 48px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .hero__pixels span { animation: none; }
  html { scroll-behavior: auto; }
}

/* 焦点可见性（a11y） */
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }

/* ===================== 投稿分类选择 ===================== */
.submit-cat {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  margin: 0 0 18px; padding: 12px 14px;
  background: var(--panel); border: var(--px) solid var(--line);
}
.submit-cat label {
  font-family: var(--font-pixel); font-size: 11px; color: var(--ink);
  letter-spacing: 1px;
}
.submit-cat select {
  font-family: var(--font-grotesk); font-size: 14px; font-weight: 500;
  color: var(--ink); background: var(--bg-soft);
  border: var(--px) solid var(--line); padding: 8px 12px; cursor: pointer;
}
.submit-cat select:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }
.submit-cat__hint { font-size: 12px; color: var(--muted, #8a8f98); }
@media (max-width: 640px) { .submit-cat__hint { width: 100%; } }
