/**
 * 界面动效.css — 汉堡图标、窄屏全屏导航、右侧登录抽屉的过渡与动画
 *
 * 依赖：须先引入同目录下的 导航栏.css（:root 变量与静态布局）
 */

/* —— 登录抽屉：时长与曲线（与 iOS / 现代 Web 长减速接近） —— */
:root {
  --login-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --login-ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --login-dur-overlay: 0.4s;
  --login-dur-drawer: 0.48s;
  --login-dur-inner: 0.42s;
  --login-stagger-1: 0.07s;
  --login-stagger-2: 0.05s;
}

/* —— 窄屏全屏菜单：时间与曲线变量 —— */
.nav-dropdown {
  --nav-dur: 0.4s;
  --nav-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --nav-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --nav-dur-spring: 0.56s;
  --nav-motion-blur: 5px;
}

/* —— 汉堡按钮：线条变叉 —— */
.menu-btn .line {
  transition: transform 0.35s cubic-bezier(0.68, -0.55, 0.27, 1.55), opacity 0.25s ease, margin 0.35s ease;
}

.menu-btn.is-open .line:first-child {
  transform: translateY(5px) rotate(45deg);
}

.menu-btn.is-open .line:last-child {
  transform: translateY(-5px) rotate(-45deg);
}

.user-link {
  transition: opacity 0.2s;
}

@media (max-width: 767.98px) {
  body.menu-open {
    overflow: hidden;
    touch-action: none;
  }

  .nav-dropdown {
    position: fixed;
    inset: 0;
    z-index: 250;
    display: flex;
    flex-direction: column;
    padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0)
      env(safe-area-inset-left, 0);
    overflow: hidden auto;
    -webkit-overflow-scrolling: touch;
    opacity: 1;
    pointer-events: none;
    background: #333333;
    clip-path: inset(0 0 100% 0);
    transition: clip-path var(--nav-dur) var(--nav-ease);
  }

  .nav-dropdown.is-open {
    pointer-events: auto;
    clip-path: inset(0 0 0 0);
  }

  .mobile-menu-sheet {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: min(100vh, 100dvh);
    -webkit-filter: blur(var(--nav-motion-blur));
    filter: blur(var(--nav-motion-blur));
    transition:
      -webkit-filter calc(var(--nav-dur-spring) * 0.9) var(--nav-ease),
      filter calc(var(--nav-dur-spring) * 0.9) var(--nav-ease);
  }

  .nav-dropdown.is-open .mobile-menu-sheet {
    -webkit-filter: blur(0);
    filter: blur(0);
  }

  .mobile-menu-top {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 8px 4px 12px;
    flex-shrink: 0;
  }

  .mobile-menu-close {
    width: 44px;
    height: 44px;
    border: none;
    padding: 0;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transform: scale(0.78);
    transform-origin: center;
    transition: transform var(--nav-dur-spring) var(--nav-spring);
    transition-delay: 0s;
  }

  .nav-dropdown.is-open .mobile-menu-close {
    transform: scale(1);
    transition-delay: 0.06s;
  }

  .nav-dropdown:not(.is-open) .mobile-menu-close {
    transition-delay: 0s;
  }

  .mobile-menu-close-icon {
    position: relative;
    width: 22px;
    height: 22px;
    display: block;
  }

  .mobile-menu-close-icon::before,
  .mobile-menu-close-icon::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 1px;
  }

  .mobile-menu-close-icon::before {
    transform: translate(-50%, -50%) rotate(45deg);
  }

  .mobile-menu-close-icon::after {
    transform: translate(-50%, -50%) rotate(-45deg);
  }

  .nav-dropdown-inner {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 4px 4px 32px;
    transform: translate3d(0, 18px, 0);
    transition: transform var(--nav-dur-spring) var(--nav-spring);
    transition-delay: 0s;
  }

  .nav-dropdown.is-open .nav-dropdown-inner {
    transform: translate3d(0, 0, 0);
    transition-delay: 0.04s;
  }

  .nav-dropdown:not(.is-open) .nav-dropdown-inner {
    transition-delay: 0s;
  }

  .nav-dropdown a {
    position: relative;
    color: rgba(255, 255, 255, 0.88);
    text-decoration: none;
    font-size: 17px;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1.4;
    padding: 14px 12px;
    border-radius: 10px;
    text-align: left;
    width: 100%;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    transition: color 0.2s ease, background 0.2s ease;
  }

  .nav-dropdown a.is-active {
    color: #fff;
    font-weight: 600;
  }

  .nav-dropdown a:hover,
  .nav-dropdown a:focus-visible {
    background: rgba(255, 255, 255, 0.08);
    outline: none;
  }
}

@media (hover: none) and (max-width: 767.98px) {
  .nav-dropdown a:active {
    transform: scale(0.98);
  }
}

