/**
 * CE Blog Styles — Production CSS
 * ================================
 * Styling for auto-generated blog post elements produced by n8n workflows.
 * All colors derive from two CSS custom properties injected by PHP:
 *   --ce-primary       (hex)
 *   --ce-accent        (hex)
 *   --ce-primary-rgb   (R, G, B — for rgba())
 *   --ce-accent-rgb    (R, G, B — for rgba())
 *
 * Typography inherits from the active WordPress theme.
 * Spacing uses rem units. Max-width prevents full-bleed stretching.
 *
 * Table of Contents
 * -----------------
 *  1. Shared / Base
 *  2. Table of Contents    (.ce-toc)
 *  3. CTA Card             (.ce-cta-card)
 *  4. Pro / Expert Tip     (.ce-pro-tip)
 *  5. Warning Box          (.ce-warning)
 *  6. Key Stat Highlight   (.ce-key-stat)
 *  7. Products Grid        (.ce-products-mentioned)
 *  8. Expert Bio Card      (.ce-expert-bio)
 *  9. Did You Know Box     (.ce-did-you-know)
 * 10. Quick Reference      (.ce-quick-reference)
 * 11. Responsive (tablet)
 * 12. Responsive (mobile)
 * 13. Print styles
 * 14. Accessibility / Focus
 */


/* =====================================================================
   1. SHARED / BASE
   ===================================================================== */

.ce-toc,
.ce-cta-card,
.ce-pro-tip,
.ce-warning,
.ce-key-stat,
.ce-products-mentioned,
.ce-expert-bio,
.ce-did-you-know,
.ce-quick-reference {
    box-sizing: border-box;
    max-width: 780px;
    margin-left: auto;
    margin-right: auto;
    font-family: inherit;
    line-height: 1.6;
    color: inherit;
}

/* Shared transition for interactive states */
.ce-cta-btn,
.ce-product-card,
.ce-toc a,
.ce-expert-bio a {
    transition: all 0.2s ease;
}


/* =====================================================================
   2. TABLE OF CONTENTS  (.ce-toc)
   ===================================================================== */

.ce-toc {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
    background: #fafafa;
}

/* Sticky mode — add .ce-toc-sticky to the wrapper for opt-in sticky behavior */
.ce-toc.ce-toc-sticky {
    position: sticky;
    top: 2rem;
    z-index: 10;
}

