/* ============================================================
   Canify 官网样式 — Next.js 风格设计系统
   基调：黑白为主、细边框、克制的蓝色点缀、Geist 排版、
        等宽字体细节、克制的点缀（无渐变横幅、无彩色图标块）
   主题：跟随系统 + 手动切换（html[data-theme="light|dark"]）
   ============================================================ */

/* ---------- 字体：自托管 Geist（SIL OFL 1.1，见 fonts/LICENSE.txt） ---------- */
@font-face {
  font-family: "Geist";
  src: url("./fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("./fonts/GeistMono-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---------- 设计令牌 ---------- */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --fg: #171717;
  --fg-2: #666666;
  --fg-3: #8f8f8f;
  --fg-grad: #a8a8a8;
  --border: #eaeaea;
  --border-2: #dcdcdc;
  --accent: #0070f3;
  --accent-hover: #0060df;
  --accent-soft: rgba(0, 112, 243, 0.08);
  --success: #15803d;
  --warn: #b45309;
  --code-bg: rgba(0, 0, 0, 0.05);
  --dot: rgba(0, 0, 0, 0.13);
  --glow: rgba(0, 112, 243, 0.055);
  --header-bg: rgba(255, 255, 255, 0.8);
  --btn-primary-hover: #383838;
  --shot-shadow: 0 24px 70px -24px rgba(0, 0, 0, 0.28), 0 8px 24px -12px rgba(0, 0, 0, 0.1);
  --radius: 12px;
  --maxw: 1080px;
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans SC", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0a0a;
  --bg-subtle: #111111;
  --fg: #ededed;
  --fg-2: #a1a1a1;
  --fg-3: #6f6f6f;
  --fg-grad: #565656;
  --border: #2e2e2e;
  --border-2: #3a3a3a;
  --accent: #3291ff;
  --accent-hover: #5da8ff;
  --accent-soft: rgba(50, 145, 255, 0.12);
  --success: #4ade80;
  --warn: #f5a623;
  --code-bg: rgba(240, 240, 240, 0.07);
  --dot: rgba(255, 255, 255, 0.12);
  --glow: rgba(50, 145, 255, 0.08);
  --header-bg: rgba(10, 10, 10, 0.75);
  --btn-primary-hover: #cccccc;
  --shot-shadow: 0 24px 80px -24px rgba(0, 0, 0, 0.7), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

::selection { background: rgba(0, 112, 243, 0.25); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  white-space: nowrap;
}

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* 切换主题时的过渡（由 JS 短暂挂载，避免首帧闪烁） */
html.theming, html.theming *, html.theming *::before, html.theming *::after {
  transition: background-color 0.25s ease, border-color 0.25s ease,
    color 0.25s ease, fill 0.25s ease, box-shadow 0.25s ease !important;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 18px; border-radius: 999px;
  font-size: 14px; font-weight: 500; white-space: nowrap;
  border: 1px solid transparent; cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--fg); color: var(--bg); }
.btn-primary:hover { background: var(--btn-primary-hover); }
.btn-secondary { border-color: var(--border-2); color: var(--fg); background: var(--bg); }
.btn-secondary:hover { border-color: var(--fg-3); background: var(--bg-subtle); }
.btn-lg { height: 44px; padding: 0 24px; font-size: 15px; }
.btn svg { width: 15px; height: 15px; flex: none; }
.btn .ext { font-size: 12px; color: var(--fg-3); }

/* ---------- 顶栏 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 60;
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; gap: 16px; height: 64px; }

.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 600; font-size: 15.5px; letter-spacing: -0.01em;
}
.brand img { width: 26px; height: 26px; border-radius: 7px; }

.nav-links { display: flex; gap: 2px; }
.nav-links a {
  font-size: 14px; color: var(--fg-2);
  padding: 6px 10px; border-radius: 8px;
}
.nav-links a:hover { color: var(--fg); background: var(--bg-subtle); text-decoration: none; }

.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.lang-switch { font-size: 13px; color: var(--fg-3); white-space: nowrap; }
.lang-switch a { padding: 2px 3px; color: var(--fg-3); }
.lang-switch a:hover { color: var(--fg); text-decoration: none; }
.lang-switch a.current { color: var(--fg); font-weight: 600; }

.theme-toggle {
  width: 36px; height: 36px; border-radius: 999px;
  border: 1px solid var(--border-2); background: transparent; color: var(--fg-2);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.theme-toggle:hover { color: var(--fg); border-color: var(--fg-3); background: var(--bg-subtle); }
.theme-toggle svg { width: 16px; height: 16px; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

.nav-toggle {
  display: none; width: 36px; height: 36px; border-radius: 999px;
  border: 1px solid var(--border-2); background: transparent; color: var(--fg);
  align-items: center; justify-content: center; cursor: pointer; flex: none;
}
.nav-toggle svg { width: 17px; height: 17px; }

/* ---------- Hero ---------- */
.hero { position: relative; padding: 92px 0 28px; text-align: center; overflow: hidden; }

/* 点阵背景 + 顶部微光（纯 CSS，随主题变化） */
.hero::before {
  content: ""; position: absolute; left: 50%; top: -90px; transform: translateX(-50%);
  width: 1300px; height: 640px; pointer-events: none;
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(ellipse 48% 52% at 50% 42%, #000 0%, transparent 72%);
  mask-image: radial-gradient(ellipse 48% 52% at 50% 42%, #000 0%, transparent 72%);
}
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 46% 34% at 50% 10%, var(--glow), transparent 70%);
}
.hero .container { position: relative; z-index: 1; }

.hero h1 {
  font-size: clamp(42px, 7.2vw, 76px);
  line-height: 1.06; font-weight: 700; letter-spacing: -0.035em;
}
.hero h1 .grad { color: var(--fg); }
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .hero h1 .grad {
    background: linear-gradient(180deg, var(--fg) 45%, var(--fg-grad));
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
  }
}

