/* =============================================
   流水账 - 登录页样式（竹林图片背景 + 半透明毛玻璃）
   ============================================= */

:root {
  --bamboo-green: #4CAF50;
  --bamboo-dark: #2E7D32;
  --bamboo-light: #A5D6A7;
  --card-bg: rgba(255, 255, 255, 0.25);
  --card-border: rgba(255, 255, 255, 0.35);
  --card-blur: blur(24px);
  --text: #fff;
  --text-secondary: rgba(255, 255, 255, 0.85);
  --text-muted: rgba(255, 255, 255, 0.6);
  --text-light: rgba(255, 255, 255, 0.4);
  --border: rgba(255, 255, 255, 0.2);
  --input-bg: rgba(255, 255, 255, 0.12);
  --input-focus-bg: rgba(255, 255, 255, 0.2);
  --shadow: 0 8px 40px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  --shadow-hover: 0 12px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
  --radius: 20px;
  --font: 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  --transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: #0d1f0d;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* ==================== 竹林背景图片 ==================== */
.bamboo-bg {
  position: fixed;
  top: -20px;
  left: -20px;
  width: calc(100% + 40px);
  height: calc(100% + 40px);
  /* background-image 由 JS 竞速加载后动态设置 */
  background-size: cover;
  background-position: center bottom;
  background-repeat: no-repeat;
  z-index: 0;
  /* 缓慢飘移动画 */
  animation: bgDrift 30s ease-in-out infinite alternate;
  filter: brightness(0.85) saturate(1.15);
}

@keyframes bgDrift {
  0% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(-10px, -5px) scale(1.03);
  }
  100% {
    transform: translate(5px, 3px) scale(1.02);
  }
}

/* ==================== 粒子画布 ==================== */
#particle-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

/* ==================== 飘落竹叶容器 ==================== */
#leaves-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
}

