/* ============================================
   织梦书境 · 首页样式（梦幻女性向 + 移动端适配）
   ============================================ */

:root {
  --app-bg-l1: #0d0a1a;
  --app-bg-l2: rgba(255,255,255,.06);
  --app-bg-l3: rgba(255,255,255,.1);
  --app-bg-l5: rgba(255,255,255,.14);
  --app-bg-l7: rgba(255,255,255,.2);
  --app-bg-topbar: rgba(12,8,24,.82);
  --app-text-l1: #f5f0ff;
  --app-text-l3: #d8cfe8;
  --app-text-l4: #a89bc4;
  --app-text-l5: #7a6e96;
  --app-border-l1: rgba(255,255,255,.08);
  --app-border-l2: rgba(255,255,255,.13);
  --app-color-theme: #e87acc;
  --app-color-secondary: #1a0a2e;
  --glow-pink: rgba(232,122,204,.35);
  --glow-purple: rgba(167,139,250,.3);
  --glow-cyan: rgba(103,232,210,.25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  min-height: 100vh;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--app-bg-l1);
  color: var(--app-text-l1);
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  /* 梦幻渐变背景（不用fixed，避免移动端渲染异常） */
  background-image:
    radial-gradient(ellipse 80% 60% at 10% 20%, rgba(232,122,204,.15) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 85% 30%, rgba(167,139,250,.18) 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 50% 85%, rgba(103,232,210,.12) 0%, transparent 55%),
    linear-gradient(175deg, #0d0a1a 0%, #140e28 35%, #1a1235 65%, #0f1a2a 100%);
}

/* ⚠️ 移动端触摸优化：只对按钮去300ms延迟，绝不写 * 全局（会禁用页面滚动！）*/
* { -webkit-tap-highlight-color: transparent; }
button, .nav-btn, .hero-cta, .script-card-main, .second-category-item, .page-btn,
.sort-select, select, input[type="submit"], input[type="button"] {
  touch-action: manipulation;
}
/* 链接去掉下划线（用户反馈卡片文字不该有横杠）*/
a {
  color: inherit;
  text-decoration: none !important;
}

/* ===== 全局光斑动画（降低层级，不阻挡触摸）===== */
body::before {
  content: "";
  position: absolute; /* 改为absolute，不固定在视口 */
  top: 0; left: 0; right: 0;
  height: 200vh; /* 跟随内容 */
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 25%, rgba(232,122,204,.08) 0%, transparent 40%),
    radial-gradient(circle at 78% 68%, rgba(167,139,250,.07) 0%, transparent 40%);
  animation: bgFloat 14s ease-in-out infinite alternate;
}
@keyframes bgFloat {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(-15px, 20px) scale(1.04); }
  100% { transform: translate(12px, -10px) scale(1.02); }
}

