﻿/* ==========================================================================
   To Whity — 共享设计系统
   奶油 / 珊瑚 / 深墨（日记页）+ 紫（她的页面）
   来自 DESIGN-claude.md，alpha 版 Claude.com 设计体系
   ========================================================================== */

:root {
  /* ---- 主色 ---- */
  --primary: #cc785c;
  --primary-active: #ffb578;
  --primary-disabled: #e6dfd8;
  --primary-soft: rgba(66,185,131,1.00);

  /* ---- 墨色字阶 ---- */
  --ink: #141413;
  --body-strong: #252523;
  --body: #181715;
  --muted: #6c6a64;
  --muted-soft: #8e8b82;

  /* ---- 表面 ---- */
  --canvas: #faf9f5;
  --surface-soft: #f5f0e8;
  --surface-card: #efe9de;
  --surface-cream-strong: #e8e0d2;
  --surface-dark: #181715;
  --surface-dark-elevated: #252320;
  --surface-dark-soft: #1b315b;

  /* ---- 线 ---- */
  --hairline: #e6dfd8;
  --hairline-soft: #ebe6df;

  /* ---- 反色文字 ---- */
  --on-primary: #ffffff;
  --on-dark: #faf9f5;
  --on-dark-soft: #a09d96;

  /* ---- 状态 ---- */
  --accent-teal: #5db8a6;
  --accent-amber: #e8a55a;
  --success: #5db872;
  --warning: #d4a017;
  --error: #c64545;
  --error-soft: #fdf2f2;

  /* ---- 紫（她的页面）---- */
  --plum: #472153;
  --plum-soft: #ece2ee;
  --plum-tint: #faf8f7;
  --plum-mid: #8b5fa0;
  --plum-line: #ddd0e0;

  /* ---- 字体 ---- */
  --font-display: "Noto Serif SC Local", "Noto Serif SC", "Songti SC", "STSong", "SimSun", Georgia, serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, "Courier New", monospace;

  /* ---- 圆角 ---- */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 9999px;

  /* ---- 间距 ---- */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-12: 48px;
  --s-24: 96px;

  /* ---- 唯一允许的阴影 ---- */
  --shadow: 0 1px 3px rgba(20, 20, 19, 0.08);
  --max-w: 720px;
}

/* ==========================================================================
   标题字体（子集化内嵌，见 fonts/）
   ========================================================================== */
@font-face {
  font-family: "Noto Serif SC Local";
  src: url("../fonts/noto-serif-sc-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ==========================================================================
   基础
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--body);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; display: block; }

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: inherit; color: var(--ink); }

/* 选区：深藏青底 + 奶白字 */
::selection { background: #1b315b; color: #faf9f5; }
::-moz-selection { background: #1b315b; color: #faf9f5; }

/* 键盘可达性：只在键盘操作时显示焦点环 */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ==========================================================================
   顶栏
   ========================================================================== */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--s-6);
  background: rgba(250, 249, 245, 0.88);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--hairline);
}

/* 顶栏在页面滚下去时才显形，避免和开屏打架 */
.top-nav {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
body.booted .top-nav {
  opacity: 1;
  transform: none;
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 17px;
  letter-spacing: -0.2px;
  color: var(--ink);
  text-decoration: none;
}

.nav-brand::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--primary);
  flex: none;
}

.nav-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  transition: color 0.15s ease, background-color 0.15s ease;
  white-space: nowrap;
}
.nav-link:hover { color: var(--ink); background: var(--surface-soft); }
.nav-link:active { background: var(--surface-card); }

/* ==========================================================================
   版心
   ========================================================================== */
main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--s-12) var(--s-6) var(--s-24);
}

@media (max-width: 767px) {
  main { padding: var(--s-8) var(--s-5) var(--s-12); }
}

/* ==========================================================================
   开屏
   ========================================================================== */
#splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-8);
  background: var(--canvas);
  transition: opacity 0.7s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.7s;
}

#splash.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#splash .splash-logo {
  width: min(340px, 62vw);
  height: auto;
  opacity: 0;
  transform: translateY(10px) scale(0.985);
  animation: splashLogo 0.95s cubic-bezier(0.22, 1, 0.36, 1) 0.15s forwards;
}

