/* =========================================================================
   CNGTX Global Website - MVP Design System (Apple Principles)
   Focus: Typography, Spacing, Minimalism, and Clean Contrasts
========================================================================= */

/* 1. CSS Reset & Base Variables */
:root {
  /* Colors */
  --color-bg-primary: #FFFFFF;     /* Brilliant White */
  --color-bg-secondary: #F5F5F7;   /* Apple Subtle Gray */
  --color-text-primary: #1D1D1F;   /* Deep Charcoal */
  --color-text-secondary: #86868B; /* Subtitle Gray */
  --color-accent: #0071E3;         /* Apple System Blue */
  --color-accent-hover: #0077ED;
  
  /* Surfaces */
  --surface-nav: rgba(255, 255, 255, 0.8);
  --surface-card: #FFFFFF;
  --shadow-subtle: 0px 4px 20px rgba(0, 0, 0, 0.05);
  
  /* Layout & Spacing */
  --max-width: 1200px;
  --spacing-xs: 8px;
  --spacing-sm: 16px;
  --spacing-md: 32px;
  --spacing-lg: 64px;
  --spacing-xl: 120px;
  --border-radius-card: 18px;
  --border-radius-btn: 999px; /* Pill shape */
  
  /* Typography */
  --font-family-en: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-family-zh: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

/* Base HTML reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  min-height: 100vh;
  /* Use language specific font-family fallbacks via generic declaration */
  font-family: var(--font-family-en);
  background-color: var(--color-bg-secondary);
  color: var(--color-text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Dynamic language styling for Chinese pages */
html[lang="zh-CN"] body {
  font-family: var(--font-family-zh);
}

/* 2. Typography Hierarchy (Apple Scale) */
h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -0.015em;
  margin-bottom: var(--spacing-sm);
  color: var(--color-text-primary);
}

h1 {
  font-size: clamp(3rem, 5vw, 5rem); /* Massive, bold editorials */
  line-height: 1.1;
  letter-spacing: -0.02em;
}

h2 {
  font-size: clamp(2rem, 3.5vw, 3rem);
  line-height: 1.15;
}

h3 {
  font-size: 1.5rem;
}

p {
  font-size: 1.0625rem; /* ~17px standard Apple body size */
  color: var(--color-text-secondary);
  max-width: 800px;
  margin-bottom: var(--spacing-md);
  line-height: 1.5;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  text-decoration: underline;
}

/* 3. Global Layout & Components */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

/* Navigation - Frosted Glass Sticky Header */
.global-nav {
  position: fixed;
  top: 0;
  width: 100%;
  height: 60px;
  background: var(--surface-nav);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  display: flex;
  align-items: center;
  z-index: 1000;
  transition: all 0.3s ease;
}

.nav-container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-logo {
  height: 40px; /* Increased for better visibility */
  object-fit: contain;
}

.nav-links {
  display: flex;
  gap: var(--spacing-md);
  list-style: none;
}

.nav-links a {
  color: var(--color-text-primary);
  font-size: 0.85rem;
  letter-spacing: -0.01em;
  font-weight: 500;
}

.nav-links a:hover {
  color: var(--color-accent);
  text-decoration: none;
}

/* Buttons */
.btn {
  display: inline-block;
  background-color: var(--color-accent);
  color: #fff;
  font-size: 1.0625rem;
  padding: 12px 24px;
  border-radius: var(--border-radius-btn);
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.btn:hover {
  background-color: var(--color-accent-hover);
  text-decoration: none;
  transform: scale(1.02);
}

.btn-secondary {
  background-color: transparent;
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
}

.btn-secondary:hover {
  background-color: var(--color-accent);
  color: #fff;
}

/* Section Spacing (Breathing Room) */
.section-pad {
  padding: var(--spacing-xl) 0;
}

.section-hero {
  padding-top: calc(60px + var(--spacing-xl)); /* clear fixed nav */
  text-align: center;
  background-color: var(--color-bg-secondary);
}

/* Premium Surface Cards */
.card {
  background-color: var(--surface-card);
  border-radius: var(--border-radius-card);
  padding: var(--spacing-md);
  box-shadow: var(--shadow-subtle);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  border: 1px solid rgba(0,0,0,0.03); /* Extremely subtle definition */
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0px 12px 30px rgba(0, 0, 0, 0.08);
}

/* Image scaling effect */
.product-image {
  width: 100%;
  border-radius: var(--border-radius-card);
  transition: transform 0.8s ease;
  overflow: hidden;
  background-color: white; /* Base for product photography */
}

.product-image img {
  width: 100%;
  height: auto;
  display: block;
  mix-blend-mode: multiply; /* Helps isolate white background logos/products */
}

/* Responsive Grid System */
.grid {
  display: grid;
  gap: var(--spacing-md);
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

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

/* Utility alignments */
.text-center { text-align: center; }
.margin-auto { margin: 0 auto; }

/* Hide hamburger button on desktop */
.nav-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
}

/* 4. Mobile Responsiveness */
@media (max-width: 1024px) {
  :root {
    --spacing-xl: 60px;
  }

  .nav-links {
    display: none;
  }

  .nav-menu-btn {
    display: block;
  }
}

/* 5. Documentation Style Layout (3-Column) */
.docs-layout {
  display: grid;
  grid-template-columns: 240px 1fr 240px;
  max-width: 1440px;
  margin: 0 auto;
  gap: var(--spacing-md);
  padding-top: 60px; /* clear fixed nav */
  align-items: start;
}

.docs-sidebar {
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  padding: var(--spacing-md) var(--spacing-sm);
  border-right: 1px solid rgba(0,0,0,0.05);
  background-color: var(--color-bg-secondary);
}

.docs-content {
  padding: var(--spacing-lg) var(--spacing-md);
  background-color: var(--color-bg-primary);
  min-height: 100vh;
}

.docs-toc {
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  padding: var(--spacing-md) var(--spacing-sm);
  border-left: 1px solid rgba(0,0,0,0.05);
}

/* 6. Article Components (CNGTX WeChat Mapping) */
.article-body {
  max-width: 677px;
  margin: 0 auto;
  padding: 0 15px;
  font-size: 1.125rem;
  line-height: 1.8;
  color: #333333;
}

/* Editor's Note (编者按) */
.editor-note {
  background-color: #f7f9fa;
  border-left: 4px solid #003366;
  padding: 20px 25px;
  margin-bottom: 40px;
  border-radius: 0 4px 4px 0;
  font-size: 1rem;
}

.editor-note strong {
  color: #003366;
}

/* Article Headings */
.article-h1 {
  font-size: 1.5rem;
  color: #003366;
  font-weight: 700;
  border-bottom: 2px solid #003366;
  padding-bottom: 12px;
  margin-top: var(--spacing-lg);
  margin-bottom: var(--spacing-md);
  display: inline-block;
}

/* Heading Badge (e.g., 2.1) */
.heading-badge {
  background-color: #003366;
  color: #ffffff;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 0.875rem;
  margin-right: 12px;
  font-weight: 700;
  vertical-align: middle;
}

/* Sidebar & TOC Navigation */
.sidebar-nav h4, .docs-toc h5 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-secondary);
  margin-bottom: var(--spacing-sm);
}

