/* ==========================================================
   Affiliate Content Sites — Shared Design System
   Three sites: Tool Compare, Automate Compare, Dev Tool Rank
   Goals: Fast-loading, readable, credible, conversion-optimized
   ========================================================== */

/* --- Variables --- */
:root {
    /* Core */
    --bg: #f8f9fb;
    --fg: #1a1a2e;
    --fg-secondary: #4a4a6a;
    --muted: #8b8ba7;
    --border: #e4e7ee;
    --card-bg: #ffffff;
    --max-width: 820px;
    --max-width-wide: 1100px;

    /* Brand — site overrides set on body */
    --accent: #2563eb;
    --accent-light: #dbeafe;
    --accent-dark: #1d4ed8;
    --accent-gradient: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);

    /* Category colors */
    --cat-review: #2563eb;
    --cat-review-light: #dbeafe;
    --cat-comparison: #7c3aed;
    --cat-comparison-light: #ede9fe;
    --cat-bestof: #d97706;
    --cat-bestof-light: #fef3c7;
    --cat-tutorial: #059669;
    --cat-tutorial-light: #d1fae5;

    /* Alerts/boxes */
    --pro-bg: #f0fdf4;
    --pro-border: #22c55e;
    --con-bg: #fef2f2;
    --con-border: #ef4444;
    --info-bg: #eff6ff;
    --info-border: #3b82f6;
    --affiliate-bg: #fffbeb;
    --affiliate-border: #f59e0b;

    /* Typography */
    --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-heading: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--fg);
    line-height: 1.7;
    font-size: 17px;
    -webkit-font-smoothing: antialiased;
}

/* --- Per-Site Branding (set by build script) --- */
body.site-toolcompare {
    --accent: #2563eb;
    --accent-light: #dbeafe;
    --accent-dark: #1d4ed8;
    --accent-gradient: linear-gradient(135deg, #2563eb 0%, #6366f1 100%);
}
body.site-automatecompare {
    --accent: #059669;
    --accent-light: #d1fae5;
    --accent-dark: #047857;
    --accent-gradient: linear-gradient(135deg, #059669 0%, #2563eb 100%);
}
body.site-devtoolrank {
    --accent: #7c3aed;
    --accent-light: #ede9fe;
    --accent-dark: #6d28d9;
    --accent-gradient: linear-gradient(135deg, #7c3aed 0%, #db2777 100%);
}

/* --- Layout --- */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }
.container-wide { max-width: var(--max-width-wide); margin: 0 auto; padding: 0 24px; }

/* --- Links --- */
a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent-dark); text-decoration: underline; }

/* --- Header --- */
.site-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    height: 60px;
}
.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}
.logo {
    font-size: 1.25em;
    font-weight: 800;
    color: var(--fg);
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 8px;
}
.logo:hover { color: var(--accent); text-decoration: none; }
.logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--accent-gradient);
    border-radius: 8px;
    color: white;
    font-size: 0.75em;
    font-weight: 700;
}

/* Navigation */
.nav-toggle { display: none; }
.site-header nav { display: flex; align-items: center; gap: 4px; }
.site-header nav a {
    padding: 8px 14px;
    color: var(--fg-secondary);
    font-size: 0.88em;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.15s;
}
.site-header nav a:hover {
    color: var(--accent);
    background: var(--accent-light);
    text-decoration: none;
}

@media (max-width: 640px) {
    .nav-toggle {
        display: flex;
        flex-direction: column;
        gap: 4px;
        cursor: pointer;
        padding: 8px;
        border: none;
        background: none;
    }
    .nav-toggle span {
        display: block;
        width: 22px;
        height: 2.5px;
        background: var(--fg);
        border-radius: 2px;
        transition: 0.2s;
    }
    .site-header nav {
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        padding: 12px 24px 20px;
        border-bottom: 1px solid var(--border);
        box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    }
    .site-header nav.open { display: flex; }
    .site-header nav a {
        padding: 12px 8px;
        width: 100%;
        font-size: 1em;
        border-bottom: 1px solid var(--border);
        border-radius: 0;
    }
    .site-header nav a:last-child { border-bottom: none; }
}

/* --- Hero Section --- */
.hero {
    text-align: center;
    padding: 80px 20px 60px;
    background: var(--accent-gradient);
    margin: 0 -24px;
    position: relative;
    overflow: hidden;
}
.hero::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
}
.hero h1 {
    font-size: 2.4em;
    font-weight: 800;
    color: white;
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin-bottom: 16px;
    position: relative;
}
.hero p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 1.1em;
    max-width: 550px;
    margin: 0 auto;
    line-height: 1.5;
    position: relative;
}
.hero .cta-btn {
    display: inline-block;
    margin-top: 24px;
    padding: 12px 32px;
    background: white;
    color: var(--accent-dark);
    font-weight: 700;
    border-radius: 8px;
    font-size: 0.95em;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: transform 0.15s, box-shadow 0.15s;
}
.hero .cta-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
    text-decoration: none;
}

