/* ================================================================
   Earth API - 用户协议样式 (agreement.css) v1.0
   ----------------------------------------------------------------
   设计依据：windows/DESIGN.md（Earth API 全局设计系统）
     · 主色青色 #0EA5E9（操作/链接/激活态）
     · 强调色琥珀 #F59E0B（仅敏感/金额，本页禁用）
     · 禁紫色；禁渐变文字；禁 em-dash；禁全大写眉题
     · ring 风格替代 border：默认 1px 内描边，hover 加深，focus 3px 光环
     · 同心圆角：外圆角 = 内圆角 + padding
     · 字体栈：Outfit + Noto Sans SC + JetBrains Mono（数值用 mono + tabular-nums）
     · 缓动：--ea-ease 与 --ea-ease-spring，反 AI 味的统一弹性入场
   视觉参考：claude.com 文档阅读体验（编辑式阅读布局，非白卡居中模板）
   命名空间：ea- 前缀，与 ec-（控制台）/ ew-（钱包）/ mk-（市场）平行
   ================================================================ */

/* ---------- 设计令牌 ---------- */
:root {
  /* 背景 */
  --ea-bg: #f8fafc;
  --ea-bg-elevated: #ffffff;
  --ea-bg-hover: #f1f5f9;
  --ea-bg-subtle: #fafbfc;
  --ea-bg-active: rgba(14, 165, 233, 0.08);

  /* 主色 - 青色（DESIGN.md 规定） */
  --ea-primary: #0ea5e9;
  --ea-primary-hover: #0284c7;
  --ea-primary-deep: #0369a1;
  --ea-primary-soft: rgba(14, 165, 233, 0.10);
  --ea-primary-border: rgba(14, 165, 233, 0.25);
  --ea-primary-text: #0369a1;

  /* 语义色 */
  --ea-success: #10b981;
  --ea-success-soft: rgba(16, 185, 129, 0.10);
  --ea-success-text: #047857;
  --ea-error: #ef4444;
  --ea-error-soft: rgba(239, 68, 68, 0.10);
  --ea-error-text: #b91c1c;

  /* 文字 */
  --ea-text-primary: #0f172a;
  --ea-text-secondary: #475569;
  --ea-text-tertiary: #64748b;
  --ea-text-muted: #94a3b8;
  --ea-text-placeholder: #94a3b8;
  --ea-text-on-primary: #ffffff;

  /* 边框 / ring 风格（DESIGN.md 4.0 规则） */
  --ea-border: #e2e8f0;
  --ea-border-strong: #cbd5e1;
  --ea-border-subtle: #f1f5f9;
  --ea-ring: 0 0 0 1px rgba(15, 23, 42, 0.06);
  --ea-ring-hover: 0 0 0 1px rgba(14, 165, 233, 0.18), 0 4px 12px rgba(15, 23, 42, 0.05);
  --ea-ring-focus: 0 0 0 3px rgba(14, 165, 233, 0.15);
  --ea-ring-error: 0 0 0 1px rgba(239, 68, 68, 0.22);

  /* 圆角 - 同心圆角体系 */
  --ea-radius-xs: 5px;
  --ea-radius-sm: 7px;
  --ea-radius-md: 10px;
  --ea-radius-lg: 12px;
  --ea-radius-xl: 14px;
  --ea-radius-2xl: 18px;
  --ea-radius-full: 999px;

  /* 阴影 - 极轻（DESIGN.md 6.1） */
  --ea-shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --ea-shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
  --ea-shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
  --ea-shadow-lg: 0 12px 24px rgba(15, 23, 42, 0.08), 0 4px 8px rgba(15, 23, 42, 0.04);

  /* 尺寸 */
  --ea-site-header-height: 68px;
  --ea-content-max: 820px;
  --ea-reading-max: 760px;

  /* 字体 - DESIGN.md 3.2 规定 */
  --ea-font-base: 'Outfit', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', Roboto, sans-serif;
  --ea-font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', Consolas, monospace;

  /* 间距 - 同 DESIGN.md 5.2 */
  --ea-space-1: 0.25rem;
  --ea-space-2: 0.5rem;
  --ea-space-3: 0.75rem;
  --ea-space-4: 1rem;
  --ea-space-6: 1.5rem;
  --ea-space-8: 2rem;
  --ea-space-12: 3rem;
  --ea-space-16: 4rem;
  --ea-space-24: 6rem;

  /* 缓动 - 反 AI 味统一弹性入场 */
  --ea-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ea-ease-fast: cubic-bezier(0.4, 0, 0.2, 1);
  --ea-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---------- 基础重置 ---------- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  font-family: var(--ea-font-base);
  background: var(--ea-bg);
  color: var(--ea-text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: var(--ea-primary);
  text-decoration: none;
  transition: color 0.15s var(--ea-ease-fast);
}
a:hover {
  color: var(--ea-primary-hover);
}

/* 选中色 */
::selection {
  background: rgba(14, 165, 233, 0.18);
  color: var(--ea-text-primary);
}

/* 纤细滚动条 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--ea-border-strong);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--ea-text-muted);
}

/* ---------- skip-link ---------- */
.ea-skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 1000;
  padding: 10px 16px;
  background: var(--ea-bg-elevated);
  color: var(--ea-primary);
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--ea-radius-md);
  box-shadow: var(--ea-shadow-md);
  transition: top 0.18s var(--ea-ease-fast);
}
.ea-skip-link:focus {
  top: 16px;
}

