/* Automatic Grant Contents */
.gdtoc[hidden] {
    display: none !important;
}

.gdtoc {
    --gdtoc-card-width: min(258px, calc(100vw - 62px));
    position: fixed;
    left: 8px;
    top: 50%;
    z-index: 997;
    width: 28px;
    font-family: inherit;
    transform: translateY(-50%);
}

.gdtoc__toggle {
    width: 28px;
    height: 86px;
    min-width: 28px;
    min-height: 86px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #9ca3af;
    box-shadow: none;
    cursor: pointer;
}

.gdtoc__toggle:hover,
.gdtoc.is-open .gdtoc__toggle {
    color: #6b7280;
}

.gdtoc__toggle:focus {
    outline: none;
}

.gdtoc__toggle:focus-visible {
    outline: 2px solid var(--grantaura-primary);
    outline-offset: 3px;
    border-radius: 4px;
}

.gdtoc__lines {
    display: grid;
    gap: 9px;
    width: 18px;
}

.gdtoc__line {
    display: block;
    width: 14px;
    height: 1.5px;
    border-radius: 999px;
    background: currentColor;
}

.gdtoc__line:nth-child(2),
.gdtoc__line:nth-child(4) {
    width: 16px;
}

.gdtoc__panel {
    position: absolute;
    left: 28px;
    top: 50%;
    width: var(--gdtoc-card-width);
    max-height: min(52vh, 330px);
    overflow: hidden;
    padding: 14px 12px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 7px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(17, 24, 39, 0.1), 0 14px 36px rgba(17, 24, 39, 0.06);
    opacity: 0;
    visibility: hidden;
    transform: translate(-4px, -50%);
    pointer-events: none;
    transition: opacity 0.14s ease, visibility 0.14s ease, transform 0.14s ease;
}

.gdtoc:hover .gdtoc__panel,
.gdtoc:focus-within .gdtoc__panel,
.gdtoc.is-open .gdtoc__panel {
    opacity: 1;
    visibility: visible;
    transform: translate(0, -50%);
    pointer-events: auto;
}

.gdtoc__label {
    margin: 0 0 11px;
    padding: 0 1px;
    font-size: 0.68rem;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #333333;
}

.gdtoc__list {
    display: grid;
    gap: 2px;
    max-height: calc(min(52vh, 330px) - 43px);
    margin: 0;
    padding: 0;
    list-style: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

.gdtoc__list::-webkit-scrollbar {
    width: 6px;
}

.gdtoc__list::-webkit-scrollbar-track {
    background: transparent;
}

.gdtoc__list::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: #d1d5db;
}

.gdtoc__item {
    min-width: 0;
}

.gdtoc__item--h3 {
    padding-left: 10px;
}

.gdtoc__item--h4 {
    padding-left: 20px;
}

.gdtoc__link {
    display: block;
    min-height: 32px;
    padding: 3px 0;
    border-radius: 0;
    color: #858585;
    font-size: 0.82rem;
    line-height: 1.35;
    font-weight: 400;
    text-decoration: none !important;
}

.gdtoc__link:hover,
.gdtoc__link:focus-visible,
.gdtoc__link.is-active {
    color: #333333;
}

.gdtoc__link:focus {
    outline: none;
}

.gdtoc__link:focus-visible {
    box-shadow: 0 0 0 1px var(--grantaura-primary);
}

.grantdetail-primary__description h2[id],
.grantdetail-primary__description h3[id],
.grantdetail-primary__description h4[id] {
    scroll-margin-top: 110px;
}

@media (min-width: 768px) {
    .gdtoc {
        left: 8px;
    }

    .gdtoc__panel {
        left: 28px;
    }
}

@media (min-width: 1280px) {
    .gdtoc {
        left: 8px;
    }
}

@media (max-width: 520px) {
    .gdtoc {
        left: 4px;
        top: 52%;
    }

    .gdtoc__panel {
        left: 28px;
        max-height: min(55vh, 340px);
    }

    .gdtoc__list {
        max-height: calc(min(55vh, 340px) - 43px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .gdtoc__panel {
        transition: none;
    }
}