@media (max-width: 600px) {
    .hero { padding: 50px 16px 40px; margin: 0 -24px; }
    .hero h1 { font-size: 1.7em; }
}

/* --- Category Sections (Homepage) --- */
.category-section {
    margin: 48px 0;
}
.category-section h2 {
    font-size: 1.35em;
    font-weight: 700;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.category-section h2 .badge {
    font-size: 0.6em;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Category badges on cards */
.badge-review { background: var(--cat-review-light); color: var(--cat-review); }
.badge-comparison { background: var(--cat-comparison-light); color: var(--cat-comparison); }
.badge-bestof { background: var(--cat-bestof-light); color: var(--cat-bestof); }
.badge-tutorial { background: var(--cat-tutorial-light); color: var(--cat-tutorial); }
.badge-guide { background: #f3e8ff; color: #7c3aed; }

/* --- Article Cards --- */
.articles { margin: 0 0 40px; }
.articles-grid {
    display: grid;
    gap: 24px;
}
.articles-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.articles-grid.cols-1 { grid-template-columns: 1fr; }

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 28px;
    transition: box-shadow 0.2s, transform 0.15s;
}
.card:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    transform: translateY(-1px);
}
.card h3 {
    font-size: 1.15em;
    margin-bottom: 12px;
    line-height: 1.4;
}
.card h3 a { color: var(--fg); font-weight: 700; }
.card h3 a:hover { color: var(--accent); }
.card p {
    color: var(--fg-secondary);
    font-size: 0.9em;
    line-height: 1.6;
    margin-bottom: 14px;
}
.card-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 0.82em;
    color: var(--muted);
    flex-wrap: wrap;
}
.card-meta .badge {
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.85em;
    text-transform: capitalize;
}
.card-meta time { color: var(--muted); }
.card-meta .reading-time {
    color: var(--muted);
}

@media (max-width: 640px) {
    .articles-grid.cols-2 { grid-template-columns: 1fr; }
}

/* --- Individual Article Page --- */
.article-page {
    padding: 40px 0 60px;
    display: grid;
    grid-template-columns: 1fr 240px;
    gap: 40px;
}

.article-content { min-width: 0; }

.article-header {
    margin-bottom: 40px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--border);
}
.article-header h1 {
    font-size: 2em;
    font-weight: 800;
    line-height: 1.3;
    letter-spacing: -0.02em;
    margin-bottom: 20px;
    color: var(--fg);
}
.article-header .meta-row {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
    font-size: 0.88em;
    color: var(--fg-secondary);
}
.article-header .meta-row .badge { font-size: 0.82em; }
.article-header .meta-row time { color: var(--muted); }
.article-header .meta-row .affiliate-tag {
    background: var(--affiliate-bg);
    color: #92400e;
    border: 1px solid var(--affiliate-border);
    padding: 3px 12px;
    border-radius: 4px;
    font-size: 0.82em;
}

/* Affiliate CTA Box */
.affiliate-cta {
    background: var(--affiliate-bg);
    border: 1px solid var(--affiliate-border);
    border-radius: 10px;
    padding: 20px 24px;
    margin: 32px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.affiliate-cta p {
    margin: 0;
    font-size: 0.92em;
    color: #78350f;
    font-weight: 500;
}
.cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    background: var(--accent);
    color: white;
    font-weight: 700;
    border-radius: 8px;
    font-size: 0.9em;
    white-space: nowrap;
    transition: background 0.15s, transform 0.15s;
}
.cta-btn:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
    text-decoration: none;
    color: white;
}
.cta-btn.secondary {
    background: white;
    color: var(--accent);
    border: 2px solid var(--accent);
}
.cta-btn.secondary:hover { background: var(--accent-light); }

/* --- Sidebar TOC --- */
.article-sidebar {
    position: sticky;
    top: 80px;
    align-self: start;
}
.toc {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
}
.toc h4 {
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 12px;
    font-weight: 600;
}
.toc a {
    display: block;
    padding: 6px 0;
    font-size: 0.85em;
    color: var(--fg-secondary);
    border-bottom: 1px solid var(--border);
    transition: color 0.1s;
}
.toc a:last-child { border-bottom: none; }
.toc a:hover { color: var(--accent); text-decoration: none; }
.toc a.toc-h3 { padding-left: 16px; font-size: 0.82em; color: var(--muted); }

@media (max-width: 820px) {
    .article-page { grid-template-columns: 1fr; }
    .article-sidebar { display: none; }
}

