/* ==========================================================================
   小问号vibecoding · Master Shared UI Components (v2.0 · Monochrome Editorial)
   主站与所有子作品共用的基础样式、黑白高对比按钮体系、点阵底纹、玻璃面板、
   子作品统一返回顶栏与 Toast 轻提示。
   ========================================================================== */

@import url("./xwh-tokens.css");

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background-color: var(--xwh-black);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--xwh-font-sans);
  font-size: 16px;
  line-height: 1.66;
  color: var(--xwh-text-on-dark);
  background-color: var(--xwh-black);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.xwh-theme-light {
  background-color: var(--xwh-light-canvas);
  color: var(--xwh-text-on-light);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--xwh-mint);
  outline-offset: 3px;
}

.xwh-container {
  width: min(100% - var(--xwh-gutter) * 2, var(--xwh-max-w));
  margin-inline: auto;
}

/* --------------------------------------------------------------------------
   1. 签名视觉表面：点阵矩阵 & 细微胶片质感
   -------------------------------------------------------------------------- */
.xwh-dot-matrix {
  background-color: var(--xwh-black);
  background-image: radial-gradient(rgba(255, 255, 255, 0.14) 1px, transparent 1px);
  background-size: 28px 28px;
}

/* --------------------------------------------------------------------------
   2. 品牌手写感 Logo
   -------------------------------------------------------------------------- */
.xwh-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
  flex-shrink: 0;
}

.xwh-brand-wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.xwh-brand-cn {
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.xwh-brand-en {
  font-family: var(--xwh-font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  opacity: 0.58;
}

/* --------------------------------------------------------------------------
   3. 黑白高对比按钮体系 (Wegic 级纯净质感)
   -------------------------------------------------------------------------- */
.xwh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 22px;
  border-radius: var(--xwh-radius-pill);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  border: 1px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
  transition:
    transform var(--xwh-dur-fast) var(--xwh-ease-out),
    background-color var(--xwh-dur-fast) var(--xwh-ease-out),
    border-color var(--xwh-dur-fast) var(--xwh-ease-out),
    color var(--xwh-dur-fast) var(--xwh-ease-out),
    box-shadow var(--xwh-dur-base) var(--xwh-ease-out);
}

.xwh-btn:active {
  transform: scale(0.97);
}

/* 深色背景主按钮：纯白胶囊 + 漆黑字 */
.xwh-btn-white {
  background: #ffffff;
  color: #0a0a0c;
  box-shadow: 0 8px 26px -10px rgba(255, 255, 255, 0.45);
}

.xwh-btn-white:hover {
  background: #f0f0f2;
  transform: translateY(-1px);
  box-shadow: 0 12px 32px -10px rgba(255, 255, 255, 0.55);
}

/* 浅色背景主按钮：纯黑胶囊 + 纯白字 */
.xwh-btn-black {
  background: #0a0a0c;
  color: #ffffff;
  box-shadow: 0 10px 26px -12px rgba(0, 0, 0, 0.5);
}

.xwh-btn-black:hover {
  background: #232328;
  transform: translateY(-1px);
}

/* 深色背景次按钮：冷炭磨砂玻璃 */
.xwh-btn-glass {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.xwh-btn-glass:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

/* 浅色背景次按钮 */
.xwh-btn-outline-light {
  background: #ffffff;
  border-color: var(--xwh-light-border-strong);
  color: var(--xwh-text-on-light);
}

.xwh-btn-outline-light:hover {
  background: #f4f4f5;
  border-color: rgba(0, 0, 0, 0.28);
}

.xwh-btn-ghost {
  background: transparent;
  color: var(--xwh-text-on-dark-muted);
  padding: 0 12px;
}

.xwh-btn-ghost:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.07);
}

.xwh-btn-sm {
  min-height: 36px;
  padding: 0 15px;
  font-size: 13px;
}

/* --------------------------------------------------------------------------
   4. 标签胶囊与微光圆点
   -------------------------------------------------------------------------- */
.xwh-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--xwh-radius-pill);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.78);
}

.xwh-pill-light {
  border-color: rgba(0, 0, 0, 0.08);
  background: rgba(0, 0, 0, 0.045);
  color: #46464f;
}

.xwh-pill-mint {
  border-color: rgba(56, 232, 158, 0.3);
  background: rgba(56, 232, 158, 0.12);
  color: #8af7c8;
}

.xwh-dot-live {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--xwh-mint);
  box-shadow: 0 0 10px var(--xwh-mint);
  animation: xwh-pulse 2.2s infinite ease-in-out;
}

@keyframes xwh-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.8);
  }
}

/* --------------------------------------------------------------------------
   5. 统一深色/浅色卡片（带柔和鼠标聚光）
   -------------------------------------------------------------------------- */
.xwh-card {
  position: relative;
  border-radius: var(--xwh-radius-lg);
  background: rgba(20, 20, 24, 0.78);
  border: 1px solid var(--xwh-dark-border);
  box-shadow: var(--xwh-shadow-glass-panel);
  overflow: hidden;
  transition:
    transform var(--xwh-dur-base) var(--xwh-ease-out),
    border-color var(--xwh-dur-base) var(--xwh-ease-out),
    background-color var(--xwh-dur-base) var(--xwh-ease-out);
}

