/* ==========================================================================
   Single Article Detailed Styles (Reference Design Structured)
   ========================================================================== */
:root {
    --c-accent-blue: #2563eb;
    /* Strong blue for key accents */
    --c-accent-blue-light: #eff6ff;
    --c-sidebar-bg: #f3f4f6;
    /* slightly darker off-white for contrasts */
    --c-sidebar-border: #e5e7eb;
}

.article-main {
    padding-top: 0;
    position: relative;
}

.global-progress-bar {
    position: fixed;
    bottom: 0 !important;
    top: auto !important;
    left: 0;
    height: 4px;
    background-color: var(--c-accent-blue);
    width: 0%;
    z-index: 10000;
    transition: width 0.1s ease;
}

/* Hero Header */
.entry-header-hero {
    position: relative;
    color: var(--c-text-main);
    margin-bottom: var(--spacing-md);
    /* Reduced from xl to md */
    padding: 0 var(--spacing-sm);
    margin-top: 0;
    /* Remove negative margin — let it sit naturally below the sticky header */
    text-align: right;
}

.hero-image-wrapper {
    position: relative;
    width: 100%;
    max-width: 1200px;
    /* Constrain width to not stretch full screen */
    margin: 0 auto;
    /* Center it */
    height: 70vh;
    /* Increased height */
    min-height: 500px;
    max-height: 700px;
    overflow: hidden;
    border-radius: 20px;
    /* Rounded corners */
}

.hero-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.3) 50%, rgba(0, 0, 0, 0.1) 100%);
}

.hero-content {
    position: absolute;
    bottom: var(--spacing-lg);
    left: 5%;
    width: 90%;
    z-index: 2;
    padding: 0 var(--spacing-sm);
    text-align: right;
    /* Ensure RTL alignment */
}

.hero-meta {
    display: flex;
    gap: var(--spacing-sm);
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: var(--spacing-sm);
}

.meta-category {
    background-color: var(--c-accent-blue);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
}

.hero-title {
    font-size: 3.5rem;
    color: white;
    margin: 0 0 var(--spacing-md) 0;
    line-height: 1.2;
    max-width: 800px;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.6;
    max-width: 700px;
}

/* Standard Header without Image */
.entry-header-standard {
    padding-top: var(--spacing-xl);
    padding-bottom: var(--spacing-lg);
    text-align: right;
    border-bottom: 1px solid var(--c-border);
    margin-bottom: var(--spacing-xl);
}

/* Two-Column Layout */
.article-layout {
    display: flex;
    gap: var(--spacing-xl);
    align-items: flex-start;
    height: 100%;
    /* Important for sticky sidebar to work */
}

.article-body {
    flex: 1;
    min-width: 0;
    max-width: 780px;
    /* Wider reading max-width */
}

/* Smooth Scrolling and Scroll Margin/Padding for Anchor Links */
html {
    scroll-behavior: smooth;
    scroll-padding-top: 100px;
    /* Gives a comfortable top offset so headings don't hug the browser top */
}

/* Sidebar Structure */
.article-sidebar {
    width: 280px;
    flex-shrink: 0;
    position: sticky;
    top: 40px;
    /* Ensures the sidebar stays sticky correctly */
    align-self: flex-start;
    /* Stops the flex item from stretching, crucial for sticky to work! */
}

.sticky-sidebar-inner {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
}

/* Hide scrollbar for sidebar inner but keep functionality */
.sticky-sidebar-inner::-webkit-scrollbar {
    width: 0;
    background: transparent;
}

.sidebar-widget {
    margin-bottom: 0;
}

.widget-title {
    display: block;
    font-size: 0.75rem;
    color: var(--c-text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
}

/* Progress Widget */
.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--c-text-muted);
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.progress-percentage {
    color: var(--c-accent-blue);
}

.progress-track {
    width: 100%;
    height: 4px;
    background-color: var(--c-sidebar-border);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--c-accent-blue);
    width: 0%;
    transition: width 0.1s ease;
}

/* ToC Widget */
#toc-container ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#toc-container li {
    position: relative;
    margin-bottom: 4px;
    padding: 6px 18px 6px 6px;
    /* Room for active indicator and click area */
    border-right: 2px solid transparent;
    border-radius: 4px 0 0 4px;
    /* Slight rounding on left side */
    transition: background-color 0.2s ease;
}

/* Hover State */
#toc-container li:hover {
    background-color: var(--c-sidebar-bg);
    /* Subtle background on hover */
}

/* Active State Styles */
#toc-container li.active {
    border-right-color: var(--c-accent-blue);
    background-color: var(--c-accent-blue-light);
    /* Distinct background for active */
}

#toc-container li::before {
    content: '';
    position: absolute;
    right: -2px;
    /* Align over border */
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 0;
    background: var(--c-accent-blue);
    transition: height 0.2s ease;
}

