/* ============================================================================
 * 三角洲ARG档案馆 · 基础样式（设计令牌 / 布局外壳 / 通用组件）
 * ----------------------------------------------------------------------------
 * 依赖 assets/vendor/modern-normalize/modern-normalize.css（跨浏览器重置）。
 * 深色模式通过 <html class="dark-theme"> 切换，由 assets/js/theme.js 维护。
 * ========================================================================== */

/* ------------------------------------------------------------------ 设计令牌 */

:root {
  --bg: #f4f7fc;
  --bg-soft: #e9eef8;
  --surface: #ffffff;
  --surface-2: #f8fafd;
  --border: rgba(22, 45, 80, 0.12);
  --border-strong: rgba(22, 45, 80, 0.22);
  --text: #16233a;
  --text-secondary: #5b6b85;
  --text-muted: #8494ac;
  --accent: #2f6fd0;
  --accent-2: #3f9fe0;
  --accent-soft: rgba(63, 143, 224, 0.12);
  --accent-contrast: #ffffff;
  --ok: #2f9e6f;
  --ok-soft: rgba(47, 158, 111, 0.13);
  --warn: #c98a1c;
  --warn-soft: rgba(201, 138, 28, 0.15);
  --danger: #cd4b46;
  --danger-soft: rgba(205, 75, 70, 0.13);
  --info: #3f7fd6;
  --info-soft: rgba(63, 127, 214, 0.13);
  --shadow-sm: 0 1px 2px rgba(20, 45, 85, 0.06);
  --shadow: 0 4px 16px rgba(20, 45, 85, 0.08);
  --shadow-lg: 0 12px 36px rgba(20, 45, 85, 0.14);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --header-h: 60px;
  --sidebar-w: 268px;
  --content-max: 1040px;
  --content-max-wide: 1264px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

html.dark-theme {
  --bg: #0d1524;
  --bg-soft: #111c2e;
  --surface: #141f33;
  --surface-2: #18253c;
  --border: rgba(150, 190, 240, 0.15);
  --border-strong: rgba(150, 190, 240, 0.28);
  --text: #e8eefb;
  --text-secondary: #a3b5d2;
  --text-muted: #7d90ae;
  --accent: #6cc4f6;
  --accent-2: #4d9ee6;
  --accent-soft: rgba(108, 196, 246, 0.14);
  --accent-contrast: #08111f;
  --ok: #4fc48d;
  --ok-soft: rgba(79, 196, 141, 0.16);
  --warn: #e3b055;
  --warn-soft: rgba(227, 176, 85, 0.16);
  --danger: #f0786f;
  --danger-soft: rgba(240, 120, 111, 0.16);
  --info: #6cb0f0;
  --info-soft: rgba(108, 176, 240, 0.16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 14px 40px rgba(0, 0, 0, 0.45);
}

/* ------------------------------------------------------------------ 基础重置 */

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

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.35; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-2); }
code { font-family: var(--mono); font-size: 0.9em; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.icon { flex: none; vertical-align: middle; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 200;
  transform: translateY(-200%);
  background: var(--accent); color: var(--accent-contrast);
  padding: 8px 14px; border-radius: var(--radius-sm); font-size: 14px;
  transition: transform var(--transition);
}
.skip-link:focus { transform: translateY(0); color: var(--accent-contrast); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ------------------------------------------------------------------ 外壳布局 */

.app-wrapper { min-height: 100vh; display: flex; flex-direction: column; }

.header {
  position: sticky; top: 0; z-index: 60;
  height: var(--header-h);
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
@supports not (backdrop-filter: blur(1px)) {
  .header { background: var(--surface); }
}
.header-left { display: flex; align-items: center; gap: 4px; flex: 1 1 auto; min-width: 0; }
.header-right { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }

.site-name {
  font-weight: 700; font-size: 16px; color: var(--text);
  padding-left: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--text-secondary);
  cursor: pointer; transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.icon-btn:active { transform: scale(0.96); }

/* 语言下拉 */
.lang-dropdown { position: relative; }
.lang-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 10px;
  background: transparent; color: var(--text-secondary);
  font-size: 13px; cursor: pointer; transition: all var(--transition);
}
.lang-btn:hover { border-color: var(--accent); color: var(--accent); }
.lang-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 168px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  display: none; z-index: 70;
}
.lang-dropdown.open .lang-menu { display: block; }
.lang-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px;
}
.lang-item:hover { background: var(--accent-soft); color: var(--accent); }
.lang-item.active { color: var(--accent); font-weight: 600; background: var(--accent-soft); }
.lang-item .check-icon { color: var(--accent); }