.xwh-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    380px circle at var(--mx, 50%) var(--my, 50%),
    rgba(255, 255, 255, 0.08),
    transparent 62%
  );
  transition: opacity var(--xwh-dur-base) var(--xwh-ease-out);
}

.xwh-card:hover {
  transform: translateY(-3px);
  border-color: var(--xwh-dark-border-strong);
}

.xwh-card:hover::before {
  opacity: 1;
}

/* --------------------------------------------------------------------------
   6. 表单控件（黑白通用）
   -------------------------------------------------------------------------- */
.xwh-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.xwh-label {
  font-size: 13px;
  font-weight: 600;
  color: inherit;
  opacity: 0.78;
}

.xwh-input,
.xwh-textarea,
.xwh-select {
  width: 100%;
  padding: 12px 15px;
  border-radius: var(--xwh-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
  font-size: 14px;
  line-height: 1.5;
  transition:
    border-color var(--xwh-dur-fast) var(--xwh-ease-out),
    background-color var(--xwh-dur-fast) var(--xwh-ease-out);
}

.xwh-select option {
  background: #141418;
  color: #ffffff;
}

.xwh-input::placeholder,
.xwh-textarea::placeholder {
  color: rgba(255, 255, 255, 0.36);
}

.xwh-input:focus,
.xwh-textarea:focus,
.xwh-select:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.48);
  background: rgba(255, 255, 255, 0.09);
}

.xwh-textarea {
  resize: vertical;
  min-height: 104px;
}

/* --------------------------------------------------------------------------
   7. 子作品统一接入顶部栏 (Sub-App Unified Monochrome Shell)
   -------------------------------------------------------------------------- */
.xwh-subapp-bar {
  position: sticky;
  top: 0;
  z-index: 60;
  height: 54px;
  padding-inline: clamp(12px, 3vw, 24px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(9, 9, 11, 0.86);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  color: #ffffff;
}

.xwh-subapp-left,
.xwh-subapp-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.xwh-subapp-title {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xwh-subapp-divider {
  width: 1px;
  height: 15px;
  background: rgba(255, 255, 255, 0.18);
}

/* 子作品全屏微粒画布 */
#xwh-subapp-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.xwh-subapp-page {
  position: relative;
  z-index: 2;
}

/* --------------------------------------------------------------------------
   8. Toast 轻提示
   -------------------------------------------------------------------------- */
.xwh-toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  z-index: 140;
  padding: 11px 20px;
  border-radius: var(--xwh-radius-pill);
  background: #121216;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(16px);
  transition:
    opacity 0.25s var(--xwh-ease-out),
    transform 0.25s var(--xwh-ease-out);
}

.xwh-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* --------------------------------------------------------------------------
   9. 全站统一登录 / 注册弹窗与顶栏用户徽章
   -------------------------------------------------------------------------- */
.xwh-auth-slot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.xwh-user-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px 4px 5px;
  border-radius: var(--xwh-radius-pill);
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 13px;
  color: #ffffff;
  max-width: 150px;
}

.xwh-user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: #0a0a0c;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.xwh-user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xwh-auth-backdrop {
  position: fixed;
  inset: 0;
  z-index: 130;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: grid;
  place-items: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s var(--xwh-ease-out);
}

.xwh-auth-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.xwh-auth-modal {
  width: min(440px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  border-radius: 26px;
  background: #111114;
  color: #ffffff;
  font-family: var(--xwh-font-sans);
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 32px 84px rgba(0, 0, 0, 0.8);
  padding: 26px;
  transform: translateY(10px) scale(0.97);
  transition: transform 0.26s var(--xwh-ease-out);
}

.xwh-auth-backdrop.is-open .xwh-auth-modal {
  transform: translateY(0) scale(1);
}

.xwh-auth-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.xwh-auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}

.xwh-auth-title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.xwh-auth-reason {
  margin: 0 0 18px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--xwh-text-on-dark-muted);
}

.xwh-auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  margin-bottom: 16px;
}

.xwh-auth-tab {
  min-height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
  font-weight: 600;
  transition: background-color 0.2s, color 0.2s;
}

.xwh-auth-tab.is-active {
  background: #ffffff;
  color: #0a0a0c;
}

.xwh-auth-error {
  margin-bottom: 14px;
  padding: 10px 13px;
  border-radius: 10px;
  background: rgba(255, 107, 107, 0.14);
  border: 1px solid rgba(255, 107, 107, 0.36);
  color: #ffb4b4;
  font-size: 13px;
}

.xwh-auth-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.xwh-auth-form[hidden] {
  display: none;
}

.xwh-auth-row2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.xwh-auth-submit {
  width: 100%;
  margin-top: 4px;
}

.xwh-pass-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.xwh-pass-wrap .xwh-input {
  width: 100%;
  padding-right: 42px;
}

.xwh-pass-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.56);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: color 140ms ease, background-color 140ms ease;
}

.xwh-pass-toggle:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.xwh-auth-foot {
  margin: 2px 0 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--xwh-text-on-dark-faint);
}

@media (max-width: 520px) {
  .xwh-auth-row2 {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .xwh-card,
  .xwh-btn,
  .xwh-dot-live {
    transition: none;
    animation: none;
  }
}
