/* ============================================================
   AO Table of Contents – ao-toc.css  v1.2.5
   Left sticky rail (desktop) · Slide-up drawer (mobile)
   Brand: #ff791f orange · #25232e dark · #E2E2DC border
   Dark mode: the TOC carries [data-ao-skip], so the theme
   switcher leaves it alone — its html.ao-dark rules live here.
   ============================================================ */

/* ── Desktop: left sticky panel (fallback when not relocated) ── */
.ao-toc-panel {
    position: fixed;
    left: max(16px, calc((100vw - 1200px) / 2 - 256px));
    top: 140px;
    width: 224px;
    max-height: calc(100vh - 180px);
    display: flex;
    flex-direction: column;
    overflow: hidden;           /* the list scrolls, head + foot stay put */
    background: #fff4ec42;          /* translucent warm tint (desktop rail) */
    border: 1px solid #E2E2DC;
    border-radius: 8px;
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-8px);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.ao-toc-panel.ao-toc-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

/* ── Desktop: in-flow column inside Elementor .blog-layout ──
   JS relocates the panel into the template's blog-layout flex row, so it
   becomes a real LEFT column.
   • body.ao-toc-2col (default): 2 columns — TOC · article.
     The right-hand sidebar card column is hidden; the article gets the room.
   • Filter ao_toc_two_column → false: legacy 3 columns — TOC · article · sidebar.
   Mobile keeps the slide-up drawer (see @media ≤900px). */
