/* ==========================================================================
   TOC FIXES - SWISS DESIGN SYSTEM (NO ROUNDNESS)
   COMPLETE REWRITE: Sticky sidebar, scrolling TOC, proper numbering
   ========================================================================== */

/* ==========================================================================
   PARENT GRID - MUST ALLOW STICKY
   ========================================================================== */

/* ==========================================================================
   DESKTOP TOC SIDEBAR - STICKY CONTAINER
   ========================================================================== */

.swiss-toc-sidebar {
    display: none;
}

@media (min-width: 1024px) {
    .swiss-toc-sidebar {
        display: block;
        width: 280px;
        min-width: 280px;
        max-width: 280px;
        flex-shrink: 0;
        position: relative;
        height: auto !important;
    }
    
    /* The sticky wrapper - this is what stays fixed */
    .swiss-toc-sticky {
        position: -webkit-sticky;
        position: sticky;
        top: 90px;
        max-height: calc(100vh - 110px);
        overflow: visible;
    }
}

/* ==========================================================================
   TOC BOX - SWISS DESIGN
   ========================================================================== */

.swiss-toc {
    background: #ffffff;
    border: 2px solid var(--swiss-black, #111111);
    border-radius: 0 !important;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 280px);
    overflow: hidden;
}

/* Header */
.swiss-toc__header {
    padding: 0.875rem 1rem;
    border-bottom: 2px solid var(--swiss-black, #111111);
    background: var(--swiss-off-white, #F5F5F0);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.swiss-toc__label {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--swiss-red, #FF3B30);
}

.swiss-toc__progress-text {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--swiss-black, #111111);
    opacity: 0.5;
}

/* Progress Bar */
.swiss-toc__progress {
    height: 3px;
    background: var(--swiss-off-white, #F5F5F0);
    flex-shrink: 0;
}

.swiss-toc__progress-bar {
    height: 100%;
    width: 0;
    background: var(--swiss-red, #FF3B30);
    transition: width 0.1s linear;
}

/* ==========================================================================
   SCROLLABLE TOC CONTENT - KEY FIX
   ========================================================================== */

.swiss-toc__content {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0;
    min-height: 100px;
    max-height: 100%;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
    scroll-behavior: smooth;
}

.swiss-toc__content::-webkit-scrollbar {
    width: 4px;
}

.swiss-toc__content::-webkit-scrollbar-track {
    background: transparent;
}

.swiss-toc__content::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 0;
}

.swiss-toc__content::-webkit-scrollbar-thumb:hover {
    background: var(--swiss-red, #FF3B30);
}

/* ==========================================================================
   TOC LINKS - PROPER NUMBER SPACING
   ========================================================================== */

.swiss-toc__content nav,
.swiss-toc__content #TableOfContents {
    margin: 0;
    padding: 0;
}

.swiss-toc__content nav > ul,
.swiss-toc__content #TableOfContents > ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.swiss-toc__content nav ul,
.swiss-toc__content #TableOfContents ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.swiss-toc__content nav li,
.swiss-toc__content #TableOfContents li {
    margin: 0;
    padding: 0;
}

/* Main Link Styling */
.swiss-toc__content nav a,
.swiss-toc__content #TableOfContents a {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.35;
    color: #555;
    text-decoration: none;
    transition: all 0.12s ease;
    border-left: 2px solid transparent;
    background: transparent;
}

.swiss-toc__content nav a:hover,
.swiss-toc__content #TableOfContents a:hover {
    color: var(--swiss-black, #111111);
    background: rgba(0, 0, 0, 0.02);
    border-left-color: #ccc;
}

/* Active State - Highlighted */
.swiss-toc__content nav a.active,
.swiss-toc__content nav a.swiss-toc__link--active,
.swiss-toc__content #TableOfContents a.active,
.swiss-toc__content #TableOfContents a.swiss-toc__link--active {
    color: var(--swiss-red, #FF3B30);
    font-weight: 600;
    background: rgba(255, 59, 48, 0.06);
    border-left-color: var(--swiss-red, #FF3B30);
}

/* Number Badge - FIXED */
.swiss-toc__link-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    width: 18px;
    height: 18px;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.5625rem;
    font-weight: 700;
    color: #888;
    background: #f0f0f0;
    border: 1px solid #ddd;
    flex-shrink: 0;
    line-height: 1;
}

.swiss-toc__content nav a:hover .swiss-toc__link-number,
.swiss-toc__content #TableOfContents a:hover .swiss-toc__link-number {
    background: #e0e0e0;
    color: #555;
}