/* ===== 顶栏（玻璃拟态）===== */
.top-bar {
  background-color: var(--app-bg-topbar);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  padding: .5rem 1.5rem;
  border-bottom: 1px solid var(--app-border-l1);
  display: flex; justify-content: space-between; align-items: center;
  position: fixed; top: 0; left: 0; right: 0; height: 52px; z-index: 1000;
}
.top-bar-left { display: flex; align-items: center; gap: 1.75rem; }
.logo-lockup {
  display: flex; align-items: center;
  text-decoration: none; cursor: pointer;
}
.logo-text {
  font-size: 20px; font-weight: 800; letter-spacing: .06em;
  background: linear-gradient(135deg, #e87acc, #c084fc, #67e8d2);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  white-space: nowrap; /* 防止 logo 文字换行 */
}
.logo-dot {
  font-size: 20px; font-weight: 700; color: var(--app-color-theme);
}
.logo-sub {
  font-size: 15px; font-weight: 500; color: var(--app-text-l3);
  margin-left: 2px;
}
.nav { display: flex; align-items: center; gap: .25rem; }
.nav-btn {
  background: transparent; border: 0; cursor: pointer;
  color: var(--app-text-l4); font-size: 14px;
  padding: .45rem .85rem; border-radius: 999px;
  transition: all .25s ease; font-family: inherit;
  position: relative;
}
.nav-btn:hover {
  color: var(--app-text-l1);
  background: rgba(255,255,255,.08);
}
.nav-btn.is-active {
  color: #fff;
  background: linear-gradient(135deg, #e87acc, #c084fc);
  font-weight: 700;
  box-shadow: 0 2px 14px var(--glow-pink), 0 0 30px rgba(232,122,204,.12);
}
.auth-btn {
  background: linear-gradient(135deg, #e87acc, #c084fc);
  color: #fff;
  border: 0; cursor: pointer; font-weight: 700; font-size: 13px;
  padding: .45rem 1.1rem; border-radius: 999px; font-family: inherit;
  box-shadow: 0 2px 16px var(--glow-pink);
  transition: all .25s ease;
}
.auth-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px var(--glow-pink), 0 0 36px rgba(232,122,204,.18);
}
.ai-status-sm {
  font-size: 12px; color: var(--app-text-l5); font-weight: 500;
  padding: .3rem .65rem; border-radius: 999px;
  background: rgba(255,255,255,.05); border: 1px solid var(--app-border-l1);
}

/* ===== Hero 横幅（梦幻插画风）===== */
.hero-banner {
  position: relative;
  margin-top: 52px; /* 匹配顶栏高度 */
  min-height: 280px;
  height: auto;
  overflow: visible;
  display: flex; align-items: center; justify-content: center;
  z-index: 1;
}
.hero-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 90% 80% at 50% 40%, rgba(232,122,204,.2) 0%, transparent 60%),
    radial-gradient(ellipse 70% 60% at 75% 30%, rgba(167,139,250,.18) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 25% 70%, rgba(103,232,210,.12) 0%, transparent 50%),
    linear-gradient(145deg, #1a0a2e 0%, #2a1045 25%, #1e1540 50%, #141e35 75%, #0d1525 100%);
  z-index: 0;
  pointer-events: none;
}
/* 星星装饰 */
.hero-bg::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 10% 20%, rgba(255,255,255,.7) 100%, transparent),
    radial-gradient(1.2px 1.2px at 25% 65%, rgba(255,255,255,.5) 100%, transparent),
    radial-gradient(1.8px 1.8px at 55% 15%, rgba(232,200,255,.8) 100%, transparent),
    radial-gradient(1.3px 1.3px at 72% 48%, rgba(255,255,255,.5) 100%, transparent),
    radial-gradient(1.6px 1.6px at 88% 72%, rgba(200,180,255,.6) 100%, transparent),
    radial-gradient(1.1px 1.1px at 38% 82%, rgba(255,255,255,.4) 100%, transparent),
    radial-gradient(1.4px 1.4px at 62% 72%, rgba(255,220,255,.6) 100%, transparent),
    radial-gradient(1px 1px at 15% 48%, rgba(255,255,255,.5) 100%, transparent),
    radial-gradient(1.5px 1.5px at 82% 22%, rgba(230,200,255,.7) 100%, transparent),
    radial-gradient(1.2px 1.2px at 45% 42%, rgba(255,255,255,.4) 100%, transparent);
  animation: twinkle 5s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes twinkle {
  0%   { opacity: .6; }
  50%  { opacity: 1; }
  100% { opacity: .5; }
}
.hero-bg::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 65% 45%, rgba(232,122,204,.1) 0%, transparent 60%);
  pointer-events: none;
}
/* Hero 内容 — 高z-index确保可点击 */
.hero-content {
  position: relative; z-index: 10;
  text-align: center; padding: 2rem 1.5rem;
}
.hero-content h1 {
  margin: 0 0 .6rem;
  font-size: 32px; font-weight: 800; letter-spacing: .04em;
  background: linear-gradient(135deg, #fff 0%, #f5d0fe 40%, #c4b5fd 70%, #a5f3e8 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: heroFloat 4s ease-in-out infinite;
  filter: drop-shadow(0 2px 12px rgba(232,122,204,.3));
}
@keyframes heroFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}
.hero-content p {
  margin: 0 0 1.3rem; font-size: 15px; color: var(--app-text-l3);
  line-height: 1.6; letter-spacing: .03em;
}
/* 开始创作按钮 — 确保可点击 */
.hero-cta {
  display: inline-block;
  position: relative; z-index: 10;
  padding: .8rem 2.4rem;
  background: linear-gradient(135deg, #e87acc 0%, #f0a0c8 40%, #e879a0 70%, #c084fc 100%);
  color: #fff;
  text-decoration: none; border-radius: 999px;
  font-weight: 800; font-size: 16px;
  letter-spacing: .04em;
  box-shadow: 0 4px 24px var(--glow-pink), 0 0 50px rgba(232,122,204,.12), inset 0 1px 0 rgba(255,255,255,.3);
  transition: all .3s ease;
  overflow: hidden;
  animation: ctaPulse 2.5s ease-in-out infinite;
  cursor: pointer;
  border: none;
  -webkit-transform: translateZ(0); /* 触发GPU层，提升响应 */
  transform: translateZ(0);
}
@keyframes ctaPulse {
  0%, 100% { box-shadow: 0 4px 24px var(--glow-pink), 0 0 50px rgba(232,122,204,.12), inset 0 1px 0 rgba(255,255,255,.3); }
  50%      { box-shadow: 0 6px 32px var(--glow-pink), 0 0 70px rgba(232,122,204,.2), inset 0 1px 0 rgba(255,255,255,.4); }
}
.hero-cta::before {
  content: "";
  position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,.2) 0%, transparent 55%);
  opacity: 0; transition: opacity .4s;
  pointer-events: none;
}
.hero-cta:hover, .hero-cta:active {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 8px 36px var(--glow-pink), 0 0 80px rgba(232,122,204,.25);
  animation: none;
}
.hero-cta:hover::before, .hero-cta:active::before { opacity: 1; }

