/* Table of contents
 *
 * Figma: MMpPdW3v7g7kvRCS8g1O4o, desktop sticky node 361:8529 and mobile
 * node 361:7634. The three public positions share one semantic navigation
 * shell. The theme controls the page grid; this component fills either the
 * article column or its 361px sidebar track.
 */
.ut-toc-anchor {
    box-sizing: border-box;
    width: 100%;
    margin: var(--ut-spacing-md, 16px) 0;
    padding: 16px 24px;
    border: 0;
    border-radius: var(--ut-radius-lg, 16px);
    background: var(--background-accent-muted, #f7f9fd);
    color: var(--text-primary-color, #1e2058);
}

.ut-toc-anchor__toggle,
.ut-toc-anchor__header {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 24px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    gap: 8px;
}

.ut-toc-anchor__toggle {
    cursor: pointer;
}

.ut-toc-anchor__toggle:focus-visible {
    outline: 2px solid var(--ut-blue-600, #0d49c7);
    outline-offset: 4px;
    border-radius: 4px;
}

.ut-toc-anchor__list-icon {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    background: url('../img/toc-list-unordered.svg') center / 16px 12.002px no-repeat;
}

.ut-toc-anchor__title {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: 0;
    font-family: var(--ut-font-family, 'Poppins', sans-serif);
    font-size: 14px;
    font-weight: 600;
    line-height: 22px;
}

.ut-toc-anchor__chevron {
    display: none;
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    background: url('../img/toc-chevron-up.svg') center / 10px 6px no-repeat;
    transform: rotate(180deg);
    transition: transform 0.2s ease;
}

.ut-toc-anchor__toggle[aria-expanded="true"] .ut-toc-anchor__chevron {
    transform: none;
}

.ut-toc-anchor .pages-table-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    margin: 16px 0 0;
    padding: 0;
    list-style: none;
    counter-reset: ut-toc-item;
}

.ut-toc-anchor--center .pages-table-content {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 24px;
}

.ut-toc-anchor__item {
    min-width: 0;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-increment: ut-toc-item;
}

.ut-toc-anchor__sublist {
    margin: 0;
    padding: 0;
    list-style: none;
}

.ut-toc-anchor__link {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    min-height: 40px;
    box-sizing: border-box;
    padding: 8px 16px;
    border-radius: var(--ut-radius-md, 8px);
    color: var(--text-primary-color, #1e2058);
    font-family: var(--ut-font-family, 'Poppins', sans-serif);
    font-size: var(--ut-font-size-md, 16px);
    font-weight: 400;
    line-height: 1.5;
    text-decoration: none;
    overflow-wrap: anywhere;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.ut-toc-anchor__link::before {
    content: counter(ut-toc-item) '.';
    text-align: center;
    font-size: 14px;
    font-weight: 500;
}

.ut-toc-anchor__link:hover {
    background: var(--ut-blue-30, #e7edfa);
    color: var(--text-primary-color, #1e2058);
    text-decoration: none;
}

.ut-toc-anchor__link:focus-visible {
    outline: 2px solid var(--ut-blue-600, #0d49c7);
    outline-offset: -2px;
}

.ut-toc-anchor__link.is-active,
.ut-toc-anchor__link[aria-current="location"] {
    background: var(--button-bg-primary, #050745);
    color: var(--ut-gray-50, #fff);
}

/* Sticky-top is the 361px detail-sidebar variant. The page layout owns that
   track; the block remains width:100% and sticks below the visible header. */
.ut-toc-anchor--sticky-top {
    position: relative;
}

.ut-toc-anchor--sticky-top[data-sticky="true"] {
    position: sticky;
    top: calc(var(--ut-header-visible-height, var(--ut-header-height, 64px)) + 16px);
    z-index: 1001;
}

.ut-toc-anchor--sticky-top .ut-toc-anchor__link {
    display: block;
    min-height: 0;
    padding: 8px 16px 8px 29px;
    border-left: 3px solid var(--border-default-primary, #cfdbf4);
    border-radius: 0;
    background: transparent;
    color: var(--text-secondary-color, #50527d);
    font-size: 14px;
    line-height: 22px;
}

/* Nested H3 entries remain on the same continuous active rail as their H2
   parent, while their labels move one spacing step inward. */
.ut-toc-anchor--sticky-top .ut-toc-anchor__sublist .ut-toc-anchor__link {
    padding-left: 45px;
}

.ut-toc-anchor--sticky-top .ut-toc-anchor__link::before {
    display: none;
}

.ut-toc-anchor--sticky-top .ut-toc-anchor__link:hover {
    background: transparent;
    color: var(--text-primary-color, rgb(5 7 69 / 90%));
}

.ut-toc-anchor--sticky-top .ut-toc-anchor__link.is-active,
.ut-toc-anchor--sticky-top .ut-toc-anchor__link[aria-current="location"] {
    border-left-color: var(--ut-orange-500, #fc7d21);
    background: transparent;
    color: var(--text-primary-color, rgb(5 7 69 / 90%));
    font-weight: 600;
}

.ut-toc-anchor--sticky-top.is-stuck {
    box-shadow: 0 4px 8px rgb(5 7 69 / 8%);
}

body.ut-toc-stuck ut-header,
body.ut-toc-stuck #ut-main-header {
    --ut-header-shadow: none;
}

body.ut-toc-stuck .header-wrapper:not(ut-header):not(#ut-main-header),
body.ut-toc-stuck header.site-header,
body.ut-toc-stuck #masthead {
    box-shadow: none !important;
    border-bottom-color: transparent !important;
}

.block-editor-page .ut-toc-anchor--sticky-preview {
    outline: 1px dashed rgb(5 7 69 / 20%);
    outline-offset: 2px;
}

.ut-toc-anchor__editor-item + .ut-toc-anchor__editor-item {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #ddd;
}

@media (max-width: 800px) {
    .ut-toc-anchor,
    .ut-toc-anchor--center,
    .ut-toc-anchor--side,
    .ut-toc-anchor--sticky-top {
        margin: 0;
        padding: 16px 24px;
        border-radius: var(--ut-radius-lg, 16px);
    }

    .ut-toc-anchor__chevron {
        display: block;
    }

    .ut-toc-anchor .pages-table-content,
    .ut-toc-anchor--center .pages-table-content {
        grid-template-columns: minmax(0, 1fr);
        margin-top: 16px;
    }

    .ut-toc-anchor .pages-table-content[hidden] {
        display: none;
    }

    .ut-toc-anchor--sticky-top[data-sticky="true"] {
        top: var(--ut-header-visible-height, var(--ut-header-height, 56px));
    }

    .ut-toc-anchor--sticky-top.is-stuck {
        width: 100%;
        margin-right: 0;
        margin-left: 0;
        border-radius: var(--ut-radius-lg, 16px);
    }

    .ut-toc-anchor--sticky-top.is-open .pages-table-content {
        position: absolute;
        top: 100%;
        left: 0;
        z-index: 1;
        width: 100%;
        max-height: calc(100vh - var(--ut-header-visible-height, var(--ut-header-height, 56px)) - 72px);
        margin: 0;
        padding: 0 24px 16px;
        border-radius: 0 0 var(--ut-radius-lg, 16px) var(--ut-radius-lg, 16px);
        background: var(--background-accent-muted, #f7f9fd);
        box-sizing: border-box;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .ut-toc-anchor--sticky-top .ut-toc-anchor__link {
        min-height: 0;
        padding: 8px 16px 8px 29px;
    }

    .ut-toc-anchor--sticky-top:not(.is-open) .ut-toc-anchor__list-icon {
        display: none;
    }

    .ut-toc-anchor--sticky-top:not(.is-open) .ut-toc-anchor__title {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }
}

/*
 * Compatibility outside the Kreditkarte detail template
 * ------------------------------------------------------
 * GT-363 changes the TOC into the credit-card sidebar/mobile disclosure. Deal
 * and editorial posts already use this block as a horizontal sticky chip row;
 * keep that established presentation unless the maintained theme positively
 * identifies a Kreditkarte detail page. Gutenberg adds the explicit
 * horizontal-preview class for every other post type because iframe-based
 * editors cannot inherit the frontend body class.
 */
body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper) .ut-toc-anchor,
.ut-toc-anchor--horizontal-preview {
    margin: var(--ut-spacing-md, 16px) 0;
    padding: 12px 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor__toggle,
.ut-toc-anchor--horizontal-preview .ut-toc-anchor__header {
    display: none;
}

body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor[data-sticky="true"] {
    position: sticky;
    top: 0;
    z-index: 1001;
    padding: 12px 0;
    background: transparent;
    transition: box-shadow 0.2s ease;
}

body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor[data-sticky="true"].is-stuck {
    margin-right: calc(50% - 50vw);
    margin-left: calc(50% - 50vw);
    padding: 12px max(var(--ut-spacing-md, 16px), calc(50vw - var(--content-max-width, 1280px) / 2));
    padding-top: calc(12px + var(--ut-header-visible-height, var(--ut-header-height, 64px)));
    border-radius: 0;
    background: var(--ut-gray-50, #fff);
    box-shadow: 0 4px 8px rgb(5 7 69 / 8%);
    transition: padding-top 0.3s ease, box-shadow 0.2s ease;
}

body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor .pages-table-content,
.ut-toc-anchor--horizontal-preview .pages-table-content {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--ut-spacing-sm, 8px);
    margin: 0;
    padding: 0;
    overflow-x: auto;
    list-style: none;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor .pages-table-content[hidden],
.ut-toc-anchor--horizontal-preview .pages-table-content[hidden] {
    display: flex;
}

body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor .pages-table-content::-webkit-scrollbar,
.ut-toc-anchor--horizontal-preview .pages-table-content::-webkit-scrollbar {
    display: none;
}

body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor .pages-table-content li,
body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor__item,
.ut-toc-anchor--horizontal-preview .pages-table-content li,
.ut-toc-anchor--horizontal-preview .ut-toc-anchor__item {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    gap: var(--ut-spacing-sm, 8px);
    margin: 0;
    scroll-snap-align: start;
    text-align: left;
}

body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor__sublist,
.ut-toc-anchor--horizontal-preview .ut-toc-anchor__sublist {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--ut-spacing-sm, 8px);
}

body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor__link,
body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor--sticky-top .ut-toc-anchor__link,
body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor--sticky-top .ut-toc-anchor__sublist .ut-toc-anchor__link,
.ut-toc-anchor--horizontal-preview .ut-toc-anchor__link,
.ut-toc-anchor--horizontal-preview.ut-toc-anchor--sticky-top .ut-toc-anchor__link,
.ut-toc-anchor--horizontal-preview.ut-toc-anchor--sticky-top
    .ut-toc-anchor__sublist .ut-toc-anchor__link {
    display: inline-flex;
    align-items: center;
    gap: var(--ut-spacing-xs, 4px);
    min-height: 0;
    padding: 6px 12px 6px var(--ut-spacing-sm, 8px);
    border: 1px solid var(--border-default-primary, var(--ut-blue-20, #cfdbf4));
    border-radius: 40px;
    background: transparent;
    color: var(--text-primary-color, #1e2058);
    font-size: var(--ut-font-size-sm, 14px);
    font-weight: 500;
    line-height: var(--ut-line-height-md, 22px);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor__link::before,
body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor--sticky-top .ut-toc-anchor__link::before,
.ut-toc-anchor--horizontal-preview .ut-toc-anchor__link::before {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M7 12H17M17 12L13 8M17 12L13 16' stroke='%231E2058' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor__link:hover,
.ut-toc-anchor--horizontal-preview .ut-toc-anchor__link:hover {
    border-color: var(--border-default-primary, var(--ut-blue-20, #cfdbf4));
    background: var(--ut-blue-30, #e7edfa);
    color: var(--text-primary-color, #1e2058);
}

body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor__link:focus-visible,
body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor__link.is-active,
body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor__link[aria-current="location"],
.ut-toc-anchor--horizontal-preview .ut-toc-anchor__link:focus-visible,
.ut-toc-anchor--horizontal-preview .ut-toc-anchor__link.is-active,
.ut-toc-anchor--horizontal-preview .ut-toc-anchor__link[aria-current="location"] {
    border-color: var(--ut-blue-600, #0d49c7);
    background: var(--button-bg-primary, #050745);
    color: var(--ut-gray-50, #fff);
    font-weight: 500;
}

body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor__link:focus-visible::before,
body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor__link.is-active::before,
body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor__link[aria-current="location"]::before,
.ut-toc-anchor--horizontal-preview .ut-toc-anchor__link:focus-visible::before,
.ut-toc-anchor--horizontal-preview .ut-toc-anchor__link.is-active::before,
.ut-toc-anchor--horizontal-preview .ut-toc-anchor__link[aria-current="location"]::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M7 12H17M17 12L13 8M17 12L13 16' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-deal-content-row .ut-toc-anchor[data-sticky="true"].is-stuck {
    position: fixed;
    right: 0;
    left: 0;
    width: 100%;
    margin: 0;
    box-sizing: border-box;
    padding-right: max(var(--ut-spacing-md, 16px), calc(50vw - var(--content-max-width, 1280px) / 2));
    padding-left: max(var(--ut-spacing-md, 16px), calc(50vw - var(--content-max-width, 1280px) / 2));
}

@media (max-width: 800px) {
    body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
        .ut-toc-anchor:not(.is-stuck) {
        margin-top: 0;
        padding-top: 0;
    }
}

/* A Deal TOC is promoted above the article/sidebar row at runtime so the
   navigation spans the complete content card and both columns start below it. */
body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor--deal-wide {
    box-sizing: border-box;
    width: 100%;
    margin: 0 0 var(--ut-spacing-lg, 24px);
    padding: 0;
}

/* The promoted TOC already owns the separation from article content. Remove
   the legacy post-content inset and first-block margin so those three spacing
   layers resolve to one intentional 24px gap. */
body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor--deal-wide + .ut-deal-content-row > .post-content {
    padding-top: 0;
}

body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor--deal-wide + .ut-deal-content-row > .post-content > :first-child {
    margin-top: 0;
}

/* Keep the stuck row compact below the visible header. The generic legacy
   rule fills the header space with padding; a full-width Deal row can instead
   use a real fixed top offset and avoid the large blank band above its chips. */
body:not(.ut-credit-card-detail):not(.block-editor-page):not(.editor-styles-wrapper)
    .ut-toc-anchor--deal-wide[data-sticky="true"].is-stuck {
    position: fixed;
    top: var(--ut-header-visible-height, var(--ut-header-height, 64px));
    right: 0;
    left: 0;
    width: 100%;
    margin: 0;
    padding: 12px max(var(--ut-spacing-md, 16px), calc(50vw - var(--content-max-width, 1280px) / 2));
}