.swiss-toc__content nav a.active .swiss-toc__link-number,
.swiss-toc__content nav a.swiss-toc__link--active .swiss-toc__link-number,
.swiss-toc__content #TableOfContents a.active .swiss-toc__link-number,
.swiss-toc__content #TableOfContents a.swiss-toc__link--active .swiss-toc__link-number {
    background: var(--swiss-red, #FF3B30);
    color: white;
    border-color: var(--swiss-red, #FF3B30);
}

/* Nested Lists - Sub-items */
.swiss-toc__content nav ul ul,
.swiss-toc__content #TableOfContents ul ul {
    margin: 0;
    padding: 0;
}

.swiss-toc__content nav ul ul a,
.swiss-toc__content #TableOfContents ul ul a {
    padding-left: 2.25rem;
    font-size: 0.6875rem;
    color: #777;
}

.swiss-toc__content nav ul ul a::before,
.swiss-toc__content #TableOfContents ul ul a::before {
    content: '–';
    color: #bbb;
    margin-right: 0.375rem;
    flex-shrink: 0;
    font-size: 0.75rem;
}

/* ==========================================================================
   TOC ACTIONS - COMPACT
   ========================================================================== */

.swiss-toc-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.375rem;
    padding: 0.625rem 0.75rem;
    border-top: 2px solid var(--swiss-black, #111111);
    background: var(--swiss-off-white, #F5F5F0);
    flex-shrink: 0;
}

.swiss-toc-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.375rem 0.5rem;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.5rem;
    font-weight: 700;
    color: var(--swiss-black, #111111);
    background: #ffffff;
    border: 1px solid var(--swiss-black, #111111);
    border-radius: 0;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.12s ease;
}

.swiss-toc-action:hover {
    background: var(--swiss-black, #111111);
    color: white;
}

.swiss-toc-action svg {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
}

/* ==========================================================================
   SIDEBAR AD BANNER - COMPACT SWISS STYLE
   ========================================================================== */

.swiss-ad-banner--sidebar {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--swiss-off-white, #F5F5F0);
    border: 2px solid var(--swiss-black, #111111);
    position: relative;
}

.swiss-ad-banner--sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--swiss-red, #FF3B30);
}

.swiss-ad-banner--sidebar .swiss-ad-banner__label {
    font-size: 0.5rem;
    margin-bottom: 0.5rem;
    color: #999;
}

.swiss-ad-banner--sidebar .swiss-ad-banner__content {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
}

.swiss-ad-banner--sidebar .swiss-ad-banner__title {
    font-size: 0.875rem;
    line-height: 1.3;
}

.swiss-ad-banner--sidebar .swiss-ad-banner__description {
    font-size: 0.75rem;
    line-height: 1.4;
    color: #666;
}

.swiss-ad-banner--sidebar .swiss-ad-banner__cta {
    width: 100%;
    justify-content: center;
    padding: 0.625rem 1rem;
    font-size: 0.5625rem;
    background: var(--swiss-black, #111111);
    color: white;
    border: none;
    text-decoration: none;
}

.swiss-ad-banner--sidebar .swiss-ad-banner__cta:hover {
    background: var(--swiss-red, #FF3B30);
}

/* ==========================================================================
   MOBILE TOC - SWISS STYLE
   ========================================================================== */

.swiss-toc-mobile {
    display: none;
    margin-bottom: 1.5rem;
}

@media (max-width: 1023px) {
    .swiss-toc-mobile {
        display: block;
    }
}

.swiss-toc-mobile__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.875rem 1rem;
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--swiss-black, #111111);
    background: #ffffff;
    border: 2px solid var(--swiss-black, #111111);
    border-radius: 0;
    cursor: pointer;
    transition: all 0.15s ease;
}

.swiss-toc-mobile__trigger:hover {
    background: var(--swiss-off-white, #F5F5F0);
}

.swiss-toc-mobile__trigger.is-open {
    background: var(--swiss-black, #111111);
    color: white;
}

.swiss-toc-mobile__label {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.swiss-toc-mobile__label svg {
    color: var(--swiss-red, #FF3B30);
    width: 16px;
    height: 16px;
}

.swiss-toc-mobile__trigger.is-open .swiss-toc-mobile__label svg {
    color: white;
}

.swiss-toc-mobile__chevron {
    transition: transform 0.2s ease;
    width: 18px;
    height: 18px;
}

.swiss-toc-mobile__trigger.is-open .swiss-toc-mobile__chevron {
    transform: rotate(180deg);
}

.swiss-toc-mobile__content {
    display: none;
    padding: 0.875rem;
    background: #ffffff;
    border: 2px solid var(--swiss-black, #111111);
    border-top: none;
    border-radius: 0;
    max-height: 50vh;
    overflow-y: auto;
}

.swiss-toc-mobile__content.is-open {
    display: block;
}

.swiss-toc-mobile__content nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.swiss-toc-mobile__content nav li {
    margin: 0;
}

.swiss-toc-mobile__content nav a {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #444;
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.12s ease;
}

.swiss-toc-mobile__content nav a:hover {
    color: var(--swiss-red, #FF3B30);
    background: rgba(255, 59, 48, 0.03);
}

.swiss-toc-mobile__content nav li:last-child a {
    border-bottom: none;
}

.swiss-toc-mobile__content nav ul ul {
    padding-left: 1.25rem;
}

.swiss-toc-mobile__content nav ul ul a {
    font-size: 0.75rem;
    color: #666;
    padding: 0.375rem;
}

/* ==========================================================================
   INLINE AD BANNER
   ========================================================================== */

.swiss-ad-banner {
    position: relative;
    background: var(--swiss-off-white, #F5F5F0);
    border: 2px solid var(--swiss-black, #111111);
    padding: 1.25rem 1.5rem;
    margin: 2rem 0;
}

.swiss-ad-banner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
    background: var(--swiss-red, #FF3B30);
}

.swiss-ad-banner__label {
    display: inline-block;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #999;
    margin-bottom: 0.625rem;
}

.swiss-ad-banner__content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
}

.swiss-ad-banner__text {
    flex: 1;
}

.swiss-ad-banner__title {
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-size: 1rem;
    font-weight: 700;
    color: var(--swiss-black, #111111);
    margin: 0 0 0.25rem;
    line-height: 1.3;
}

.swiss-ad-banner__description {
    font-size: 0.8125rem;
    color: #666;
    margin: 0;
    line-height: 1.45;
}

.swiss-ad-banner__cta {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.625rem 1rem;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.5625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: white;
    background: var(--swiss-black, #111111);
    border: none;
    text-decoration: none;
    transition: all 0.12s ease;
    flex-shrink: 0;
}

.swiss-ad-banner__cta:hover {
    background: var(--swiss-red, #FF3B30);
}

.swiss-ad-banner__cta svg {
    width: 12px;
    height: 12px;
}

/* Responsive */
@media (max-width: 640px) {
    .swiss-ad-banner__content {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.875rem;
    }
    
    .swiss-ad-banner__cta {
        width: 100%;
        justify-content: center;
    }
}