/* --- Article Body Typography --- */
.body-content { font-size: 1em; line-height: 1.85; }
.body-content h1 {
    display: none;
}
.body-content h2 {
    font-size: 1.5em;
    font-weight: 700;
    margin: 60px 0 28px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
    line-height: 1.3;
    color: var(--fg);
    scroll-margin-top: 80px;
}
.body-content h3 {
    font-size: 1.2em;
    font-weight: 700;
    margin: 44px 0 18px;
    color: var(--fg-secondary);
    scroll-margin-top: 80px;
}
.body-content h4 {
    font-size: 1em;
    font-weight: 700;
    margin: 28px 0 10px;
}
.body-content p { margin-bottom: 28px; color: var(--fg); }
.body-content ul, .body-content ol {
    margin: 20px 0 28px 32px;
}
.body-content li { margin-bottom: 12px; line-height: 1.7; }
.body-content strong { font-weight: 600; }
.body-content blockquote {
    border-left: 4px solid var(--accent);
    padding: 20px 28px;
    margin: 36px 0;
    background: var(--accent-light);
    border-radius: 0 8px 8px 0;
    color: var(--fg-secondary);
    font-style: italic;
}
.body-content code {
    font-family: var(--font-mono);
    background: #f1f5f9;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.88em;
}
.body-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 24px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.88em;
    line-height: 1.6;
    margin: 32px 0;
}
.body-content pre code {
    background: none;
    color: inherit;
    padding: 0;
    border-radius: 0;
    font-size: 0.88em;
}
.body-content img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    margin: 28px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.body-content a[rel~="nofollow"] {
    font-weight: 500;
}

