/* =========================================================
   Wiki 公开站 · 布局与组件
   色值一律取自 tokens.css，本文件不写死颜色
   ========================================================= */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  /* 撑满一屏的列布局：内容不够长时，页脚靠 margin-top: auto 吸在屏幕底部，
     而不是跟着内容停在半空 */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-family: var(--w-font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--w-text);
  background: var(--w-page);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--w-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 8px 14px;
  background: var(--w-surface);
  border-radius: var(--w-radius-sm);
  z-index: 100;
}
.skip-link:focus { left: 12px; top: 12px; }

:focus-visible {
  outline: 2px solid var(--w-accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* —— 顶栏 —— */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--w-glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--w-border);
}

.topbar-inner {
  /* 通栏：站点名贴着窗口左侧，只留一个字（1em）的间距 */
  padding: 10px 1em;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--w-text);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; opacity: 0.75; }

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.search input {
  width: 200px;
  height: 34px;
  padding: 0 14px;
  font: inherit;
  font-size: 14px;
  color: var(--w-text);
  background: var(--w-fill);
  border: 1px solid transparent;
  border-radius: var(--w-radius-pill);
  transition: border-color var(--w-dur) var(--w-ease), width var(--w-dur) var(--w-ease);
}
.search input:focus {
  width: 260px;
  outline: none;
  border-color: var(--w-accent);
  background: var(--w-surface);
}

.theme-toggle {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--w-fill);
  border: 1px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: transform var(--w-dur) var(--w-ease);
}
.theme-toggle:hover { transform: scale(1.06); }
.theme-toggle:active { transform: scale(0.94); }

