/* ==========================================================================
   ABK UI · Base
   轻量 reset、排版、以及最基础的布局原语（stack / cluster / grid）。
   ========================================================================== */

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

* {
  margin: 0;
}

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

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* 纸张微噪点：纯 SVG data URI，无外部请求 */
  background-image: var(--paper-grain);
  background-attachment: fixed;
  transition: background-color var(--dur-slow) var(--ease-out),
              color var(--dur-slow) var(--ease-out);
}

/* 纸张质感：极淡的纤维噪点，叠加在背景之上 */
[data-grain="on"] body {
  --paper-grain: radial-gradient(circle at 20% 30%, rgba(120, 100, 70, .035) 0 1px, transparent 1.5px),
                  radial-gradient(circle at 70% 65%, rgba(120, 100, 70, .03) 0 1px, transparent 1.5px);
  background-size: 7px 7px, 11px 11px;
}

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

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

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

button:disabled {
  cursor: not-allowed;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-hand);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  letter-spacing: .01em;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: .92em;
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

/* ---------------------------------------------------------------- 图标 */
[data-abk-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  line-height: 1;
  vertical-align: middle;
}

[data-abk-icon] > svg {
  width: var(--icon-size, 20px);
  height: var(--icon-size, 20px);
  flex: none;
  pointer-events: none;
}

/* ---------------------------------------------------------------- 焦点 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ---------------------------------------------------------------- 滚动条 */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

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

::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--r-pill);
  border: 3px solid transparent;
  background-clip: content-box;
}

/* ---------------------------------------------------------------- 布局原语 */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap, var(--sp-4));
}

.stack--xs { --gap: var(--sp-1); }
.stack--sm { --gap: var(--sp-2); }
.stack--md { --gap: var(--sp-4); }
.stack--lg { --gap: var(--sp-6); }
.stack--xl { --gap: var(--sp-8); }

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap, var(--sp-2));
}

.cluster--between {
  justify-content: space-between;
}

.cluster--end {
  justify-content: flex-end;
}

.spacer {
  flex: 1;
}

.grid {
  display: grid;
  gap: var(--gap, var(--sp-4));
  grid-template-columns: repeat(auto-fill, minmax(var(--min, 240px), 1fr));
}

.container {
  width: 100%;
  max-width: 1080px;
  margin-inline: auto;
  padding-inline: var(--sp-5);
}

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

/* ---------------------------------------------------------------- 排版工具 */
.text-hand { font-family: var(--font-hand); }
.text-xs { font-size: var(--fs-xs); }
.text-sm { font-size: var(--fs-sm); }
.text-lg { font-size: var(--fs-lg); }
.text-xl { font-size: var(--fs-xl); }
.text-2xl { font-size: var(--fs-2xl); }
.text-muted { color: var(--ink-muted); }
.text-soft { color: var(--ink-soft); }
.text-faint { color: var(--ink-faint); }
.text-accent { color: var(--accent); }
.text-balance { text-wrap: balance; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eyebrow {
  font-family: var(--font-hand);
  font-size: var(--fs-sm);
  color: var(--ink-muted);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.divider {
  height: 1px;
  border: 0;
  background: var(--line);
}

/* 手写高亮：给关键词一条略微歪的“马克笔”底 */
.mark {
  background: linear-gradient(100deg,
    transparent 0 4%,
    var(--accent-soft) 4% 96%,
    transparent 96%);
  padding-inline: 2px;
  border-radius: 2px;
}