.leaf {
  position: absolute;
  top: -60px;
  opacity: 0;
  animation: leafFall linear forwards;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.leaf svg {
  width: 100%;
  height: 100%;
}

@keyframes leafFall {
  0% {
    transform: translateY(0) rotate(0deg) rotateY(0deg);
    opacity: 0;
  }
  5% {
    opacity: 0.85;
  }
  50% {
    opacity: 0.7;
  }
  90% {
    opacity: 0.35;
  }
  100% {
    transform: translateY(105vh) rotate(720deg) rotateY(360deg);
    opacity: 0;
  }
}

/* ==================== 登录框容器 ==================== */
.login-wrapper {
  position: relative;
  z-index: 10;
  perspective: 1200px;
}

/* 登录卡片 - 3D翻转容器 */
.login-card {
  width: 400px;
  max-width: 92vw;
  min-height: 480px;
  position: relative;
  transform-style: preserve-3d;
  border-radius: var(--radius);
  /* 入场动画由 JS 触发 */
  opacity: 0;
  transform: translateY(30px) scale(0.95);
  transition: opacity 0.8s cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.4s ease;
}

.login-card.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* 卡片悬停微动 */
.login-card:hover {
  box-shadow: var(--shadow-hover);
}

.login-card.visible:not(.flipped):hover {
  transform: translateY(-2px) scale(1);
}

/* 翻转状态 */
.login-card.flipped {
  transform: rotateY(180deg) !important;
  transition: opacity 0.8s cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 0.6s ease,
              box-shadow 0.4s ease;
}

.login-card.flipped.visible {
  transform: rotateY(180deg) !important;
}

.login-card.flipped.visible:hover {
  transform: rotateY(180deg) translateY(-2px) !important;
}

/* ==================== 卡片正反面通用 ==================== */
.card-face {
  background: var(--card-bg);
  backdrop-filter: var(--card-blur);
  -webkit-backdrop-filter: var(--card-blur);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  min-height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: box-shadow 0.4s ease;
}

/* 正面 */
.card-front {
  z-index: 2;
}

/* 背面 */
.card-back {
  transform: rotateY(180deg);
  z-index: 1;
}

/* ==================== 装饰竹节 ==================== */
.card-decoration {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  overflow: hidden;
}

.bamboo-node {
  position: absolute;
  width: 60px;
  height: 4px;
  background: linear-gradient(90deg, transparent, rgba(165, 214, 167, 0.5), transparent);
  border-radius: 2px;
  opacity: 0.4;
}

.top-node {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

.bottom-node {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

/* ==================== Logo 区域 ==================== */
.login-header {
  padding: 40px 36px 20px;
  text-align: center;
}

.login-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: iconPulse 3s ease-in-out infinite;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.login-icon:hover {
  transform: scale(1.08);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.login-icon:active {
  transform: scale(0.95);
}

@keyframes iconPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.2); }
  50% { box-shadow: 0 0 0 14px rgba(255, 255, 255, 0); }
}

.login-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: 2px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 1px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* ==================== 表单区域 ==================== */
.login-body {
  padding: 10px 36px 36px;
}

.login-error {
  background: rgba(211, 47, 47, 0.2);
  border: 1px solid rgba(211, 47, 47, 0.4);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: #FFCDD2;
  margin-bottom: 16px;
  display: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: shake 0.5s ease;
}

.login-error.show {
  display: block;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* 输入组 */
.input-group {
  position: relative;
  margin-bottom: 16px;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
  z-index: 1;
}

.input-group input {
  width: 100%;
  height: 50px;
  padding: 0 16px 0 44px;
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 15px;
  font-family: var(--font);
  color: var(--text);
  background: var(--input-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all var(--transition);
  outline: none;
}

.input-group input::placeholder {
  color: var(--text-light);
}

.input-group input:focus {
  border-color: rgba(255, 255, 255, 0.5);
  background: var(--input-focus-bg);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.08);
  color: #fff;
}

.input-group input:focus ~ .input-icon {
  color: rgba(255, 255, 255, 0.9);
}

/* 登录按钮 */
.login-btn {
  width: 100%;
  height: 50px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  letter-spacing: 4px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all var(--transition);
  margin-top: 8px;
}

.login-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.login-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.login-btn:active {
  transform: translateY(0);
}

.login-btn:active::before {
  width: 300px;
  height: 300px;
}

.login-btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

.login-btn.loading .btn-text {
  display: none;
}

.login-btn.loading .btn-loading {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
}

.btn-loading {
  display: none;
}

.spinner {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 底部链接 */
.login-footer {
  text-align: center;
  margin-top: 20px;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition);
}

.footer-link:hover {
  color: #fff;
  text-decoration: none;
}

.footer-text {
  font-size: 13px;
  color: var(--text-muted);
}

/* ==================== 注册弹窗 ==================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.register-card {
  background: var(--card-bg);
  backdrop-filter: var(--card-blur);
  -webkit-backdrop-filter: var(--card-blur);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 400px;
  max-width: 92vw;
  overflow: hidden;
  transform: translateY(20px) scale(0.95);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.show .register-card {
  transform: translateY(0) scale(1);
}

.register-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 0;
}

.register-header h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  color: var(--text);
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.modal-close-btn {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition);
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.register-body {
  padding: 20px 28px 28px;
}

.register-error {
  background: rgba(211, 47, 47, 0.2);
  border: 1px solid rgba(211, 47, 47, 0.4);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: #FFCDD2;
  margin-bottom: 16px;
  display: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.register-error.show {
  display: block;
  animation: shake 0.5s ease;
}

.register-submit {
  margin-top: 4px;
}

.register-switch {
  text-align: center;
  margin-top: 18px;
}

.register-switch a {
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
}

.register-switch a:hover {
  color: #fff;
}

/* ==================== Toast ==================== */
.toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-family: var(--font);
  font-weight: 500;
  color: #fff;
  pointer-events: auto;
  animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
             toastOut 0.3s ease 2.5s forwards;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.toast.success { background: rgba(46, 125, 50, 0.85); }
.toast.error { background: rgba(211, 47, 47, 0.85); }
.toast.info { background: rgba(33, 150, 243, 0.85); }

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-20px) scale(0.9);
  }
}

