/* ==========================================================================
   Alpha Club · 交互微调层
   --------------------------------------------------------------------------
   按 oil-ui「三处基本动效」补齐，复用 style.css 里已有的设计变量，
   不新造体系、不覆盖品牌资产。

     1) 主操作反馈      —— 按下立刻回应，松开回弹
     2) 状态切换的来路  —— 分类切换用会移动的滑块
     3) 首次进入的出场  —— 列表按阅读顺序依次出现

   另含跨页过渡（列表 → 文章落地页）与「减少动态效果」降级。
   ========================================================================== */

:root {
  /* 按压：面积越大，缩得越少（过冲幅度跟着面积走） */
  --press-scale-sm: 0.96;   /* 药丸、图标按钮 */
  --press-scale-md: 0.975;  /* 常规按钮 */
  --press-scale-lg: 0.992;  /* 卡片、大块面 */
  --press-in: 80ms;         /* 按下立即生效 */
  --press-out: 200ms;       /* 松开回弹 */
  --ease-soft: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-fast: cubic-bezier(0.4, 0, 1, 1);
}

/* --------------------------------------------------------------------------
   1) 主操作反馈
   -------------------------------------------------------------------------- */

/* 补齐现有 :active 未覆盖的交互元素，统一时序：
   按下走 80ms 加速曲线立即到位，松开走 200ms 减速曲线回弹 */
.article-cat-pill,
.article-card,
.btn-card-quick-edit,
.vibe-nav-link,
.vibe-user-slot,
.vibe-collapse-btn,
.palette-cat-pill,
.palette-course-item {
  transition:
    transform var(--press-out) var(--ease-soft),
    background-color 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    box-shadow 150ms ease,
    opacity 150ms ease;
}

.article-cat-pill:active,
.btn-card-quick-edit:active,
.vibe-nav-link:active,
.vibe-user-slot:active,
.vibe-collapse-btn:active {
  transform: scale(var(--press-scale-sm));
  transition-duration: var(--press-in);
  transition-timing-function: var(--ease-in-fast);
}

/* 卡片面积大，只做极轻微下压 + 下沉，避免整块画面晃动 */
.article-card:active {
  transform: translateY(1px) scale(var(--press-scale-lg));
  transition-duration: var(--press-in);
  transition-timing-function: var(--ease-in-fast);
}

/* 药丸选中态：给一次轻微的到位弹动，只在切换那一刻播放 */
.article-cat-pill.active,
.post-cat-pill.active {
  animation: pill-settle 260ms var(--ease-soft);
}
@keyframes pill-settle {
  0%   { transform: scale(0.94); }
  60%  { transform: scale(1.015); }
  100% { transform: scale(1); }
}

/* --------------------------------------------------------------------------
   2) 状态切换的来路：分类切换用一块会移动的滑块
   --------------------------------------------------------------------------
   由 community.js 在切换时更新 --glider-x / --glider-w，
   旧的熄灭、新的点亮改成同一块底板滑过去。
   -------------------------------------------------------------------------- */

.cat-pill-wrap {
  position: relative;
}

.cat-pill-glider {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: var(--glider-w, 0px);
  transform: translate3d(var(--glider-x, 0px), 0, 0);
  border-radius: 7px;
  background: #ffffff;
  box-shadow: 0 1px 8px rgba(255, 255, 255, 0.14);
  pointer-events: none;
  z-index: 0;
  transition:
    transform 280ms var(--ease-soft),
    width 280ms var(--ease-soft),
    opacity 160ms ease;
  opacity: 0;
}
.cat-pill-glider.ready {
  opacity: 1;
}

/* 滑块之下，药丸自身不再画选中底色，只负责文字颜色 */
.cat-pill-wrap .article-cat-pill,
.cat-pill-wrap .post-cat-pill {
  position: relative;
  z-index: 1;
  background: transparent !important;
  box-shadow: none !important;
}

/* --------------------------------------------------------------------------
   3) 首次进入的出场：列表按阅读顺序依次出现
   -------------------------------------------------------------------------- */

@keyframes enter-rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.enter-stagger > * {
  animation: enter-rise 380ms var(--ease-soft) backwards;
  animation-delay: calc(var(--i, 0) * 45ms);
}

/* 首屏主角先到，其余跟上（间隔 45ms，总长不超过 600ms） */
@media (prefers-reduced-motion: no-preference) {
  .enter-stagger > *:nth-child(n + 11) {
    animation-delay: 450ms;
  }
}

/* --------------------------------------------------------------------------
   悬停上浮：现有卡片只有 -1px，抬到 2–3px 并让阴影同步加深
   -------------------------------------------------------------------------- */

@media (hover: hover) {
  .article-card-claude:hover {
    transform: translateY(-2px);
  }
  .article-card-claude:active {
    transform: translateY(0) scale(var(--press-scale-lg));
    box-shadow: 0 4px 14px -6px rgba(0, 0, 0, 0.5);
  }
}

/* --------------------------------------------------------------------------
   跨页过渡：列表卡片 → 文章落地页，标题接力形变
   -------------------------------------------------------------------------- */

@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 260ms;
  animation-timing-function: var(--ease-soft);
}

/* 减少动态效果：整页过渡直接到位 */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}

