/* 视觉地基：老城夕阳 + 落灰 — 中英字体在 assets/fonts.css（由 HTML 单独引入，避免 @import 阻塞首屏） */

:root {
  --bg-void: #0e0c0a;
  --bg-deep: #151311;
  --bg-mist: #1c1916;
  --text-ash: #d8cfc2;
  --text-dust: #9a9187;
  --text-faint: #6a6560;
  --gold-dim: #9a8a5e;
  --gold: #c9b06a;
  --gold-bright: #dcc47a;
  --slate: #5c6a78;
  --slate-deep: #3d4852;
  --brick: #8f4a42;
  --brick-shadow: #5c2f2a;
  --serif-zh: "LXGW WenKai Screen", "LXGW WenKai", "PingFang SC", "Hiragino Sans GB", serif;
  --serif-en: "EB Garamond", "LXGW WenKai", Georgia, serif;
  --mono-atmos: "Consolas", "DejaVu Sans Mono", ui-monospace, monospace;
  --write-size: 0.95rem;
  --write-line: 1.75;
  --fragment-max: 22rem;
}

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

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--serif-zh), var(--serif-en);
  font-size: var(--write-size);
  line-height: var(--write-line);
  letter-spacing: 0.02em;
  color: var(--text-ash);
  background: var(--bg-deep);
  -webkit-font-smoothing: antialiased;
}

/* —— 门厅 —— */
body.gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse 120% 80% at 50% 100%, #1a1512 0%, var(--bg-void) 55%);
  color: var(--text-ash);
}

body.gate main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.25rem;
  padding: 0 1.5rem;
}

body.gate .gate-intro {
  max-width: 26rem;
  margin: 0;
  text-align: center;
}

body.gate .gate-intro p {
  margin: 0;
  font-family: var(--serif-zh), var(--serif-en);
  font-size: 0.92rem;
  font-weight: 400;
  line-height: 1.7;
  color: var(--text-dust);
  letter-spacing: 0.03em;
}

body.gate .gate-intro .gate-intro-en {
  margin-top: 0.9rem;
  font-family: var(--serif-en), var(--serif-zh);
  font-size: 0.86rem;
  line-height: 1.65;
  color: var(--text-faint);
  letter-spacing: 0.01em;
}

body.gate .gate-intro .gate-intro-tech {
  color: var(--text-dust);
  text-decoration: none;
  border-bottom: 1px solid rgba(154, 145, 135, 0.45);
  transition: color 0.15s ease, border-color 0.15s ease;
}

body.gate .gate-intro .gate-intro-tech:hover {
  color: var(--gold);
  border-bottom-color: var(--gold-dim);
}

body.gate .gate-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.75rem;
}

body.gate a {
  font-family: var(--serif-zh), var(--serif-en);
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--gold);
  text-decoration: none;
  text-underline-offset: 0.35em;
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

body.gate a:hover {
  color: var(--gold-bright);
  text-decoration: underline;
  text-decoration-color: var(--brick);
}

body.gate .gate-link-life,
body.gate .gate-link-tech {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  line-height: 1.25;
}

body.gate .gate-link-life .gate-link-title,
body.gate .gate-link-tech .gate-link-title {
  font-size: 1.35rem;
  font-weight: 500;
}

body.gate .gate-link-life .gate-link-tag,
body.gate .gate-link-tech .gate-link-tag {
  font-family: var(--serif-en), var(--serif-zh);
  font-size: 0.78rem;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.04em;
  color: var(--text-dust);
  text-decoration: none;
  transition: color 0.2s ease;
}

body.gate .gate-link-life:hover .gate-link-tag,
body.gate .gate-link-tech:hover .gate-link-tag {
  color: var(--text-ash);
}

body.gate .gate-link-life:hover,
body.gate .gate-link-tech:hover {
  text-decoration: none;
}

body.gate .gate-link-life:hover .gate-link-title,
body.gate .gate-link-tech:hover .gate-link-title {
  text-decoration: underline;
  text-decoration-color: var(--brick);
}

/* —— 生活侧 —— */
body.life {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg-void);
  color: var(--text-ash);
}

/* 子元素全是 position:absolute 时，若此处高度为 0，则 top 的 % 相对高度为 0，碎片会全部挤到顶端 */
body.life #shards {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  min-height: 100vh;
  min-width: 100%;
}

/* 勿用 z-index: -1：会整层落到 body 背景色下方，栅格图（.png 等）会「消失」 */
#atmos {
  position: fixed;
  inset: 0;
  z-index: 0;
  margin: 0;
  padding: 1.5vmin;
  white-space: pre;
  font-family: var(--mono-atmos);
  font-size: clamp(7px, 1.1vmin, 11px);
  line-height: 1.05;
  color: var(--slate);
  /* 空 .txt 时原先几乎不可见；略提高以便字符画底纹能辨认 */
  opacity: 0.5;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  filter: contrast(0.92) saturate(0.85);
}

/* 与 .txt 二选一：同栏目名下若有 .png/.jpg/.webp 则作铺满底图（优先于字符画） */
#atmos.atmos-raster {
  display: block;
  padding: 0;
  white-space: normal;
  font-size: 0;
  line-height: 0;
  color: transparent;
  opacity: 0.52;
  background-color: var(--bg-void);
  background-repeat: no-repeat;
  background-size: cover;
  /* 略偏上，让画面中部「落地窗」一带落在视区中心附近 */
  background-position: center 38%;
  filter: contrast(0.98) saturate(0.88) brightness(1);
}

body.life .fragment {
  position: absolute;
  z-index: 1;
  max-width: var(--fragment-max);
  padding: 0;
  font-family: var(--serif-zh), var(--serif-en);
  font-size: clamp(0.82rem, 1.1vw, 0.95rem);
  line-height: var(--write-line);
  color: var(--text-ash);
  opacity: 0.88;
  text-shadow: 0 0 1.25em rgba(14, 12, 10, 0.85), 0 1px 0 rgba(20, 18, 16, 0.4);
  pointer-events: auto;
  hyphens: auto;
}

body.life .fragment-title-link {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  text-shadow: inherit;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  text-decoration-color: rgba(201, 176, 106, 0.45);
}

body.life .fragment-title-link:hover {
  color: var(--gold-bright);
  text-decoration-color: var(--gold-dim);
}

body.life .fragment-title-link:focus-visible {
  outline: 1px solid var(--gold-dim);
  outline-offset: 2px;
}

/* 单篇阅读 scene.html */
body.life-read {
  min-height: 100vh;
  position: relative;
  background: var(--bg-void);
  color: var(--text-ash);
}

body.life-read .back-life {
  position: fixed;
  top: 1rem;
  left: 1.25rem;
  z-index: 2;
  font-size: 0.82rem;
  color: var(--text-faint);
  text-decoration: none;
  opacity: 0.55;
  transition: opacity 0.2s ease, color 0.2s ease;
}

body.life-read .back-life:hover {
  opacity: 0.9;
  color: var(--gold-dim);
}

body.life-read .scene-article {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  max-width: 40rem;
  margin: 0 auto;
  padding: 3.25rem 1.35rem 4rem;
  font-family: var(--serif-zh), var(--serif-en);
  font-size: clamp(0.88rem, 1.05vw, 0.98rem);
  line-height: var(--write-line);
  letter-spacing: 0.02em;
}

body.life-read .scene-article p {
  margin: 0 0 0.75em;
}

body.life-read .scene-article p:last-child {
  margin-bottom: 0;
}

body.life-read .scene-article h1,
body.life-read .scene-article h2,
body.life-read .scene-article h3,
body.life-read .scene-article h4 {
  font-weight: 600;
  margin: 1em 0 0.5em;
  color: var(--text-ash);
}

body.life-read .scene-article h1:first-child,
body.life-read .scene-article h2:first-child,
body.life-read .scene-article h3:first-child {
  margin-top: 0;
}

body.life-read .scene-article pre,
body.life-read .scene-article code {
  font-family: var(--mono-atmos);
  font-size: 0.9em;
}

body.life-read .scene-article pre {
  margin: 0.75em 0;
  padding: 0.65rem 0.85rem;
  overflow: auto;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 4px;
  border: 1px solid rgba(154, 145, 135, 0.12);
}

body.life-read .scene-article ul,
body.life-read .scene-article ol {
  margin: 0.5em 0;
  padding-left: 1.35em;
}