.theme-toggle-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--w-text-2);
  box-shadow: inset -4px -2px 0 0 var(--w-page);
}
:root[data-theme='dark'] .theme-toggle-icon {
  background: var(--w-text);
  box-shadow: none;
}
:root[data-theme='color'] .theme-toggle-icon {
  background: linear-gradient(135deg, #7c5cff, #22d3ee 55%, #ec4899);
  box-shadow: none;
}

/* —— 标签页（站点根目录 = 标签页）—— */

.tabs {
  padding: 0 1em;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--w-text-2);
  white-space: nowrap;
  border-radius: var(--w-radius-sm) var(--w-radius-sm) 0 0;
  transition: color var(--w-dur) var(--w-ease);
}
.tab:hover { color: var(--w-text); text-decoration: none; }
.tab.is-active { color: var(--w-text); }
.tab.is-active::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--w-accent);
}
:root[data-theme='color'] .tab.is-active::after {
  background: linear-gradient(90deg, #7c5cff, #22d3ee 55%, #ec4899);
}

/* —— 主体骨架 —— */

.main {
  /* width: 100% 不能省：body 是 flex 列容器，交叉轴上的 auto 外边距会让这一项
     按内容收缩而不是撑满，整页会缩成一条窄列。
     撑满之后再靠 max-width 封顶、auto 外边距居中。 */
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.layout { display: grid; gap: 28px; grid-template-columns: 1fr; }
.layout.has-sidebar { grid-template-columns: 250px minmax(0, 1fr); }

.content {
  min-width: 0;
  background: var(--w-surface);
  border: 1px solid var(--w-border);
  border-radius: var(--w-radius-xl);
  box-shadow: var(--w-shadow-card);
  padding: 32px 36px;
}
:root[data-theme='color'] .content {
  background: linear-gradient(155deg, var(--w-glass-strong), var(--w-glass));
  backdrop-filter: blur(30px) saturate(185%);
  -webkit-backdrop-filter: blur(30px) saturate(185%);
  border-color: var(--w-border);
}

body[data-width='full'] .main { max-width: none; }
body[data-width='wide'] .main { max-width: 1400px; }

/* —— 主页 —— */

.hero {
  display: grid;
  gap: 32px;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  align-items: center;
  padding: 56px 40px;
  background: var(--w-surface);
  border: 1px solid var(--w-border);
  border-radius: var(--w-radius-xl);
  box-shadow: var(--w-shadow-card);
}
:root[data-theme='color'] .hero {
  background: linear-gradient(155deg, var(--w-glass-strong), var(--w-glass));
  backdrop-filter: blur(30px) saturate(185%);
  -webkit-backdrop-filter: blur(30px) saturate(185%);
}

.hero-title {
  margin: 0 0 12px;
  font-size: 44px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 700;
}
:root[data-theme='color'] .hero-title {
  background: linear-gradient(115deg, #5b3df5, #0ea5e9 52%, #ec4899);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-subtitle {
  margin: 0 0 28px;
  font-size: 19px;
  color: var(--w-text-2);
}

.hero-hint { margin: 12px 0 0; font-size: 14px; color: var(--w-text-3); }

.hero-features { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.hero-feature { display: flex; align-items: flex-start; gap: 10px; color: var(--w-text-2); }
.hero-check {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  border-radius: 50%;
  background: var(--w-accent-soft);
  position: relative;
}
.hero-check::after {
  content: '';
  position: absolute;
  left: 7px;
  top: 4px;
  width: 5px;
  height: 9px;
  border: solid var(--w-accent);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
:root[data-theme='color'] .hero-check::after { border-color: #6d5efc; }

/* —— 按钮 —— */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  padding: 0 22px;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--w-text);
  background: var(--w-fill);
  border: 1px solid transparent;
  border-radius: var(--w-radius-pill);
  cursor: pointer;
  transition: transform var(--w-dur) var(--w-ease), opacity var(--w-dur) var(--w-ease);
}
.button:hover { text-decoration: none; opacity: 0.88; }
.button:active { transform: scale(0.97); }
.button.is-disabled { opacity: 0.45; cursor: not-allowed; }

.button-primary {
  color: var(--w-on-accent);
  background: var(--w-accent);
}
:root[data-theme='color'] .button-primary {
  background-image: linear-gradient(135deg, #7c5cff, #4f46e5 48%, #22d3ee);
}

/* 小号按钮：评论区的「回复 / 取消」这类贴身操作用。
   除尺寸外与 .button 逐项一致（配色、圆角、字重、悬停、按下），不做第二套语言 */
.button-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--w-text);
  background: var(--w-fill);
  border: 1px solid transparent;
  border-radius: var(--w-radius-pill);
  cursor: pointer;
  transition: transform var(--w-dur) var(--w-ease), opacity var(--w-dur) var(--w-ease);
}
.button-sm:hover { text-decoration: none; opacity: 0.88; }
.button-sm:active { transform: scale(0.97); }
/* 浮在彩色底上的次要按钮：不着色，免得和底色打架 */
.button-sm.is-quiet { color: var(--w-accent); background: transparent; }
.button-sm.is-quiet:hover { background: var(--w-surface); opacity: 1; }

/* —— 侧栏目录树 —— */

.sidebar {
  position: sticky;
  top: 84px;
  align-self: start;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding: 18px 14px;
  background: var(--w-surface);
  border: 1px solid var(--w-border);
  border-radius: var(--w-radius-lg);
  box-shadow: var(--w-shadow-sm);
}
:root[data-theme='color'] .sidebar {
  background: var(--w-glass);
  backdrop-filter: blur(30px) saturate(185%);
  -webkit-backdrop-filter: blur(30px) saturate(185%);
}

.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree-children { margin-left: 10px; padding-left: 8px; border-left: 1px solid var(--w-border); }
.tree-docs { margin: 2px 0 6px; }

.tree-folder, .tree-doc {
  display: block;
  padding: 5px 10px;
  font-size: 14px;
  color: var(--w-text-2);
  border-radius: var(--w-radius-sm);
  transition: background var(--w-dur) var(--w-ease), color var(--w-dur) var(--w-ease);
}
.tree-folder { font-weight: 600; color: var(--w-text); }
.tree-doc { padding-left: 18px; }
.tree-folder:hover, .tree-doc:hover {
  background: var(--w-fill);
  text-decoration: none;
  color: var(--w-text);
}
.tree-doc.is-current {
  background: var(--w-accent-soft);
  color: var(--w-accent);
  font-weight: 500;
}

/* —— 列表与卡片 —— */

.section { margin-top: 32px; }
.section-title {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--w-text-3);
}

.doc-list, .folder-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.doc-card, .folder-card {
  padding: 16px 18px;
  background: var(--w-surface-2);
  border: 1px solid var(--w-border);
  border-radius: var(--w-radius-md);
  transition: transform var(--w-dur) var(--w-ease), box-shadow var(--w-dur) var(--w-ease);
}
.doc-card:hover, .folder-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--w-shadow-sm);
}

.doc-card-title, .folder-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--w-text);
}
.doc-card-title:hover, .folder-card-title:hover { text-decoration: none; color: var(--w-accent); }
.doc-card-summary { margin: 6px 0 0; font-size: 14px; color: var(--w-text-2); }
/* 命中片段：语义检索告诉你「命中的是哪一段」。左侧一道竖线，与摘要区分开 */
.doc-card-snippet {
  margin: 6px 0 0;
  padding-left: 10px;
  border-left: 2px solid var(--w-border-strong);
  font-size: 13px;
  color: var(--w-text-2);
}
.doc-card-time { display: block; margin-top: 8px; font-size: 12px; color: var(--w-text-3); }

.folder-card { display: flex; align-items: center; gap: 10px; }
.folder-card-count {
  margin-left: auto;
  min-width: 24px;
  padding: 1px 8px;
  font-size: 12px;
  text-align: center;
  color: var(--w-text-3);
  background: var(--w-fill);
  border-radius: var(--w-radius-pill);
}

.empty { padding: 28px 0; text-align: center; color: var(--w-text-3); }

/* —— 面包屑与标题 —— */

.crumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--w-text-3);
}
.crumb a { color: var(--w-text-2); }
.crumb-sep { color: var(--w-text-3); }