/* ---------- 阅读布局 ---------- */
.ea-page {
  min-height: calc(100vh - var(--ea-site-header-height));
  margin-top: var(--ea-site-header-height);
  background: var(--ea-bg);
  padding: 56px 24px 64px;
}

.ea-container {
  max-width: var(--ea-content-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ---------- 标题区（编辑式大标题，左对齐） ---------- */
.ea-title-block {
  max-width: var(--ea-reading-max);
  margin: 0 auto;
  text-align: left;
  padding: 0 4px;
}

.ea-title {
  font-family: var(--ea-font-base);
  font-size: clamp(1.85rem, 4vw, 2.4rem);
  font-weight: 600;
  color: var(--ea-text-primary);
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin: 0 0 10px;
  text-wrap: balance;
}

.ea-subtitle {
  font-size: 0.95rem;
  color: var(--ea-text-tertiary);
  line-height: 1.6;
  margin: 0;
  text-wrap: pretty;
}

/* ---------- tabs（下划线激活态） ---------- */
.ea-tabs {
  max-width: var(--ea-reading-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--ea-border);
  padding: 0 4px;
}

.ea-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 12px 18px;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ea-text-secondary);
  letter-spacing: -0.005em;
  transition: color 0.18s var(--ea-ease-fast);
}
.ea-tab:hover {
  color: var(--ea-text-primary);
}
.ea-tab:focus-visible {
  outline: none;
  border-radius: var(--ea-radius-sm);
  box-shadow: var(--ea-ring-focus);
}

/* 激活态：青色文字 + 青色下划线（位于底边线之上） */
.ea-tab[aria-selected="true"] {
  color: var(--ea-primary);
  font-weight: 600;
}
.ea-tab[aria-selected="true"]::after {
  content: '';
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--ea-primary);
}

/* ---------- 正文阅读区容器 ---------- */
.ea-body-wrap {
  max-width: var(--ea-reading-max);
  margin: 0 auto;
  width: 100%;
  background: var(--ea-bg-elevated);
  border-radius: var(--ea-radius-2xl);
  padding: 40px 44px;
  box-shadow: var(--ea-ring), var(--ea-shadow-xs);
  transition: box-shadow 0.25s var(--ea-ease);
}
.ea-body-wrap:hover {
  box-shadow: var(--ea-ring-hover);
}

/* 同心圆角：内部正文区 */
.ea-body {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--ea-text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  text-wrap: pretty;
}

.ea-body h1,
.ea-body h2,
.ea-body h3,
.ea-body h4 {
  font-family: var(--ea-font-base);
  margin: 28px 0 14px;
  color: var(--ea-text-primary);
  letter-spacing: -0.015em;
  line-height: 1.3;
  font-weight: 600;
  text-wrap: balance;
}
.ea-body h1 { font-size: 1.5rem; }
.ea-body h2 { font-size: 1.25rem; }
.ea-body h3 { font-size: 1.125rem; }
.ea-body h4 { font-size: 1rem; }

