/* =========================================
   1. CORE VARIABLES & DESIGN SYSTEM
   ========================================= */
:root {
    /* 60% - Base Backgrounds */
    --bg-beige: #F3EDE1;
    --bg-white: #FFFFFF;
    
    /* 30% - Branding */
    --brand-dark-blue: #2A58B6;
    --brand-vivid-blue: #2264EB;
    --brand-vivid-blue-light: rgba(34, 100, 235, 0.1);

    /* 10% - Accent/Conversion */
    --accent-terracotta: #FF6B35;
    --accent-terracotta-hover: #E55A2B;

    /* Typography & Neutrals */
    --text-main: #1F1F1F;
    --text-muted: #555555;
    --border-color: #E0E0E0;

    /* Fonts */
    /* --font-head: 'Plus Jakarta Sans', sans-serif; */
    /* --font-body: 'Inter', sans-serif; */
    --font-head: 'Lora', sans-serif;
    --font-body: 'Public Sans', sans-serif;

    /* Layout & Effects */
    --container-width: 1200px;
    --header-height: 80px;
    --radius-sm: 8px;
    --radius-md: 16px;
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 10px 30px rgba(42, 88, 182, 0.15);
}

/* =========================================
   2. GLOBAL RESET & BASE STYLES
   ========================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    background-color: var(--bg-beige);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Accessibility Focus */
*:focus-visible {
    outline: 3px solid var(--brand-vivid-blue);
    outline-offset: 2px;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-head);
    color: var(--brand-dark-blue);
    line-height: 1.25;
    margin-bottom: 1rem;
}

h3.subtle-subheader {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-family: var(--font-body);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-weight: normal;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s ease;
}

ul { list-style: none; }

/* =========================================
   3. UTILITIES & BUTTONS
   ========================================= */
.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 20px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-family: var(--font-body);
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    font-size: 1rem;
}

.btn-primary {
    background-color: var(--brand-vivid-blue);
    color: white;
}
.btn-primary:hover {
    background-color: var(--brand-dark-blue);
    transform: translateY(-2px);
}

.btn-cta {
    background-color: var(--accent-terracotta);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
}
.btn-cta:hover {
    background-color: var(--accent-terracotta-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.4);
}

/* -----------------------------------------------------------
TAG STYLES
----------------------------------------------------------- */

/* Container to hold multiple tags */
.tag-group {
    display: flex;
    flex-wrap: wrap; /* Allows tags to drop to next line */
    gap: 8px;        /* Consistent space between tags */
    margin-bottom: 1rem;
}

/* Updated Tag Element */
.tag {
    display: inline-block; 
    padding: 4px 10px; 
    border-radius: 4px;
    font-size: 0.7rem; /* Slightly smaller to accommodate multiple */
    font-weight: 700; 
    text-transform: uppercase;
    letter-spacing: 0.5px; 
    
    /* Theme Colors */
    background-color: var(--brand-vivid-blue-light);
    color: var(--brand-dark-blue); 
    border: 1px solid rgba(34, 100, 235, 0.1); /* Subtle border for definition */
    
    /* Remove bottom margin here, let the .tag-group handle it */
    margin-bottom: 0; 
    white-space: nowrap; /* Prevents text inside a single tag from breaking */
}

/* Optional: Different color for specific tag types (e.g., 'New') */
.tag.secondary {
    background-color: #FFF4E5;
    color: var(--accent-terracotta);
    border-color: rgba(255, 107, 53, 0.2);
}

/* =========================================
   4. NAVIGATION
   ========================================= */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(243, 237, 225, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    height: var(--header-height);
    display: flex;
    align-items: center;
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.logo {
    font-family: var(--font-head);
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--brand-dark-blue);
    display: flex;
    align-items: center;
    gap: 8px;
}
.logo span { color: var(--brand-vivid-blue); }