/* ===== 页面容器 ===== */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
  position: relative; z-index: 1;
}

/* ===== 布局 ===== */
.layout {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 0;
}
.category-panel { padding-top: .25rem; }
.category-list { list-style: none; margin: 0; padding: 0; }
.second-category-item {
  padding: .55rem .85rem; margin-bottom: .3rem; border-radius: 999px;
  cursor: pointer; color: var(--app-text-l3); font-size: 13px;
  transition: all .25s ease; white-space: nowrap;
  border: 1px solid transparent;
  font-weight: 500;
  position: relative;
  z-index: 1;
}
.second-category-item:hover {
  color: var(--app-text-l1);
  background: rgba(255,255,255,.07);
  border-color: var(--app-border-l1);
}
.second-category-item.active {
  background: linear-gradient(135deg, #e87acc, #c084fc);
  color: #fff; font-weight: 700;
  border-color: transparent;
  box-shadow: 0 2px 14px var(--glow-pink);
}

/* ===== 内容区 ===== */
.content { min-width: 0; padding-left: 1.8rem; }
.script-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; margin-bottom: 1rem;
  position: relative; z-index: 1;
}
.sort-control { 
  display: inline-flex; align-items: center; gap: .5rem;
  flex-shrink: 0;
}
.sort-label { 
  color: var(--app-text-l4); 
  font-size: .9rem; 
  line-height: 1; 
  font-weight: 500; 
  white-space: nowrap;
}
.sort-select {
  width: 120px; flex-shrink: 0;
  background: rgba(255,255,255,.07); color: var(--app-text-l1);
  border: 1px solid var(--app-border-l1); border-radius: 999px;
  padding: .45rem .75rem; font-size: 13px; font-family: inherit; cursor: pointer;
  backdrop-filter: blur(4px);
  -webkit-appearance: none; appearance: none;
  transition: all .2s ease;
  position: relative; z-index: 2;
  height: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23a89bc4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.sort-select:focus { outline: none; border-color: var(--app-color-theme); background-color: rgba(255,255,255,.1); }
.sort-select option { background: #1a1235; color: #fff; }
.script-count {
  font-size: .82rem; color: var(--app-text-l5);
  padding: .28rem .72rem; border-radius: 999px;
  background: rgba(255,255,255,.04); border: 1px solid var(--app-border-l1);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===== 剧本卡片网格 ===== */
.script-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.25rem; margin-top: .6rem;
  position: relative; z-index: 1;
}
.script-card-main {
  display: flex; align-items: flex-start; gap: .85rem;
  padding: 1rem; border-radius: 16px; cursor: pointer;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--app-border-l1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all .3s cubic-bezier(.2,.9,.3,1.2);
  position: relative; overflow: hidden;
  z-index: 1;
}
/* 卡片悬停光效 */
.script-card-main::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 0%, rgba(232,122,204,.08) 0%, transparent 60%);
  opacity: 0; transition: opacity .3s;
  pointer-events: none;
  z-index: 0;
}
.script-card-main:hover, .script-card-main:active {
  background: rgba(255,255,255,.09);
  border-color: rgba(232,122,204,.25);
  transform: translateY(-4px);
  box-shadow:
    0 12px 40px rgba(0,0,0,.3),
    0 0 30px rgba(232,122,204,.08),
    inset 0 1px 0 rgba(255,255,255,.06);
}
.script-card-main:hover::before { opacity: 1; }

