/* Junfan Labs — site styles */
:root {
  --bg: #F7F7F4;
  --surface: #FFFFFF;
  --surface-2: #EFEFEA;
  --ink: #0E1116;
  --ink-2: #2B303A;
  --muted: #5B6270;
  --line: #E2E2DA;
  --line-2: #CFCFC5;
  --accent: #3A57F0;
  --accent-soft: #EAEEFF;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(14, 17, 22, .04), 0 10px 30px rgba(14, 17, 22, .06);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B0D11;
    --surface: #12151B;
    --surface-2: #1A1E27;
    --ink: #ECEEF2;
    --ink-2: #C8CDD7;
    --muted: #9AA1AF;
    --line: #232832;
    --line-2: #333A47;
    --accent: #8097FF;
    --accent-soft: #1A2142;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Bilingual: only the active language is shown */
html[data-lang="en"] .l-zh,
html[data-lang="zh"] .l-en { display: none !important; }

a { color: inherit; }
img, svg { display: block; max-width: 100%; }
p { margin: 0 0 1em; }
.wrap { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 32px); }

.skip {
  position: absolute; left: -9999px; top: 10px; z-index: 100;
  background: var(--ink); color: var(--bg); padding: 8px 12px; border-radius: 8px; text-decoration: none;
}
.skip:focus { left: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.site-header.scrolled { border-bottom-color: var(--line); }
.header-inner { display: flex; align-items: center; gap: 20px; height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 650; font-size: 17px; letter-spacing: -.01em; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.bm-bg { fill: var(--ink); }
.bm-j { fill: none; stroke: var(--bg); stroke-width: 7; stroke-linecap: round; }
.bm-dot { fill: var(--accent); }
.nav { display: flex; gap: 2px; margin-left: auto; }
.nav a {
  text-decoration: none; color: var(--muted); font-size: 14.5px;
  padding: 8px 12px; border-radius: 999px; transition: color .15s, background .15s;
}
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.lang-toggle {
  appearance: none; cursor: pointer; min-width: 54px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font: 600 13px/1 var(--font); padding: 9px 12px; border-radius: 999px;
}
.lang-toggle:hover { border-color: var(--ink-2); }
@media (max-width: 880px) {
  .nav { display: none; }
  .header-actions { margin-left: auto; }
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  font-weight: 600; font-size: 15px; line-height: 1.2; padding: 13px 20px;
  border-radius: 999px; border: 1px solid transparent;
  transition: transform .15s, border-color .15s, opacity .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-ghost { border-color: var(--line-2); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink-2); }
.btn-small { padding: 9px 14px; font-size: 13.5px; }
.btn-light { background: var(--bg); color: var(--ink); }

/* Type */
section { padding: clamp(64px, 9vw, 112px) 0; }
h1, h2, h3 { margin: 0; color: var(--ink); font-weight: 650; }
h1 { font-size: clamp(2.4rem, 5vw, 3.75rem); line-height: 1.05; letter-spacing: -.035em; }
h2 { font-size: clamp(1.9rem, 3.6vw, 2.7rem); line-height: 1.12; letter-spacing: -.025em; }
h3 { font-size: 1.15rem; line-height: 1.3; letter-spacing: -.01em; }
html[lang="zh-CN"] h1, html[lang="zh-CN"] h2, html[lang="zh-CN"] h3 { letter-spacing: 0; }
html[lang="zh-CN"] h1 { line-height: 1.16; }
.nb { display: inline-block; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 0 18px;
  font: 600 12px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.eyebrow::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.lede { font-size: clamp(1.06rem, 1.6vw, 1.2rem); color: var(--ink-2); max-width: 36em; }
.section-head {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px 48px; align-items: end; margin-bottom: 44px;
}
.section-head p { margin: 0; color: var(--muted); font-size: 1.05rem; }
.alt { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
@media (max-width: 880px) { .section-head { grid-template-columns: 1fr; } }

/* Hero */
.hero { padding-top: clamp(40px, 7vw, 88px); padding-bottom: clamp(56px, 8vw, 104px); }
.hero-grid {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(32px, 5vw, 64px); align-items: center;
}
.hero h1 { margin-bottom: 22px; }
.hero .lede { margin: 0 0 32px; }
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; }
@media (max-width: 920px) { .hero-grid { grid-template-columns: 1fr; } }

.viz { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 10px 10px 16px; box-shadow: var(--shadow); }
.viz svg { width: 100%; height: auto; }
.legend {
  list-style: none; margin: 4px 0 0; padding: 0 12px;
  display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; color: var(--muted);
}
.legend li { display: inline-flex; align-items: center; gap: 8px; }
.sw { display: inline-block; width: 22px; height: 0; border-top: 2px solid var(--muted); }
.sw-fan { opacity: .6; }
.sw-plan { border-top: 3px solid var(--accent); }
.sw-meas { border-top: 2px dashed var(--ink); }
.sw-delta { font-weight: 700; color: var(--accent); width: 22px; text-align: center; }

/* Hero diagram */
.v-dot { fill: var(--line-2); }
.v-fan { fill: none; stroke: var(--muted); stroke-width: 1.4; opacity: .45; }
.v-fan-end { fill: var(--surface); stroke: var(--muted); stroke-width: 1.4; opacity: .7; }
.v-plan { fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-linecap: round; }
.v-plan-end { fill: var(--accent); }
.v-meas { fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-dasharray: 7 6; stroke-linecap: round; }
.v-meas-end { fill: var(--ink); }
.v-ring { fill: none; stroke: var(--line-2); stroke-width: 1.5; }
.v-robot { fill: var(--ink); }
.v-eye { fill: var(--accent); }
.v-gap { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.v-axis { stroke: var(--line-2); stroke-width: 1.2; }
.v-cap { font: 600 13px var(--mono); letter-spacing: .08em; fill: var(--muted); }
html[lang="zh-CN"] .v-cap { font-family: var(--font); letter-spacing: .04em; }
.v-math { font: italic 500 16px var(--font); fill: var(--ink-2); }
.v-tick { font: 500 13px var(--mono); fill: var(--muted); }
.v-delta { font: 700 17px var(--font); fill: var(--accent); }

/* Research cards */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px;
  transition: border-color .2s, transform .2s;
}
.card:hover { border-color: var(--line-2); transform: translateY(-2px); }
.icon {
  width: 44px; height: 44px; border-radius: 12px; margin-bottom: 20px;
  background: var(--accent-soft); color: var(--accent); display: grid; place-items: center;
}
.icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.card h3 { margin-bottom: 10px; }
.card p { margin: 0; color: var(--muted); }
@media (max-width: 720px) { .cards { grid-template-columns: 1fr; } .card { padding: 24px; } }

/* Principles */
.principles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; }
.principle { border-top: 2px solid var(--ink); padding-top: 20px; }
.principle h3 { margin-bottom: 10px; }
.principle p { margin: 0; color: var(--muted); }
@media (max-width: 880px) { .principles { grid-template-columns: 1fr; gap: 28px; } }

/* Founder */
.founder { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.6fr); gap: clamp(28px, 5vw, 64px); align-items: start; }
.person { position: sticky; top: 96px; }
.avatar {
  width: 96px; height: 96px; border-radius: 24px; margin-bottom: 20px;
  background: linear-gradient(135deg, #3A57F0, #8B5CF6); color: #fff;
  display: grid; place-items: center; font: 650 32px/1 var(--font); letter-spacing: -.02em;
}
.person h3 { font-size: 1.5rem; }
.person .alt-name { color: var(--muted); font-size: .95rem; margin: 2px 0 0; }
.person .role { color: var(--muted); margin: 6px 0 18px; }
.links { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0; }
.links a {
  display: inline-block; text-decoration: none; font-size: 13px; font-weight: 600;
  padding: 7px 11px; border: 1px solid var(--line-2); border-radius: 999px;
}
.links a:hover { border-color: var(--ink-2); }
.bio p { font-size: 1.06rem; color: var(--ink-2); }
.pubs { margin-top: 36px; border-top: 1px solid var(--line); }
.pubs h3 { margin: 28px 0 4px; }
.pubs .note { margin: 0 0 8px; color: var(--muted); font-size: .95rem; }
.pub-list { list-style: none; margin: 0; padding: 0; }
.pub { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 20px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.pub a { font-weight: 600; text-decoration: none; color: var(--ink); }
.pub a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.pub .venue { font: 500 12.5px/1.7 var(--mono); color: var(--accent); white-space: nowrap; text-align: right; }
.pub p { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: .95rem; }
@media (max-width: 880px) { .founder { grid-template-columns: 1fr; } .person { position: static; } }
@media (max-width: 600px) { .pub { grid-template-columns: 1fr; } .pub .venue { text-align: left; white-space: normal; } }

/* Community */
.community { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: clamp(28px, 5vw, 64px); align-items: start; }
.community .lede { margin-bottom: 24px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 20px; }
.stat b { display: block; font-size: clamp(1.6rem, 3vw, 2.1rem); line-height: 1.1; letter-spacing: -.02em; font-weight: 650; margin-bottom: 6px; }
.stat span { color: var(--muted); font-size: .92rem; line-height: 1.4; display: block; }
.events { list-style: none; padding: 0; margin: 14px 0 0; border-top: 1px solid var(--line); }
.events li { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.events .when { color: var(--muted); font: 500 13px/1.6 var(--mono); white-space: nowrap; }
html[lang="zh-CN"] .events .when { font-family: var(--font); }
.events-title { font: 600 12px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 36px 0 0; }
html[lang="zh-CN"] .events-title { font-family: var(--font); letter-spacing: .04em; }
.partners { margin: 28px 0 0; color: var(--muted); }
.inline-links { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 0; padding: 0; list-style: none; }
.inline-links a { font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--line-2); }
.inline-links a:hover { border-color: var(--ink); }
.fine { font-size: .85rem; color: var(--muted); margin: 20px 0 0; }
@media (max-width: 920px) { .community { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .events li { flex-direction: column; gap: 2px; } }

/* Contact */
.contact-box {
  background: var(--ink); color: var(--bg); border-radius: 28px; padding: clamp(32px, 6vw, 64px);
  display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 32px; align-items: end;
}
.contact-box .eyebrow { color: var(--bg); opacity: .7; }
.contact-box h2 { color: var(--bg); }
.contact-box p { color: var(--bg); opacity: .75; margin: 14px 0 0; font-size: 1.08rem; }
.contact-actions { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.contact-meta { font: 500 13px/1.6 var(--mono); color: var(--bg); opacity: .65; }
@media (max-width: 880px) { .contact-box { grid-template-columns: 1fr; } }

/* Footer */
.site-footer { padding: 8px 0 56px; color: var(--muted); font-size: .92rem; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 24px; border-top: 1px solid var(--line); padding-top: 28px; }
.footer-inner p { margin: 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; }
.footer-links a { text-decoration: none; }
.footer-links a:hover { color: var(--ink); }

/* Simple pages (privacy, 404) */
.page { padding: clamp(48px, 8vw, 96px) 0; }
.page .prose { max-width: 680px; }
.page .prose h1 { font-size: clamp(2.1rem, 4.5vw, 3rem); margin-bottom: 12px; }
.page .prose h2 { font-size: 1.25rem; letter-spacing: -.01em; margin: 32px 0 8px; }
.page .prose p { color: var(--ink-2); }
.page .updated { color: var(--muted); font: 500 13px/1.6 var(--mono); margin-bottom: 28px; }
