/**
 * Shared Header Styles — WenPill Series
 *
 * 通用页首样式，支持亮色/暗色主题、移动端抽屉、页面过渡。
 * 零外部依赖，纯 CSS 实现。
 * 图标依赖 Material Symbols（可选，未引入时图标位留空）。
 */

/* ══════════════════════════════════════════
   0. 基础 / 无障碍
   ══════════════════════════════════════════ */

html {
  overflow-y: scroll;
}

.sh-skip-link {
  position: fixed;
  left: 1rem;
  top: 0.75rem;
  z-index: 70;
  padding: 0.65rem 0.95rem;
  border-radius: 9999px;
  background: #0c6780;
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-180%);
  transition: transform 180ms ease, opacity 180ms ease;
  opacity: 0;
}

.sh-skip-link:focus,
.sh-skip-link:focus-visible {
  transform: translateY(0);
  opacity: 1;
}

.sh-skip-link:focus-visible,
.sh-nav a:focus-visible,
.sh-nav button:focus-visible,
.sh-drawer a:focus-visible,
.sh-drawer button:focus-visible {
  outline: 2px solid #0c6780;
  outline-offset: 2px;
}

.sh-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.sh-avatar-icon {
  font-size: 1.5rem;
  line-height: 1;
}

/* ══════════════════════════════════════════
   1. 顶部导航栏
   ══════════════════════════════════════════ */

.sh-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.76);
  border-bottom: 1px solid rgba(186, 212, 227, 0.48);
  -webkit-backdrop-filter: blur(22px) saturate(1.16);
  backdrop-filter: blur(22px) saturate(1.16);
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

html.dark .sh-nav {
  background: rgba(10, 18, 32, 0.72);
  border-bottom-color: rgba(82, 109, 143, 0.38);
  box-shadow: 0 8px 26px rgba(2, 6, 23, 0.28);
}

.sh-nav-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 80rem;
  margin: 0 auto;
  padding: 1rem 2rem;
}

.sh-brand {
  flex: 1 1 0%;
  display: flex;
  justify-content: flex-start;
  text-decoration: none;
  font-size: 1.5rem;
  color: #075985;
  white-space: nowrap;
}

html.dark .sh-brand {
  color: #bae6fd;
}

.sh-brand-prefix {
  font-weight: 400;
}

.sh-brand-strong {
  font-weight: 700;
}

.sh-links {
  display: none;
  align-items: center;
  gap: 2rem;
  flex: none;
}

.sh-actions {
  flex: 1 1 0%;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
}

@media (min-width: 768px) {
  .sh-links {
    display: flex;
  }

  .sh-menu-trigger {
    display: none;
  }
}

/* ══════════════════════════════════════════
   2. 桌面导航链接
   ══════════════════════════════════════════ */

.sh-nav-link {
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.06em;
  line-height: 1.2;
  color: #475569;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 180ms ease;
}

.sh-nav-link:hover {
  color: #0ea5e9;
}

.sh-nav-link.is-active {
  color: #0c4a6e;
  font-weight: 400;
  border-bottom-color: #0ea5e9;
}

html.dark .sh-nav-link {
  color: #94a3b8;
}

html.dark .sh-nav-link:hover {
  color: #7dd3fc;
}

html.dark .sh-nav-link.is-active {
  color: #e0f2fe;
}

@media (min-width: 768px) {
  .sh-nav-link {
    font-size: 14px;
  }
}

/* ══════════════════════════════════════════
   3. 图标按钮 / 头像菜单
   ══════════════════════════════════════════ */

.sh-icon-btn {
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(255, 255, 255, 0.72);
  color: #0f4c76;
  cursor: pointer;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: transform 160ms ease, background-color 180ms ease, color 180ms ease;
}

.sh-icon-btn:active {
  transform: scale(0.95);
}

html.dark .sh-icon-btn {
  background: rgba(15, 23, 42, 0.72);
  border-color: rgba(148, 163, 184, 0.34);
  color: #9dcfe8;
}

.sh-avatar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sh-user-card {
  position: absolute;
  top: 3rem;
  right: 0;
  min-width: 220px;
  padding: 1rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(226, 232, 240, 0.8);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  opacity: 0;
  transform: translateY(-4px) scale(0.97);
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}

.sh-user-card.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.sh-user-card.is-hidden {
  display: none;
}

html.dark .sh-user-card {
  border-color: rgba(51, 65, 85, 0.8);
  background: rgba(15, 23, 42, 0.94);
  box-shadow: 0 16px 40px rgba(2, 6, 23, 0.5);
}

.sh-user-card-title {
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #64748b;
}

html.dark .sh-user-card-title {
  color: #94a3b8;
}

.sh-user-name {
  margin-top: 0.25rem;
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
}

html.dark .sh-user-name {
  color: #f1f5f9;
}

.sh-user-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.sh-user-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  width: 100%;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  color: #0369a1;
  background: rgba(186, 230, 253, 0.8);
  transition: background-color 180ms ease;
}

.sh-user-link:hover {
  background: rgba(125, 211, 252, 0.9);
}

html.dark .sh-user-link {
  color: #bae6fd;
  background: rgba(8, 47, 73, 0.8);
}

