/* ==========================================================================
   AUTOFLOWSTACK: HIGH-PERFORMANCE STATIC BLOG ENGINE (CLOUDFLARE PAGES)
   Core Web Vitals: 99+ Mobile, Zero Bloat, Pre-Engineered AdSense Zones
   ========================================================================== */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-body: #334155;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-code: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
}

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

body {
    font-family: var(--font-stack);
    background-color: var(--bg-main);
    color: var(--text-body);
    line-height: 1.75;
    font-size: 17px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

.site-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header & Navigation */
header.site-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.brand-logo a {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.5px;
}
.brand-logo a span { color: var(--primary); }

nav.nav-menu ul {
    display: flex;
    list-style: none;
    gap: 22px;
}
nav.nav-menu a {
    font-size: 15px;
    font-weight: 600;
    color: #475569;
}
nav.nav-menu a:hover { color: var(--primary); text-decoration: none; }

/* Ad Unit Containers */
.ad-slot {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f1f5f9;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    margin: 28px 0;
    overflow: hidden;
    text-align: center;
    font-size: 12px;
    color: #94a3b8;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.ad-header-banner { max-width: 728px; height: 90px; margin: 18px auto; }
.ad-in-article { min-height: 250px; width: 100%; }
.ad-sidebar-sticky { position: sticky; top: 90px; min-height: 600px; max-width: 300px; margin: 20px auto; }
.ad-multiplex-grid { min-height: 200px; width: 100%; margin: 36px 0; }

/* Layout Grid */
.layout-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 40px;
    margin: 32px 0 60px;
}

@media (max-width: 920px) {
    .layout-grid { grid-template-columns: 1fr; }
    .ad-sidebar-sticky { position: static; }
}

/* Article Page */
main.main-content {
    background: #ffffff;
    border-radius: 12px;
    padding: 44px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

@media (max-width: 600px) {
    main.main-content { padding: 22px; }
}

h1.article-title {
    font-size: 34px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.25;
    letter-spacing: -0.6px;
    margin-bottom: 16px;
}

.article-meta {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.tag-badge {
    background: #e0f2fe;
    color: #0369a1;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
}

.article-body h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
    margin: 38px 0 16px;
    border-bottom: 2px solid var(--border-light);
    padding-bottom: 8px;
    letter-spacing: -0.3px;
}

.article-body h3 {
    font-size: 19px;
    font-weight: 700;
    color: #1e293b;
    margin: 28px 0 12px;
}

.article-body p { margin-bottom: 20px; }
.article-body ul, .article-body ol { margin: 16px 0 24px 28px; }
.article-body li { margin-bottom: 8px; }

/* Tables */
.table-wrapper {
    overflow-x: auto;
    margin: 28px 0;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
table.styled-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 15px;
    background: #ffffff;
}
table.styled-table th {
    background: #f8fafc;
    color: var(--text-main);
    font-weight: 700;
    padding: 14px 18px;
    border-bottom: 2px solid var(--border-color);
}
table.styled-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-light);
}
table.styled-table tr:hover { background-color: #f8fafc; }

/* Code Blocks */
pre {
    background: #0f172a;
    color: #f8fafc;
    padding: 18px 22px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: var(--font-code);
    font-size: 14px;
    line-height: 1.6;
    margin: 24px 0;
}
code {
    font-family: var(--font-code);
    font-size: 14px;
    background: #f1f5f9;
    color: #0f172a;
    padding: 2px 6px;
    border-radius: 4px;
}
pre code { background: none; color: inherit; padding: 0; }

/* Callout Boxes */
.pro-tip {
    background: var(--primary-light);
    border-left: 4px solid var(--primary);
    padding: 18px 22px;
    border-radius: 0 8px 8px 0;
    margin: 26px 0;
    color: #1e40af;
}
.pro-tip strong { color: #1e3a8a; }

.alert-box {
    background: #fef2f2;
    border-left: 4px solid #ef4444;
    padding: 18px 22px;
    border-radius: 0 8px 8px 0;
    margin: 26px 0;
    color: #991b1b;
}

/* Sidebar Widgets */
aside.site-sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.sidebar-widget {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
}
.author-card { text-align: center; }
.author-avatar {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: #e2e8f0;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}
.author-card h4 { font-size: 17px; font-weight: 700; color: var(--text-main); margin-bottom: 4px; }
.author-card p { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* Homepage Grid */
.hero-section {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 48px;
    margin: 32px 0 40px;
    text-align: center;
}
.hero-section h1 {
    font-size: 38px;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.8px;
    margin-bottom: 12px;
}
.hero-section p {
    font-size: 18px;
    color: var(--text-muted);
    max-width: 680px;
    margin: 0 auto;
}

.article-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 28px;
    margin-bottom: 60px;
}
.card-item {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 28px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.05);
}
.card-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.35;
    margin: 12px 0;
}
.card-excerpt {
    font-size: 15px;
    color: var(--text-muted);
    margin-bottom: 16px;
    line-height: 1.6;
}

/* Footer */
footer.site-footer {
    background: #0f172a;
    color: #94a3b8;
    padding: 48px 0;
    font-size: 14px;
    border-top: 1px solid #1e293b;
}
.footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}
.footer-links a { color: #cbd5e1; margin-left: 20px; }
.footer-links a:hover { color: #ffffff; }
