/* --- SINGLE POST TEMPLATE (ISOLATED) --- */

/* Hero Header */
.acme-single-hero {
    background-color: #1e1e1e;
    /* Dark background as reference */
    color: #fff;
    padding: 60px 20px;
    margin-bottom: 0;
    width: 100%;
}

.acme-hero-inner {
    max-width: 1200px;
    margin: 0 auto;
}

.acme-single-hero .entry-title {
    font-size: 3rem;
    margin: 0 0 20px 0;
    line-height: 1.2;
    color: #fff !important;
}

.acme-single-hero .acme-entry-meta {
    font-size: 1rem;
    color: #ccc !important;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 15px;
    white-space: nowrap;
    line-height: 1.3;
}

.acme-entry-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.acme-meta-icon {
    color: var(--acme-blue-light);
    stroke: var(--acme-blue-light);
    flex-shrink: 0;
}

/* Mobile Meta Refinement */
@media (max-width: 480px) {
    .acme-single-hero .acme-entry-meta {
        font-size: 0.85rem;
        gap: 10px;
    }
}

/* Tablet/Mobile Meta Padding */
@media (max-width: 1023px) {
    .acme-single-hero .acme-entry-meta {
        padding: 0 16px;
        flex-wrap: wrap;
        white-space: normal;
        justify-content: center;
        /* Center align for better look on mobile */
    }

    .acme-single-hero .acme-updated {
        flex-basis: 100%;
        width: 100%;
        justify-content: center;
        margin-top: 5px;
        /* Add some spacing between lines */
    }
}

@media (max-width: 767px) {
    .acme-single-hero .acme-entry-meta {
        padding: 0 12px;
    }
}

.acme-single-post-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    display: flex;
    gap: 60px;
    position: relative;
    box-sizing: border-box;
    margin-bottom: 100px;
    /* Ensure sidebar stops before footer */
}

/* Main Content Column */
.acme-single-post-container .acme-main-content {
    flex: 1;
    min-width: 0;
    /* Prevent flex overflow */
}

/* Post Styling */
.acme-single-post-container article {
    margin-bottom: 40px;
}

/* ============================================
   ACME TOC Component - Scoped & Responsive Styles
   ============================================ */

/* Reset only within TOC scope */
.acme-toc-wrapper *,
.acme-toc-fab *,
.acme-toc-modal * {
    box-sizing: border-box;
}

/* ============================================
   MOBILE FIRST: Base Styles (< 768px)
   ============================================ */

/* Hide desktop TOC on mobile */
.acme-toc-wrapper {
    display: none;
}

/* Floating Action Button (FAB) */
.acme-toc-fab {
    position: fixed;
    position: fixed;
    /* Respect Safe Area + clear the progress bar height (approx 40px) */
    bottom: calc(50px + env(safe-area-inset-bottom, 0px));
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: #0066CC;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
    z-index: 1000000;
    /* Higher than mobile progress bar (999999) */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}


.acme-toc-fab:hover {
    background-color: #0052A3;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.19), 0 6px 12px rgba(0, 0, 0, 0.28);
    transform: scale(1.05);
}

.acme-toc-fab:focus {
    outline: 2px solid #4D90FE;
    outline-offset: 2px;
}

.acme-toc-fab:active {
    transform: scale(0.95);
}

.acme-toc-fab-icon {
    color: #FFFFFF;
    width: 24px;
    height: 24px;
}

/* Modal/Bottom Sheet */
.acme-toc-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000001;
    /* Higher than FAB */
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s linear 0.3s, opacity 0.3s ease-in-out;
}


.acme-toc-modal.acme-toc-modal-active {
    visibility: visible;
    opacity: 1;
    transition-delay: 0s;
}

.acme-toc-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.acme-toc-modal-content {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 90%;
    background-color: #FFFFFF;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.acme-toc-modal.acme-toc-modal-active .acme-toc-modal-content {
    transform: translateY(0);
}

/* Mobile Modal Header */
/* Mobile Modal Header */
.acme-toc-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #E0E0E0;
    flex-shrink: 0;
}



