/*
  基础层：重置 → 排版 → 装饰件。依赖 tokens.css，不自带任何写死的色值。
*/

/* ---------- 重置 ---------- */

*,
*::before,
*::after {
	box-sizing: border-box;
}

/*
  hidden 必须真的能隐藏。浏览器自带的 [hidden]{display:none} 是元素选择器级，
  任何类选择器里的 display 都压得过它 —— 表现是 .actionbar（display:flex）
  这类组件上 el.hidden = true 完全无效，一颗注定失败的按钮还亮着等人点。
  用 !important 是刻意的：hidden 是「不该存在」，不该被布局规则翻盘。
*/
[hidden] {
	display: none !important;
}

/* 纸底放 html 上。body 被 --shell-max 收窄后两侧露出的是 html ——
   只给 body 上底色的表现是宽屏下两边各一条纯白、中间一条米色。 */
html {
	-webkit-text-size-adjust: 100%;
	background-color: var(--c-paper);
	background-image: var(--tex-paper);
}

body {
	margin: 0 auto;
	max-width: var(--shell-max);
	font-family: var(--ff-sans);
	font-size: var(--fs-body);
	line-height: var(--lh);
	color: var(--c-ink);
	background-color: var(--c-paper);
	background-image: var(--tex-paper);
	/* 横向永不滚动：子元素溢出应换行或截断，而不是让整页能左右拖 ——
     藏在屏幕右边的内容很少有人发现。 */
	overflow-x: hidden;
	overscroll-behavior-y: contain;
}

img {
	max-width: 100%;
	display: block;
}

button,
input,
select,
textarea {
	font: inherit;
	color: inherit;
}

button {
	cursor: pointer;
	background: none;
	border: 0;
	padding: 0;
}

ul,
ol {
	margin: 0;
	padding: 0;
	list-style: none;
}

/* 焦点环全站统一。去掉 outline 的表现是键盘用户不知道焦点在哪。 */
:focus-visible {
	outline: 2px solid var(--c-brand);
	outline-offset: 2px;
	border-radius: var(--r-sm);
}

/* 点按反馈。移动端没有 hover，靠 :active 给触感 —— 没有的表现是
   用户点完不确定有没有点上，于是又点一次。 */
a,
button {
	-webkit-tap-highlight-color: transparent;
}

/* ---------- 排版 ---------- */

h1,
h2,
h3,
h4 {
	font-family: var(--ff-serif);
	line-height: var(--lh-tight);
	letter-spacing: var(--ls-title);
	margin: 0;
	font-weight: 600;
}

h1 {
	font-size: var(--fs-xl);
}

h2 {
	font-size: var(--fs-lg);
}

h3 {
	font-size: var(--fs-md);
}

h4 {
	font-size: var(--fs-body);
}

p {
	margin: 0 0 var(--sp-3);
}

p:last-child {
	margin-bottom: 0;
}

a {
	color: var(--c-brand);
	text-decoration: none;
}

.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;
}

.t-sub {
	color: var(--c-ink-sub);
}

.t-faint {
	color: var(--c-ink-faint);
}

.t-faint.gai {
	color: #ffffff;
}

.t-xs {
	font-size: var(--fs-xs);
}

.t-sm {
	font-size: var(--fs-sm);
}

.t-md {
	font-size: var(--fs-md);
}

.t-serif {
	font-family: var(--ff-serif);
}

.t-num {
	font-family: var(--ff-num);
	font-variant-numeric: tabular-nums;
}

.t-bold {
	font-weight: 600;
}

.t-cinnabar {
	color: var(--c-cinnabar);
}

.t-brand {
	color: var(--c-brand);
}

.t-gold {
	color: var(--c-gold-ink);
}

/* 截断。两行以上一律用这个，不靠固定高度 overflow hidden ——
   固定高度的表现是字号一变就露出半行字的上半截。 */
