/* ============================================================
 * Butterfly 灰白配色（浅色）+ 深蓝顶部导航 + Supabase 评论区样式
 * 通过 themes/butterfly/_config.yml 的 inject.head 引入
 * ============================================================ */

/* ---------- 默认（浅色）：灰白主色调（覆盖 Butterfly 变量） ---------- */
:root {
  --global-bg: #f2f4f6;            /* 页面背景：浅灰 */
  --card-bg: #ffffff;              /* 卡片背景：白色 */
  --font-color: #3f444b;           /* 正文文字：深灰 */
  --card-meta: #8b9096;            /* 次要文字：中灰 */
  --white: #1f2328;                /* 强调文字：近黑 */
  --light-grey: #6b7078;
  --dark-grey: #5a5f66;
  --hr-border: #e4e6e8;            /* 分割线：浅灰 */
  --blockquote-color: #5a6b7a;
  --blockquote-bg: #eef2f6;
  --text-highlight-color: #6b7078;
  --toc-link-color: #4f6b8a;
  --scrollbar-color: #c6ccd2;
  --default-bg-color: #8b9096;
  --search-bg: #ffffff;
  --sidebar-bg: #ffffff;
  --btn-bg: #e6e9ec;
  --btn-color: #3f444b;
  --btn-hover-color: #1f2328;
  --pseudo-hover: #3f444b;
}

/* ---------- 深色模式（可选）：保持原深灰配色 ---------- */
[data-theme='dark'] {
  --global-bg: #232529;
  --card-bg: #2b2d31;
  --font-color: #cfd3d8;
  --card-meta: #9aa1a9;
  --white: #e4e7ea;
  --light-grey: #6b7078;
  --dark-grey: #4a4f56;
  --hr-border: #3d4147;
  --blockquote-color: #aab1b8;
  --blockquote-bg: #232529;
  --text-highlight-color: #8b9096;
  --toc-link-color: #aeb7c0;
  --scrollbar-color: #3d4147;
  --default-bg-color: #8b9096;
  --search-bg: #2b2d31;
  --sidebar-bg: #2b2d31;
  --btn-bg: #3d4147;
  --btn-color: #cfd3d8;
  --btn-hover-color: #eef1f3;
  --pseudo-hover: #8b9096;
}

/* 链接颜色 */
:root a {
  color: #4f7ea8;                  /* 浅色模式链接：柔蓝 */
}

:root a:hover {
  color: #2f5f8f;
}

[data-theme='dark'] #post a,
[data-theme='dark'] .post-content a,
[data-theme='dark'] a {
  color: #aeb7c0;
}

[data-theme='dark'] a:hover {
  color: #eef1f3;
}

/* 代码块 */
[data-theme='dark'] figure.highlight,
[data-theme='dark'] .highlight {
  background: #22252a;
}

/* 侧边栏/卡片悬浮 */
[data-theme='dark'] .card-widget:hover {
  box-shadow: 0 3px 8px 6px rgba(0, 0, 0, 0.3);
}

/* 顶部栏：深海洋蓝（亮/暗模式一致；选择器需覆盖主题自带的白色/黑色底规则） */
#page-header.not-top-img > #nav,
[data-theme='dark'] #page-header.not-top-img > #nav {
  background: #28547a;
}

#page-header.nav-fixed > #nav,
[data-theme='dark'] #page-header.nav-fixed > #nav {
  background: rgba(40, 84, 122, 0.88);
}

/* 深蓝底上的导航文字改用白色 */
#nav a,
#nav span.site-page,
#nav #toggle-menu,
#nav .site-name {
  color: #f2f7fc !important;
  text-shadow: none;
}

#nav a:hover,
#nav span.site-page:hover,
#nav #toggle-menu:hover {
  color: #ffffff !important;
}