@media (prefers-reduced-motion: reduce) and (max-width: 767.98px) {
  .nav-dropdown,
  .nav-dropdown-inner,
  .mobile-menu-close,
  .mobile-menu-sheet {
    transition-duration: 0.2s !important;
    transition-timing-function: ease !important;
    transition-delay: 0s !important;
  }

  .mobile-menu-sheet {
    -webkit-filter: none !important;
    filter: none !important;
  }

  .nav-dropdown.is-open .nav-dropdown-inner {
    transform: none !important;
  }

  .nav-dropdown.is-open .mobile-menu-close {
    transform: none !important;
  }

  .nav-dropdown.is-open {
    clip-path: inset(0 0 0 0) !important;
  }
}

/* —— 右侧登录：仅此处为 Apple / iOS 风格（雾面 sheet + 系统蓝主按钮） —— */
.login-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 280;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  -webkit-backdrop-filter: blur(0px);
  backdrop-filter: blur(0px);
  transition:
    opacity var(--login-dur-overlay) var(--login-ease-out),
    visibility 0s linear var(--login-dur-overlay),
    -webkit-backdrop-filter var(--login-dur-overlay) var(--login-ease-out),
    backdrop-filter var(--login-dur-overlay) var(--login-ease-out);
}

body.login-drawer-open .login-drawer-overlay {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition:
    opacity var(--login-dur-overlay) var(--login-ease-out),
    visibility 0s linear 0s,
    -webkit-backdrop-filter var(--login-dur-overlay) var(--login-ease-out),
    backdrop-filter var(--login-dur-overlay) var(--login-ease-out);
}