.acme-toc-modal-title {
    font-size: 20px;
    font-weight: 600;
    color: #333333;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.acme-toc-modal-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    color: #333333;
}

.acme-toc-modal-close:hover {
    background-color: #F0F0F0;
}

.acme-toc-modal-close:focus {
    outline: 2px solid #4D90FE;
    outline-offset: 2px;
}

.acme-toc-modal-list {
    list-style: none;
    padding: 16px 0;
    overflow-y: auto;
    flex: 1;
    margin: 0;
    /* User Requested Border at End */
    border-bottom: 4px solid #CBD5E1;
}

.acme-toc-modal-list .acme-toc-item {
    margin: 0;
}

.acme-toc-modal-list .acme-toc-link {
    display: block;
    padding: 16px 24px;
    color: #333333;
    text-decoration: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    transition: background-color 0.2s ease, color 0.2s ease;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.acme-toc-modal-list .acme-toc-link:hover {
    background-color: #F0F4F8;
    color: #0066CC;
}

.acme-toc-modal-list .acme-toc-link:focus {
    outline: 2px solid #4D90FE;
    outline-offset: -2px;
}

.acme-toc-modal-list .acme-toc-link.is-active {
    background-color: #F0F4F8;
    color: #0066CC;
    border-left: 3px solid #0066CC;
    padding-left: 21px;
}

/* Level indentation in modal */
.acme-toc-modal-list .acme-toc-item.h2 .acme-toc-link {
    padding-left: 24px;
    font-weight: 600;
    font-size: 16px;
    border-bottom: 1px solid #f0f0f0;
}

.acme-toc-modal-list .acme-toc-item.h3 .acme-toc-link {
    padding-left: 40px;
    font-weight: 400;
    font-size: 14px;
    color: #555;
    border-bottom: 1px solid #f0f0f0;
}

/* Modern Link Styling (Mobile) */
.acme-toc-modal-list .acme-toc-link {
    text-decoration: none !important;
    /* Force remove underline */
    color: #333;
    transition: all 0.2s ease;
}

.acme-toc-modal-list .acme-toc-link:hover,
.acme-toc-modal-list .acme-toc-link:active {
    background-color: #f7f9fc;
    color: var(--acme-blue-primary, #0066CC);
    padding-left: 20px;
    /* Subtle slide effect */
}


/* Base Style: Hide toggle button by default (Mobile/Tablet) */
.acme-toc-toggle {
    display: none !important;
}

/* ============================================
   TABLET: 768px - 1024px
   ============================================ */
/* ============================================
   TABLET: 768px - 1024px
   ============================================ */
@media (min-width: 768px) {

    /* Hide FAB on tablet+ */
    .acme-toc-fab {
        display: none;
    }

    /* Hide modal on tablet+ */
    .acme-toc-modal {
        display: none;
    }

    /* Show desktop TOC - Base Styles for Tablet+ */
    .acme-toc-wrapper {
        display: block;
        background-color: #FFFFFF;
        border: 1px solid #E2E8F0;
        border-left: 6px solid var(--acme-blue-primary, #0066CC);
        border-radius: 8px;
        padding: 0;
        margin-bottom: 40px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
        position: -webkit-sticky;
        position: sticky;
        top: 90px;
        z-index: 10;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow: hidden;
        max-height: 70vh;
    }

    .acme-toc-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 15px 20px;
        background: #F8FAFC;
    }

    .acme-toc-title {
        font-size: 1rem;
        margin: 0;
        color: var(--acme-navy-deep, #333333);
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    /* Toggle Button (Visible on Tablet+) */
    .acme-toc-toggle {
        display: flex !important;
        background: #FFFFFF;
        border: 1px solid rgba(0, 0, 0, 0.08);
        cursor: pointer;
        color: var(--acme-blue-primary, #0066CC);
        padding: 0;
        align-items: center;
        justify-content: center;
        transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
        border-radius: 999px;
        position: relative;
        overflow: hidden;
        width: 40px;
        height: 40px;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.12);
    }

    .acme-toc-toggle::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 0;
        height: 0;
        border-radius: 999px;
        background: color-mix(in srgb, var(--acme-blue-primary, #0066CC) 20%, transparent);
        transform: translate(-50%, -50%);
        transition: width 0.6s, height 0.6s;
    }

    .acme-toc-toggle:hover::before {
        width: 100%;
        height: 100%;
    }

    .acme-toc-toggle:hover {
        background: #F8FAFC;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12), 0 6px 16px rgba(0, 0, 0, 0.12);
        transform: translateY(-1px);
    }

    .acme-toc-toggle:active {
        transform: translateY(0);
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16);
        background: #EEF2F7;
    }

    .acme-toc-toggle svg {
        position: relative;
        z-index: 1;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        transform: rotate(180deg);
        /* Default: Expanded (UP) */
    }

    .acme-toc-wrapper.is-collapsed .acme-toc-toggle svg {
        transform: rotate(0deg);
        /* Collapsed (DOWN) */
    }

    /* Logic to actually collapse the content */
    .acme-toc-wrapper.is-collapsed .acme-toc-content {
        max-height: 0 !important;
        height: 0 !important;
        min-height: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        opacity: 0;
        pointer-events: none;
        margin: 0 !important;
        overflow: hidden;
        border: none !important;
        border-bottom: none !important;
        visibility: hidden;
    }

    /* Hide list when collapsed */
    .acme-toc-wrapper.is-collapsed .acme-toc-list {
        display: none;
    }

    /* Remove header border-bottom when collapsed */
    .acme-toc-wrapper.is-collapsed .acme-toc-header {
        border-bottom: none !important;
        margin-bottom: 0;
        padding-bottom: 15px;
    }

    /* Adjust wrapper height when collapsed */
    .acme-toc-wrapper.is-collapsed {
        max-height: fit-content;
        height: auto;
        padding-bottom: 0;
    }

    .acme-toc-content {
        max-height: 1000px;
        transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease;
        padding: 20px;
        overflow-y: auto;
    }

    .acme-toc-list {
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .acme-toc-item {
        margin-bottom: 12px;
    }

    .acme-toc-item:last-child {
        margin-bottom: 0;
    }

    .acme-toc-item.h3 {
        padding-left: 20px;
    }

    .acme-toc-link {
        text-decoration: none !important;
        color: var(--acme-blue-dark, #666666);
        font-weight: 500;
        font-size: 13px;
        transition: all 0.2s ease;
        display: block;
        line-height: 1.4;
        padding: 10px 12px;
        border-left: 2px solid transparent;
        border-radius: 4px;
        min-height: 44px;
        display: flex;
        align-items: center;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .acme-toc-link:hover {
        background-color: #F0F4F8;
        color: var(--acme-blue-primary, #0066CC);
    }

    .acme-toc-link:focus {
        outline: 2px solid #4D90FE;
        outline-offset: 2px;
    }

    .acme-toc-link.is-active {
        color: var(--acme-blue-primary, #0066CC);
        font-weight: 700;
        border-left-color: var(--acme-blue-primary, #0066CC);
        background-color: #F0F4F8;
    }

    /* Compact Sticky TOC State */
    .acme-toc-wrapper.is-stuck {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    }

    .acme-toc-wrapper.is-stuck .acme-toc-header {
        padding: 10px 20px;
    }

    .acme-toc-wrapper.is-stuck .acme-toc-title {
        font-size: 0.95rem;
    }
}

/* ============================================
   STRICT TABLET OVERRIDES (768px - 1023px)
   ============================================ */
/* ============================================
   STRICT TABLET OVERRIDES (768px - 1023px)
   ============================================ */
@media (min-width: 768px) and (max-width: 1023px) {
    .acme-toc-wrapper {
        border-left: 1px solid #e5e7eb;
        /* Override thick border */
        border-radius: 12px;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        /* Disable sticky on tablet to prevent blocking content */
        position: relative;
        top: auto;
        width: 100%;
        margin-bottom: 30px;
        z-index: 1;
    }

    .acme-toc-header {
        background: #f8fafc;
        border-bottom: 1px solid #E2E8F0;
        /* Clean light border */
        padding: 16px 20px;
        box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
        /* Modern separation */
    }

    .acme-toc-content {
        padding: 16px 0;
        /* User Requested Border at End */
        border-bottom: 4px solid #CBD5E1;
    }

    /* Remove border when collapsed on tablet */
    .acme-toc-wrapper.is-collapsed .acme-toc-content {
        border-bottom: none !important;
        height: 0 !important;
        min-height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Remove header border when collapsed on tablet */
    .acme-toc-wrapper.is-collapsed .acme-toc-header {
        border-bottom: none !important;
        margin-bottom: 0;
        box-shadow: none;
    }

    .acme-toc-link {
        color: #64748b;
        font-size: 14px;
        padding: 10px 20px;
        border-left-width: 3px;
    }

    .acme-toc-link:hover {
        background-color: #f1f5f9;
        color: var(--acme-blue-primary, #0284c7);
        border-left-color: var(--acme-blue-primary, #0284c7);
    }

    .acme-toc-link.is-active {
        background-color: #f0f9ff;
        color: var(--acme-blue-primary, #0284c7);
    }

    .acme-toc-item.h3 .acme-toc-link {
        padding-left: 32px;
    }
}

/* ============================================
   DESKTOP: 1024px+
   ============================================ */
@media (min-width: 1024px) {
    .acme-toc-wrapper {
        max-height: calc(100vh - 48px);
        transition: opacity 0.3s ease;
        border-left: 1px solid #E2E8F0;
        border-right: 1px solid #E2E8F0;
    }

    /* Ensure collapsed wrapper fits header only on desktop */
    .acme-toc-wrapper.is-collapsed {
        max-height: fit-content;
        height: auto;
        padding-bottom: 0;
    }

    /* Remove header border when collapsed on desktop */
    .acme-toc-wrapper.is-collapsed .acme-toc-header {
        border-bottom: none !important;
        margin-bottom: 0;
    }

    /* Ensure content is fully collapsed on desktop */
    .acme-toc-wrapper.is-collapsed .acme-toc-content {
        height: 0 !important;
        min-height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
    }

    .acme-toc-wrapper.acme-toc-fading {
        opacity: 0;
        pointer-events: none;
    }

    .acme-toc-title {
        font-size: 1.1rem;
    }

    .acme-toc-link {
        font-size: 14px;
        padding: 12px 14px;
    }

    .acme-toc-item.h2 .acme-toc-link {
        font-size: 14px;
        font-weight: 600;
        color: var(--acme-navy-deep, #333333);
    }

    .acme-toc-item.h3 .acme-toc-link {
        font-size: 12px;
        color: #999999;
    }

    /* Toggle button styles moved to min-width: 768px block */
}

/* ============================================
   ACCESSIBILITY ENHANCEMENTS
   ============================================ */

/* Ensure focus is always visible */
.acme-toc-toggle:focus {
    outline: none;
    /* Remove default browser outline on click */
}

.acme-toc-link:focus-visible,
.acme-toc-fab:focus-visible,
.acme-toc-modal-close:focus-visible,
.acme-toc-toggle:focus-visible {
    outline: 2px solid #4D90FE;
    outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {

    .acme-toc-fab,
    .acme-toc-link,
    .acme-toc-modal,
    .acme-toc-modal-content,
    .acme-toc-wrapper {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .acme-toc-wrapper {
        border: 2px solid currentColor;
    }

    .acme-toc-link.is-active {
        border-left-width: 4px;
    }
}


.acme-single-post-container .acme-entry-content {
    line-height: 1.8;
    color: #333;
    font-size: 1.1rem;
}

.acme-single-post-container .acme-entry-content h2,
.acme-single-post-container .acme-entry-content h3 {
    margin-top: 1.5em;
    margin-bottom: 0.8em;
    color: #222;
}

.acme-single-post-container .acme-entry-content p {
    margin-bottom: 1.5em;
}

/* Sidebar Column */
.acme-single-post-container .acme-single-sidebar {
    width: 300px;
    flex-shrink: 0;
    position: relative;
}

/* Sticky Sidebar Content */
.acme-single-post-container .acme-progress-widget,
.acme-single-post-container .acme-related-posts {
    margin-bottom: 40px;
}

.acme-single-post-container .acme-single-sidebar {
    position: -webkit-sticky;
    position: sticky;
    top: 100px;
    align-self: start;
    z-index: 20;
    /* Removed fit-content to rely on natural height */
}

/* Ensure container allows sticky */
.acme-single-post-container {
    overflow: visible !important;
}

/* Widget Styles */
.acme-single-post-container .widget-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 15px;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Desktop Progress Bar Widget */
.acme-single-post-container .acme-progress-container-start {
    width: 100%;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 10px;
}

.acme-single-post-container .acme-progress-bar {
    height: 100%;
    width: 0%;
    background: #2271b1;
    transition: width 0.1s linear;
}

.acme-single-post-container .acme-progress-text {
    font-weight: 600;
    color: #2271b1;
    text-align: right;
}

/* Related Posts List */
.acme-single-post-container .acme-related-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.acme-single-post-container .acme-related-list li {
    margin-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 12px;
}

.acme-single-post-container .acme-related-list li:last-child {
    border-bottom: none;
}

.acme-single-post-container .acme-related-list a {
    text-decoration: none;
    color: #555;
    font-weight: 500;
    transition: color 0.2s;
    display: block;
    line-height: 1.4;
}

.acme-single-post-container .acme-related-list a:hover {
    color: #2271b1;
}

/* Mobile Progress Bar */
body.single-post #mobile-progress-bar {
    display: none;
    /* JS toggles this */
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    /* Allow height to grow with padding */
    /* Fixed height to prevent CLS */
    height: 50px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-sizing: content-box;
    /* Height + Padding */
    background: #fff;
    z-index: 999999;
    /* Constrained shadow to prevent horizontal overflow */
    box-shadow: 0 -2px 10px 0 rgba(0, 0, 0, 0.1);
    align-items: center;
    border-top: 1px solid #eee;
    /* Use display: flex by default on mobile to prevent JS CLS */
    display: flex;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    overflow: hidden;
    /* Ensure nothing spills out */
}

body.single-post #mobile-progress-bar.acme-bar-hidden {
    transform: translateY(100%);
}

#mobile-progress-fill {
    height: 4px;
    width: 0%;
    background: #2271b1;
    position: absolute;
    top: 0;
    left: 0;
    transition: width 0.1s linear;
}

.acme-mobile-progress-text {
    font-size: 13px;
    color: #333;
    margin-left: 12px;
    font-weight: 700;
    margin-top: 0;
    /* Align center */
    line-height: 1;
    z-index: 2;
    /* Ensure above fill */
    position: relative;
}

/* --- RESPONSIVE --- */
@media (max-width: 900px) {
    .acme-single-post-container {
        gap: 40px;
    }

    .acme-single-post-container .acme-single-sidebar {
        width: 250px;
    }
}

@media (max-width: 767px) {


    /* Stack Layout */
    .acme-single-post-container {
        flex-direction: column;
        padding: 30px 20px;
        gap: 40px;
    }

    /* Reserve space for sticky progress bar (50px height + safe area) */
    body.single-post {
        padding-bottom: calc(50px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .acme-single-post-container .acme-single-sidebar {
        width: 100%;
        position: static;
        border-top: 1px solid #eee;
        padding-top: 40px;
    }

    /* Hide Desktop Progress Widget */
    .acme-single-post-container .acme-progress-widget {
        display: none;
    }

    /* Show Mobile Sticky Progress Bar */
    body.single-post #mobile-progress-bar {
        display: flex;
    }

    /* Move Related Posts to bottom flow naturally */
    .acme-single-post-container .acme-related-posts {
        margin-bottom: 0;
    }

    .acme-single-post-container {
        margin-bottom: 0;
        /* Remove extra margin on mobile if handled by bar hiding, or keep if needed */
    }
}