/* ========================================
   全局样式 - 优化版
   ======================================== */

/* ---------- 颜色系统 ---------- */
:root {
  /* 主色调 - 金色系 */
  --color-primary: #eab308;
  --color-primary-light: #f59e0b;
  --color-primary-dark: #d4a017;
  --color-primary-lighter: rgba(234, 179, 8, 0.15);
  --color-primary-lightest: rgba(234, 179, 8, 0.08);

  /* 文字颜色 */
  --color-text: #4a4035;
  --color-text-heading: #3d3226;
  --color-text-secondary: #5a4a38;
  --color-text-muted: #8b7355;
  --color-text-code: #f8f8f2;

  /* 背景色 */
  --color-bg-card: rgba(255, 252, 245, 0.95);
  --color-bg-code: rgba(255, 252, 245, 0.95);
  --color-bg-hover: rgba(234, 179, 8, 0.06);

  /* 边框 */
  --color-border: rgba(234, 179, 8, 0.15);
  --color-border-light: rgba(234, 179, 8, 0.1);

  /* 阴影 */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(234, 179, 8, 0.08);
  --shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.12);

  /* 间距 */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 20px;
  --spacing-xl: 24px;
  --spacing-xxl: 32px;

  /* 圆角 */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --radius-2xl: 16px;
}

/* ---------- 布局宽度 ---------- */
.layout {
  max-width: 1400px !important;
}

@media screen and (min-width: 2000px) {
  .layout {
    max-width: 70% !important;
  }
}

.layout.hide-aside {
  max-width: 1200px !important;
}

@media screen and (min-width: 2000px) {
  .layout.hide-aside {
    max-width: 1500px !important;
  }
}

/* ---------- 内容区 ---------- */
.layout > div:first-child:not(.nc) {
  padding: 50px 44px;
}

@media screen and (max-width: 768px) {
  .layout > div:first-child:not(.nc) {
    padding: 32px 18px;
  }
}

/* ---------- 过渡效果 ---------- */
a,
button,
.card-widget,
.recent-post-item,
#card-info-btn,
.layout > div:first-child {
  transition: all 0.3s ease;
}

/* ---------- 卡片悬停 ---------- */
.card-widget:hover,
.recent-post-item:hover {
  transform: translateY(-4px);
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.08),
    0 4px 12px rgba(0, 0, 0, 0.04) !important;
}

/* ---------- 内容进入动画 ---------- */
#content-inner,
#article-container,
.post-body {
  animation: contentFadeIn 0.7s ease-out;
}

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

/* ---------- 滚动条 ---------- */
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  border-radius: var(--radius-sm);
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-primary-dark) 100%);
}

*::-webkit-scrollbar-track {
  background: var(--color-primary-lightest);
  border-radius: var(--radius-sm);
}

/* ---------- 导航菜单 ---------- */
#nav .menus_items .menus_item {
  padding: 0 6px;
}

#nav .menus_items .menus_item .site-page {
  padding: 10px 16px;
  font-size: 0.95em;
  letter-spacing: 0;
  border-radius: var(--radius-lg);
  transition: all 0.3s ease;
}

#nav .menus_items .menus_item .site-page:hover {
  background: var(--color-primary-lightest);
  color: var(--color-primary);
}

/* ---------- 按钮 ---------- */
button,
.btn,
#card-info-btn,
.post-button {
  border-radius: var(--radius-md) !important;
  font-weight: 500 !important;
  box-shadow: 0 4px 12px var(--color-primary-lighter) !important;
  transition: all 0.3s ease;
}

button:hover,
.btn:hover,
#card-info-btn:hover,
.post-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(234, 179, 8, 0.35) !important;
}

