/* ============================================================
   MetaChaos · 淡雅纸感主题
   设计原则：暖白纸底（#f7f6f2 而非纯白，避免刺眼），
   墨色文字，强调色只用墨蓝一种并克制点缀；
   标题用衬线体提气质，无光晕无渐变堆叠，
   层次靠留白、细线与字重建立，而非颜色对比。
   ============================================================ */

:root {
  /* 底色与表面：暖白纸感 */
  --bg: #f7f6f2;
  --surface: #fffefb;
  --surface-hover: #faf8f2;
  --border: #e6e2d8;
  --border-strong: #d2cdbf;

  /* 文字层级：墨色 */
  --text: #26292e;
  --text-muted: #6b7079;
  --text-faint: #9c9f95;

  /* 强调色：墨蓝（沉稳克制）+ 古铜点缀 */
  --accent: #3b6270;
  --accent-2: #4f7f88;
  --accent-3: #8a7355;
  --accent-soft: rgba(59, 98, 112, 0.06);
  --accent-glow: rgba(59, 98, 112, 0.14);
  --gradient: linear-gradient(120deg, #3b6270 0%, #4f7f88 100%);

  /* 提示框 */
  --warn-bg: rgba(138, 115, 85, 0.055);
  --warn-border: rgba(138, 115, 85, 0.2);
  --warn-text: #6f5c40;

  --radius: 12px;
  --radius-sm: 7px;
  --maxw: 744px;

  --font-sans: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB',
    'Noto Sans CJK SC', 'Source Han Sans SC', 'Microsoft YaHei', sans-serif;
  --font-serif: 'Songti SC', 'STSong', 'Source Han Serif SC', 'Noto Serif CJK SC',
    'SimSun', Georgia, 'Times New Roman', serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16.5px;
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  overflow-x: hidden;
}

/* ---------- 背景：极淡顶部晕染（纸感主题不需要网格与光晕） ---------- */

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(59, 98, 112, 0.05) 0%,
    rgba(59, 98, 112, 0) 420px
  );
}

/* 浅色主题下光晕是噪音，直接关掉 */
.glow {
  display: none;
}

.glow-a {
  width: 460px;
  height: 460px;
  top: -180px;
  left: 50%;
  transform: translateX(-70%);
  background: radial-gradient(circle, rgba(34, 211, 238, 0.32), transparent 68%);
  animation: drift 22s ease-in-out infinite alternate;
}

.glow-b {
  width: 380px;
  height: 380px;
  top: 180px;
  right: -120px;
  background: radial-gradient(circle, rgba(167, 139, 250, 0.26), transparent 68%);
  animation: drift 28s ease-in-out infinite alternate-reverse;
}

@keyframes drift {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(40px, 30px, 0) scale(1.12);
  }
}

.site-header,
main,
.site-footer {
  position: relative;
  z-index: 1;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.18s ease;
}

a:hover {
  color: #2f5563;
  text-decoration: none;
}

/* ---------- header ---------- */

.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(247, 246, 242, 0.86);
  backdrop-filter: saturate(150%) blur(14px);
  -webkit-backdrop-filter: saturate(150%) blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  padding-top: 15px;
  padding-bottom: 13px;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.brand-mark {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--gradient);
  box-shadow: none;
  animation: pulse 2.6s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.55;
    transform: scale(0.82);
  }
}

.brand:hover {
  text-decoration: none;
}

.nav {
  display: flex;
  gap: 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex: 1;
}

.nav::-webkit-scrollbar {
  display: none;
}

.nav a {
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
  padding-bottom: 3px;
  border-bottom: 1.5px solid transparent;
  transition: color 0.18s ease, border-color 0.18s ease;
}

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

.nav a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---------- typography ---------- */

h1,
h2,
h3,
h4 {
  line-height: 1.45;
  font-weight: 650;
  margin: 1.8em 0 0.6em;
  color: var(--text);
  font-family: var(--font-serif);
}

h1 {
  font-size: 28px;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 21px;
  padding-bottom: 0.35em;
  border-bottom: 1px solid var(--border);
}

h3 {
  font-size: 18px;
}

p {
  margin: 0 0 1.15em;
}

.lede {
  font-size: 17.5px;
  color: var(--text-muted);
  line-height: 1.8;
}