/* Title */
.ce-toc-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 0.75rem;
    color: var(--ce-primary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Ordered list */
.ce-toc ol {
    margin: 0;
    padding-left: 1.25rem;
    list-style: decimal;
}

.ce-toc li {
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

.ce-toc a {
    color: var(--ce-primary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

.ce-toc a:hover,
.ce-toc a:focus {
    border-bottom-color: var(--ce-primary);
}

/* ── Mobile collapsed toggle ── */

/* Hidden checkbox drives the CSS-only toggle */
.ce-toc-toggle {
    display: none;
}

.ce-toc-toggle-label {
    display: none;          /* shown only on mobile */
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--ce-primary);
    font-weight: 600;
    user-select: none;
    margin-bottom: 0.5rem;
}

.ce-toc-toggle-label::after {
    content: " [+]";
    font-weight: 400;
}

.ce-toc-toggle:checked ~ .ce-toc-toggle-label::after {
    content: " [-]";
}


/* =====================================================================
   3. CTA CARD  (.ce-cta-card)
   ===================================================================== */

.ce-cta-card {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-left: 4px solid var(--ce-accent);
    border-radius: 6px;
    padding: 1.5rem 1.75rem;
    margin: 2rem auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.ce-cta-card h4 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    color: #222;
}

.ce-cta-card p {
    font-size: 0.95rem;
    color: #555;
    margin: 0 0 1rem;
}

/* Button group */
.ce-cta-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

/* Primary button */
.ce-cta-btn {
    display: inline-block;
    padding: 0.6rem 1.4rem;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border-radius: 5px;
    cursor: pointer;
    border: 2px solid var(--ce-primary);
    background: var(--ce-primary);
    color: #fff;
    line-height: 1.4;
}

.ce-cta-btn:hover,
.ce-cta-btn:focus {
    opacity: 0.88;
    box-shadow: 0 2px 6px rgba(var(--ce-primary-rgb), 0.35);
}

/* Secondary (outlined) button */
.ce-cta-btn.ce-cta-secondary {
    background: transparent;
    color: var(--ce-primary);
}

.ce-cta-btn.ce-cta-secondary:hover,
.ce-cta-btn.ce-cta-secondary:focus {
    background: rgba(var(--ce-primary-rgb), 0.08);
    opacity: 1;
}


/* =====================================================================
   4. PRO / EXPERT TIP  (.ce-pro-tip)
   ===================================================================== */

.ce-pro-tip {
    background: rgba(var(--ce-primary-rgb), 0.05);
    border-left: 3px solid var(--ce-primary);
    border-radius: 0 6px 6px 0;
    padding: 1.15rem 1.5rem 1.15rem 1.75rem;
    margin: 1.75rem auto;
    position: relative;
}

/* SVG lightbulb icon via ::before */
.ce-pro-tip::before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 0.5rem;
    vertical-align: middle;
    /* Lightbulb SVG (simple outline) encoded as data URI */
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18h6'/%3E%3Cpath d='M10 22h4'/%3E%3Cpath d='M12 2a7 7 0 0 0-4 12.7V17h8v-2.3A7 7 0 0 0 12 2z'/%3E%3C/svg%3E") no-repeat center / contain;
    /* Use currentColor fallback; tint via filter isn't reliable, so we keep neutral */
    flex-shrink: 0;
}

/* Prefix text */
.ce-pro-tip strong:first-child {
    color: var(--ce-primary);
}

.ce-pro-tip p {
    margin: 0;
    font-size: 0.95rem;
    color: #333;
}

.ce-pro-tip p:first-of-type {
    display: inline; /* flows after the ::before icon */
}


/* =====================================================================
   5. WARNING BOX  (.ce-warning)
   ===================================================================== */

.ce-warning {
    background: #fff3cd;
    border-left: 3px solid #dc3545;
    border-radius: 0 6px 6px 0;
    padding: 1.15rem 1.5rem 1.15rem 1.75rem;
    margin: 1.75rem auto;
    position: relative;
}

/* SVG triangle-exclamation icon */
.ce-warning::before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 0.5rem;
    vertical-align: middle;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23dc3545' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z'/%3E%3Cline x1='12' y1='9' x2='12' y2='13'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E") no-repeat center / contain;
    flex-shrink: 0;
}

.ce-warning strong:first-child {
    color: #dc3545;
}

.ce-warning p {
    margin: 0;
    font-size: 0.95rem;
    color: #5a3e00;
}

.ce-warning p:first-of-type {
    display: inline;
}


/* =====================================================================
   6. KEY STAT HIGHLIGHT  (.ce-key-stat)
   ===================================================================== */

.ce-key-stat {
    text-align: center;
    padding: 2rem 1.5rem;
    margin: 2rem auto;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    background: #fdfdfd;
}

/* Large stat value */
.ce-key-stat-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--ce-accent);
    line-height: 1.2;
    margin-bottom: 0.35rem;
}

/* Optional unit suffix (e.g. "/month") */
.ce-key-stat-unit {
    font-size: 1.25rem;
    font-weight: 400;
    color: var(--ce-accent);
    opacity: 0.75;
}

/* Description text beneath the number */
.ce-key-stat-desc {
    display: block;
    font-size: 0.95rem;
    color: #777;
    margin-top: 0.25rem;
}


/* =====================================================================
   7. PRODUCTS GRID  (.ce-products-mentioned)
   ===================================================================== */

.ce-products-mentioned {
    margin: 2.5rem auto;
}

.ce-products-mentioned-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 1rem;
    color: #222;
}

/* Grid container */
.ce-products-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
}

/* Individual product card */
.ce-product-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    background: #fff;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ce-product-card:hover {
    border-color: var(--ce-primary);
    box-shadow: 0 4px 12px rgba(var(--ce-primary-rgb), 0.12);
    transform: translateY(-2px);
}

/* Thumbnail */
.ce-product-card img {
    width: 100%;
    max-width: 180px;
    height: auto;
    border-radius: 4px;
    margin-bottom: 0.75rem;
    object-fit: cover;
}

