/**
 * Worgoo TOC — Frontend Styles
 *
 * All visual properties use CSS custom properties (--wtoc-*).
 * Override these variables from Elementor, theme, or admin panel.
 *
 * Themes: default, minimal, dark
 */

/* ──────────────────────────────────────
   Custom Properties (Root Defaults)
   Override these anywhere to restyle.
   ────────────────────────────────────── */

.worgoo-toc {
    /* Box */
    --wtoc-bg: #f8f9fa;
    --wtoc-border: #e2e4e7;
    --wtoc-radius: 8px;
    --wtoc-padding: 1.25rem;
    --wtoc-margin: 1.5rem 0;
    --wtoc-max-width: 100%;
    --wtoc-font-family: inherit;
    --wtoc-font-size: 0.9rem;
    --wtoc-line-height: 1.6;

    /* Title */
    --wtoc-title-font-size: 1.3rem;
    --wtoc-title-font-weight: 700;
    --wtoc-title-color: #1e1e1e;

    /* Toggle button */
    --wtoc-toggle-size: 32px;
    --wtoc-toggle-radius: 6px;
    --wtoc-toggle-bg: rgba(0, 0, 0, 0.04);
    --wtoc-toggle-bg-hover: rgba(0, 0, 0, 0.08);
    --wtoc-toggle-border: var(--wtoc-border);
    --wtoc-toggle-border-hover: rgba(0, 0, 0, 0.15);
    --wtoc-toggle-color: var(--wtoc-title-color);

    /* Links */
    --wtoc-link-color: #2271b1;
    --wtoc-link-hover: #135e96;
    --wtoc-link-active: #0a4b78;
    --wtoc-link-font-size: inherit;
    --wtoc-link-padding: 0.3rem 0.5rem;

    /* Active state (scroll spy) */
    --wtoc-active-bg: rgba(34, 113, 177, 0.08);
    --wtoc-active-border: #2271b1;

    /* Sticky */
    --wtoc-sticky-top: 100px;
}

/* ──────────────────────────────────────
   Base / Reset
   ────────────────────────────────────── */

.worgoo-toc {
    box-sizing: border-box;
    font-family: var(--wtoc-font-family);
    font-size: var(--wtoc-font-size);
    line-height: var(--wtoc-line-height);
    background: var(--wtoc-bg);
    border: 1px solid var(--wtoc-border);
    border-radius: var(--wtoc-radius);
    padding: var(--wtoc-padding);
    margin: var(--wtoc-margin);
    max-width: var(--wtoc-max-width);
}

.worgoo-toc *,
.worgoo-toc *::before,
.worgoo-toc *::after {
    box-sizing: border-box;
}

/* ──────────────────────────────────────
   Header (Title + Toggle)
   ────────────────────────────────────── */

.worgoo-toc__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-direction: row;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--wtoc-border);
}

.worgoo-toc__title {
    font-weight: var(--wtoc-title-font-weight);
    font-size: var(--wtoc-title-font-size);
    font-family: var(--wtoc-font-family);
    color: var(--wtoc-title-color);
    margin: 0;
    padding: 0;
    line-height: 1.3;
    flex: 1;
    border: none;
    background: none;
    text-transform: none;
    letter-spacing: normal;
    order: 0;
}

.worgoo-toc__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--wtoc-toggle-bg);
    border: 1px solid var(--wtoc-toggle-border);
    cursor: pointer;
    width: var(--wtoc-toggle-size);
    height: var(--wtoc-toggle-size);
    min-width: var(--wtoc-toggle-size);
    min-height: var(--wtoc-toggle-size);
    max-width: var(--wtoc-toggle-size);
    max-height: var(--wtoc-toggle-size);
    padding: 0;
    margin: 0;
    border-radius: var(--wtoc-toggle-radius);
    color: var(--wtoc-toggle-color);
    transition: background-color 0.15s ease, border-color 0.15s ease;
    box-shadow: none;
    text-decoration: none;
    text-transform: none;
    letter-spacing: normal;
    line-height: 1;
    position: relative;
    opacity: 1;
    visibility: visible;
    overflow: visible;
    font-size: 0;
    order: 1;
}

.worgoo-toc__toggle:hover {
    background: var(--wtoc-toggle-bg-hover);
    border-color: var(--wtoc-toggle-border-hover);
}

.worgoo-toc__toggle:focus,
.worgoo-toc__toggle:focus-visible {
    outline: 2px solid var(--wtoc-link-color);
    outline-offset: 2px;
}

.worgoo-toc__toggle[aria-expanded="false"] .worgoo-toc__icon {
    transform: rotate(-90deg);
}

.worgoo-toc__icon {
    transition: transform 0.25s ease;
    display: block;
    width: 16px;
    height: 16px;
}

