/* ==========================================================================
   hosiyin个人笔记 — 全站样式
   纯静态 / 移动优先 / 无外部依赖 / 支持亮色与暗色模式
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. 设计令牌
   -------------------------------------------------------------------------- */
:root {
  color-scheme: light;

  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New",
    monospace;

  /* 亮色：暖灰底 + 深墨字，长时间阅读更舒适 */
  --bg: #f6f5f1;
  --bg-soft: #efece5;
  --surface: #fffdfa;
  --text: #23272c;
  --text-2: #5b636c;
  --text-3: #8b939c;
  --line: #e1ded6;
  --line-2: #cbc8bf;
  --accent: #1f6f63;
  --accent-hover: #175a51;
  --accent-soft: #e3efec;
  --accent-fg: #ffffff;
  --code-bg: #f0eee7;
  --shadow: 0 1px 2px rgba(24, 28, 32, 0.06), 0 8px 24px rgba(24, 28, 32, 0.05);

  --wrap: 768px;
  --radius: 10px;
  --header-h: 60px;
}

html[data-theme="dark"] {
  color-scheme: dark;

  /* 暗色：低对比蓝灰，避免纯黑刺眼 */
  --bg: #12151a;
  --bg-soft: #171b22;
  --surface: #1a1f27;
  --text: #dfe4ea;
  --text-2: #a3adb8;
  --text-3: #7a8590;
  --line: #262c35;
  --line-2: #363e49;
  --accent: #6fc4b3;
  --accent-hover: #8ad3c3;
  --accent-soft: #1b2a29;
  --accent-fg: #0e1a18;
  --code-bg: #10141a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* --------------------------------------------------------------------------
   2. 基础重置与排版
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  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);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body,
.site-header,
.site-footer {
  transition: background-color 0.2s ease, color 0.2s ease;
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

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

a:hover {
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
}

/* 屏幕阅读器专用文本 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* 跳转到主内容 */
.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  color: var(--text);
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 12px;
  text-decoration: none;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: 20px;
}

/* --------------------------------------------------------------------------
   3. 页头与导航
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-height: var(--header-h);
  padding-block: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 650;
  letter-spacing: 0.01em;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-text {
  font-size: 15.5px;
}

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

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--text-2);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  background: var(--bg-soft);
  color: var(--text);
}

/* 主题图标：亮色显示月亮，暗色显示太阳 */
.icon-sun {
  display: none;
}

html[data-theme="dark"] .icon-sun {
  display: block;
}

html[data-theme="dark"] .icon-moon {
  display: none;
}

/* 导航默认可见；启用 JS 后折叠为按钮控制的菜单 */
.site-nav {
  width: 100%;
  order: 3;
}

.site-nav ul {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-block: 10px 4px;
  border-top: 1px solid var(--line);
}

.site-nav a {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 15px;
}

.site-nav a:hover {
  background: var(--bg-soft);
  color: var(--text);
  text-decoration: none;
}

.site-nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

html.js .site-nav {
  display: none;
}

html.js .site-nav.is-open {
  display: block;
}

html.no-js .nav-toggle {
  display: none;
}

html.js .nav-toggle {
  display: grid;
}

.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  display: block;
  width: 17px;
  height: 1.5px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle-bars::before,
.nav-toggle-bars::after {
  content: "";
  position: relative;
}

.nav-toggle-bars::before {
  top: -6px;
}