/* 顶部导航栏「留言板」菜单项：排在搜索按钮左边 + 高亮文字（仅桌面端；移动端在侧边菜单列表中） */
@media (min-width: 769px) {
  #menus {
    display: flex;
    align-items: center;
  }

  #nav .menus_items {
    display: contents; /* 让菜单项参与 #menus 的 flex 排序 */
  }

  #nav .menus_items .menus_item:has(> a[href='/comments/']) {
    order: 1; /* 留言板 → 最左 */
  }

  #menus #search-button {
    order: 2; /* 搜索 → 紧跟其后 */
  }

  #nav .menus_items .menus_item:not(:has(> a[href='/comments/'])) {
    order: 3; /* Home/Archives/... 保持原顺序 */
  }

  #nav.hide-menu .menus_items {
    display: none; /* 兜底：窄桌面窗口菜单收起时保持隐藏 */
  }

  #toggle-menu {
    order: 5; /* 汉堡按钮始终在最右 */
  }

  #nav .menus_items .menus_item:has(> a[href='/comments/']) > a {
    color: #ffb86c !important; /* 亮暖橙（深蓝底上醒目） */
    font-weight: 600; /* 加粗 */
  }

  #nav .menus_items .menus_item:has(> a[href='/comments/']) > a:hover {
    color: #ffffff !important; /* 悬停变白 */
  }
}

/* 顶部图禁用时首页布局 */
[data-theme='dark'] #page-header #site-info {
  padding-top: 6rem;
}

/* ---------- Supabase 评论区（sc-*，颜色跟随亮/暗模式变量） ---------- */
.sc-wrap {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--hr-border);
}

.sc-title {
  font-size: 1.1em;
  color: var(--font-color);
  margin-bottom: 12px;
}

.sc-list {
  margin-bottom: 20px;
}

.sc-empty {
  color: var(--card-meta);
  padding: 20px 0;
  text-align: center;
}

.sc-cmt {
  padding: 14px 0;
  border-bottom: 1px solid var(--hr-border);
}

.sc-cmt:last-child {
  border-bottom: none;
}

.sc-cmt-root {
  margin-bottom: 4px;
}

.sc-cmt-reply {
  margin-left: 44px;
  padding-left: 16px;
  border-left: 2px solid var(--hr-border);
}

.sc-cmt-meta {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}

.sc-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--btn-bg);
  color: var(--font-color);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  flex-shrink: 0;
}

.sc-cmt-nick {
  color: var(--font-color);
  font-weight: 600;
  margin-right: 10px;
}

.sc-cmt-time {
  color: var(--card-meta);
  font-size: 0.8em;
}

.sc-cmt-body {
  color: var(--font-color);
  line-height: 1.7;
  word-break: break-word;
}

.sc-cmt-foot {
  margin-top: 6px;
}

.sc-reply-btn {
  background: none;
  border: none;
  color: var(--card-meta);
  cursor: pointer;
  padding: 0;
  font-size: 0.85em;
}

.sc-reply-btn:hover {
  color: var(--font-color);
}

.sc-form {
  margin-top: 8px;
}

.sc-reply-hint {
  color: var(--card-meta);
  font-size: 0.85em;
  margin-bottom: 8px;
  cursor: pointer;
}

.sc-form-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.sc-form input,
.sc-form textarea {
  background: var(--global-bg);
  border: 1px solid var(--hr-border);
  color: var(--font-color);
  border-radius: 4px;
  font-size: 0.9em;
  font-family: inherit;
  outline: none;
}

.sc-form input:focus,
.sc-form textarea:focus {
  border-color: #8fb2d9;
}

.sc-form input {
  flex: 1;
  padding: 8px 12px;
}

.sc-form textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  resize: vertical;
  margin-bottom: 10px;
}

.sc-submit {
  background: #28547a;
  color: #ffffff;
  border: 1px solid #3a6a94;
  padding: 8px 24px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
}

.sc-submit:hover {
  background: #3a6a94;
}

.sc-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.sc-note {
  margin-top: 10px;
  color: var(--card-meta);
  font-size: 0.85em;
  display: none;
}

