@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ---------- 日夜氛围色板 ----------
   默认（无 JS / 不支持时）落在 night，和站点上线以来的原始深色一致；
   day/dusk 靠 public/experience.js 按访客本地时间挂在 <html data-ambient>
   上切换，过渡时长见下面 body 的 transition。三套色板只换„情绪基调"，
   --accent 三态统一不变，是贯穿全站的锚点色。 */
:root,
html[data-ambient="night"] {
  --bg: #14161c;
  --bg-raised: #1a1d25;
  --text: #ece7dd;
  --text-dim: #8b8f9c;
  --hairline: #2a2d37;
  --accent: #b1503a;
  --accent-soft: rgba(177, 80, 58, 0.14);
}

html[data-ambient="dusk"] {
  --bg: #1c1815;
  --bg-raised: #241f1a;
  --text: #e3d9cb;
  --text-dim: #9c8f7f;
  --hairline: #33291f;
  --accent: #b1503a;
  --accent-soft: rgba(177, 80, 58, 0.16);
}

html[data-ambient="day"] {
  --bg: #f5f3ee;
  --bg-raised: #ece8e0;
  --text: #2a2620;
  --text-dim: #8b8579;
  --hairline: #e3ddd0;
  --accent: #9c4530;
  --accent-soft: rgba(156, 69, 48, 0.1);
}

/* 跨页面翻页时给个 ~500ms 的淡入淡出，支持的浏览器（Chrome）才有效果，
   其余浏览器直接忽略这条规则，退化成普通跳转——不是必需的交互，只是锦上添花。 */
@view-transition {
  navigation: auto;
}

@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0.5s;
    animation-timing-function: ease;
  }
}

* { box-sizing: border-box; }

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Serif SC', 'Songti SC', serif;
  line-height: 1.9;
  -webkit-font-smoothing: antialiased;
  /* 氛围切换时背景/文字慢慢淡过去，不是一下跳变的主题切换 */
  transition: background-color 20s ease, color 20s ease;
}

.mono {
  font-family: 'IBM Plex Mono', 'SF Mono', monospace;
}

.sans {
  font-family: 'Inter', -apple-system, sans-serif;
}

a { color: inherit; }

.wrap {
  max-width: 620px;
  margin: 0 auto;
  padding: 64px 24px 120px;
}

/* ---------- 折叠导航 ----------
   默认只有一个极淡的 ··· ，点开才出现「阅读 / 时间 / 关于」——首页不
   应该一直摆着一排导航项。 */
.nav-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 50;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  padding: 10px 12px;
  cursor: pointer;
  letter-spacing: 0.15em;
  transition: color 0.15s ease;
}

.nav-toggle:hover { color: var(--text); }