.nav-links { display: flex; gap: 2rem; }
.nav-links a { font-weight: 500; color: var(--text-main); font-size: 0.95rem; }
.nav-links a:hover, .nav-links a.active { color: var(--brand-vivid-blue); }

/* =========================================
   5. HERO SECTIONS (Home, Inner, Article)
   ========================================= */
/* Common Neuro Canvas */
#neuro-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.6;
}

/* Homepage Hero */
.hero {
    position: relative;
    padding: 5rem 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    min-height: 80vh;
}
.hero-content { position: relative; z-index: 1; max-width: 600px; }
.hero h1 { font-size: 3.5rem; font-weight: 800; letter-spacing: -0.02em; }
.hero p { font-size: 1.25rem; color: var(--text-muted); margin-bottom: 2rem; max-width: 90%; }

/* Inner Page Hero (Blog/White Papers) */
.page-hero {
    position: relative;
    padding: 5rem 0 3rem 0;
    overflow: hidden;
}
.page-hero-content {
    position: relative; z-index: 1;
    display: flex; flex-direction: column; align-items: center; text-align: center;
    max-width: 800px; margin: 0 auto;
}
.page-hero h1 { font-size: 3rem; font-weight: 800; }
.page-hero p { font-size: 1.125rem; color: var(--text-muted); max-width: 600px; margin-bottom: 2rem; }

/* Article/Post Hero */
.article-hero {
    position: relative;
    padding: 6rem 0 4rem 0;
    overflow: hidden;
}
.article-hero h1 { font-size: 3rem; font-weight: 800; margin-bottom: 1.5rem; letter-spacing: -0.02em; }

/* =========================================
   6. COMPONENTS (Cards, Grids, Forms)
   ========================================= */

/* --- Email Capture --- */
.email-capture { 
    display: flex; 
    gap: 10px; 
    max-width: 450px; 
    position: relative; /* Critical for absolute positioning of feedback */
    margin-bottom: 2rem; /* Ensure space below for the floating message */
}
.email-capture input {
    flex: 1; padding: 1rem; border-radius: 50px; border: 2px solid #ddd;
    font-family: var(--font-body); font-size: 1rem; transition: border-color 0.3s;
}
.email-capture input:focus { border-color: var(--brand-vivid-blue); outline: none; }

/* --- New Form Feedback Styles --- */
.form-feedback {
    position: absolute;
    top: 100%; /* Push exactly below the input */
    left: 0;
    width: 100%;
    margin-top: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.3s ease;
    pointer-events: none;
    text-align: left;
    padding-left: 1rem; /* Align with input text */
}

.form-feedback.active {
    opacity: 1;
    transform: translateY(0);
}

.form-feedback.success {
    color: #27ae60; /* Success Green - Clean & Professional */
}

.form-feedback.error {
    color: var(--accent-terracotta); /* Using your brand error/accent color */
}

/* --- Subscribe Modal --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(31, 31, 31, 0.7); /* Dark overlay */
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal-content {
    background: var(--bg-white);
    padding: 3rem;
    border-radius: var(--radius-md);
    width: 90%; max-width: 500px;
    position: relative;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    transform: translateY(20px); transition: transform 0.3s ease;
    border: 1px solid var(--border-color);
}
.modal-overlay.active .modal-content { transform: translateY(0); }

.modal-close-btn {
    position: absolute; top: 15px; right: 15px;
    background: none; border: none; font-size: 1.5rem;
    color: var(--text-muted); cursor: pointer;
    line-height: 1; padding: 5px;
}
.modal-close-btn:hover { color: var(--brand-dark-blue); }

.modal-content h3 { font-size: 1.75rem; margin-bottom: 0.5rem; color: var(--brand-dark-blue); }
.modal-content p { color: var(--text-muted); margin-bottom: 2rem; font-size: 1rem; }

/* Modal specific form overrides */
.modal-content .email-capture { 
    max-width: 100%; 
    flex-direction: column; 
    gap: 1rem; 
    margin-bottom: 0; /* Reset margin inside modal */
}
.modal-content .email-capture button { width: 100%; }