.card-media { width: 105px; flex-shrink: 0; position: relative; z-index: 1; }
.card-cover-frame {
  position: relative; width: 105px; height: 105px; overflow: hidden; border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.card-cover-frame::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 44%;
  pointer-events: none; z-index: 2;
  background: linear-gradient(180deg, #0000, #0000009e);
  border-radius: 0 0 12px 12px;
}
.card-cover-fallback {
  position: absolute; inset: 0; z-index: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 800; color: rgba(255,255,255,.75);
  letter-spacing: -0.02em;
}
.script-player-count {
  position: absolute; left: .4rem; right: .4rem; bottom: .3rem; z-index: 1;
  margin: 0; font-size: .7rem; font-weight: 600; color: #fffffff0; line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .8);
}
.card-body { min-width: 0; flex: 1; position: relative; z-index: 1; }
.card-title {
  margin: 0 0 .35rem; font-size: 1.04rem; font-weight: 700; color: var(--app-text-l1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  letter-spacing: .01em;
}
.card-author {
  margin: 0 0 .45rem; font-size: .83rem; color: var(--app-text-l4);
}
.card-desc {
  margin: 0 0 .6rem; font-size: .88rem; color: var(--app-text-l4); line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; text-overflow: ellipsis; min-height: 2.6em;
}
.script-tags { margin-top: .5rem; display: flex; flex-wrap: wrap; gap: .4rem; }
.script-tag {
  font-size: 11px; padding: .2rem .6rem; border-radius: 999px;
  background: rgba(232,122,204,.12); color: #f0b8dc;
  border: 1px solid rgba(232,122,204,.15);
  font-weight: 500;
  transition: all .2s ease;
}
.script-card-main:hover .script-tag {
  background: rgba(232,122,204,.2);
  border-color: rgba(232,122,204,.28);
  color: #fadbf0;
}

/* ===== 空货架 ===== */
.empty-shelf {
  padding: 4.5rem 1rem; text-align: center;
  position: relative; z-index: 1;
}
.empty-icon { font-size: 52px; margin-bottom: .85rem; animation: emptyBounce 2.5s ease-in-out infinite; }
@keyframes emptyBounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
.empty-shelf > div:nth-child(2) { font-size: 1.05rem; color: var(--app-text-l3); margin-bottom: .5rem; font-weight: 600; }
.empty-hint { font-size: .88rem; color: var(--app-text-l5); }
.empty-hint a { color: var(--app-color-theme); text-decoration: none; font-weight: 600; }
.empty-hint a:hover { text-decoration: underline; }

.loading-state, .empty-state {
  padding: 3rem 1rem; text-align: center; color: var(--app-text-l5); font-size: .95rem;
  position: relative; z-index: 1;
}

/* ===== 分页 ===== */
.pagination-wrapper { 
  margin-top: 2rem; 
  display: flex; justify-content: center; flex-wrap: wrap; gap: .4rem;
  position: relative; z-index: 1;
}
.page-btn {
  min-width: 34px; height: 34px; padding: 0 .55rem;
  background: rgba(255,255,255,.05); color: var(--app-text-l3);
  border: 1px solid var(--app-border-l1); border-radius: 999px;
  cursor: pointer; font-size: 13px; font-family: inherit;
  transition: all .22s ease; font-weight: 500;
  backdrop-filter: blur(4px);
  position: relative; z-index: 1;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}
.page-btn:hover:not(:disabled) {
  background: rgba(255,255,255,.1); color: var(--app-text-l1);
  border-color: rgba(255,255,255,.15);
  transform: translateY(-1px);
}
.page-btn.is-active {
  background: linear-gradient(135deg, #e87acc, #c084fc);
  color: #fff; border-color: transparent; font-weight: 700;
  box-shadow: 0 2px 14px var(--glow-pink);
}

/* ===== 响应式（重点修复移动端）===== */
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .top-bar { 
    padding: .4rem .75rem; 
    height: 48px;
  }
  .logo-text { font-size: 14px; white-space: nowrap; }
  .nav { gap: .15rem; }
  .nav-btn { 
    padding: .35rem .5rem; 
    font-size: 12px; 
  }
  .top-bar-left { gap: .6rem; }
  .ai-status-sm { 
    font-size: 11px; 
    padding: .22rem .45rem; 
  }

  /* Hero 移动端缩小 */
  .hero-banner { 
    margin-top: 48px;
    min-height: 220px;
  }
  .hero-content { 
    padding: 1.5rem 1rem; 
  }
  .hero-content h1 { 
    font-size: 22px; 
  }
  .hero-content p { 
    font-size: 13px; 
    margin-bottom: 1rem;
  }
  .hero-cta {
    padding: .7rem 2rem;
    font-size: 15px;
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 44px; /* 微信最小触控区 */
  }
  /* 月亮装饰缩小 */
  .hero-deco {
    width: 120px !important;
    height: 100px !important;
    top: 8px !important;
    right: 20px !important;
    opacity: .25 !important;
  }

  /* 单栏布局 */
  .layout { grid-template-columns: 1fr; }
  
  /* 分类标签横滑 */
  .category-panel {
    display: flex; 
    overflow-x: auto; 
    gap: .3rem;
    padding: .5rem 0 .7rem; 
    margin-bottom: .3rem;
    border-bottom: 1px solid var(--app-border-l1);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .category-panel::-webkit-scrollbar { display: none; }
  .category-list { display: flex; gap: .25rem; flex-wrap: nowrap; }
  .second-category-item { 
    white-space: nowrap; 
    margin-bottom: 0; 
    padding: .38rem .7rem; 
    font-size: 12px; 
    flex-shrink: 0;
  }

  /* 内容区无左内边距 */
  .content { padding-left: 0; }

  /* 排序工具栏移动端优化（关键修复！） */
  .script-toolbar {
    flex-wrap: wrap;
    gap: .5rem .75rem;
    align-items: center;
    margin-bottom: .85rem;
    padding: .4rem 0;
  }
  .sort-control {
    width: 100%;
    justify-content: flex-start;
  }
  .sort-label { font-size: 13px; }
  .sort-select {
    width: 100%;
    max-width: 180px;
    flex: 1;
    height: 36px;
    font-size: 13px;
  }
  .script-count {
    width: 100%;
    text-align: center;
    order: -1; /* 计数放到最上面 */
    font-size: 12px;
    margin-bottom: .2rem;
  }

  /* 卡片网格单列 */
  .page { 
    padding: .75rem .75rem 4rem; 
  }
  .script-list { 
    grid-template-columns: 1fr; 
    gap: .85rem; 
  }
  .card-cover-frame { width: 80px; height: 80px; }
  .card-media { width: 80px; }
  .card-title { font-size: .98rem; }
  .card-desc { 
    -webkit-line-clamp: 2; 
    font-size: .84rem;
  }
  .script-card-main { 
    padding: .75rem; 
    border-radius: 14px;
  }
  .script-player-count { font-size: .65rem; }

  /* 分页按钮加大触控区 */
  .page-btn {
    min-width: 38px;
    height: 38px;
  }
}

@media (max-width: 400px) {
  .hero-content h1 { font-size: 19px; }
  .hero-cta { 
    padding: .6rem 1.5rem; 
    font-size: 14px;
  }
  .sort-select { max-width: 150px; }
  .card-cover-frame { width: 68px; height: 68px; }
  .card-media { width: 68px; }
}
