/* ==========================================================================
   首页访客 IP 提示条（配合 source/js/ip-greeting.js）
   配色与博客自定义色板一致（#567bbd 蓝系 / 暗色 #8ca5d7），浅暗两态。
   动效：丝滑浮现（回弹曲线 + 轻微上浮 + 光影过渡），几秒后自动丝滑收起。
   ========================================================================== */

.ipg-bar {
  /* ---------- 主题变量派生 ---------- */
  --ipg-bg: var(--board-bg-color);
  --ipg-bg-mix: color-mix(in srgb, var(--board-bg-color) 86%, #567bbd 14%);
  --ipg-border: color-mix(in srgb, var(--line-color) 55%, #567bbd 45%);
  --ipg-text: var(--text-color);
  --ipg-muted: var(--sec-text-color);
  --ipg-accent: #567bbd;
  --ipg-accent-soft: rgba(86, 123, 189, 0.13);

  position: fixed;
  top: 72px;
  left: 50%;
  z-index: 1040; /* 高于 Fluid header 的 1029 */

  display: flex;
  align-items: center;
  gap: 9px;
  /* width:max-content 让容器按内容撑开；max-width 防止长地名撑出屏幕 */
  width: max-content;
  max-width: calc(100vw - 28px);
  padding: 7px 7px 7px 13px;

  border: 1px solid var(--ipg-border);
  border-radius: 999px;
  background: var(--ipg-bg);
  background: var(--ipg-bg-mix);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow:
    0 6px 22px rgba(40, 60, 110, 0.10),
    0 1px 0 rgba(255, 255, 255, 0.35) inset;

  color: var(--ipg-text);
  font-size: 14px;
  line-height: 1.5;
  white-space: nowrap;

  /* 初始态：上移 + 轻微缩小 + 模糊，配合 opacity 做玻璃溶入 */
  opacity: 0;
  transform: translate(-50%, -16px) scale(0.96);
  filter: blur(4px);
  pointer-events: none;
  transition:
    opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.55s ease,
    border-color 0.25s ease,
    box-shadow 0.25s ease;
}

.ipg-bar.is-in {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  filter: blur(0);
  pointer-events: auto;
}

.ipg-bar.is-out {
  opacity: 0;
  transform: translate(-50%, -14px) scale(0.97);
  filter: blur(3px);
  pointer-events: none;
  /* 收起比浮现利落一点 */
  transition:
    opacity 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    filter 0.45s ease;
}

/* ---------- 定位图标：悬浮光晕呼吸 ---------- */
.ipg-icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--ipg-accent-soft);
  color: var(--ipg-accent);
  animation: ipg-pulse 3.2s ease-in-out infinite;
}

@keyframes ipg-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(86, 123, 189, 0.30); }
  55%      { box-shadow: 0 0 0 6px rgba(86, 123, 189, 0); }
}

/* ---------- 文案 ---------- */
.ipg-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ipg-text b {
  color: var(--ipg-accent);
  font-weight: 600;
}

/* ---------- IP ---------- */
.ipg-ip {
  flex: none;
  padding-left: 9px;
  border-left: 1px solid var(--ipg-border);
  color: var(--ipg-muted);
  font-family: Consolas, ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  letter-spacing: 0.01em;
}

/* IP 还没查到时不要留空位和分隔线 */
.ipg-ip:empty {
  display: none;
}

/* ---------- 关闭按钮 ---------- */
.ipg-close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ipg-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.ipg-close:hover {
  background: var(--ipg-accent-soft);
  color: var(--ipg-accent);
  transform: rotate(90deg);
}

/* ---------- 整条 hover 微浮（提示可交互）---------- */
.ipg-bar.is-in:hover {
  box-shadow:
    0 10px 28px rgba(40, 60, 110, 0.16),
    0 1px 0 rgba(255, 255, 255, 0.35) inset;
  border-color: color-mix(in srgb, var(--line-color) 40%, #567bbd 60%);
}

/* ---------- 暗色：跟着主题走 ---------- */
[data-user-color-scheme='dark'] .ipg-bar {
  --ipg-bg-mix: color-mix(in srgb, var(--board-bg-color) 86%, #8ca5d7 14%);
  --ipg-border: color-mix(in srgb, var(--line-color) 50%, #8ca5d7 50%);
  --ipg-accent: #8ca5d7;
  --ipg-accent-soft: rgba(140, 165, 215, 0.18);
  box-shadow:
    0 6px 22px rgba(0, 0, 0, 0.34),
    0 1px 0 rgba(255, 255, 255, 0.06) inset;
}

[data-user-color-scheme='dark'] .ipg-icon {
  animation-name: ipg-pulse-dark;
}

@keyframes ipg-pulse-dark {
  0%, 100% { box-shadow: 0 0 0 0 rgba(140, 165, 215, 0.35); }
  55%      { box-shadow: 0 0 0 6px rgba(140, 165, 215, 0); }
}

@media (prefers-color-scheme: dark) {
  html:not([data-user-color-scheme='light']) .ipg-bar {
    --ipg-bg-mix: color-mix(in srgb, var(--board-bg-color) 86%, #8ca5d7 14%);
    --ipg-border: color-mix(in srgb, var(--line-color) 50%, #8ca5d7 50%);
    --ipg-accent: #8ca5d7;
    --ipg-accent-soft: rgba(140, 165, 215, 0.18);
    box-shadow:
      0 6px 22px rgba(0, 0, 0, 0.34),
      0 1px 0 rgba(255, 255, 255, 0.06) inset;
  }
}

/* ---------- 减弱动效偏好：直接显示/消失，无呼吸 ---------- */
@media (prefers-reduced-motion: reduce) {
  .ipg-bar,
  .ipg-bar.is-in,
  .ipg-bar.is-out {
    transition: opacity 0.25s ease;
    transform: translate(-50%, 0) !important;
    filter: none !important;
  }
  .ipg-icon { animation: none; }
  .ipg-close:hover { transform: none; }
}

/* ---------- 移动端 ---------- */
@media (max-width: 576px) {
  /* 窄屏一行装不下「文案 + IP」，改用两行 grid：
     第一行 图标 + 文案 + 关闭，第二行 IP 居中 */
  .ipg-bar {
    top: 64px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "icon text close"
      "ip   ip   ip";
    align-items: center;
    row-gap: 1px;
    column-gap: 7px;
    padding: 6px 8px 6px 10px;
    font-size: 13px;
    white-space: normal;
  }

  .ipg-icon {
    grid-area: icon;
    width: 23px;
    height: 23px;
  }

  .ipg-text {
    grid-area: text;
    text-align: center;
  }

  .ipg-ip {
    grid-area: ip;
    padding-left: 0;
    border-left: 0;
    text-align: center;
    font-size: 11px;
  }

  .ipg-close {
    grid-area: close;
  }
}