html.dark .sh-user-link:hover {
  background: rgba(12, 74, 110, 0.9);
}

/* ══════════════════════════════════════════
   4. 移动端抽屉
   ══════════════════════════════════════════ */

.sh-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 58;
  opacity: 0;
  pointer-events: none;
  background: rgba(7, 14, 27, 0.34);
  transition: opacity 220ms ease;
}

.sh-drawer-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.sh-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100dvh;
  width: min(82vw, 320px);
  z-index: 59;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  transform: translateX(100%);
  transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
  background: rgba(255, 255, 255, 0.9);
  border-left: 1px solid rgba(148, 163, 184, 0.24);
  box-shadow: -12px 0 28px rgba(15, 23, 42, 0.12);
  -webkit-backdrop-filter: blur(18px) saturate(1.12);
  backdrop-filter: blur(18px) saturate(1.12);
}

.sh-drawer.is-open {
  transform: translateX(0);
}

html.dark .sh-drawer {
  background: rgba(10, 18, 32, 0.9);
  border-left-color: rgba(82, 109, 143, 0.38);
  box-shadow: -14px 0 34px rgba(2, 6, 23, 0.4);
}

.sh-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0.25rem 0.5rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
}

html.dark .sh-drawer-head {
  border-bottom-color: rgba(82, 109, 143, 0.4);
}

.sh-drawer-title {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 600;
}

html.dark .sh-drawer-title {
  color: #a4bad5;
}

.sh-drawer-links {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sh-drawer-item {
  display: flex;
  align-items: center;
  gap: 0.72rem;
  border-radius: 0.85rem;
  padding: 0.72rem 0.8rem;
  color: #3f4b5e;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: background-color 180ms ease, color 180ms ease;
}

.sh-drawer-item .sh-icon {
  font-size: 1.15rem;
  color: #0f6a95;
}

.sh-drawer-item:hover {
  background: rgba(14, 116, 144, 0.08);
  color: #0f4c76;
}

.sh-drawer-item.is-active {
  background: rgba(14, 116, 144, 0.14);
  color: #0f4c76;
  font-weight: 600;
}

html.dark .sh-drawer-item {
  color: #b9c8dd;
}

html.dark .sh-drawer-item .sh-icon {
  color: #9dcfe8;
}

html.dark .sh-drawer-item:hover {
  background: rgba(56, 189, 248, 0.12);
  color: #e4f2ff;
}

html.dark .sh-drawer-item.is-active {
  background: rgba(56, 189, 248, 0.18);
  color: #f2f8ff;
}

html.sh-nav-open,
body.sh-nav-open {
  overflow: hidden;
}

@media (min-width: 768px) {
  .sh-menu-trigger,
  .sh-drawer,
  .sh-drawer-overlay {
    display: none !important;
  }
}

/* ══════════════════════════════════════════
   5. 页面加载进度条
   ══════════════════════════════════════════ */

.sh-page-loader {
  position: fixed;
  top: 5.25rem;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 49;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  transition: opacity 180ms ease;
}

.sh-page-loader.is-active {
  opacity: 1;
}

.sh-page-loader::after {
  content: '';
  display: block;
  height: 100%;
  width: 0;
  border-radius: 0 2px 2px 0;
  background: linear-gradient(90deg, #0c6780, #38bdf8, #0ea5e9, #0c6780);
  background-size: 200% 100%;
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.sh-page-loader.is-active::after {
  width: 60%;
  animation: shLoaderSlide 0.9s ease-in-out infinite;
}

.sh-page-loader.is-complete::after {
  width: 100%;
  animation: none;
  background: #0c6780;
  transition: width 0.15s ease-out;
}

@keyframes shLoaderSlide {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ══════════════════════════════════════════
   6. 页面过渡动画（可选）
   ══════════════════════════════════════════ */

.sh-nav-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 5.25rem;
  z-index: 51;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.84) 0%, rgba(255, 255, 255, 0.66) 100%);
  -webkit-backdrop-filter: blur(20px) saturate(1.14);
  backdrop-filter: blur(20px) saturate(1.14);
  transition: opacity 180ms ease;
}

html.dark .sh-nav-mask {
  background: linear-gradient(180deg, rgba(10, 18, 32, 0.9) 0%, rgba(10, 18, 32, 0.72) 100%);
}

.sh-transition-enabled .sh-nav-mask,
.sh-transition-exiting .sh-nav-mask {
  opacity: 1;
}

.sh-transition-ready .sh-nav-mask {
  opacity: 0;
}

.sh-transition-enabled main {
  opacity: 0;
}

.sh-transition-entering main,
.sh-transition-ready main {
  transition: opacity 280ms ease;
}

.sh-transition-ready main {
  opacity: 1;
}

.sh-transition-exiting main {
  transition: opacity 220ms ease-out;
  opacity: 0;
}

/* ══════════════════════════════════════════
   7. 无障碍：减少动效
   ══════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  .sh-nav-mask,
  .sh-drawer,
  .sh-drawer-overlay,
  .sh-user-card,
  .sh-skip-link,
  .sh-transition-enabled main,
  .sh-transition-entering main,
  .sh-transition-ready main,
  .sh-transition-exiting main {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
  }
}