/* ---------- 输入框 ---------- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea {
  border-radius: 12px !important;
  border: 2px solid var(--color-border) !important;
  transition: border-color 0.3s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
textarea:focus {
  border-color: var(--color-primary) !important;
  box-shadow: 0 0 0 4px var(--color-primary-lightest) !important;
  outline: none !important;
}

/* ---------- 徽章标签 ---------- */
.badge,
.tag,
.label {
  border-radius: 12px !important;
  font-weight: 500 !important;
  padding: 4px 12px !important;
  background: var(--color-primary-lighter) !important;
  color: var(--color-primary-dark) !important;
  border: 1px solid var(--color-border) !important;
  transition: background 0.3s ease;
}

.badge:hover,
.tag:hover,
.label:hover {
  background: rgba(234, 179, 8, 0.25) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px var(--color-primary-lighter) !important;
}

/* ---------- 侧边栏作者标签 ---------- */
.author-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.author-tag {
  display: inline-block;
  padding: 5px 14px;
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.12) 0%, rgba(245, 158, 11, 0.08) 100%);
  border: 1px solid rgba(234, 179, 8, 0.25);
  border-radius: 18px;
  font-size: 0.85rem;
  color: #b8860b;
  font-weight: 600;
  transition: all 0.3s ease;
  cursor: default;
}

.author-tag:hover {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.2) 0%, rgba(245, 158, 11, 0.15) 100%);
  border-color: rgba(234, 179, 8, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(234, 179, 8, 0.2);
}

/* ---------- 链接 ---------- */
a {
  color: var(--color-primary-dark);
  text-decoration: none;
  border-bottom: 1px dashed rgba(184, 134, 11, 0.35);
  transition: color 0.2s;
}

a:hover {
  color: var(--color-primary-dark);
  border-bottom-style: solid;
  border-bottom-color: var(--color-primary-dark);
}

/* ---------- 引用块 ---------- */
blockquote {
  margin: 18px 0;
  padding: 16px 22px;
  background: var(--color-primary-lightest);
  border-left: 4px solid var(--color-primary);
  border-radius: 0 12px 12px 0;
  color: var(--color-text-secondary);
  font-style: italic;
  box-shadow: var(--shadow-sm);
}

blockquote:hover {
  background: rgba(234, 179, 8, 0.12);
  box-shadow: var(--shadow-md);
}

/* ---------- 代码块（Typora 风格）---------- */
pre,
code,
.highlight {
  border-radius: 6px !important;
  font-family: 'Courier New', 'Fira Code', 'Monaco', monospace !important;
}

pre {
  background: #f6f8fa !important;
  border: 1px solid #e1e4e8 !important;
  padding: 16px !important;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 20px auto;
  width: 100%;
  max-width: 750px;
  min-height: 120px;
}

code {
  background: rgba(234, 179, 8, 0.08) !important;
  color: #b8860b !important;
  padding: 2px 6px !important;
  border-radius: 3px !important;
  font-size: 0.9em !important;
  border: none !important;
}

pre code {
  background: transparent !important;
  color: #24292e !important;
  padding: 0 !important;
  border-radius: 0 !important;
  border: none !important;
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ---------- 表格 ---------- */
table {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border-collapse: separate;
  border-spacing: 0;
  margin: 18px 0;
}

table thead {
  background: var(--color-primary-lighter);
}

table th {
  padding: 20px 20px;
  font-weight: 600;
  color: var(--color-text-heading);
  border-bottom: 2px solid var(--color-border);
  text-align: left;
}

table td {
  padding: 20px 20px;
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text-secondary);
}

table tbody tr {
  transition: background 0.2s;
}

table tbody tr:hover {
  background: var(--color-bg-hover);
}

/* ---------- 图片 ---------- */
img {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  transition: box-shadow 0.3s;
}

img:hover {
  box-shadow: var(--shadow-hover);
}

/* ---------- 列表 ---------- */
ul,
ol {
  padding-left: 22px;
  margin: 14px 0;
}

li {
  margin: 6px 0;
  line-height: 1.8;
}

ul li::marker {
  color: var(--color-primary);
}

ol li::marker {
  color: var(--color-primary);
  font-weight: 600;
}