/* --- Tables --- */
.body-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 32px 0;
    font-size: 0.9em;
    border-radius: 8px;
    overflow: hidden;
}
.body-content th {
    background: var(--accent-light);
    color: var(--accent-dark);
    font-weight: 600;
    padding: 14px 18px;
    text-align: left;
}
.body-content td {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
}
.body-content tr:last-child td { border-bottom: none; }
.body-content tr:hover td { background: #fafbfc; }

/* --- Pros/Cons Boxes --- */
.pro-box, .con-box, .info-box {
    padding: 20px 24px;
    border-radius: 10px;
    margin: 32px 0;
    position: relative;
}
.pro-box {
    background: var(--pro-bg);
    border-left: 4px solid var(--pro-border);
}
.pro-box::before { content: '✅ Pro'; display: block; font-weight: 700; color: #15803d; margin-bottom: 8px; font-size: 0.9em; }
.con-box {
    background: var(--con-bg);
    border-left: 4px solid var(--con-border);
}
.con-box::before { content: '⚠️ Con'; display: block; font-weight: 700; color: #dc2626; margin-bottom: 8px; font-size: 0.9em; }
.info-box {
    background: var(--info-bg);
    border-left: 4px solid var(--info-border);
}
.info-box::before { content: '💡 Tip'; display: block; font-weight: 700; color: var(--info-border); margin-bottom: 8px; font-size: 0.9em; }

/* --- Verdict Box --- */
.verdict-box {
    background: var(--accent-light);
    border: 2px solid var(--accent);
    border-radius: 12px;
    padding: 32px;
    margin: 48px 0;
    position: relative;
}
.verdict-box::before {
    content: '🏆 Verdict';
    display: block;
    font-weight: 800;
    font-size: 1.1em;
    color: var(--accent-dark);
    margin-bottom: 14px;
}
.verdict-box p { margin-bottom: 14px; line-height: 1.6; }
.verdict-box .stars {
    display: inline-flex;
    gap: 2px;
    margin-bottom: 10px;
}
.verdict-box .cta-btn { margin-top: 8px; }
.rating-score {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.rating-score .score {
    font-size: 2em;
    font-weight: 800;
    color: var(--accent);
}
.rating-score .label {
    font-size: 0.85em;
    color: var(--fg-secondary);
}

/* --- Star ratings (inline, CSS-only stars) --- */
.stars {
    display: inline-flex;
    gap: 1px;
    unicode-bidi: bidi-override;
    color: #f59e0b;
    font-size: 0.9em;
    letter-spacing: 2px;
}

/* --- FAQ section --- */
.faq-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}
.faq-item summary {
    padding: 14px 18px;
    font-weight: 600;
    cursor: pointer;
    background: var(--card-bg);
    font-size: 0.95em;
    display: flex;
    align-items: center;
    gap: 8px;
}
.faq-item summary:hover { background: #fafbfc; }
.faq-item summary::before { content: '❓'; font-size: 0.85em; }
.faq-item[open] summary { border-bottom: 1px solid var(--border); }
.faq-item .faq-answer { padding: 14px 18px; font-size: 0.93em; line-height: 1.6; }

/* --- Author Box --- */
.author-box {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin: 36px 0;
}
.author-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.2em;
    flex-shrink: 0;
}
.author-info h4 {
    font-size: 1em;
    font-weight: 700;
    margin-bottom: 4px;
}
.author-info p {
    font-size: 0.88em;
    color: var(--fg-secondary);
    line-height: 1.5;
}

/* --- Category Archive Pages --- */
.archive-header {
    padding: 40px 0 24px;
}
.archive-header h1 {
    font-size: 1.8em;
    font-weight: 800;
    margin-bottom: 8px;
}
.archive-header p {
    color: var(--fg-secondary);
}

/* --- Pricing / Feature Comparison Table --- */
.price-table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
    font-size: 0.9em;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.price-table th {
    background: var(--fg);
    color: white;
    padding: 14px 16px;
    text-align: center;
    font-weight: 600;
}
.price-table th:first-child { text-align: left; }
.price-table td {
    padding: 12px 16px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}
.price-table td:first-child {
    text-align: left;
    font-weight: 600;
    color: var(--fg-secondary);
}
.price-table tr:hover td { background: #f8fafc; }
.price-table .price {
    font-weight: 700;
    font-size: 1.1em;
    color: var(--accent);
}
.price-table .pick {
    display: inline-block;
    background: var(--accent);
    color: white;
    padding: 2px 12px;
    border-radius: 12px;
    font-size: 0.82em;
    font-weight: 600;
}

/* --- Disclosure (sticky footer) --- */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 36px 24px;
    text-align: center;
    font-size: 0.85em;
    color: var(--muted);
    background: var(--card-bg);
    margin-top: 40px;
}
.site-footer .footer-nav {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.site-footer a { color: var(--fg-secondary); font-weight: 500; }
.site-footer a:hover { color: var(--accent); }
.site-footer .disclosure {
    font-style: italic;
    margin: 10px auto;
    max-width: 600px;
    font-size: 0.9em;
    line-height: 1.5;
    background: var(--affiliate-bg);
    padding: 10px 16px;
    border-radius: 6px;
    color: #78350f;
}
.site-footer .copyright { margin-top: 16px; font-size: 0.88em; }

/* --- About Page --- */
.about-page { padding: 40px 0 60px; }
.about-page h1 { font-size: 2em; margin-bottom: 20px; }
.about-page h2 { font-size: 1.3em; margin: 28px 0 12px; }
.about-page p { margin-bottom: 16px; line-height: 1.7; }
.about-page .value-prop {
    background: var(--accent-light);
    border-radius: 10px;
    padding: 24px;
    margin: 20px 0;
}
.about-page .value-prop h3 { color: var(--accent-dark); margin-bottom: 8px; }

/* --- Comparison Charts (inline styled tables for pro/con checkmarks) --- */
.comparison-chart { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 0.9em; border-radius: 8px; overflow: hidden; }
.comparison-chart th { background: var(--accent-light); color: var(--accent-dark); padding: 10px 14px; text-align: center; font-weight: 600; }
.comparison-chart th:first-child { text-align: left; }
.comparison-chart td { padding: 10px 14px; text-align: center; border-bottom: 1px solid var(--border); }
.comparison-chart td:first-child { text-align: left; }
.comparison-chart .check { color: #22c55e; font-weight: 700; }
.comparison-chart .cross { color: #ef4444; }

/* --- Breadcrumbs --- */
.breadcrumbs {
    font-size: 0.85em;
    color: var(--muted);
    margin-bottom: 16px;
    padding: 12px 0;
}
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs span { margin: 0 6px; }

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}
.empty-state h2 { font-size: 1.4em; margin-bottom: 8px; }
.empty-state p { font-size: 1em; }

/* --- Privacy / Contact Pages (standalone) --- */
.standalone-page { padding: 40px 0 60px; }
.standalone-page h1 { font-size: 1.8em; margin-bottom: 20px; }
.standalone-page h2 { font-size: 1.2em; margin: 24px 0 12px; }
.standalone-page p { margin-bottom: 14px; line-height: 1.7; }

/* --- Utility --- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
}

/* --- Responsive tweaks --- */
@media (max-width: 600px) {
    body { font-size: 16px; }
    .container { padding: 0 16px; }
    .article-header h1 { font-size: 1.5em; }
    .body-content h2 { font-size: 1.25em; }
    .body-content { font-size: 0.95em; }
    .affiliate-cta { flex-direction: column; text-align: center; }
    .author-box { flex-direction: column; align-items: center; text-align: center; }
    .price-table { font-size: 0.82em; }
    .price-table th, .price-table td { padding: 8px 10px; }
    .verdict-box { padding: 20px; }
}