@media (max-width: 767px) {
  .sc-form-row {
    flex-direction: column;
  }

  .sc-cmt-reply {
    margin-left: 16px;
  }
}

/* ---------- 音乐播放器（music-*） ---------- */
.music-fab {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 200;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #28547a;
  color: #fff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transition: transform .2s, background .2s;
}

.music-fab:hover {
  transform: scale(1.08);
  background: #3a6a94;
}

.music-fab .music-eq {
  display: none;
  align-items: flex-end;
  height: 16px;
}

.music-fab.playing .music-eq {
  display: flex;
}

.music-fab.playing .fa-music {
  display: none;
}

.music-eq i {
  width: 3px;
  margin: 0 1px;
  background: #fff;
  border-radius: 1px;
  animation: music-eq-bounce 1s ease-in-out infinite;
}

.music-eq i:nth-child(1) { height: 6px; animation-delay: 0s; }
.music-eq i:nth-child(2) { height: 14px; animation-delay: .2s; }
.music-eq i:nth-child(3) { height: 9px; animation-delay: .4s; }

@keyframes music-eq-bounce {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(.4); }
}

.music-panel {
  position: fixed;
  left: 24px;
  bottom: 84px;
  z-index: 200;
  width: 260px;
  background: var(--card-bg);
  border: 1px solid var(--hr-border);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  display: none;
}

.music-panel.open {
  display: block;
}

.music-info {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
  min-width: 0;
}

.music-title {
  color: var(--font-color);
  font-size: 0.95em;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.music-author {
  color: var(--card-meta);
  font-size: 0.8em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}

.music-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.music-time {
  color: var(--card-meta);
  font-size: 0.75em;
  min-width: 34px;
}

.music-bar {
  flex: 1;
  height: 4px;
  background: var(--btn-bg);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}

.music-bar-fill {
  height: 100%;
  width: 0;
  background: #28547a;
  border-radius: 2px;
}

.music-btns {
  display: flex;
  align-items: center;
  gap: 10px;
}

.music-btns button {
  background: none;
  border: none;
  padding: 4px;
  color: var(--font-color);
  font-size: 16px;
  cursor: pointer;
  border-radius: 50%;
  transition: color .2s;
}

.music-btns button:hover {
  color: #28547a;
}

.music-btns .music-close {
  margin-left: auto;
  color: var(--card-meta);
}

.music-play.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 767px) {
  .music-fab {
    left: 16px;
    bottom: 16px;
  }

  .music-panel {
    left: 16px;
    bottom: 76px;
    width: calc(100vw - 32px);
    max-width: 280px;
  }
}

/* ---------- 管理后台（adm-*） ---------- */
.adm-login {
  max-width: 380px;
  margin: 60px auto;
  padding: 28px;
  background: var(--card-bg);
  border: 1px solid var(--hr-border);
  border-radius: 10px;
}

.adm-login h2 {
  font-size: 1.2em;
  margin-bottom: 18px;
  color: var(--font-color);
}

.adm-login input {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 12px;
  padding: 9px 12px;
  background: var(--global-bg);
  border: 1px solid var(--hr-border);
  border-radius: 5px;
  color: var(--font-color);
  font-size: 0.95em;
  outline: none;
}

.adm-login input:focus {
  border-color: #8fb2d9;
}

.adm-btn {
  display: inline-block;
  padding: 8px 22px;
  border: none;
  border-radius: 5px;
  background: #28547a;
  color: #fff;
  font-size: 0.95em;
  cursor: pointer;
  transition: background .2s;
}

.adm-btn:hover {
  background: #3a6a94;
}

.adm-btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.adm-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.adm-bar h2 {
  font-size: 1.2em;
  margin: 0 12px 0 0;
  color: var(--font-color);
}

.adm-tabs {
  display: flex;
  gap: 6px;
  margin-right: auto;
  flex-wrap: wrap;
}

