/* ===== 首页 Live2D 皮肤展示组件(l2d) ===== */
.l2d-section {
  margin-bottom: 12px;
}

.l2d-stage {
  position: relative;
  width: 100%;
  height: 660px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(31, 111, 92, .28), transparent 60%),
    radial-gradient(900px 420px at 85% 110%, rgba(93, 63, 211, .22), transparent 60%),
    radial-gradient(700px 380px at 12% 105%, rgba(214, 69, 69, .14), transparent 55%),
    linear-gradient(180deg, #0e1420 0%, #131c2e 55%, #0b101a 100%);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}

/* 普通立绘(无特殊背景):背景替换为透明,融入页面 */
.l2d-stage.transparent {
  background: transparent;
  box-shadow: none;
}
/* 带特殊背景的立绘:保留深色舞台衬托模型内置背景 */
.l2d-stage.has-bg {
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(31, 111, 92, .28), transparent 60%),
    radial-gradient(900px 420px at 85% 110%, rgba(93, 63, 211, .22), transparent 60%),
    radial-gradient(700px 380px at 12% 105%, rgba(214, 69, 69, .14), transparent 55%),
    linear-gradient(180deg, #0e1420 0%, #131c2e 55%, #0b101a 100%);
}

.l2d-stage canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

/* 左上角:角色 + 皮肤名 */
.l2d-info {
  position: absolute;
  top: 14px;
  left: 16px;
  z-index: 5;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(10, 14, 22, .55);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, .12);
}

.l2d-info .l2d-ship {
  font-size: 19px;
  font-weight: 700;
  color: #f2f5f9;
  letter-spacing: .5px;
}

.l2d-info .l2d-skin {
  font-size: 13px;
  color: #9fb0c8;
}

/* 右上角:两个按钮 */
.l2d-controls {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 6;
  display: flex;
  gap: 8px;
}

.l2d-controls button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(10, 14, 22, .6);
  backdrop-filter: blur(6px);
  color: #e8edf4;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s, transform .12s, border-color .18s;
}

.l2d-controls button:hover {
  background: rgba(31, 111, 92, .75);
  border-color: rgba(255, 255, 255, .4);
  transform: translateY(-1px);
}

.l2d-controls button:active {
  transform: translateY(0) scale(.97);
}

/* 缩放按钮组 */
.l2d-zoom {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(10, 14, 22, .6);
  backdrop-filter: blur(6px);
  border-radius: 999px;
}

.l2d-zoom button {
  border: none;
  background: transparent;
  padding: 5px 9px;
  min-width: 32px;
  text-align: center;
  font-size: 14px;
  line-height: 1.2;
}

.l2d-zoom button:hover {
  background: rgba(31, 111, 92, .75);
  border-color: transparent;
  transform: none;
}

.l2d-zoom button:active {
  transform: scale(.94);
}

#l2d-btn-zoom-reset {
  font-size: 11px;
  color: #9fb0c8;
  min-width: 40px;
}

/* loading / 错误 */
.l2d-loading {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 14px;
  color: #aebbd0;
  background: rgba(8, 11, 18, .45);
  backdrop-filter: blur(2px);
}

.l2d-loading::before {
  content: '';
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, .25);
  border-top-color: #4fd1a5;
  border-radius: 50%;
  animation: l2d-spin .8s linear infinite;
}

.l2d-loading.err::before {
  display: none;
}

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

/* 触摸特效 */
.l2d-touch-fx {
  position: absolute;
  z-index: 7;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .95), rgba(255, 200, 120, .5) 60%, transparent 70%);
  pointer-events: none;
  animation: l2d-fx .55s ease-out forwards;
}

@keyframes l2d-fx {
  0% { transform: scale(.4); opacity: 1; }
  100% { transform: scale(2.6); opacity: 0; }
}

/* 随机抽取闪光 */
.l2d-flash canvas { transition: filter .3s; }
.l2d-flash::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: radial-gradient(circle at 50% 55%, rgba(255, 255, 255, .85), rgba(255, 255, 255, .15) 40%, transparent 70%);
  animation: l2d-flash-fx .6s ease-out forwards;
}

@keyframes l2d-flash-fx {
  0% { opacity: 0; }
  25% { opacity: 1; }
  100% { opacity: 0; }
}

/* ===== 列表抽屉 ===== */
.l2d-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 998;
  background: rgba(8, 10, 16, .55);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}

.l2d-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 999;
  width: min(420px, 92vw);
  background: var(--card);
  box-shadow: -8px 0 30px rgba(0, 0, 0, .25);
  transform: translateX(105%);
  transition: transform .28s cubic-bezier(.2, .8, .25, 1);
  display: flex;
  flex-direction: column;
}