#toc-container li.active::before {
    height: 100%;
}

#toc-container li a {
    text-decoration: none;
    color: var(--c-text-muted);
    font-size: 0.95rem;
    transition: all 0.2s ease;
    display: block;
}

#toc-container li:hover a {
    color: var(--c-text-main);
}

#toc-container li.active a {
    color: var(--c-accent-blue);
    /* Strong distinct color */
    font-weight: 700;
    /* Bold active state */
}

#toc-container li.toc-level-h3 {
    margin-right: 12px;
    font-size: 0.85rem;
}

/* Ensure headings have scroll-margin to play nicely with offset */
h1,
h2,
h3,
h4,
h5,
h6 {
    scroll-margin-top: 100px;
}

/* Subscribe Widget */
.subscribe-widget {
    background: var(--c-sidebar-bg);
    padding: var(--spacing-md);
    border-radius: 8px;
    border: 1px solid var(--c-sidebar-border);
}

.subscribe-widget p {
    font-size: 0.85rem;
    color: var(--c-text-muted);
    margin-bottom: var(--spacing-sm);
    line-height: 1.5;
}

.btn-subscribe-small {
    display: block;
    width: 100%;
    text-align: center;
    background: var(--c-accent-blue);
    color: white;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

.btn-subscribe-small:hover {
    background: #1d4ed8;
    /* darker blue */
    color: white;
}

/* Core Content Typography & Block Styles */
.entry-content {
    font-size: 1.15rem;
    /* Slightly larger base size for deep reading */
}

/* Large stylish blockquote (matching the blue italic text out of layout) */
.wp-block-quote,
blockquote {
    font-family: var(--font-sans);
    font-size: 1.6rem;
    color: var(--c-accent-blue);
    font-style: italic;
    border: none;
    /* No border for the main stylish quote */
    padding: 0 var(--spacing-md);
    margin: var(--spacing-xl) 0;
    font-weight: 500;
    position: relative;
    line-height: 1.4;
}

blockquote::before {
    content: '"';
    position: absolute;
    right: -10px;
    top: -20px;
    font-size: 4rem;
    color: var(--c-accent-blue-light);
    z-index: -1;
    line-height: 1;
}

/* Replicate "Key Takeaway" Information Box */
.is-style-insight-box,
.wp-block-group.insight-box {
    background-color: var(--c-sidebar-bg);
    border: 1px solid var(--c-sidebar-border);
    padding: var(--spacing-lg);
    border-radius: 8px;
    margin: var(--spacing-lg) 0;
}

.is-style-insight-box h3,
.insight-box-title {
    color: var(--c-accent-blue);
    font-size: 1.1rem;
    margin-bottom: var(--spacing-sm);
    margin-top: 0;
    font-family: var(--font-sans);
}

/* Headers with Numbered Style support */
.entry-content h2 {
    font-size: 2.2rem;
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    border: none;
    padding: 0;
}

/* Lists styling to match numbered highlights */
.entry-content ol {
    padding-right: 2rem;
    /* RTL */
    counter-reset: item;
    list-style-type: none;
}

.entry-content ol>li {
    position: relative;
    margin-bottom: 1rem;
}

.entry-content ol>li::before {
    content: "0" counter(item) ".";
    counter-increment: item;
    position: absolute;
    right: -2.5rem;
    color: var(--c-accent-blue);
    font-weight: 700;
    font-size: 1.1rem;
}

/* Author Box */
.author-bio-box {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-lg) 0;
    margin-top: var(--spacing-xl);
    border-top: 1px solid var(--c-border);
}

.author-avatar img {
    border-radius: 50%;
    width: 60px;
    height: 60px;
}

.author-info {
    flex: 1;
}

.author-name {
    margin: 0 0 5px 0;
    font-size: 1.2rem;
}

.author-desc {
    margin: 0;
    color: var(--c-text-muted);
    font-size: 0.95rem;
}

.btn-follow {
    background-color: var(--c-sidebar-bg);
    color: var(--c-text-main);
    border: 1px solid var(--c-sidebar-border);
    padding: 0.5rem 1.2rem;
    font-size: 0.9rem;
    border-radius: 20px;
}

.btn-follow:hover {
    background-color: var(--c-sidebar-border);
}

/* Responsive constraints */
@media (max-width: 1024px) {
    .article-layout {
        flex-direction: column;
    }

    .article-sidebar {
        width: 100%;
        margin-bottom: var(--spacing-xl);
        border-bottom: 1px solid var(--c-border);
        padding-bottom: var(--spacing-md);
    }

    .sticky-sidebar-inner {
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .sidebar-widget {
        flex: 1;
        min-width: 200px;
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .article-body {
        max-width: 100%;
    }
}