.ea-body h1:first-child,
.ea-body h2:first-child,
.ea-body h3:first-child,
.ea-body h4:first-child {
  margin-top: 0;
}

.ea-body p {
  margin: 0 0 16px;
}
.ea-body p:last-child {
  margin-bottom: 0;
}

.ea-body ul,
.ea-body ol {
  margin: 0 0 16px;
  padding-left: 1.5em;
}
.ea-body li {
  margin: 6px 0;
  line-height: 1.75;
}

.ea-body a {
  color: var(--ea-primary);
  text-decoration: underline;
  text-decoration-color: rgba(14, 165, 233, 0.35);
  text-underline-offset: 3px;
  transition: color 0.15s var(--ea-ease-fast), text-decoration-color 0.15s var(--ea-ease-fast);
}
.ea-body a:hover {
  color: var(--ea-primary-hover);
  text-decoration-color: var(--ea-primary-hover);
}

.ea-body strong {
  font-weight: 600;
  color: var(--ea-text-primary);
}

.ea-body code {
  font-family: var(--ea-font-mono);
  font-size: 0.875em;
  padding: 2px 6px;
  background: var(--ea-bg-hover);
  border-radius: var(--ea-radius-xs);
  color: var(--ea-primary-text);
  font-variant-numeric: tabular-nums;
}

.ea-body pre {
  font-family: var(--ea-font-mono);
  font-size: 0.875rem;
  padding: 16px 18px;
  background: var(--ea-bg-hover);
  border-radius: var(--ea-radius-md);
  overflow-x: auto;
  line-height: 1.6;
  margin: 0 0 16px;
}

.ea-body blockquote {
  margin: 0 0 16px;
  padding: 8px 18px;
  border-left: 3px solid var(--ea-primary);
  background: var(--ea-primary-soft);
  color: var(--ea-text-secondary);
  border-radius: 0 var(--ea-radius-sm) var(--ea-radius-sm) 0;
}

.ea-body hr {
  border: none;
  height: 1px;
  background: var(--ea-border);
  margin: 28px 0;
}

/* ---------- 骨架占位（shimmer） ---------- */
.ea-skeleton {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ea-skeleton-line {
  height: 14px;
  border-radius: var(--ea-radius-xs);
  background: linear-gradient(
    90deg,
    rgba(15, 23, 42, 0.05) 0%,
    rgba(15, 23, 42, 0.10) 50%,
    rgba(15, 23, 42, 0.05) 100%
  );
  background-size: 200% 100%;
  animation: eaShimmer 1.6s var(--ea-ease) infinite;
}
.ea-skeleton-line:nth-child(1) { width: 55%; height: 22px; margin-bottom: 8px; }
.ea-skeleton-line:nth-child(2) { width: 100%; }
.ea-skeleton-line:nth-child(3) { width: 92%; }
.ea-skeleton-line:nth-child(4) { width: 100%; }
.ea-skeleton-line:nth-child(5) { width: 75%; }
.ea-skeleton-line:nth-child(6) { width: 100%; }
.ea-skeleton-line:nth-child(7) { width: 88%; }
.ea-skeleton-line:nth-child(8) { width: 40%; height: 22px; margin-top: 8px; }
.ea-skeleton-line:nth-child(9) { width: 100%; }
.ea-skeleton-line:nth-child(10) { width: 95%; }
.ea-skeleton-line:nth-child(11) { width: 100%; }
.ea-skeleton-line:nth-child(12) { width: 60%; }

@keyframes eaShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.ea-loading-text {
  margin: 0 0 20px;
  font-size: 0.85rem;
  color: var(--ea-text-muted);
  letter-spacing: 0.01em;
}

/* ---------- 错误态 + 重试 ---------- */
.ea-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 48px 20px;
  text-align: center;
}

.ea-error-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--ea-radius-full);
  background: var(--ea-error-soft);
  color: var(--ea-error);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ea-error-icon svg {
  width: 22px;
  height: 22px;
}

