/* base.css —— 设计基座:颜色 token、字体、通用组件(按钮/输入框/毛玻璃/toast) */

:root {
  /* 背景与表面 */
  --bg-0: #0b0b0f;
  --bg-1: #16161d;
  --bg-2: #1f1f29;

  /* 毛玻璃 */
  --glass: rgba(255, 255, 255, 0.07);
  --glass-strong: rgba(255, 255, 255, 0.12);
  --glass-brd: rgba(255, 255, 255, 0.14);

  /* 文字 */
  --text-1: #ffffff;
  --text-2: rgba(255, 255, 255, 0.65);
  --text-3: rgba(255, 255, 255, 0.4);

  /* 抖音系强调色 */
  --cyan: #25f4ee;
  --pink: #fe2c55;
  --grad: linear-gradient(135deg, #25f4ee, #fe2c55);

  /* 状态色 */
  --danger: #ff3b5c;
  --ok: #2de0a5;
  --warn: #ffb800;

  /* 圆角 */
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;

  --shadow-pop: 0 10px 34px rgba(254, 44, 85, 0.32);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'HarmonyOS Sans SC',
    'Microsoft YaHei', 'Segoe UI', sans-serif;
  background: var(--bg-0);
  color: var(--text-1);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button { font-family: inherit; }
input { font-family: inherit; }

/* ---- 毛玻璃表面(不支持 backdrop-filter 时回退为不透明深色) ---- */
.glass {
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--glass-brd);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: rgba(22, 22, 29, 0.92); }
}

/* ---- 按钮 ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 999px;
  padding: 0 22px;
  height: 44px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
  background: var(--glass-strong);
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn:hover { filter: brightness(1.12); transform: translateY(-1px); }
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--grad);
  box-shadow: 0 6px 24px rgba(254, 44, 85, 0.35);
}
.btn-primary:hover { box-shadow: var(--shadow-pop); }

.btn-lg { height: 52px; width: 100%; font-size: 17px; letter-spacing: 1px; }

/* ---- 输入框 ---- */
.input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--glass-brd);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-1);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input::placeholder { color: var(--text-3); }
.input:focus {
  border-color: rgba(37, 244, 238, 0.6);
  box-shadow: 0 0 0 3px rgba(37, 244, 238, 0.14);
}

/* 房间号输入:等宽大写、字距拉开 */
.code-input {
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 0.35em;
  font-weight: 700;
  font-size: 18px;
}

/* 输入错误抖动 */
.shake { animation: shake 0.4s ease; }
@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* ---- toast(顶部居中胶囊,抖音式) ---- */
.toasts {
  position: fixed;
  top: calc(max(env(safe-area-inset-top), 12px) + 44px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  max-width: min(78vw, 360px);
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-brd);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
  animation: toast-in 0.28s cubic-bezier(0.22, 1.4, 0.36, 1);
}
.toast.out { animation: toast-out 0.25s ease forwards; }
.toast-error { border-color: rgba(255, 59, 92, 0.55); }
.toast-ok { border-color: rgba(45, 224, 165, 0.55); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-14px) scale(0.92); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(-10px) scale(0.94); }
}

/* 动效降级:尊重系统设置,动画退化为快速淡入淡出 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
