/* ==========================================================================
   Design Tokens & Modern Variable system
   ========================================================================== */
:root {
  color-scheme: light dark;

  /* 配色系统 (使用 light-dark() 以原生支持系统暗色模式) */
  --color-primary: light-dark(#4f46e5, #818cf8);
  --color-primary-hover: light-dark(#4338ca, #6366f1);
  --color-primary-light: light-dark(rgba(79, 70, 229, 0.1), rgba(129, 140, 248, 0.15));
  
  --color-bg-page: light-dark(#f8fafc, #070a13);
  --color-card-bg: light-dark(rgba(255, 255, 255, 0.7), rgba(15, 23, 42, 0.6));
  --color-card-border: light-dark(rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.07));
  
  --color-text: light-dark(#0f172a, #f8fafc);
  --color-text-muted: light-dark(#64748b, #94a3b8);
  
  --color-shadow: light-dark(rgba(79, 70, 229, 0.06), rgba(0, 0, 0, 0.3));
  
  /* 测评维度状态配色 */
  --color-agree: light-dark(#059669, #34d399);
  --color-agree-hover: light-dark(#047857, #059669);
  --color-disagree: light-dark(#e11d48, #fb7185);
  --color-disagree-hover: light-dark(#be123c, #e11d48);
  
  /* 字体与字号 */
  --font-family: 'Outfit', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
  
  /* 圆角 */
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 8px;
}

/* ==========================================================================
   全局重置与基本布局
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--color-bg-page);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  line-height: 1.6;
  position: relative;
}

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

/* ==========================================================================
   炫彩模糊渐变背景网格
   ========================================================================== */
.bg-blur-grid {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
}

.circle {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: light-dark(0.4, 0.25);
  transition: background-color 0.8s ease;
}

.circle-1 {
  top: -10%;
  left: 5%;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, #818cf8 0%, rgba(129, 140, 248, 0) 70%);
}

.circle-2 {
  bottom: 10%;
  right: -5%;
  width: 45vw;
  height: 45vw;
  background: radial-gradient(circle, #c084fc 0%, rgba(192, 132, 252, 0) 70%);
}

.circle-3 {
  top: 40%;
  left: 30%;
  width: 35vw;
  height: 35vw;
  background: radial-gradient(circle, #60a5fa 0%, rgba(96, 165, 250, 0) 70%);
}

/* ==========================================================================
   导航头部 (Header)
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: light-dark(rgba(248, 250, 252, 0.8), rgba(7, 10, 19, 0.8));
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-card-border);
}

.header-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-text {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #4f46e5, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  border: 1px solid rgba(129, 140, 248, 0.3);
}

.theme-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text);
  padding: 0.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, transform 0.2s;
  width: 40px;
  height: 40px;
  border: 1px solid var(--color-card-border);
}

.theme-btn:hover {
  background-color: var(--color-primary-light);
  transform: scale(1.05);
}

.theme-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* 主题图标控制 */
.sun-icon { display: block; width: 20px; height: 20px; }
.moon-icon { display: none; width: 20px; height: 20px; }

:root[class="dark"] .sun-icon { display: none; }
:root[class="dark"] .moon-icon { display: block; }

/* ==========================================================================
   主体容器 (Content & Glass Card)
   ========================================================================== */
.app-content {
  flex: 1;
  padding: 3rem 1.5rem;
  display: flex;
  align-items: center;
}

.container {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.glass-card {
  background: var(--color-card-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--color-card-border);
  box-shadow: 0 20px 50px var(--color-shadow);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  transition: box-shadow 0.3s ease;
  position: relative;
}

/* ==========================================================================
   通用视图动画与状态
   ========================================================================== */
.view {
  display: none;
  opacity: 0;
  transform: translateY(20px);
}

.view.active {
  display: flex;
  flex-direction: column;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  transition-behavior: allow-discrete;
}

@starting-style {
  .view.active {
    opacity: 0;
    transform: translateY(20px);
  }
}

.view-title {
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 1rem;
  text-wrap: balance;
  background: linear-gradient(135deg, var(--color-text) 60%, var(--color-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.view-subtitle {
  color: var(--color-text-muted);
  font-size: 1.1rem;
  margin-bottom: 2rem;
  text-wrap: pretty;
}

/* ==========================================================================
   视图 - 开始页面 (Start View)
   ========================================================================== */
.feature-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 2.5rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border-radius: 50px;
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid rgba(129, 140, 248, 0.15);
}

.tag svg {
  stroke: var(--color-primary);
}

.cta-section {
  display: flex;
  justify-content: center;
  margin-bottom: 3rem;
}

/* ==========================================================================
   通用按钮样式 (Buttons)
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.9rem 2rem;
  border-radius: var(--radius-md);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 52px; /* Touch target size optimized */
}

.btn-primary {
  background-color: var(--color-primary);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background-color: light-dark(rgba(15, 23, 42, 0.05), rgba(255, 255, 255, 0.05));
  color: var(--color-text);
  border: 1px solid var(--color-card-border);
}

.btn-secondary:hover:not(:disabled) {
  background-color: light-dark(rgba(15, 23, 42, 0.08), rgba(255, 255, 255, 0.08));
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ==========================================================================
   WorkBuddy 推广广告位 (Ad Banner)
   ========================================================================== */
.ad-container {
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  border: 1px solid var(--color-card-border);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
  background-color: light-dark(rgba(255, 255, 255, 0.5), rgba(30, 41, 59, 0.3));
}

.ad-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background-color: rgba(15, 23, 42, 0.6);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
  backdrop-filter: blur(4px);
  z-index: 10;
  pointer-events: none;
}

.ad-link {
  display: block;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.ad-image {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.ad-hover-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(79, 70, 229, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.ad-hover-text {
  background-color: var(--color-primary);
  color: #ffffff;
  padding: 0.6rem 1.2rem;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.ad-link:hover .ad-image {
  transform: scale(1.03);
}

.ad-link:hover .ad-hover-overlay {
  opacity: 1;
}

/* ==========================================================================
   视图 - 答题页面 (Quiz View)
   ========================================================================== */
.quiz-header {
  margin-bottom: 2rem;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

.progress-text strong {
  font-weight: 700;
  color: var(--color-primary);
}

.progress-percent {
  color: var(--color-text-muted);
}

.progress-bar-container {
  height: 8px;
  background-color: light-dark(#e2e8f0, #1e293b);
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary) 0%, #c084fc 100%);
  border-radius: 10px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.question-container {
  min-height: 110px;
  display: flex;
  align-items: center;
  margin-bottom: 2.5rem;
}

.question-text {
  font-size: clamp(1.2rem, 4vw, 1.45rem);
  font-weight: 700;
  line-height: 1.4;
  color: var(--color-text);
  text-wrap: pretty;
}

.options-container {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-bottom: 2.5rem;
}

/* 李克特量表答题选项按钮 */
.option-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-card-border);
  background-color: light-dark(rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.02));
  color: var(--color-text);
  font-size: 1.05rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  min-height: 56px;
}

.option-indicator {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid light-dark(#cbd5e1, #475569);
  flex-shrink: 0;
  position: relative;
  transition: all 0.2s ease;
}

.option-indicator::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #ffffff;
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.option-btn:hover {
  transform: translateX(4px);
  background-color: light-dark(rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.05));
  border-color: var(--color-primary);
}

/* 颜色倾斜化选项激活状态 */
.option-btn.agree-strong:hover { border-color: var(--color-agree); }
.option-btn.agree:hover { border-color: var(--color-agree); }
.option-btn.disagree:hover { border-color: var(--color-disagree); }
.option-btn.disagree-strong:hover { border-color: var(--color-disagree); }

.option-btn.selected {
  color: #ffffff;
}

.option-btn.selected .option-indicator {
  border-color: #ffffff;
}

.option-btn.selected .option-indicator::after {
  transform: translate(-50%, -50%) scale(1);
}

/* 选中不同程度按钮的填充颜色 */
.option-btn.selected.agree-strong {
  background-color: var(--color-agree);
  border-color: var(--color-agree);
  box-shadow: 0 4px 15px rgba(5, 150, 105, 0.3);
}

.option-btn.selected.agree {
  background-color: light-dark(#059669e0, #34d399c7);
  border-color: transparent;
  box-shadow: 0 4px 15px rgba(5, 150, 105, 0.15);
}

.option-btn.selected.neutral {
  background-color: light-dark(#64748b, #475569);
  border-color: transparent;
  box-shadow: 0 4px 15px rgba(100, 116, 139, 0.2);
}

.option-btn.selected.disagree {
  background-color: light-dark(#e11d48de, #fb7185c7);
  border-color: transparent;
  box-shadow: 0 4px 15px rgba(225, 29, 72, 0.15);
}

.option-btn.selected.disagree-strong {
  background-color: var(--color-disagree);
  border-color: var(--color-disagree);
  box-shadow: 0 4px 15px rgba(225, 29, 72, 0.3);
}

.quiz-navigation {
  display: flex;
  justify-content: flex-start;
}

/* ==========================================================================
   视图 - 结果报告页面 (Result View)
   ========================================================================== */
.result-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.badge-accent {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--color-primary);
  background-color: var(--color-primary-light);
  padding: 0.35rem 0.85rem;
  border-radius: 50px;
  margin-bottom: 0.8rem;
}

.result-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.result-code-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 1.2rem;
}

.result-code {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(3rem, 10vw, 4.5rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -2px;
  background: linear-gradient(135deg, var(--color-primary) 0%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.result-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
}

.result-summary {
  font-size: 1.05rem;
  color: var(--color-text-muted);
  max-width: 500px;
  margin: 0 auto;
}

/* 维度双向分流条 (Split Bars) */
.dimension-section {
  background-color: light-dark(rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.01));
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-md);
  padding: 1.8rem;
  margin-bottom: 2.5rem;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.dimensions-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.dimension-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dimension-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  font-weight: 600;
}

.label-left { text-align: left; }
.label-right { text-align: right; }

.split-bar-container {
  height: 14px;
  background-color: light-dark(#e2e8f0, #1e293b);
  border-radius: 50px;
  position: relative;
  overflow: hidden;
}

.split-bar-center-line {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background-color: light-dark(#94a3b8, #475569);
  z-index: 5;
}

.split-bar-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0%;
  transition: width 1s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 50px;
}

.split-bar-fill.left {
  right: 50%;
  background: linear-gradient(to left, var(--color-primary), #60a5fa);
}

.split-bar-fill.right {
  left: 50%;
  background: linear-gradient(to right, var(--color-primary), #c084fc);
}

.split-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: #ffffff;
  border: 3.5px solid var(--color-primary);
  transform: translate(-50%, -50%);
  z-index: 10;
  transition: left 1s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.dimension-percentages {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-text);
  font-family: 'Outfit', sans-serif;
}

.percent-left { text-align: left; }
.percent-right { text-align: right; }

/* 性格解读细则卡片 */
.details-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

@media (min-width: 600px) {
  .details-section {
    grid-template-columns: 1fr 1fr;
  }
}

.detail-card {
  background-color: light-dark(rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.01));
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

.detail-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.8rem;
  color: var(--color-primary);
  border-left: 3px solid var(--color-primary);
  padding-left: 0.6rem;
}

.detail-card p {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  line-height: 1.55;
  text-wrap: pretty;
}

.result-actions {
  display: flex;
  justify-content: center;
}

/* ==========================================================================
   页脚 (Footer)
   ========================================================================== */
.app-footer {
  border-top: 1px solid var(--color-card-border);
  padding: 2rem 1.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  background: light-dark(#f1f5f9, #05070e);
}

.footer-container {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-seo-links {
  font-size: 0.8rem;
  opacity: 0.8;
}

/* ==========================================================================
   响应式设计与无障碍 (A11y/RWD)
   ========================================================================== */
@media (max-width: 640px) {
  .app-content {
    padding: 1.5rem 1rem;
  }
  
  .glass-card {
    padding: 1.5rem;
  }
  
  .option-btn {
    padding: 1rem;
    font-size: 0.95rem;
  }
  
  .dimension-section {
    padding: 1.2rem;
  }
}

/* 提升 coarse 指针(如触屏)下的交互按钮面积 */
@media (pointer: coarse) {
  .btn, .option-btn, .theme-btn {
    padding-top: 1.1rem;
    padding-bottom: 1.1rem;
  }
}

/* 尊重用户系统减弱动画设置 */
@media (prefers-reduced-motion: reduce) {
  *, .view.active, .progress-bar-fill, .split-bar-fill, .split-marker, .ad-image {
    transition: none !important;
    animation: none !important;
    transform: none !important;
  }
}
