/* =====================================================================
   顶部导航「日/夜间模式」切换：下拉菜单重新设计成液态玻璃，
   以及首次访问的引导气泡（.theme-hint）。
   行为在 js/theme-switcher.js；标记在 layouts/_nav.blade.php。
   玻璃参数、圆角、动效节奏跟底部导航条 / 联系抽屉保持一致，不用另一套。
   ===================================================================== */

/* -------- 下拉菜单：液态玻璃 -------- */
.theme-menu {
  --tm-bg: rgba(255, 255, 255, .68);
  --tm-border: rgba(255, 255, 255, .85);
  --tm-inset: inset 0 1px 0 rgba(255, 255, 255, .9), inset 0 -1px 0 rgba(255, 255, 255, .3);
  --tm-shadow: 0 24px 48px -20px rgba(24, 29, 37, .35), 0 4px 16px rgba(24, 29, 37, .08);
  --tm-text: #1f2430;
  --tm-muted: #6b7684;
  --tm-item-hover: rgba(24, 29, 37, .06);
  --tm-active-a: rgba(47, 110, 213, .18);
  --tm-active-b: rgba(13, 202, 240, .12);
  --tm-check: #2f6ed5;

  padding: .5rem !important;
  border: 1px solid var(--tm-border) !important;
  border-radius: 1.25rem !important;
  background: var(--tm-bg) !important;
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--tm-shadow), var(--tm-inset) !important;
  color: var(--tm-text);
}
/* 按钮离视口右边缘较近时（常见于窄屏），改贴右对齐，别再居中溢出屏幕；js/theme-switcher.js 判断后加这个类 */
.theme-menu.align-end {
  left: auto !important;
  right: -.35rem !important;
  transform: none !important;
}
html[data-bs-theme="dark"] .theme-menu,
html[data-theme="dark"] .theme-menu {
  --tm-bg: rgba(28, 34, 46, .74);
  --tm-border: rgba(255, 255, 255, .14);
  --tm-inset: inset 0 1px 0 rgba(255, 255, 255, .14), inset 0 -1px 0 rgba(255, 255, 255, .03);
  --tm-shadow: 0 24px 48px -18px rgba(0, 0, 0, .6), 0 4px 16px rgba(0, 0, 0, .25);
  --tm-text: #eef2f8;
  --tm-muted: #93a0b4;
  --tm-item-hover: rgba(255, 255, 255, .09);
  --tm-active-a: rgba(96, 165, 250, .28);
  --tm-active-b: rgba(96, 165, 250, .12);
  --tm-check: #8db9ff;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .theme-menu { --tm-bg: rgba(255, 255, 255, .96); }
  html[data-bs-theme="dark"] .theme-menu,
  html[data-theme="dark"] .theme-menu { --tm-bg: rgba(28, 34, 46, .97); }
}

.theme-menu .dropdown-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .5rem .6rem;
  margin-bottom: .15rem;
  border-radius: .9rem;
  color: var(--tm-text) !important;
  background: transparent;
  transition: background-color .25s ease, transform .2s ease;
}
.theme-menu li:last-child .dropdown-item { margin-bottom: 0; }
.theme-menu .dropdown-item:hover,
.theme-menu .dropdown-item:focus-visible {
  background: var(--tm-item-hover);
  color: var(--tm-text);
}
.theme-menu .dropdown-item:active { transform: scale(.97); }
.theme-menu .dropdown-item.active {
  background: linear-gradient(120deg, var(--tm-active-a), var(--tm-active-b));
}

