/* ============================================================
   ziyue. — 极简个人博客样式（多页版）
   ============================================================ */

/* ── 设计品牌 ── */
:root {
  --bg-light: #f8f7f4;
  --text-light: #2c2c2c;
  --muted-light: #999999;
  --subtle-light: #e8e6e1;
  --card-light: #ffffff;
  --border-light: #eae8e3;

  --bg-dark: #18181b;
  --text-dark: #e5e5e5;
  --muted-dark: #777777;
  --subtle-dark: #2a2a2e;
  --card-dark: #222225;
  --border-dark: #333337;

  --accent: #8b7355;
  --accent-light: #a08b6e;
  --radius: 8px;
  --radius-lg: 14px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

/* ── 重置 ── */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
               "Noto Serif SC", "Microsoft YaHei", sans-serif;
  background: var(--bg-light);
  color: var(--text-light);
  transition: background-color 0.8s var(--ease-in-out),
              color 0.8s var(--ease-in-out);
  line-height: 2;
  letter-spacing: 0.05em;
  overflow-x: hidden;
}

body.dark {
  background: var(--bg-dark);
  color: var(--text-dark);
}

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

/* ── 页面加载遮罩 ── */
.loader {
  position: fixed; inset: 0; z-index: 10000;
  background: var(--bg-light);
  display: flex; justify-content: center; align-items: center;
  transition: opacity 0.6s var(--ease-out), visibility 0.6s;
}
body.dark .loader { background: var(--bg-dark); }
.loader.hide { opacity: 0; visibility: hidden; pointer-events: none; }

.loader-text {
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 200; letter-spacing: 0.15em;
  color: var(--text-light);
  animation: loader-pulse 1.2s var(--ease-in-out) infinite alternate;
}
body.dark .loader-text { color: var(--text-dark); }
@keyframes loader-pulse { from { opacity: 0.3; } to { opacity: 1; } }