.l2d-drawer.open {
  transform: translateX(0);
}

.l2d-drawer-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.l2d-drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.l2d-drawer-head h3 {
  margin: 0;
  font-size: 16px;
  flex: 1;
  color: var(--text);
}

.l2d-drawer-head .l2d-close {
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 8px;
}

.l2d-drawer-head .l2d-close:hover {
  background: var(--hover);
  color: var(--text);
}

/* 抽屉 Tab:立绘列表 / 动画展示 */
.l2d-tabs {
  display: flex;
  padding: 8px 16px 0;
  gap: 8px;
}

.l2d-tab {
  flex: 1;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  padding: 8px 0;
  border-radius: 10px 10px 0 0;
  font-size: 14px;
  cursor: pointer;
  border-bottom: none;
  transition: all .15s;
}

.l2d-tab.active {
  background: var(--hover);
  color: var(--primary);
  font-weight: 600;
}

/* 动画展示列表 */
.l2d-motion-box {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.l2d-motion-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s;
}

.l2d-motion-item:hover {
  background: var(--hover);
}

.l2d-motion-label {
  font-size: 14px;
  color: var(--text);
}

.l2d-motion-cat {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

.l2d-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.l2d-search-row {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
}

.l2d-search-row input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
  background: var(--input-bg);
  color: var(--text);
}

.l2d-search-row input:focus {
  border-color: var(--primary);
}

.l2d-search-row .l2d-count {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.l2d-list-box {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.l2d-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s;
}

.l2d-item:hover {
  background: var(--hover);
}

.l2d-item img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(0, 0, 0, .35);
  flex-shrink: 0;
}

.l2d-item-txt {
  min-width: 0;
}

.l2d-item-ship {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.l2d-item-skin {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 移动端 */
@media (max-width: 768px) {
  .l2d-stage { height: min(520px, 118vw); }
  .l2d-controls {
    top: auto;
    bottom: 10px;
    right: 10px;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
  }
  .l2d-controls button { font-size: 12px; padding: 7px 12px; }
  .l2d-zoom button { font-size: 13px; min-width: 30px; padding: 4px 8px; }
  #l2d-btn-zoom-reset { min-width: 38px; }
  .l2d-info { top: 10px; left: 10px; padding: 8px 11px; }
  .l2d-info .l2d-ship { font-size: 15px; }
  .l2d-info .l2d-skin { font-size: 11px; }
  .l2d-drawer { width: 100vw; }
  .l2d-item img { width: 46px; height: 46px; }
  .l2d-list-box { padding: 6px; }
  .l2d-item { padding: 7px 8px; gap: 8px; }
  .l2d-item-ship { font-size: 13px; }
  .l2d-item-skin { font-size: 11px; }

  /* ===== 抽屉头部与动画 tab 移动端适配 ===== */
  .l2d-drawer { padding-top: env(safe-area-inset-top, 0px); }
  .l2d-drawer-head { padding: 10px 12px; }
  .l2d-drawer-head h3 { font-size: 15px; }
  .l2d-drawer-head .l2d-close {
    width: 44px;
    height: 44px;
    font-size: 22px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  /* tab 变胶囊分段控件:全圆角、44px 大触区、轻按下反馈 */
  .l2d-tabs {
    padding: 8px 10px 0;
    gap: 6px;
  }
  .l2d-tab {
    padding: 12px 0;
    font-size: 14px;
    border-radius: 12px;
    border-bottom: 1px solid var(--border);
    -webkit-tap-highlight-color: transparent;
  }
  .l2d-tab:active {
    background: var(--hover);
    color: var(--primary);
  }
  /* 动画列表项:48px 触控目标 + 按压反馈 */
  .l2d-motion-box { padding: 6px; }
  .l2d-motion-item {
    min-height: 48px;
    padding: 10px 12px;
    gap: 8px;
  }
  .l2d-motion-item:active { background: var(--hover); }
  .l2d-motion-label {
    font-size: 14px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .l2d-motion-cat {
    font-size: 10px;
    padding: 3px 8px;
    flex-shrink: 0;
  }
  /* 搜索框:移动端 44px 高、16px 字号防 iOS 缩放 */
  .l2d-search-row {
    padding: 8px 10px;
    gap: 6px;
  }
  .l2d-search-row input {
    height: 44px;
    padding: 10px 12px;
    font-size: 16px;
    border-radius: 10px;
  }
  .l2d-empty { padding: 20px 12px; }
}