/* ==================== 音乐图标触发按钮 ==================== */
.music-toggle-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition);
  z-index: 10;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.music-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
  transform: scale(1.08);
}

.music-toggle-btn:active {
  transform: scale(0.95);
}

/* 背面返回按钮 */
.music-back-btn {
  top: 12px;
  right: 12px;
}

/* ==================== 音乐播放器（背面） ==================== */
.music-player {
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 480px;
}

/* 顶部标题 */
.music-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.music-icon-pulse {
  width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.9);
  animation: musicIconPulse 2s ease-in-out infinite;
}

@keyframes musicIconPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.2); }
  50% { box-shadow: 0 0 0 10px rgba(255, 255, 255, 0); }
}

.music-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 2px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* 当前播放信息 */
.now-playing {
  text-align: center;
  margin-bottom: 16px;
  min-height: 44px;
}

.song-name {
  display: block;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.song-artist {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* 进度条 */
.progress-area {
  width: 100%;
  margin-bottom: 18px;
}

.progress-bar {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, rgba(255,255,255,0.6), rgba(255,255,255,0.9));
  border-radius: 3px;
  width: 0%;
  transition: width 0.1s linear;
  position: relative;
}

.progress-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.2s, left 0.1s linear;
  box-shadow: 0 0 6px rgba(255,255,255,0.5);
}

.progress-bar:hover .progress-thumb {
  opacity: 1;
}

.time-info {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-light);
}

/* 控制按钮 */
.music-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 20px;
}

.ctrl-btn {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.8);
  transition: all var(--transition);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
  transform: scale(1.1);
}

.ctrl-btn:active {
  transform: scale(0.95);
}

.ctrl-play {
  width: 52px;
  height: 52px;
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3);
}

.ctrl-play:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* 歌曲列表 */
.playlist {
  width: 100%;
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.playlist::-webkit-scrollbar {
  width: 4px;
}

.playlist::-webkit-scrollbar-track {
  background: transparent;
}

.playlist::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.playlist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.25s ease;
  border: 1px solid transparent;
}

.playlist-item:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

.playlist-item.active {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
}

.playlist-item .pl-index {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}

.playlist-item.active .pl-index {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.playlist-item .pl-info {
  flex: 1;
  min-width: 0;
}

.playlist-item .pl-name {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist-item.active .pl-name {
  color: #fff;
  font-weight: 500;
}

.playlist-item .pl-artist {
  font-size: 11px;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist-item.active .pl-artist {
  color: var(--text-muted);
}

.playlist-item .pl-playing-icon {
  display: none;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.7);
}

.playlist-item.active .pl-playing-icon {
  display: flex;
}

/* ==================== 响应式 ==================== */
@media (max-width: 480px) {
  .login-card {
    width: 94vw;
    border-radius: 18px;
  }

  .card-face {
    border-radius: 18px;
  }

  .login-header {
    padding: 32px 24px 16px;
  }

  .login-body {
    padding: 8px 24px 28px;
  }

  .login-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
  }

  .login-title {
    font-size: 22px;
  }

  .input-group input {
    height: 46px;
    font-size: 14px;
  }

  .login-btn {
    height: 46px;
    font-size: 15px;
  }

  .register-card {
    width: 94vw;
  }

  .register-header {
    padding: 20px 20px 0;
  }

  .register-body {
    padding: 16px 20px 24px;
  }

  .music-player {
    padding: 16px 18px 20px;
    min-height: 420px;
  }

  .playlist {
    max-height: 160px;
  }

  .song-name {
    max-width: 220px;
  }
}