/* ── Flash 消息 ── */
.flash-container {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
  max-width: 90vw;
}
.flash-message {
  padding: 10px 24px; border-radius: 999px;
  font-size: 13px; backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(255,255,255,0.85); color: var(--text-light);
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  white-space: nowrap;
}
body.dark .flash-message {
  background: rgba(40,40,44,0.85); color: var(--text-dark);
}
.flash-message.flash-error { border-left: 3px solid #e74c3c; }
.flash-message.flash-success { border-left: 3px solid #27ae60; }

/* ── 左侧导航 ── */
.sidebar {
  position: fixed; left: 0; top: 0; width: 220px; height: 100dvh;
  padding: 25vh 40px 20px;
  display: flex; flex-direction: column; z-index: 100;
  transition: opacity 0.6s var(--ease-out), transform 0.5s var(--ease-out);
}
.sidebar.hidden-nav { opacity: 0; pointer-events: none; transform: translateX(-10px); }

.logo {
  font-size: 26px; font-weight: 200; letter-spacing: 2px; margin-bottom: 50px;
}
.logo a { text-decoration: none; color: inherit; transition: opacity 0.3s; }
.logo a:hover { opacity: 0.6; }

.sidebar ul { list-style: none; flex: 1; }
.sidebar li { margin: 18px 0; }
.sidebar a {
  text-decoration: none; color: var(--muted-light);
  font-size: 14px; letter-spacing: 0.1em;
  transition: color 0.3s, transform 0.3s;
  position: relative; display: inline-block;
}
.sidebar a::after {
  content: ''; position: absolute; bottom: -2px; left: 0;
  width: 0; height: 1px; background: var(--accent);
  transition: width 0.3s var(--ease-out);
}
.sidebar a:hover { color: var(--text-light); transform: translateX(4px); }
.sidebar a:hover::after, .sidebar a.active::after { width: 100%; }
.sidebar a.active { color: var(--text-light); }
body.dark .sidebar a { color: var(--muted-dark); }
body.dark .sidebar a:hover, body.dark .sidebar a.active { color: var(--text-dark); }

/* 侧边栏底部（登录/注册/用户信息） */
.sidebar-bottom {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
  display: flex; flex-direction: column; gap: 8px;
}
body.dark .sidebar-bottom { border-top-color: var(--border-dark); }
.sidebar-bottom a {
  font-size: 12px; color: var(--muted-light);
  text-decoration: none; transition: color 0.3s;
}
.sidebar-bottom a:hover { color: var(--accent); }
.sidebar-user { font-weight: 500; color: var(--accent) !important; }
.sidebar-admin-btn { color: var(--accent) !important; font-size: 12px; }
.sidebar-logout { font-size: 11px; }
.sidebar-login, .sidebar-register { font-size: 12px; }

.theme-toggle-btn {
  background: none; border: none; color: var(--muted-light);
  cursor: pointer; font-size: 12px; display: flex;
  align-items: center; gap: 6px; font-family: inherit; padding: 0;
}
.theme-toggle-btn:hover { color: var(--accent); }
body.dark .theme-toggle-btn { color: var(--muted-dark); }

/* ── 主要内容区 ── */
.main-content {
  margin-left: 220px;
  min-height: 100dvh;
}

/* ── 墨点画布 ── */
#ink-canvas {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
}

/* ── 首屏 ── */
.hero {
  position: relative; z-index: 1;
  min-height: 100dvh;
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  text-align: center; padding: 20px;
}

/* 标题：书写渐现动画 */
.hero-title {
  font-size: clamp(4rem, 10vw, 7rem);
  font-weight: 200; letter-spacing: 0.08em;
  font-style: italic; margin-bottom: 2rem;

  color: transparent;
  background: linear-gradient(90deg, var(--text-light) 0%, var(--text-light) 100%);
  background-clip: text;
  -webkit-background-clip: text;
  background-size: 0% 100%;
  background-repeat: no-repeat;
  animation: write-in 2.2s var(--ease-out) forwards;
}
body.dark .hero-title {
  background: linear-gradient(90deg, var(--text-dark) 0%, var(--text-dark) 100%);
  background-clip: text;
  -webkit-background-clip: text;
}

@keyframes write-in {
  0%   { background-size: 0% 100%; }
  40%  { background-size: 100% 100%; }
  85%  { background-size: 100% 100%; }
  100% { background-size: 100% 100%; opacity: 1; }
}

/* Slogan：呼吸动画 */
.slogan {
  display: flex; gap: 10px; align-items: center;
  color: var(--muted-light); letter-spacing: 0;
  margin-bottom: 3rem; font-size: 14px; font-weight: 300;
}
body.dark .slogan { color: var(--muted-dark); }
.slogan .dot { opacity: 0.3; }

.breathe-char {
  display: inline-block;
  animation: breathe 4s ease-in-out infinite;
}
.breathe-char:nth-child(1) { animation-delay: 0.0s; }
.breathe-char:nth-child(2) { animation-delay: 0.15s; }
.breathe-char:nth-child(3) { animation-delay: 0.3s; }
.breathe-char:nth-child(4) { animation-delay: 0.45s; }
.breathe-char:nth-child(6) { animation-delay: 0.6s; }
.breathe-char:nth-child(7) { animation-delay: 0.75s; }
.breathe-char:nth-child(8) { animation-delay: 0.9s; }
.breathe-char:nth-child(9) { animation-delay: 1.05s; }

@keyframes breathe {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

/* 每日诗句：洇墨渐现 */
.poem {
  max-width: 520px; padding: 0 20px;
  font-size: 1.05rem; line-height: 2.2;
  letter-spacing: 2px; font-weight: 300; min-height: 2.2em;
  color: var(--muted-light);

  opacity: 0; filter: blur(4px);
  animation: ink-reveal 1.8s 0.6s var(--ease-out) forwards;
}
body.dark .poem { color: var(--muted-dark); }

@keyframes ink-reveal {
  0%   { opacity: 0; filter: blur(5px); transform: translateY(12px); }
  100% { opacity: 1; filter: blur(0);   transform: translateY(0); }
}

/* 底部收笔线 */
.brush-line {
  position: absolute; bottom: 50px; left: 50%;
  transform: translateX(-50%);
  width: 1px; height: 40px;
  background: var(--muted-light);
  opacity: 0.25;
  animation: pulse-line 3s ease-in-out infinite;
}
body.dark .brush-line { background: var(--muted-dark); }
.brush-line::after {
  content: ''; position: absolute; bottom: 0; left: -2px;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); opacity: 0.4;
}

@keyframes pulse-line {
  0%, 100% { opacity: 0.25; }
  50%      { opacity: 0.55; }
}

/* ── Section/页面通用 ── */
.page-section {
  padding: 100px 60px;
  min-height: 60dvh;
}

.section-title {
  font-size: 24px; font-weight: 200; letter-spacing: 6px;
  margin-bottom: 12px; text-align: center;
}
.section-desc {
  text-align: center; font-size: 12px; color: var(--muted-light);
  letter-spacing: 2px; margin-bottom: 50px;
}
body.dark .section-desc { color: var(--muted-dark); }

/* ── 博客卡片 ── */
.posts { max-width: 560px; margin: 0 auto; }
.post-card {
  padding: 30px 0; border-bottom: 1px solid var(--border-light);
  transition: padding-left 0.3s var(--ease-out);
}
body.dark .post-card { border-bottom-color: var(--border-dark); }
.post-card:hover { padding-left: 12px; }

.post-meta {
  display: flex; gap: 12px; align-items: center;
  margin-bottom: 8px; font-size: 12px; color: var(--muted-light);
}
body.dark .post-meta { color: var(--muted-dark); }
.post-tag {
  font-size: 10px; padding: 1px 8px;
  border: 1px solid currentColor; border-radius: 999px;
  letter-spacing: 1px;
}

.post-title {
  font-size: 18px; font-weight: 400; margin-bottom: 8px;
  letter-spacing: 0.06em;
}
.post-excerpt {
  font-size: 13px; color: var(--muted-light);
  line-height: 1.8; margin-bottom: 10px;
}
body.dark .post-excerpt { color: var(--muted-dark); }

.post-link {
  font-size: 12px; color: var(--accent); text-decoration: none;
  letter-spacing: 1px; transition: opacity 0.3s, transform 0.3s;
  display: inline-block;
}
.post-link:hover { opacity: 0.7; transform: translateX(3px); }

/* ── 文章详情 ── */
.post-article { max-width: 700px; margin: 0 auto; }
.post-header { margin-bottom: 40px; }
.post-title-lg {
  font-size: 28px; font-weight: 400; letter-spacing: 0.06em;
  margin-bottom: 12px;
}
.post-meta-lg {
  font-size: 12px; color: var(--muted-light);
  letter-spacing: 1px;
}
body.dark .post-meta-lg { color: var(--muted-dark); }

.post-admin-tools {
  margin-top: 12px; display: flex; gap: 12px; align-items: center;
}
.admin-link {
  font-size: 12px; color: var(--accent); text-decoration: none;
  cursor: pointer; background: none; border: none; font-family: inherit;
}
.admin-link:hover { opacity: 0.7; }
.delete-link { color: #c0392b; }

.post-content {
  font-size: 15px; line-height: 2.2; letter-spacing: 0.04em;
}
.post-content h2 { font-size: 22px; font-weight: 400; margin: 40px 0 16px; letter-spacing: 0.06em; }
.post-content h3 { font-size: 18px; font-weight: 400; margin: 32px 0 12px; }
.post-content p { margin-bottom: 1.2em; }
.post-content blockquote {
  border-left: 2px solid var(--accent); padding-left: 20px;
  margin: 20px 0; color: var(--muted-light); font-style: italic;
}
body.dark .post-content blockquote { color: var(--muted-dark); }
.post-content pre {
  background: var(--subtle-light); padding: 16px; border-radius: var(--radius);
  overflow-x: auto; font-size: 13px; margin: 20px 0;
}
body.dark .post-content pre { background: var(--subtle-dark); }
.post-content code { font-size: 13px; }
.post-content img { max-width: 100%; border-radius: var(--radius); margin: 20px 0; }
.post-content a { color: var(--accent); }
.post-content ul, .post-content ol { padding-left: 20px; margin-bottom: 1.2em; }
.post-content li { margin-bottom: 0.4em; }

/* ── 评论 ── */
.comment-form, .msg-form {
  max-width: 560px; margin: 0 auto 40px;
}
.comment-list, .msg-list { max-width: 560px; margin: 0 auto; }

.comment-item, .msg-item {
  padding: 16px 0; border-bottom: 1px solid var(--border-light);
}
body.dark .comment-item, body.dark .msg-item { border-bottom-color: var(--border-dark); }
.comment-item:last-child, .msg-item:last-child { border-bottom: none; }

.comment-header, .msg-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.comment-author, .msg-author {
  font-size: 13px; font-weight: 500; letter-spacing: 0.04em;
}
.comment-time, .msg-time {
  font-size: 11px; color: var(--muted-light);
}
body.dark .comment-time, body.dark .msg-time { color: var(--muted-dark); }

.comment-body, .msg-body {
  font-size: 14px; line-height: 1.9; color: var(--muted-light);
  letter-spacing: 0.03em;
}
body.dark .comment-body, body.dark .msg-body { color: var(--muted-dark); }
.comment-body p, .msg-body p { margin-bottom: 0.5em; }
.comment-body p:last-child, .msg-body p:last-child { margin-bottom: 0; }

.empty-hint {
  text-align: center; color: var(--muted-light);
  font-size: 13px; padding: 40px 0;
}
body.dark .empty-hint { color: var(--muted-dark); }

/* ── 分页 ── */
.pagination {
  display: flex; justify-content: center; align-items: center;
  gap: 16px; padding: 30px 0;
}
.page-link {
  font-size: 13px; color: var(--accent); text-decoration: none;
  letter-spacing: 1px; transition: opacity 0.3s;
}
.page-link:hover { opacity: 0.7; }
.page-info { font-size: 12px; color: var(--muted-light); }
body.dark .page-info { color: var(--muted-dark); }

/* ── 认证表单 ── */
.auth-page { max-width: 400px; margin: 0 auto; }
.auth-form { max-width: 360px; margin: 0 auto; }

.form-group { margin-bottom: 20px; }
.form-group label {
  display: block; font-size: 13px; margin-bottom: 6px;
  letter-spacing: 0.06em; color: var(--muted-light);
}
body.dark .form-group label { color: var(--muted-dark); }
.optional { font-weight: 300; font-size: 11px; }

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group textarea {
  width: 100%; padding: 12px 16px;
  border: 1px solid var(--border-light); border-radius: var(--radius);
  background: transparent; color: inherit;
  font-size: 14px; letter-spacing: 0.04em;
  outline: none; transition: border-color 0.3s;
  font-family: inherit; line-height: 1.6;
}
.form-group input:focus,
.form-group textarea:focus { border-color: var(--accent); }
body.dark .form-group input,
body.dark .form-group textarea { border-color: var(--border-dark); }

.btn-submit {
  padding: 12px 32px;
  border: 1px solid var(--text-light); border-radius: 999px;
  background: transparent; color: var(--text-light);
  font-size: 13px; letter-spacing: 0.1em;
  cursor: pointer; transition: all 0.3s var(--ease-out);
  font-family: inherit;
}
.btn-submit:hover {
  background: var(--text-light); color: var(--bg-light);
}
body.dark .btn-submit {
  border-color: var(--text-dark); color: var(--text-dark);
}
body.dark .btn-submit:hover {
  background: var(--text-dark); color: var(--bg-dark);
}

.btn-cancel {
  padding: 12px 32px; font-size: 13px; letter-spacing: 0.1em;
  color: var(--muted-light); text-decoration: none;
  transition: color 0.3s;
}
.btn-cancel:hover { color: var(--text-light); }
body.dark .btn-cancel:hover { color: var(--text-dark); }

.form-actions { display: flex; gap: 12px; align-items: center; }

.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; cursor: pointer; color: var(--muted-light);
}
body.dark .checkbox-label { color: var(--muted-dark); }

.auth-alt {
  text-align: center; margin-top: 24px;
  font-size: 13px; color: var(--muted-light);
}
body.dark .auth-alt { color: var(--muted-dark); }
.auth-alt a { color: var(--accent); text-decoration: none; }

/* ── 时间轴 ── */
.timeline {
  max-width: 480px; margin: 0 auto;
  padding-left: 30px; border-left: 1px solid var(--border-light);
}
body.dark .timeline { border-left-color: var(--border-dark); }

.tl-item { position: relative; padding-bottom: 40px; }
.tl-item:last-child { padding-bottom: 0; }

.tl-dot {
  position: absolute; left: -37px; top: 6px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); transition: transform 0.3s;
}
.tl-item:hover .tl-dot { transform: scale(1.4); }

