/* 缝合像素字体（Fusion Pixel Font, OFL-1.1）：10px 比例宽 */
/* 设计尺寸 10px，正文按 20px（2 倍整数缩放）渲染以保持像素锐利 */
@font-face {
  font-family: 'Fusion Pixel';
  src: url('assets/fonts/fusion-pixel-10px-proportional-latin.otf.woff2') format('woff2');
  unicode-range: U+0000-00FF;
  font-display: swap;
}
@font-face {
  font-family: 'Fusion Pixel';
  src: url('assets/fonts/fusion-pixel-10px-proportional-zh_hans.otf.woff2') format('woff2');
  font-display: swap;
}

/* ---- 三套主题：白天 / 傍晚 / 深夜 ---- */
/* 线条统一 #34458f；深夜背景太深，线条改用更亮的 #aab0e8 保证可读 */

:root, :root[data-theme="day"] {
  --bg-grad: linear-gradient(180deg, #f0d4cf 0%, #dcc190 50%, #d29f70 100%);
  --particles: #faf1ef;
  --fg: #2e2a55;
  --muted: #5b5688;
  --link: #34458f;
  --accent: #34458f;
  --on-accent: #faf1ef;
  --border: #34458f;
  --panel: rgba(255, 250, 248, 0.45);
  --panel-strong: rgba(255, 250, 248, 0.65);
  --shadow: rgba(52, 69, 143, 0.35);
  --code-bg: rgba(255, 250, 248, 0.5);
  --glitch-1: #5cc8e0;
  --glitch-2: #d06ae0;
}

:root[data-theme="dusk"] {
  --bg-grad: linear-gradient(180deg, #4e4e6e 0%, #de6152 50%, #3d3a5c 100%);
  --particles: #faf5ef;
  --fg: #faf5ef;
  --muted: #e8cfc0;
  --link: #ffe3b8;
  --accent: #34458f;
  --on-accent: #faf5ef;
  --border: #34458f;
  --panel: rgba(62, 58, 92, 0.4);
  --panel-strong: rgba(62, 58, 92, 0.6);
  --shadow: rgba(20, 18, 45, 0.5);
  --code-bg: rgba(30, 27, 60, 0.5);
  --glitch-1: #6fb8d4;
  --glitch-2: #e08ad0;
}

:root[data-theme="night"] {
  --bg-grad: linear-gradient(180deg, rgba(124, 120, 173, 0.97) 0%, #4a4f9e 50%, rgba(47, 57, 128, 0.95) 100%);
  --particles: #cfcee5;
  --fg: #e6e4f8;
  --muted: #b9b7dd;
  --link: #d6d4ff;
  --accent: #34458f;
  --on-accent: #e6e4f8;
  --border: #aab0e8;
  --panel: rgba(40, 45, 105, 0.35);
  --panel-strong: rgba(40, 45, 105, 0.55);
  --shadow: rgba(12, 14, 45, 0.6);
  --code-bg: rgba(25, 28, 70, 0.5);
  --glitch-1: #6fb8d4;
  --glitch-2: #b87fc6;
}

* {
  box-sizing: border-box;
  border-radius: 0 !important; /* 像素风：消灭圆角 */
}

html {
  font-size: 12px; /* 布局 rem 基准 */
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-grad);
  background-attachment: fixed;
  color: var(--fg);
  font-family: 'Fusion Pixel', monospace;
  font-size: 20px; /* 10px 字体 2 倍整数缩放 */
  line-height: 1.6;
  -webkit-font-smoothing: none;
  font-smooth: never;
  transition: background 0.6s, color 0.6s;
}

#particles {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

img { image-rendering: pixelated; }

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

main {
  max-width: 72rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 5rem;
}

a { color: var(--link); text-decoration: none; }
a:hover { background: var(--accent); color: var(--on-accent); }

/* 毛玻璃通用件 */
.glass, .intro, .site-title, .site-header nav a, .theme-switch button,
.post-content pre, .post-content blockquote {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* ---- 顶栏 ---- */

.site-header {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.site-title {
  position: relative;
  font-weight: 700;
  font-size: 30px;
  line-height: 1;
  color: var(--fg);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border: 2px solid var(--border);
  background: var(--panel);
  box-shadow: 4px 4px 0 var(--shadow);
}
.site-title:hover {
  background: var(--accent);
  color: var(--on-accent);
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--shadow);
}

/* 故障（glitch）效果：Remilla 的底色特点，像素抖动版 */
.site-title::before,
.site-title::after {
  content: attr(data-text);
  position: absolute;
  left: 1rem;
  top: 0.5rem;
  opacity: 0;
  pointer-events: none;
}
.site-title::before { color: var(--glitch-1); }
.site-title::after { color: var(--glitch-2); }

.site-title:hover::before {
  opacity: 0.8;
  animation: glitch-shift 0.6s steps(2, end) infinite;
}
.site-title:hover::after {
  opacity: 0.8;
  animation: glitch-shift 0.6s steps(2, end) infinite reverse;
}

/* 偶发 glitch（JS 定时加 .glitching，0.35 秒后移除） */
.site-title.glitching::before {
  opacity: 0.8;
  animation: glitch-shift 0.35s steps(2, end) infinite;
}
.site-title.glitching::after {
  opacity: 0.8;
  animation: glitch-shift 0.35s steps(2, end) infinite reverse;
}

@keyframes glitch-shift {
  0%   { transform: translate(2px, -2px); clip-path: inset(0 0 55% 0); }
  50%  { transform: translate(-2px, 2px); clip-path: inset(45% 0 10% 0); }
  100% { transform: translate(2px, 0);    clip-path: inset(20% 0 35% 0); }
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.site-header nav a {
  color: var(--fg);
  padding: 0.25rem 0.75rem;
  border: 2px solid var(--border);
  background: var(--panel);
}
.site-header nav a:hover {
  background: var(--accent);
  color: var(--on-accent);
}
/* 当前页导航项 */
.site-header nav a.active,
.site-header nav a.active:hover {
  background: var(--accent);
  color: var(--on-accent);
  cursor: default;
}

/* 主题切换 */
.theme-switch {
  display: flex;
  gap: 0.25rem;
  margin-left: 0.5rem;
}
.theme-switch button {
  font-family: inherit;
  cursor: pointer;
  color: var(--fg);
  padding: 0.25rem 0.5rem;
  border: 2px solid var(--border);
  background: var(--panel);
}
.theme-switch button:hover { background: var(--panel-strong); }
.theme-switch button.active {
  background: var(--accent);
  color: var(--on-accent);
}

/* ---- 首页介绍卡 ---- */

.intro {
  background: var(--panel);
  border: 2px solid var(--border);
  box-shadow: 4px 4px 0 var(--shadow), inset 0 0 0 2px var(--panel-strong);
  padding: 1.5rem 2rem;
  margin: 0.5rem 0 2.5rem;
}

.intro p { margin: 0 0 1rem; }
.intro p:last-child { margin-bottom: 0; }
.intro .intro-cta { color: var(--muted); }

/* 摸头计数器 */
.pet-box {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}
#pet-btn {
  font-family: inherit;
  font-size: 20px;
  cursor: pointer;
  color: var(--on-accent);
  padding: 0.25rem 1rem;
  border: 2px solid var(--border);
  background: var(--accent);
  box-shadow: 4px 4px 0 var(--shadow);
}
#pet-btn:hover:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--shadow);
}
#pet-btn:disabled {
  cursor: default;
  background: var(--panel-strong);
  color: var(--muted);
  box-shadow: none;
}
.pet-count { color: var(--muted); }

/* 打字机光标：像素方块闪烁 */
.type-cursor {
  display: inline-block;
  width: 12px;
  height: 22px;
  margin-left: 2px;
  vertical-align: -4px;
  background: var(--fg);
  animation: cursor-blink 0.8s steps(1) infinite;
}
@keyframes cursor-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ---- 文章列表 ---- */

.page-title {
  font-size: 30px;
  line-height: 1;
  margin: 1rem 0 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border);
}

