/**
 * share_css_typora02 — Trilium 分享页 · Typora 默认浅色风格
 * ─────────────────────────────────────────────────────────
 * 版本: 2026.05.16
 * 设计: Typora 官方默认配色 + Trilium 分享页完整布局机制
 *
 * 配色 = Typora 官方 (纯白 · #333 · 系统字体 · 干净)
 * 布局 = GPU 合成 transform 侧栏，零重排
 * 特色 = 侧栏当前笔记高亮标记 ◀ · 子笔记卡片
 */

/* ══════════════════════════════════════════════════════════════
   1. 设计变量
   ══════════════════════════════════════════════════════════════ */
:root {
  --bg:             #ffffff;
  --bg-card:        #f7f7f7;
  --bg-elevated:    #f0f0f0;
  --bg-hover:       #eaeaea;
  --bg-code:        #f4f4f4;

  --text-main:      #333333;
  --text-secondary: #555555;
  --text-muted:     #888888;
  --text-code:      #c7254e;

  --link:           #2f6f9f;
  --link-hover:     #1a4f7a;
  --primary:        #2f6f9f;

  --border:         #d4d4d4;
  --border-light:   #e0e0e0;

  --accent-soft:    rgba(47, 111, 159, 0.05);
  --shadow-sm:      0 1px 4px rgba(0,0,0,0.05);
  --shadow-md:      0 4px 16px rgba(0,0,0,0.06);

  --font:           -apple-system, "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono:      "SF Mono", "Fira Code", "Menlo", "Consolas", monospace;
  --radius:         3px;

  /* 侧栏尺寸 */
  --menu-w:         280px;
  --menu-collapsed: 18px;
}

/* ══════════════════════════════════════════════════════════════
   2. 全局重置
   ══════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box !important; }

html { scroll-behavior: smooth; }

body.share-body {
  margin: 0 !important;
  padding: 0 !important;
  background: var(--bg) !important;
  color: var(--text-main);
  font-family: var(--font);
  font-size: clamp(15px, 0.9vw + 12px, 17px);
  line-height: 1.65;
  overflow-x: hidden !important;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: #b4d5fe;
  color: #000;
}

/* ══════════════════════════════════════════════════════════════
   3. 核心布局 — GPU transform 侧栏 (零重排)
   ══════════════════════════════════════════════════════════════ */
#layout {
  display: flex !important;
  flex-direction: row !important;
  width: 100% !important;
  max-width: 100% !important;
  min-height: 100vh !important;
}

/* ── 左侧目录栏：固定宽度 280px，默认 translateX 隐藏 ── */
#menu {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: var(--menu-w) !important;
  min-width: var(--menu-w) !important;
  height: 100vh !important;
  z-index: 9999 !important;
  background: var(--bg-card) !important;
  border-right: 2px solid var(--border) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;

  padding: 28px 20px !important;

  /* GPU 合成：只动 transform + opacity */
  transform: translateX(calc(var(--menu-collapsed) - var(--menu-w))) !important;
  opacity: 0.55;
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.18s ease !important;
  will-change: transform, opacity;
}

#menu:hover {
  transform: translateX(0) !important;
  opacity: 1 !important;
  box-shadow: 5px 0 20px rgba(0,0,0,0.06) !important;
}

/* ── 窄条图标 ── */
#menu::before {
  content: '☰';
  position: absolute;
  top: 50%;
  right: 2px;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.5;
  transition: opacity 0.15s ease;
  pointer-events: none;
  z-index: 1;
}
#menu:hover::before { opacity: 0 !important; }

#menu p { margin: 0 0 4px 0; font-size: 0.85em; }
#menu > p {
  font-weight: 700;
  font-size: 1em;
  color: var(--text-main);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 10px;
}
#menu a {
  color: var(--text-secondary);
  text-decoration: none;
  display: block;
  padding: 3px 0;
  transition: color 0.15s ease;
}
#menu a:hover { color: var(--link); }
#menu ul { padding-left: 18px; list-style: none; }
#menu ul li { margin: 0; }

/* ── 当前笔记高亮标记 ◀ ── */
#menu strong {
  font-weight: 600;
  color: var(--text-main);
  display: block;
  padding: 5px 10px;
  margin: 3px -10px;
  background: #e8eef5;
  border-radius: var(--radius);
  position: relative;
}
#menu strong::before {
  content: '◀ ';
  color: var(--link);
  font-size: 0.85em;
}

