/* Aureole TOC — Newstarsec build (floating in-page index, universal FAB + panel) */

:root {
    --aureole-toc-primary: #333333;        /* Newstarsec deep gray — headings / text */
    --aureole-toc-accent: #E48216;         /* Newstarsec orange — FAB + active accent */
    --aureole-toc-accent-dark: #C46E0E;    /* darker orange for hover */
    --aureole-toc-accent-light: #F5A648;   /* lighter orange */
    --aureole-toc-text: #1F2937;
    --aureole-toc-text-muted: #4B5563;
    --aureole-toc-text-meta: #6B7280;
    --aureole-toc-bg: #FFFFFF;
    --aureole-toc-bg-hover: rgba(228, 130, 22, 0.07);
    --aureole-toc-bg-active: rgba(228, 130, 22, 0.12);
    --aureole-toc-border: #E5E7EB;
    --aureole-toc-shadow: 0 8px 24px rgba(51, 51, 51, 0.14);
    --aureole-toc-scrim: rgba(31, 41, 55, 0.55);
}

/* Shared list ----------------------------------------------------------- */
.aureole-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
}
.aureole-toc-item { margin: 0; padding: 0; }
.aureole-toc-item > a {
    display: block;
    padding: 10px 14px;
    color: var(--aureole-toc-text-muted);
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s, background-color 0.15s;
    word-break: break-word;
    line-height: 1.45;
}
.aureole-toc-item > a:hover,
.aureole-toc-item > a:focus-visible {
    color: var(--aureole-toc-primary);
    background-color: var(--aureole-toc-bg-hover);
    outline: none;
}
.aureole-toc-item > a.is-active {
    color: var(--aureole-toc-accent);
    border-left-color: var(--aureole-toc-accent);
    font-weight: 600;
    background-color: var(--aureole-toc-bg-active);
}
.aureole-toc-h3 > a {
    padding-left: 30px;
    font-size: 13px;
    color: var(--aureole-toc-text-meta);
}

/* FAB ------------------------------------------------------------------- */
/* Mobile default: bottom-right, clearing the Newstarsec lang switcher */
.aureole-toc-fab {
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    right: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--aureole-toc-accent);
    color: #FFFFFF;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(228, 130, 22, 0.42);
    z-index: 99997;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.96;
    transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
.aureole-toc-fab:hover,
.aureole-toc-fab:focus-visible {
    opacity: 1;
    background: var(--aureole-toc-accent-dark);
    box-shadow: 0 8px 22px rgba(228, 130, 22, 0.55);
    transform: scale(1.05);
    outline: none;
}
.aureole-toc-fab.is-near-top,
.aureole-toc-fab.is-hidden-by-form {
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
}

/* Scrim ------------------------------------------------------------------ */
.aureole-toc-scrim {
    position: fixed;
    inset: 0;
    background: var(--aureole-toc-scrim);
    z-index: 99998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.aureole-toc-scrim.is-visible {
    opacity: 1;
    pointer-events: auto;
}

/* Sheet/panel — mobile: full-width bottom sheet; desktop: side-docked panel ---- */
.aureole-toc-sheet {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translate(-50%, 100%);
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    background: var(--aureole-toc-bg);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.18);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    outline: none;
}
.aureole-toc-sheet.is-visible { transform: translate(-50%, 0); }

@media (min-width: 1024px) {
    /* Desktop: FAB at mid-LEFT */
    .aureole-toc-fab {
        top: 50%;
        bottom: auto;
        left: 24px;
        right: auto;
        transform: translateY(-50%);
    }
    .aureole-toc-fab:hover,
    .aureole-toc-fab:focus-visible {
        transform: translateY(-50%) scale(1.05);
    }
    .aureole-toc-fab.is-hidden-by-form {
        transform: translateY(calc(-50% + 8px));
    }

    /* Desktop panel: docked to the RIGHT of the FAB, vertically centered */
    .aureole-toc-sheet {
        right: auto;
        left: 92px; /* 24 (FAB left) + 52 (FAB w) + 16 (gap) */
        top: 50%;
        bottom: auto;
        width: 360px;
        max-width: 360px;
        max-height: min(70vh, 640px);
        transform: translate(-20px, -50%) scale(0.96);
        opacity: 0;
        border-radius: 12px;
        transition: opacity 0.18s ease, transform 0.18s ease;
        box-shadow: 0 16px 40px rgba(51, 51, 51, 0.22);
    }
    .aureole-toc-sheet.is-visible {
        transform: translate(0, -50%) scale(1);
        opacity: 1;
    }
    /* Lighter scrim on desktop — the panel is small */
    .aureole-toc-scrim {
        background: rgba(31, 41, 55, 0.18);
    }
    /* Don't lock body scroll on desktop — user can keep reading */
    body.aureole-toc-open { overflow: visible; }
}

.aureole-toc-sheet__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 12px;
    border-bottom: 1px solid var(--aureole-toc-border);
    flex-shrink: 0;
    position: relative;
}
/* Subtle Newstarsec orange accent rule under the title bar */
.aureole-toc-sheet__head::after {
    content: "";
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: -1px;
    height: 2px;
    background: linear-gradient(90deg, var(--aureole-toc-accent) 0%, var(--aureole-toc-accent-light) 60%, transparent 100%);
    border-radius: 2px;
    opacity: 0.85;
}
.aureole-toc-sheet__title {
    font-weight: 700;
    color: var(--aureole-toc-primary);
    font-size: 15px;
    letter-spacing: 0.02em;
}
.aureole-toc-sheet__close {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--aureole-toc-text-meta);
    padding: 6px;
    line-height: 0;
    border-radius: 6px;
    transition: background-color 0.15s, color 0.15s;
}
.aureole-toc-sheet__close:hover,
.aureole-toc-sheet__close:focus-visible {
    background: #F3F4F6;
    color: var(--aureole-toc-accent);
    outline: none;
}
.aureole-toc-sheet__body {
    overflow-y: auto;
    padding: 8px 6px 16px;
    flex: 1;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
.aureole-toc-sheet__body::-webkit-scrollbar { width: 6px; }
.aureole-toc-sheet__body::-webkit-scrollbar-thumb { background: var(--aureole-toc-border); border-radius: 3px; }

.aureole-toc-sheet .aureole-toc-list { font-size: 14px; }
.aureole-toc-sheet .aureole-toc-item > a {
    padding: 11px 16px;
    border-left-width: 3px;
}
.aureole-toc-sheet .aureole-toc-h3 > a {
    padding-left: 34px;
    font-size: 13px;
}

body.aureole-toc-open { overflow: hidden; }

/* CN typography tweak ---------------------------------------------------- */
:root[lang^="zh"] .aureole-toc-list,
.aureole-toc-list:lang(zh) { letter-spacing: 0.01em; }

/* Reduced motion --------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .aureole-toc-scrim,
    .aureole-toc-sheet,
    .aureole-toc-fab,
    .aureole-toc-item > a { transition: none; }
}