@keyframes splashLogo {
  to { opacity: 1; transform: none; }
}

#splash .splash-poem {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(15px, 3.6vw, 19px);
  line-height: 1.9;
  letter-spacing: 0.22em;
  color: var(--muted);
  text-align: center;
  margin: 0;
  padding: 0 var(--s-6);
  /* 逐字淡入由 JS 拆字后控制 */
}

#splash .splash-poem .ch {
  display: inline-block;
  opacity: 0;
  transform: translateY(6px);
  animation: poemIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes poemIn {
  to { opacity: 1; transform: none; }
}

/* 尊重系统「减少动态效果」 */
@media (prefers-reduced-motion: reduce) {
  #splash .splash-logo,
  #splash .splash-poem .ch { animation-duration: 0.01ms !important; opacity: 1; transform: none; }
  #splash { transition-duration: 0.01ms; }
}

/* ==========================================================================
   入场动画（滚动触发）
   ========================================================================== */
[data-enter] {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 2.0s cubic-bezier(0.22, 1, 0.36, 1),
              transform 2.0s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
}

[data-enter].entered {
  opacity: 1;
  transform: none;
}

/* 动画结束后移出合成层，省内存 */
[data-enter].settled { will-change: auto; }

/* 图片入场稍微慢一点、带轻微缩放 */
[data-enter="image"] {
  transform: translateY(10px) scale(0.994);
}
[data-enter="image"].entered { transform: none; }

@media (prefers-reduced-motion: reduce) {
  [data-enter] { opacity: 1; transform: none; transition: none; }
}

/* ==========================================================================
   文章
   ========================================================================== */
.post-date {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted-soft);
  margin: 0 0 var(--s-4);
}

.post-date::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--hairline);
}

#title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 36px;
  line-height: 1.2;
  letter-spacing: -0.5px;
  color: var(--ink);
  margin: 0 0 var(--s-3);
  word-break: break-word;
  min-height: 1.2em; /* 打字机开始前占位，防止跳动 */
}

/* 打字机光标 */
#title::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 0.92em;
  margin-left: 3px;
  vertical-align: -0.08em;
  background: var(--primary);
  opacity: 0;
  animation: caret 1.05s steps(1) infinite;
}

#title.typing::after { opacity: 1; }

/* 标题为空时不显示光标 */
#title:empty::after { display: none; }

@keyframes caret {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

#title .ch {
  display: inline-block;
}

.text {
  font-size: 18px;
  line-height: 1.85;
  color: var(--body);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.text p { margin: 0 0 1.1em; }

.images {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  margin: var(--s-8) 0 0;
}

.images figure {
  margin: 0;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface-soft);
}

.images img {
  width: 100%;
  display: block;
}

.images figcaption {
  font-size: 13px;
  color: var(--muted-soft);
  padding: var(--s-3) var(--s-4);
  background: var(--surface-soft);
}

/* 返回 */
.back {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  padding: var(--s-2) var(--s-3) var(--s-2) 0;
  margin-bottom: var(--s-6);
  transition: color 0.15s ease;
}
.back:hover { color: var(--primary); }
.back svg { width: 15px; height: 15px; flex: none; }

/* ==========================================================================
   区块标题
   ========================================================================== */
.band-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 26px;
  line-height: 1.25;
  letter-spacing: -0.3px;
  color: var(--ink);
  margin: 0 0 var(--s-6);
}

section { margin-top: var(--s-24); }
section:first-of-type { margin-top: var(--s-12); }

.muted { color: var(--muted-soft); font-size: 14px; margin: 0; }

/* ==========================================================================
   留言
   ========================================================================== */
.comments form {
  background: var(--surface-card);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.comments input[type="text"],
.comments textarea {
  width: 100%;
  background: var(--canvas);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 10px var(--s-4);
  font-size: 15px;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  resize: vertical;
}

.comments input[type="text"] { height: 40px; }
.comments textarea { min-height: 80px; line-height: 1.6; }

.comments input::placeholder,
.comments textarea::placeholder { color: var(--muted-soft); }

.comments input[type="text"]:focus,
.comments textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(204, 120, 92, 0.15);
}

.comment-actions {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
}

.comment-actions .btn-primary {
  flex: none;            /* 禁止被压缩 */
  min-width: 76px;
}

