/* Layer order is shared by every page; later files extend these layers. */
@layer reset, tokens, base, layout, components, animations, utilities;

@font-face {
  font-family: "Home Serif";
  src: url("../assets/fonts/home-serif.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body, h1, h2, h3, p, figure, dl, dd { margin: 0; }
  img, svg { display: block; max-width: 100%; }
  img { height: auto; }
  button, input, select, textarea { font: inherit; }
  button, a, select, summary { -webkit-tap-highlight-color: transparent; }
  button { cursor: pointer; }
  ul, ol { padding-inline-start: 1.3em; }
  a { color: inherit; text-underline-offset: .3em; }
  button { color: inherit; }
}

@layer tokens {
  :root {
    color-scheme: light;
    --paper: #fbf8f4;
    --white: #fff;
    --ink: #2f3231;
    --muted: #5d605b;
    --rose: #6d5058;
    --rose-soft: #ede1dd;
    --teal: #2e6f73;
    --teal-soft: #e9f1f0;
    --sand: #f0eae2;
    --field-border: #91827c;
    --display: "Home Serif", "Songti SC", "Noto Serif CJK SC", "STSong", serif;
    --body: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    --gutter: clamp(20px, 4vw, 64px);
    --measure: 1344px;
    --section-space: clamp(72px, 8vw, 120px);
  }
}

@layer base {
  html { scroll-behavior: smooth; scroll-padding-top: 24px; }
  body { background: var(--paper); color: var(--ink); font: 400 17px/1.75 var(--body); }
  h1, h2, .display { font-family: var(--display); font-weight: 500; }
  h1 { font-size: clamp(36px, 4.3vw, 64px); line-height: 1.3; letter-spacing: -.045em; }
  h2 { font-size: clamp(30px, 3.2vw, 46px); line-height: 1.35; letter-spacing: -.035em; }
  h3 { font-size: clamp(21px, 1.7vw, 25px); font-weight: 500; line-height: 1.45; }
  p { max-width: 46em; }
  p + p { margin-top: 1em; }
  a:focus-visible, button:focus-visible, select:focus-visible, summary:focus-visible, input:focus-visible {
    outline: 3px solid var(--teal); outline-offset: 5px;
  }
  ::selection { background: var(--rose-soft); color: var(--ink); }
  [hidden] { display: none !important; }
  section[id], article[id] { scroll-margin-top: 0; }
  summary { cursor: pointer; }
  figcaption, .note { color: var(--muted); font-size: 14px; line-height: 1.65; }
  figcaption { margin-top: 10px; }
  small { font-size: 14px; }
  @media (max-width: 767px) {
    body { font-size: 16px; }
    html { scroll-padding-top: 24px; }
  }
}

@layer utilities {
  .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
  .skip-link { position: fixed; top: 12px; left: 12px; z-index: 100; padding: 12px 20px; background: var(--ink); color: var(--white); transform: translateY(-180%); }
  .skip-link:focus { transform: none; }
}