/* 窄屏：语言按钮只留图标，避免顶栏拥挤变形 */
@media (max-width: 600px) {
  .lang-btn { padding: 0 9px; gap: 0; }
  .lang-btn-text, .lang-caret { display: none; }
  .site-name { font-size: 15px; }
}

/* 侧栏 */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 90;
  width: var(--sidebar-w); max-width: 86vw;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
  transform: translateX(-102%);
  transition: transform var(--transition);
  box-shadow: var(--shadow-lg);
}
.sidebar.open { transform: translateX(0); }
.sidebar-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(9, 18, 33, 0.5);
  opacity: 0; visibility: hidden; transition: opacity var(--transition), visibility var(--transition);
}
.sidebar-overlay.show { opacity: 1; visibility: visible; }

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 14px 14px 12px; border-bottom: 1px solid var(--border);
}
.sidebar-logo { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; }
.sidebar-close { display: inline-flex; }

.sidebar-nav { flex: 1 1 auto; overflow-y: auto; padding: 10px 10px 16px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px; border-radius: 11px;
  color: var(--text-secondary); font-size: 14.5px; font-weight: 500;
}
.nav-item:hover { background: var(--bg-soft); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.nav-item.active .icon { color: var(--accent); }

/* 移动端侧栏展开时锁定背景滚动（由 app.js 添加 body.sidebar-open） */
body.sidebar-open { overflow: hidden; }

/* 主内容 */
.main-content { flex: 1 1 auto; min-width: 0; }
.content-wrapper {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 26px 16px 48px;
}
/* 需要展示整屏截图的页面（如解密网站）：放宽到接近截图原始宽度 */
.content-wrapper--wide { max-width: var(--content-max-wide); }
/* 以正文为主的页面（如动态详情）：收窄并整体居中 */
.content-wrapper--narrow { max-width: 880px; }

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted); font-size: 13px;
}
.footer-inner { max-width: var(--content-max); margin: 0 auto; padding: 18px 16px 24px; }
.footer-copy { color: var(--text-muted); font-size: 12.5px; }

/* 桌面端：侧栏常驻 */
@media (min-width: 1024px) {
  .menu-toggle { display: none; }
  .sidebar { transform: none; box-shadow: none; top: 0; }
  .sidebar-close { display: none; }
  .sidebar-overlay { display: none; }
  .app-wrapper { padding-left: var(--sidebar-w); }
  .header { padding-left: 20px; }
  .content-wrapper { padding: 34px 28px 60px; }
  .site-name { font-size: 17px; }
}

/* ------------------------------------------------------------------ 通用组件 */

.section { margin-bottom: 40px; }
.section:last-child { margin-bottom: 8px; }

.section-title {
  display: flex; align-items: center; gap: 9px;
  font-size: 19px; margin-bottom: 16px;
}
.section-title .icon { color: var(--accent); }
.section-more {
  margin-left: auto; display: inline-flex; align-items: center; gap: 4px;
  font-size: 13.5px; font-weight: 500; color: var(--accent);
}

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm);
}

.grid { display: grid; gap: 14px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 0 15px;
  border: 1px solid var(--border-strong); border-radius: 11px;
  background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 550; cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition);
}
.btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn--primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--accent-contrast); }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--text-secondary); }
.btn--sm { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 9px; }
.btn--disabled { opacity: 0.55; cursor: not-allowed; border-style: dashed; }
.btn--disabled:hover { border-color: var(--border-strong); color: var(--text-secondary); background: transparent; }

/* 徽章 */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--bg-soft); color: var(--text-secondary);
  border: 1px solid var(--border);
  font-size: 12px; line-height: 1.6; white-space: nowrap;
}
.chip .icon { opacity: 0.9; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 5px; }

