/* ==========================================================================
   加密文章外观（hexo-blog-encrypt 4.x）

   插件自带 default 主题是透明输入框 + 蓝色渐变按钮，跟本站在用的
   --btf-* 令牌体系不搭；这里只覆盖配色与排版，不动解密逻辑。

   选择器统一带 #hexo-blog-encrypt 前缀：
     1. 压过插件自带的单类规则，不依赖 CSS 加载顺序；
     2. 只作用于加密容器，不影响正文。
   深色模式跟随站点 data-theme，而不是插件的 prefers-color-scheme。
   ========================================================================== */

#hexo-blog-encrypt.hbe-container {
  margin: 0 auto;
  padding: 8px 0 28px;
}

#hexo-blog-encrypt .hbe-content {
  max-width: 360px;
  margin: 0 auto;
  padding: 0;
  font-size: 0.95rem;
  text-align: left;
}

#hexo-blog-encrypt .hbe-form {
  align-items: stretch;
}

/* 输入区：DOM 里是 input + label，反转后让「请输入密码」落在输入框上方 */
#hexo-blog-encrypt .hbe-input,
#hexo-blog-encrypt .hbe-input-default {
  display: flex;
  flex-direction: column-reverse;
  width: 100%;
  min-width: 0;
  margin: 0 0 14px;
  overflow: visible;
}

#hexo-blog-encrypt .hbe-input-field,
#hexo-blog-encrypt .hbe-input-field-default {
  float: none;
  width: 100%;
  margin: 0;
  padding: 10px 14px;
  opacity: 1;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--btf-font-color);
  background: var(--btf-second-bg);
  border: 1px solid var(--btf-card-border);
  border-radius: var(--btf-radius-sm);
  transition: border-color var(--btf-transition), background var(--btf-transition);
}

#hexo-blog-encrypt .hbe-input-field:focus,
#hexo-blog-encrypt .hbe-input-field-default:focus {
  outline: none;
  background: var(--btf-card-bg);
  border-color: var(--btf-theme);
}

#hexo-blog-encrypt .hbe-input-label,
#hexo-blog-encrypt .hbe-input-label-default {
  position: static;
  float: none;
  width: 100%;
  margin: 0;
  padding: 0 0 8px;
  font-size: 0.9rem;
  font-weight: 400;
  text-align: left;
  color: var(--btf-second-text);
  pointer-events: none;
}

/* default 主题靠这两层伪元素做下划线动画，这里不需要 */
#hexo-blog-encrypt .hbe-input-label-default::before,
#hexo-blog-encrypt .hbe-input-label-default::after {
  content: none;
}

#hexo-blog-encrypt .hbe-input-label-content,
#hexo-blog-encrypt .hbe-input-label-content-default {
  padding: 0;
  font-size: 1em;
  font-weight: 400;
  color: var(--btf-second-text);
  transform: none;
}

#hexo-blog-encrypt .hbe-button {
  align-self: center;
  margin: 0;
  padding: 8px 24px;
  min-width: 0;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.6;
  color: var(--btf-nav-hover-text);
  background: var(--btf-theme);
  border: none;
  border-radius: var(--btf-radius-pill);
  cursor: pointer;
  transition: opacity var(--btf-transition);
}

#hexo-blog-encrypt .hbe-button:hover,
#hexo-blog-encrypt .hbe-button:focus {
  background: var(--btf-theme);
  opacity: 0.85;
  box-shadow: none;
}

#hexo-blog-encrypt .hbe-button[aria-busy="true"] {
  opacity: 0.7;
}

#hexo-blog-encrypt .hbe-error {
  margin: 10px 0 0;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.85rem;
  border-radius: var(--btf-radius-sm);
}

[data-theme="light"] #hexo-blog-encrypt .hbe-error {
  color: #c0392b;
}

[data-theme="light"] #hexo-blog-encrypt .hbe-error:not(:empty) {
  background: rgba(192, 57, 43, 0.08);
}

[data-theme="dark"] #hexo-blog-encrypt .hbe-error {
  color: #ff8a8a;
}

[data-theme="dark"] #hexo-blog-encrypt .hbe-error:not(:empty) {
  background: rgba(255, 138, 138, 0.12);
}

/* 用记住的密码自动解锁时，正文上方会出现「忘记已保存的密钥」 */
#hexo-blog-encrypt .hbe-forget {
  margin: 0 0 12px;
  font: inherit;
  font-size: 0.8rem;
  color: var(--btf-second-text);
  text-align: right;
}

#hexo-blog-encrypt .hbe-forget-button {
  padding: 2px 10px;
  font: inherit;
  font-size: 0.8rem;
  color: var(--btf-second-text);
  background: transparent;
  border: 1px solid var(--btf-card-border);
  border-radius: var(--btf-radius-pill);
  cursor: pointer;
}

#hexo-blog-encrypt.hbe-decrypted-content {
  padding: 0;
}

/* --------------------------------------------------------------------------
   「忘记已保存的密钥」挪到文章头部之后

   位置由 post-encrypt.js 决定（追加进 #post-firstinfo .meta-firstline），
   这里只负责让它和「原创 / 闲聊杂谈」那排胶囊同一套视觉：
   32px 高、pill 圆角、半透明底、跟随那一行的文字色。

   两套配色是因为头部有两种形态：有封面图时是白字压在图上，没封面时是
   浅底深字。默认规则跟随 currentColor，封面规则再把白字套回来。
   -------------------------------------------------------------------------- */

#post-firstinfo .meta-firstline .hbe-forget {
  display: flex;
  align-items: center;
  margin: 0 0 0 20px;
  text-align: left;
}

/* 无封面时的兜底：跟随头部文字色 */
#post-firstinfo .meta-firstline .hbe-forget-button {
  height: 32px;
  margin: 0;
  padding: 0 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  line-height: 32px;
  color: inherit;
  background: color-mix(in srgb, currentColor 14%, transparent);
  border: none;
  border-radius: var(--btf-radius-pill);
  cursor: pointer;
  transition: background-color .3s ease, color .3s ease;
}

#post-firstinfo .meta-firstline .hbe-forget-button:hover,
#post-firstinfo .meta-firstline .hbe-forget-button:focus-visible {
  background: color-mix(in srgb, currentColor 26%, transparent);
  outline: none;
}

/* 有封面图：与「原创 / 闲聊杂谈」的胶囊完全一致 */
.post #page-header.post-bg:not(.not-top-img) #post-firstinfo .meta-firstline .hbe-forget-button {
  color: var(--btf-white);
  background: var(--btf-header-white-op);
}

.post #page-header.post-bg:not(.not-top-img) #post-firstinfo .meta-firstline .hbe-forget-button:hover,
.post #page-header.post-bg:not(.not-top-img) #post-firstinfo .meta-firstline .hbe-forget-button:focus-visible {
  color: var(--btf-header-theme);
  background: var(--btf-white);
}

/* 点完之后按钮消失，原地留下「已忘记已保存的密钥.」 */
#post-firstinfo .meta-firstline .hbe-forget [role="status"] {
  color: inherit;
  font-size: 13px;
  line-height: 32px;
  opacity: .75;
}

.post #page-header.post-bg:not(.not-top-img) #post-firstinfo .meta-firstline .hbe-forget [role="status"] {
  color: var(--btf-white);
}

/* 插件用 script 给它 focus()，鼠标点完会多出一个方框，压掉；
   role="status" 本身仍然会让读屏软件播报这条提示 */
#post-firstinfo .meta-firstline .hbe-forget [role="status"]:focus,
#post-firstinfo .meta-firstline .hbe-forget [role="status"]:focus-visible {
  outline: none;
}
