/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #0ea5e9;
    --accent-color: #22c55e;
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --surface-light: #334155;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --gradient-start: #6366f1;
    --gradient-end: #0ea5e9;
    --code-bg: #1e293b;
    --code-border: #334155;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', Roboto, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

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

a:hover {
    color: var(--secondary-color);
}

code {
    font-family: 'Fira Code', 'Consolas', monospace;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--text-color);
}

.logo-icon {
    font-size: 1.5rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 32px;
}

.nav-links a {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

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

.nav-links a.nav-highlight {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    padding: 8px 16px;
    border-radius: 8px;
    color: white !important;
    font-weight: 600;
}

.nav-links a.nav-highlight:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Language Switch Button */
.lang-switch {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.lang-switch:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-github {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-color);
    padding: 8px 16px;
    border-radius: 8px;
    color: var(--text-color) !important;
    border: 1px solid var(--border-color);
}

.btn-github:hover {
    background: var(--surface-light);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Hero Section */
.hero {
    min-height: 100vh;
    padding: 120px 24px 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 60px;
    max-width: 1400px;
    margin: 0 auto;
    flex-wrap: wrap;
}

.hero-content {
    flex: 1;
    min-width: 300px;
    max-width: 600px;
}

.hero-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 24px;
}

.hero h1 {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--text-color), var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.5rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.highlight {
    color: var(--primary-light);
    font-weight: 600;
}

.hero-description {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 32px;
    line-height: 1.7;
}

.hero-buttons {
    display: flex;
    gap: 16px;
    margin-bottom: 48px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 1rem;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
    color: white;
}

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

.btn-secondary:hover {
    background: var(--surface-light);
    color: var(--text-color);
}

.btn-large {
    padding: 16px 32px;
    font-size: 1.1rem;
}

.hero-stats {
    display: flex;
    gap: 40px;
    flex-wrap: wrap;
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-light);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Hero Visual / Animation */
.hero-visual {
    flex: 1;
    min-width: 300px;
    max-width: 500px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.blocks-animation {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    align-items: center;
    position: relative;
}

.block {
    width: 140px;
    height: 100px;
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 500;
    transition: all 0.3s;
    animation: float 3s ease-in-out infinite;
}

.block:hover {
    border-color: var(--primary-light);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.2);
}

.block-1 { animation-delay: 0s; }
.block-2 { animation-delay: 0.5s; }
.block-3 { animation-delay: 1s; }

.block-icon {
    font-size: 2rem;
}

.connection {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.connection.vertical {
    position: absolute;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
}

.data-flow {
    width: 60px;
    height: 4px;
    background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end));
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}

.connection.vertical .data-flow {
    width: 4px;
    height: 40px;
    background: linear-gradient(180deg, var(--gradient-start), var(--gradient-end));
}

.data-flow::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
    animation: dataflow 1.5s infinite;
}

.connection-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes dataflow {
    0% { left: -100%; }
    100% { left: 200%; }
}

/* Respect user preferences for reduced motion */
@media (prefers-reduced-motion: reduce) {
    .block {
        animation: none;
    }
    
    .data-flow::after {
        animation: none;
    }
    
    .feature-card,
    .use-case-card,
    .lang-card,
    .step,
    .faq-item {
        transition: none;
    }
}

/* Sections Common Styles */
section {
    padding: 100px 24px;
}

.section-title {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 16px;
}

.section-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto 60px;
}

/* Features Section */
.features {
    background: var(--surface-color);
}

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

.feature-card {
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 32px;
    transition: all 0.3s;
}

.feature-card:hover {
    border-color: var(--primary-light);
    transform: translateY(-4px);
}

.feature-icon {
    font-size: 2.5rem;
    margin-bottom: 16px;
}

.feature-card h3 {
    font-size: 1.25rem;
    margin-bottom: 12px;
}

.feature-card p {
    color: var(--text-muted);
    line-height: 1.6;
}

/* How It Works Section */
.how-it-works {
    background: var(--background-color);
}

.architecture {
    margin-bottom: 60px;
}

.arch-diagram {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
}

.arch-layer {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    min-width: 250px;
    flex: 1;
    max-width: 350px;
}

.arch-layer h4 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--primary-light);
    font-size: 1.1rem;
}

.arch-box {
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 12px;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    text-align: center;
}

.arch-box.highlight-box {
    border-color: var(--primary-light);
    background: rgba(99, 102, 241, 0.1);
}

.arch-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 100px;
}

.arrow-line {
    width: 80px;
    height: 4px;
    background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end));
    border-radius: 2px;
    position: relative;
}

.arrow-line::after {
    content: '→';
    position: absolute;
    right: -20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5rem;
    color: var(--secondary-color);
}

.arrow-labels {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.arrow-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.arrow-label.request {
    color: var(--primary-light);
}

.arrow-label.response {
    color: var(--secondary-color);
}

/* Protocol Details */
.protocol-details h3 {
    text-align: center;
    margin-bottom: 32px;
    font-size: 1.5rem;
}

.protocol-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    max-width: 800px;
    margin: 0 auto;
}

.protocol-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
}

.protocol-card h4 {
    margin-bottom: 20px;
    color: var(--text-color);
}

.packet-structure {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.packet-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--background-color);
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.packet-field.payload {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary-light);
}

.field-name {
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
}

.field-type {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--surface-light);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Code Examples Section */
.examples {
    background: var(--surface-color);
}

.code-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.tab-btn {
    background: var(--background-color);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    border-color: var(--primary-light);
    color: var(--text-color);
}