.chip--status.status--open { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 32%, transparent); }
.chip--status.status--restricted { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 32%, transparent); }
.chip--status.status--closed { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 32%, transparent); }
.chip--status.status--unknown { background: var(--bg-soft); color: var(--text-muted); }
.chip--status.status--archive { background: var(--info-soft); color: var(--info); }
.chip--important { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 34%, transparent); }
.chip--normal { background: var(--bg-soft); color: var(--text-muted); }
.chip--sample { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 34%, transparent); }
.chip--version { font-family: var(--mono); }
.chip--type { background: var(--accent-soft); color: var(--accent); }
.chip--latest { background: var(--ok-soft); color: var(--ok); }
.chip--kind { background: var(--info-soft); color: var(--info); }

/* 带胶囊按钮（筛选 / 搜索范围） */
.chip-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-secondary); font-size: 13px; cursor: pointer;
  transition: all var(--transition); white-space: nowrap;
}
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }
.chip-btn.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }

/* 表单 */
.field { display: inline-flex; align-items: center; gap: 8px; }
.field--search {
  flex: 1 1 240px;
  padding: 0 12px; min-height: 40px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 11px;
  color: var(--text-muted);
}
.field--search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field--search input {
  flex: 1 1 auto; min-width: 0; border: 0; background: transparent; outline: none;
  color: var(--text); font-size: 14.5px; padding: 9px 0;
}
.field--select { gap: 8px; }
.field--select select {
  min-height: 38px; padding: 0 10px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 13.5px; font-family: inherit;
}
.filter-label { color: var(--text-muted); font-size: 13px; white-space: nowrap; }

/* 提示条 */
.notice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; margin: 14px 0;
  border-radius: var(--radius); font-size: 13.5px;
  background: var(--info-soft); color: var(--text-secondary);
  border: 1px solid color-mix(in srgb, var(--info) 26%, transparent);
}
.notice .icon { color: var(--info); margin-top: 2px; }
.notice--warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.notice--warn .icon { color: var(--warn); }

/* 空状态 */
.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 40px 16px; color: var(--text-muted); text-align: center;
}
.empty-state-title { font-size: 15px; color: var(--text-secondary); }
.empty-state-hint { font-size: 13.5px; }

/* 面包屑 */
.breadcrumb { margin-bottom: 16px; font-size: 13px; }
.breadcrumb ol { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--text-muted); }
.breadcrumb-item + .breadcrumb-item::before { content: "/"; margin-right: 6px; color: var(--text-muted); opacity: 0.6; }
.breadcrumb-item[aria-current] { color: var(--text-secondary); }

/* 返回顶部 */
.to-top {
  position: fixed; right: 16px; bottom: 20px; z-index: 70;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary);
  box-shadow: var(--shadow); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.to-top:hover { color: var(--accent); border-color: var(--accent); }

/* 轻提示 */
.toast-host {
  position: fixed; left: 50%; bottom: 28px; z-index: 120;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  padding: 10px 16px; border-radius: 999px;
  background: color-mix(in srgb, var(--text) 88%, transparent);
  color: var(--bg); font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 200ms ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 应用内锚点高亮 */
:target { scroll-margin-top: calc(var(--header-h) + 20px); }

/* 入场动画（由 app.js 通过 IntersectionObserver 触发） */
[data-animate] { will-change: opacity, transform; }

/* ------------------------------------------------------------------ 入口页 / 404 兜底 */

.entry-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.entry { max-width: 520px; text-align: center; }
.entry-code { font-family: var(--mono); font-size: 40px; color: var(--accent); }
.entry-title { font-size: 22px; margin-bottom: 10px; }
.entry-desc { color: var(--text-secondary); margin-bottom: 18px; }
.entry-langs { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.entry-langs a {
  padding: 9px 16px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text);
}
.entry-langs a:hover { border-color: var(--accent); color: var(--accent); }

/* ------------------------------------------------------------------ 打印 */

@media print {
  .header, .sidebar, .sidebar-overlay, .site-footer, .to-top,
  .filter-bar, .rumor-toolbar, .skip-link, .toast-host, .entry-langs { display: none !important; }
  .app-wrapper { padding-left: 0; }
  body { background: #fff; color: #000; }
  .card, .tl-card, .release-body, .decrypt-card, .oss-card, .rumor { box-shadow: none; border-color: #ccc; }
  a { color: #000; text-decoration: underline; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 11px; }
  .content-wrapper { max-width: none; padding: 0; }
}
