/* ============================================================
   赤墨 — hker2024.work 全局样式
   设计原则：单色出声 / 留白即设计 / 零装饰动效
   所有组件必须引用 CSS 变量，禁止写裸 hex
   ============================================================ */

/* —— §4 设计 Token —— */

:root {
  /* 色彩：赤墨 · 亮色 */
  --bg:            #fafaf8;
  --surface:       #ffffff;
  --text:          #1c1917;
  --text-muted:    #6b6560;
  --border:        #e8e5e1;
  --accent:        #b91c1c;
  --accent-weak:   #fef5f5;
  --accent-press:  #991b1b;

  /* 字号体系 */
  --fs-xs:   0.8125rem;
  --fs-sm:   0.9375rem;
  --fs-base: 1rem;
  --fs-lg:   1.25rem;
  --fs-xl:   1.75rem;
  --fs-2xl:  2.5rem;
  --fs-hero: 3.5rem;

  /* 间距体系（8px 节奏） */
  --sp-1:  0.5rem;
  --sp-2:  1rem;
  --sp-3:  1.5rem;
  --sp-4:  2rem;
  --sp-6:  3rem;
  --sp-8:  4rem;
  --sp-12: 6rem;

  /* 其它 */
  --radius:    12px;
  --radius-sm:  8px;
  --maxw:      720px;
  --maxw-wide: 1100px;
  --ease:      cubic-bezier(0.22, 1, 0.36, 1);
  --dur:       200ms;
  --focus-ring: 0 0 0 3px var(--accent-weak), 0 0 0 4px var(--accent);
}

[data-theme="dark"] {
  --bg:            #0c0a09;
  --surface:       #1a1816;
  --text:          #e7e5e4;
  --text-muted:    #a8a29e;
  --border:        #292524;
  --accent:        #f87171;
  --accent-weak:   #1f1313;
  --accent-press:  #fca5a5;
}

/* —— §6.4 主题切换过渡 —— */
body {
  transition: color var(--dur) var(--ease),
              background-color var(--dur) var(--ease);
}

/* —— §6.4 动效守卫 —— */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ============================================================
   Reset & Base
   ============================================================ */

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

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

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB",
               -apple-system, system-ui, sans-serif;
  font-size: var(--fs-base);
  line-height: 1.75;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: "Noto Serif SC", "Songti SC", "SimSun", "STSong", serif;
  line-height: 1.3;
  color: var(--text);
}

h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); margin-top: var(--sp-8); margin-bottom: var(--sp-3); }
h3 { font-size: var(--fs-lg); margin-top: var(--sp-4); margin-bottom: var(--sp-2); }

p {
  margin-bottom: var(--sp-3);
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: background-color var(--dur) var(--ease),
              text-decoration-thickness var(--dur) var(--ease);
  border-radius: 2px;
}

a:hover {
  background-color: var(--accent-weak);
  text-decoration-thickness: 2px;
}

a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

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

ul, ol {
  padding-left: var(--sp-3);
  margin-bottom: var(--sp-3);
}

li {
  margin-bottom: var(--sp-1);
}

code {
  font-family: "JetBrains Mono", "Cascadia Code", ui-monospace, monospace;
  font-size: 0.9em;
  background: var(--surface);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  border: 1px solid var(--border);
}

pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-3);
  overflow-x: auto;
  margin-bottom: var(--sp-3);
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: var(--fs-sm);
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--sp-8) 0;
}

::selection {
  background: var(--accent-weak);
  color: var(--text);
}

/* —— Skip Link —— */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--sp-2);
  background: var(--accent);
  color: #ffffff;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-sm);
  z-index: 1000;
  font-size: var(--fs-sm);
  text-decoration: none;
}

.skip-link:focus {
  top: var(--sp-2);
}

/* ============================================================
   Layout Utilities
   ============================================================ */

.container {
  width: 100%;
  max-width: var(--maxw);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--sp-3);
  padding-right: var(--sp-3);
}

.container-wide {
  max-width: var(--maxw-wide);
}

.page {
  padding-top: var(--sp-8);
  padding-bottom: var(--sp-12);
  min-height: 80dvh;
}

.page-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 100dvh;
  padding-top: var(--sp-6);
  padding-bottom: var(--sp-8);
}

/* ============================================================
   §5.1 链接
   ============================================================ */