/* ---------- 分隔线 ---------- */
hr {
  height: 2px;
  background: linear-gradient(90deg,
      transparent,
      rgba(180, 160, 130, 0.4) 20%,
      rgba(234, 179, 8, 0.6) 50%,
      rgba(180, 160, 130, 0.4) 80%,
      transparent);
  border: none;
  margin: 30px 0;
  border-radius: 1px;
}

/* ---------- 标题 ---------- */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 700;
  color: var(--color-text-heading);
  line-height: 1.4;
  margin: 24px 0 14px;
}

h1 {
  font-size: 2.2rem;
  padding-bottom: 10px;
  border-bottom: 3px solid var(--color-border);
}

h2 {
  font-size: 1.8rem;
  padding-left: 16px;
  border-left: 4px solid var(--color-primary);
}

h3 {
  font-size: 1.5rem;
  padding-left: 12px;
  border-left: 3px solid rgba(234, 179, 8, 0.6);
}

h4 {
  font-size: 1.25rem;
  padding-left: 10px;
  border-left: 2px solid rgba(234, 179, 8, 0.4);
}

/* ---------- 文本 ---------- */
p {
  line-height: 1.9;
  margin: 14px 0;
  color: var(--color-text);
}

strong,
b {
  color: var(--color-text-heading);
  font-weight: 600;
}

em,
i {
  color: var(--color-text-muted);
}

/* ---------- 选中文本 ---------- */
::selection {
  background: rgba(234, 179, 8, 0.3);
  color: var(--color-text-heading);
}

::-moz-selection {
  background: rgba(234, 179, 8, 0.3);
  color: var(--color-text-heading);
}

/* ---------- 焦点可见性 ---------- */
*:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ---------- 暗色模式 - 使用 CSS 变量 ---------- */
[data-theme='dark'] {
  color: #c8bfa8;

  /* 暗色模式颜色覆盖 */
  --color-text: #c8bfa8;
  --color-text-heading: #f5f0e1;
  --color-text-secondary: #d4c9b1;
  --color-text-muted: #a89880;
  --color-text-code: #f5f5dc;
  --color-bg-card: rgba(40, 36, 30, 0.95);
  --color-bg-code: rgba(38, 34, 28, 0.98);
  --color-bg-hover: rgba(234, 179, 8, 0.1);
  --color-border: rgba(234, 179, 8, 0.25);
  --color-border-light: rgba(234, 179, 8, 0.18);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 24px rgba(234, 179, 8, 0.12);
  --shadow-hover: 0 12px 32px rgba(0, 0, 0, 0.45);
}

/* ---------- 暗色模式特定样式 ---------- */
[data-theme='dark'] a {
  color: #eab308;
  border-bottom-color: rgba(234, 179, 8, 0.4);
}

[data-theme='dark'] a:hover {
  color: #f59e0b;
  border-bottom-color: #f59e0b;
}

[data-theme='dark'] blockquote {
  background: rgba(234, 179, 8, 0.12);
  color: #d4c9b1;
  border-left-color: rgba(234, 179, 8, 0.5);
}

[data-theme='dark'] code {
  background: rgba(234, 179, 8, 0.15) !important;
  color: #fbbf24 !important;
}

[data-theme='dark'] pre {
  background: #1e1e1e !important;
  border-color: #2d2d2d !important;
}

[data-theme='dark'] table {
  background: rgba(45, 40, 35, 0.6);
}

[data-theme='dark'] table thead {
  background: rgba(234, 179, 8, 0.25);
}

[data-theme='dark'] table th {
  color: #f5f0e1;
  border-bottom-color: rgba(234, 179, 8, 0.5);
}

[data-theme='dark'] table td {
  color: #d4c9b1;
  border-bottom-color: rgba(234, 179, 8, 0.25);
}

[data-theme='dark'] table tbody tr:hover {
  background: rgba(234, 179, 8, 0.12);
}

