/* Sahaha Table of Contents Stylesheet */

.sahaha-toc-container {
    display: inline-block;
    min-width: 280px;
    max-width: 100%;
    box-sizing: border-box;
    background-color: #fffaf5;
    border: 1px solid #ffd8b5;
    border-radius: 8px;
    padding: 16px 20px;
    margin: 20px 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.03), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    transition: all 0.3s ease;
}

.sahaha-toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    padding-bottom: 8px;
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s ease;
}

.sahaha-toc-container.active .sahaha-toc-header {
    border-bottom-color: #ffe4e6;
}

.sahaha-toc-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sahaha-toc-icon {
    display: flex;
    align-items: center;
    color: #fe7801; /* Teal color */
}

.sahaha-toc-title {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
}

.sahaha-toc-toggle {
    display: flex;
    align-items: center;
    color: #4b5563;
    transition: transform 0.3s ease;
}

.sahaha-toc-container.active .sahaha-toc-toggle {
    transform: rotate(180deg);
}

.sahaha-toc-list {
    margin: 0;
    padding: 0;
    list-style: none !important;
    list-style-type: none !important;
    max-height: 0;
    opacity: 0;
    overflow: hidden !important;
    position: relative;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, margin-top 0.3s ease;
}

.sahaha-toc-list li {
    list-style: none !important;
    list-style-type: none !important;
}

.sahaha-toc-list li::before {
    content: none !important;
}

.sahaha-toc-container.active .sahaha-toc-list {
    max-height: 2000px; /* High enough to contain large TOCs */
    opacity: 1;
    margin-top: 12px;
}

.sahaha-toc-container.active.sahaha-toc-limited .sahaha-toc-list {
    max-height: 400px !important;
    overflow: hidden !important;
}

.sahaha-toc-container.active.sahaha-toc-expanded .sahaha-toc-list {
    max-height: 2000px !important;
}

.sahaha-toc-list::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: linear-gradient(to bottom, rgba(255, 250, 245, 0), rgba(255, 250, 245, 1));
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sahaha-toc-container.active.sahaha-toc-limited .sahaha-toc-list::after {
    opacity: 1;
}

.sahaha-toc-container.active.sahaha-toc-expanded .sahaha-toc-list::after {
    opacity: 0 !important;
}

/* Read more button */
.sahaha-toc-readmore-wrap {
    display: none;
    justify-content: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed #ffd8b5;
}

.sahaha-toc-container.active.sahaha-toc-limited .sahaha-toc-readmore-wrap {
    display: flex;
}

.sahaha-toc-readmore-btn {
    background-color: #fe7801;
    color: #ffffff;
    border: none;
    border-radius: 20px;
    padding: 8px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(254, 120, 1, 0.15);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.2;
    outline: none;
}

.sahaha-toc-readmore-btn:hover {
    background-color: #e06a00;
    box-shadow: 0 6px 12px rgba(254, 120, 1, 0.25);
    transform: translateY(-1px);
}

.sahaha-toc-readmore-btn:active {
    transform: translateY(1px);
}

.sahaha-toc-readmore-btn svg {
    transition: transform 0.2s ease;
}

.sahaha-toc-item {
    padding: 6px 0;
    line-height: 1.5;
    font-size: 15px;
    transition: all 0.2s ease;
}

.sahaha-toc-link {
    color: #374151;
    text-decoration: none !important;
    display: inline-block;
    transition: color 0.2s ease, transform 0.2s ease;
}

.sahaha-toc-link:hover {
    color: #fe7801;
    transform: translateX(4px);
}

/* Indentation levels */
.sahaha-toc-level-2 {
    margin-left: 0;
    font-weight: 500;
}

.sahaha-toc-level-3 {
    margin-left: 20px;
    font-size: 14.5px;
}

.sahaha-toc-level-4 {
    margin-left: 40px;
    font-size: 14px;
}