/* ==========================================================================
   焕影Club v18 — shared design tokens, dual theme (深海蓝 / 白底资讯)
   Used by index.html, article.html, tutorial.html. download.html is untouched.
   ========================================================================== */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07111f;
  --bg-soft: #0a1626;
  --surface: #0d1b2e;
  --surface-2: #12233a;
  --surface-hover: #142a45;
  --line: rgba(158, 188, 222, .12);
  --line-strong: rgba(158, 188, 222, .22);
  --text: #e9eff7;
  --text-2: #a9b8cb;
  --text-3: #6f8299;
  --accent: #b8e875;          /* 工作室标准色：薄荷黄绿 */
  --accent-ink: #0c1a0a;
  --accent-text: #c3f07d;     /* 绿色文字 */
  --accent-line: #b8e875;     /* 绿色线条/标记 */
  --accent-shadow: #5d8a2c;   /* 伪 3D 按钮底边 */
  --accent-soft: rgba(184, 232, 117, .12);
  --link: #8fe8ff;            /* 青蓝：链接与来源 */
  --tag-bg: rgba(184, 232, 117, .12);
  --tag-text: #c3f07d;
  --live: #b8e875;
  --warn: #e7b65c;
  --img-bg: #0f2036;
  --header-bg: rgba(7, 17, 31, .84);
  --dock-bg: rgba(9, 20, 36, .92);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .25);
  --shadow-2: 0 18px 50px rgba(0, 0, 0, .35);
  --logo-filter: none;
  --hero-glow: radial-gradient(1200px 520px at 15% -10%, rgba(31, 92, 160, .35), transparent 60%),
               radial-gradient(900px 420px at 95% 0%, rgba(25, 120, 150, .18), transparent 60%);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f3f5f8;
  --surface-hover: #f0f4f9;
  --line: #e8ebf0;
  --line-strong: #d6dbe3;
  --text: #111a27;
  --text-2: #4b5667;
  --text-3: #8a94a3;
  --accent: #b8e875;          /* 浅色同样用工作室绿作填充 */
  --accent-ink: #10200a;
  --accent-text: #3d7a0c;     /* 白底上可读的深绿 */
  --accent-line: #8fcf3c;
  --accent-shadow: #7fb043;
  --accent-soft: rgba(143, 207, 60, .16);
  --link: #0d5fa8;            /* 深海蓝作链接 */
  --tag-bg: rgba(143, 207, 60, .16);
  --tag-text: #3d7a0c;
  --live: #23a55a;
  --warn: #b7791f;
  --img-bg: #eef1f5;
  --header-bg: rgba(255, 255, 255, .9);
  --dock-bg: rgba(255, 255, 255, .95);
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-2: 0 18px 48px rgba(16, 24, 40, .12);
  --logo-filter: brightness(0) saturate(100%);
  --hero-glow: none;
}

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "HarmonyOS Sans SC",
               "Microsoft YaHei", "微软雅黑", "SimHei", "黑体", "Helvetica Neue", Arial, sans-serif;
  --font-num: "SF Pro Display", "Segoe UI", "DIN Alternate", "Helvetica Neue", Arial, sans-serif;
  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 18px;
  --container: 1200px;
  --gutter: 20px;
  --header-h: 60px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.theme-switching, .theme-switching *, .theme-switching *::before, .theme-switching *::after {
  transition: background-color .32s var(--ease), color .32s var(--ease), border-color .32s var(--ease), fill .32s var(--ease) !important;
}

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--header-bg);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 24px; height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-logo { width: 30px; height: 30px; display: grid; place-items: center; }
.brand-logo img { width: 28px; height: 28px; object-fit: contain; filter: var(--logo-filter); }
.brand-copy { display: grid; line-height: 1.1; }
.brand-copy b { font-size: 17px; font-weight: 700; letter-spacing: .01em; }
.brand-copy small { margin-top: 3px; color: var(--text-3); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; }

.main-nav { display: flex; align-items: center; gap: 4px; margin-left: 12px; }
.nav-item {
  position: relative; height: var(--header-h); padding: 0 12px;
  display: inline-flex; align-items: center;
  color: var(--text-2); font-size: 15px; font-weight: 500;
}
.nav-item:hover { color: var(--text); }
.nav-item.active { color: var(--text); font-weight: 600; }
.nav-item.active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 3px;
  border-radius: 3px 3px 0 0; background: var(--accent-line);
}
.header-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  display: inline-grid; place-items: center;
  color: var(--text-2); border: 1px solid transparent;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn svg { width: 19px; height: 19px; }
.lang-btn {
  height: 32px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--text-2);
  font-size: 12.5px; font-weight: 600; letter-spacing: .02em;
}
.lang-btn:hover { color: var(--text); border-color: var(--text-3); }
.lang-btn .lang-alt { color: var(--text-3); font-weight: 500; }