.tab-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.code-panels {
    max-width: 800px;
    margin: 0 auto;
}

.code-panel {
    display: none;
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 12px;
    overflow: hidden;
}

.code-panel.active {
    display: block;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--code-border);
}

.code-filename {
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.code-lang {
    font-size: 0.75rem;
    color: var(--primary-light);
    background: rgba(99, 102, 241, 0.1);
    padding: 4px 10px;
    border-radius: 4px;
}

.code-panel pre {
    padding: 20px;
    overflow-x: auto;
    font-size: 0.9rem;
    line-height: 1.6;
}

.code-panel code {
    font-family: 'Fira Code', monospace;
}

/* Syntax Highlighting */
.keyword { color: #c678dd; }
.type { color: #e5c07b; }
.function { color: #61afef; }
.string { color: #98c379; }
.number { color: #d19a66; }
.comment { color: #5c6370; font-style: italic; }
.attribute { color: #56b6c2; }
.macro { color: #61afef; }

/* Use Cases Section */
.use-cases {
    background: var(--background-color);
}

.use-case-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.use-case-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 32px;
    transition: all 0.3s;
}

.use-case-card:hover {
    border-color: var(--primary-light);
}

.use-case-icon {
    font-size: 2.5rem;
    margin-bottom: 16px;
}

.use-case-card h3 {
    font-size: 1.25rem;
    margin-bottom: 12px;
}

.use-case-card p {
    color: var(--text-muted);
    margin-bottom: 16px;
}

.use-case-card ul {
    list-style: none;
    margin-bottom: 20px;
}

.use-case-card li {
    color: var(--text-muted);
    padding: 6px 0;
    padding-left: 20px;
    position: relative;
}

.use-case-card li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--primary-light);
}

.use-case-link {
    display: inline-block;
    color: var(--primary-light);
    font-weight: 500;
}

/* Getting Started Section */
.getting-started {
    background: var(--surface-color);
}

.steps {
    max-width: 700px;
    margin: 0 auto 60px;
}

.step {
    display: flex;
    gap: 24px;
    margin-bottom: 40px;
}

.step-number {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.step-content {
    flex: 1;
}

.step-content h3 {
    margin-bottom: 16px;
    font-size: 1.25rem;
}

.step-content p {
    color: var(--text-muted);
    margin-bottom: 16px;
}

.code-block {
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.code-block pre {
    padding: 16px;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.5;
}

.language-options {
    text-align: center;
}

.language-options h3 {
    margin-bottom: 32px;
    font-size: 1.5rem;
}

.lang-cards {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
}

.lang-card {
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 32px;
    width: 280px;
    text-align: center;
    transition: all 0.3s;
}

.lang-card:hover {
    border-color: var(--primary-light);
}

.lang-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.lang-card h4 {
    margin-bottom: 12px;
    font-size: 1.25rem;
}

.lang-card p {
    color: var(--text-muted);
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.lang-card a {
    font-weight: 500;
}

/* FAQ Section */
.faq {
    background: var(--background-color);
}

.faq-list {
    max-width: 800px;
    margin: 0 auto;
}

.faq-item {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    background: var(--surface-color);
}

.faq-question {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s;
}

.faq-question:hover {
    background: rgba(255, 255, 255, 0.02);
}

.faq-icon {
    font-size: 1.5rem;
    color: var(--primary-light);
    transition: transform 0.3s;
}

.faq-item.active .faq-icon {
    transform: rotate(45deg);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s;
}

.faq-item.active .faq-answer {
    max-height: 500px;
    padding: 0 24px 20px;
}

.faq-answer p {
    color: var(--text-muted);
    line-height: 1.7;
}

.faq-answer code {
    background: var(--background-color);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.9em;
}

/* CTA Section */
.cta {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    text-align: center;
    padding: 80px 24px;
}

.cta h2 {
    font-size: 2.5rem;
    margin-bottom: 16px;
}

.cta p {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 32px;
}

.cta-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.cta .btn-primary {
    background: white;
    color: var(--primary-dark);
}

.cta .btn-primary:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.cta .btn-secondary {
    background: transparent;
    border-color: white;
    color: white;
}

.cta .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Footer */
.footer {
    background: var(--surface-color);
    padding: 60px 24px;
    border-top: 1px solid var(--border-color);
}

.footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 24px;
}

.footer-content {
    text-align: left;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.footer-content p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.footer-credit {
    margin-top: 8px;
}

.footer-links {
    display: flex;
    gap: 24px;
}

.footer-links a {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.footer-links a:hover {
    color: var(--text-color);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--surface-color);
        flex-direction: column;
        padding: 24px;
        gap: 16px;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-links.active {
        display: flex;
    }

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

    .hero {
        padding-top: 100px;
        flex-direction: column;
        text-align: center;
    }

    .hero h1 {
        font-size: 2.5rem;
    }

    .hero-subtitle {
        font-size: 1.25rem;
    }

    .hero-buttons {
        justify-content: center;
    }

    .hero-stats {
        justify-content: center;
    }

    .section-title {
        font-size: 2rem;
    }

    .arch-diagram {
        flex-direction: column;
        align-items: center;
    }

    .arch-arrow {
        transform: rotate(90deg);
        margin: 20px 0;
    }

    .step {
        flex-direction: column;
        text-align: center;
    }

    .step-number {
        margin: 0 auto;
    }

    .footer .container {
        flex-direction: column;
        text-align: center;
    }
}