[data-theme='dark'] strong,
[data-theme='dark'] b {
  color: #f5f0e1;
  background: rgba(234, 179, 8, 0.15);
}

[data-theme='dark'] ::selection {
  background: rgba(234, 179, 8, 0.5);
  color: #f5f0e1;
}

[data-theme='dark'] img {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

[data-theme='dark'] img:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* 暗色模式侧边栏作者标签 */
[data-theme='dark'] .author-tag {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.15) 0%, rgba(245, 158, 11, 0.1) 100%);
  border-color: rgba(234, 179, 8, 0.35);
  color: #fbbf24;
}

[data-theme='dark'] .author-tag:hover {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.25) 0%, rgba(245, 158, 11, 0.2) 100%);
  border-color: rgba(234, 179, 8, 0.5);
}

/* ---------- 响应式设计 ---------- */
@media (max-width: 900px) {
  .layout {
    max-width: 100% !important;
  }

  .layout > div:first-child:not(.nc) {
    padding: 36px 28px;
  }
}

@media (max-width: 768px) {
  .layout > div:first-child:not(.nc) {
    padding: 28px 20px;
  }

  h1 {
    font-size: 1.8rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  h3 {
    font-size: 1.3rem;
  }

  table {
    font-size: 0.9rem;
  }

  table th,
  table td {
    padding: 16px 16px;
  }

  .highlight,
  pre {
    border-radius: 12px;
  }

  /* 移动端暗色模式优化 */
  [data-theme='dark'] blockquote {
    background: rgba(234, 179, 8, 0.08);
  }

  [data-theme='dark'] code {
    background: rgba(234, 179, 8, 0.12);
  }

  [data-theme='dark'] table {
    background: rgba(45, 40, 35, 0.6);
  }

  [data-theme='dark'] table thead {
    background: rgba(234, 179, 8, 0.18);
  }

  [data-theme='dark'] table th {
    color: #e0d5c5;
    border-bottom-color: rgba(234, 179, 8, 0.4);
  }

  [data-theme='dark'] table td {
    color: #b5a890;
    border-bottom-color: rgba(234, 179, 8, 0.2);
  }

  [data-theme='dark'] table th,
  [data-theme='dark'] table td {
    padding: 16px 16px;
  }

  [data-theme='dark'] strong,
  [data-theme='dark'] b {
    background: rgba(234, 179, 8, 0.08);
  }

  [data-theme='dark'] .toc {
    background: rgba(234, 179, 8, 0.08);
  }

  [data-theme='dark'] pre {
    background: #1e1e1e !important;
    padding: 16px !important;
  }

  [data-theme='dark'] pre code {
    color: #f5f5dc !important;
    font-size: 0.85rem;
    line-height: 1.6;
  }
}

@media (max-width: 480px) {
  .layout > div:first-child:not(.nc) {
    padding: 20px 16px;
  }

  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.3rem;
  }

  h3 {
    font-size: 1.15rem;
  }

  table {
    font-size: 0.85rem;
  }

  table th,
  table td {
    padding: 14px 12px;
  }

  .highlight,
  pre {
    border-radius: 10px;
  }

  /* 小屏幕暗色模式优化 */
  [data-theme='dark'] blockquote {
    background: rgba(234, 179, 8, 0.1);
    padding: 14px 18px;
  }

  [data-theme='dark'] :not(pre) > code {
    background: rgba(234, 179, 8, 0.15);
    padding: 2px 5px;
    font-size: 0.85em;
  }

  [data-theme='dark'] table th,
  [data-theme='dark'] table td {
    padding: 14px 12px;
  }

  [data-theme='dark'] strong,
  [data-theme='dark'] b {
    background: rgba(234, 179, 8, 0.12);
    padding: 1px 4px;
  }

  [data-theme='dark'] pre {
    background: #1e1e1e !important;
    padding: 14px !important;
  }

  [data-theme='dark'] pre code {
    font-size: 0.8rem;
    line-height: 1.5;
  }
}