#commentStatus { font-size: 13px; color: var(--muted-soft); }
#commentStatus.error { color: var(--error); }
#commentStatus.ok { color: var(--success); }

/* 留言条目 */
.comment {
  background: var(--surface-soft);
  border-radius: var(--r-lg);
  padding: var(--s-4) var(--s-5);
  margin-top: var(--s-3);
}

.comment-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-1);
}

.comment-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}

.comment-time {
  font-size: 12px;
  color: var(--muted-soft);
  font-variant-numeric: tabular-nums;
  flex: none;
}

.comment-body {
  font-size: 15px;
  line-height: 1.7;
  color: var(--body);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* ==========================================================================
   按钮
   ========================================================================== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: 40px;
  padding: 0 var(--s-5);
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.btn-primary:hover { background: var(--primary-active); }
.btn-primary:active { transform: scale(0.985); }
.btn-primary:disabled { background: var(--primary-disabled); color: var(--muted-soft); cursor: default; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: 40px;
  padding: 0 var(--s-5);
  background: var(--canvas);
  color: var(--body-strong);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.btn-secondary:hover { background: var(--surface-soft); border-color: var(--surface-cream-strong); }
.btn-secondary:active { transform: scale(0.985); }

.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
  padding: var(--s-2) 0;
  transition: color 0.15s ease;
}
.btn-text:hover { color: var(--primary-active); }

/* ==========================================================================
   两层归档：月份 > 周
   ========================================================================== */
.archive-month {
  margin-bottom: var(--s-6);
}

.month-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--hairline);
  padding: var(--s-3) 0;
  margin-bottom: var(--s-1);
  text-align: left;
  color: var(--ink);
}

.month-head .label {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 400;
  letter-spacing: -0.1px;
}

.month-head .count {
  font-size: 12px;
  color: var(--muted-soft);
  font-variant-numeric: tabular-nums;
}

.month-head .chev {
  margin-left: auto;
  width: 16px;
  height: 16px;
  color: var(--muted-soft);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  flex: none;
}

.archive-month.collapsed .month-head .chev { transform: rotate(-90deg); }

/* 折叠体：用 grid-template-rows 0fr/1fr 做高度动画，无需测量像素 */
.month-body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.36s cubic-bezier(0.22, 1, 0.36, 1);
}

.archive-month.collapsed .month-body { grid-template-rows: 0fr; }

.month-body > .month-body-inner {
  overflow: hidden;
  min-height: 0;
}

/* 周 */
.archive-week { margin-top: var(--s-1); }

.week-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  background: none;
  border: none;
  padding: var(--s-2) var(--s-1);
  text-align: left;
  color: var(--muted);
  border-radius: var(--r-sm);
  transition: background-color 0.15s ease;
}
.week-head:hover { background: var(--surface-soft); }

.week-head .label {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.week-head .count {
  font-size: 12px;
  color: var(--muted-soft);
  font-variant-numeric: tabular-nums;
}

.week-head .chev {
  margin-left: auto;
  width: 14px;
  height: 14px;
  color: var(--muted-soft);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  flex: none;
}

.archive-week.collapsed .week-head .chev { transform: rotate(-90deg); }

.week-body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.archive-week.collapsed .week-body { grid-template-rows: 0fr; }

.week-body > .week-body-inner {
  overflow: hidden;
  min-height: 0;
  padding-top: var(--s-1);
}

/* 文章条目 */
.post-row {
  display: block;
  padding: var(--s-3) var(--s-4);
  margin-bottom: var(--s-1);
  background: var(--surface-soft);
  border-left: 2px solid transparent;
  border-radius: var(--r-sm);
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.post-row:hover { background: var(--surface-card); }

.post-row.current {
  background: var(--surface-card);
  border-left-color: var(--primary);
}

.post-row .t {
  display: block;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.45;
  word-break: break-word;
}

.post-row .d {
  display: block;
  font-size: 12px;
  color: var(--muted-soft);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   她的归档（紫色区）
   ========================================================================== */
#herArchive {
  background: var(--plum-tint);
  border-radius: var(--r-lg);
  padding: var(--s-8) var(--s-6);
  margin-top: var(--s-12);
  border: 1px solid var(--plum-line);
}

#herArchive .band-title {
  color: var(--plum);
  font-size: 22px;
  margin-bottom: var(--s-4);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.her-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-1);
  border-bottom: 1px solid var(--plum-line);
  text-decoration: none;
  transition: background-color 0.15s ease;
  border-radius: var(--r-xs);
}

.her-row:last-child { border-bottom: none; }

.her-row:hover { background: var(--plum-soft); }

.her-row .t {
  font-size: 15px;
  color: var(--plum);
  line-height: 1.5;
  word-break: break-word;
}

.her-row .d {
  font-size: 12px;
  color: var(--plum-mid);
  flex: none;
  font-variant-numeric: tabular-nums;
}

.her-row .lock {
  font-size: 12px;
  margin-left: var(--s-2);
  opacity: 0.75;
}

/* ==========================================================================
   兔子入口
   ========================================================================== */
.bunny {
  display: block;
  margin: var(--s-24) auto 0;
  padding: var(--s-4);
  background: none;
  border: none;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted-soft);
  text-align: center;
  white-space: pre;
  border-radius: var(--r-md);
  transition: color 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
}

.bunny:hover {
  color: var(--primary);
  background: var(--surface-soft);
  transform: translateY(-2px);
}

.bunny:active { transform: translateY(0); }

/* ==========================================================================
   页脚
   ========================================================================== */
.site-footer {
  background: var(--surface-dark);
  color: var(--on-dark-soft);
  padding: var(--s-12) var(--s-6);
  margin-top: var(--s-24);
}

.site-footer-inner {
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-6);
  flex-wrap: wrap;
}

.f-brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 17px;
  color: var(--on-dark);
}

.f-logo {
  display: block;
  height: 42px;
  width: auto;
  opacity: 0.98;
  transition: opacity 0.2s ease;
}

.f-brand:hover .f-logo { opacity: 1; }

.f-note {
  font-size: 13px;
  color: var(--on-dark-soft);
}

@media (max-width: 767px) {
  .site-footer-inner { flex-direction: column; align-items: flex-start; gap: var(--s-3); }
  .site-footer { padding: var(--s-8) var(--s-5); }
  .bunny { margin-top: var(--s-12); }
}

/* ==========================================================================
   弹窗
   ========================================================================== */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
  background: rgba(20, 20, 19, 0.42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.24s ease, visibility 0.24s;
}

.modal-mask.open { opacity: 1; visibility: visible; }

.modal-card {
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--canvas);
  border-radius: var(--r-xl);
  padding: var(--s-6);
  box-shadow: var(--shadow);
  transform: translateY(12px) scale(0.99);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-mask.open .modal-card { transform: none; }

.modal-card h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  color: var(--ink);
  margin: 0 0 var(--s-6);
  letter-spacing: -0.2px;
}

.modal-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: var(--s-4) 0 var(--s-2);
}

.modal-card input[type="text"],
.modal-card textarea,
.modal-card select {
  width: 100%;
  background: var(--surface-soft);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 10px var(--s-3);
  font-size: 15px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.modal-card input[type="text"] { height: 40px; }
.modal-card textarea { min-height: 140px; resize: vertical; line-height: 1.6; }

.modal-card input:focus,
.modal-card textarea:focus,
.modal-card select:focus {
  outline: none;
  background: var(--canvas);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(204, 120, 92, 0.15);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-3);
  margin-top: var(--s-6);
}

.modal-status {
  font-size: 13px;
  color: var(--muted-soft);
  margin-top: var(--s-3);
  min-height: 1.2em;
}

.modal-status.error { color: var(--error); }

/* ==========================================================================
   响应式
   ========================================================================== */
@media (max-width: 767px) {
  #title { font-size: 28px; letter-spacing: -0.3px; }
  .band-title { font-size: 22px; }
  .comments form { padding: var(--s-4); }
  .text { font-size: 17px; line-height: 1.85; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  #title { font-size: 32px; }
}

/* 深色模式：保持奶白，但让系统 UI 跟随 */
@media (prefers-color-scheme: dark) {
  /* 刻意不切换配色——奶白 canvas 就是这个站的品牌，
     强行反色会毁掉 Claude 体系的呼吸感 */
}