.theme-menu .theme-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  font-size: 1rem;
  color: var(--tm-muted);
  background: rgba(120, 130, 145, .14);
  transition: background-color .3s ease, color .3s ease, transform .45s cubic-bezier(.34, 1.56, .64, 1);
}
/* 三个选项各自的强调色（未选中时只淡淡点缀，选中后填满） */
.theme-menu .dropdown-item[data-bs-theme-value="light"] .theme-icon { color: #e08a1e; }
.theme-menu .dropdown-item[data-bs-theme-value="dark"] .theme-icon { color: #6d7ef2; }
.theme-menu .dropdown-item[data-bs-theme-value="auto"] .theme-icon { color: #0dcaf0; }
.theme-menu .dropdown-item.active .theme-icon {
  color: #fff;
  background: linear-gradient(135deg, var(--tm-check), #64d9f2);
  box-shadow: 0 6px 14px -6px rgba(47, 110, 213, .7);
}
/* 每次被选中时图标弹一下（js 每次切换都重新触发一次） */
.theme-menu .theme-icon.is-pop { animation: tm-jelly .55s .02s both; }
@keyframes tm-jelly {
  0%   { transform: scale(1, 1); }
  30%  { transform: scale(.8, 1.18); }
  60%  { transform: scale(1.12, .9); }
  100% { transform: scale(1, 1); }
}

.theme-menu .theme-label { font-weight: 600; font-size: .875rem; }

.theme-menu .item-active-indicator {
  flex: none;
  color: var(--tm-check);
  opacity: 0;
  transform: scale(.4);
  transition: opacity .3s cubic-bezier(.34, 1.56, .64, 1), transform .35s cubic-bezier(.34, 1.56, .64, 1);
}
.theme-menu .dropdown-item.active .item-active-indicator { opacity: 1; transform: scale(1); }

/* 顶部触发按钮：切换主题时图标换一下，带一点弹性 */
.theme-icon-active { transition: transform .45s cubic-bezier(.34, 1.56, .64, 1); }
.theme-icon-active.is-pop { animation: tm-jelly .55s .02s both; }

@media (prefers-reduced-motion: reduce) {
  .theme-menu .dropdown-item,
  .theme-menu .theme-icon,
  .theme-menu .item-active-indicator,
  .theme-icon-active { transition-duration: .01s !important; }
  .theme-menu .theme-icon.is-pop,
  .theme-icon-active.is-pop { animation: none !important; }
}

/* -------- 首次访问的引导气泡：指向主题按钮，几秒后自己收回 -------- */
.theme-hint {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  z-index: 1030;
  width: max-content;
  max-width: 210px;
  padding: .55rem .9rem;
  border-radius: .9rem;
  font-size: .8125rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  color: #fff;
  background: rgba(24, 29, 37, .92);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  box-shadow: 0 16px 32px -14px rgba(24, 29, 37, .55), inset 0 1px 0 rgba(255, 255, 255, .14);
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(-50% + var(--hint-shift, 0px))) scale(.35);
  transform-origin: top center;
  transition: opacity .32s ease, transform .45s cubic-bezier(.34, 1.56, .64, 1);
}
html[data-bs-theme="dark"] .theme-hint,
html[data-theme="dark"] .theme-hint {
  color: #181d25;
  background: rgba(238, 242, 248, .95);
  box-shadow: 0 16px 32px -14px rgba(0, 0, 0, .65), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.theme-hint::before {
  content: "";
  position: absolute;
  top: -5px;
  left: calc(50% - var(--hint-shift, 0px));
  width: 10px;
  height: 10px;
  transform: translateX(-50%) rotate(45deg);
  background: inherit;
}
.theme-hint.is-shown {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(calc(-50% + var(--hint-shift, 0px))) scale(1);
}
/* 缩回：往按钮方向收缩淡出，不是简单消失 */
.theme-hint.is-hiding {
  opacity: 0;
  transform: translateX(calc(-50% + var(--hint-shift, 0px))) scale(.3);
  transition: opacity .3s ease, transform .32s cubic-bezier(.5, 0, .75, 0);
}
@media (prefers-reduced-motion: reduce) {
  .theme-hint,
  .theme-hint.is-hiding { transition-duration: .01s !important; }
}
