/* ==========================================================================
   base.css — reset / 字体栈 / 排版 / 焦点环 / 滚动条 / reduced-motion
   对应 design-spec §3 字体与排版、§4.5 阴影、§8.4 降级、§9.2 焦点、§9.5 语义
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* 锚点跳转不被 sticky 导航盖住 */
  scroll-padding-top: calc(var(--m-nav-h) + var(--m-hud-h) + var(--m-s-3));
  background: var(--m-bg-base);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--m-bg-base);
  color: var(--m-text-1);
  font-family: var(--m-font-body);
  font-size: var(--m-fs-body);
  line-height: var(--m-lh-body);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  /* 遮罩/抽屉打开时禁止背景滚动 */
  overscroll-behavior-y: none;
}

body[data-scroll-lock="true"] {
  overflow: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  font-family: var(--m-font-display);
  font-weight: 800;
  color: var(--m-text-1);
  text-shadow: 2px 2px 0 var(--m-line-hard);
  overflow-wrap: anywhere;
}

h1 {
  font-size: var(--m-fs-h1);
  line-height: var(--m-lh-h1);
  letter-spacing: .02em;
}

h2 {
  font-size: var(--m-fs-h2);
  line-height: var(--m-lh-h2);
  letter-spacing: .02em;
}

h3 {
  font-size: var(--m-fs-h3);
  line-height: var(--m-lh-h3);
  font-weight: 700;
  letter-spacing: .04em;
}

h4 {
  font-size: var(--m-fs-h4);
  line-height: var(--m-lh-h4);
  font-weight: 700;
  letter-spacing: .04em;
}

p {
  margin: 0 0 var(--m-s-4);
  overflow-wrap: anywhere;
}

p:last-child {
  margin-bottom: 0;
}

ul,
ol {
  margin: 0 0 var(--m-s-4);
  padding-left: var(--m-s-5);
}

li {
  margin-bottom: var(--m-s-1);
}

a {
  color: var(--m-brand);
  text-decoration: none;
  text-underline-offset: 4px;
}

a:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

strong,
b {
  font-weight: 700;
  color: var(--m-text-1);
}

small {
  font-size: var(--m-fs-caption);
  line-height: var(--m-lh-caption);
  color: var(--m-text-3);
}

img,
svg,
canvas {
  max-width: 100%;
  display: block;
}

button {
  font: inherit;
  color: inherit;
}

input,
select,
textarea {
  font: inherit;
  /* iOS 输入框字号 <16px 会自动放大页面 */
  font-size: var(--m-fs-body);
}

hr {
  border: none;
  border-top: 1px dashed var(--m-line-dashed);
  margin: var(--m-s-5) 0;
}

::selection {
  background: var(--m-brand);
  color: var(--m-brand-ink);
}

/* ── §9.2 焦点环：一律 outline，禁止 box-shadow（会盖掉像素描边） ── */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--m-focus);
  outline-offset: var(--m-focus-offset);
  border-radius: inherit;
}

/* 纸面反色区（/about/ 长文）焦点环换深蓝 */
.m-paper :where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline-color: var(--m-focus-paper);
}

/* 全站禁止 outline:none —— 这条注释即纪律，勿加 */

/* ── 跳转链接 ─────────────────────────────────────────────────── */
.m-skip {
  position: fixed;
  top: -200px;
  left: var(--m-s-2);
  z-index: var(--m-z-skip);
  height: var(--m-hit);
  padding: var(--m-s-3) var(--m-s-4);
  background: var(--m-brand);
  color: var(--m-brand-ink);
  font-weight: 700;
  box-shadow: var(--m-shadow-2);
  border-radius: var(--m-r-1);
}

.m-skip:focus {
  top: var(--m-s-2);
  text-decoration: none;
}

/* ── §3.4 数字样式（四种，禁止自由发挥） ──────────────────────── */
.m-num {
  font-family: var(--m-font-pixel);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: .08em;
  font-weight: 700;
}

.m-num--display {
  font-size: var(--m-fs-display);
  line-height: var(--m-lh-display);
  color: var(--m-brand);
  text-shadow: 3px 3px 0 var(--m-line-hard);
}

.m-num--xl {
  font-size: var(--m-fs-h3);
  line-height: 1.1;
}

.m-num--md {
  font-size: var(--m-fs-h3);
  line-height: 1.2;
  /* 计数动画时列不左右跳 */
  min-width: 5ch;
  display: inline-block;
}

.m-num--sm {
  font-size: var(--m-fs-body);
  line-height: 1.4;
}

/* ── §9.5 视觉隐藏 ────────────────────────────────────────────── */
.m-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── 滚动条（深色，像素方块滑块） ─────────────────────────────── */
* {
  scrollbar-color: var(--m-line-strong) var(--m-bg-deep);
  scrollbar-width: thin;
}

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--m-bg-deep);
}

::-webkit-scrollbar-thumb {
  background: var(--m-line-strong);
  border-radius: 0;
  border: 2px solid var(--m-bg-deep);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--m-line-soft);
}

/* ── §6.2 响应式字号（只在 <768 变动，正文永不缩小） ──────────── */
@media (max-width: 767px) {
  :root {
    --m-pad-x: 16px;
    --m-gutter: 12px;
    --m-section-gap: 48px;
    --m-card-pad: 16px;
    --m-nav-h: 56px;
    --m-hud-h: 48px;
    --m-btn-h-cta: 56px;
  }

  h1 {
    font-size: 32px;
  }

  h2 {
    font-size: 24px;
  }

  body {
    /* 移动端底部固定 CTA 条不盖内容 */
    padding-bottom: calc(var(--m-btmbar-h) + env(safe-area-inset-bottom, 0px));
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  /* 平板段：屏幕比手机宽，留白不该比手机还窄（原来 20px < 手机 16px 的视觉密度）。
     同时把容器收到 800px：原来 max-width:100% 让正文一行排到 700+px（约 45 个汉字），
     平板竖屏读起来非常累。收到 800 后内容区 736px，仍是单列但行宽可控。 */
  :root {
    --m-pad-x: 32px;
    --m-gutter: 24px;
    --m-section-gap: 72px;
    --m-card-pad: 24px;
    --m-nav-h: 64px;
    --m-max-w: 800px;
  }

  h2 {
    font-size: 28px;
  }
}

@media (min-width: 1024px) and (max-width: 1279px) {
  :root {
    --m-max-w: 960px;
  }
}

/* ── §8.4 prefers-reduced-motion 降级（信息不变，只是没有动态） ── */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }

  html {
    scroll-behavior: auto;
  }

  .m-result-card,
  .m-result-card__score,
  .m-num--count,
  .m-rank-table tbody tr {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .m-confetti,
  .m-scanlines {
    display: none !important;
  }

  .m-skeleton {
    animation: none !important;
    background-image: none !important;
    background: var(--m-bg-surface) !important;
  }

  .m-hud__timer.is-danger {
    animation: none !important;
  }
}

/* ── 打印（家长可能打印家长须知） ─────────────────────────────── */
@media print {
  body {
    background: #fff;
    color: #000;
  }

  .m-nav,
  .m-footer,
  .m-btmbar,
  .m-scanlines {
    display: none !important;
  }
}
