/* ==========================================================================
   Casino Starter — Sidebar Styles
   ========================================================================== */

.site-sidebar {
    position: sticky;
    top: calc(70px + var(--space-xl)); /* header height + gap */
    max-height: calc(100vh - 70px - var(--space-xl));
    overflow-y: auto;
}

/* --- Table of Contents --- */
.toc {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    margin-bottom: var(--space-lg);
}

.toc__header {
    background: var(--color-primary);
    color: var(--color-white);
    padding: var(--space-md) var(--space-lg);
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
}

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

.toc__item {
    border-bottom: 1px solid var(--color-border-light, #f0f0f5);
}

.toc__item:last-child {
    border-bottom: none;
}

/* --- H2-level links (simple & expandable) --- */
.toc__link {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 16px;
    color: var(--color-text);
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.45;
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.toc__link:hover {
    background: var(--color-light-bg, #f5f6fa);
    color: var(--color-primary);
}

.toc__link.is-active,
.toc__item.is-active > .toc__link {
    color: var(--color-primary);
    background: rgba(10, 36, 99, 0.04);
    border-left: 3px solid var(--color-primary);
}

.toc__link span:first-child {
    flex: 1;
    min-width: 0;
}

/* --- Expand icon (+/-) --- */
.toc__expand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 1px;
    transition: transform 0.25s ease, background 0.2s;
    line-height: 1;
}

.toc__item:hover .toc__expand-icon {
    background: var(--color-primary-dark, #071d52);
}

.toc__item.is-expanded .toc__expand-icon {
    transform: rotate(45deg);
    background: var(--color-primary);
}

/* --- Sub-items (H3/H4) --- */
.toc__sublist {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
    background: var(--color-light-bg, #f8f9fc);
    border-top: 1px solid var(--color-border-light, #eff0f5);
}

.toc__item.is-expanded .toc__sublist {
    max-height: 600px;
}

.toc__sublist li {
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.toc__sublist li:last-child {
    border-bottom: none;
}

.toc__sublink {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px 9px 24px;
    color: var(--color-text-secondary, #555);
    font-size: 12.5px;
    font-weight: 400;
    line-height: 1.45;
    text-decoration: none;
    transition: color 0.15s, background 0.15s, padding-left 0.15s;
    position: relative;
}

.toc__sublink::before {
    content: '';
    display: block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--color-border, #ccc);
    flex-shrink: 0;
    transition: background 0.15s;
}

.toc__sublink:hover {
    color: var(--color-primary);
    background: rgba(10, 36, 99, 0.03);
    padding-left: 28px;
}

.toc__sublink:hover::before {
    background: var(--color-primary);
}

/* --- Sidebar Widgets --- */
.sidebar-widget {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.sidebar-widget__title {
    font-family: var(--font-heading);
    font-size: var(--text-base);
    font-weight: var(--weight-bold);
    color: var(--color-text);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 2px solid var(--color-primary);
}

/* Admin bar fix for sticky sidebar */
.admin-bar .site-sidebar {
    top: calc(70px + 32px + var(--space-xl));
}

/* ==========================================================================
   Mobile Floating TOC (FAB + Drawer)
   Visible only on screens < 768px.
   ========================================================================== */

/* --- FAB Button --- */
.mobile-toc-fab {
    display: none; /* shown via media query */
    position: fixed;
    bottom: 7.5rem; /* above mobile bottom bar (56px) */
    right: 1.25rem;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    color: var(--color-white);
    border: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
}

.mobile-toc-fab svg {
    width: 24px;
    height: 24px;
}

.mobile-toc-fab:active {
    transform: scale(0.92);
}

.mobile-toc-fab.is-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

/* --- Drawer Container --- */
.mobile-toc-drawer {
    display: none; /* shown via media query */
    position: fixed;
    inset: 0;
    z-index: 10000;
    pointer-events: none;
}

.mobile-toc-drawer.is-open {
    pointer-events: auto;
}

/* --- Overlay --- */
.mobile-toc-drawer__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.mobile-toc-drawer.is-open .mobile-toc-drawer__overlay {
    opacity: 1;
}

/* --- Panel (slides up from bottom) --- */
.mobile-toc-drawer__panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 75vh;
    background: var(--color-white);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform var(--transition-slow);
}

.mobile-toc-drawer.is-open .mobile-toc-drawer__panel {
    transform: translateY(0);
}

/* --- Header --- */
.mobile-toc-drawer__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    background: var(--color-primary);
    color: var(--color-white);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    flex-shrink: 0;
}

.mobile-toc-drawer__title {
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
}

.mobile-toc-drawer__close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.15);
    color: var(--color-white);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.mobile-toc-drawer__close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.mobile-toc-drawer__close svg {
    width: 20px;
    height: 20px;
}

/* --- Body (scrollable list) --- */
.mobile-toc-drawer__body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
}

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

/* Reuse toc item styling */
.mobile-toc-drawer__list .toc__item {
    border-bottom: 1px solid var(--color-border-light, #f0f0f5);
}

.mobile-toc-drawer__list .toc__item:last-child {
    border-bottom: none;
}

.mobile-toc-drawer__list .toc__link {
    padding: 12px 16px;
    font-size: 14px;
}

.mobile-toc-drawer__list .toc__sublist {
    background: var(--color-light-bg, #f8f9fc);
}

.mobile-toc-drawer__list .toc__sublink {
    padding: 9px 16px 9px 24px;
    font-size: 13px;
}

/* --- Media Query: show on mobile only --- */
@media screen and (max-width: 768px) {
    .mobile-toc-fab {
        display: flex;
    }

    .mobile-toc-drawer {
        display: block;
    }
}

/* --- Author box responsive --- */
@media screen and (max-width: 480px) {
    .author-box__body {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .author-box__name-row {
        justify-content: center;
    }

    .author-box__meta {
        justify-content: center;
    }
}