.sidebar-nav a, .docs-toc a {
  display: block;
  font-size: 0.9rem;
  padding: 6px 0;
  color: var(--color-text-primary);
  transition: color 0.2s;
}

.sidebar-nav a:hover, .docs-toc a:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.sidebar-nav a.active, .docs-toc a.active {
  color: var(--color-accent);
  font-weight: 600;
}

.back-link {
  font-weight: 600;
  margin-bottom: var(--spacing-md);
  color: var(--color-accent) !important;
}

/* Article Image Placeholders */
.img-placeholder {
  background-color: #f0f0f7;
  border: 1px dashed #ccc;
  border-radius: 12px;
  padding: 40px;
  margin: 40px 0;
  text-align: center;
  color: var(--color-text-secondary);
}

.img-placeholder span {
  display: block;
  font-size: 0.85rem;
  margin-top: 10px;
}

/* Responsive Docs Layout */
@media (max-width: 1200px) {
  .docs-layout {
    grid-template-columns: 240px 1fr;
  }
  .docs-toc {
    display: none;
  }
}

@media (max-width: 768px) {
  .docs-layout {
    grid-template-columns: 1fr;
  }
  .docs-sidebar {
    display: none; /* Mobile would use a toggle menu */
  }
  .docs-content {
    padding-left: 0;
    padding-right: 0;
  }
}
