/* ═══════════════════════════════════════════════════════════════════
   Accessibility — 大字体 / 简洁模式 / 高对比度 / 减弱动效
   ═══════════════════════════════════════════════════════════════════ */

/* ── Large Text Mode ── */
html[data-font-scale="large"] body {
  font-size: var(--fs-body);
}

html[data-font-scale="xl"] body {
  font-size: var(--fs-body);
}

/* Enforce a readable floor for legacy components that still use px/rem sizes.
   max() preserves intentionally larger headings while lifting small labels. */
html[data-font-scale="large"] :where(p, li, label, td, th, small, code, button, input, select, textarea, a, .meta, .tag, .fy-pill, .si-state, .nav-link) {
  font-size: var(--fs-body-s) !important;
  line-height: var(--lh-body-s) !important;
}
html[data-font-scale="xl"] :where(p, li, label, td, th, small, code, button, input, select, textarea, a, .meta, .tag, .fy-pill, .si-state, .nav-link) {
  font-size: var(--fs-body-s) !important;
  line-height: var(--lh-body-s) !important;
}

/* Some compact page layers use fixed pixels for their standard desktop view.
   Reapply semantic tokens here so “大字/超大” changes the actual reading
   hierarchy rather than only the inherited body size. */
html[data-font-scale="large"] .fy-page-header h1,
html[data-font-scale="xl"] .fy-page-header h1 {
  font-size: var(--fs-h1);
  line-height: var(--lh-h1);
}

html[data-font-scale="large"] .fy-page-header p,
html[data-font-scale="xl"] .fy-page-header p,
html[data-font-scale="large"] .fy-mode-indicator,
html[data-font-scale="xl"] .fy-mode-indicator {
  font-size: var(--fs-body-s);
  line-height: var(--lh-body-s);
}

html[data-font-scale="large"] :where(.button, input, select, textarea),
html[data-font-scale="xl"] :where(.button, input, select, textarea) {
  min-height: 60px;
}

/* Large text: DH panel layout — narrower companion, more answer room */
body.large-text .fy-digital-human-panel,
html[data-font-scale="large"] .fy-digital-human-panel,
html[data-font-scale="xl"] .fy-digital-human-panel {
  grid-template-columns: minmax(260px, 0.7fr) minmax(360px, 1.3fr);
}

body.large-text .fy-media-status,
html[data-font-scale="xl"] .fy-media-status {
  grid-template-columns: 1fr;
}

@media (max-width: 900px) {
  body.large-text .fy-digital-human-panel,
  html[data-font-scale="large"] .fy-digital-human-panel,
  html[data-font-scale="xl"] .fy-digital-human-panel {
    grid-template-columns: 1fr;
  }
}

/* ── Simple Mode ── */
body.simple-mode .fy-card {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* Simple mode reduces visual density but never hides provenance, warnings or
   actions. Official links remain visible and usable. */
body.simple-mode :where(.fy-kb-charts, .fy-kb-capabilities, .fy-corpus-section-head p, .fy-variant-note, .fy-page-header > p, .fy-chart-card-head > p) { display: none; }
body.simple-mode :where(.fy-kb-overview, .fy-corpus, .fy-card, .source-card, .knowledge-card, .case-card) { box-shadow: none; }
body.simple-mode .fy-kb-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
body.simple-mode .fy-kb-stat { min-height: 0; }
body.simple-mode .fy-kb-meta { margin-top: 0; }
body.simple-mode .fy-corpus-row-main p { display: none; }

/* ── High Contrast Mode ── */
body.fy-high-contrast {
  --color-paper-card: #ffffff;
  --color-ink: #07111f;
  --color-ink-soft: #26364d;
  background: #ffffff !important;
}

body.fy-high-contrast::before {
  display: none;
}

/* ── Reduced Motion ── */
body.fy-reduced-motion *,
body.fy-reduced-motion *::before,
body.fy-reduced-motion *::after {
  animation: none !important;
  transition: none !important;
}

body.fy-reduced-motion .fy-avatar-pulse { animation: none; }

/* Also respect OS-level preference */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Risk 不只靠颜色 (UI 2.1)：badge/chip 前加几何圆点 ── */
.fy-risk-badge,
.fy-risk-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.fy-risk-badge::before,
.fy-risk-chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.9;
  flex-shrink: 0;
}

/* ── Focus Visible (UI 2.0：清晰可见的键盘焦点) ──
   可点击/可聚焦元素获得焦点时给出高可见描边，仅针对键盘导航。 */
:is(a, button, input, select, textarea, [tabindex], summary, [role="button"]):focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-s);
}

/* ── Touch target 下限 (适老硬要求，见方案 §13.1) ── */
a, button, [role="button"], input, select, textarea {
  touch-action: manipulation;
}
button, [role="button"], a.nav-link {
  min-height: var(--touch-min);
}

/* 减少动画：同时应用用户设置与系统偏好 (方案 §13.5) */
body.fy-reduced-motion *,
body.fy-reduced-motion *::before,
body.fy-reduced-motion *::after {
  animation-duration: 0.01ms !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}