@media (min-width: 901px) {
    .blog-layout {
        align-items: flex-start !important;  /* top-align the columns */
        gap: 48px !important;
        flex-wrap: nowrap !important;
    }

    /* 2-column mode: drop Elementor's default 10px container padding so the
       TOC lines up with "Back to blogs" and the article runs to the edge */
    .ao-toc-2col .blog-layout,
    .ao-toc-2col .blog-layout > .e-con:not(.blog-sticky-wrap) {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* TOC: fixed-width sticky left rail */
    .blog-layout > .ao-toc-panel {
        position: sticky;
        top: 120px;            /* clears the sticky site nav */
        left: auto;
        transform: none;
        opacity: 1;
        pointer-events: auto;
        flex: 0 0 260px;       /* TOC column width */
        width: 260px;
        align-self: flex-start; /* required for position:sticky to engage */
        max-height: calc(100vh - 150px);
        margin: 0;
        z-index: 1;
    }

    /* 2-column mode: article fills the rest of the row (no dead gutter on the right) */
    .ao-toc-2col .blog-layout > .e-con:not(.blog-sticky-wrap) {
        flex: 1 1 0 !important;
        width: auto !important;
        --width: auto !important;
        max-width: none !important;
        min-width: 0 !important;
    }

    /* Post body / title / meta span the full article column */
    .ao-toc-2col .blog-layout .elementor-widget-theme-post-content,
    .ao-toc-2col .blog-layout .elementor-widget-theme-post-title,
    .ao-toc-2col .blog-layout .elementor-widget-post-info {
        width: 100% !important;
        max-width: 100% !important;
        --container-widget-width: 100% !important;
    }

    /* 3-column legacy mode: content + sidebar split the leftover width */
    body:not(.ao-toc-2col) .blog-layout > .e-con:not(.blog-sticky-wrap),
    body:not(.ao-toc-2col) .blog-layout > .blog-sticky-wrap {
        flex: 1 1 0 !important;
        width: auto !important;
        --width: auto !important;
        min-width: 0 !important;
    }
    body:not(.ao-toc-2col) .blog-layout { gap: 40px !important; }
    body:not(.ao-toc-2col) .blog-layout > .ao-toc-panel { flex-basis: 240px; width: 240px; }

    /* H3s only show under the H2 you're reading */
    .ao-toc-h3            { display: none; }
    .ao-toc-h3.ao-toc-open { display: block; }
}

/* Two-line H2s inside the post body were set at line-height 1 and touched */
.ao-toc-2col .elementor-widget-theme-post-content h2 {
    line-height: 1.2;
}

/* ── Recent Blog Posts (Loop Grid) → real cards ─────────── */
.ao-toc-2col [data-elementor-type="single-post"] .e-loop-item > .e-con {
    height: 100%;
    padding: 12px 12px 20px !important;
    background: #ffffff;
    border: 1px solid #ECE7E1;
    border-radius: 12px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.ao-toc-2col [data-elementor-type="single-post"] .e-loop-item > .e-con:hover {
    transform: translateY(-3px);
    border-color: #FFD2B3;
    box-shadow: 0 16px 32px -18px rgba(37, 35, 46, 0.28);
}
.ao-toc-2col [data-elementor-type="single-post"] .e-loop-item > .e-con > .e-con-inner {
    padding: 0 !important;
    gap: 16px !important;
    --gap: 16px !important;
}
.ao-toc-2col [data-elementor-type="single-post"] .e-loop-item img {
    border-radius: 8px;
}
.ao-toc-2col [data-elementor-type="single-post"] .e-loop-item .elementor-widget-theme-post-title {
    padding: 0 6px;
}
.ao-toc-2col [data-elementor-type="single-post"] .e-loop-item .elementor-heading-title a {
    transition: color 0.15s ease;
}
.ao-toc-2col [data-elementor-type="single-post"] .e-loop-item > .e-con:hover .elementor-heading-title,
.ao-toc-2col [data-elementor-type="single-post"] .e-loop-item > .e-con:hover .elementor-heading-title a {
    color: #ff791f;
}
html.ao-dark .ao-toc-2col [data-elementor-type="single-post"] .e-loop-item > .e-con {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.10);
}
@media (prefers-reduced-motion: reduce) {
    .ao-toc-2col [data-elementor-type="single-post"] .e-loop-item > .e-con { transition: none; }
    .ao-toc-2col [data-elementor-type="single-post"] .e-loop-item > .e-con:hover { transform: none; }
}

/* 2-column mode: hide the right-hand sidebar card column (all breakpoints) */
.ao-toc-2col .blog-layout > .blog-sticky-wrap {
    display: none !important;
}

/* ── Head: title + reading progress ──────────────────────── */
.ao-toc-head {
    flex: 0 0 auto;
    padding: 16px 16px 10px;
}

.ao-toc-title {
    font-family: Inter, sans-serif;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #6B6B6B;
    margin: 0 0 10px;
}

.ao-toc-progress {
    height: 3px;
    background: #EFEAE4;
    border-radius: 3px;
    overflow: hidden;
}

.ao-toc-progress-bar {
    display: block;
    height: 100%;
    background: #ff791f;
    border-radius: 3px;
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 0.12s linear;
}

/* ── List ──────────────────────────────────────────────────
   Still scrolls when the list is taller than the panel (the active item is
   auto-scrolled into view by JS, and wheel/touch work) — the bar is hidden. */
.ao-toc-inner {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 10px 10px;
    scrollbar-width: none;          /* Firefox */
    -ms-overflow-style: none;       /* old Edge */
    overscroll-behavior: contain;   /* wheel at the end doesn't scroll the page */
}

.ao-toc-inner::-webkit-scrollbar { display: none; width: 0; height: 0; }

/* Mobile-only header — hidden on desktop */
.ao-toc-mobile-header {
    display: none;
}

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

.ao-toc-item {
    margin: 0;
}

/* ── Links ────────────────────────────────────────────────── */
.ao-toc-link {
    display: block;
    font-family: Inter, sans-serif;
    font-size: 12.5px;
    line-height: 1.45;
    color: #25232e;
    text-decoration: none;
    padding: 6px 8px 6px 10px;
    border-left: 2px solid transparent;
    border-radius: 0 4px 4px 0;
    transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

/* H2 */
.ao-toc-h2 .ao-toc-link {
    font-weight: 500;
    color: #25232e;
    font-size: 12.5px;
}

/* H2 that owns the section you're in (while one of its H3s is active) */
.ao-toc-h2.ao-toc-current .ao-toc-link {
    font-weight: 600;
    color: #25232e;
}

/* H3 sub-item */
.ao-toc-h3 .ao-toc-link {
    font-weight: 400;
    font-size: 11.5px;
    color: #6B6B6B;
    padding-left: 22px;
}

/* Hover */
.ao-toc-link:hover {
    color: #ff791f;
    border-left-color: #E2E2DC;
    background: rgba(255, 121, 31, 0.04);
    text-decoration: none;
}

/* Active */
.ao-toc-link.ao-toc-active {
    color: #ff791f !important;
    border-left-color: #ff791f;
    background: rgba(255, 121, 31, 0.08);
}

.ao-toc-h2 .ao-toc-link.ao-toc-active {
    font-weight: 600;
}

.ao-toc-h3 .ao-toc-link.ao-toc-active {
    font-weight: 600;
}

/* ── Foot: share + demo ───────────────────────────────────── */
.ao-toc-foot {
    flex: 0 0 auto;
    padding: 12px 16px 16px;
    border-top: 1px dashed #E2E2DC;
}

.ao-toc-share {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}

.ao-toc-share-label {
    font-family: Inter, sans-serif;
    font-size: 11px;
    font-weight: 600;
    color: #6B6B6B;
    margin-right: auto;
}

.ao-toc-panel .ao-toc-share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid #E2E2DC;
    border-radius: 50%;
    background: #ffffff;
    color: #25232e;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.ao-toc-panel .ao-toc-share-btn:hover,
.ao-toc-panel .ao-toc-share-btn:focus-visible {
    color: #ff791f;
    border-color: #ff791f;
    background: #ffffff;
}

.ao-toc-panel .ao-toc-share-btn:focus { background: #ffffff; color: #25232e; outline: none; }
.ao-toc-panel .ao-toc-share-btn:focus-visible { outline: 2px solid rgba(255, 121, 31, 0.45); outline-offset: 2px; }

.ao-toc-panel .ao-toc-copy.ao-toc-copy-done {
    color: #ffffff;
    border-color: #1E9E61;
    background: #1E9E61;
}

.ao-toc-copied {
    position: absolute;
    right: 0;
    top: -22px;
    font-family: Inter, sans-serif;
    font-size: 11px;
    font-weight: 600;
    color: #1E9E61;
    pointer-events: none;
}

.ao-toc-panel .ao-toc-demo {
    display: block;
    text-align: center;
    font-family: Inter, sans-serif;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    padding: 11px 12px;
    border-radius: 4px;
    background: #ff791f;
    color: #ffffff;
    text-decoration: none;
    transition: background 0.15s ease;
}

.ao-toc-panel .ao-toc-demo:hover,
.ao-toc-panel .ao-toc-demo:focus {
    background: #E9680F;
    color: #ffffff;
    text-decoration: none;
}

/* "· 9 min read" appended to the post date */
.ao-toc-readtime {
    white-space: nowrap;
}

/* ── Mobile toggle button ─────────────────────────────────── */
.ao-toc-mobile-btn {
    display: none; /* shown only in mobile breakpoint */
    position: fixed;
    bottom: 24px;
    left: 20px;
    z-index: 1001;
    align-items: center;
    gap: 7px;
    padding: 10px 16px 10px 13px;
    background: #25232e;
    color: #ffffff;
    border: none;
    border-radius: 24px;
    font-family: Inter, sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
    transition: background 0.15s ease, transform 0.12s ease;
}

/* The Elementor kit's button rule outranks the class (4px radius, 14px text) */
#ao-toc-mobile-btn {
    border: none;
    border-radius: 24px;
    font-size: 13px;
    line-height: 1;
}

.ao-toc-mobile-btn:hover,
#ao-toc-mobile-btn:hover,
#ao-toc-mobile-btn:focus {
    background: #ff791f;
    color: #ffffff;
}

.ao-toc-mobile-btn:active {
    transform: scale(0.96);
}

.ao-toc-btn-label {
    line-height: 1;
}

/* Hidden while the drawer is open (it would sit on top of the drawer footer) */
.ao-toc-mobile-btn.ao-toc-btn-tucked {
    opacity: 0;
    pointer-events: none;
}

/* ── Backdrop (mobile only) ───────────────────────────────── */
.ao-toc-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(37, 35, 46, 0.45);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.22s ease;
}