.tl-content time {
  font-size: 11px; color: var(--muted-light); letter-spacing: 2px;
}
body.dark .tl-content time { color: var(--muted-dark); }
.tl-content p {
  font-size: 14px; line-height: 1.9; margin-top: 4px;
  letter-spacing: 0.04em;
}

/* ── 对话 ── */
.chat-box {
  max-width: 560px; margin: 0 auto;
}
.chat-messages {
  min-height: 300px; max-height: 500px; overflow-y: auto;
  padding: 20px 0;
}
.chat-msg { display: flex; gap: 12px; margin-bottom: 20px; }
.chat-msg.bot { }
.chat-msg.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--subtle-light); display: flex;
  justify-content: center; align-items: center;
  font-size: 12px; flex-shrink: 0;
}
body.dark .msg-avatar { background: var(--subtle-dark); }

.msg-content {
  max-width: 80%; padding: 10px 16px;
  border-radius: var(--radius-lg);
  background: var(--subtle-light); font-size: 14px; line-height: 1.8;
}
body.dark .msg-content { background: var(--subtle-dark); }

.chat-input-area {
  display: flex; gap: 10px; margin-top: 16px;
}
.chat-input-area textarea {
  flex: 1; padding: 12px 16px;
  border: 1px solid var(--border-light); border-radius: var(--radius);
  background: transparent; color: inherit; font-size: 14px;
  font-family: inherit; line-height: 1.6; resize: none; outline: none;
  transition: border-color 0.3s;
}
.chat-input-area textarea:focus { border-color: var(--accent); }
body.dark .chat-input-area textarea { border-color: var(--border-dark); }

