/*
Theme Name:   JMustang Child
Theme URI:    https://jmustang.com
Description:  美国华人新闻网站子主题（父主题：Kadence）。所有站点自定义样式与模板均在此，父主题保持可无痛升级。
Author:       JMustang
Template:     kadence
Version:      0.1.0
Text Domain:  jm-child
*/

/* =============================================================
   1. 设计令牌
   ============================================================= */
:root {
	/* 中文系统字体栈 —— 绝不加载中文 Web 字体（完整中文字体 3–8MB，
	   会彻底毁掉移动端首屏）。见 docs/operations.md 的性能红线。 */
	--jm-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI",
		"PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
		"Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
	--jm-font-serif: Georgia, "Songti SC", "SimSun", serif;

	--jm-red: #c8102e;          /* 主色，用于头条、栏目标识 */
	--jm-red-dark: #9c0c24;     /* hover / 已访问 */
	--jm-ink: #1a1a1a;          /* 正文 —— 对白底对比度 16.1:1 */
	--jm-ink-muted: #595959;    /* 元信息 —— 对白底 7.0:1，仍达 AAA */
	--jm-line: #e2e2e2;
	--jm-bg: #ffffff;
	--jm-bg-alt: #f7f7f7;

	--jm-focus: #0057b8;        /* 键盘焦点环，与主色区分以免混淆 */

	--jm-space: 1rem;
	--jm-radius: 4px;
	--jm-maxw: 1200px;
}

/* =============================================================
   2. 中文排版基线
   中文方块字密度高于拉丁字母，沿用英文站的 1.5 行高会非常难读。
   ============================================================= */
body {
	font-family: var(--jm-font-sans);
	color: var(--jm-ink);
	background: var(--jm-bg);
	/* 中英混排时自动插入四分之一空隙 */
	text-spacing: ideograph-alpha ideograph-numeric;
}

.entry-content {
	font-size: 1.0625rem; /* 17px */
	line-height: 1.85;
}

.entry-content p {
	margin-block: 0 1em;
}

/* 中文没有真正的斜体字形，浏览器会做伪斜（机械倾斜），非常难看 */
.entry-content em,
.entry-content i,
cite {
	font-style: normal;
	font-weight: 600;
}

.entry-content blockquote {
	margin: 1.5em 0;
	padding: 0.5em 0 0.5em 1em;
	border-left: 3px solid var(--jm-red);
	color: var(--jm-ink-muted);
}

h1, h2, h3, h4 {
	font-weight: 700;
	line-height: 1.4;      /* 标题行高可略紧，但仍高于英文站 */
	letter-spacing: 0;     /* 中文不加字距，加了会散 */
}

/* =============================================================
   3. 可访问性
   ============================================================= */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
	outline: 3px solid var(--jm-focus);
	outline-offset: 2px;
}

.jm-skip-link {
	position: absolute;
	left: -9999px;
	top: 0;
	z-index: 999;
	padding: 0.75em 1.25em;
	background: var(--jm-bg);
	color: var(--jm-ink);
	border: 2px solid var(--jm-focus);
}
.jm-skip-link:focus {
	left: 0;
}

.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* =============================================================
   4. 栏目区块（首页各模块通用）
   ============================================================= */
.jm-section {
	max-width: var(--jm-maxw);
	margin-inline: auto;
	padding-inline: var(--jm-space);
	margin-block-end: 2.5rem;
}

.jm-section__head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
	border-block-end: 2px solid var(--jm-red);
	padding-block-end: 0.5rem;
	margin-block-end: 1.25rem;
}

.jm-section__title {
	font-size: 1.375rem;
	margin: 0;
}

.jm-section__more {
	font-size: 0.9375rem;
	color: var(--jm-ink-muted);
	text-decoration: none;
	flex: none;
}
.jm-section__more:hover { color: var(--jm-red); }

.jm-grid {
	display: grid;
	gap: 1.5rem;
	grid-template-columns: 1fr;
}
@media (min-width: 600px)  { .jm-grid--3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px)  { .jm-grid--3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 600px)  { .jm-grid--4 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .jm-grid--4 { grid-template-columns: repeat(4, 1fr); } }

/* =============================================================
   5. 文章卡片
   ============================================================= */