/* Model number badge */
.ce-product-model {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ce-primary);
    background: rgba(var(--ce-primary-rgb), 0.08);
    padding: 0.15rem 0.6rem;
    border-radius: 3px;
    margin-bottom: 0.5rem;
}

/* Product name */
.ce-product-name {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 0.4rem;
    color: #222;
}

/* Key specs list */
.ce-product-specs {
    list-style: none;
    padding: 0;
    margin: 0 0 0.75rem;
    font-size: 0.82rem;
    color: #666;
    text-align: left;
    width: 100%;
}

.ce-product-specs li {
    padding: 0.2rem 0;
    border-bottom: 1px solid #f2f2f2;
}

.ce-product-specs li:last-child {
    border-bottom: none;
}

/* View Details link */
.ce-product-link {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ce-primary);
    text-decoration: none;
    margin-top: auto; /* push to bottom of flex column */
}

.ce-product-link:hover,
.ce-product-link:focus {
    text-decoration: underline;
}

.ce-product-link::after {
    content: " \2192"; /* → arrow */
}


/* =====================================================================
   8. EXPERT BIO CARD  (.ce-expert-bio)
   ===================================================================== */

.ce-expert-bio {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2.5rem auto;
    background: #fafafa;
}

/* Circular author photo */
.ce-expert-bio-photo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 3px solid var(--ce-primary);
}

/* Text block */
.ce-expert-bio-info {
    flex: 1;
    min-width: 0; /* prevent overflow */
}

.ce-expert-bio-name {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 0.15rem;
    color: #222;
}

.ce-expert-bio-title {
    font-size: 0.85rem;
    font-weight: 400;
    color: #777;
    margin: 0 0 0.6rem;
}

.ce-expert-bio-desc {
    font-size: 0.9rem;
    color: #444;
    margin: 0 0 0.6rem;
    line-height: 1.5;
}

/* Social / profile links */
.ce-expert-bio-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 1rem;
}

.ce-expert-bio-links a {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ce-primary);
    text-decoration: none;
}

.ce-expert-bio-links a:hover,
.ce-expert-bio-links a:focus {
    text-decoration: underline;
}


/* =====================================================================
   9. DID YOU KNOW BOX  (.ce-did-you-know)
   ===================================================================== */

.ce-did-you-know {
    background: #e8f4fd;
    border-left: 3px solid #2196f3;
    border-radius: 0 6px 6px 0;
    padding: 1.15rem 1.5rem 1.15rem 1.75rem;
    margin: 1.75rem auto;
    position: relative;
}

/* SVG info-circle icon */
.ce-did-you-know::before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 0.5rem;
    vertical-align: middle;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232196f3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='16' x2='12' y2='12'/%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'/%3E%3C/svg%3E") no-repeat center / contain;
    flex-shrink: 0;
}

.ce-did-you-know strong:first-child {
    color: #1565c0;
}

.ce-did-you-know p {
    margin: 0;
    font-size: 0.95rem;
    color: #1a3a5c;
}

.ce-did-you-know p:first-of-type {
    display: inline;
}


/* =====================================================================
   10. QUICK REFERENCE CHECKLIST  (.ce-quick-reference)
   ===================================================================== */

.ce-quick-reference {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin: 2rem auto;
    background: #fff;
}

.ce-quick-reference-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 0.75rem;
    color: var(--ce-primary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.ce-quick-reference ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ce-quick-reference li {
    position: relative;
    padding: 0.45rem 0 0.45rem 2rem;
    font-size: 0.93rem;
    color: #333;
    border-bottom: 1px solid #f2f2f2;
}

.ce-quick-reference li:last-child {
    border-bottom: none;
}

/* CSS-only checkbox marker */
.ce-quick-reference li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.55rem;
    width: 16px;
    height: 16px;
    border: 2px solid #bbb;
    border-radius: 3px;
    background: #fff;
}

/* Checked state — add .ce-checked class to the li */
.ce-quick-reference li.ce-checked::before {
    background: var(--ce-primary);
    border-color: var(--ce-primary);
}

.ce-quick-reference li.ce-checked::after {
    content: "";
    position: absolute;
    left: 3px;
    top: 0.55rem;
    width: 10px;
    height: 6px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg);
    transform-origin: center;
    margin-top: 3px;
}