/* ── 正文区 ── */
#main {
  flex: 1 !important;
  margin-left: 18px !important;
  padding: clamp(28px, 4vw, 60px) clamp(20px, 4vw, 60px) !important;
  background: var(--bg) !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

/* ── Toggle 按钮 ── */
#toggleMenuButton {
  display: none;
  position: fixed;
  top: 8px;
  left: 8px;
  width: 38px;
  height: 38px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 1.6rem;
  z-index: 100;
  cursor: pointer;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  align-items: center;
  justify-content: center;
}

/* ══════════════════════════════════════════════════════════════
   4. 导航信息
   ══════════════════════════════════════════════════════════════ */
#parentLink {
  font-size: 0.88em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
#parentLink a {
  color: var(--link);
  text-decoration: none;
}
#parentLink a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* ══════════════════════════════════════════════════════════════
   5. 标题 — Typora 干净风格
   ══════════════════════════════════════════════════════════════ */
#title {
  margin: 0 0 24px 0 !important;
  font-size: clamp(1.8em, 3.5vw, 2.4em) !important;
  font-weight: 700 !important;
  line-height: 1.3;
  color: var(--text-main) !important;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

#content h2, .ck-content h2 {
  font-size: clamp(1.35em, 2.5vw, 1.6em);
  font-weight: 700;
  margin: 1.8em 0 0.6em 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
}

#content h3, .ck-content h3 {
  font-size: clamp(1.1em, 1.8vw, 1.3em);
  font-weight: 700;
  margin: 1.4em 0 0.4em 0;
  color: var(--text-main);
}

#content h4, .ck-content h4 {
  font-size: 1.05em;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 1.2em 0 0.3em 0;
}

#content h5, .ck-content h5 {
  font-size: 0.92em;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 1em 0 0.2em 0;
}
#content h6, .ck-content h6 {
  font-size: 0.9em;
  font-weight: 400;
  color: var(--text-muted);
  font-style: italic;
  margin: 0.8em 0 0.2em 0;
}

/* ══════════════════════════════════════════════════════════════
   6. 正文排版
   ══════════════════════════════════════════════════════════════ */
#content p, .ck-content p { margin: 0.6em 0; }
#content ul, .ck-content ul,
#content ol, .ck-content ol { padding-left: 1.8em; }
#content li, .ck-content li { margin: 0.25em 0; }

blockquote, .ck-content blockquote {
  margin: 1em 0;
  padding: 8px 18px;
  border-left: 4px solid #ddd;
  background: none;
  color: #666;
  font-style: italic;
}
blockquote p { margin: 0 !important; }

a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* ══════════════════════════════════════════════════════════════
   7. 代码
   ══════════════════════════════════════════════════════════════ */
code:not(pre code) {
  background: var(--bg-code) !important;
  color: var(--text-code) !important;
  padding: 2px 6px !important;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.88em;
}

pre, .ck-content pre {
  background: var(--bg-code) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius);
  padding: 16px !important;
  margin: 1em 0 !important;
  overflow-x: auto !important;
  font-family: var(--font-mono);
  font-size: 0.88em;
  line-height: 1.55;
  color: var(--text-main);
}

/* ══════════════════════════════════════════════════════════════
   8. 表格
   ══════════════════════════════════════════════════════════════ */