.nav-panel {
  position: fixed;
  top: 54px;
  right: 20px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.nav-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.nav-panel a,
.nav-panel button {
  display: block;
  background: none;
  border: none;
  font-family: 'Inter', sans-serif;
  color: var(--text-dim);
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  padding: 2px 0;
}

.nav-panel a:hover,
.nav-panel button:hover {
  color: var(--accent);
}

/* ---------- 首屏 hero ----------
   进场：opacity + 1~2px 位移，依次出现，不做旋转/缩放/粒子这类炫技动画。
   本来还叠了 filter: blur() 做虚焦到清晰的效果，但 blur() 动画在不少移动端
   浏览器（尤其 WebKit）结束后不保证真的落回 blur(0)，会卡在半模糊状态
   出不来（阅读页最明显——见此规则的调整记录），所以去掉，只留 opacity +
   位移一样能有"渐渐显现"的效果，且不会有这个坑。 */
@keyframes heroFadeIn {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

header.site.hero {
  /* 有意不做 100vh 满屏——那意味着每次打开都要先划过一整屏空白才看到
     第一条内容，对一个常回来看/写的私人博客来说是负担而不是氛围。用
     padding 撑出"进场"的分量感就够了，第一条内容的时间戳在桌面端会
     隐约露出一点在折叠线附近，暗示"还有内容，往下看"。 */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 15vh 24px 9vh;
  margin-bottom: 0;
}

header.site.hero .brand {
  flex-direction: column;
  gap: 18px;
  margin-bottom: 16px;
  animation: heroFadeIn 700ms ease-out 200ms both;
}

header.site.hero .mark-icon {
  width: 44px;
  height: 44px;
}

header.site.hero h1 {
  font-size: 36px;
}

header.site.hero > p.sans {
  animation: heroFadeIn 700ms ease-out 450ms both;
}

.hero-echo {
  margin-top: 36px;
  text-align: center;
  animation: heroFadeIn 700ms ease-out 600ms both;
}

.hero-echo-time {
  font-size: 15px;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 8px;
}

.hero-echo p {
  margin: 0;
  font-size: 13px;
  color: var(--text-dim);
}

.hero-year {
  margin-top: 32px;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  animation: heroFadeIn 700ms ease-out 750ms both;
}

.hero-arrow {
  display: block;
  margin-top: 40px;
  font-size: 18px;
  color: var(--text-dim);
  text-decoration: none;
  animation: heroFadeIn 700ms ease-out 1050ms both;
}

a.hero-arrow:hover { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  header.site.hero .brand,
  header.site.hero > p.sans,
  .hero-echo,
  .hero-year,
  .hero-arrow {
    animation: none;
  }
}

header.site {
  margin-bottom: 56px;
}

header.site .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

header.site .mark-icon {
  display: block;
  border-radius: 8px;
  flex-shrink: 0;
}

header.site h1 {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.02em;
  margin: 0;
}

header.site p {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text-dim);
  margin: 0;
}

/* 折叠进「时间」/「搜索」里的归档 + 搜索框，各自独立展开 */
.time-panel,
.search-panel {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.4s ease, opacity 0.3s ease;
}

.time-panel.open,
.search-panel.open {
  max-height: 2000px;
  opacity: 1;
}

.empty {
  color: var(--text-dim);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  padding: 40px 0;
}

.search {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.search input[type="text"] {
  flex: 1;
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  padding: 9px 16px;
}

.search input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

.search .clear {
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
  white-space: nowrap;
}

.archive {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--hairline);
}

.archive a {
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
}

.archive a.active {
  color: var(--accent);
}

.archive a:hover {
  color: var(--text);
}

/* ---------- 阅读呼吸 ----------
   段落整体渐显（不是逐字），滚动到视口内才慢慢显现；见 public/experience.js
   的 IntersectionObserver。没有 JS 时 .in-view 由 experience.js 直接补上，
   所以永远不会卡在 opacity:0。 */
.post[data-reveal] {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.9s ease, transform 0.9s ease;
}

.post[data-reveal].in-view {
  opacity: 1;
  transform: translateY(0);
}

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

.post {
  position: relative;
  padding: 32px 0;
  margin-top: 28px;
  border-top: none;
}

.post:first-of-type {
  margin-top: 0;
}

.post:not(:first-of-type)::before {
  content: '·';
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--hairline);
  font-size: 20px;
  line-height: 1;
}

.post time {
  display: block;
  font-family: 'IBM Plex Mono', 'SF Mono', monospace;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 16px;
  letter-spacing: 0.02em;
}

/* 时间 > 日期：这个站的内容几乎全发生在深夜，具体几点比日期本身更有
   信息量，所以时间字号更大、颜色更亮，日期只是个淡淡的坐标。 */
.t-date {
  color: var(--text-dim);
  opacity: 0.85;
}

.t-time {
  margin-left: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

/* 整条内容本身就是进沉浸阅读的入口，不用一行"沉浸阅读 →"的产品化文案——
   .post-link 铺满整块当"拉伸热区"，但内容里真正的链接/媒体控件/点赞按钮
   要叠在它上面（z-index 更高），否则会被这块透明链接整个盖住点不到。 */
.post-link {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.post time,
.post .content a,
.post .attachment,
.post .reactions {
  position: relative;
  z-index: 2;
}

.post .content { cursor: pointer; }

.post .content {
  font-size: 19px;
  line-height: 1.9;
  word-break: break-word;
  letter-spacing: 0.01em;
}

@media (max-width: 640px) {
  .post .content {
    font-size: 18px;
    line-height: 1.85;
  }
}

.post .content p {
  margin: 0 0 14px;
}

.post .content p:last-child {
  margin-bottom: 0;
}

.post .content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--hairline);
}

