/* RankHandy Single Post Template Styles */

:root {
    --rh-primary: #007bff;
    /* Verified Blue */
    --rh-text: #333333;
    --rh-bg: #FFFFFF;
    --rh-gray-light: #f8f9fa;
    --rh-border: #e9ecef;
    --rh-accent: #FE8848;
    /* Verified Orange Accent */
    --rh-font-heading: 'Inter', sans-serif;
    --rh-font-body: 'Roboto', sans-serif;
}

/* GLOBAL OVERRIDES to fix background issues */
body.single-post,
body.page-template-single-rankhandy {
    background-color: #FFFFFF !important;
}

/* Force container to break out of theme constraints if needed */
.rankhandy-blog-container {
    font-family: var(--rh-font-body);
    color: var(--rh-text);
    background: var(--rh-bg);
    line-height: 1.6;

    /* Full Width Breakout Strategy */
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    padding-bottom: 60px;
    /* Space for sticky footer */
}

.rh-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* HERO SECTION */
.rh-hero {
    padding: 40px 0 10px 0;
    text-align: left;
}

.rh-breadcrumbs {
    font-size: 0.9em;
    color: #6c757d;
    margin-bottom: 15px;
}

.rh-breadcrumbs a {
    color: #6c757d;
    text-decoration: none;
    transition: color 0.2s;
}

.rh-breadcrumbs a:hover {
    color: var(--rh-accent);
}

.rh-title {
    font-family: var(--rh-font-heading);
    font-size: 3rem;
    font-weight: 700;
    margin: 0 0 20px 0;
    line-height: 1.2;
}

.rh-meta {
    display: flex;
    align-items: center;
    font-size: 0.9em;
    color: #6c757d;
    margin-bottom: 10px;
}

