/* ============================================
   animated-list.css —— 弹簧列表的皮
   ------------------------------------------------------------
   配合 assets/js/animated-list.js。
   所有位置/尺寸/透明度由 JS 每帧写 inline style —— 别在这里写
   transform / height，会被内联样式压住，白写。

   主题：不走 prop，直接跟站内 html[data-theme='dark'] 联动。
   变量名 --al-* 与原版逐字对应，方便对着上游文档查。
   ============================================ */

.animated-list {
  position: relative;
  width: min(100%, var(--al-width));
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  border-radius: calc(var(--al-radius) + 12px);
  color: var(--al-ink);
  -webkit-tap-highlight-color: transparent;

  /* ---- 浅色主题（站内默认底色派生）---- */
  --al-frame: rgba(240, 240, 243, 0.8);
  --al-frame-edge: rgba(24, 24, 27, 0.07);
  --al-frame-highlight: rgba(255, 255, 255, 0.95);
  --al-frame-shadow: 0 22px 44px -22px rgba(24, 24, 27, 0.3), 0 6px 16px -10px rgba(24, 24, 27, 0.16);
  --al-tile: linear-gradient(180deg, #ffffff 0%, #f6f6f8 100%);
  --al-tile-edge: rgba(24, 24, 27, 0.08);
  --al-tile-highlight: rgba(255, 255, 255, 1);
  --al-tile-shadow: 0 4px 10px -5px rgba(24, 24, 27, 0.25);
  --al-well: rgba(24, 24, 27, 0.05);
  --al-ink: #27272a;
  --al-muted: rgba(39, 39, 42, 0.55);
  --al-thumb: rgba(24, 24, 27, 0.16);
  --al-ring: rgba(24, 24, 27, 0.28);
  --al-ring-fill: transparent;
  --al-hover: brightness(0.97);
  --al-press: brightness(0.92);
  --al-active: none;
}

/* ---- 暗色主题（跟站内 html[data-theme='dark'] 走）---- */
html[data-theme='dark'] .animated-list {
  --al-frame: rgba(38, 35, 46, 0.66);
  --al-frame-edge: rgba(255, 255, 255, 0.08);
  --al-frame-highlight: rgba(255, 255, 255, 0.07);
  --al-frame-shadow: 0 22px 44px -20px rgba(0, 0, 0, 0.8), 0 6px 16px -8px rgba(0, 0, 0, 0.5);
  --al-tile: linear-gradient(180deg, #3a3644 0%, #27242f 100%);
  --al-tile-edge: rgba(255, 255, 255, 0.07);
  --al-tile-highlight: rgba(255, 255, 255, 0.12);
  --al-tile-shadow: 0 4px 10px -4px rgba(0, 0, 0, 0.7);
  --al-well: rgba(255, 255, 255, 0.08);
  --al-ink: #f4f4f5;
  --al-muted: rgba(244, 244, 245, 0.55);
  --al-thumb: rgba(255, 255, 255, 0.16);
  --al-ring: rgba(244, 244, 245, 0.3);
  --al-ring-fill: rgba(244, 244, 245, 0.05);
  --al-hover: brightness(1.12);
  --al-press: brightness(0.85);
  --al-active: brightness(1.16);
}

.animated-list--framed {
  padding: 6px;
  background: var(--al-frame);
  box-shadow: var(--al-frame-shadow);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  backdrop-filter: blur(20px) saturate(1.6);
}

.animated-list:has(> .animated-list__viewport:focus-visible) {
  outline: 2px solid var(--al-accent, var(--al-ink));
  outline-offset: 3px;
}

.animated-list__frame-rim {
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  box-shadow:
    inset 0 0 0 1px var(--al-frame-edge),
    inset 0 1px 0 var(--al-frame-highlight);
  pointer-events: none;
}

.animated-list__viewport {
  --al-fade-top: 0px;
  --al-fade-bottom: 0px;
  position: relative;
  box-sizing: border-box;
  padding: 6px;
  overflow-x: hidden;
  overflow-y: auto;
  /* overscroll-behavior 不设 contain（2026-10-20 修滚动 bug）：
     contain 会切断滚动链 —— 列表是不可滚的 overflow:auto 容器时（移动端触摸），
     手势被它吞掉且不传给页面，页面就滚不动了。回归浏览器默认链式滚动：
     内层列表滚到底/本就不可滚时，自然带动页面滚。 */
  overscroll-behavior: auto;
  border-radius: calc(var(--al-radius) + 6px);
  outline: none;
  scrollbar-width: thin;
  scrollbar-color: var(--al-thumb) transparent;
}

.animated-list__viewport::-webkit-scrollbar {
  width: 6px;
}

.animated-list__viewport::-webkit-scrollbar-track {
  background: transparent;
}

.animated-list__viewport::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background: var(--al-thumb);
}

.animated-list__viewport--bare {
  scrollbar-width: none;
}

.animated-list__viewport--bare::-webkit-scrollbar {
  display: none;
}

.animated-list__track {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--al-gap);
}

.animated-list__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 10px 14px 10px 10px;
  box-sizing: border-box;
  border-radius: var(--al-radius);
  background: var(--al-tile);
  box-shadow: var(--al-tile-shadow);
  color: var(--al-ink);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

/* 入场前的初始态：未落位前先藏住，等 JS 发 transition */
.animated-list[data-animated] .animated-list__item:not([data-state]) {
  opacity: 0;
}

@media (hover: hover) {
  .animated-list__item:hover {
    filter: var(--al-hover);
  }
}

.animated-list__item[data-selected]:not(:active) {
  filter: var(--al-active);
}

.animated-list__item:active {
  filter: var(--al-press);
}

.animated-list__lead {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  overflow: hidden;
  border-radius: max(8px, calc(var(--al-radius) - 4px));
  background: var(--al-well);
  color: var(--al-ink);
}

.animated-list__lead svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.animated-list__lead img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.animated-list__text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.animated-list__title {
  overflow: hidden;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.animated-list__description {
  overflow: hidden;
  font-size: 13px;
  line-height: 1.35;
  color: var(--al-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.animated-list__meta {
  flex: none;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--al-muted);
}

.animated-list__rim {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow:
    inset 0 0 0 1px var(--al-tile-edge),
    inset 0 1px 0 var(--al-tile-highlight);
  pointer-events: none;
}

/* 弹簧滑块：JS 每帧改 translate3d + height */
.animated-list__indicator {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  height: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.animated-list__ring {
  position: absolute;
  inset: 0;
  border-radius: var(--al-radius);
  background: var(--al-ring-fill);
  box-shadow: inset 0 0 0 1px var(--al-ring);
}