.ea-error-message {
  margin: 0;
  font-size: 0.95rem;
  color: var(--ea-error-text);
  line-height: 1.6;
  max-width: 420px;
}

.ea-error-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ea-text-muted);
  line-height: 1.6;
}

.ea-retry-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 18px;
  border-radius: var(--ea-radius-md);
  background: var(--ea-bg-elevated);
  color: var(--ea-primary);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--ea-ring), var(--ea-shadow-xs);
  transition: box-shadow 0.18s var(--ea-ease), transform 0.12s var(--ea-ease-fast);
  margin-top: 4px;
}
.ea-retry-btn svg {
  width: 15px;
  height: 15px;
}
.ea-retry-btn:hover {
  box-shadow: var(--ea-ring-hover);
  color: var(--ea-primary-hover);
}
.ea-retry-btn:active {
  transform: scale(0.96);
}
.ea-retry-btn:focus-visible {
  outline: none;
  box-shadow: var(--ea-ring-focus);
}

/* ---------- 返回链接区 ---------- */
.ea-back {
  max-width: var(--ea-reading-max);
  margin: 8px auto 0;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
  font-size: 0.86rem;
  color: var(--ea-text-muted);
}

.ea-back-sep {
  color: var(--ea-border-strong);
  padding: 0 4px;
}

.ea-back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 4px 8px;
  border-radius: var(--ea-radius-sm);
  color: var(--ea-text-secondary);
  font-weight: 500;
  transition: color 0.15s var(--ea-ease-fast), background 0.15s var(--ea-ease-fast);
}
.ea-back-link svg {
  width: 14px;
  height: 14px;
  transition: transform 0.18s var(--ea-ease);
}
.ea-back-link:hover {
  color: var(--ea-primary);
  background: var(--ea-primary-soft);
}
.ea-back-link:hover svg {
  transform: translateX(-2px);
}
.ea-back-link:focus-visible {
  outline: none;
  box-shadow: var(--ea-ring-focus);
}

/* ---------- 可见性辅助 ---------- */
.ea-hidden {
  display: none !important;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
  .ea-page {
    padding: 44px 24px 56px;
  }
}

@media (max-width: 768px) {
  .ea-page {
    padding: 32px 16px 48px;
  }
  .ea-container {
    gap: 22px;
  }
  .ea-title {
    font-size: 1.6rem;
  }
  .ea-subtitle {
    font-size: 0.88rem;
  }
  .ea-body-wrap {
    padding: 28px 24px;
    border-radius: var(--ea-radius-xl);
  }
  .ea-body {
    font-size: 0.95rem;
    line-height: 1.78;
  }
  .ea-body h1 { font-size: 1.35rem; }
  .ea-body h2 { font-size: 1.15rem; }
  .ea-body h3 { font-size: 1.05rem; }
  .ea-tab {
    padding: 10px 14px;
    font-size: 0.88rem;
  }
}

@media (max-width: 480px) {
  .ea-page {
    padding: 24px 14px 40px;
  }
  .ea-title {
    font-size: 1.4rem;
  }
  .ea-body-wrap {
    padding: 22px 18px;
    border-radius: var(--ea-radius-lg);
  }
  .ea-body {
    font-size: 0.92rem;
    line-height: 1.75;
  }
  .ea-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .ea-tabs::-webkit-scrollbar {
    display: none;
  }
  .ea-tab {
    flex-shrink: 0;
    padding: 10px 12px;
  }
  .ea-back {
    font-size: 0.82rem;
  }
}

/* ---------- 可访问性 ---------- */
:focus-visible {
  outline: 2px solid var(--ea-primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .ea-skeleton-line {
    animation: none;
    background: rgba(15, 23, 42, 0.06);
  }
}

@media (prefers-contrast: high) {
  .ea-body-wrap,
  .ea-retry-btn {
    border: 1px solid var(--ea-border-strong);
  }
  .ea-tab[aria-selected="true"]::after {
    height: 3px;
  }
}

/* 高对比度下强制不透明背景 */
@media (prefers-reduced-transparency: reduce) {
  .ea-body-wrap,
  .ea-retry-btn {
    background: var(--ea-bg-elevated);
  }
}
