/* ═══════════════════════════════════════════
   🔴 共享文件 · 修改前必须告知 OP-01
      详见 /COLLABORATION.md
   ═══════════════════════════════════════════
   global.css — 全站统一设计令牌
   唯一变量源 · 所有页面引用此文件
   style.css / showcase.css 仅使用变量，不重新定义
   ═══════════════════════════════════════════ */

/* ── 日间模式 ── */
:root {
  /* 品牌色 */
  --bg:            #faf6f0;
  --bg-container:  #faf6f0;
  --bg-card:       #fffdf9;
  --bg-accent:     #f5ede0;
  --bg-elevated:   #ffffff;
  --text:          #3d3629;
  --text-muted:    #8c8070;
  --text-header:   #2c2416;
  --link:          #8b2500;
  --link-hover:    #b83a14;
  --border:        #e8dcc8;
  --border-card:   #e8dcc8;
  --border-accent: #c9a87c;
  --divider:       #e8dcc8;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.03);
  --shadow:        0 4px 24px rgba(0,0,0,.05), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg:     0 12px 40px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);

  /* 按钮 */
  --btn-bg:        #f5ede0;
  --btn-border:    #d4c4a8;
  --btn-hover-bg:  #ebe0cc;

  /* 标签 */
  --tag-bg:        #f5ede0;
  --tag-color:     #5c3d20;

  /* 强调色 */
  --accent-red:    #8b2500;
  --accent-gold:   #b8860b;
  --accent-blue:   #3a7bb8;
  --accent-green:  #3a6a4a;
  --accent-purple: #7b4fa0;
  --accent-teal:   #2a9a8a;

  /* 分类色 (数据可视化/状态/标签，比accent更明亮) */
  --cat-red:       #d46050;
  --cat-gold:      #c89840;
  --cat-green:     #5ab86a;
  --cat-blue:      #5a90d0;
  --cat-purple:    #b060b0;
  --cat-teal:      #3ab8a8;
  --cat-gray:      #7a8a8a;
  --cat-brown:     #8a6a4a;

  /* Canvas utility variables */
  --ch-head-h:     1.05em;
  --ch-head-w:     700;
  --toc-bg:        rgba(128,90,60,.06);
  --toc-border:    rgba(128,90,60,.18);

  /* Hero 渐变 */
  --gradient-hero: linear-gradient(135deg, #faf6f0 0%, #f0e4d0 40%, #faf6f0 100%);

  /* 排版 */
  --font-sans:     -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  --font-serif:    "Noto Serif SC", "Source Han Serif SC", Georgia, "Songti SC", serif;
  --font-mono:     Consolas, "Monaco", "Courier New", monospace;
  --font-base:     16px;
  --line-base:     1.5;
  --font-read:     17px;
  --line-read:     1.8;

  /* 布局 */
  --content-width: 720px;
  --wide-width:    1280px;
  --nav-height:    56px;
  --gutter:        24px;
  --radius:        8px;
  --radius-sm:     4px;
  --radius-lg:     12px;

  /* 间距 */
  --space-xs:      4px;
  --space-sm:      8px;
  --space-md:      16px;
  --space-lg:      24px;
  --space-xl:      40px;

  /* 兼容别名 (--c-* 桥接) */
  --c-bg:          var(--bg);
  --c-surface:     var(--bg-card);
  --c-surface-alt: var(--bg-accent);
  --c-border:      var(--border);
  --c-text:        var(--text);
  --c-text-sec:    var(--text-muted);
  --c-blood:       var(--accent-red);
  --c-gold:        var(--accent-gold);
  --c-purple:      var(--accent-purple);
  --c-blue:        var(--accent-blue);
  --c-green:       var(--accent-green);
}