/* In Modal, feedback shouldn't be absolute because flex-col handles height gracefully */
.modal-content .form-feedback {
    position: relative;
    top: auto;
    left: auto;
    text-align: center;
    padding-left: 0;
    margin-top: 0;
    height: 0; /* Animate height to avoid jumpiness */
    overflow: hidden;
}
.modal-content .form-feedback.active {
    height: auto;
    margin-top: 10px;
}

/* --- Search Bar --- */
.search-container { width: 100%; max-width: 500px; position: relative; margin-bottom: 2rem; }
.search-input {
    width: 100%; padding: 16px 24px; padding-right: 60px;
    border-radius: 50px; border: 1px solid #ccc;
    font-family: var(--font-body); font-size: 1rem;
    background: rgba(255,255,255,0.8); backdrop-filter: blur(5px); transition: all 0.3s;
}
.search-input:focus { border-color: var(--brand-vivid-blue); background: white; outline: none; }
.search-btn {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    width: 40px; height: 40px; border-radius: 50%; border: none;
    background: var(--brand-vivid-blue); color: white;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
}

/* --- Filter Pills --- */
.filter-bar { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 2rem; }
.filter-pill {
    padding: 8px 16px; border-radius: 50px; border: 1px solid var(--border-color);
    background: rgba(255,255,255,0.6); color: var(--text-muted);
    font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.filter-pill:hover { border-color: var(--brand-dark-blue); color: var(--brand-dark-blue); }
.filter-pill.active { background: var(--brand-dark-blue); color: white; border-color: var(--brand-dark-blue); }

/* --- Bento Grid & Blog Cards --- */
.bento-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 24px; padding: 3rem 0;
}
.card {
    background: var(--bg-white); border-radius: var(--radius-md); padding: 32px;
    box-shadow: var(--shadow-card); transition: all 0.3s ease;
    display: flex; flex-direction: column; justify-content: space-between;
    border: 1px solid transparent; height: 100%; position: relative;
}
.card:hover { transform: translateY(-5px); box-shadow: var(--shadow-hover); border-color: rgba(34, 100, 235, 0.2); }
.card.featured {
    grid-column: span 2;
    background: linear-gradient(135deg, #ffffff 0%, #EBF3FF 100%);
    border-left: 5px solid var(--brand-vivid-blue);
}
.card-content h3 { font-size: 1.5rem; margin-bottom: 0.75rem; color: var(--brand-dark-blue); }
.card.featured h3 { font-size: 2rem; }
.card-excerpt { color: var(--text-muted); margin-bottom: 1rem; flex-grow: 1; }
.card-meta {
    margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid #eee;
    display: flex; justify-content: space-between; align-items: center;
    font-size: 0.85rem; color: #888;
}
.read-more { color: var(--brand-vivid-blue); font-weight: 700; display: flex; align-items: center; gap: 4px; }

/* Takeaways (Hover Reveal) */
.takeaways {
    max-height: 0; opacity: 0; overflow: hidden; transition: all 0.4s ease;
    background: var(--brand-vivid-blue-light); border-radius: 8px;
    font-size: 0.9rem; color: var(--text-main); margin-top: 0;
}
.card:hover .takeaways { max-height: 200px; opacity: 1; margin-top: 1rem; padding: 16px; }
.takeaways ul { padding-left: 1.2rem; list-style: disc; margin-top: 8px; }

/* --- White Paper Cards --- */
.resource-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 32px; padding: 4rem 0;
}
.doc-card {
    background: var(--bg-white); border-radius: var(--radius-md); overflow: hidden;
    box-shadow: var(--shadow-card); transition: all 0.3s ease;
    display: flex; flex-direction: column; border: 1px solid transparent;
}
.doc-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-hover); border-color: rgba(34, 100, 235, 0.2); }
.doc-preview {
    height: 180px; background: #E0E7F3; display: flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden;
}
.file-badge {
    position: absolute; top: 16px; right: 16px; background: white; padding: 4px 10px;
    border-radius: 4px; font-size: 0.75rem; font-weight: 700; color: var(--accent-terracotta);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.doc-content { padding: 24px; flex-grow: 1; display: flex; flex-direction: column; }
.doc-cat {
    font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--brand-vivid-blue); font-weight: 700; margin-bottom: 8px;
}
.download-link { color: var(--brand-dark-blue); font-weight: 600; font-size: 0.9rem; display: flex; align-items: center; gap: 6px; }
.download-link:hover { color: var(--accent-terracotta); }
.doc-meta { display: flex; justify-content: flex-end; } 