.adm-tab {
  padding: 5px 14px;
  border: 1px solid var(--hr-border);
  border-radius: 20px;
  background: var(--card-bg);
  color: var(--card-meta);
  font-size: 0.85em;
  cursor: pointer;
  transition: all .2s;
}

.adm-tab.active {
  background: #28547a;
  border-color: #28547a;
  color: #fff;
}

.adm-refresh,
.adm-logout {
  font-size: 0.85em;
  padding: 6px 14px;
  border-radius: 5px;
  border: 1px solid var(--hr-border);
  background: var(--card-bg);
  color: var(--font-color);
  cursor: pointer;
}

.adm-logout {
  border-color: #c96a6a;
  color: #c96a6a;
}

.adm-cmt {
  background: var(--card-bg);
  border: 1px solid var(--hr-border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
}

.adm-cmt-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.adm-nick {
  font-weight: 600;
  color: var(--font-color);
}

.adm-time {
  color: var(--card-meta);
  font-size: 0.8em;
}

.adm-status {
  font-size: 0.75em;
  padding: 2px 10px;
  border-radius: 10px;
}

.adm-status.pending { background: #f4e3c1; color: #8a6116; }
.adm-status.approved { background: #d5e8d8; color: #2e6b37; }
.adm-status.rejected { background: #f0d5d5; color: #8a2e2e; }

.adm-path {
  color: var(--card-meta);
  font-size: 0.8em;
  margin-bottom: 6px;
  word-break: break-all;
}

.adm-body {
  color: var(--font-color);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 10px;
}

.adm-actions {
  display: flex;
  gap: 8px;
}

.adm-actions button {
  border: none;
  border-radius: 4px;
  padding: 5px 14px;
  font-size: 0.85em;
  cursor: pointer;
  transition: opacity .2s;
}

.adm-actions button:hover { opacity: 0.85; }

.adm-ok { background: #3d8b4f; color: #fff; }
.adm-rej { background: #b58a3a; color: #fff; }
.adm-del { background: #c0504d; color: #fff; }

.adm-empty {
  text-align: center;
  color: var(--card-meta);
  padding: 40px 0;
}

.adm-note {
  margin-top: 10px;
  color: var(--card-meta);
  font-size: 0.85em;
  line-height: 1.6;
}

.adm-error {
  margin-top: 10px;
  color: #c0504d;
  font-size: 0.9em;
}

/* 歌单模式：按钮排布（有歌单时列表按钮靠右） */
.music-btns .music-close {
  margin-left: auto;
}

.music-panel:has(.music-list-btn) .music-close {
  margin-left: 0;
}

.music-panel:has(.music-list-btn) .music-list-btn {
  margin-left: auto;
}

/* 歌单列表 */
.music-listbox {
  display: none;
  border-top: 1px solid var(--hr-border);
  margin-top: 10px;
  padding-top: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.music-listbox.open {
  display: block;
}

.music-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
  color: var(--font-color);
  font-size: 0.85em;
  transition: background .2s;
}

.music-list-item:hover {
  background: var(--btn-bg);
}

.music-list-item.active {
  color: #28547a;
  font-weight: 600;
}

.music-list-idx {
  color: var(--card-meta);
  font-size: 0.8em;
  min-width: 18px;
}

.music-list-item.active .music-list-idx {
  color: #28547a;
}

.music-list-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.music-list-eq {
  display: none;
  align-items: flex-end;
  height: 12px;
  margin-left: auto;
}

.music-list-item.playing .music-list-eq {
  display: flex;
}

.music-list-eq i {
  width: 2px;
  margin: 0 1px;
  background: #28547a;
  border-radius: 1px;
  animation: music-eq-bounce 1s ease-in-out infinite;
}

.music-list-eq i:nth-child(1) { height: 5px; }
.music-list-eq i:nth-child(2) { height: 11px; animation-delay: .2s; }
.music-list-eq i:nth-child(3) { height: 7px; animation-delay: .4s; }