/* ──────────────────────────────────────
   List
   ────────────────────────────────────── */

.worgoo-toc__list {
    margin: 0;
    padding: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, opacity 0.25s ease;
}

ul.worgoo-toc__list {
    list-style: none;
}

.worgoo-toc__list[aria-hidden="true"] {
    max-height: 0 !important;
    opacity: 0;
    pointer-events: none;
}

.worgoo-toc__sublist {
    margin: 0;
    padding: 0 0 0 1rem;
}

ul.worgoo-toc__sublist {
    list-style: none;
}

ol.worgoo-toc__list {
    list-style: decimal;
    padding-left: 1.25rem;
}

ol.worgoo-toc__sublist {
    list-style: decimal;
    padding-left: 1.25rem;
}

/* ──────────────────────────────────────
   Items & Links
   ────────────────────────────────────── */

.worgoo-toc__item {
    margin: 0;
    padding: 0;
}

.worgoo-toc__link {
    display: block;
    padding: var(--wtoc-link-padding);
    color: var(--wtoc-link-color);
    text-decoration: none;
    border-left: 3px solid transparent;
    border-radius: 2px;
    font-size: var(--wtoc-link-font-size);
    line-height: var(--wtoc-line-height);
    background: none;
    transition: color 0.15s ease,
                background-color 0.15s ease,
                border-color 0.15s ease;
}

.worgoo-toc__link:hover {
    color: var(--wtoc-link-hover);
    background-color: rgba(0, 0, 0, 0.03);
}

.worgoo-toc__link:focus-visible {
    outline: 2px solid var(--wtoc-link-color);
    outline-offset: 1px;
}

.worgoo-toc__link--active {
    color: var(--wtoc-link-active);
    background-color: var(--wtoc-active-bg);
    border-left-color: var(--wtoc-active-border);
    font-weight: 600;
}

.worgoo-toc__item--level-3 > .worgoo-toc__link { font-size: 0.875em; }
.worgoo-toc__item--level-4 > .worgoo-toc__link { font-size: 0.825em; }
.worgoo-toc__item--level-5 > .worgoo-toc__link,
.worgoo-toc__item--level-6 > .worgoo-toc__link { font-size: 0.8em; opacity: 0.85; }

/* ──────────────────────────────────────
   Sticky Mode
   ────────────────────────────────────── */

.worgoo-toc--sticky {
    position: sticky;
    top: var(--wtoc-sticky-top);
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}

.worgoo-toc--sticky::-webkit-scrollbar { width: 4px; }
.worgoo-toc--sticky::-webkit-scrollbar-thumb {
    background: var(--wtoc-border);
    border-radius: 4px;
}

/* ──────────────────────────────────────
   Theme: Minimal
   ────────────────────────────────────── */

.worgoo-toc--theme-minimal {
    --wtoc-bg: transparent;
    --wtoc-border: transparent;
    --wtoc-radius: 0;
    --wtoc-padding: 0;
    border: none;
}

.worgoo-toc--theme-minimal .worgoo-toc__header {
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e2e4e7;
    margin-bottom: 0.5rem;
}

/* ──────────────────────────────────────
   Theme: Dark
   ────────────────────────────────────── */

.worgoo-toc--theme-dark {
    --wtoc-bg: #1e1e2e;
    --wtoc-border: #313244;
    --wtoc-title-color: #cdd6f4;
    --wtoc-link-color: #89b4fa;
    --wtoc-link-hover: #b4d0fb;
    --wtoc-link-active: #74c7ec;
    --wtoc-active-bg: rgba(137, 180, 250, 0.1);
    --wtoc-active-border: #89b4fa;
    --wtoc-toggle-bg: rgba(255, 255, 255, 0.06);
    --wtoc-toggle-bg-hover: rgba(255, 255, 255, 0.1);
    --wtoc-toggle-border: rgba(255, 255, 255, 0.12);
    --wtoc-toggle-border-hover: rgba(255, 255, 255, 0.2);
    --wtoc-toggle-color: #cdd6f4;
}

/* ──────────────────────────────────────
   Responsive / Mobile Collapse
   ────────────────────────────────────── */

@media (max-width: 768px) {
    .worgoo-toc {
        --wtoc-font-size: 0.85rem;
        --wtoc-padding: 1rem;
    }

    .worgoo-toc--sticky {
        position: relative;
        top: auto;
        max-height: none;
    }
}

/* ──────────────────────────────────────
   Print
   ────────────────────────────────────── */

@media print {
    .worgoo-toc {
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }

    .worgoo-toc__toggle { display: none; }

    .worgoo-toc__list[aria-hidden="true"] {
        max-height: none !important;
        opacity: 1;
        pointer-events: auto;
    }
}