/* 搜索框 */
.post-search { margin-bottom: 1.5rem; }
.post-search input {
  width: 100%;
  font-family: inherit;
  font-size: 20px;
  color: var(--fg);
  padding: 0.5rem 1rem;
  border: 2px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 4px 4px 0 var(--shadow);
  outline: none;
  appearance: none;
}
.post-search input::placeholder { color: var(--muted); }
.post-search input:focus {
  background: var(--panel-strong);
  box-shadow: 2px 2px 0 var(--shadow);
  transform: translate(2px, 2px);
}

.post-search-empty {
  color: var(--muted);
  padding: 1rem 0;
}

/* 标签 */
.tag {
  display: inline-block;
  font-size: 16px;
  padding: 0 0.5rem;
  border: 2px solid var(--shadow);
  color: var(--muted);
  background: var(--panel);
}
.post-tags { margin: 0.5rem 0 0; }

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.tag-filter button {
  font-family: inherit;
  font-size: 16px;
  cursor: pointer;
  color: var(--fg);
  padding: 0.125rem 0.75rem;
  border: 2px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.tag-filter button:hover { background: var(--panel-strong); }
.tag-filter button.active {
  background: var(--accent);
  color: var(--on-accent);
}

.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-list li {
  padding: 1.5rem 0;
  border-bottom: 2px dashed var(--shadow);
}

.post-list a {
  font-weight: 700;
  color: var(--fg);
}
.post-list a:hover { background: var(--accent); color: var(--on-accent); }

.post-list a::before { content: '▸ '; color: var(--link); }

.post-list time {
  display: block;
  color: var(--muted);
  margin-top: 0.25rem;
}

.post-list p {
  margin: 0.5rem 0 0;
  color: var(--muted);
}

/* ---- 文章页 ---- */

.post h1 {
  font-size: 30px;
  line-height: 1.5;
  margin: 1rem 0 0.5rem;
}

.post-meta {
  color: var(--muted);
  margin: 0 0 2.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px dashed var(--shadow);
}

.post-content h2 {
  font-size: 30px;
  line-height: 1.5;
  margin-top: 3rem;
  padding: 0.25rem 0.75rem;
  background: var(--panel-strong);
  border-left: 4px solid var(--accent);
}

.post-content h3 {
  margin-top: 2rem;
  padding-left: 0.75rem;
  border-left: 4px solid var(--shadow);
}

.post-content img { max-width: 100%; height: auto; border: 2px solid var(--border); }

.post-content code {
  background: var(--code-bg);
  padding: 0 0.5rem;
  border: 2px solid var(--shadow);
  font-family: 'Fusion Pixel', monospace;
}

.post-content pre {
  background: var(--code-bg);
  padding: 1rem 1.5rem;
  border: 2px solid var(--border);
  box-shadow: 4px 4px 0 var(--shadow);
  overflow-x: auto;
}

.post-content pre code { background: none; padding: 0; border: none; }

.post-content blockquote {
  margin: 0;
  padding: 0.5rem 1.5rem;
  border: 2px solid var(--border);
  border-left: 4px solid var(--accent);
  background: var(--panel);
  color: var(--muted);
}

.post-content ul li::marker { content: '▸ '; color: var(--link); }

.post-content table {
  border-collapse: collapse;
  width: 100%;
}
.post-content th, .post-content td {
  border: 2px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}
.post-content th { background: var(--panel-strong); }

/* ---- 页脚 ---- */

.site-footer {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 2rem;
  color: var(--muted);
  border-top: 2px solid var(--border);
}

.status-line { margin-top: 0; }

/* ---- 情感收集箱（论坛页） ---- */

.emotion-box {
  background: var(--panel);
  border: 2px solid var(--border);
  box-shadow: 4px 4px 0 var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 1.5rem 2rem;
  margin: 1.5rem 0 2.5rem;
}

.emotion-question-label {
  color: var(--muted);
  margin: 0;
}

.emotion-question {
  font-size: 30px;
  line-height: 1.4;
  margin: 0.5rem 0 1.5rem;
  color: var(--fg);
}

.emotion-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#emotion-input {
  font-family: inherit;
  font-size: 20px;
  color: var(--fg);
  background: var(--code-bg);
  border: 2px solid var(--border);
  padding: 0.75rem 1rem;
  resize: vertical;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
#emotion-input:focus { background: var(--panel-strong); }
#emotion-input::placeholder { color: var(--muted); }

#emotion-submit {
  font-family: inherit;
  font-size: 20px;
  cursor: pointer;
  align-self: flex-start;
  color: var(--on-accent);
  padding: 0.25rem 1rem;
  border: 2px solid var(--border);
  background: var(--accent);
  box-shadow: 4px 4px 0 var(--shadow);
}
#emotion-submit:hover:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--shadow);
}
#emotion-submit:disabled {
  cursor: default;
  background: var(--panel-strong);
  color: var(--muted);
  box-shadow: none;
}