.meta {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

/* ---------- cards ---------- */

.card-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 14px;
}

.card {
  position: relative;
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease,
    background 0.22s ease;
}

/* 左上角装饰角标 */
.card::before {
  content: '';
  position: absolute;
  top: -1px;
  left: -1px;
  width: 16px;
  height: 16px;
  border-top: 1.5px solid var(--accent);
  border-left: 1.5px solid var(--accent);
  border-top-left-radius: var(--radius);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  background: var(--surface-hover);
  box-shadow: 0 8px 24px -14px rgba(38, 41, 46, 0.14);
}

.card:hover::before {
  opacity: 1;
}

.card h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.card h3 a {
  color: var(--text);
}

.card h3 a:hover {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.card p {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 15px;
}

/* ---------- tags ---------- */

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.tag {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(59, 98, 112, 0.16);
  padding: 1px 9px;
  border-radius: 20px;
  line-height: 1.7;
}

/* ---------- sections on home ---------- */

.section {
  margin: 46px 0 0;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 9px;
  margin-bottom: 18px;
  position: relative;
}

/* 章节标题左侧渐变竖条 */
.section-head::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 4px;
  bottom: 9px;
  width: 2px;
  background: var(--gradient);
  border-radius: 2px;
}

.section-head h2 {
  border: none;
  padding: 0;
  margin: 0;
  font-size: 19px;
}

.section-head a {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  white-space: nowrap;
}

/* ---------- hero ---------- */

.hero {
  padding: 52px 0 12px;
}

.hero h1 {
  margin-top: 0;
  font-size: 34px;
  letter-spacing: -0.02em;
  font-weight: 700;
  color: var(--text);
}

/* hero 下方终端风格提示行 */
.hero::after {
  content: '> building in public — thoughts, notes & things I made';
  display: block;
  margin-top: 18px;
  padding-left: 16px;
  border-left: 2px solid rgba(59, 98, 112, 0.35);
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- article ---------- */

.article-body {
  font-size: 16.5px;
}

.article-body img {
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.article-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.2em 0;
}

.article-body blockquote {
  margin: 1.5em 0;
  padding: 10px 18px;
  border-left: 2px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
}

.article-body blockquote p:last-child {
  margin-bottom: 0;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  margin: 1.5em 0;
  display: block;
  overflow-x: auto;
  border-radius: var(--radius-sm);
}

.article-body th,
.article-body td {
  border: 1px solid var(--border);
  padding: 9px 13px;
  text-align: left;
}

.article-body th {
  background: rgba(59, 98, 112, 0.05);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.article-body code {
  font-family: var(--font-mono);
  font-size: 0.87em;
  background: rgba(148, 163, 184, 0.14);
  border: 1px solid rgba(148, 163, 184, 0.16);
  padding: 1px 6px;
  border-radius: 5px;
  color: #35606e;
}

.article-body pre {
  background: #f2f0e8;
  border: 1px solid var(--border);
  padding: 15px 17px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.7;
}

.article-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
}

.article-body ul,
.article-body ol {
  padding-left: 1.3em;
}

.article-body li {
  margin-bottom: 0.4em;
}

.article-body li::marker {
  color: var(--accent);
}

/* ---------- notice ---------- */

.notice {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 14px;
  color: var(--warn-text);
  line-height: 1.75;
  margin: 1.7em 0;
}

/* ---------- 邮箱主通道卡片 ---------- */

.mail-card {
  display: block;
  margin: 6px 0 0;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  position: relative;
  overflow: hidden;
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

.mail-card::before {
  content: '';
  position: absolute;
  top: -1px;
  left: -1px;
  width: 16px;
  height: 16px;
  border-top: 1.5px solid var(--accent);
  border-left: 1.5px solid var(--accent);
  border-top-left-radius: var(--radius);
  transition: opacity 0.22s ease;
}

.mail-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 12px 34px -14px var(--accent-glow);
}

.mail-card-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--text-faint);
}

.mail-card-addr {
  display: block;
  margin: 7px 0 5px;
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.01em;
  word-break: break-all;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.mail-card-hint {
  font-size: 12.5px;
  color: var(--text-faint);
}

/* ---------- button（通用，未来可能复用） ---------- */
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.06em;
  font-weight: 500;
  padding: 10px 24px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--gradient);
  color: #fff;
  cursor: pointer;
  transition: box-shadow 0.22s ease, transform 0.18s ease;
}

