/* ============================================================
   佛山政策通 · 适老化与阅读增强
   字号缩放、阅读模式、触控尺寸、对比度与动效偏好
   ============================================================ */

/* 三档字号：标准 / 大字 / 特大 */
html[data-font="large"] { --a11y-text: 1.12; }
html[data-font="xlarge"] { --a11y-text: 1.25; }

/* 辅助文字加深，提升小字对比度（WCAG AA） */
:root { --text-muted: #6f746d; }

/* ---------- 字号切换按钮 ---------- */
.font-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 58px;
  height: 38px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-sub);
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .02em;
  transition: border-color .18s var(--ease), color .18s var(--ease), background .18s var(--ease);
}
.font-toggle-word {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
}
.font-toggle:hover { border-color: var(--primary); color: var(--primary); }
.font-toggle:focus-visible { outline: 2px solid var(--seal); outline-offset: 2px; }
.font-toggle[data-mode="large"],
.font-toggle[data-mode="xlarge"] {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-hover);
}

/* ---------- 触控尺寸 ---------- */
.btn { min-height: 44px; }
.btn-sm { min-height: 36px; }
.chip { min-height: 40px; padding-top: 8px; padding-bottom: 8px; }
.page-btn { min-width: 40px; height: 40px; }
.header-icon-link { width: 40px; height: 40px; }
.nav-toggle { width: 44px; height: 44px; }

@media (max-width: 768px) {
  .chip { min-height: 44px; }
  .page-btn { min-width: 44px; height: 44px; }
}

@media (max-width: 480px) {
  .font-toggle { min-width: 40px; padding: 0 7px; }
  .font-toggle-word { display: none; }
}

/* 大字模式下页头不因文字变大而溢出 */
html[data-font] .header-link { display: none; }
html[data-font="large"] .main-nav a { font-size: 15px; padding-left: 9px; padding-right: 9px; }
html[data-font="xlarge"] .main-nav a { font-size: 15.5px; padding-left: 8px; padding-right: 8px; }
@media (max-width: 1180px) {
  html[data-font] .main-nav a { padding-left: 7px; padding-right: 7px; }
}
@media (max-width: 900px) {
  html[data-font] .header-inner { gap: 10px; }
}

/* ---------- 详情页工具栏 ---------- */
.detail-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-sub);
  font-size: calc(13.5px * var(--a11y-text));
  font-weight: 600;
  transition: border-color .18s var(--ease), color .18s var(--ease), background .18s var(--ease);
}
.tool-btn:hover { border-color: var(--primary); color: var(--primary); }
.tool-btn:focus-visible { outline: 2px solid var(--seal); outline-offset: 2px; }
.tool-btn[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.tool-btn svg { width: 16px; height: 16px; }
.tool-btn[hidden] { display: none; }

/* ---------- 阅读模式 ---------- */
body.reading-mode #readableContent {
  max-width: 48rem;
  margin: 0 auto;
}
body.reading-mode .detail-grid { grid-template-columns: minmax(0, 1fr); }
body.reading-mode .detail-side { display: none; }
body.reading-mode .detail-header { padding: 32px 34px; }
body.reading-mode .card { padding: 30px 34px; }
body.reading-mode .detail-header h1 { font-size: calc(30px * var(--a11y-text)); }
body.reading-mode .prose.doc-body { font-size: calc(20px * var(--a11y-text)); line-height: 2.1; }
body.reading-mode .prose.doc-body p { margin-bottom: 18px; }
body.reading-mode .interpret-block p,
body.reading-mode .card-desc { line-height: 1.95; }

@media (max-width: 768px) {
  body.reading-mode .detail-header { padding: 22px 18px; }
  body.reading-mode .card { padding: 22px 18px; }
  body.reading-mode .detail-header h1 { font-size: calc(24px * var(--a11y-text)); }
  body.reading-mode .prose.doc-body { font-size: calc(18px * var(--a11y-text)); }
}

/* ---------- 日历可读性 ---------- */
html[data-font] .calendar-cell { min-height: 88px; }
html[data-font="xlarge"] .calendar-cell { min-height: 100px; }
html[data-font] .calendar-weekdays,
html[data-font] .calendar-grid { min-width: 680px; }
html[data-font] .calendar-event {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
  overflow: hidden;
  text-overflow: clip;
}

/* ---------- 动效与焦点 ---------- */
/* 尊重系统“减少动态效果”设置 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

:focus-visible {
  outline: 2px solid var(--seal);
  outline-offset: 2px;
}

/* 打印时隐藏交互控件 */
@media print {
  .font-toggle,
  .detail-tools,
  .back-to-top { display: none !important; }
}

/* ---------- 移动端可读性与触控 ---------- */
@media (max-width: 768px) {
  .prose { font-size: calc(17px * var(--a11y-text)); line-height: 1.85; }
  .meta-item { font-size: calc(14px * var(--a11y-text)); }
  .detail-header h1, .page-hero h1 { font-size: calc(21px * var(--a11y-text)); line-height: 1.45; }
  .chip, .pagination a, .pagination span { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
  .filter-group select, .filter-group input, .search-input { min-height: 44px; font-size: 15px; }
  .tool-btn { min-height: 44px; }
  .list-item-foot { gap: 6px 8px; }
}

/* ---------- 跳转到主内容 ---------- */
.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 200;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  transition: top .18s var(--ease);
}
.skip-link:focus {
  top: 12px;
}
