/* ============================================================
   学序 2.0 R3 · 任务卡左滑操作（SwipeableCard）
   ------------------------------------------------------------
   - 操作层在卡片「下面」：卡片 surface 左移后露出右侧操作区；
   - 操作层用真实玻璃材质（复用 glass-controls.css 的 --gc-* 令牌：
     半透明底 + 顶部高光 + 0.5px 暗边 + backdrop blur），
     不是三块实色按钮；每个操作再叠一层按 tone 的 tint；
   - 卡片只做水平位移，纵向滚动完全交给页面（touch-action: pan-y）；
   - 吸附/回弹曲线用 spring，和 Tabbar/控件层一致；
   - 桌面（>900px）不启用：操作层与「更多操作」入口都隐藏；
   - 深色 / 降低动效 / 降低透明度 / 高对比度有降级。
   ============================================================ */

:root {
  --swipe-action-width: 68px;
  --swipe-spring: cubic-bezier(0.22, 1.35, 0.36, 1);

  /* 各 tone 的「玻璃 tint + 可读 ink」，都基于半透明，保证下面是玻璃不是色块 */
  --swipe-ok-ink: #1f7a3d;
  --swipe-ok-tint: rgba(47, 158, 68, 0.16);
  --swipe-accent-tint: rgba(10, 108, 255, 0.14);
  --swipe-danger-tint: rgba(194, 37, 92, 0.16);
  --swipe-neutral-tint: rgba(15, 23, 42, 0.07);
}

:root[data-theme="dark"] {
  --swipe-ok-ink: #86e0a5;
  --swipe-ok-tint: rgba(47, 158, 68, 0.24);
  --swipe-accent-tint: rgba(84, 151, 255, 0.22);
  --swipe-danger-tint: rgba(255, 107, 157, 0.22);
  --swipe-neutral-tint: rgba(255, 255, 255, 0.09);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --swipe-ok-ink: #86e0a5;
    --swipe-ok-tint: rgba(47, 158, 68, 0.24);
    --swipe-accent-tint: rgba(84, 151, 255, 0.22);
    --swipe-danger-tint: rgba(255, 107, 157, 0.22);
    --swipe-neutral-tint: rgba(255, 255, 255, 0.09);
  }
}

/* ---------------- 外壳：操作层与卡片的叠放上下文 ---------------- */
.swipe-card {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: var(--mat-surface, var(--surface));
}

/* ---------------- 右侧操作区：玻璃底板（默认被 surface 盖住） ---------------- */
.swipe-card-actions {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  pointer-events: none;
  background-color: var(--gc-bg, rgba(255, 255, 255, 0.58));
  background-image: linear-gradient(
    180deg,
    var(--gc-highlight, rgba(255, 255, 255, 0.82)) 0%,
    rgba(255, 255, 255, 0) 58%
  );
  -webkit-backdrop-filter: blur(var(--gc-blur-sm, 12px)) saturate(var(--gc-saturate, 180%));
  backdrop-filter: blur(var(--gc-blur-sm, 12px)) saturate(var(--gc-saturate, 180%));
  box-shadow:
    inset 0 0.5px 0 var(--gc-highlight, rgba(255, 255, 255, 0.82)),
    inset 1px 0 0 var(--gc-border, rgba(15, 23, 42, 0.11));
}
.swipe-card[data-open="true"] .swipe-card-actions {
  pointer-events: auto;
}

