/* ==========================================================================
   学习笔记站  -  公共样式
   ========================================================================== */

:root {
  --bg: #f6f7fb;
  --bg-soft: #ffffff;
  --bg-sunken: #eef0f7;
  --text: #1b1f2a;
  --text-soft: #5b6478;
  --text-faint: #8b93a7;
  --border: #e2e5ef;
  --primary: #4f6ef7;
  --primary-soft: rgba(79, 110, 247, 0.1);
  --accent: #12b8a6;
  --warning: #f0932b;
  --danger: #e4572e;
  --code-bg: #1e2231;
  --code-text: #e6e9f2;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, 0.12);
  --radius: 14px;
  --radius-sm: 9px;
  --maxw: 1240px;
  --header-h: 62px;
}

html[data-theme='dark'] {
  --bg: #12141c;
  --bg-soft: #191c26;
  --bg-sunken: #212533;
  --text: #e8eaf2;
  --text-soft: #a5adc0;
  --text-faint: #737c92;
  --border: #2b3040;
  --primary: #7c93ff;
  --primary-soft: rgba(124, 147, 255, 0.14);
  --accent: #2fd4bf;
  --code-bg: #0e1018;
  --code-text: #e6e9f2;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 24px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 15px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code,
pre,
kbd {
  font-family: 'JetBrains Mono', 'Cascadia Code', Consolas, 'Courier New', monospace;
}

/* ------------------------------- 顶栏 ---------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  background: color-mix(in srgb, var(--bg-soft) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  white-space: nowrap;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 15px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 4px 12px rgba(79, 110, 247, 0.35);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.site-nav::-webkit-scrollbar {
  display: none;
}

.site-nav a {
  position: relative;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-soft);
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}

.site-nav a:hover {
  background: var(--bg-sunken);
  color: var(--text);
  text-decoration: none;
}

.site-nav a.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
}

.icon-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
  transform: translateY(-1px);
}

/* ------------------------------- 布局 ---------------------------------- */

.layout {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px 22px 80px;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 34px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: calc(var(--header-h) + 28px);
  max-height: calc(100vh - var(--header-h) - 56px);
  overflow-y: auto;
  padding-right: 4px;
  font-size: 13.5px;
}

.sidebar::-webkit-scrollbar {
  width: 5px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 10px 10px;
}

.toc {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border);
}

.toc a {
  display: block;
  padding: 5px 10px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--text-soft);
  line-height: 1.5;
}

.toc a:hover {
  color: var(--text);
  text-decoration: none;
}

.toc a.active {
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}

.toc li.sub a {
  padding-left: 24px;
  font-size: 13px;
}

.sidebar-progress {
  margin: 20px 10px 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}

.sidebar-progress h4 {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text-soft);
  font-weight: 600;
}

.progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-sunken);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.35s ease;
}

.progress-text {
  margin-top: 7px;
  font-size: 12px;
  color: var(--text-faint);
}

/* ------------------------------- 内容 ---------------------------------- */

.content {
  min-width: 0;
}

.page-hero {
  padding: 30px 32px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  box-shadow: var(--shadow);
  margin-bottom: 26px;
  position: relative;
  overflow: hidden;
}

.page-hero::after {
  content: '';
  position: absolute;
  inset: 0 0 auto auto;
  width: 320px;
  height: 320px;
  transform: translate(35%, -55%);
  background: radial-gradient(circle, var(--primary-soft), transparent 68%);
  pointer-events: none;
}

.page-hero .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 4px 11px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.page-hero h1 {
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.page-hero p {
  margin: 0;
  max-width: 62ch;
  color: var(--text-soft);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-sunken);
  color: var(--text-soft);
  border: 1px solid var(--border);
}

section.topic {
  margin-bottom: 28px;
  padding: 26px 30px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  box-shadow: var(--shadow);
}

section.topic > h2 {
  margin: 0 0 6px;
  font-size: 21px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}

section.topic > h2 .num {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 7px;
  padding: 3px 8px;
  letter-spacing: 0.02em;
}

.topic-sub {
  color: var(--text-faint);
  font-size: 13.5px;
  margin: 0 0 18px;
}

h3 {
  font-size: 16px;
  margin: 24px 0 8px;
  letter-spacing: -0.01em;
}

h3::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 14px;
  border-radius: 2px;
  background: var(--accent);
  margin-right: 8px;
  vertical-align: -1px;
}

h4 {
  font-size: 14.5px;
  margin: 18px 0 6px;
  color: var(--text);
}

p {
  margin: 8px 0;
}

ul,
ol {
  margin: 8px 0;
  padding-left: 22px;
}

li {
  margin: 5px 0;
}

li::marker {
  color: var(--primary);
}

strong {
  font-weight: 650;
}

/* ------------------------------- 代码 ---------------------------------- */

pre {
  position: relative;
  margin: 14px 0;
  padding: 16px 18px;
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.7;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

pre code {
  color: inherit;
  font-size: inherit;
  background: none;
  padding: 0;
}

pre .lang-tag {
  position: absolute;
  top: 0;
  right: 0;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8f9bb8;
  background: rgba(255, 255, 255, 0.05);
  padding: 3px 10px;
  border-radius: 0 var(--radius-sm) 0 8px;
}

.copy-btn {
  position: absolute;
  top: 34px;
  right: 10px;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07);
  color: #b9c2d8;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
}

pre:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