.page-title {
  margin: 0 0 6px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-hint { margin: 0 0 8px; font-size: 13px; color: var(--w-text-3); }

/* —— 文章 —— */

.doc-title {
  margin: 0 0 8px;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.doc-meta { font-size: 13px; color: var(--w-text-3); }
.doc-summary {
  margin: 18px 0 0;
  padding: 14px 18px;
  font-size: 15px;
  color: var(--w-text-2);
  background: var(--w-fill);
  border-left: 3px solid var(--w-accent);
  border-radius: 0 var(--w-radius-sm) var(--w-radius-sm) 0;
}
.doc-body { margin-top: 24px; }

/* —— 评论区 —— */

.comments {
  margin-top: 48px;
  padding-top: 28px;
  border-top: 1px solid var(--w-border);
  scroll-margin-top: 90px;
}

.comments-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 18px;
  font-size: 18px;
}
.comments-count {
  padding: 1px 9px;
  font-size: 12px;
  font-weight: 500;
  color: var(--w-text-3);
  background: var(--w-fill);
  border-radius: var(--w-radius-pill);
}

.notice {
  margin: 0 0 18px;
  padding: 11px 16px;
  font-size: 14px;
  border-radius: var(--w-radius-sm);
}
.notice.is-ok { color: var(--w-ok); background: var(--w-accent-soft); }
.notice.is-error { color: var(--w-danger); background: var(--w-fill); }

.comment-list, .comment-replies { list-style: none; margin: 0; padding: 0; }
.comment-list { display: grid; gap: 22px; }
.comment-replies { margin-top: 16px; display: grid; gap: 16px; }
.comment.is-reply {
  padding-left: 16px;
  border-left: 2px solid var(--w-border);
}

.comment-head { display: flex; align-items: center; gap: 9px; }
.comment-avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--w-text-2);
  background: var(--w-fill);
  border-radius: 50%;
}
.comment-avatar.is-admin { color: var(--w-on-accent); background: var(--w-accent); }
.comment-name { font-size: 14px; font-weight: 600; }
.comment-name.is-admin { color: var(--w-accent); }
.comment-time { font-size: 12px; color: var(--w-text-3); }
.comment-body { margin: 8px 0 0 39px; white-space: pre-wrap; word-break: break-word; }
/* 缩进到顶的深层回复：层级靠这行字说清楚 */
.comment-reply-to { margin-right: 6px; color: var(--w-accent); }

/* 每条评论下的「回复」：指向最下方那张表单的锚点，点它由 wiki.js 填上 parentId
   （没有脚本时退化成一次跳转）。按钮尺寸见 .button-sm */
.comment-actions { margin: 12px 0 0 39px; }

.comment-form {
  margin-top: 28px;
  padding: 20px;
  background: var(--w-surface-2);
  border: 1px solid var(--w-border);
  border-radius: var(--w-radius-lg);
  /* 评论里的「回复」锚点跳到这儿，别让顶栏盖住表单顶部 */
  scroll-margin-top: 90px;
}
/* 正在回复谁：点「回复」才会出现，取消即消失 */
.comment-reply-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--w-text-2);
  background: var(--w-accent-soft);
  border-radius: var(--w-radius-sm);
}
.comment-reply-chip[hidden] { display: none; }
/* 「取消」贴右边 */
.comment-reply-chip > :last-child { margin-left: auto; }
/* 按底对齐：两个字段的标签长短不一（邮箱那栏还带一句说明），
   不这么做两个输入框会一高一低 */
.comment-form-row { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; align-items: end; }
.field { display: block; margin-bottom: 14px; }
.field-label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--w-text-2); }
.field-hint { font-weight: 400; color: var(--w-text-3); }

.field input, .field textarea {
  width: 100%;
  padding: 10px 13px;
  font: inherit;
  font-size: 15px;
  color: var(--w-text);
  background: var(--w-surface);
  border: 1px solid var(--w-border-strong);
  border-radius: var(--w-radius-sm);
  transition: border-color var(--w-dur) var(--w-ease);
}
.field textarea { resize: vertical; min-height: 90px; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--w-accent); }

.comment-form-actions { display: flex; align-items: center; gap: 14px; }
.comment-form-actions .button { margin-left: auto; }

/* —— 错误页与页脚 —— */

.error-page { text-align: center; padding: 64px 36px; }
.error-code { margin: 0; font-size: 52px; font-weight: 700; color: var(--w-text-3); letter-spacing: -0.03em; }

.footer {
  /* margin-top: auto 把页脚推到底部；内容够长时它退化成 0，间距由 main 的下内边距给 */
  margin-top: auto;
  border-top: 1px solid var(--w-border);
  background: var(--w-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 16px;
  padding: 20px 1em;
  font-size: 13px;
  color: var(--w-text-3);
  text-align: center;
}
.footer-icp { color: var(--w-text-3); }
.footer-icp:hover { color: var(--w-text-2); }

/* —— 窄屏 —— */

@media (max-width: 900px) {
  .layout.has-sidebar { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
  .hero { grid-template-columns: 1fr; padding: 40px 24px; }
  .hero-title { font-size: 32px; }
  .content { padding: 24px 20px; }
  .doc-title { font-size: 26px; }
  .comment-form-row { grid-template-columns: 1fr; }
  .search input { width: 140px; }
  .search input:focus { width: 180px; }
}