.swipe-card-action {
  position: relative;
  width: var(--swipe-action-width);
  flex: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 0.5px solid var(--gc-border, rgba(15, 23, 42, 0.11));
  border-radius: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background-color: transparent;
  background-image: none;
  color: var(--gc-ink-muted, var(--text-2));
  font: inherit;
  font-size: 11.5px;
  font-weight: 620;
  line-height: 1.15;
  letter-spacing: 0.01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transform: scale(1);
  transition:
    background-color 0.16s ease,
    color 0.16s ease,
    transform 0.28s var(--gc-spring, var(--swipe-spring));
}
/* 每颗操作自己的顶部高光：玻璃感来自「半透明 tint + 高光 + 暗边」，而不是实色 */
.swipe-card-action::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.4) 0%,
    rgba(255, 255, 255, 0) 52%
  );
  opacity: 0.6;
}
.swipe-card-action > * {
  position: relative;
}
.swipe-card-action[data-tone="ok"] {
  color: var(--swipe-ok-ink);
  background-color: var(--swipe-ok-tint);
}
.swipe-card-action[data-tone="accent"] {
  color: var(--accent-text);
  background-color: var(--swipe-accent-tint);
}
.swipe-card-action[data-tone="danger"] {
  color: var(--gc-danger-ink, var(--danger-2));
  background-color: var(--swipe-danger-tint);
}
.swipe-card-action[data-tone="neutral"] {
  color: var(--gc-ink-muted, var(--text-2));
  background-color: var(--swipe-neutral-tint);
}
.swipe-card-action:hover {
  filter: saturate(1.06) brightness(1.03);
}
.swipe-card-action:active {
  transform: scale(0.94);
  transition-duration: 0.09s;
  transition-timing-function: ease-out;
}
.swipe-card-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}
.swipe-card-action-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.96;
}
.swipe-card-action-label {
  display: block;
  white-space: nowrap;
}

/* ---------------- 卡片本体：可平移的 surface ---------------- */
.swipe-card-surface {
  position: relative;
  z-index: 1;
  background: var(--mat-surface, var(--surface));
  /* 只允许纵向滚动：横向手势由 JS 接管，避免浏览器抢去当横向平移 */
  touch-action: pan-y;
  transform: translate3d(0, 0, 0);
  transition:
    transform 0.36s var(--swipe-spring),
    box-shadow 0.24s ease;
  will-change: transform;
}
.swipe-card[data-open="true"] .swipe-card-surface {
  box-shadow: -10px 0 22px rgba(15, 23, 42, 0.1);
}

/* 展开时点卡片内容 = 收起（不触发内容里的按钮，再次点击才生效） */
.swipe-card-scrim {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ---------------- 行分隔线：包了一层之后 :last-child 需要修正 ---------------- */
.card > .swipe-card:not(:last-child) .assign-item::after {
  display: block;
}
.card > .swipe-card:last-child .assign-item::after {
  display: none;
}
/* 卡片内行不再叠加自己的底边，发丝线统一由 ::after 画 */
.swipe-card .assign-item {
  border-bottom: 0 !important;
}

/* ---------------- trailing「更多操作」入口：桌面隐藏，手机显示 ---------------- */
.assign-more-btn {
  display: none;
}

/* ---------------- 桌面：完全不启用 ---------------- */
@media (min-width: 901px) {
  .swipe-card {
    background: transparent;
  }
  .swipe-card-actions {
    display: none;
  }
  .swipe-card-surface {
    transform: none !important;
    transition: none;
    touch-action: auto;
    will-change: auto;
  }
  .swipe-card[data-open="true"] .swipe-card-surface {
    box-shadow: none;
  }
}

@media (max-width: 900px) {
  .assign-more-btn {
    display: inline-flex;
    align-items: center;
  }
}

/* ---------------- 无障碍降级 ---------------- */
@media (prefers-reduced-motion: reduce) {
  .swipe-card-surface,
  .swipe-card-action {
    transition: none !important;
  }
}
@media (prefers-reduced-transparency: reduce) {
  .swipe-card,
  .swipe-card-surface {
    background: var(--mat-surface, var(--surface));
  }
  .swipe-card-actions {
    background-color: var(--surface-2, var(--surface));
    background-image: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .swipe-card-action[data-tone="ok"] {
    background-color: color-mix(in srgb, var(--swipe-ok-ink) 16%, var(--surface-2, #fff));
  }
  .swipe-card-action[data-tone="accent"] {
    background-color: color-mix(in srgb, var(--accent) 16%, var(--surface-2, #fff));
  }
  .swipe-card-action[data-tone="danger"] {
    background-color: color-mix(in srgb, var(--danger-2) 16%, var(--surface-2, #fff));
  }
  .swipe-card-action::before {
    display: none;
  }
}
@media (prefers-contrast: more) {
  .swipe-card-action {
    border-left-color: color-mix(in srgb, var(--text) 34%, transparent);
  }
  .swipe-card-action[data-tone="ok"],
  .swipe-card-action[data-tone="accent"],
  .swipe-card-action[data-tone="danger"],
  .swipe-card-action[data-tone="neutral"] {
    color: var(--text);
  }
}