.login-drawer {
  position: fixed;
  top: 50%;
  right: 0;
  bottom: auto;
  z-index: 281;
  width: min(100vw - 20px, 380px);
  max-width: 100%;
  max-height: min(620px, calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
  overflow-x: hidden;
  background: rgba(44, 44, 46, 0.94);
  -webkit-backdrop-filter: blur(48px) saturate(190%);
  backdrop-filter: blur(48px) saturate(190%);
  color: #f5f5f7;
  font-family: var(--font-apple);
  box-shadow:
    0 0 0 0.5px rgba(255, 255, 255, 0.12),
    -28px 0 56px rgba(0, 0, 0, 0.42);
  border-radius: 22px 0 0 22px;
  transform: translate3d(calc(100% + 16px), -50%, 0) scale(0.97);
  opacity: 0;
  transition:
    transform var(--login-dur-drawer) var(--login-ease-drawer),
    opacity calc(var(--login-dur-drawer) * 0.85) var(--login-ease-out);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  padding: 14px max(12px, env(safe-area-inset-right, 0px)) 14px max(12px, env(safe-area-inset-left, 0px));
  will-change: transform;
}

body.login-drawer-open .login-drawer {
  transform: translate3d(0, -50%, 0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.login-drawer__inner {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  padding: 0 4px 4px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* —— auth-sheet（与 index.html 中 class 一致） —— */
.auth-sheet {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  font-family: var(--font-apple);
  opacity: 0;
  transform: translate3d(0, 14px, 0);
  transition:
    opacity var(--login-dur-inner) var(--login-ease-out),
    transform var(--login-dur-inner) var(--login-ease-drawer);
  transition-delay: 0s;
}

body.login-drawer-open .login-drawer .auth-sheet {
  opacity: 1;
  transform: translate3d(0, 0, 0);
  transition-delay: var(--login-stagger-1), var(--login-stagger-2);
}

body:not(.login-drawer-open) .login-drawer .auth-sheet {
  opacity: 0;
  transform: translate3d(0, 12px, 0);
  transition-delay: 0s;
  transition-duration: 0.22s;
  transition-timing-function: ease;
}

.auth-sheet__header {
  position: relative;
  padding: 0 36px 12px 0;
  flex-shrink: 0;
}

.auth-sheet__close {
  position: absolute;
  top: -4px;
  right: 0;
  width: 44px;
  height: 44px;
  margin: 0;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  border-radius: 10px;
}

.auth-sheet__close:focus {
  outline: none;
}

.auth-sheet__close:focus-visible {
  outline: 2px solid rgba(10, 132, 255, 0.55);
  outline-offset: 2px;
}

.auth-sheet__close-icon {
  position: relative;
  width: 22px;
  height: 22px;
  display: block;
}

.auth-sheet__close-icon::before,
.auth-sheet__close-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 2px;
  background: rgba(245, 245, 247, 0.68);
  border-radius: 1px;
}

.auth-sheet__close-icon::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.auth-sheet__close-icon::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.auth-sheet__title {
  font-size: 1.28rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: #f5f5f7;
  line-height: 1.25;
  margin-bottom: 6px;
}

.auth-sheet__lead {
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(245, 245, 247, 0.55);
  letter-spacing: -0.01em;
  line-height: 1.35;
  margin-bottom: 14px;
}

.auth-sheet__segment {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(118, 118, 128, 0.24);
}

.auth-sheet__seg {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: rgba(245, 245, 247, 0.45);
  background: transparent;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    color 0.2s cubic-bezier(0.25, 0.1, 0.25, 1),
    background 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.auth-sheet__seg.is-active {
  color: #f5f5f7;
  background: rgba(118, 118, 128, 0.45);
}

.auth-sheet__seg:focus {
  outline: none;
}

.auth-sheet__seg:focus-visible {
  outline: 2px solid rgba(10, 132, 255, 0.45);
  outline-offset: 1px;
}

.auth-sheet__views {
  position: relative;
  overflow: hidden;
  transition: height 0.38s var(--login-ease-drawer);
}

.auth-panel {
  width: 100%;
}

.auth-panel:not(.is-active) {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
}

.auth-panel.is-active {
  position: relative;
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 4px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-label {
  font-size: 13px;
  font-weight: 500;
  color: rgba(245, 245, 247, 0.62);
  letter-spacing: -0.01em;
}

.auth-input {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
  color: #f5f5f7;
  background: rgba(118, 118, 128, 0.28);
  border: none;
  border-radius: 12px;
  outline: none;
  box-shadow: 0 0 0 0 rgba(10, 132, 255, 0);
  transition: box-shadow 0.2s cubic-bezier(0.25, 0.1, 0.25, 1), background 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.auth-input::placeholder {
  color: rgba(245, 245, 247, 0.32);
}

.auth-input:focus {
  background: rgba(118, 118, 128, 0.38);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.32);
}

.auth-msg {
  min-height: 1.25em;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 159, 10, 0.95);
  letter-spacing: -0.01em;
}

.auth-btn {
  margin-top: 4px;
  padding: 14px 18px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #fff;
  background: #0a84ff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background 0.16s cubic-bezier(0.25, 0.1, 0.25, 1),
    transform 0.12s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.auth-btn:hover {
  background: #409cff;
}

.auth-btn:active {
  transform: scale(0.99);
}

.auth-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

.auth-btn--logout {
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.14);
  color: rgba(245, 245, 247, 0.95);
}

.auth-btn--logout:hover {
  background: rgba(255, 69, 58, 0.42);
  color: #fff;
}

.auth-form--logged-in {
  padding-top: 6px;
}

.auth-logged-welcome {
  font-size: 1.05rem;
  font-weight: 600;
  color: #f5f5f7;
  letter-spacing: -0.02em;
  margin-bottom: 0.35em;
}

.auth-logged-tip {
  font-size: 0.8125rem;
  color: rgba(245, 245, 247, 0.48);
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

/* 注册：头像 */
.auth-avatar {
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
}

.auth-avatar__pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.auth-avatar__input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  overflow: hidden;
}

.auth-avatar__frame {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(118, 118, 128, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  transition: background 0.2s ease;
}

.auth-avatar__pick:hover .auth-avatar__frame {
  background: rgba(118, 118, 128, 0.48);
}

.auth-avatar__preview {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.auth-avatar__hint {
  font-size: 28px;
  font-weight: 300;
  color: rgba(245, 245, 247, 0.45);
  line-height: 1;
  z-index: 0;
}

.auth-avatar__frame.has-image .auth-avatar__hint {
  display: none;
}

/* 已登录抽屉：无照片时用姓氏/首字母代替 “+” */
.auth-avatar__surname {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  border-radius: 50%;
  z-index: 1;
  pointer-events: none;
}

.auth-avatar__frame.auth-avatar__frame--surname .auth-avatar__surname:not([hidden]) {
  display: flex;
}

.auth-avatar__frame.auth-avatar__frame--surname .auth-avatar__hint {
  display: none;
}

.auth-avatar__caption {
  font-size: 12px;
  font-weight: 500;
  color: rgba(245, 245, 247, 0.42);
}

.auth-logged-avatar-hint {
  font-size: 12px;
  color: rgba(245, 245, 247, 0.48);
  margin: 0 0 10px;
  line-height: 1.45;
}

.auth-avatar--account {
  margin-bottom: 6px;
}

.auth-avatar--account .auth-avatar__frame {
  width: 64px;
  height: 64px;
}

body.login-drawer-open {
  overflow: hidden;
  touch-action: none;
}

@media (prefers-reduced-motion: reduce) {
  .menu-btn .line {
    transition-duration: 0.12s !important;
    transition-timing-function: ease !important;
  }

  .login-drawer,
  .login-drawer-overlay {
    transition-duration: 0.15s !important;
    transition-timing-function: ease !important;
  }

  .login-drawer-overlay {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }

  .login-drawer {
    transform: translate3d(100%, -50%, 0) !important;
    opacity: 0 !important;
  }

  body.login-drawer-open .login-drawer {
    transform: translate3d(0, -50%, 0) scale(1) !important;
    opacity: 1 !important;
  }

  .login-drawer .auth-sheet {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .auth-sheet__views {
    transition: none !important;
  }
}