.hero .lead { max-width: 660px; margin: 22px auto 0; font-size: 18px; color: var(--fg-2); }
.hero .lead b { color: var(--fg); font-weight: 600; }

.hero-actions { margin-top: 34px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero-meta { margin-top: 18px; font-size: 13px; color: var(--fg-3); }

/* 主截图（窗口框 + 明暗两版图片，由主题决定显示哪张） */
.hero-shot { max-width: 960px; margin: 56px auto 0; text-align: left; }
.window {
  border: 1px solid var(--border-2); border-radius: var(--radius);
  overflow: hidden; background: var(--bg-subtle); box-shadow: var(--shot-shadow);
  cursor: zoom-in;
}
.window-bar {
  display: flex; align-items: center; gap: 7px; padding: 10px 14px;
  border-bottom: 1px solid var(--border); background: var(--bg);
}
.window-bar .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border-2); }
.window-bar .title { margin-left: 8px; font-family: var(--font-mono); font-size: 12px; color: var(--fg-3); }
.theme-img { display: none; width: 100%; }
[data-theme="light"] .img-light { display: block; }
[data-theme="dark"] .img-dark { display: block; }

/* ---------- 通用 section ---------- */
.section { padding: 92px 0; }
main > .section + .section { border-top: 1px solid var(--border); }

.section-head { max-width: 660px; margin: 0 auto 52px; text-align: center; }
.kicker {
  display: block; margin-bottom: 14px;
  font-family: var(--font-mono); font-size: 12px; font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent);
}
.section-head h2, .spotlight h2 {
  font-size: clamp(26px, 3.6vw, 34px);
  letter-spacing: -0.02em; line-height: 1.22; font-weight: 700;
}
.section-head p { color: var(--fg-2); margin-top: 12px; font-size: 15.5px; }

/* ---------- 特性（合并边框网格，Next.js 卡片风格） ---------- */
.tile-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.tile { background: var(--bg); padding: 26px; position: relative; transition: background-color 0.15s ease; }
.tile:hover { background: var(--bg-subtle); }
.tile h3 { font-size: 15.5px; font-weight: 600; letter-spacing: -0.01em; padding-right: 26px; }
.tile p { margin-top: 8px; font-size: 14px; color: var(--fg-2); line-height: 1.65; }
.tile .arrow {
  position: absolute; top: 24px; right: 22px;
  color: var(--fg-3); font-size: 14px; line-height: 1;
  opacity: 0; transform: translate(-4px, 4px); transition: opacity 0.2s ease, transform 0.2s ease;
}
.tile:hover .arrow { opacity: 1; transform: none; }

/* ---------- CANopen 专题 ---------- */
.spotlight { display: grid; grid-template-columns: 1fr 1.15fr; gap: 56px; align-items: center; }
.spotlight .desc { color: var(--fg-2); margin: 16px 0 26px; font-size: 15.5px; }
.spotlight ul { list-style: none; display: grid; gap: 12px; }
.spotlight li { display: flex; gap: 10px; font-size: 14.5px; color: var(--fg-2); line-height: 1.6; }
.spotlight li svg {
  width: 16px; height: 16px; flex: none; margin-top: 4px;
  stroke: var(--success); fill: none; stroke-width: 2.5;
}
.spotlight .shot {
  border: 1px solid var(--border-2); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shot-shadow); cursor: zoom-in;
}

/* ---------- 截图画廊 ---------- */
.gallery {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.gallery figure { background: var(--bg); cursor: zoom-in; transition: background-color 0.15s ease; }
.gallery figure:hover { background: var(--bg-subtle); }
.gallery img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; }
.gallery figcaption { padding: 12px 18px; font-size: 13px; color: var(--fg-2); border-top: 1px solid var(--border); }
.gallery .idx { font-family: var(--font-mono); font-size: 12px; color: var(--fg-3); margin-right: 8px; }

/* ---------- 硬件支持 ---------- */
.hw-wrap { display: grid; grid-template-columns: 1.15fr 1fr; gap: 48px; align-items: start; }
.hw-list { list-style: none; border-top: 1px solid var(--border); }
.hw-list li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 15px 4px; border-bottom: 1px solid var(--border);
}
.hw-list .name { font-size: 14.5px; font-weight: 500; }
.hw-list .note { color: var(--fg-3); font-size: 12.5px; text-align: right; font-family: var(--font-mono); }
.hw-note {
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  font-size: 14.5px; color: var(--fg-2);
}
.hw-note b { color: var(--fg); font-weight: 600; }

/* ---------- 下载 ---------- */
.dl-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1px; background: var(--border); max-width: 860px; margin: 0 auto;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.dl-card {
  background: var(--bg); padding: 34px 30px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  text-align: center; transition: background-color 0.15s ease;
}
.dl-card:hover { background: var(--bg-subtle); }
.dl-card .os { display: flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 600; }
.dl-card .os svg { width: 20px; height: 20px; fill: currentColor; }
.dl-card .files { color: var(--fg-2); font-size: 13px; min-height: 40px; }
.dl-card .btn { align-self: stretch; }
.dl-all { max-width: 860px; margin: 24px auto 0; text-align: center; font-size: 14px; color: var(--fg-2); }
.dl-all a { color: var(--accent); }
.dl-all a:hover { text-decoration: underline; }
.dl-card .dl-links { font-size: 13px; color: var(--fg-2); }
.dl-card .dl-links a { color: var(--accent); margin: 0 5px; }
.dl-card .dl-links a:hover { text-decoration: underline; }