/* 基础 a 样式已在 Reset 中定义 */
/* 导航链接（无下划线，需要时加） */
.nav-link {
  color: var(--text);
  text-decoration: none;
  font-size: var(--fs-sm);
  font-weight: 500;
  padding: var(--sp-1) 0;
  transition: color var(--dur) var(--ease);
}

.nav-link:hover {
  color: var(--accent);
  background-color: transparent;
  text-decoration: none;
}

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

/* ============================================================
   §5.2 按钮
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  min-height: 44px;
  min-width: 44px;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: var(--fs-base);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  border: 1.5px solid transparent;
  transition: transform var(--dur) var(--ease),
              background-color var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
  user-select: none;
}

.btn:hover {
  transform: translateY(-1px);
}

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

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* 主 CTA */
.btn-primary {
  background-color: var(--accent);
  color: #ffffff;
}

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

.btn-primary:active {
  background-color: var(--accent-press);
}

/* 次 CTA（描边） */
.btn-secondary {
  background-color: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  background-color: var(--accent-weak);
}

/* 按钮组 */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
}

/* ============================================================
   §5.3 作品卡片
   ============================================================ */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-3);
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
  color: inherit;
}

.card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
}

.card:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.card:hover .card-link-text {
  background-color: var(--accent-weak);
  text-decoration-thickness: 2px;
}

.card-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  margin-bottom: var(--sp-2);
  color: var(--accent);
}

.card-title {
  font-size: var(--fs-lg);
  font-weight: 600;
  margin-bottom: var(--sp-1);
}

.card-desc {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-2);
  flex: 1;
}

.card-link-text {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: background-color var(--dur) var(--ease);
  width: fit-content;
}

/* 空位卡片 */
.card-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  background: transparent;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: var(--sp-3);
  cursor: default;
  pointer-events: none;
}

.card-placeholder:hover {
  transform: none;
  border-color: var(--border);
}

.card-placeholder-text {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  text-align: center;
}

/* ============================================================
   Top Nav
   ============================================================ */

.site-nav {
  padding: var(--sp-3) 0;
}

.site-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-nav-home {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: var(--fs-base);
}

.site-nav-home:hover {
  color: var(--accent);
  background-color: transparent;
}

.site-nav-links {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  list-style: none;
  padding: 0;
  margin: 0;
}

.site-nav-links li {
  margin: 0;
}

/* ============================================================
   Bottom Nav (首页轻导航)
   ============================================================ */

.footer-nav {
  margin-top: auto;
  padding-top: var(--sp-6);
}

.footer-nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.footer-nav-links li {
  display: flex;
  align-items: center;
  margin: 0;
}

.footer-nav-links .sep {
  margin: 0 var(--sp-2);
  color: var(--border);
  user-select: none;
}

/* ============================================================
   Theme Toggle Button
   ============================================================ */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  color: var(--text);
  transition: background-color var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              transform var(--dur) var(--ease);
  flex-shrink: 0;
}

.theme-toggle:hover {
  background-color: var(--accent-weak);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.theme-toggle:active {
  transform: translateY(0);
}

.theme-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  pointer-events: none;
}

/* 亮色模式：显示月亮（切换到暗色） */
.theme-toggle .icon-moon { display: inline; }
.theme-toggle .icon-sun  { display: none; }

/* 暗色模式：显示太阳（切换到亮色） */
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: inline; }

/* ============================================================
   Logo
   ============================================================ */

.logo {
  width: 120px;
  height: 120px;
  border-radius: var(--radius);
  object-fit: contain;
  margin-bottom: var(--sp-4);
  user-select: none;
}

/* ============================================================
   Hero 区块（首页）
   ============================================================ */

.hero-name {
  font-family: "Noto Serif SC", "Songti SC", "SimSun", "STSong", serif;
  font-size: var(--fs-hero);
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: var(--sp-3);
  line-height: 1.15;
}

.hero-tagline {
  font-family: "Noto Serif SC", "Songti SC", "SimSun", serif;
  font-size: var(--fs-lg);
  color: var(--text);
  font-style: italic;
  max-width: 28em;
  margin-bottom: var(--sp-4);
  line-height: 1.6;
}

.hero-divider {
  width: 60px;
  height: 1px;
  background: var(--border);
  margin: var(--sp-6) auto;
}

/* ============================================================
   页面标题（子页面用）
   ============================================================ */

.page-title {
  font-family: "Noto Serif SC", "Songti SC", "SimSun", "STSong", serif;
  font-size: var(--fs-2xl);
  font-weight: 600;
  margin-bottom: var(--sp-2);
}