.jm-card { display: flex; flex-direction: column; gap: 0.625rem; }

.jm-card__media {
	position: relative;
	display: block;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background: var(--jm-bg-alt);
	border-radius: var(--jm-radius);
}
.jm-card__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.3s ease;
}
.jm-card:hover .jm-card__media img { transform: scale(1.04); }

@media (prefers-reduced-motion: reduce) {
	.jm-card__media img { transition: none; }
	.jm-card:hover .jm-card__media img { transform: none; }
}

.jm-card__title {
	font-size: 1.0625rem;
	line-height: 1.5;
	margin: 0;
}
.jm-card__title a { color: var(--jm-ink); text-decoration: none; }
.jm-card__title a:hover { color: var(--jm-red); }

.jm-card__meta {
	font-size: 0.8125rem;
	color: var(--jm-ink-muted);
	display: flex;
	gap: 0.75rem;
	flex-wrap: wrap;
}

.jm-card__excerpt {
	font-size: 0.9375rem;
	line-height: 1.7;
	color: var(--jm-ink-muted);
	margin: 0;
}

/* 头条：1 大 + N 小 */
.jm-lead {
	display: grid;
	gap: 1.5rem;
	grid-template-columns: 1fr;
	max-width: var(--jm-maxw);
	margin: 1.5rem auto 2.5rem;
	padding-inline: var(--jm-space);
}
@media (min-width: 900px) {
	.jm-lead { grid-template-columns: 1.6fr 1fr; }
	.jm-lead__secondary { display: grid; gap: 1rem; align-content: start; }
	.jm-lead__secondary .jm-card { flex-direction: row; gap: 0.75rem; }
	.jm-lead__secondary .jm-card__media { flex: 0 0 110px; aspect-ratio: 4 / 3; }
}
.jm-lead__primary .jm-card__title { font-size: 1.625rem; font-weight: 700; }

/* =============================================================
   6. 广告位
   广告必须与新闻内容视觉区隔并标注「广告」—— FTC 合规要求，
   也是新闻站的信任基础。无素材时整块不渲染，避免布局跳动（CLS）。
   ============================================================= */
.jm-ad {
	max-width: var(--jm-maxw);
	margin: 2rem auto;
	padding-inline: var(--jm-space);
	text-align: center;
}
.jm-ad__label {
	display: block;
	font-size: 0.6875rem;
	letter-spacing: 0.1em;
	color: var(--jm-ink-muted);
	text-align: start;
	margin-block-end: 0.25rem;
	padding-block-start: 0.25rem;
	border-block-start: 1px solid var(--jm-line);
}
.jm-ad__body img { display: block; margin-inline: auto; height: auto; }

/* =============================================================
   7. 移动端底部导航
   ============================================================= */
.jm-tabbar {
	position: fixed;
	inset-block-end: 0;
	inset-inline: 0;
	z-index: 100;
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	background: var(--jm-bg);
	border-block-start: 1px solid var(--jm-line);
	padding-block-end: env(safe-area-inset-bottom); /* iPhone home indicator */
}
.jm-tabbar__item {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 2px;
	padding: 0.5rem 0.25rem;
	font-size: 0.6875rem;
	color: var(--jm-ink-muted);
	text-decoration: none;
	min-height: 48px;          /* 触摸目标下限 */
	justify-content: center;
}
.jm-tabbar__item[aria-current="page"] { color: var(--jm-red); }
.jm-tabbar__icon { font-size: 1.125rem; line-height: 1; }

@media (min-width: 768px) { .jm-tabbar { display: none; } }
@media (max-width: 767px) { body { padding-block-end: 60px; } }

/* =============================================================
   8. 分享按钮
   ============================================================= */
.jm-share {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-block: 2rem 1rem;
	padding-block-start: 1rem;
	border-block-start: 1px solid var(--jm-line);
	position: relative;
}

.jm-share__label {
	font-size: 0.875rem;
	color: var(--jm-ink-muted);
	margin-inline-end: 0.25rem;
}