/* ── 夜间模式 ── */
[data-theme="night"] {
  --bg:            #121214;
  --bg-container:  #121214;
  --bg-card:       #1c1c1f;
  --bg-accent:     #242427;
  --bg-elevated:   #28282b;
  --text:          #b0b0b5;
  --text-muted:    #707078;
  --text-header:   #d0d0d6;
  --link:          #d4786e;
  --link-hover:    #e89088;
  --border:        #2a2a2d;
  --border-card:   #2a2a2d;
  --border-accent: #5a4030;
  --divider:       #2a2a2d;
  --shadow-sm:     0 1px 2px rgba(0,0,0,.3);
  --shadow:        0 4px 24px rgba(0,0,0,.4), 0 1px 4px rgba(0,0,0,.3);
  --shadow-lg:     0 12px 40px rgba(0,0,0,.5), 0 4px 12px rgba(0,0,0,.3);
  --btn-bg:        #242427;
  --btn-border:    #3a3a3d;
  --btn-hover-bg:  #2e2e32;
  --tag-bg:        #242427;
  --tag-color:     #b0b0b5;
  --accent-red:    #d4786e;
  --accent-gold:   #c9a050;
  --accent-blue:   #6ba3d8;
  --accent-green:  #6aaa7a;
  --accent-purple: #b088d0;
  --accent-teal:   #3ab8a8;

  /* 分类色 (夜间模式：略亮) */
  --cat-red:       #e07060;
  --cat-gold:      #d8a850;
  --cat-green:     #6aaa7a;
  --cat-blue:      #6aa0e0;
  --cat-purple:    #c870c8;
  --cat-teal:      #4ac8b8;
  --cat-gray:      #98b0b0;
  --cat-brown:     #a88a5a;
  --gradient-hero: linear-gradient(135deg, #121214 0%, #1a1715 40%, #121214 100%);

  --c-bg:          var(--bg);
  --c-surface:     var(--bg-card);
  --c-surface-alt: var(--bg-accent);
  --c-border:      var(--border);
  --c-text:        var(--text);
  --c-text-sec:    var(--text-muted);
  --c-blood:       var(--accent-red);
  --c-gold:        var(--accent-gold);
  --c-purple:      var(--accent-purple);
  --c-blue:        var(--accent-blue);
  --c-green:       var(--accent-green);
}

/* ═══════════════════════════════════════════
   全站统一组件
   ═══════════════════════════════════════════ */

/* ── 世界观标签 .world-tag ── */
.world-tag {
  color: var(--accent-red);
  border-bottom: 1px dashed var(--accent-red);
  cursor: help;
  position: relative;
  text-decoration: none;
  font-weight: 500;
}
.world-tag:hover {
  color: var(--link-hover);
  border-bottom-color: var(--link-hover);
}
.world-tag::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.5;
  max-width: 240px;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.world-tag:hover::after { opacity: 1; }

/* ── 面包屑 ── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  padding: var(--space-sm) 0;
  margin-bottom: var(--space-md);
}
.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color .15s;
}
.breadcrumb a:hover { color: var(--link); }
.breadcrumb .sep { opacity: .4; }
.breadcrumb .current { color: var(--text); font-weight: 600; }

/* ── 通用按钮 .g-btn ── */
.g-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all .2s;
  line-height: 1.4;
}
.g-btn:hover {
  background: var(--btn-hover-bg);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.g-btn.primary {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: #fff;
}
.g-btn.primary:hover {
  filter: brightness(1.1);
  box-shadow: var(--shadow);
}
.g-btn.ghost {
  background: transparent;
  border-color: var(--border);
}
.g-btn.ghost:hover {
  background: var(--bg-accent);
}

/* ── 徽章 .badge ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
}
.badge.red    { background: rgba(139,37,0,.1);  color: var(--accent-red); }
.badge.gold   { background: rgba(184,134,11,.1); color: var(--accent-gold); }
.badge.blue   { background: rgba(58,123,184,.1); color: var(--accent-blue); }
.badge.green  { background: rgba(58,106,74,.1);  color: var(--accent-green); }
.badge.purple { background: rgba(123,79,160,.1); color: var(--accent-purple); }

/* ── 分割线 ── */
.divider {
  height: 1px;
  background: var(--divider);
  border: none;
  margin: var(--space-lg) 0;
}

/* ── 折叠面板 (全站通用) ── */
.collapse-hd {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-header);
  transition: all .2s;
  user-select: none;
  margin-bottom: 2px;
}
.collapse-hd:hover { border-color: var(--border-accent); }
.collapse-hd .arrow {
  font-size: 10px;
  transition: transform .25s;
  color: var(--text-muted);
}
.collapse-hd.open .arrow { transform: rotate(90deg); }
.collapse-body {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  margin-bottom: var(--space-md);
}
.collapse-body.shut { display: none; }