/* Theme toggle: two-state pill with sliding knob */
.theme-toggle {
  position: relative; width: 60px; height: 32px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: space-between;
  padding: 0 8px; border: 1px solid var(--line-strong); background: var(--surface-2);
  color: var(--text-3);
}
.theme-toggle svg { position: relative; z-index: 1; width: 15px; height: 15px; transition: color .25s var(--ease); }
.theme-toggle::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); box-shadow: var(--shadow-1);
  transition: transform .32s var(--ease), background-color .32s var(--ease);
}
:root[data-theme="dark"] .theme-toggle .ico-moon { color: var(--accent-ink); }
:root[data-theme="light"] .theme-toggle::before { transform: translateX(28px); }
:root[data-theme="light"] .theme-toggle .ico-sun { color: var(--accent-ink); }
.theme-toggle:hover { border-color: var(--text-3); }

.search-drawer { border-top: 1px solid var(--line); background: var(--header-bg); }
.search-drawer .container { display: flex; align-items: center; gap: 10px; padding-top: 10px; padding-bottom: 10px; }
.search-drawer label {
  flex: 1; display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text-3);
}
.search-drawer input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; }
.search-drawer button { color: var(--text-2); font-size: 14px; padding: 0 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 18px; border-radius: 10px; font-size: 14px; font-weight: 600;
  transition: transform .15s var(--ease), background-color .2s, border-color .2s;
}
.btn:active { transform: translateY(2px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 3px 0 var(--accent-shadow), 0 10px 22px rgba(120, 180, 60, .18); }
.btn-primary:active { box-shadow: 0 1px 0 var(--accent-shadow); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { border: 1px solid var(--line-strong); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }

/* ---------- Tags ---------- */
.tag {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px;
  background: var(--tag-bg); color: var(--tag-text); font-size: 12px; font-weight: 600; white-space: nowrap;
}
.status-text { color: var(--text-3); font-size: 12px; }

/* ---------- Footer ---------- */
.site-footer { margin-top: 72px; border-top: 1px solid var(--line); background: var(--bg-soft); }
.site-footer .container { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 32px; padding-top: 28px; padding-bottom: 28px; }
.footer-brand { display: grid; gap: 2px; }
.footer-brand b { font-size: 15px; }
.footer-brand small { color: var(--text-3); font-size: 12.5px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 13.5px; color: var(--text-2); }
.footer-links a:hover { color: var(--text); }
.footer-link-pending { color: var(--text-3); }

/* ---------- Mobile dock ---------- */
.mobile-dock { display: none; }
@media (max-width: 899px) {
  .main-nav { display: none; }
  .mobile-dock {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    display: grid; grid-template-columns: repeat(5, 1fr);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--dock-bg);
    backdrop-filter: saturate(160%) blur(16px);
    -webkit-backdrop-filter: saturate(160%) blur(16px);
    border-top: 1px solid var(--line);
  }
  .mobile-dock a {
    display: grid; justify-items: center; gap: 3px; padding: 6px 0 4px; border-radius: 10px;
    color: var(--text-3); font-size: 11px; font-weight: 500;
  }
  .mobile-dock svg { width: 23px; height: 23px; }
  .mobile-dock a.active { color: var(--text); font-weight: 600; }
  .mobile-dock a.active svg { color: var(--accent-ink); background: var(--accent); border-radius: 9px; padding: 3px; width: 34px; height: 27px; box-shadow: 0 2px 0 var(--accent-shadow); }
  .mobile-dock a[data-download] svg { color: var(--link); }
  body.has-dock { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 96px; z-index: 80;
  display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: 999px;
  background: var(--text); color: var(--bg); font-size: 13.5px; box-shadow: var(--shadow-2);
  opacity: 0; transform: translate(-50%, 12px); pointer-events: none;
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast span { color: var(--accent); }
:root[data-theme="light"] .toast span { color: var(--accent); }

/* ---------- Page transition (page-transition.js) ---------- */
.page-transition {
  position: fixed; inset: 0; z-index: 200; pointer-events: none;
  background: var(--bg); opacity: 0; transition: opacity .16s ease-out;
}
.page-transition-code, .page-transition-dot { display: none; }
.page-transition-line {
  position: absolute; top: 0; left: 0; height: 2px; width: 100%;
  background: var(--accent); transform: scaleX(0); transform-origin: left;
}
html.page-leaving .page-transition { opacity: 1; }
html.page-leaving .page-transition-line { transform: scaleX(.85); transition: transform .5s var(--ease); }

@media (max-width: 640px) {
  :root { --gutter: 16px; --header-h: 54px; }
  .brand-copy small { display: none; }
  .header-inner { gap: 12px; }
  .header-tools { gap: 4px; }
  .icon-btn { width: 36px; height: 36px; }
}

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