p code,
li code,
td code,
th code,
h3 code,
h4 code {
  background: var(--bg-sunken);
  color: var(--primary);
  padding: 1.5px 6px;
  border-radius: 5px;
  font-size: 0.88em;
  border: 1px solid var(--border);
}

kbd {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 12px;
}

/* ------------------------------- 组件 ---------------------------------- */

.grid {
  display: grid;
  gap: 14px;
}

.grid.cols-2 {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.card {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.card h4 {
  margin: 0 0 6px;
  font-size: 14.5px;
}

.card p {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-soft);
}

.callout {
  display: flex;
  gap: 12px;
  margin: 14px 0;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  background: var(--bg);
  font-size: 14px;
}

.callout .ico {
  flex: none;
  font-size: 15px;
  line-height: 1.6;
}

.callout.tip {
  border-left-color: var(--accent);
}

.callout.warn {
  border-left-color: var(--warning);
}

.callout.danger {
  border-left-color: var(--danger);
}

.callout p {
  margin: 0;
}

.callout p + p {
  margin-top: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 13.5px;
  display: block;
  overflow-x: auto;
}

th,
td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--bg-sunken);
  font-weight: 650;
  white-space: nowrap;
}

tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--bg-sunken) 45%, transparent);
}

/* 可勾选的知识点 */
.checklist {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}

.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 10px;
  margin: 0 0 4px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.checklist li:hover {
  background: var(--bg-sunken);
}

.checklist input[type='checkbox'] {
  margin-top: 5px;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  flex: none;
}

.checklist li.done > span {
  color: var(--text-faint);
  text-decoration: line-through;
}

/* 首页 */
.hero {
  padding: 62px 30px 54px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: -40% 30% auto;
  height: 460px;
  background: radial-gradient(ellipse at center, var(--primary-soft), transparent 70%);
  pointer-events: none;
}

.hero h1 {
  position: relative;
  margin: 0 0 14px;
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.hero h1 .grad {
  background: linear-gradient(120deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero p {
  position: relative;
  margin: 0 auto;
  max-width: 60ch;
  color: var(--text-soft);
  font-size: 16px;
}

.hero-actions {
  position: relative;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn.primary {
  background: linear-gradient(135deg, var(--primary), #6f8bff);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 18px rgba(79, 110, 247, 0.32);
}

.btn.primary:hover {
  box-shadow: 0 10px 26px rgba(79, 110, 247, 0.42);
}

.section-heading {
  max-width: var(--maxw);
  margin: 0 auto 18px;
  padding: 0 22px;
}

.section-heading h2 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.section-heading p {
  margin: 0;
  color: var(--text-faint);
  font-size: 14px;
}

.track-grid {
  max-width: var(--maxw);
  margin: 0 auto 8px;
  padding: 0 22px;
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(272px, 1fr));
}

.track-card {
  display: block;
  padding: 22px 22px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  box-shadow: var(--shadow);
  color: var(--text);
  transition: transform 0.24s, box-shadow 0.24s, border-color 0.24s;
}

.track-card:hover {
  text-decoration: none;
  transform: translateY(-4px);
  border-color: transparent;
  box-shadow: var(--shadow-lg);
}

.track-icon {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 22px;
  margin-bottom: 14px;
  background: var(--primary-soft);
}

.track-card h3 {
  margin: 0 0 6px;
  font-size: 17px;
}

.track-card h3::before {
  display: none;
}

.track-card p {
  margin: 0 0 14px;
  font-size: 13.5px;
  color: var(--text-soft);
}

.track-card ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--text-soft);
}

.track-foot {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-faint);
}

.stats {
  max-width: var(--maxw);
  margin: 44px auto 0;
  padding: 0 22px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}

.stat {
  text-align: center;
  padding: 20px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

.stat b {
  display: block;
  font-size: 26px;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat span {
  font-size: 12.5px;
  color: var(--text-faint);
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 30px;
  flex-wrap: wrap;
}

.pager a {
  flex: 1 1 220px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text);
  transition: all 0.2s;
}

.pager a:hover {
  text-decoration: none;
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.pager small {
  display: block;
  color: var(--text-faint);
  font-size: 12px;
}

.pager .next {
  text-align: right;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 26px 22px;
  text-align: center;
  font-size: 13px;
  color: var(--text-faint);
}

.site-footer a {
  color: var(--text-soft);
}

/* 返回顶部 */
.to-top {
  position: fixed;
  right: 26px;
  bottom: 26px;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-soft);
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all 0.25s;
  box-shadow: var(--shadow);
  z-index: 40;
  font-size: 17px;
}

.to-top.show {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.to-top:hover {
  color: var(--primary);
  border-color: var(--primary);
}

/* 响应式 */
@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .sidebar {
    position: static;
    max-height: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-soft);
    padding: 16px;
  }

  .toc {
    columns: 2;
    column-gap: 20px;
  }

  .toc a {
    break-inside: avoid;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 14.5px;
  }

  .site-header {
    padding: 0 14px;
    gap: 10px;
  }

  .brand span.name {
    display: none;
  }

  .layout {
    padding: 18px 14px 60px;
  }

  section.topic,
  .page-hero {
    padding: 20px 18px;
  }

  .page-hero h1 {
    font-size: 24px;
  }

  .toc {
    columns: 1;
  }

  .hero {
    padding: 44px 18px 38px;
  }
}

@media print {
  .site-header,
  .sidebar,
  .to-top,
  .pager,
  .copy-btn {
    display: none !important;
  }

  .layout {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
