@charset "utf-8";

/* ==========================================================================
 * Self-Hosted Webfonts (Latin Modern WOFF2 + CJK Biaodian + Montserrat + JetBrains Mono)
 * Zero external Google Fonts requests; font-display: fallback avoids flash on cached/fast loads.
 * ========================================================================== */
@font-face {
  font-family: "LM-Roman-10";
  font-style: normal;
  font-weight: 400;
  font-display: fallback;
  src: url("../fonts/lmroman10-regular.woff2") format("woff2");
}

@font-face {
  font-family: "LM-Roman-10";
  font-style: italic;
  font-weight: 400;
  font-display: fallback;
  src: url("../fonts/lmroman10-italic.woff2") format("woff2");
}

@font-face {
  font-family: "LM-Roman-10";
  font-style: normal;
  font-weight: 700;
  font-display: fallback;
  src: url("../fonts/lmroman10-bold.woff2") format("woff2");
}

@font-face {
  font-family: "LM-Roman-10";
  font-style: italic;
  font-weight: 700;
  font-display: fallback;
  src: url("../fonts/lmroman10-bolditalic.woff2") format("woff2");
}

@font-face {
  font-family: "LM-Mono-10";
  font-style: normal;
  font-weight: 400;
  font-display: fallback;
  src: url("../fonts/lmmono10-regular.woff2") format("woff2");
}

@font-face {
  font-family: "LM-Mono-10";
  font-style: italic;
  font-weight: 400;
  font-display: fallback;
  src: url("../fonts/lmmono10-italic.woff2") format("woff2");
}

@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 400 600;
  font-display: fallback;
  src: url("../fonts/montserrat-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 700;
  font-display: fallback;
  src: url("../fonts/jetbrains-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: italic;
  font-weight: 400;
  font-display: fallback;
  src: url("../fonts/jetbrains-mono-italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "biaodian";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/biaodian-minus59.woff2") format("woff2");
  unicode-range: U+3001-3002, U+3008-3011, U+3014-3015, U+FF01, U+FF08-FF09, U+FF0C, U+FF1A-FF1B, U+FF1F;
}

@font-face {
  font-family: "biaodian";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/biaodian-minus59.woff2") format("woff2");
  unicode-range: U+3001-3002, U+3008-3011, U+3014-3015, U+FF01, U+FF08-FF09, U+FF0C, U+FF1A-FF1B, U+FF1F;
}

@font-face {
  font-family: "biaodian";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/biaodian-minus59.woff2") format("woff2");
  unicode-range: U+3001-3002, U+3008-3011, U+3014-3015, U+FF01, U+FF08-FF09, U+FF0C, U+FF1A-FF1B, U+FF1F;
}

/* Metric-matched system fallback faces to prevent layout shift if webfonts are delayed */
@font-face {
  font-family: "LM-Roman-10 Fallback";
  src: local("Georgia"), local("Times New Roman");
  size-adjust: 100%;
  ascent-override: 112.7%;
  descent-override: 29%;
  line-gap-override: 0%;
  unicode-range: U+0000-024F, U+2000-206F;
}

@font-face {
  font-family: "Montserrat Fallback";
  src: local("Arial"), local("Helvetica Neue");
  size-adjust: 109.68%;
  ascent-override: 88.26%;
  descent-override: 22.89%;
  line-gap-override: 0%;
  unicode-range: U+0000-024F, U+2000-206F;
}

@font-face {
  font-family: "JetBrains Mono Fallback";
  src: local("Menlo"), local("Consolas"), local("Courier New");
  size-adjust: 100%;
  ascent-override: 102%;
  descent-override: 30%;
  line-gap-override: 0%;
  unicode-range: U+0000-024F, U+2000-206F, U+2190-2193;
}

/* ==========================================================================
 * Design Tokens — Paper & Ink Monochrome (Typo + Mashiro)
 * ========================================================================== */
:root {
  /* Surfaces */
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --bg-quote: #f7f7f7;
  --bg-header: rgba(255, 255, 255, 0.86);
  --bg-code: #f8f8f8;
  --bg-zebra-even: #ffffff;
  --bg-zebra-odd: #fafafa;

  /* Ink (WCAG AA+ contrast on #ffffff) */
  --ink: #111111;
  --ink-body: #222222;
  --ink-secondary: #555555;
  --ink-muted: #6e6e6e;
  --ink-refer: #1c2032;

  /* Rules & Borders */
  --border: #dddddd;
  --border-subtle: #ececec;
  --border-strong: #111111;
  --border-code: #e5e7eb;

  /* Interactive Accents */
  --link: #2659b8;
  --link-hover: #173f8c;
  --hashtag: #666973;
  --paginator-inactive: #eeeeee;
  --paginator-active: #111111;

  /* Typography Stacks */
  --font-serif: "biaodian", "LM-Roman-10", "LM-Roman-10 Fallback", "Songti TC", "Songti SC", "Noto Serif CJK TC", "STSong", Georgia, serif;
  --font-cjk: "Songti TC", "Noto Serif TC", "Songti SC", "PMingLiU", serif;
  --font-ui: "Montserrat", "Montserrat Fallback", -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "JetBrains Mono Fallback", "LM-Mono-10", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Measure & Spacing */
  --shell-width: 820px;
  --measure: 44rem;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 32px;
  --space-xl: 56px;
}

/* Explicit Dark Theme (toggled via JS) */
:root[data-theme="dark"] {
  --bg: #1c1e24;
  --bg-subtle: #23262e;
  --bg-quote: #23262e;
  --bg-header: rgba(28, 30, 36, 0.86);
  --bg-code: #15171c;
  --bg-zebra-even: #1c1e24;
  --bg-zebra-odd: #21242c;

  --ink: #f1f3f5;
  --ink-body: #dadde3;
  --ink-secondary: #b0b5bf;
  --ink-muted: #8f96a3;
  --ink-refer: #cbd2e0;

  --border: #363a45;
  --border-subtle: #2b2e37;
  --border-strong: #d4d8e0;
  --border-code: #2c303a;

  --link: #7ab3ef;
  --link-hover: #a1cbf7;
  --hashtag: #9fa6b5;
  --paginator-inactive: #343844;
  --paginator-active: #f1f3f5;
}

/* System Dark Mode fallback before JS hydration */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1e24;
    --bg-subtle: #23262e;
    --bg-quote: #23262e;
    --bg-header: rgba(28, 30, 36, 0.86);
    --bg-code: #15171c;
    --bg-zebra-even: #1c1e24;
    --bg-zebra-odd: #21242c;

    --ink: #f1f3f5;
    --ink-body: #dadde3;
    --ink-secondary: #b0b5bf;
    --ink-muted: #8f96a3;
    --ink-refer: #cbd2e0;

    --border: #363a45;
    --border-subtle: #2b2e37;
    --border-strong: #d4d8e0;
    --border-code: #2c303a;

    --link: #7ab3ef;
    --link-hover: #a1cbf7;
    --hashtag: #9fa6b5;
    --paginator-inactive: #343844;
    --paginator-active: #f1f3f5;
  }
}
