/**
 * base.css — 重置、全局排版、舞台画布的定位、通用工具类。
 */

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

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body, h1, h2, h3, h4, p, ul, ol, dl, dd, figure {
    margin: 0;
  }

  ul, ol {
    padding: 0;
    list-style: none;
  }

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

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

  button {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
  }

  input {
    color: inherit;
    font: inherit;
  }

  b, strong {
    font-weight: 600;
  }

  i, em {
    font-style: normal;
  }

  [hidden] {
    display: none !important;
  }
}

@layer base {
  html {
    background: var(--ink-1);
    color: var(--paper);
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: var(--paper-4) transparent;
    scroll-behavior: smooth;
  }

  /* 平滑滚动由脚本接管时，关掉浏览器自己的 */
  html.has-smooth-scroll,
  html.is-lite {
    scroll-behavior: auto;
  }

  html.is-locked {
    overflow: hidden;
  }

  body {
    min-height: 100svh;
    overflow-x: clip;
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }

  ::selection {
    background: var(--amber);
    color: var(--ink-0);
  }

  :focus-visible {
    outline: 2px solid var(--amber);
    outline-offset: 4px;
    border-radius: 2px;
  }

  [tabindex="-1"]:focus {
    outline: none;
  }

  h1, h2, h3, h4 {
    font-weight: inherit;
    text-wrap: balance;
  }

  kbd {
    padding: 0.15em 0.5em;
    border: 1px solid var(--line-2);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.04em;
    color: var(--paper-3);
  }

  /* ── 舞台 ── 粒子画布固定在最底层，内容在其上滚动 */
  .fx-field {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 0;
    width: 100vw;
    height: 100lvh;
    pointer-events: none;
  }

  /* 不支持 WebGL2 / 脚本未运行时：用一层静态渐变代替粒子 */
  html:not(.has-gl) .fx-field {
    display: none;
  }

  html:not(.has-gl) body {
    background:
      radial-gradient(60rem 40rem at 78% -8%, rgb(255 157 46 / 0.09), transparent 62%),
      radial-gradient(52rem 38rem at 4% 38%, rgb(143 227 214 / 0.06), transparent 60%),
      var(--ink-1);
    background-attachment: fixed;
  }

  .fx-flock {
    position: fixed;
    top: 0;
    left: 0;
    z-index: var(--z-flock);
    width: 100vw;
    height: 100vh;
    pointer-events: none;
  }

  main {
    position: relative;
    z-index: 1;
    /* 任何横向溢出都在这里截住：手机浏览器不会因此把整页缩小 */
    overflow-x: clip;
  }

  .section {
    position: relative;
    padding-block: clamp(5rem, 15vh, 11rem);
  }

  .wrap {
    width: min(100% - var(--gutter) * 2, var(--max));
    margin-inline: auto;
  }

  /* 等宽小标签：全站的「仪表」语气 */
  .mono {
    font-family: var(--font-mono);
    font-size: var(--fs-mono);
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--paper-3);
  }

  .mono > i {
    margin-inline: 0.6em;
    color: var(--paper-4);
  }

  .hl {
    font-weight: inherit;
    color: var(--amber-hi);
  }

  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  .skip {
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 300;
    padding: 0.6rem 1rem;
    border-radius: 999px;
    background: var(--paper);
    color: var(--ink-0);
    transform: translateY(-200%);
  }

  .skip:focus {
    transform: none;
  }

  /* 本地直接打开 / 脚本加载失败时出现的提示条 */
  .notice {
    display: none;
    position: relative;
    z-index: 60;
    padding: 0.75rem var(--gutter);
    background: var(--amber);
    color: var(--ink-0);
    font-size: 0.875rem;
    line-height: 1.6;
  }

  .notice a {
    text-decoration: underline;
    text-underline-offset: 0.2em;
  }

  .notice code {
    padding: 0.1em 0.4em;
    border-radius: 3px;
    background: rgb(6 5 4 / 0.14);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
  }

  html.is-static .notice {
    display: block;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto !important;
  }
}