/* =====================================================================
   11. RESPONSIVE — TABLET  (max-width: 768px)
   ===================================================================== */

@media (max-width: 768px) {

    /* Products grid: 2 columns */
    .ce-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    /* Expert bio keeps horizontal but tighter */
    .ce-expert-bio {
        gap: 1rem;
        padding: 1.25rem;
    }

    .ce-expert-bio-photo {
        width: 64px;
        height: 64px;
    }

    /* Key stat slightly smaller */
    .ce-key-stat-value {
        font-size: 2rem;
    }
}


/* =====================================================================
   12. RESPONSIVE — MOBILE  (max-width: 480px)
   ===================================================================== */

@media (max-width: 480px) {

    /* ── TOC: collapsed by default ── */
    .ce-toc-toggle-label {
        display: block;
    }

    /* Hide the list when toggle is unchecked */
    .ce-toc ol {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .ce-toc-toggle:checked ~ ol {
        max-height: 1000px; /* large enough for any TOC */
    }

    .ce-toc {
        padding: 1rem;
    }

    /* ── CTA Card: stack buttons ── */
    .ce-cta-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .ce-cta-btn {
        text-align: center;
    }

    .ce-cta-card {
        padding: 1.25rem;
    }

    /* ── Products grid: single column ── */
    .ce-products-grid {
        grid-template-columns: 1fr;
    }

    /* ── Expert bio: stack vertically ── */
    .ce-expert-bio {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .ce-expert-bio-links {
        justify-content: center;
    }

    /* ── Key stat: smaller ── */
    .ce-key-stat-value {
        font-size: 1.75rem;
    }

    .ce-key-stat {
        padding: 1.5rem 1rem;
    }

    /* ── All callout boxes: tighter padding ── */
    .ce-pro-tip,
    .ce-warning,
    .ce-did-you-know {
        padding: 1rem 1rem 1rem 1.25rem;
    }
}


/* =====================================================================
   13. PRINT STYLES
   ===================================================================== */

@media print {

    /* Remove decorative shadows and backgrounds */
    .ce-cta-card,
    .ce-product-card,
    .ce-expert-bio,
    .ce-toc,
    .ce-quick-reference {
        box-shadow: none !important;
        background: #fff !important;
        border: 1px solid #ccc !important;
    }

    /* Hide CTA buttons in print */
    .ce-cta-actions {
        display: none !important;
    }

    /* Make TOC always expanded */
    .ce-toc ol {
        max-height: none !important;
        overflow: visible !important;
    }

    .ce-toc-toggle-label {
        display: none !important;
    }

    /* Ensure callout boxes print legibly */
    .ce-pro-tip,
    .ce-warning,
    .ce-did-you-know {
        background: #f9f9f9 !important;
        border-left-width: 3px !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Product grid → single column for paper */
    .ce-products-grid {
        grid-template-columns: 1fr !important;
    }

    /* Ensure links show their URL */
    .ce-product-link::after,
    .ce-expert-bio-links a::after {
        content: " (" attr(href) ")" !important;
        font-size: 0.75rem;
        font-weight: 400;
        color: #666;
    }

    /* Hide sticky behavior */
    .ce-toc.ce-toc-sticky {
        position: static !important;
    }
}


/* =====================================================================
   14. ACCESSIBILITY / FOCUS INDICATORS
   ===================================================================== */

/* Visible focus ring for keyboard navigation */
.ce-cta-btn:focus-visible,
.ce-toc a:focus-visible,
.ce-product-link:focus-visible,
.ce-expert-bio-links a:focus-visible {
    outline: 3px solid var(--ce-accent);
    outline-offset: 2px;
}

/* Ensure sufficient contrast for light backgrounds */
.ce-pro-tip,
.ce-did-you-know,
.ce-warning {
    /* Text colors set explicitly above to meet WCAG AA on their backgrounds */
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .ce-product-card,
    .ce-cta-btn,
    .ce-toc a,
    .ce-expert-bio a,
    .ce-toc ol {
        transition: none !important;
    }

    .ce-product-card:hover {
        transform: none !important;
    }
}