/* --------------------------------------------------------------------------
   减少动态效果：所有状态直接到位，不播放动画
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .article-cat-pill,
  .article-card,
  .btn-card-quick-edit,
  .vibe-nav-link,
  .vibe-user-slot,
  .vibe-collapse-btn,
  .article-card-claude {
    transition: background-color 120ms linear, border-color 120ms linear, color 120ms linear !important;
    transform: none !important;
  }
  .article-cat-pill.active,
  .post-cat-pill.active,
  .enter-stagger > * {
    animation: none !important;
  }
  .cat-pill-glider {
    transition: none !important;
  }
}

/* ==========================================================================
   4) 按钮与表单状态
   --------------------------------------------------------------------------
   盘点时发现：:hover 有 120 条规则，但 :disabled 只有 1 条、加载态 0 条、
   表单错误态 0 条。这里补齐，沿用页面已有的 red-500 / emerald-500 语义色。
   ========================================================================== */

/* ---------- 禁用态：看得懂、点不动、不再有悬停反馈 ---------- */

.btn-primary:disabled,
.alpha-gate-submit:disabled,
.alpha-feedback-submit:disabled,
.alpha-auth-submit:disabled,
.comment-submit:disabled,
button[disabled]:not([aria-busy="true"]) {
  opacity: 0.42;
  cursor: not-allowed;
  filter: grayscale(0.35);
  box-shadow: none !important;
}

/* 禁用时不再响应悬停与按压，避免"看起来还能点" */
.btn-primary:disabled:hover,
.btn-primary:disabled:active,
.alpha-gate-submit:disabled:hover,
.alpha-feedback-submit:disabled:hover,
.comment-submit:disabled:hover,
button[disabled]:hover,
button[disabled]:active {
  transform: none !important;
}

/* ---------- 加载态：同一位置转圈，宽度不跳 ---------- */

[data-loading="true"],
.is-loading {
  pointer-events: none;
  cursor: progress;
  opacity: 0.78;
}

[data-loading="true"]::after,
.is-loading::after {
  content: "";
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-left: 8px;
  vertical-align: -2px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 640ms linear infinite;
}

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

/* 深色底上的按钮用浅色描边，浅色底上的按钮用深色描边 */
[data-loading="true"]::after,
.is-loading::after {
  opacity: 0.85;
}

/* ---------- 输入框：悬停、禁用、错误 ---------- */

.alpha-field,
input[type="email"],
input[type="password"],
input[type="text"],
textarea {
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease;
}

/* 悬停时轻微提亮边框，提示"这里可以输入" */
@media (hover: hover) {
  input[type="email"]:not(:disabled):not([aria-invalid="true"]):hover,
  input[type="password"]:not(:disabled):not([aria-invalid="true"]):hover,
  input[type="text"]:not(:disabled):not([aria-invalid="true"]):hover,
  textarea:not(:disabled):not([aria-invalid="true"]):hover {
    border-color: rgba(255, 255, 255, 0.22);
  }
}

input:disabled,
textarea:disabled,
select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background-color: rgba(255, 255, 255, 0.02) !important;
}

/* 错误态：边框与底色用页面已有的 red-500 语义色 */
input[aria-invalid="true"],
textarea[aria-invalid="true"],
.alpha-field[aria-invalid="true"] {
  border-color: rgba(239, 68, 68, 0.55) !important;
  background-color: rgba(239, 68, 68, 0.06) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.08);
}

input[aria-invalid="true"]:focus,
textarea[aria-invalid="true"]:focus {
  border-color: rgba(239, 68, 68, 0.75) !important;
  outline: none;
}

/* 校验通过：只在错误态之后出现，避免干扰正常输入 */
input[aria-invalid="false"]:not(:placeholder-shown) {
  border-color: rgba(16, 185, 129, 0.4);
}

/* 错误文字：跟着输入框，说明具体哪里不对 */
.field-error {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.5;
  color: rgba(252, 165, 165, 0.9);
}

/* 出错时轻轻推一下输入框，把注意力带过去 */
@keyframes field-nudge {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-4px); }
  45%      { transform: translateX(3px); }
  70%      { transform: translateX(-2px); }
}
.field-shake {
  animation: field-nudge 320ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

/* ---------- 减少动态效果：转圈保留（它是进度指示），其余去掉 ---------- */

@media (prefers-reduced-motion: reduce) {
  .field-shake { animation: none !important; }
  [data-loading="true"]::after,
  .is-loading::after {
    animation-duration: 1.4s;
  }
  input, textarea, select, .btn-primary, .alpha-gate-submit {
    transition: border-color 120ms linear, background-color 120ms linear !important;
  }
}

/* ==========================================================================
   5) 侧栏响应式布局保护 (Sidebar Anti-Overlap Guard)
   --------------------------------------------------------------------------
   确保桌面与平板端 (>= 768px) body 永远让出完整的侧栏宽度，严禁侧栏遮挡内容；
   移动端 (< 768px) 侧栏自动适应为底部轻量悬浮导航栏。
   ========================================================================== */

@media (min-width: 768px) {
  html body.with-vibe-sidebar {
    padding-left: var(--vibe-w, 240px) !important;
    padding-bottom: 0 !important;
  }
}

@media (max-width: 767px) {
  html body.with-vibe-sidebar {
    padding-left: 0 !important;
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* 咨询弹窗层级：高于固定侧栏 (9000) 与所有浮动层 */
#consultationModal.modal-overlay {
  z-index: 99999 !important;
}
