/* ==========================================
   1. CSS VARIABLES & THEME TOKENS
   ========================================== */
:root {
    /* Brand Colors (Modern Teal/Green inspired by your original) */
    --brand-primary: #0f766e;
    --brand-primary-hover: #115e59;
    --brand-accent: #f59e0b;        /* "Support Us" / Viral Action Color */

    /* Light Theme (Default) */
    --bg-main: #f8fafc;             /* App background */
    --bg-surface: #ffffff;          /* Cards, Post backgrounds */
    --bg-surface-alt: #f1f5f9;      /* Comments area, Input backgrounds */

    --text-primary: #0f172a;        /* Headings */
    --text-secondary: #334155;      /* Body copy */
    --text-muted: #64748b;          /* Dates, meta data */

    --border-subtle: #e2e8f0;
    --border-strong: #cbd5e1;

    /* Typography & Spacing */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-serif: 'Merriweather', Georgia, serif; /* Better for long reading */
    --reading-width: 65ch;          /* Optimal line length for reading */
    --container-max: 1280px;

    /* Semantic / Status */
    --color-success: #10b981;
    --color-error: #ef4444;
    --color-warning: #f59e0b;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);

    /* Bootstrap Compat (If still using BS grid/utilities) */
    --bs-primary: var(--brand-primary);
    --bs-body-bg: var(--bg-main);
    --bs-body-color: var(--text-secondary);
    --bs-font-sans-serif: var(--font-sans);
}

/* Dark Theme Overrides */
[data-theme="dark"] {
    --bg-main: #020617;
    --bg-surface: #0f172a;
    --bg-surface-alt: #1e293b;

    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    --border-subtle: #1e293b;
    --border-strong: #334155;

    --brand-primary: #14b8a6;
    --brand-primary-hover: #2dd4bf;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.5);
}

/* Auto Dark Mode Fallback */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        /* Copies the dark mode variables above */
        --bg-main: #020617;
        --bg-surface: #0f172a;
        --bg-surface-alt: #1e293b;
        --text-primary: #f8fafc;
        --text-secondary: #cbd5e1;
        --text-muted: #94a3b8;
        --border-subtle: #1e293b;
        --brand-primary: #14b8a6;
    }
}

/* ==========================================
   2. RESET & BASE DOCUMENT FLOW
   ========================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth; /* Great for Table of Contents links */
    font-size: 16px;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Global Container */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ==========================================
   3. TYPOGRAPHY & READING EXPERIENCE
   ========================================== */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 700;
    line-height: 1.2;
    margin-top: 0;
    margin-bottom: 1rem;
}

/* Fluid Typography for Viral Headlines */
h1 { font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.5rem, 4vw, 2.25rem); margin-top: 2rem; }
h3 { font-size: clamp(1.25rem, 3vw, 1.75rem); }

a {
    color: var(--brand-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--brand-primary-hover);
}

/* The Core Blog Post Content Area */
.article-body {
    font-family: var(--font-sans); /* Switch to --font-serif if preferred */
    font-size: 1.125rem;
    line-height: 1.8;
    max-width: var(--reading-width);
    margin: 0 auto;
    color: var(--text-secondary);
}

.article-body p { margin-bottom: 1.5rem; }
.article-body img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 2rem 0;
}
.article-body blockquote {
    border-left: 4px solid var(--brand-primary);
    background-color: var(--bg-surface-alt);
    padding: 1rem 1.5rem;
    margin: 2rem 0;
    font-style: italic;
    border-radius: 0 8px 8px 0;
    color: var(--text-primary);
}

/* ==========================================
   4. BLOG LAYOUT GRIDS
   ========================================== */
.post-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.post-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

.post-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}

/* ==========================================
   5. UI COMPONENTS (Forms, Buttons, Badges)
   ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--brand-primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--brand-primary-hover);
}

/* Viral / Monetization Buttons */
.btn-support {
    background-color: var(--brand-accent);
    color: #fff;
    box-shadow: 0 4px 14px 0 rgba(245, 158, 11, 0.39);
}

.btn-support:hover {
    transform: scale(1.05);
    background-color: #d97706;
}

.form-control, .form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background-color: var(--bg-surface);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.2);
}

/* ==========================================
   6. BLOG-SPECIFIC MODULES
   ========================================== */

/* A. Ad Slots (Prevents Cumulative Layout Shift) */
.ad-container {
    width: 100%;
    background-color: var(--bg-surface-alt);
    border: 1px dashed var(--border-strong);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2rem 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}
.ad-horizontal { min-height: 100px; } /* Ensures space is reserved before JS loads AdSense */
.ad-sidebar { min-height: 250px; }

/* B. Social Sharing Bar */
.social-share-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 2rem 0;
}

.btn-social {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--bg-surface-alt);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
}

.btn-social:hover {
    background: var(--border-subtle);
}

/* Platform specific colors on hover if desired */
.btn-social.whatsapp:hover { background: #25D366; color: white; border-color: #25D366; }
.btn-social.x-twitter:hover { background: #000; color: white; border-color: #000; }

/* C. Comments Section */
.comment-thread {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-subtle);
}

.comment-node {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-surface);
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
}

.comment-reply {
    margin-left: 2rem; /* Indent for threaded replies */
    border-left: 3px solid var(--border-subtle);
    border-radius: 0 8px 8px 0;
}

/* ==========================================
   7. UTILITIES
   ========================================== */
.text-center { text-align: center; }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }

/* Hide scrollbar for clean horizontal scrolls (like category chips) */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }