/* ==========================================================================
   自定义右键菜单 —— 样式
   由 source/css/rightmenu.css 提供（该文件不会被编译，原样输出到 /css/rightmenu.css）
   在 _config.butterfly.yml 的 inject.head 中引入
   ========================================================================== */

/* 全屏遮罩：拦住菜单打开时的误点击，点击即关闭 */
#rightmenu-mask {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  background: transparent;
}

#rightMenu {
  /* -------------------- 浅色（默认） -------------------- */
  --rcm-bg: #ffffff;
  --rcm-nav-bg: #fafafa;
  --rcm-text: #1f1f1f;
  --rcm-line: rgba(0, 0, 0, 0.07);
  --rcm-border: rgba(0, 0, 0, 0.08);
  --rcm-hover-bg: #1a1a1a;
  --rcm-hover-text: #ffffff;
  --rcm-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);

  position: fixed;
  z-index: 2001;
  display: none;
  box-sizing: border-box;
  width: 200px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--rcm-border);
  border-radius: 12px;
  background: var(--rcm-bg);
  box-shadow: var(--rcm-shadow);
  color: var(--rcm-text);
  font-size: 14px;
  line-height: 1.4;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* -------------------- 深色模式：黑底白字，悬浮为黄色 -------------------- */
html[data-theme='dark'] #rightMenu {
  --rcm-bg: #0d0d0d;
  --rcm-nav-bg: #161616;
  --rcm-text: #ffffff;
  --rcm-line: rgba(255, 255, 255, 0.12);
  --rcm-border: rgba(255, 255, 255, 0.16);
  --rcm-hover-bg: #f5d94a;
  --rcm-hover-text: #111111;
  --rcm-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
}

#rightMenu *,
#rightMenu *::before,
#rightMenu *::after {
  box-sizing: border-box;
}

/* 分组：隐藏的分组不占位，因此分割线跟随"当前可见"的分组 */
#rightMenu .rcm-group {
  padding: 5px;
}

#rightMenu .rcm-group + .rcm-group {
  border-top: 1px solid var(--rcm-line);
}

/* 顶部图标组（前进/后退/刷新/回顶） */
#rightMenu .rcm-group.rcm-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  background: var(--rcm-nav-bg);
}

/* 通用菜单项 */
#rightMenu .rcm-item {
  display: flex;
  align-items: center;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  color: inherit;
  font-size: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease;
}

#rightMenu .rcm-item > i {
  flex: 0 0 auto;
  width: 20px;
  margin-right: 10px;
  font-size: 15px;
  text-align: center;
}

#rightMenu .rcm-item > span {
  flex: 1 1 auto;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#rightMenu .rcm-item:hover,
#rightMenu .rcm-item:focus-visible {
  background: var(--rcm-hover-bg);
  color: var(--rcm-hover-text);
  outline: none;
}

/* 顶部图标项：等宽居中，无文字 */
#rightMenu .rcm-nav .rcm-item {
  flex: 1 1 0;
  justify-content: center;
  height: 36px;
  padding: 0;
}

#rightMenu .rcm-nav .rcm-item > i {
  width: auto;
  margin: 0;
  font-size: 16px;
}

/* -------------------- 轻提示 -------------------- */
.rcm-toast {
  position: fixed;
  left: 50%;
  bottom: 64px;
  z-index: 3000;
  padding: 8px 16px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.82);
  color: #ffffff;
  font-size: 13px;
  line-height: 1.4;
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.rcm-toast.rcm-toast--show {
  opacity: 1;
  transform: translate(-50%, 0);
}

html[data-theme='dark'] .rcm-toast {
  background: #f5d94a;
  color: #111111;
}