.clamp-1,
.clamp-2,
.clamp-3 {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.clamp-1 {
	-webkit-line-clamp: 1;
}

.clamp-2 {
	-webkit-line-clamp: 2;
}

.clamp-3 {
	-webkit-line-clamp: 3;
}

/* ---------- 装饰件 ---------- */

/*
  区块标题。左侧一道朱砂短竖，取典籍段首的鱼尾标记。
  右侧「更多」用 margin-left:auto 顶出去，不用 space-between ——
  用 space-between 的表现是没有「更多」时标题被推到左端而副标题居中。
*/
.sec-head {
	display: flex;
	align-items: baseline;
	gap: var(--sp-2);
	margin: var(--sp-6) 0 var(--sp-3);
	padding-left: var(--sp-3);
	border-left: 3px solid var(--c-cinnabar);
}

.sec-head .sec-t {
	font-family: var(--ff-serif);
	font-size: var(--fs-lg);
	line-height: 1.25;
	letter-spacing: var(--ls-title);
	font-weight: 600;
}

.sec-head .sec-sub {
	font-size: var(--fs-xs);
	color: var(--c-ink-faint);
	letter-spacing: var(--ls-wide);
	text-transform: uppercase;
}

/*
  写成独立的 .sec-more 而不是 .sec-head .sec-more —— 后代选择器的表现是
  放在 .sec-head 外面的那几个「更多」拿不到 min-height 与箭头，
  掉到 21px 高、还少一个箭头，而它跟区块里的那些看着是同一种东西。

  本项目在 v1 已经栽过一次同型的错：`.hint` 原先写作 `.field .hint`，
  十二处 hint 里有五处不在 .field 内，完全没拿到样式；
  更麻烦的是改 `.field .hint` 的人以为全站都改了，实际只改到七处。
*/
.sec-more {
	margin-left: auto;
	font-size: var(--fs-sm);
	color: var(--c-ink-sub);
	display: inline-flex;
	align-items: center;
	gap: 2px;
	min-height: var(--tap-sm);
}

.sec-more::after {
	content: '';
	width: 5px;
	height: 5px;
	border-top: 1.5px solid currentColor;
	border-right: 1.5px solid currentColor;
	transform: rotate(45deg);
}

/* 印章。方章不圆角 —— 圆角的表现是它看着像个普通标签，不像章。 */
.seal {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-family: var(--ff-serif);
	font-size: var(--fs-cap);
	font-weight: 600;
	line-height: 1;
	letter-spacing: 0.04em;
	padding: 3px 5px;
	border-radius: var(--r-sm);
	border: 1px solid currentColor;
	color: var(--c-cinnabar);
	flex: none;
}

.seal-gold {
	color: var(--c-gold-ink);
}

.seal-brand {
	color: var(--c-brand);
}

.seal-brand.gai {
	color: #b1a46c;
}

.seal-fill {
	background: var(--c-cinnabar);
	color: #fff;
	border-color: var(--c-cinnabar);
}

.seal-fill-gold {
	background: var(--c-gold);
	color: #3a2500;
	border-color: var(--c-gold);
}

/* 竖排小标。药柜抽屉上的标签，用在主视觉侧边。 */
.vlabel {
	writing-mode: vertical-rl;
	font-family: var(--ff-serif);
	font-size: var(--fs-sm);
	letter-spacing: 0.28em;
	color: var(--c-ink-faint);
}

/* 回纹分隔。章节之间用，比一条灰线有来处。 */
.fret {
	height: 8px;
	margin: var(--sp-6) 0;
	background-image: var(--tex-fret);
	background-repeat: repeat-x;
	opacity: 0.65;
}

/* 双线分隔，带中心圆点。用在页脚与段末收尾。 */
.rule-dot {
	display: flex;
	align-items: center;
	gap: var(--sp-3);
	margin: var(--sp-6) 0;
	color: var(--c-line);
}

.rule-dot::before,
.rule-dot::after {
	content: '';
	flex: 1;
	height: 1px;
	background: currentColor;
}

.rule-dot span {
	width: 4px;
	height: 4px;
	border-radius: 50%;
	background: var(--c-celadon);
	flex: none;
}