.btn:hover {
  box-shadow: 0 8px 28px -8px var(--accent-glow);
  transform: translateY(-1px);
}

/* ---------- footer ---------- */

.site-footer {
  margin-top: 72px;
  padding: 28px 0 44px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

.site-footer p {
  margin: 0 0 6px;
}

/* ---------- 表格（Markdown 渲染产物） ---------- */
/* .table-wrap 由 build.mjs 的 mdToHtml 包在 <table> 外层。
   表格在窄屏会超宽，必须靠这层 overflow-x 容器兜住，否则会被裁切。 */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 22px 0;
}

.table-wrap table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 14.5px;
  margin: 0;
}

.table-wrap th,
.table-wrap td {
  padding: 9px 11px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}

.table-wrap th {
  background: var(--accent-soft);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--accent);
  white-space: nowrap;
}

.table-wrap tbody tr:hover {
  background: var(--surface-hover);
}

/* ---------- 选中与滚动条 ---------- */

::selection {
  background: rgba(59, 98, 112, 0.16);
  color: var(--text);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: rgba(59, 98, 112, 0.22);
  border-radius: 6px;
  border: 2px solid var(--bg);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(59, 98, 112, 0.34);
}

/* ---------- responsive ---------- */

/* 平板 / 小笔记本：单列布局无需分栏，主要解决内容贴边与字号过大 */
@media (max-width: 900px) {
  .wrap {
    padding: 0 22px;
  }

  .hero {
    padding: 44px 0 10px;
  }

  .hero h1 {
    font-size: 32px;
  }

  h1 {
    font-size: 26px;
  }

  h2 {
    font-size: 21px;
  }

  .card {
    padding: 19px 18px;
  }
}

@media (max-width: 600px) {
  body {
    font-size: 16px;
  }

  .wrap {
    padding: 0 16px;
  }

  .hero {
    padding: 34px 0 6px;
  }

  .hero h1 {
    font-size: 27px;
  }

  .hero::after {
    font-size: 11px;
    margin-top: 14px;
  }

  h1 {
    font-size: 23px;
  }

  h2 {
    font-size: 19px;
  }

  .site-header .wrap {
    padding-top: 12px;
    padding-bottom: 10px;
    gap: 12px;
  }

  /* 导航变长（新闻推送/读书整理/新认知/小项目），收紧间距让手机一屏放得下 */
  .nav {
    gap: 12px;
  }

  .nav a {
    font-size: 13px;
    letter-spacing: 0.02em;
  }

  .card {
    padding: 17px 16px;
  }

  .card-list {
    gap: 11px;
  }

  /* 移动端去掉装饰竖条，避免超出视口 */
  .section-head::before {
    display: none;
  }

  .glow-a {
    width: 320px;
    height: 320px;
  }

  .glow-b {
    width: 260px;
    height: 260px;
  }
}

/* ---------- 小屏表格：改为堆叠卡片，避免横滑/裁切 ---------- */
/* 字段名来自 build.mjs 写入的 td[data-label]。>640px 仍是常规表格 + 横向滚动。 */

@media (max-width: 640px) {
  .table-wrap {
    overflow-x: visible;
    margin: 18px 0;
  }

  .table-wrap table {
    min-width: 0;
    font-size: 15px;
  }

  .table-wrap thead {
    display: none;
  }

  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td {
    display: block;
    width: 100%;
  }

  .table-wrap tr {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 11px 13px 7px;
    margin-bottom: 10px;
    background: var(--surface);
  }

  .table-wrap tr:last-child {
    margin-bottom: 0;
  }

  .table-wrap tr:hover {
    background: var(--surface);
  }

  .table-wrap td {
    border: none;
    padding: 4px 0;
  }

  .table-wrap td::before {
    content: attr(data-label);
    display: block;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--text-faint);
    margin-bottom: 1px;
  }

  .table-wrap td:first-child {
    font-weight: 600;
    color: var(--text);
    padding-bottom: 6px;
    margin-bottom: 5px;
    border-bottom: 1px dashed var(--border);
  }
}

/* ---------- 无障碍：尊重减少动效偏好 ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
