/* ═══════════════════════════════════════════════
   QiGlobal Blog — Shared Stylesheet
   blog.qiglobal.co
   ═══════════════════════════════════════════════ */

/* ── Tokens ── */
:root {
  --green:       #214f3d;
  --green2:      #2b624c;
  --green-pale:  #eaf5ef;
  --green-mid:   rgba(33,79,61,.12);
  --cream:       #f5f0e8;
  --text:        #1d1d1f;
  --muted:       #6e6e73;
  --line:        #e5e5ea;
  --bg:          #f5f5f7;
  --card:        #ffffff;
  --soft:        #fafafc;
  --amber:       #b06020;
  --max-article: 720px;
  --max-site:    1100px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

/* ── Base ── */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
               Arial, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.75;
  /* Critical fix: prevent character-by-character wrapping */
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Chinese body gets slightly looser tracking */
:lang(zh) body, body.lang-zh {
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei",
               -apple-system, BlinkMacSystemFont, sans-serif;
  letter-spacing: .02em;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
button { font: inherit; cursor: pointer; }

/* ── Site header ── */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(245,245,247,.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.site-header .inner {
  max-width: var(--max-site);
  margin: auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 16px; color: var(--text);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.logo-box {
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--green);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-box svg { width: 16px; height: 16px; }
.header-nav {
  display: flex; gap: 24px; font-size: 14px; color: #444;
}
.header-nav a { color: #444; }
.header-nav a:hover { color: var(--green); text-decoration: none; }
.header-cta {
  padding: 7px 18px; border-radius: 999px;
  background: var(--green); color: #fff;
  font-size: 13px; font-weight: 600;
  white-space: nowrap;
}
.header-cta:hover { background: var(--green2); text-decoration: none; }
.lang-toggle {
  font-size: 13px; color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  background: #fff;
}
.lang-toggle:hover { border-color: var(--green); color: var(--green); text-decoration: none; }

/* ── Cover / Hero ── */
.cover {
  background: var(--green);
  color: #fff;
  padding: 80px 24px 72px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.cover::after {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.04'/%3E%3C/svg%3E");
  pointer-events: none;
}
.cover-inner { position: relative; z-index: 1; max-width: 800px; margin: auto; }
.series-tag {
  display: inline-block;
  padding: 5px 16px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.25);
  font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  color: rgba(255,255,255,.7);
  margin-bottom: 28px;
}
.cover h1 {
  font-size: clamp(32px, 5.5vw, 58px);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.1;
  color: #fff;
  /* Fix: ensure full width rendering */
  width: 100%;
  display: block;
}
.cover .deck {
  margin: 20px auto 0;
  max-width: 600px;
  font-size: clamp(16px, 2vw, 20px);
  color: rgba(255,255,255,.72);
  line-height: 1.6;
  /* Fix: ensure text wraps properly */
  width: 100%;
  display: block;
}
.cover-meta {
  margin-top: 32px;
  font-size: 13px; color: rgba(255,255,255,.45);
  display: flex; justify-content: center;
  gap: 6px 20px; flex-wrap: wrap;
}
.cover-meta span + span::before {
  content: '·'; margin-right: 20px; opacity: .5;
}

/* ── Article layout ── */
.article-wrap {
  max-width: var(--max-article);
  margin: 56px auto 100px;
  padding: 0 24px;
  /* Critical fix for Chinese text */
  width: 100%;
}

/* ── Cover image ── */
.cover-image {
  max-width: calc(var(--max-article) + 120px);
  margin: -1px auto 0;
}
.cover-image img {
  width: 100%;
  display: block;
}

/* ── Typography ── */
.article-wrap p {
  font-size: 17px;
  line-height: 1.9;
  color: #2c2c2e;
  margin-bottom: 26px;
  /* Fix: explicit width prevents single-char lines */
  width: 100%;
  display: block;
}
:lang(zh) .article-wrap p,
.lang-zh .article-wrap p {
  font-size: 17px;
  line-height: 2;
  letter-spacing: .03em;
}
.article-wrap h2 {
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.3;
  color: var(--text);
  margin: 56px 0 16px;
  width: 100%;
  display: block;
}
.article-wrap h3 {
  font-size: 19px; font-weight: 700;
  color: var(--text);
  margin: 32px 0 10px;
}

/* ── Pull quote ── */
.pull-quote {
  margin: 40px 0;
  padding: 26px 28px;
  border-left: 4px solid var(--green);
  background: var(--green-pale);
  border-radius: 0 16px 16px 0;
}
.pull-quote p {
  font-size: 20px !important;
  line-height: 1.65 !important;
  color: var(--green) !important;
  font-weight: 700;
  font-style: italic;
  letter-spacing: -.01em;
  margin: 0 !important;
}

/* ── Inline diagram / image ── */
.article-image {
  margin: 40px -24px;
  background: #fff;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.article-image img {
  width: 100%;
  display: block;
}
.article-image figcaption {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  padding: 12px 24px 16px;
}

/* ── Callout ── */
.callout {
  margin: 36px 0;
  padding: 22px 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.callout-label {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 10px; font-weight: 700;
}
.callout p {
  font-size: 15px !important;
  color: #444 !important;
  line-height: 1.75 !important;
  margin: 0 !important;
}

/* ── Numbered step list ── */
.step-list {
  margin: 28px 0;
  list-style: none;
  counter-reset: steps;
}
.step-list li {
  counter-increment: steps;
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 14px;
  align-items: start;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
  color: #2c2c2e;
  line-height: 1.75;
  /* Fix for Chinese list items */
  width: 100%;
}
.step-list li:last-child { border-bottom: none; }
.step-list li::before {
  content: counter(steps);
  width: 28px; height: 28px;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ── Key takeaway ── */
.takeaway {
  margin: 52px 0 0;
  padding: 30px;
  background: var(--green);
  border-radius: 20px;
  color: #fff;
}
.takeaway h3 {
  font-size: 20px; font-weight: 800;
  margin: 0 0 14px; color: #fff;
  width: 100%;
}
.takeaway p {
  font-size: 16px !important;
  color: rgba(255,255,255,.82) !important;
  line-height: 1.8 !important;
  margin: 0 0 10px !important;
  width: 100%;
}
.takeaway p:last-child { margin: 0 !important; }

/* ── Series navigation ── */
.series-nav {
  margin: 52px 0 0;
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
}
.series-nav > strong {
  display: block;
  font-size: 11px; text-transform: uppercase;
  letter-spacing: .1em; color: var(--muted);
  margin-bottom: 16px;
}
.series-list { display: flex; flex-direction: column; gap: 8px; }
.series-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--soft);
  font-size: 14px; color: #444;
  line-height: 1.5;
  width: 100%;
}
.series-item.current {
  background: var(--green-pale);
  border-color: rgba(33,79,61,.22);
  color: var(--green); font-weight: 600;
}
.series-num {
  width: 22px; height: 22px; border-radius: 999px;
  background: var(--line);
  font-size: 12px; font-weight: 700; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}
.series-item.current .series-num {
  background: var(--green); color: #fff;
}

/* ── Article CTA ── */
.article-cta {
  margin: 40px 0 0;
  text-align: center;
  padding: 40px 24px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 20px;
}
.article-cta h3 {
  font-size: 24px; font-weight: 800;
  letter-spacing: -.02em; margin: 0 0 10px;
}
.article-cta p {
  font-size: 16px !important;
  color: var(--muted) !important;
  margin: 0 0 22px !important;
  max-width: 480px;
  margin-left: auto !important;
  margin-right: auto !important;
}
.btn-primary {
  display: inline-block;
  padding: 13px 30px;
  background: var(--green); color: #fff;
  border-radius: 999px;
  font-weight: 700; font-size: 15px;
  border: none;
}
.btn-primary:hover { background: var(--green2); text-decoration: none; }

/* ── Divider ── */
hr.divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 44px 0;
}

/* ── Site footer ── */
.site-footer {
  background: var(--soft);
  border-top: 1px solid var(--line);
  padding: 48px 24px 64px;
}
.site-footer .inner {
  max-width: var(--max-site);
  margin: auto;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}
.footer-col strong {
  display: block;
  font-size: 11px; text-transform: uppercase;
  letter-spacing: .1em; color: #8a8a8f;
  margin-bottom: 12px;
}
.footer-col a,
.footer-col span {
  display: block;
  font-size: 14px; color: #515154;
  line-height: 1.6; margin-bottom: 6px;
}
.footer-col a:hover { color: var(--green); text-decoration: none; }
.footer-bottom {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px; color: var(--muted);
}
.footer-links { display: flex; gap: 20px; flex-wrap: wrap; }
.footer-links a { color: var(--muted); font-size: 13px; }
.footer-links a:hover { color: var(--green); text-decoration: none; }

/* ── Homepage: post list ── */
.page-hero {
  background: var(--green);
  padding: 72px 24px 64px;
  text-align: center;
  color: #fff;
}
.page-hero h1 {
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 800; letter-spacing: -.04em;
  line-height: 1.1; color: #fff;
  margin-bottom: 16px;
}
.page-hero p {
  font-size: clamp(16px, 2vw, 20px);
  color: rgba(255,255,255,.68);
  max-width: 540px; margin: 0 auto;
  line-height: 1.6;
}
.lang-tabs {
  display: flex; justify-content: center; gap: 10px;
  margin: 32px 24px 0;
}
.lang-tab {
  padding: 8px 22px; border-radius: 999px;
  font-size: 14px; font-weight: 600;
  border: 1px solid var(--line);
  background: #fff; color: #444;
  cursor: pointer;
}
.lang-tab.active {
  background: var(--green); color: #fff; border-color: var(--green);
}
.post-grid {
  max-width: var(--max-site);
  margin: 48px auto 80px;
  padding: 0 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}
.post-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: box-shadow .2s, transform .2s;
}
.post-card:hover {
  box-shadow: 0 8px 28px rgba(0,0,0,.08);
  transform: translateY(-2px);
  text-decoration: none;
}
.post-card-img {
  width: 100%; aspect-ratio: 16/9;
  object-fit: cover; display: block;
  background: var(--green);
}
.post-card-body { padding: 20px 22px 24px; flex: 1; display: flex; flex-direction: column; }
.post-card-tag {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--green); margin-bottom: 10px;
}
.post-card-title {
  font-size: 19px; font-weight: 800;
  letter-spacing: -.02em; line-height: 1.3;
  color: var(--text); margin-bottom: 10px;
  /* Fix */
  width: 100%; display: block;
}
.post-card-excerpt {
  font-size: 14px; color: var(--muted);
  line-height: 1.65; flex: 1;
  /* Fix */
  width: 100%; display: block;
}
.post-card-footer {
  margin-top: 18px;
  display: flex; justify-content: space-between;
  align-items: center; font-size: 13px; color: var(--muted);
}
.read-more {
  color: var(--green); font-weight: 600; font-size: 13px;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .header-nav { display: none; }
}
@media (max-width: 600px) {
  .article-wrap { padding: 0 18px; }
  .article-image { margin: 36px -18px; }
  .site-header .inner { padding: 0 18px; }
  .cover { padding: 60px 20px 52px; }
  .footer-grid { grid-template-columns: 1fr; }
  .footer-bottom { flex-direction: column; align-items: flex-start; }
  .step-list li { grid-template-columns: 28px 1fr; }
}
