/* ==========================================================================
   CONTACT RAIL  —  右侧固定联系栏
   桌面：右侧竖排，hover 向左展开文字
   手机：底部通栏，三等分
   ========================================================================== */

.rail {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

.rail__item {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 54px;
  padding: 0 17px;
  border: 0;
  border-radius: 10px 0 0 10px;
  color: #fff;
  font-family: Poppins-Medium, Arial, sans-serif;
  font-size: 13px;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .16);
  transition: background-color .25s;
}

.rail__ico {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
}

.rail__ico i {
  font-size: 20px;
  line-height: 1;
}

.rail__text {
  color: #fff;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  letter-spacing: .01em;
  transition: max-width .38s cubic-bezier(.4, 0, .2, 1), opacity .22s, padding-right .38s;
}

.rail__item:hover .rail__text,
.rail__item:focus-visible .rail__text {
  max-width: 280px;
  opacity: 1;
  padding-right: 12px;
}

.rail__item:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -4px;
}

/* 三个入口的配色 */
.rail__item--mail { background: #003c92; }
.rail__item--mail:hover { background: #004bb5; }

.rail__item--wa { background: #086200; }
.rail__item--wa:hover { background: #0a7a00; }

.rail__item--top { background: #1a1a1a; }
.rail__item--top:hover { background: #333333; }

/* 未滚动时隐藏「回到顶部」 */
.rail--at-top .rail__item--top {
  opacity: 0;
  transform: translateX(12px);
  pointer-events: none;
}

.rail__item--top {
  transition: background-color .25s, opacity .3s, transform .3s;
}

/* ---------- 手机：底部通栏 ---------- */
@media screen and (max-width: 767px) {
  .rail {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    transform: none;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    height: 56px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, .14);
  }

  .rail__item {
    flex: 1 1 0;
    height: 56px;
    justify-content: center;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
  }

  .rail__item .rail__text { display: none; }

  .rail__ico i { font-size: 22px; }

  .rail--at-top .rail__item--top {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }

  /* 避免底部栏遮住页脚最后一行 */
  body { padding-bottom: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  .rail__text, .rail__item { transition: none; }
}