body.life-read .scene-article a {
  color: var(--gold);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

body.life-read .scene-article a:hover {
  color: var(--gold-bright);
}

body.life-read .scene-read-err {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  max-width: 40rem;
  margin: 2rem auto 0;
  padding: 0 1.35rem 3rem;
  text-align: center;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-dust);
  opacity: 0.85;
}

/* 建站说明（日期在 assets/site-meta.js 的 blogSince 修改） */
body.life .blog-since,
body.life-read .blog-since {
  position: fixed;
  z-index: 1;
  bottom: 2.35rem;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 0;
  max-width: min(96vw, 28rem);
  font-size: calc(var(--write-size) * 0.44);
  letter-spacing: 0.05em;
  line-height: 1.35;
  text-align: center;
  color: var(--text-faint);
  opacity: 0.42;
  pointer-events: none;
}

body.life .blog-since:empty,
body.life-read .blog-since:empty {
  display: none;
}

/* 脚注彩蛋：具体位置与透明度由 dust-easter.js 随机；无 JS 时仍略可见 */
body.life .dust-footnote,
body.life-read .dust-footnote {
  position: fixed;
  z-index: 1;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: calc(var(--write-size) * 0.48);
  letter-spacing: 0.1em;
  color: var(--text-dust);
  opacity: 0.18;
  pointer-events: none;
  white-space: nowrap;
}

body.life .back-gate {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 2;
  font-size: 0.7rem;
  color: var(--text-faint);
  text-decoration: none;
  opacity: 0.45;
  transition: opacity 0.2s ease, color 0.2s ease;
}

body.life .back-gate:hover {
  opacity: 0.85;
  color: var(--gold-dim);
}

body.life .shard-empty {
  position: fixed;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  max-width: 22rem;
  padding: 0 1rem;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-dust);
  opacity: 0.75;
  text-align: center;
  pointer-events: none;
}

/* —— 写作页 —— */
body.write {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-deep);
  color: var(--text-ash);
}

body.write #buf {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 6vmin 8vmin 4.5rem;
  border: none;
  resize: none;
  font-family: var(--serif-zh), var(--serif-en);
  font-size: var(--write-size);
  line-height: var(--write-line);
  letter-spacing: 0.03em;
  color: var(--text-ash);
  background: linear-gradient(165deg, var(--bg-mist) 0%, var(--bg-deep) 45%, #12100e 100%);
  caret-color: var(--gold);
  outline: none;
}

body.write.mode-command #buf {
  caret-color: var(--brick);
  caret-shape: block;
}

body.write.mode-ask-category #buf {
  pointer-events: none;
}

#cat-hint {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 3.1rem;
  padding: 0.35rem 8vmin;
  font-size: 0.68rem;
  line-height: 1.45;
  color: var(--text-faint);
  background: linear-gradient(to top, rgba(14, 12, 10, 0.92), transparent);
  pointer-events: none;
}

#cat-hint[hidden] {
  display: none !important;
}

#cmdline-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15em 0.35em;
  padding: 0.55rem 8vmin 0.75rem;
  font-family: var(--serif-en), var(--serif-zh);
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--text-dust);
  background: linear-gradient(to top, rgba(12, 10, 9, 0.97), rgba(18, 16, 14, 0.88));
  border-top: 1px solid rgba(92, 106, 120, 0.25);
  min-height: 2.5rem;
}

#cmdline-wrap[hidden] {
  display: none !important;
}

#cmdline {
  color: var(--gold-dim);
}

#cmdline .cmd-prefix {
  color: var(--slate);
  margin-right: 0.25em;
}

body.write #category-input.category-input {
  flex: 1 1 12rem;
  min-width: 8rem;
  max-width: 100%;
  margin: 0;
  padding: 0.1em 0;
  border: none;
  border-bottom: 1px solid rgba(154, 138, 94, 0.35);
  background: transparent;
  font: inherit;
  font-size: 0.95em;
  color: var(--gold);
  caret-color: var(--gold-bright);
  outline: none;
}

body.write #category-input.category-input:focus {
  border-bottom-color: var(--gold-dim);
}

body.write #category-input.category-input::placeholder {
  color: var(--text-faint);
  opacity: 0.65;
}