.ao-toc-backdrop.ao-toc-backdrop-visible {
    opacity: 1;
}

/* ── Close button inside drawer (mobile) ─────────────────── */
.ao-toc-close {
    display: none;
}

/* ── Mobile breakpoint (≤ 900px) ─────────────────────────── */
@media (max-width: 900px) {

    /* Show the floating toggle button */
    .ao-toc-mobile-btn {
        display: flex;
    }

    /* Show backdrop */
    .ao-toc-backdrop {
        display: block;
    }

    /* Reset desktop positioning → slide-up drawer */
    .ao-toc-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        max-height: 70vh;
        border-radius: 16px 16px 0 0;
        border: none;
        border-top: 1px solid #E2E2DC;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.14);
        background: #FFFBF8;  /* opaque — the drawer overlays article text */
        z-index: 1000;

        /* Slide-up animation */
        transform: translateY(100%);
        opacity: 1;           /* override desktop opacity-0 */
        pointer-events: none;
        transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    }

    /* Drag handle pill */
    .ao-toc-panel::before {
        content: '';
        display: block;
        flex: 0 0 auto;
        width: 36px;
        height: 4px;
        background: #E2E2DC;
        border-radius: 2px;
        margin: 10px auto 0;
    }

    /* Open state on mobile */
    .ao-toc-panel.ao-toc-mobile-open {
        transform: translateY(0);
        pointer-events: auto;
    }

    /* Mobile drawer header */
    .ao-toc-mobile-header {
        display: flex;
        flex: 0 0 auto;
        align-items: center;
        justify-content: space-between;
        padding: 8px 16px 0;
    }

    .ao-toc-mobile-title {
        font-family: Inter, sans-serif;
        font-size: 14px;
        font-weight: 700;
        color: #25232e;
    }

    /* Close button — doubled selector outranks the Elementor kit's
       button rule (dark fill + 8px 16px padding that hid the ✕) */
    .ao-toc-panel .ao-toc-close {
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 32px;
        width: 32px;
        height: 32px;
        padding: 0;
        background: #f4f4f0;
        border: none;
        border-radius: 50%;
        color: #25232e;
        cursor: pointer;
        transition: background 0.14s;
    }

    .ao-toc-panel .ao-toc-close:hover,
    .ao-toc-panel .ao-toc-close:focus {
        background: #E2E2DC;
        color: #25232e;
    }

    /* Title is in the header row on mobile; keep the progress bar */
    .ao-toc-title {
        display: none;
    }

    .ao-toc-head {
        padding: 10px 16px 6px;
    }

    /* Larger tap targets on mobile */
    .ao-toc-link {
        font-size: 14px;
        padding: 8px 16px 8px 14px;
    }

    .ao-toc-h3 .ao-toc-link {
        font-size: 13px;
        padding-left: 30px;
    }

    .ao-toc-foot {
        padding-bottom: 20px;
    }
}