table {
  width: 100% !important;
  margin: 1.2em 0 !important;
  border-collapse: collapse;
  font-size: 0.95em;
}
table th {
  background: #f2f2f2;
  font-weight: 600;
  padding: 10px 14px;
  text-align: left;
  border: 1px solid var(--border);
  font-size: 0.9em;
}
table td {
  padding: 8px 14px;
  border: 1px solid var(--border-light);
  color: var(--text-main);
}
table tr:nth-child(even) td { background: #fafafa; }
table tr:hover td { background: #f0f0f0; }

/* ══════════════════════════════════════════════════════════════
   9. 图片
   ══════════════════════════════════════════════════════════════ */
img {
  max-width: 100% !important;
  height: auto !important;
}
figure.image { margin: 1.5em auto !important; text-align: center; }
figure.image img { display: inline-block; }

/* ══════════════════════════════════════════════════════════════
   10. Include-Note
   ══════════════════════════════════════════════════════════════ */
section.include-note {
  display: block;
  margin: 1em 0;
  padding: 20px;
  border: 1px dashed #ccc;
  border-radius: var(--radius);
  background: #fafafa;
  min-height: 60px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85em;
  font-style: italic;
  transition: border-color 0.2s ease, background 0.2s ease;
}
section.include-note:hover {
  border-color: var(--primary);
  background: var(--accent-soft);
}
section.include-note::after {
  content: "📎 子笔记引用 (分享页暂不支持动态加载)";
  opacity: 0.7;
}

/* ══════════════════════════════════════════════════════════════
   11. 剪藏来源
   ══════════════════════════════════════════════════════════════ */
#noteClippedFrom {
  margin: 1em 0;
  padding: 10px 14px;
  background: #fafafa;
  border: 1px solid var(--border-light);
  border-left: 0;
  border-right: 0;
  color: var(--text-muted);
  font-size: 0.88em;
}

/* ══════════════════════════════════════════════════════════════
   12. 子笔记导航 — 卡片式
   ══════════════════════════════════════════════════════════════ */
#childLinks {
  margin-top: 2em;
  padding-top: 1em;
  border-top: 1px solid var(--border-light);
}
#childLinks hr { border: none; border-top: 1px solid var(--border-light); margin: 0 0 8px 0; }

/* ── 卡片网格 ── */
#childLinks.grid ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  padding: 0;
  gap: 12px;
}
#childLinks.grid ul li {
  width: 185px;
  height: 110px;
}
#childLinks.grid ul li a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
  font-size: 0.9em;
  padding: 16px 12px;
  color: var(--text-main);
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: all 0.22s ease;
  position: relative;
  overflow: hidden;
}
/* 卡片顶部蓝色强调线 */
#childLinks.grid ul li a::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--link);
  opacity: 0.25;
  transition: opacity 0.22s ease;
}
#childLinks.grid ul li a:hover {
  background: #fafcfd;
  border-color: var(--link);
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}
#childLinks.grid ul li a:hover::before {
  opacity: 1;
}

/* ── 列表模式 ── */
#childLinks.list ul {
  list-style: none;
  display: inline-flex;
  flex-wrap: wrap;
  padding: 0;
  gap: 4px 20px;
}
#childLinks.list ul li a { color: var(--link); padding: 2px 0; }

/* ══════════════════════════════════════════════════════════════
   13. 杂项
   ══════════════════════════════════════════════════════════════ */
hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 1.5em 0;
}
del { color: var(--text-muted); }
kbd {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 0.88em;
}

/* ══════════════════════════════════════════════════════════════
   14. 滚动条
   ══════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #aaa; background-clip: content-box; }

/* ══════════════════════════════════════════════════════════════
   15. 响应式
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  #layout { flex-direction: column !important; }

  #menu {
    width: 100% !important;
    min-width: 100% !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border) !important;
    z-index: 150 !important;
    transform: translateX(-100%) !important;
    opacity: 0 !important;
    transition: transform 0.25s ease, opacity 0.25s ease !important;
  }
  #menu::before { display: none; }

  #layout.showMenu #menu {
    transform: translateX(0) !important;
    opacity: 1 !important;
  }

  #toggleMenuButton { display: flex !important; }

  #main {
    margin-left: 0 !important;
    padding: 20px 16px 40px !important;
  }

  #childLinks.grid ul { flex-direction: column; }
  #childLinks.grid ul li { width: 100%; height: auto; }
  #childLinks.grid ul li a { height: 48px; flex-direction: row; justify-content: flex-start; padding: 0 14px; }
  #childLinks.grid ul li a::before { display: none; }
  section.include-note { padding: 14px; }
}

/* 中屏 */
@media (min-width: 769px) and (max-width: 1024px) {
  :root {
    --menu-w: 220px;
    --menu-collapsed: 14px;
  }
  #menu { padding: 24px 16px !important; }
  #main { margin-left: 14px !important; padding: 28px !important; }
}

/* ══════════════════════════════════════════════════════════════
   16. 打印
   ══════════════════════════════════════════════════════════════ */
@media print {
  #menu { display: none !important; }
  #main { margin-left: 0 !important; }
  body.share-body { background: white !important; color: black !important; }
  #title { color: #1a1a1a !important; }
  a { color: #333 !important; text-decoration: underline !important; }
}