.page-subtitle {
  color: var(--text-muted);
  font-size: var(--fs-lg);
  margin-bottom: var(--sp-6);
  max-width: 36em;
}

/* ============================================================
   随笔列表
   ============================================================ */

.note-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.note-item {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--border);
}

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

.note-date {
  font-family: "JetBrains Mono", "Cascadia Code", ui-monospace, monospace;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 6.5em;
}

.note-title {
  font-size: var(--fs-base);
  font-weight: 500;
}

/* ============================================================
   文章模板样式
   ============================================================ */

.article {
  max-width: var(--maxw);
  margin: 0 auto;
}

.article-header {
  margin-bottom: var(--sp-6);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
}

.article-date {
  font-family: "JetBrains Mono", "Cascadia Code", ui-monospace, monospace;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
}

.article-title {
  font-family: "Noto Serif SC", "Songti SC", "SimSun", "STSong", serif;
  font-size: var(--fs-2xl);
  font-weight: 600;
  margin: 0 0 var(--sp-1) 0;
}

.article-body {
  line-height: 1.85;
}

.article-body p {
  margin-bottom: var(--sp-3);
}

.article-back {
  display: inline-block;
  margin-top: var(--sp-8);
  font-size: var(--fs-sm);
}

/* ============================================================
   关于页 - 区块
   ============================================================ */

.about-section {
  margin-bottom: var(--sp-6);
}

.about-section h2 {
  font-family: "Noto Serif SC", "Songti SC", "SimSun", "STSong", serif;
  font-size: var(--fs-xl);
  font-weight: 600;
  margin-bottom: var(--sp-2);
  color: var(--accent);
}

.about-section p,
.about-section li {
  color: var(--text);
}

/* 能力地图 */
.skill-map {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--sp-3);
  list-style: none;
  padding: 0;
}

.skill-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-3);
}

.skill-group h3 {
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, system-ui, sans-serif;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 var(--sp-1) 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.skill-group ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.skill-group li {
  font-size: var(--fs-sm);
  color: var(--text);
  margin-bottom: 0.25rem;
}

/* 网站日志 */
.changelog {
  list-style: none;
  padding: 0;
}

.changelog li {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  padding: var(--sp-1) 0;
  font-size: var(--fs-sm);
  border-bottom: 1px solid var(--border);
}

.changelog-date {
  font-family: "JetBrains Mono", "Cascadia Code", ui-monospace, monospace;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ============================================================
   联系页
   ============================================================ */

.contact-list {
  list-style: none;
  padding: 0;
  margin-top: var(--sp-2);
}

.contact-list li {
  margin-bottom: var(--sp-2);
}

.contact-footer-note {
  margin-top: var(--sp-6);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-style: italic;
}

/* ============================================================
   404 页
   ============================================================ */

.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 100dvh;
  padding: var(--sp-3);
}

.error-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  margin-bottom: var(--sp-4);
}

.error-title {
  font-size: var(--fs-2xl);
  font-weight: 600;
  margin-bottom: var(--sp-2);
}

.error-desc {
  color: var(--text-muted);
  margin-bottom: var(--sp-4);
}

/* ============================================================
   工具图标（内联 SVG）
   ============================================================ */

.icon {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 32px; height: 32px; }

/* ============================================================
   页脚
   ============================================================ */

.site-footer {
  text-align: center;
  padding: var(--sp-6) 0;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.site-footer a {
  font-size: var(--fs-xs);
}

/* ============================================================
   响应式断点
   ============================================================ */

/* Mobile < 768px — 默认单列，已写 */

/* Tablet ≥ 768px */
@media (min-width: 768px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .site-nav {
    padding: var(--sp-4) 0;
  }
}

/* Desktop ≥ 1024px */
@media (min-width: 1024px) {
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .hero-name {
    font-size: var(--fs-hero);
  }

  .page {
    padding-top: var(--sp-12);
    padding-bottom: var(--sp-12);
  }
}

/* Wide ≥ 1440px */
@media (min-width: 1440px) {
  .container-wide {
    max-width: 1200px;
  }
}

/* print-friendly */
@media print {
  body {
    background: #fff;
    color: #000;
  }

  .site-nav,
  .footer-nav,
  .theme-toggle,
  .btn {
    display: none;
  }

  a {
    color: #000;
    text-decoration: underline;
  }
}
