/* MOSS 原型 · 共享样式 */
:root {
  --bg: #F5F6F3;
  --surface: #FFFFFF;
  --surface-2: #FAFBF8;
  --ink: #14161A;
  --muted: #6A7078;
  --muted-2: #8B9199;
  --line: #E3E6DF;
  --line-2: #EFF1EC;
  --brand: #0A9F5E;
  --brand-deep: #065F39;
  --brand-soft: #E8FAF1;
  --dark: #101418;
  --dark-2: #171C22;
  --dark-3: #232A32;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(16, 20, 24, .04), 0 10px 28px rgba(16, 20, 24, .05);
  --font: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.75 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--brand-deep); }
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.ink { color: var(--ink); }
.tiny { font-size: 12px; letter-spacing: .04em; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(245, 246, 243, .88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 24px; height: 64px;
  display: flex; align-items: center; gap: 26px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 30px; height: 30px; border-radius: 9px; background: var(--brand);
  color: #fff; display: grid; place-items: center; font: 700 15px/1 var(--mono);
}
.brand b { font-size: 15px; letter-spacing: .16em; font-weight: 700; }
.brand span { font-size: 11.5px; color: var(--muted-2); letter-spacing: .06em; }

.nav { display: flex; align-items: center; gap: 2px; }
.nav a {
  padding: 7px 12px; border-radius: 8px;
  color: var(--muted); font-size: 14px;
}
.nav a:hover { background: var(--surface); color: var(--ink); }
.nav a.on { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }

.search {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 10px; width: 190px; flex: 0 0 auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted-2); font-size: 13px;
}
.search span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search kbd {
  margin-left: auto; font: 500 11px var(--mono); color: var(--muted-2);
  border: 1px solid var(--line); border-radius: 4px; padding: 0 4px;
}
.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 999px;
  background: #1E3A32; color: #D7F7E5; display: grid; place-items: center;
  font: 600 12px var(--mono);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
  white-space: nowrap;
}
.btn:hover { border-color: #CDD3C9; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); color: #fff; }
.btn-dark { background: var(--dark); border-color: var(--dark); color: #fff; }
.btn-dark:hover { background: #000; color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------- 标签 ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line);
  color: var(--muted); font: 500 11.5px/1 var(--font); white-space: nowrap;
}
.chip-brand { background: var(--brand-soft); border-color: #C6EDDA; color: var(--brand-deep); }
.chip-dark { background: #E9EBEE; border-color: #DDE0E4; color: #3B4149; }
.chip-ghost { background: transparent; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  overflow: hidden;
}
.card-pad { padding: 22px 24px; }
.card-flat { box-shadow: none; }
.grid { display: grid; gap: 20px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* 封面块：纯色 + 编号 + 标签，避免占位图 */
.cover {
  position: relative; aspect-ratio: 16 / 10; display: flex; flex-direction: column;
  justify-content: space-between; padding: 18px 20px; color: #EDF3EF;
  background: #1E3A32;
}
.cover.sm { aspect-ratio: 16 / 9; padding: 14px 16px; }
.cover .cover-tag { font: 500 11px var(--mono); letter-spacing: .12em; opacity: .72; }
.cover .cover-num {
  font: 600 46px/1 var(--mono); letter-spacing: -.03em; color: rgba(255, 255, 255, .16);
  align-self: flex-end;
}
.cover .cover-title {
  font-size: 15px; font-weight: 600; letter-spacing: .01em; color: #EAF2ED;
  max-width: 90%;
}
.cover.deep { background: #1B2A3A; }
.cover.plum { background: #2E2438; }
.cover.slate { background: #232F33; }
.cover.olive { background: #2A3222; }
.cover.rust { background: #3A2A22; }
/* 有上传封面时用图片铺满 */
.cover.cover-img { display: block; padding: 0; background: #1B2A3A; }
.cover.cover-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover.cover-img::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, .10) 30%, rgba(0, 0, 0, .62));
}
.cover.cover-img .cover-tag,
.cover.cover-img .cover-title { position: absolute; left: 16px; right: 16px; z-index: 1; }
.cover.cover-img .cover-tag { top: 14px; }
.cover.cover-img .cover-title { bottom: 14px; }
.cover.cover-img .cover-num { position: absolute; right: 16px; bottom: 10px; z-index: 1; }
.avatar.has-img, .p-avatar.has-img { padding: 0; overflow: hidden; }
.avatar.has-img img, .p-avatar.has-img img {
  width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit;
}

/* ---------- 区块标题 ---------- */
.sec-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin: 44px 0 18px;
}
.sec-head h2 { margin: 0; font-size: 22px; line-height: 1.3; font-weight: 650; letter-spacing: -.01em; }
.sec-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.sec-head .more { color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.sec-head .more:hover { color: var(--brand-deep); }

/* ---------- 页脚 ---------- */
.footer {
  margin-top: 64px; border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.footer-inner {
  max-width: 1180px; margin: 0 auto; padding: 28px 24px;
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between;
  color: var(--muted); font-size: 13px;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; }

/* ---------- 文章列表卡 ---------- */
.post-card { display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s; }
.post-card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(16,20,24,.05), 0 16px 34px rgba(16,20,24,.08); }
.post-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.post-body h3 { margin: 0; font-size: 16px; line-height: 1.5; font-weight: 650; }
.post-body p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.post-meta {
  display: flex; align-items: center; gap: 10px;
  margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line-2);
  color: var(--muted-2); font: 500 11.5px var(--mono);
}
.dot { width: 3px; height: 3px; border-radius: 999px; background: var(--muted-2); }

/* ---------- 通用小元素 ---------- */
.kicker { font: 600 11px var(--mono); letter-spacing: .14em; color: var(--brand-deep); text-transform: uppercase; }
.hr { height: 1px; background: var(--line); border: 0; margin: 26px 0; }
.stat-row { display: flex; flex-wrap: wrap; gap: 28px; }
.stat b { display: block; font: 650 20px/1.2 var(--mono); letter-spacing: -.02em; }
.stat span { font-size: 12px; color: var(--muted); }

/* ---------- 响应式 ---------- */
@media (max-width: 1000px) {
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .wrap { padding: 0 18px; }
  .topbar-inner { height: 58px; gap: 14px; padding: 0 18px; }
  .nav { display: none; }
  .search { width: auto; flex: 1; min-width: 0; }
  .search span { display: none; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .sec-head { margin: 32px 0 14px; }
  .stat-row { gap: 20px; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
  .lang { display: none; }
}

/* ---------- 多语言：中文 / 维吾尔语 ---------- */
@font-face {
  font-family: "UKIJ Ekran";
  src: url("../fonts/UKIJEkran.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
:root {
  --font-ug: "UKIJ Ekran", "UKIJEkran", "Microsoft Uighur", "UKIJ Tuz Tom", "Noto Naskh Arabic", "Microsoft YaHei", "Segoe UI", sans-serif;
  --pom: #A8322D;      /* 石榴红 */
  --sand: #BE9440;     /* 沙金 */
  --atlas: #2F6C8F;    /* 艾德莱斯蓝 */
  --plum: #7A3E6B;     /* 葡萄紫 */
}

/* 语言切换：放在顶栏，尺寸克制 */
.lang {
  display: flex; align-items: center; gap: 2px; padding: 2px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  flex: 0 0 auto;
}
.lang a { padding: 3px 9px; border-radius: 999px; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.lang a:hover { color: var(--ink); }
.lang a.on { background: var(--dark); color: #fff; }

/* ---------- 维吾尔语排印：UKIJ Ekran · 从右向左 ---------- */
[dir="rtl"] { font-family: var(--font-ug); }
[dir="rtl"] body { background: #F6F5F1; font-family: var(--font-ug); font-size: 15.5px; line-height: 1.95; }
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3, [dir="rtl"] h4,
[dir="rtl"] .ug-title { font-weight: 600; letter-spacing: 0 !important; line-height: 1.85; }
[dir="rtl"] p, [dir="rtl"] li, [dir="rtl"] .ug-body { line-height: 2; }

/* 阿拉伯字母连写：任何正字距都会断字，必须清零 */
[dir="rtl"] .kicker, [dir="rtl"] .brand b, [dir="rtl"] .brand span,
[dir="rtl"] .cover-tag, [dir="rtl"] .cover-title, [dir="rtl"] .cover-num,
[dir="rtl"] .chip, [dir="rtl"] .nav a, [dir="rtl"] .tabs a,
[dir="rtl"] .sec-head h2, [dir="rtl"] .sec-head p { letter-spacing: 0; }

/* 维文字形偏小且有下伸部，行盒要比中文更高 */
[dir="rtl"] .chip { height: 26px; padding: 0 10px; line-height: 1.7; font-family: var(--font-ug); }
[dir="rtl"] .nav a { padding: 8px 13px; }
[dir="rtl"] .post-body h3, [dir="rtl"] .sw-row h4 { line-height: 1.8; padding-bottom: 2px; }

/* 区块标题：右侧一根细彩条，全站唯一的结构性装饰 */
[dir="rtl"] .sec-head h2 { position: relative; padding-inline-start: 14px; }
[dir="rtl"] .sec-head h2::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 9px; bottom: 11px; width: 3px;
  border-radius: 3px; background: linear-gradient(180deg, var(--pom), var(--sand));
}

/* 中文对照行：右侧细线，明确“副标题”层级 */
[dir="rtl"] .zh {
  color: var(--muted); font-family: var(--font); font-size: 12.5px; line-height: 1.8; letter-spacing: 0;
  padding-inline-start: 0; border-inline-start: 0;
  padding-right: 10px; border-right: 2px solid var(--line);
}

/* 搜索框：维语提示语更长，加宽并单行省略 */
[dir="rtl"] .search { width: 214px; }
[dir="rtl"] .search span {
  min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 顶栏与卡片：偏暖的纸感，和中文版区分但不喧哗 */
[dir="rtl"] .topbar { background: rgba(246, 245, 241, .92); }
[dir="rtl"] .nav a.on { border-color: #DDE1D8; box-shadow: 0 1px 0 rgba(16, 20, 24, .04); }
[dir="rtl"] .card { box-shadow: 0 1px 2px rgba(60, 50, 40, .05), 0 12px 30px rgba(60, 50, 40, .06); }
[dir="rtl"] .post-card:hover { transform: translateY(-3px); }
[dir="rtl"] .stat b, [dir="rtl"] .post-meta, [dir="rtl"] .byline { font-variant-numeric: tabular-nums; }

/* 艾德莱斯纹样：纯 CSS 斜向彩条，只做点缀，不铺满 */
.atlas-band {
  height: 6px; border-radius: 999px; opacity: .6;
  background: repeating-linear-gradient(90deg,
    var(--pom) 0 16px, var(--sand) 16px 28px, var(--atlas) 28px 44px, var(--plum) 44px 56px);
}
.cover.atlas { background: #1E2A32; }
.cover.atlas::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 36%;
  background: repeating-linear-gradient(90deg,
    var(--pom) 0 16px, var(--sand) 16px 26px, var(--atlas) 26px 40px, var(--plum) 40px 52px);
  opacity: .22;
}
.cover.atlas > * { position: relative; }

/* RTL 镜像：只处理真正会错位的部分 */
[dir="rtl"] .search { margin-left: 0; margin-right: auto; }
[dir="rtl"] .search kbd { margin-left: 0; margin-right: auto; }
[dir="rtl"] .sw-dl { text-align: left; }
[dir="rtl"] .sec-head .more { flex-direction: row-reverse; }
[dir="rtl"] .cover-num { align-self: flex-start; }
[dir="rtl"] .footer-inner { flex-direction: row-reverse; }
[dir="rtl"] .post-meta, [dir="rtl"] .byline { flex-direction: row-reverse; }

/* 代码、URL、版本号始终从左到右 */
[dir="rtl"] code, [dir="rtl"] pre, [dir="rtl"] kbd,
[dir="rtl"] .mono, [dir="rtl"] .ed-title { direction: ltr; unicode-bidi: isolate; }

/* 首页聚合门户：快捷入口与探索区 */
.entry-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin: 6px 0 30px;
}
.entry {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .15s ease, color .15s ease;
}
.entry b { font: 600 22px/1.25 var(--mono); letter-spacing: -.02em; }
.entry span { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.entry:hover { border-color: var(--brand); color: var(--brand-deep); }
.explore-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
}
.explore-card h4 { margin: 0; font-size: 15px; }
.explore-card .filters { margin: 0; }
.explore-card .more { color: var(--muted); font-size: 13px; }
.explore-card .more:hover { color: var(--brand-deep); }
.explore-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

@media (max-width: 860px) {
  .entry-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .entry-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 博客主题「Paper 素笺」：衬线标题 + 更轻的圆角与投影 */
.theme-paper { --radius: 3px; }
.theme-paper h1,
.theme-paper h2,
.theme-paper h3,
.theme-paper .hero h1,
.theme-paper .card h3,
.theme-paper .post-title {
  font-family: Georgia, "Songti SC", "Noto Serif SC", serif;
  font-weight: 500;
  letter-spacing: 0;
}
.theme-paper .hero h1 { letter-spacing: -.01em; }
.theme-paper .kicker { letter-spacing: .16em; }
.theme-paper .card,
.theme-paper .post-card { box-shadow: 0 1px 2px rgba(34, 29, 23, .04); }
.theme-paper .brand b { letter-spacing: .24em; }

/* 动效层：滚动显现、卡片浮起、阅读进度、回顶按钮 */
html { scroll-behavior: smooth; }

.reveal {
  opacity: 0;
  transform: translateY(16px);
}
.reveal.in {
  opacity: 1;
  transform: none;
  transition: opacity .55s ease, transform .55s cubic-bezier(.22, .61, .36, 1);
}

.card,
.post-card,
.entry {
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover,
.post-card:hover,
.entry:hover {
  transform: translateY(-3px);
  border-color: var(--brand);
  box-shadow: 0 10px 28px rgba(30, 24, 18, .08);
}

.topbar { transition: box-shadow .25s ease, background .25s ease; }
.topbar.is-scrolled { box-shadow: 0 6px 22px rgba(30, 24, 18, .08); }

.logo { transition: transform .3s ease; }
.brand:hover .logo { transform: rotate(-6deg) scale(1.06); }

.hero {
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  inset: auto -90px -150px auto;
  width: 340px;
  height: 340px;
  background: radial-gradient(circle, var(--brand-soft) 0%, transparent 65%);
  opacity: .8;
  pointer-events: none;
  animation: heroDrift 14s ease-in-out infinite alternate;
}
[dir="rtl"] .hero::after { inset: auto auto -150px -90px; }
.hero > * { position: relative; z-index: 1; }

@keyframes heroDrift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(-26px, -18px, 0) scale(1.08); }
}

.sec-head h2 { position: relative; display: inline-block; }
.sec-head h2::after {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  bottom: -5px;
  height: 2px;
  width: 0;
  background: var(--brand);
  transition: width .3s ease;
}
.sec-head:hover h2::after { width: 100%; }

.read-progress {
  position: fixed;
  top: 0;
  inset-inline-start: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--brand), var(--brand-deep));
  z-index: 60;
  transition: width .1s linear;
}

.to-top {
  position: fixed;
  inset-inline-end: 22px;
  bottom: 24px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease, color .2s ease, border-color .2s ease;
  z-index: 40;
}
.to-top.show { opacity: 1; pointer-events: auto; transform: none; }
.to-top:hover { color: var(--brand-deep); border-color: var(--brand); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal, .reveal.in { opacity: 1; transform: none; transition: none; }
  .hero::after { animation: none; }
  .card:hover, .post-card:hover, .entry:hover { transform: none; }
}