/* ── 阅读容器基准 (窗口2在此范围内扩展) ── */
.read-container {
  font-family: var(--font-serif);
  font-size: var(--font-read);
  line-height: var(--line-read);
  max-width: var(--content-width);
  color: var(--text);
}
.read-container p {
  margin-bottom: 1em;
  text-indent: 2em;
}
.read-container .dialogue {
  text-indent: 0;
  padding-left: 1em;
  border-left: 3px solid var(--accent-gold);
  margin: 1em 0;
}
.read-container .scene-break {
  text-align: center;
  color: var(--text-muted);
  margin: 2em 0;
  font-size: .85em;
  letter-spacing: 4px;
}

/* ── 页脚 (全站统一) ── */
.site-footer {
  text-align: center;
  padding: var(--space-xl) var(--space-lg);
  color: var(--text-muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
  margin-top: var(--space-xl);
}

/* ═══════════════════════════════════════════
   响应式
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
  :root {
    --gutter: 16px;
    --font-base: 15px;
    --font-read: 16px;
    --space-lg: 16px;
    --space-xl: 24px;
  }
}


/* ═══════════════════════════════════════════
   抗闪烁 · 布局占位 · 防止白闪/跳动
   ═══════════════════════════════════════════ */
html { background: var(--bg); }
body {
  background: var(--bg);
  margin: 0;
  min-height: 100vh;
}

/* A区导航栏：JS填充前隐藏，防止空白条闪烁 */
#toolbar-wrap:empty {
  min-height: 42px;
  visibility: hidden;
}

/* B区按钮栏：预留空间防止后续元素跳动 */
.page-hero-actions {
  min-height: 36px;
}

/* 书名标题块：预留空间 */
.book-title-block {
  min-height: 80px;
}

/* 核心区块禁用过渡：消除主题切换/页面跳转时的动画拖影和错位 */
#toolbar-wrap,
.page-hero-actions,
.book-title-block {
  transition: none !important;
}

/* ── 书名标题块（全站基准，canvas 页面可覆盖）── */
.book-title-block {
  text-align: center;
  margin: 28px 0 20px;
  padding: 0 16px;
}
.main-logo {
  font-family: var(--font-serif);
  font-size: 2.6em;
  font-weight: 900;
  color: var(--text-header);
  letter-spacing: .06em;
  margin: 0 0 12px;
  line-height: 1.2;
}
.main-logo .accent-red { color: var(--accent-red); }
.desc-gray {
  font-family: var(--font-sans);
  font-size: .82em;
  color: var(--text-muted);
  margin: 6px 0 0;
  line-height: 1.6;
}
.desc-gold {
  font-family: var(--font-sans);
  font-size: .72em;
  color: var(--accent-gold);
  margin: 4px 0 0;
  line-height: 1.6;
}
@media(max-width:600px) {
  .main-logo { font-size: 1.8em; }
}



/* ════════════════════════════════════════════════════════════════════════════════════════════════════
   页面底部功能按钮（仅规范站静态写入）
   ════════════════════════════════════════════════════════════════════════════════════════════════════ */
.page-bottom-extra-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin: 60px 0 40px;
}

.git-upload-btn,
.download-all-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
  border: 1px solid;
}

.git-upload-btn {
  background: rgba(9,130,60,.08);
  color: #09823c;
  border-color: rgba(96,196,148,.6);
}
.git-upload-btn:hover {
  background: #09823c;
  color: #fff;
}

.download-all-btn {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.download-all-btn:hover {
  background: var(--text);
  color: var(--bg);
}

.git-upload-btn svg,
.download-all-btn svg {
  flex-shrink: 0;
}
