/* ==========================================================================
   Moon Custom TOC – Stylesheet
   Matches the reference image design: grey card, bold header, >> chevrons
   ========================================================================== */

/* TOC Container */
.moon-toc {
    background-color: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    overflow: hidden;
    font-family: inherit;
    width: 100%;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* TOC Header Row — Fixed / pinned at top of the card */
.moon-toc__header {
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 5;
    background-color: #e7e7e7;
    color: #000;
    border-radius: 12px 12px 0 0;
    font-weight: 600 !important;
    font-size: 19px;
    border-bottom: 1px solid #e0e0e0;
    letter-spacing: 0.01em;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    transition: border-radius 0.2s ease;
}

.moon-toc__title {
    font-weight: 600 !important;
    font-size: 18px;
    color: #1e293b;
    line-height: 1.2;
}

/* Toggle Button (matches easy-table-of-contents reference) */
.moon-toc__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border: 1px solid #c9d2de;
    border-radius: 6px;
    padding: 3px 6px;
    cursor: pointer;
    color: #333333;
    line-height: 1;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.moon-toc__toggle:hover {
    background-color: #f2f5f9;
    border-color: #9cb0c8;
}

.moon-toc__toggle-icon {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.moon-toc-icon-list {
    color: #222222;
}

.moon-toc-icon-arrows {
    color: #222222;
}

/* Collapsed state */
.moon-toc.moon-toc--collapsed .moon-toc__list {
    display: none !important;
}

.moon-toc.moon-toc--collapsed .moon-toc__header {
    border-bottom: none;
    border-radius: 12px;
}

.moon-toc.moon-toc--collapsed {
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

/* TOC List — only the list scrolls, header stays fixed */
.moon-toc__list {
    list-style: none !important;
    margin: 0 !important;
    padding: 8px 18px 12px !important;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    scroll-behavior: smooth;
}

/* Clean scrollbar for TOC list */
.moon-toc__list::-webkit-scrollbar {
    width: 5px;
}
.moon-toc__list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}
.moon-toc__list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}
.moon-toc__list::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* TOC List Items
   — mirrors: div#ez-toc-container ul li
   — font-weight: 500, font-size: 95% */
.moon-toc__list li {
    display: flex !important;
    align-items: flex-start;
    gap: 6px;
    padding: 6px 0 !important;
    line-height: 1.45;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
}

/* Double-arrow SVG icon */
.moon-toc-arrow {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    margin-top: 4px;
    display: inline-block;
    opacity: 0.75;
}

/* TOC Links
   — mirrors: #ez-toc-container a
   — color: #444, no box-shadow, no text-decoration, no text-shadow
   — display: inline-flex, align-items: stretch, flex-wrap: nowrap */
.moon-toc__list li a {
    color: #444;
    box-shadow: none;
    text-decoration: none;
    text-shadow: none;
    display: inline-flex;
    align-items: stretch;
    flex-wrap: nowrap;
    font-weight: 500;
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
    transition: color 0.2s ease;
}

.moon-toc__list li a:hover {
    color: #222;
    text-decoration: underline;
}

/* Active TOC item — highlighted by scroll spy */
.moon-toc__list li.moon-toc-active {
    border-left: 3px solid #2d6a9f;
    padding-left: 8px !important;
    transition: all 0.2s ease;
}

.moon-toc__list li.moon-toc-active a {
    color: #2d6a9f;
    font-weight: 600 !important;
}

/* Sticky TOC wrapper — keeps TOC card visible while scrolling the page */
.moon-toc-sticky-wrap {
    position: -webkit-sticky;
    position: sticky;
    top: 130px;
    z-index: 10;
    margin-top: 25px;
}

/* Smooth scroll behaviour */
html {
    scroll-behavior: smooth;
}