/* ---------- 对比表 ---------- */
.compare-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table.compare { width: 100%; border-collapse: collapse; min-width: 760px; }
.compare th, .compare td {
  padding: 14px 18px; text-align: left; font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.compare thead th { color: var(--fg-3); font-weight: 500; font-size: 13px; background: var(--bg-subtle); }
.compare tbody tr:last-child td { border-bottom: 0; }
.compare td:first-child { font-weight: 600; }
.compare tr.canify-col { background: var(--accent-soft); }
.compare tr.canify-col td:first-child { color: var(--accent); font-weight: 700; }
.compare .yes { color: var(--success); font-family: var(--font-mono); font-weight: 600; }
.compare .no { color: var(--fg-3); font-family: var(--font-mono); }
.compare .part { color: var(--warn); }
.compare-note { color: var(--fg-3); font-size: 13px; margin-top: 14px; line-height: 1.7; }

/* ---------- FAQ ---------- */
.faq { max-width: 780px; margin: 0 auto; border-top: 1px solid var(--border); }
.faq details { border-bottom: 1px solid var(--border); }
.faq summary {
  list-style: none; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 18px 4px; font-size: 15.5px; font-weight: 500;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; font-family: var(--font-mono); font-weight: 400;
  color: var(--fg-3); font-size: 18px; line-height: 1;
  transition: transform 0.2s ease; flex: none;
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { padding: 0 4px 20px; color: var(--fg-2); font-size: 14.5px; max-width: 640px; }

/* ---------- 路线图 ---------- */
.roadmap { max-width: 640px; margin: 0 auto; list-style: none; border-top: 1px solid var(--border); }
.roadmap li {
  display: flex; gap: 16px; align-items: baseline;
  padding: 13px 4px; border-bottom: 1px solid var(--border);
  color: var(--fg-2); font-size: 14.5px;
}
.roadmap .idx { font-family: var(--font-mono); font-size: 12px; color: var(--fg-3); flex: none; }

/* ---------- 页脚 ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 40px 0 48px; margin-top: 8px; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.footer-inner .left { display: flex; align-items: center; gap: 10px; color: var(--fg-2); font-size: 13.5px; }
.footer-inner .left img { width: 20px; height: 20px; border-radius: 6px; }
.footer-inner .right { display: flex; gap: 20px; font-size: 13.5px; }
.footer-inner .right a { color: var(--fg-2); }
.footer-inner .right a:hover { color: var(--fg); text-decoration: none; }
.disclaimer { color: var(--fg-3); font-size: 12.5px; margin-top: 20px; max-width: 820px; line-height: 1.7; }

/* ---------- 灯箱 ---------- */
dialog.lightbox {
  border: 0; padding: 0; background: transparent;
  width: fit-content; max-width: min(1200px, 94vw); margin: auto;
  /* dialog 默认 inset:0 + margin:auto，会在视口内自动居中 */
}
dialog.lightbox::backdrop { background: rgba(0, 0, 0, 0.82); }
.lightbox-body { display: block; }
.lightbox-body img {
  display: block; width: auto; height: auto;
  max-width: min(1200px, 94vw); max-height: 92vh;
  border-radius: var(--radius); border: 1px solid var(--border-2);
}

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .tile-grid { grid-template-columns: 1fr 1fr; }
  .spotlight { grid-template-columns: 1fr; gap: 36px; }
  .hw-wrap { grid-template-columns: 1fr; gap: 32px; }
}

@media (max-width: 860px) {
  .nav-links {
    display: none; position: absolute; top: 64px; left: 0; right: 0;
    background: var(--bg); border-bottom: 1px solid var(--border);
    flex-direction: column; padding: 10px 16px 16px; gap: 2px;
  }
  .nav-links a { padding: 11px 12px; font-size: 15px; }
  .nav-links.open { display: flex; }
  .nav-toggle { display: inline-flex; }
}

@media (max-width: 620px) {
  .lang-switch { display: none; }
  .nav-right .btn-secondary { display: none; }
  .section { padding: 64px 0; }
  .hero { padding: 60px 0 20px; }
  .hero h1 { font-size: clamp(34px, 9.5vw, 44px); }
  .hero .lead { font-size: 16px; }
  .hero-shot { margin-top: 40px; }
  .tile-grid, .gallery, .dl-grid { grid-template-columns: 1fr; }
  .section-head { margin-bottom: 40px; }
}

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