/* ===== iOS 26 液态玻璃底部导航栏 ===== */

.glass-tabbar {
  /* 定位 */
  position: fixed;
  left: 18px;
  right: 18px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 100;

  /* 尺寸与形状 */
  height: 70px;
  border: 0;
  border-radius: 999px;

  /* 布局 */
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 7px;
  isolation: isolate;
  overflow: hidden;

  /* 液态玻璃背景 */
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.16) 31%, transparent 48%),
    radial-gradient(circle at 82% 88%, rgba(205, 231, 255, 0.68), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(243, 248, 255, 0.46));

  /* 多层阴影 */
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.95),
    inset 0 -1px 1px rgba(133, 159, 188, 0.18),
    inset 0 0 22px rgba(255, 255, 255, 0.46),
    0 16px 46px rgba(35, 47, 67, 0.18),
    0 4px 12px rgba(35, 47, 67, 0.08);

  /* 毛玻璃效果 */
  backdrop-filter: blur(34px) saturate(1.75) brightness(1.06);
  -webkit-backdrop-filter: blur(34px) saturate(1.75) brightness(1.06);

  /* 过渡 */
  transition:
    left 0.34s cubic-bezier(0.2, 0.85, 0.2, 1),
    right 0.34s cubic-bezier(0.2, 0.85, 0.2, 1),
    height 0.34s cubic-bezier(0.2, 0.85, 0.2, 1),
    bottom 0.34s cubic-bezier(0.2, 0.85, 0.2, 1),
    padding 0.34s cubic-bezier(0.2, 0.85, 0.2, 1),
    box-shadow 0.34s ease,
    background 0.34s ease;
}

/* 渐变边框 */
.glass-tabbar::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.22) 34%, rgba(95, 152, 210, 0.24) 70%, rgba(255, 255, 255, 0.7));
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  border-radius: inherit;
  pointer-events: none;
  z-index: 3;
}

/* 表面光泽层 */
.glass-tabbar::after {
  content: "";
  position: absolute;
  left: -14%;
  top: -45%;
  width: 130%;
  height: 92%;
  background:
    radial-gradient(ellipse at 28% 46%, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.28) 28%, transparent 60%),
    linear-gradient(100deg, transparent 18%, rgba(255, 255, 255, 0.48), transparent 58%);
  opacity: 0.78;
  transform: rotate(-6deg);
  mix-blend-mode: screen;
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
}

/* ===== 滑动指示器 ===== */
.tab-indicator {
  position: absolute;
  left: 7px;
  top: 7px;
  width: calc((100% - 14px) / 4);
  height: calc(100% - 14px);
  border-radius: 999px;
  overflow: hidden;

  /* 液态玻璃背景 */
  background:
    radial-gradient(circle at 28% 18%, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0.34) 33%, transparent 56%),
    radial-gradient(circle at 74% 88%, rgba(180, 222, 255, 0.62), transparent 48%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(229, 241, 255, 0.62));

  border: 1px solid rgba(255, 255, 255, 0.72);

  /* 发光阴影 */
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.98),
    inset 0 -10px 24px rgba(123, 180, 238, 0.2),
    inset 0 0 18px rgba(255, 255, 255, 0.55),
    0 12px 28px rgba(0, 122, 255, 0.2),
    0 3px 8px rgba(35, 47, 67, 0.08);

  /* 通过 CSS 变量定位 */
  transform: translateX(var(--tab-offset, 0%)) scaleX(1);

  /* 弹性缓动 */
  transition: transform 0.46s cubic-bezier(0.16, 1.08, 0.22, 1);
  z-index: 1;
}

/* 指示器内发光 */
.tab-indicator::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.9), transparent 42%),
    linear-gradient(315deg, rgba(45, 145, 255, 0.18), transparent 46%);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.84),
    inset -1px -1px 0 rgba(80, 136, 195, 0.16);
}

/* 指示器光泽扫过 */
.tab-indicator::after {
  content: "";
  position: absolute;
  left: -42%;
  top: -36%;
  width: 62%;
  height: 172%;
  background: linear-gradient(96deg, transparent, rgba(255, 255, 255, 0.9), transparent);
  filter: blur(5px);
  opacity: 0.68;
  transform: rotate(14deg) translateX(0);
}

/* ===== Tab 按钮 ===== */
.tab-button {
  border: 0;
  background: transparent;
  color: #64748b;
  border-radius: 999px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  position: relative;
  z-index: 2;
  font-size: 11px;
  font-weight: 800;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.72);
  transition:
    color 0.22s ease,
    transform 0.22s ease,
    opacity 0.22s ease,
    filter 0.22s ease;
  -webkit-tap-highlight-color: transparent;
}

.tab-button .tab-icon {
  font-size: 20px;
  line-height: 1;
  transition: transform 0.22s ease, filter 0.22s ease;
}

.tab-button .tab-label {
  line-height: 1;
  transition:
    transform 0.22s ease,
    opacity 0.22s ease,
    height 0.22s ease;
}

.tab-button.is-active {
  color: #007aff;
  transform: translateY(-1px);
  filter: saturate(1.15);
}

.tab-button:not(.is-active) {
  opacity: 0.82;
}

.tab-button.is-active .tab-icon {
  transform: scale(1.08);
  filter: drop-shadow(0 4px 8px rgba(0, 122, 255, 0.2));
}

.tab-button:active {
  transform: scale(0.97);
}

.tab-button.is-active .tab-label {
  transform: translateY(-1px);
}

/* ===== 液态动画 ===== */
@keyframes liquidPill {
  0% {
    transform: translateX(var(--tab-from-offset, 0%)) scaleX(0.82) scaleY(1.08);
  }
  42% {
    transform: translateX(var(--tab-offset, 0%)) scaleX(1.16) scaleY(0.94);
  }
  72% {
    transform: translateX(var(--tab-offset, 0%)) scaleX(0.96) scaleY(1.02);
  }
  100% {
    transform: translateX(var(--tab-offset, 0%)) scaleX(1) scaleY(1);
  }
}

@keyframes liquidSweep {
  from {
    transform: rotate(14deg) translateX(-8%);
    opacity: 0.15;
  }
  48% {
    opacity: 0.9;
  }
  to {
    transform: rotate(14deg) translateX(250%);
    opacity: 0.2;
  }
}

@keyframes liquidGlow {
  0% {
    opacity: 0.72;
  }
  48% {
    opacity: 1;
  }
  100% {
    opacity: 0.78;
  }
}

/* 触发液态动画 */
.glass-tabbar.is-morphing .tab-indicator {
  animation: liquidPill 0.5s cubic-bezier(0.16, 1.08, 0.22, 1);
}

.glass-tabbar.is-morphing .tab-indicator::after {
  animation: liquidSweep 0.52s ease;
}

.glass-tabbar.is-morphing .tab-indicator::before {
  animation: liquidGlow 0.52s ease;
}

/* ===== 收窄模式（滚动时） ===== */
.glass-tabbar.is-condensed {
  left: clamp(56px, 16vw, 84px);
  right: clamp(56px, 16vw, 84px);
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  height: 58px;
  padding: 6px;
}

.glass-tabbar.is-condensed .tab-button {
  gap: 0;
}

.glass-tabbar.is-condensed .tab-button .tab-label {
  height: 0;
  opacity: 0;
  transform: translateY(5px);
  overflow: hidden;
}

/* ===== 无障碍支持 ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