.post .content a:hover {
  text-decoration-color: var(--accent);
}

.post .content code {
  font-family: 'Inter', monospace;
  font-size: 0.9em;
  background: var(--bg-raised);
  padding: 2px 5px;
  border-radius: 3px;
}

.post .content pre {
  background: var(--bg-raised);
  padding: 14px;
  border-radius: 6px;
  overflow-x: auto;
}

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

.post .content blockquote {
  margin: 0 0 14px;
  padding-left: 16px;
  border-left: 2px solid var(--hairline);
  color: var(--text-dim);
}

.post .content ul,
.post .content ol {
  margin: 0 0 14px;
  padding-left: 22px;
}

.post img.attachment,
.post video.attachment {
  display: block;
  max-width: 100%;
  border-radius: 3px;
  margin-top: 16px;
}

.post audio.attachment {
  display: block;
  width: 100%;
  margin-top: 16px;
}

.reactions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  font-family: 'Inter', sans-serif;
}

.reactions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--hairline);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.reactions button:hover {
  border-color: var(--accent);
  color: var(--text);
}

.reactions button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.reactions button svg {
  width: 14px;
  height: 14px;
}

.reactions button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* 0 这个数字对私人日记来说没有意义，只会破坏氛围，干脆不显示——有了
   反应之后数字才出现，见 index.ejs 和下面 index.ejs 内联脚本里对
   .zero 的处理。 */
.count.zero {
  display: none;
}

.copy-btn,
.export-btn {
  padding-left: 11px;
  padding-right: 11px;
}

footer.site {
  margin-top: 80px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}

.pagination {
  text-align: center;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--hairline);
}

.pagination a {
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: none;
}

.pagination a:hover {
  color: var(--accent);
}

footer.site a {
  color: var(--text-dim);
  text-decoration: none;
  border-bottom: 1px solid var(--hairline);
}

/* ---------- admin ---------- */

.admin-wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 64px 24px 100px;
  font-family: 'Inter', sans-serif;
}

.admin-wrap h1 {
  font-family: 'Noto Serif SC', serif;
  font-size: 22px;
  font-weight: 500;
  margin-bottom: 32px;
}

.compose textarea {
  width: 100%;
  min-height: 130px;
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  color: var(--text);
  font-family: 'Noto Serif SC', serif;
  font-size: 15px;
  padding: 14px;
  resize: vertical;
  line-height: 1.7;
}

.compose textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.compose-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.media-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.media-row input[type="url"] {
  flex: 1;
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 9px 12px;
}

.media-row select {
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 9px 10px;
}

.media-row input[type="url"]:focus,
.media-row select:focus {
  outline: none;
  border-color: var(--accent);
}

.hint {
  font-size: 12px;
  color: var(--text-dim);
  margin: 8px 0 0;
}

.schedule-row {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
}

.schedule-row label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
}

.schedule-row input[type="datetime-local"] {
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  padding: 9px 12px;
  width: fit-content;
}

.schedule-row input[type="datetime-local"]:focus {
  outline: none;
  border-color: var(--accent);
}

.scheduled-tag {
  color: var(--accent);
}

.current-media {
  margin-top: 14px;
  padding: 12px;
  background: var(--bg-raised);
  border-radius: 6px;
}

.current-media img {
  max-width: 100%;
  border-radius: 4px;
  display: block;
  margin-bottom: 8px;
}

.current-media p {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text-dim);
  word-break: break-all;
}

.current-media label {
  font-size: 12px;
  color: var(--text-dim);
}

.file-label {
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
}

.file-label input { display: none; }

button.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 20px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  cursor: pointer;
}

button.primary:hover { opacity: 0.9; }

input[type="password"] {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  color: var(--text);
  font-size: 15px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
}

.error {
  color: var(--accent);
  font-size: 13px;
  margin-bottom: 16px;
}