.jm-share__btn {
	display: inline-flex;
	align-items: center;
	gap: 0.375rem;
	/* 44px 触摸目标下限 —— 移动端流量占大头 */
	min-height: 44px;
	padding: 0.5rem 0.875rem;
	font: inherit;
	font-size: 0.875rem;
	color: var(--jm-ink);
	background: var(--jm-bg-alt);
	border: 1px solid var(--jm-line);
	border-radius: var(--jm-radius);
	text-decoration: none;
	cursor: pointer;
}
.jm-share__btn:hover {
	background: var(--jm-bg);
	border-color: var(--jm-ink-muted);
	color: var(--jm-red);
}

.jm-share__btn--wechat:hover { color: #07c160; }

.jm-share__toast {
	font-size: 0.8125rem;
	color: var(--jm-ink-muted);
	opacity: 0;
	transition: opacity 0.2s ease;
}
.jm-share__toast.is-visible { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
	.jm-share__toast { transition: none; }
}

/* 移动端：按钮只留图标，省出横向空间 */
@media (max-width: 480px) {
	.jm-share__btn span:last-child { display: none; }
	.jm-share__btn--wechat span:last-child { display: none; }
	.jm-share__btn { padding-inline: 0.75rem; }
	.jm-share__toast { flex-basis: 100%; }
}

/* =============================================================
   9. 来源署名与评论
   ============================================================= */
.jm-source-credit {
	margin-block-start: 1.5rem;
	padding-block-start: 0.75rem;
	border-block-start: 1px solid var(--jm-line);
	color: var(--jm-ink-muted);
}
.jm-source-credit a { color: var(--jm-ink-muted); }

.jm-comment-notice {
	font-size: 0.875rem;
	line-height: 1.7;
	color: var(--jm-ink-muted);
	background: var(--jm-bg-alt);
	border-inline-start: 3px solid var(--jm-red);
	padding: 0.75rem 1rem;
	margin-block: 1rem;
}

/* =============================================================
   10. 投稿表单（User Submitted Posts）
   插件自带样式很基础，这里统一到站点设计令牌上。
   ============================================================= */
#usp_form {
	max-width: 640px;
	margin-block: 1.5rem;
}

#usp_form > div {
	margin-block-end: 1.25rem;
}

#usp_form label {
	display: block;
	font-weight: 600;
	font-size: 0.9375rem;
	margin-block-end: 0.375rem;
}

#usp_form .usp-input,
#usp_form .usp-textarea,
#usp_form .usp-select {
	width: 100%;
	padding: 0.625rem 0.75rem;
	font: inherit;
	font-size: 1rem;          /* 16px 起步：iOS Safari 对更小的字号会自动放大页面 */
	line-height: 1.6;
	color: var(--jm-ink);
	background: var(--jm-bg);
	border: 1px solid var(--jm-line);
	border-radius: var(--jm-radius);
}

#usp_form .usp-textarea {
	min-height: 14rem;
	line-height: 1.85;        /* 与正文一致，长文输入时可读性更好 */
	resize: vertical;
}

#usp_form .usp-input:focus,
#usp_form .usp-textarea:focus,
#usp_form .usp-select:focus {
	border-color: var(--jm-focus);
}

#usp_form .usp-submit {
	min-height: 48px;
	padding: 0.75rem 2rem;
	font: inherit;
	font-size: 1rem;
	font-weight: 600;
	color: #fff;
	background: var(--jm-red);
	border: none;
	border-radius: var(--jm-radius);
	cursor: pointer;
}
#usp_form .usp-submit:hover { background: var(--jm-red-dark); }

/* 蜜罐字段：必须对人不可见，但不能用 display:none —— 部分机器人会
   跳过被隐藏的字段，反而绕过检测。挪出视口是更可靠的做法。 */
#usp_form .usp-hidden {
	position: absolute;
	left: -9999px;
}

.usp-callout-success,
.usp-callout-failure {
	padding: 0.875rem 1rem;
	margin-block: 1rem;
	border-radius: var(--jm-radius);
	font-size: 0.9375rem;
}
.usp-callout-success {
	background: #edf7ed;
	border-inline-start: 3px solid #2e7d32;
	color: #1b5e20;
}
.usp-callout-failure {
	background: #fdecea;
	border-inline-start: 3px solid var(--jm-red);
	color: var(--jm-red-dark);
}