.emotion-hint {
  color: var(--muted);
  margin: 0.75rem 0 0;
}

.emotion-answers {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.emotion-card {
  border: 2px solid var(--shadow);
  border-left: 4px solid var(--accent);
  background: var(--panel-strong);
  padding: 0.75rem 1.25rem;
}
.emotion-card p { margin: 0; }
.emotion-card time {
  display: block;
  color: var(--muted);
  font-size: 16px;
  margin-top: 0.25rem;
}

.emotion-empty { color: var(--muted); margin: 0; }

/* ---- 手机端（≤720px）：收窄左右边距，顶栏更紧凑 ---- */

@media (max-width: 720px) {
  main {
    padding: 1.25rem 0.75rem 3rem;
  }

  .site-header {
    padding: 1rem 0.75rem 0;
    gap: 0.5rem 0.5rem;
  }

  .site-footer {
    padding: 1rem 0.75rem 1.5rem;
  }

  /* 标题缩小，和导航放同一排 */
  .site-title {
    font-size: 20px;
    padding: 0.25rem 0.5rem;
    box-shadow: 3px 3px 0 var(--shadow);
  }

  .site-header nav { gap: 0.25rem; }
  .site-header nav a { padding: 0.125rem 0.5rem; }
  .theme-switch { margin-left: 0; }
  .theme-switch button { padding: 0.125rem 0.375rem; }

  /* 卡片和内容件收紧 */
  .intro { padding: 1rem 1.25rem; }
  .post-content pre { padding: 0.75rem 1rem; }
  .post-content blockquote { padding: 0.25rem 1rem; }
}
