/* ============================================
   Static Blog Posts — rag-style dark theme
   Shared styles for /static/blog/<slug>/index.html
   ============================================
   Each post sets its own accent via CSS variables:
     --cat-fg:    lighter tint   (e.g. #fcd34d)
     --cat-hi:    primary accent (e.g. #f59e0b)
     --cat-tint:  translucent bg (e.g. rgba(245,158,11,0.15))
     --cat-border:translucent bd (e.g. rgba(245,158,11,0.35))
   Defaults to the purple primary if unset.
   ============================================ */

:root {
    --cat-fg: #c4b5fd;
    --cat-hi: #8b5cf6;
    --cat-tint: rgba(139, 92, 246, 0.15);
    --cat-border: rgba(139, 92, 246, 0.35);
}

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

html { scroll-behavior: smooth; }

/* Body styles only apply when the post is loaded standalone (not via the
   Flask layout). The Flask static-post layout provides its own body styling. */
.static-post-body-default {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #0a0710;
    color: #cbd5e1;
    line-height: 1.75;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Legacy in-post back-nav (kept for fallback rendering) */
.back-nav {
    background: rgba(10, 7, 16, 0.92);
    border-bottom: 1px solid rgba(139, 92, 246, 0.18);
    backdrop-filter: blur(10px);
    padding: 14px 24px;
    font-size: 14px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.back-nav a {
    color: #94a3b8;
    text-decoration: none;
    transition: color 0.2s;
}
.back-nav a:hover { color: var(--cat-fg); }
.back-nav .sep { color: #475569; margin: 0 8px; }
/* Hide in-post back-nav when rendered inside the Flask layout
   (the layout provides its own back-to-blog bar). */
.static-post-layout .back-nav { display: none; }

/* ── Hero with ambient accent glow ── */
.hero {
    padding: 80px 24px 60px;
    text-align: center;
    position: relative;
    overflow: hidden;
    background: transparent;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 50% 0%, var(--cat-tint) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 30%, rgba(139, 92, 246, 0.08) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}
.hero-content { position: relative; z-index: 1; max-width: 820px; margin: 0 auto; }
.hero .category,
.hero .hero-badge {
    display: inline-block;
    background: var(--cat-tint);
    border: 1px solid var(--cat-border);
    color: var(--cat-fg);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    margin-bottom: 20px;
    backdrop-filter: none;
}
.hero h1 {
    font-size: clamp(1.8rem, 4.4vw, 2.9rem);
    line-height: 1.2;
    margin-bottom: 18px;
    font-weight: 800;
    color: #f5f3ff;
    letter-spacing: -0.02em;
}
.hero .subtitle,
.hero .hero-sub {
    font-size: 1.12rem;
    color: #94a3b8;
    max-width: 680px;
    margin: 0 auto 24px;
    font-style: italic;
    line-height: 1.6;
}
.hero .meta,
.hero .hero-meta {
    display: flex;
    justify-content: center;
    gap: 18px;
    flex-wrap: wrap;
    font-size: 0.88rem;
    color: #94a3b8;
}
.hero .meta span,
.hero .hero-meta span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

/* ── Content wrapper: white "card" with rounded corners + shadow,
      lifted up so it overlaps the bottom of the dark hero. Bottom margin
      gives breathing room before the dark footer. ── */
.content-wrapper,
.content {
    background: #ffffff;
    color: #1f2937;
    padding: 56px 56px 64px;
    position: relative;
    max-width: 920px;
    margin: -40px auto 80px;
    border-radius: 24px;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45),
                0 8px 32px rgba(0, 0, 0, 0.35),
                0 -1px 0 rgba(255, 255, 255, 0.04) inset;
    z-index: 2;
}
.content-wrapper > *,
.content > * {
    max-width: 760px;
    margin-left: auto;
    margin-right: auto;
}
@media (max-width: 768px) {
    .content-wrapper, .content { padding: 40px 22px 48px; }
}

/* ── WCAG overrides for legacy dark-theme component colors ──
   The static posts inherited tinted "card" components designed for a dark page
   background (light-gray text on rgba dark fills). Now that the body is a
   white card, those colors fail contrast. Two-class selectors beat the
   single-class inline rules in each post, so order vs the inline <style> is
   not the deciding factor here.
*/
.content-wrapper .comparison-card p,
.content-wrapper .arch-layer .layer-content,
.content-wrapper .complexity-phase .phase-detail,
.content-wrapper .complexity-phase .phase-label,
.content-wrapper .trajectory-row .action,
.content-wrapper .trajectory-result .result-label,
.content-wrapper .insight-card p,
.content-wrapper .insight-card .insight-quote,
.content-wrapper .insight-card,
.content-wrapper .insight-card h3,
.content-wrapper .pattern-card p,
.content-wrapper .pattern-card,
.content-wrapper .summary-block,
.content-wrapper .feedback-block,
.content-wrapper .feedback-block p,
.content-wrapper .genie-box,
.content-wrapper .genie-box p,
.content-wrapper .genie-box h3,
.content-wrapper .failure-card,
.content-wrapper .failure-card p,
.content-wrapper .failure-card h4,
.content-wrapper .ladder-step .step-desc,
.content-wrapper .implication-card .body,
.content-wrapper .math-body,
.content-wrapper .math-formula,
.content-wrapper .math-formula .fn,
.content-wrapper .math-worked .math-step {
    color: #1f2937;
}
.content-wrapper .comparison-card.static h4 { color: #5b21b6; }
.content-wrapper .comparison-card.dynamic h4 { color: #047857; }
.content-wrapper .trajectory-example h4 { color: #0e7490; }
.content-wrapper .trajectory-result .result-value { color: #5b21b6; }
.content-wrapper .loop-diagram h4 { color: #5b21b6; }
.content-wrapper .failure-card.over h4 { color: #5b21b6; }
.content-wrapper .failure-card.under h4 { color: #9d174d; }
.content-wrapper .failure-card .stat { color: #475569; }
.content-wrapper .ladder-step .step-quote { color: #5b21b6; }
.content-wrapper .ladder-step .human-role { color: #5b21b6; }
.content-wrapper .genie-box .genie-quote {
    background: rgba(6, 182, 212, 0.10);
    color: #0f172a;
}
.content-wrapper .genie-flow .flow-step { color: #155e75; }
.content-wrapper .genie-flow .flow-arrow { color: #475569; opacity: 1; }
.content-wrapper .adjust-labels { color: #475569; }
.content-wrapper .implication-card h4 { color: #047857; }
.content-wrapper .math-section h4 { color: #5b21b6; }
.content-wrapper .math-label { color: #5b21b6; }
.content-wrapper .math-worked .math-label { color: #5b21b6; }
.content-wrapper .back-nav span[style*="color: #94a3b8"] { color: #475569 !important; }

/* ── Typography (light theme) ── */
.blog-content,
.blog-content p {
    font-size: 1.06rem;
    line-height: 1.8;
    color: #1f2937;
}
.blog-content > *:first-child { margin-top: 0; }
.blog-content p { margin-bottom: 1.25rem; }

.blog-content .lead {
    font-size: 1.18rem;
    color: #0f172a;
    border-left: 3px solid var(--cat-hi);
    padding: 14px 20px;
    margin-bottom: 1.8rem;
    font-style: italic;
    background: var(--cat-tint);
    border-radius: 0 10px 10px 0;
}

.blog-content h2 {
    font-size: clamp(1.4rem, 2.8vw, 1.75rem);
    margin: 2.5rem 0 1rem;
    color: #0f172a;
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.25;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
}
.blog-content h2:first-of-type { margin-top: 1rem; }
.blog-content h3 {
    font-size: 1.3rem;
    margin: 2rem 0 0.75rem;
    color: #1e293b;
    font-weight: 700;
}
.blog-content h4 {
    font-size: 1.1rem;
    margin: 1.5rem 0 0.5rem;
    color: #0f172a;
    font-weight: 700;
}

.blog-content ul,
.blog-content ol {
    margin: 0 0 1.25rem 1.25rem;
    padding-left: 0.5rem;
}
.blog-content li { margin-bottom: 0.5rem; color: #1f2937; }
.blog-content strong { color: #0f172a; font-weight: 700; }
.blog-content em { color: #1e293b; }

.blog-content a {
    color: var(--cat-hi);
    text-decoration: none;
    border-bottom: 1px solid var(--cat-border);
    transition: color 0.2s, border-color 0.2s;
}
.blog-content a:hover {
    color: var(--cat-hi);
    border-bottom-color: var(--cat-hi);
}

.blog-content blockquote {
    border-left: 4px solid #06b6d4;
    background: #f0fbfc;
    padding: 16px 22px;
    margin: 2rem 0;
    border-radius: 0 12px 12px 0;
    font-style: italic;
    color: #0f172a;
    font-size: 1.02rem;
}
.blog-content blockquote p:last-child { margin-bottom: 0; }

.blog-content code {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    padding: 0.12rem 0.45rem;
    border-radius: 6px;
    font-size: 0.9em;
    color: #0891b2;
    font-family: 'SF Mono', Menlo, Consolas, 'JetBrains Mono', monospace;
}
.blog-content pre {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 12px;
    padding: 18px 22px;
    overflow-x: auto;
    margin: 1.75rem 0;
    color: #e2e8f0;
    font-size: 0.9rem;
    line-height: 1.6;
    font-family: 'SF Mono', Menlo, Consolas, 'JetBrains Mono', monospace;
}
.blog-content pre code {
    background: transparent;
    border: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.blog-content img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 1.5rem 0;
    border: 1px solid #e2e8f0;
}

.blog-content hr {
    border: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, #cbd5e1, transparent);
    margin: 2.5rem 0;
}

/* ── Tables (light theme) ── */
.blog-content table,
.comparison-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.75rem 0;
    font-size: 0.95rem;
    background: #ffffff;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}
.blog-content th, .blog-content td,
.comparison-table th, .comparison-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    color: #1f2937;
}
.blog-content th,
.comparison-table th {
    background: #f8fafc;
    color: #0f172a;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.2px;
}
.comparison-table tr:last-child td { border-bottom: none; }

/* ── Callouts (accent variants, light theme) ── */
.callout {
    background: var(--cat-tint);
    border-left: 4px solid var(--cat-hi);
    padding: 18px 22px;
    margin: 1.8rem 0;
    border-radius: 0 12px 12px 0;
    color: #1f2937;
}
.callout p { margin: 0 0 0.4rem; }
.callout p:last-child { margin-bottom: 0; }
.callout strong { color: #0f172a; }
.callout-title { font-weight: 700; color: var(--cat-hi); margin-bottom: 6px; font-size: 0.92rem; text-transform: uppercase; letter-spacing: 0.4px; }

.callout.green,
.callout-success {
    background: #ecfdf5;
    border-left-color: #10b981;
}
.callout.green strong,
.callout-success strong { color: #065f46; }

.callout.amber,
.callout-warn {
    background: #fffbeb;
    border-left-color: #f59e0b;
}
.callout.amber strong,
.callout-warn strong { color: #92400e; }

.callout.blue,
.callout-info {
    background: #eff6ff;
    border-left-color: #60a5fa;
}
.callout.blue strong,
.callout-info strong { color: #1e40af; }

.callout.cyan {
    background: #ecfeff;
    border-left-color: #06b6d4;
}
.callout.cyan strong { color: #155e75; }

.callout.rose {
    background: #fdf2f8;
    border-left-color: #f472b6;
}
.callout.rose strong { color: #9d174d; }

/* ── Tool / info cards (light theme) ── */
.tool-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 3px solid var(--cat-hi);
    border-radius: 10px;
    padding: 16px 20px;
    margin: 14px 0;
    transition: background 0.2s, border-color 0.2s;
}
.tool-card:hover {
    background: var(--cat-tint);
    border-color: var(--cat-border);
    border-left-color: var(--cat-hi);
}
.tool-card .name {
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 1rem;
    font-weight: 700;
    color: var(--cat-hi);
}
.tool-card .desc {
    font-size: 0.95rem;
    color: #1f2937;
    margin-top: 4px;
    line-height: 1.6;
}

/* ── ASCII / pre-formatted diagrams ── */
.diagram {
    background: #13101a;
    color: #e2e8f0;
    padding: 22px 24px;
    border-radius: 12px;
    margin: 1.75rem 0;
    font-family: 'SF Mono', Menlo, Consolas, 'JetBrains Mono', monospace;
    font-size: 0.88rem;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre;
    border: 1px solid rgba(139, 92, 246, 0.22);
}
.diagram .hl { color: #c4b5fd; }
.diagram .green { color: #6ee7b7; }
.diagram .amber { color: #fcd34d; }
.diagram .red { color: #fca5a5; }
.diagram .cyan { color: #67e8f9; }
.diagram .blue { color: #93c5fd; }

/* ── Sequence steps (numbered) ── */
.sequence-step {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin: 12px 0;
}
.sequence-step .num {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--cat-tint);
    border: 1px solid var(--cat-border);
    color: var(--cat-fg);
    font-size: 0.82rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}
.sequence-step .text {
    font-size: 1rem;
    color: #1f2937;
    line-height: 1.65;
}

/* ── GitHub / primary button ── */
.github-link,
.btn-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--cat-tint);
    color: var(--cat-fg);
    border: 1px solid var(--cat-border);
    padding: 12px 24px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    margin: 16px 0;
    transition: background 0.2s, transform 0.2s, border-color 0.2s, color 0.2s;
}
.github-link:hover,
.btn-cta:hover {
    background: var(--cat-hi);
    border-color: var(--cat-hi);
    color: #f5f3ff;
    transform: translateY(-1px);
}

/* ── CTA section ── */
.cta-section {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.18) 0%, rgba(6, 182, 212, 0.08) 100%);
    border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: 16px;
    padding: 32px 30px;
    text-align: center;
    margin: 2.5rem 0 1rem;
    color: #1f2937;
}
.cta-section h3 {
    color: #0f172a;
    margin: 0 0 10px;
    font-size: 1.3rem;
    font-weight: 800;
}
.cta-section p {
    color: #1f2937;
    font-size: 1.05rem;
    margin: 0 0 18px;
}
.cta-section a:not(.btn-cta) {
    display: inline-block;
    background: #8b5cf6;
    color: #f5f3ff;
    padding: 12px 28px;
    border-radius: 10px;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.2s, transform 0.2s;
}
.cta-section a:not(.btn-cta):hover {
    background: #a78bfa;
    transform: translateY(-1px);
}

/* ── Stats grid ── */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
    margin: 1.8rem 0;
}
.stat {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px 16px;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
}
.stat:hover {
    background: var(--cat-tint);
    border-color: var(--cat-border);
}
.stat-value {
    font-size: 1.9rem;
    font-weight: 800;
    color: var(--cat-hi);
    line-height: 1;
}
.stat-label {
    font-size: 0.72rem;
    color: #64748b;
    margin-top: 8px;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    font-weight: 600;
}

/* ── Tags (light theme) ── */
.tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 1.5rem 0;
}
.tag,
.article-tag-pill {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #b45309;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}
.tag:hover,
.article-tag-pill:hover {
    background: #fef3c7;
    border-color: #d97706;
    color: #92400e;
}

/* ── References (light theme) ── */
.references,
.references-section {
    margin-top: 3rem;
    padding: 28px 28px 22px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 16px;
}
.references h3,
.references-section h2,
.references-section h3 {
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: #b45309;
    margin: 0 0 18px;
    border: none;
    padding: 0;
}
.references ol,
.references-section ol {
    list-style: none;
    counter-reset: ref;
    margin: 0;
    padding: 0;
}
.references li,
.references-section li {
    counter-increment: ref;
    padding: 8px 0 8px 2rem;
    font-size: 0.95rem;
    color: #1f2937;
    border-bottom: 1px solid #fde68a;
    line-height: 1.6;
    position: relative;
}
.references li:last-child,
.references-section li:last-child { border-bottom: none; }
.references li::before,
.references-section li::before {
    content: '[' counter(ref) ']';
    position: absolute;
    left: 0;
    font-weight: 800;
    color: #b45309;
    font-size: 0.9rem;
}
.references li a,
.references-section li a {
    color: #1f2937;
    text-decoration: none;
    border-bottom: 1px solid #fde68a;
    transition: color 0.2s, border-color 0.2s;
    word-break: break-word;
}
.references li a:hover,
.references-section li a:hover {
    color: #b45309;
    border-bottom-color: #d97706;
}
.references li strong,
.references-section li strong { color: #0f172a; }

/* Reference superscripts (inline [1], [2], etc.) — light theme */
.ref-link,
.reference-link {
    color: #b45309;
    text-decoration: none;
    font-weight: 700;
    vertical-align: super;
    font-size: 0.75em;
    padding: 1px 4px;
    border-radius: 3px;
    background: #fffbeb;
    margin: 0 1px;
    border: 1px solid #fde68a;
}
.ref-link:hover,
.reference-link:hover {
    background: #fef3c7;
    color: #92400e;
    border-color: #d97706;
}

/* ── Image blocks (light theme) ── */
.img-block {
    margin: 1.8rem 0;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
}
.img-block img {
    width: 100%;
    display: block;
    margin: 0;
    border-radius: 0;
    border: none;
}
.img-block .caption {
    padding: 12px 16px;
    font-size: 0.86rem;
    color: #64748b;
    font-style: italic;
    border-top: 1px solid #e2e8f0;
    background: #ffffff;
}
.img-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin: 1.8rem 0;
}
.img-compare .img-block { margin: 0; }
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    margin: 1.8rem 0;
}
.gallery .img-block { margin: 0; }
.video-block {
    margin: 1.8rem 0;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #0f172a;
}
.video-block video { width: 100%; display: block; }
.video-block .caption {
    padding: 12px 16px;
    font-size: 0.86rem;
    color: #64748b;
    font-style: italic;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
}

/* ── Previous / Next post nav (used by static_post_layout.html) ──
   Wrapped in a slim white card that matches the main content-wrapper's width
   and corner radius, so it reads as a continuation of the article card. */
.post-nav-wrapper {
    background: #ffffff;
    color: #1f2937;
    max-width: 920px;
    margin: -60px auto 80px;
    padding: 28px 56px 32px;
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    position: relative;
    z-index: 2;
}
.post-nav {
    max-width: 760px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.post-nav a {
    display: block;
    padding: 20px 22px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    text-decoration: none;
    transition: transform 0.2s, border-color 0.2s, background 0.2s;
}
.post-nav a:hover {
    transform: translateY(-2px);
    background: #f5f3ff;
    border-color: #c4b5fd;
}
.post-nav small {
    display: block;
    color: #7c3aed;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 8px;
}
.post-nav h6 {
    color: #1f2937;
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.4;
}
.post-nav a:hover h6 { color: #0f172a; }
.post-nav__placeholder {
    background: transparent;
    border: 1px dashed #e2e8f0;
    border-radius: 14px;
}
@media (max-width: 600px) {
    .post-nav { grid-template-columns: 1fr; }
}

/* ── Footer (light theme) ── */
.blog-footer {
    max-width: 820px;
    margin: 0 auto 60px;
    padding: 30px 24px;
    font-size: 0.86rem;
    color: #64748b;
    border-top: 1px solid #e2e8f0;
    text-align: center;
}
.blog-footer a { color: var(--cat-hi); text-decoration: none; transition: color 0.2s; }
.blog-footer a:hover { color: var(--cat-fg); }

/* ── Responsive ── */
@media (max-width: 768px) {
    .hero { padding: 60px 20px 40px; }
    .hero h1 { font-size: clamp(1.6rem, 6vw, 2.1rem); }
    .content-wrapper,
    .content { padding: 30px 18px 50px; }
    .blog-content { font-size: 1rem; }
    .img-compare { grid-template-columns: 1fr; }
    .stats { grid-template-columns: repeat(2, 1fr); }
}