/* --- Article Specific Components --- */
.article-grid { display: grid; grid-template-columns: 240px 1fr; gap: 64px; padding-bottom: 6rem; }

/* Sticky TOC */
.toc-sidebar { position: sticky; top: 120px; height: fit-content; }
.toc-title {
    font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px;
    color: var(--text-muted); margin-bottom: 1rem; font-weight: 700;
}
.toc-list a {
    display: block; padding: 8px 0; color: var(--text-muted);
    font-size: 0.9rem; border-left: 2px solid transparent; padding-left: 16px; transition: all 0.2s;
}
.toc-list a:hover { color: var(--brand-dark-blue); }
.toc-list a.active { color: var(--brand-vivid-blue); border-left-color: var(--brand-vivid-blue); font-weight: 600; }

/* TL;DR Box */
.tldr-box {
    background-color: var(--brand-vivid-blue-light); border-left: 5px solid var(--brand-vivid-blue);
    padding: 2rem; border-radius: 8px; margin-bottom: 3rem;
}
.tldr-box h4 {
    color: var(--brand-vivid-blue); margin-bottom: 1rem; display: flex; align-items: center; gap: 10px; font-weight: 700;
}
.article-body p { margin-bottom: 1.75rem; font-size: 1.125rem; color: #333; line-height: 1.75; }
.article-body h2 { margin-top: 3rem; font-size: 1.75rem; padding-bottom: 10px; border-bottom: 1px solid #eee; }
.article-body ul { margin-bottom: 1.75rem; padding-left: 1.5rem; list-style: disc; }

/* Inline CTA */
.inline-cta {
    margin: 3rem 0; padding: 2rem;
    background: white; border: 1px solid var(--border-color);
    border-radius: 12px; text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.03);
}
.inline-cta a { color: var(--accent-terracotta); font-weight: 700; text-decoration: underline; }

/* --- Toast Notification --- */
.toast {
    position: fixed; bottom: 30px; right: 30px;
    background: var(--bg-white); padding: 20px;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    width: 320px;
    transform: translateY(150%);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2000;
    border-left: 5px solid var(--accent-terracotta);
}
.toast.show { transform: translateY(0); }
.toast-close { position: absolute; top: 10px; right: 15px; cursor: pointer; font-size: 1.2rem; color: #999; }

/* =========================================
   7. FOOTER
   ========================================= */
footer { background: var(--brand-dark-blue); color: white; padding: 4rem 0; margin-top: 4rem; }
.footer-cols { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 2rem; }
.footer-logo { color: white; margin-bottom: 1rem; font-family: var(--font-head); font-weight: 800; font-size: 1.5rem; }
.footer-logo span { color: var(--brand-vivid-blue); }

.social-links { display: flex; gap: 16px; margin-top: 1.5rem; }
.social-icon {
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.3s ease; color: white;
}
.social-icon:hover { background: var(--brand-vivid-blue); transform: translateY(-3px); }

/* Strict SVG sizing for Icons */
.social-icon svg {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px;
    min-height: 18px;
    fill: currentColor;
}

/* =========================================
   8. RESPONSIVE
   ========================================= */
@media (max-width: 900px) {
    .card.featured { grid-column: span 1; }
    .article-grid { grid-template-columns: 1fr; }
    .toc-sidebar { display: none; }
}

@media (max-width: 768px) {
    .nav-links { display: none; }
    .hero h1, .page-hero h1, .article-hero h1 { font-size: 2.25rem; }
    .filter-bar { overflow-x: auto; justify-content: flex-start; padding-bottom: 10px; }
    .filter-pill { white-space: nowrap; }
    .email-capture { flex-direction: column; }
    .btn-cta { width: 100%; }
}

/* =========================================
   BLOG POST PAGE: EXACT TEMPLATE REPLICATION
   ========================================= */

/* 1. Spacing & Colors for Hero */
.article-hero {
    text-align: center;
    padding: 6rem 0 4rem 0; /* Exact template padding */
}

.article-meta {
    margin-bottom: 1.5rem !important; /* Exact spacing above title */
    color: #555555;
    font-size: 0.9rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.article-meta .meta-tag {
    background: rgba(34, 100, 235, 0.1);
    color: #2A58B6;
    font-weight: 600;
    text-transform: uppercase;
    padding: 4px 12px;
    border-radius: 4px;
}

.article-hero h1 {
    color: #2A58B6; /* Brand Dark Blue */
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

/* 2. TL;DR Box - FIXED BULLETS */
.tldr-box {
    background-color: rgba(34, 100, 235, 0.1);
    border-left: 5px solid #2264EB;
}

.tldr-box h4 {
    color: #2264EB;
    font-weight: 700;
}

.tldr-box ul {
    list-style: disc !important; /* Overrides global list-style: none */
    padding-left: 1.5rem !important;
    margin-bottom: 0;
}

.tldr-box li {
    display: list-item !important; /* Forces bullets to appear */
    font-size: 1rem;
    color: #1F1F1F;
    margin-bottom: 0.5rem;
}

/* 3. Table of Contents Color & Logic */
.toc-list nav ul { list-style: none; padding: 0; }

.toc-list a {
    color: #555555; /* Start muted */
    border-left: 2px solid transparent;
    padding-left: 16px;
    font-size: 0.9rem;
    display: block;
    transition: all 0.2s;
}

/* Initial "Blue" state for first item and Active state */
/* FIX: Removed the rule that forced the first-child to be blue permanently */
.toc-list a.active {
    color: #2264EB;
    border-left-color: #2264EB;
    font-weight: 600;
}

/* When another section is active, the first-child blue is removed by JS */
.toc-list a.active {
    color: #2264EB !important;
}

/* 4. References styling */
.references h4 {
    font-size: 1.1rem;
    color: #555555;
    margin-bottom: 1rem;
}

.ref-item p, .ref-item {
    font-size: 0.85rem;
    color: #777777;
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

/* =========================================
   LIVE SEARCH RESULTS DROPDOWN
   ========================================= */
.search-results-container {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.5);
    margin-top: 12px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 2000;
    display: none; /* Hidden by default */
    padding: 10px 0;
}

.search-results-container.active {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

.search-result-item {
    display: block;
    padding: 12px 24px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    transition: background 0.2s;
    text-align: left;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: rgba(34, 100, 235, 0.05); /* --brand-vivid-blue-light */
}

.search-result-title {
    font-family: var(--font-head, serif);
    font-weight: 700;
    color: #2A58B6; /* --brand-dark-blue */
    font-size: 1rem;
    margin-bottom: 4px;
}

.search-result-excerpt {
    font-family: var(--font-body, sans-serif);
    font-size: 0.85rem;
    color: #555; /* --text-muted */
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Scrollbar Styling */
.search-results-container::-webkit-scrollbar { width: 6px; }
.search-results-container::-webkit-scrollbar-track { background: transparent; }
.search-results-container::-webkit-scrollbar-thumb { background: #ccc; border-radius: 10px; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}