.rh-author {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rh-author img {
    border-radius: 50%;
    width: 40px;
    height: 40px;
    object-fit: cover;
}

.rh-meta-divider {
    margin: 0 15px;
    color: #dee2e6;
}

/* CONTENT LAYOUT */
.rh-content-wrapper {
    display: flex;
    gap: 40px;
    position: relative;
}

.rh-main-content {
    flex: 2;
    /* Approx 66% width */
    max-width: 800px;
    /* Optimal reading width */
}

.rh-sidebar {
    flex: 1;
    /* Approx 33% width */
    position: relative;
}

/* ARTICLE STYLES */
.rh-key-takeaways {
    background: #f0f7ff;
    border-left: 5px solid var(--rh-primary);
    padding: 25px;
    margin-bottom: 40px;
    border-radius: 8px;
}

.rh-key-takeaways h3 {
    color: var(--rh-primary);
    margin-top: 0;
}

.rh-article-body h2 {
    font-family: var(--rh-font-heading);
    font-size: 2rem;
    margin-top: 40px;
    margin-bottom: 20px;
}

/* Remove top margin from first element to close the gap */
.rh-article-body>*:first-child {
    margin-top: 0 !important;
}

.rh-article-body h3 {
    font-family: var(--rh-font-heading);
    font-size: 1.5rem;
    margin-top: 30px;
    margin-bottom: 15px;
}

.rh-article-body p {
    font-size: 1.125rem;
    margin-bottom: 1.5em;
    color: #4a4a4a;
}

.rh-article-body a {
    color: var(--rh-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
    border-bottom: 1px solid transparent;
}

.rh-article-body a:hover {
    color: var(--rh-accent);
    border-bottom-color: var(--rh-accent);
}

/* Pro Tip Box - Updated to Orange Accent */
.rh-pro-tip {
    background: #FFF8E1;
    /* Light orange tint */
    border: 1px solid #FFE0B2;
    padding: 20px;
    border-radius: 8px;
    margin: 30px 0;
    position: relative;
}

.rh-pro-tip h4 {
    margin-top: 0;
    color: #E65100;
    /* Darker Orange for text */
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Native Ad - Matches Blue Gradient Style */
.rh-native-ad {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    padding: 40px;
    border-radius: 12px;
    margin: 50px 0;
    text-align: center;
}

.rh-native-ad h3 {
    color: white;
    margin-top: 0;
}

.rh-btn {
    display: inline-block;
    padding: 12px 24px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 8px;
    /* Matched to 8px */
    transition: all 0.3s ease;
    cursor: pointer;
}

/* Primary Button - White on Blue Gradient, Blue on White BG */
.rh-btn-primary {
    background: white;
    color: var(--rh-primary);
}

.rh-btn-primary:hover {
    background: #f8f9fa;
    color: var(--rh-accent);
    /* Orange text on hover */
    transform: translateY(-2px);
}

/* SIDEBAR WIDGETS */
.rh-sidebar-inner {
    position: sticky;
    top: 100px;
    /* max-height: viewport - top offset - bottom padding */
    max-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow: hidden;
    /* Prevent container scroll, let TOC scroll */
}

/* TOC Widget - Flexible height */
.rh-toc-widget {
    background: white;
    border: 1px solid var(--rh-border);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 0;
    /* Handled by gap */

    /* Flex magic: Shrink if needed, but don't grow unnecessarily */
    flex: 0 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 150px;
    /* Ensure at least some TOC is visible */
}

.rh-toc-widget h3 {
    margin-top: 0;
    margin-bottom: 15px;
    flex-shrink: 0;
    /* Title always visible */
}

.rh-toc-nav {
    overflow-y: auto;
    /* Custom Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--rh-border) transparent;
}

.rh-toc-nav ul {
    list-style: none;
    padding-right: 10px;
    margin: 0;
}

/* Scrollbar styles for Webkit */
.rh-toc-nav::-webkit-scrollbar {
    width: 4px;
}

.rh-toc-nav::-webkit-scrollbar-thumb {
    background-color: var(--rh-border);
    border-radius: 4px;
}

.rh-toc-nav li {
    margin-bottom: 10px;
}

.rh-toc-nav li.h3 {
    margin-left: 15px;
    font-size: 0.9em;
}

.rh-toc-nav a {
    color: #6c757d;
    text-decoration: none;
    transition: color 0.2s;
}

.rh-toc-nav a:hover,
.rh-toc-nav a.active {
    color: var(--rh-primary);
    font-weight: 600;
}

/* CTA Widget - Fixed height, always visible at bottom */
.rh-cta-widget {
    background: #ffffff;
    border: 1px solid var(--rh-border);
    color: var(--rh-text);
    padding: 30px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
    /* NEVER shrink this */
}

.rh-cta-widget h3 {
    color: var(--rh-text);
    margin-top: 0;
}

.rh-btn-block {
    display: block;
    background: var(--rh-primary);
    color: white;
    text-align: center;
    margin-top: 20px;
    transition: background 0.3s ease;
}

.rh-btn-block:hover {
    background: var(--rh-accent);
    /* Orange on hover */
}

/* STICKY FOOTER */
.rh-sticky-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: white;
    border-top: 1px solid var(--rh-border);
    padding: 15px 0;
    z-index: 9999;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.05);
}

.rh-flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rh-sticky-text {
    font-weight: 600;
}

.rh-btn-sm {
    background: var(--rh-primary);
    color: white;
    padding: 8px 16px;
    font-size: 0.9em;
}

.rh-close-sticky {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    margin-left: 20px;
    color: #999;
}

/* RESPONSIVE */
@media (max-width: 900px) {
    .rh-content-wrapper {
        flex-direction: column;
    }

    .rh-sidebar {
        order: -1;
        /* Move sidebar (likely TOC) above content on mobile, or keep below? User requested TOC as accordion on mobile */
    }

    .rh-sidebar-inner {
        position: static;
        max-height: none;
        /* Reset desktop sticky height */
        overflow: visible;
        /* Reset desktop scroll */
        display: block;
        /* Reset flex column */
    }

    .rh-toc-widget {
        background: #f8f9fa;
        min-height: auto;
        /* Reset flex min-height */
        margin-bottom: 20px;
    }

    .rh-toc-nav ul {
        max-height: none;
        /* Let TOC expand fully */
        overflow: visible;
        padding-right: 0;
    }

    .rh-cta-widget {
        margin-top: 20px;
        /* Add spacing since gap is gone */
    }

    .rh-title {
        font-size: 2rem;
    }
}