.chat-input-area button {
  padding: 12px 24px; border: 1px solid var(--text-light);
  border-radius: 999px; background: transparent; color: var(--text-light);
  cursor: pointer; font-family: inherit; font-size: 13px;
  transition: all 0.3s; white-space: nowrap;
}
.chat-input-area button:hover:not(:disabled) {
  background: var(--text-light); color: var(--bg-light);
}
.chat-input-area button:disabled { opacity: 0.3; cursor: not-allowed; }
body.dark .chat-input-area button {
  border-color: var(--text-dark); color: var(--text-dark);
}
body.dark .chat-input-area button:hover:not(:disabled) {
  background: var(--text-dark); color: var(--bg-dark);
}

.chat-hint {
  text-align: center; font-size: 11px; color: var(--muted-light);
  margin-top: 12px; letter-spacing: 1px;
}
body.dark .chat-hint { color: var(--muted-dark); }

/* ── 编辑器 ── */
.editor-page { max-width: 800px; margin: 0 auto; }
.editor-form { max-width: 100%; }
#editor-container {
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
}
body.dark #editor-container { border-color: var(--border-dark); }

/* ── 错误页面 ── */
.error-page { text-align: center; padding: 20vh 20px !important; }
.error-code { font-size: 6rem; font-weight: 200; letter-spacing: 0.1em; }
.error-message { font-size: 16px; color: var(--muted-light); margin: 16px 0 32px; }
body.dark .error-message { color: var(--muted-dark); }