.admin-post {
  border-top: 1px solid var(--hairline);
  padding: 18px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.admin-post .content {
  font-family: 'Noto Serif SC', serif;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
}

.admin-post time {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.admin-post form { flex-shrink: 0; }

.admin-post-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.admin-post-actions a.del {
  text-decoration: none;
}

.admin-post button.del {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
}

.admin-post button.del:hover { color: var(--accent); }

.section-title {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--text-dim);
  margin: 48px 0 4px;
}

/* ---------- 沉浸阅读 (/p/:code) ----------
   一整段连续的时间流：往下滚就是更早的一条，而不是"文章详情页 + 下一篇
   按钮"。第一条(#reader-start)保留原来的进场淡入，后面每一条复用
   data-reveal 的滚动显现，衔接感靠这个，不是靠花哨的过渡。 */

.reader {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 560px;
  margin: 0 auto;
  padding: 96px 24px;
}

.reader[data-reveal] {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 1s ease, transform 1s ease;
}

.reader[data-reveal].in-view {
  opacity: 1;
  transform: translateY(0);
}

.reader time {
  display: block;
  text-align: center;
  font-family: 'IBM Plex Mono', monospace;
  margin-bottom: 48px;
}

.reader time .t-date {
  display: block;
  margin-left: 0;
  font-size: 13px;
  margin-bottom: 8px;
}

.reader time .t-time {
  display: block;
  margin-left: 0;
  font-size: 22px;
  font-weight: 500;
}

/* 记忆回声：紧贴着时间戳，比正文更淡、更小——是路过时才会注意到的
   细节，不是又一行需要读的信息。负 margin-top 把它拉近时间戳，跟
   正文之间再留出正常的呼吸间距。 */
.reader .echo {
  margin: -24px 0 40px;
  text-align: center;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--accent);
  opacity: 0.8;
}

.reader .content {
  font-size: 23px;
  line-height: 1.95;
  text-align: center;
  word-break: break-word;
}

#reader-start time {
  animation: heroFadeIn 900ms ease-out 200ms both;
}

#reader-start .content {
  animation: heroFadeIn 900ms ease-out 350ms both;
}

.reader .attachment {
  display: block;
  max-width: 100%;
  margin: 32px auto 0;
  border-radius: 3px;
}

@media (max-width: 640px) {
  .reader { padding: 72px 20px; }
  .reader .content { font-size: 19px; line-height: 1.9; }
}

@media (prefers-reduced-motion: reduce) {
  #reader-start time,
  #reader-start .content,
  .reader[data-reveal] {
    animation: none;
    opacity: 1;
    transform: none;
    transition: none;
  }
}

.reader-dot {
  text-align: center;
  color: var(--hairline);
  font-size: 20px;
}

.reader-end {
  text-align: center;
  padding: 0 24px 96px;
}

.reader-end a {
  display: inline-block;
  font-size: 20px;
  color: var(--hairline);
  text-decoration: none;
}

.reader-end a:hover { color: var(--accent); }

/* 真的翻到最早一条了，不是留一个孤零零的"·"——给这段时间流一个收尾。 */
.reader-end .dot {
  font-size: 20px;
  color: var(--hairline);
  margin: 0 0 12px;
}

.reader-end p {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--text-dim);
}

.reader-end .mark {
  margin-top: 10px;
  font-family: 'Noto Serif SC', 'Songti SC', serif;
  font-size: 16px;
  color: var(--text);
}

.reader-end[data-reveal] {
  opacity: 0;
  transition: opacity 1s ease;
}

.reader-end[data-reveal].in-view { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .reader-end[data-reveal] { opacity: 1; transition: none; }
}

/* 一开始不打扰阅读，滚动后才淡淡出现 */
.fade-in {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.fade-in.visible {
  opacity: 1;
  pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
  .fade-in { transition: none; }
}

.reader-back {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 50;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: none;
}

.reader-back:hover { color: var(--text); }

/* ---------- 关于 (/about) ---------- */

.about-page {
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 64px 24px;
}

.about-page .content {
  max-width: 420px;
  font-size: 20px;
  line-height: 2.2;
}

.about-page .content p { margin: 0 0 8px; }

.about-page .mark-icon {
  display: block;
  margin: 0 auto 24px;
  border-radius: 8px;
}

.about-page .dot {
  color: var(--hairline);
  margin: 20px 0;
}

.about-page .year {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--text-dim);
}