.nav-toggle-bars::after {
  top: 4px;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bars {
  background: transparent;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bars::before {
  transform: translateY(6px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bars::after {
  transform: translateY(-6px) rotate(-45deg);
}

/* --------------------------------------------------------------------------
   4. 首页首屏
   -------------------------------------------------------------------------- */
.hero {
  padding-block: 52px 40px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0;
  font-size: 12.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
}

.hero h1 {
  margin-top: 14px;
  font-size: clamp(30px, 7vw, 42px);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.hero .lead {
  margin-top: 16px;
  max-width: 60ch;
  font-size: 17px;
  color: var(--text-2);
}

.hero .updated {
  margin-top: 20px;
  font-size: 13.5px;
  color: var(--text-3);
}

.hero .updated time {
  font-family: var(--font-mono);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  color: var(--text);
  font-size: 15px;
  font-weight: 550;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    color 0.15s ease;
}

.btn:hover {
  background: var(--bg-soft);
  border-color: var(--text-3);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-fg);
}

/* 首屏入场：一次轻微上浮，不做循环动画 */
.hero > * {
  animation: rise 0.5s ease both;
}

.hero > *:nth-child(2) {
  animation-delay: 0.05s;
}

.hero > *:nth-child(3) {
  animation-delay: 0.1s;
}

.hero > *:nth-child(4) {
  animation-delay: 0.15s;
}

.hero > *:nth-child(5) {
  animation-delay: 0.2s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --------------------------------------------------------------------------
   5. 区块与笔记列表
   -------------------------------------------------------------------------- */
.section {
  padding-block: 36px;
  border-bottom: 1px solid var(--line);
}

.section:last-of-type {
  border-bottom: 0;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-head h2 {
  font-size: 18.5px;
  letter-spacing: -0.01em;
}

.section-head .more {
  flex: none;
  font-size: 14px;
  color: var(--text-2);
}

.note-item {
  padding-block: 20px;
}

.note-item:first-child {
  padding-top: 0;
}

.note-item:last-child {
  padding-bottom: 0;
}

.note-item + .note-item {
  border-top: 1px solid var(--line);
}

.note-item h3 {
  font-size: 17px;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

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

.note-item h3 a:hover {
  color: var(--accent);
  text-decoration: none;
}

.note-item .note-desc {
  margin-top: 8px;
  max-width: 62ch;
  font-size: 15px;
  color: var(--text-2);
}

.note-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-3);
}

.note-meta time {
  font-family: var(--font-mono);
}

.tag {
  display: inline-block;
  padding: 1px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.7;
}

.tag:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.tag.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

/* 归档 / 关于 入口行 */
.entry-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-block: 18px;
}

.entry-row + .entry-row {
  border-top: 1px solid var(--line);
}

.entry-row h3 {
  font-size: 16.5px;
}

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

.entry-row h3 a:hover {
  color: var(--accent);
  text-decoration: none;
}

.entry-row p {
  font-size: 14.5px;
  color: var(--text-2);
}

/* --------------------------------------------------------------------------
   6. 列表页：搜索与筛选
   -------------------------------------------------------------------------- */
.page-head {
  padding-block: 44px 8px;
}

.page-head h1 {
  font-size: clamp(26px, 6vw, 34px);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.page-head .lead {
  margin-top: 14px;
  max-width: 62ch;
  font-size: 16.5px;
  color: var(--text-2);
}

.filter {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-block: 26px 6px;
}

.search-field {
  position: relative;
}

.search-field input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.search-field input::placeholder {
  color: var(--text-3);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-status {
  min-height: 1.5em;
  font-size: 13.5px;
  color: var(--text-3);
}

.empty-state {
  padding-block: 34px;
  border-top: 1px solid var(--line);
  color: var(--text-2);
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.note-item[hidden] {
  display: none;
}

/* --------------------------------------------------------------------------
   7. 归档页
   -------------------------------------------------------------------------- */
.year-group {
  padding-block: 34px;
}

.year-group + .year-group {
  border-top: 1px solid var(--line);
}

.year-group > h2 {
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: 0.08em;
  color: var(--text-3);
}

.archive-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 16px;
  padding-block: 12px;
}

.archive-item + .archive-item {
  border-top: 1px solid var(--line);
}

.archive-item time {
  flex: 0 0 92px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-3);
}

.archive-item .archive-title {
  flex: 1 1 auto;
  font-size: 15.5px;
}

/* --------------------------------------------------------------------------
   8. 标签页
   -------------------------------------------------------------------------- */
.tag-index {
  padding-block: 30px 12px;
}

.tag-index-item {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding-block: 14px;
}

.tag-index-item + .tag-index-item {
  border-top: 1px solid var(--line);
}

.tag-index-item .tag {
  font-size: 14px;
}

.tag-index-item .count {
  flex: none;
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-3);
}

.tag-index-item .tag-desc {
  flex: 1 1 auto;
  font-size: 14px;
  color: var(--text-2);
}

/* --------------------------------------------------------------------------
   9. 文章正文
   -------------------------------------------------------------------------- */
.article {
  padding-block: 40px 24px;
}

.article-header h1 {
  font-size: clamp(25px, 5.6vw, 34px);
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--text-3);
}

.article-meta time {
  font-family: var(--font-mono);
}

.prose {
  margin-top: 24px;
  font-size: 16.5px;
}

.prose > p {
  margin-top: 16px;
}

.prose > p:first-child {
  margin-top: 0;
}

.prose h2 {
  margin-top: 40px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 20.5px;
  letter-spacing: -0.01em;
}

.prose h3 {
  margin-top: 26px;
  font-size: 17.5px;
}

.prose ul,
.prose ol {
  margin-top: 14px;
  padding-left: 1.35em;
  list-style: disc;
}

.prose ol {
  list-style: decimal;
}

.prose li {
  margin-top: 6px;
}

.prose a {
  border-bottom: 1px solid var(--accent);
}

.prose code {
  padding: 0.15em 0.4em;
  border-radius: 5px;
  background: var(--code-bg);
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.prose pre {
  margin-top: 18px;
  padding: 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--code-bg);
  font-size: 13.5px;
  line-height: 1.7;
  tab-size: 2;
}

.prose pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

.prose blockquote {
  margin-top: 18px;
  padding: 2px 0 2px 16px;
  border-left: 3px solid var(--accent);
  color: var(--text-2);
}

.prose blockquote p {
  margin: 0;
}

.table-wrap {
  margin-top: 18px;
  overflow-x: auto;
}

.prose table {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  font-size: 14.5px;
}

.prose th,
.prose td {
  padding: 9px 12px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.prose th {
  background: var(--bg-soft);
  font-weight: 600;
}

.prose hr {
  margin: 34px 0;
}

.article-foot {
  margin-top: 44px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.article-nav {
  display: grid;
  gap: 12px;
}

.article-nav a {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.article-nav a:hover {
  background: var(--bg-soft);
  border-color: var(--line-2);
  text-decoration: none;
}

.article-nav .label {
  display: block;
  font-size: 12.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

.article-nav .title {
  display: block;
  margin-top: 4px;
  font-size: 15.5px;
}

.article-nav .disabled {
  display: block;
  padding: 14px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--text-3);
  font-size: 14px;
}

.back-link {
  display: inline-block;
  margin-top: 22px;
  font-size: 14.5px;
  color: var(--text-2);
}

/* 阅读进度条 */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 40;
  width: 0;
  height: 2px;
  background: var(--accent);
}

/* --------------------------------------------------------------------------
   10. 关于 / 隐私等文本页
   -------------------------------------------------------------------------- */
.page-section {
  padding-block: 30px;
}

.page-section + .page-section {
  border-top: 1px solid var(--line);
}

.page-section h2 {
  font-size: 19px;
  letter-spacing: -0.01em;
}

.page-section p {
  margin-top: 14px;
  color: var(--text-2);
}

.page-section ul {
  margin-top: 14px;
  padding-left: 1.2em;
  list-style: disc;
  color: var(--text-2);
}

.page-section li {
  margin-top: 6px;
}

.fact-list {
  margin-top: 14px;
}

.fact-list div {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding-block: 11px;
}

.fact-list div + div {
  border-top: 1px solid var(--line);
}

.fact-list dt {
  flex: 0 0 120px;
  color: var(--text-3);
  font-size: 14px;
}

.fact-list dd {
  flex: 1 1 auto;
  margin: 0;
  font-size: 15px;
}

/* --------------------------------------------------------------------------
   11. 404 页
   -------------------------------------------------------------------------- */
.notfound {
  padding-block: 88px 72px;
  text-align: center;
}

.notfound .code {
  font-family: var(--font-mono);
  font-size: clamp(52px, 16vw, 76px);
  line-height: 1;
  color: var(--accent);
}

.notfound h1 {
  margin-top: 18px;
  font-size: clamp(20px, 5vw, 26px);
}

.notfound p {
  margin-top: 14px;
  color: var(--text-2);
}

.notfound .hero-actions {
  justify-content: center;
  margin-top: 26px;
}

/* --------------------------------------------------------------------------
   12. 页脚与回到顶部
   -------------------------------------------------------------------------- */
.site-footer {
  margin-top: 44px;
  padding-block: 32px 40px;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  font-size: 14px;
  color: var(--text-2);
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-bottom: 18px;
}

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

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

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

.footer-note {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-3);
}

.to-top {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 25;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease, color 0.15s ease;
}

.to-top.is-visible {
  opacity: 1;
  visibility: visible;
}

.to-top:hover {
  color: var(--accent);
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   13. 宽屏适配
   -------------------------------------------------------------------------- */
@media (min-width: 760px) {
  body {
    font-size: 16.5px;
  }

  .header-inner {
    flex-wrap: nowrap;
    gap: 20px;
  }

  html.js .site-nav,
  html.js .site-nav.is-open {
    display: flex;
    width: auto;
    order: 0;
    margin-left: auto;
  }

  .site-nav ul {
    flex-direction: row;
    gap: 4px;
    padding: 0;
    border-top: 0;
  }

  .header-actions {
    margin-left: 0;
  }

  html.js .nav-toggle {
    display: none;
  }

  .hero {
    padding-block: 76px 56px;
  }

  .section {
    padding-block: 46px;
  }

  .article {
    padding-block: 56px 30px;
  }

  .article-nav {
    grid-template-columns: 1fr 1fr;
  }

  .to-top {
    right: 24px;
    bottom: 24px;
  }
}

/* --------------------------------------------------------------------------
   14. 动效降级与打印
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media print {
  .site-header,
  .site-footer,
  .to-top,
  .progress,
  .article-nav,
  .back-link {
    display: none;
  }

  body {
    background: #fff;
    color: #000;
  }
}