/* ── Footer ── */
.site-footer {
  margin-left: 220px;
  padding: 60px 20px 40px;
  text-align: center;
  border-top: 1px solid var(--border-light);
}
body.dark .site-footer { border-top-color: var(--border-dark); }

.footer-inner {
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.footer-inner p { font-size: 12px; color: var(--muted-light); letter-spacing: 1px; }
body.dark .footer-inner p { color: var(--muted-dark); }
.footer-inner a { color: var(--accent); text-decoration: none; }
.footer-links { font-size: 11px; }

/* ── 滚动渐现动画 ── */
.reveal {
  opacity: 0; transform: translateY(24px);
  transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
}
.reveal.visible { opacity: 1; transform: translateY(0); }
.reveal.d1 { transition-delay: 0.1s; }
.reveal.d2 { transition-delay: 0.2s; }
.reveal.d3 { transition-delay: 0.3s; }
.reveal.d4 { transition-delay: 0.4s; }

/* ── 手机菜单按钮 ── */
.mobile-menu-btn {
  display: none;
  position: fixed; top: 25px; left: 25px; z-index: 1000;
  cursor: pointer; opacity: 0.6; transition: opacity 0.3s;
}
.mobile-menu-btn:hover { opacity: 1; }

/* ── 手机适配 ── */
@media (max-width: 768px) {
  .mobile-menu-btn { display: block; }

  .sidebar {
    width: 100%; background: var(--bg-light);
    transform: translateX(-100%); opacity: 0; pointer-events: none;
    padding: 100px 40px 20px;
  }
  body.dark .sidebar { background: var(--bg-dark); }
  .sidebar.show { transform: translateX(0); opacity: 1; pointer-events: auto; }

  .main-content { margin-left: 0; }
  .site-footer { margin-left: 0; }

  .hero-title { font-size: clamp(4rem, 18vw, 6rem); }
  .slogan { font-size: 13px; letter-spacing: 1px; margin-bottom: 3rem; }
  .poem { font-size: 1rem; line-height: 2; }

  .page-section { padding: 80px 20px; }
  .section-title { letter-spacing: 4px; }

  .post-card:hover { padding-left: 0; }
  .post-link { opacity: 1; transform: none; }
}

@media (max-width: 480px) {
  .hero-title { font-size: clamp(3.2rem, 16vw, 5rem); }
  .timeline { padding-left: 24px; }
  .tl-dot { left: -31px; }
  .post-title-lg { font-size: 22px; }
  .auth-page { padding-left: 16px; padding-right: 16px; }
}

/* ── 减少动效偏好 ── */
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
  .brush-line { animation: none !important; }
  .breathe-char { animation: none !important; }
  .hero-title { animation: none !important; }
  .poem { animation: none !important; }
  .loader-text { animation: none !important; }
}