/* ── Hide desktop panel on mobile ────────────────────────── */
@media (max-width: 900px) {
    /* Desktop .ao-toc-visible class has no effect on mobile –
       open/close is controlled by ao-toc-mobile-open instead */
    .ao-toc-panel.ao-toc-visible {
        opacity: 1;
        transform: translateY(100%); /* still hidden until opened */
    }

    .ao-toc-panel.ao-toc-visible.ao-toc-mobile-open {
        transform: translateY(0);
    }
}

/* ── Dark mode (html.ao-dark) — TOC ──────────────────────── */
html.ao-dark .ao-toc-panel {
    background: #2E2C36;
    border-color: rgba(255, 255, 255, 0.10);
}
html.ao-dark .ao-toc-title,
html.ao-dark .ao-toc-share-label { color: #A8A6B2; }
html.ao-dark .ao-toc-progress { background: rgba(255, 255, 255, 0.12); }
html.ao-dark .ao-toc-h2 .ao-toc-link,
html.ao-dark .ao-toc-h2.ao-toc-current .ao-toc-link { color: #EDEDF2; }
html.ao-dark .ao-toc-h3 .ao-toc-link { color: #A8A6B2; }
html.ao-dark .ao-toc-link:hover {
    color: #ff791f;
    border-left-color: rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
}
html.ao-dark .ao-toc-link.ao-toc-active { background: rgba(255, 121, 31, 0.14); }
html.ao-dark .ao-toc-foot { border-top-color: rgba(255, 255, 255, 0.14); }
html.ao-dark .ao-toc-panel .ao-toc-share-btn,
html.ao-dark .ao-toc-panel .ao-toc-share-btn:focus {
    background: transparent;
    color: #EDEDF2;
    border-color: rgba(255, 255, 255, 0.18);
}
html.ao-dark .ao-toc-panel .ao-toc-share-btn:hover,
html.ao-dark .ao-toc-panel .ao-toc-share-btn:focus-visible {
    color: #ff791f;
    border-color: #ff791f;
    background: transparent;
}
html.ao-dark .ao-toc-panel .ao-toc-copy.ao-toc-copy-done { color: #fff; background: #1E9E61; border-color: #1E9E61; }
html.ao-dark .ao-toc-mobile-title { color: #EDEDF2; }
html.ao-dark .ao-toc-panel .ao-toc-close { background: rgba(255, 255, 255, 0.08); color: #EDEDF2; }
html.ao-dark .ao-toc-panel .ao-toc-close:hover,
html.ao-dark .ao-toc-panel .ao-toc-close:focus { background: rgba(255, 255, 255, 0.14); color: #EDEDF2; }
@media (max-width: 900px) {
    html.ao-dark .ao-toc-panel { background: #25232E; border-top-color: rgba(255, 255, 255, 0.10); }
    html.ao-dark .ao-toc-panel::before { background: rgba(255, 255, 255, 0.18); }
}

/* ── Reduce motion ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .ao-toc-panel,
    .ao-toc-backdrop,
    .ao-toc-mobile-btn,
    .ao-toc-progress-bar {
        transition: none;
    }
}
