body {
    --scrollbar-width: 24px;
    --tick-color: #333333;
    --thumb-height: 40px;
}

/* ================= 布局样式 ================= */
#font-list {
    display: flex;
    overflow: auto hidden;
    padding: 1rem 0.5rem;
    margin: 0 auto;
    gap: 2rem 1rem;
    scrollbar-gutter: stable;

    body.column-list & {
        width: 580px;
        max-width: 100%;
        flex-direction: column;
        overflow: hidden auto;
    }
}

/* ================= 节点样式 ================= */
.font-card {
    display: flex;
    position: relative;
    border-radius: 2px;
    background: var(--secondary);
    color: var(--primary);
    box-shadow: 2px 2px 2px rgba(20, 20, 20, 0.4);

    .preview-section {
        flex: 1 1 auto;
        z-index: 0;

        a {
            position: absolute;
            inset: 0;

            &:focus-visible {
                background: none;
            }
        }

        header {
            pointer-events: none;
        }

        /* 字体预览容器 */
        div {
            pointer-events: none;
            font-size: 0.9em;
            color: #666;
        }
    }

    .code-section {
        padding: 10px;
        gap: 10px;
        z-index: 1;
    }

    body.column-list & {
        min-height: 150px;
        align-items: center;

        .preview-section {
            height: 100%;

            header {
                display: flex;
                height: 100%;
                align-items: center;

                &::before {
                    box-sizing: border-box;
                    content: '';
                    position: absolute;
                    left: 0;
                    top: 50%;
                    translate: 0 -50%;
                    height: 120px;
                    width: 60px;
                    border-radius: 0 120px 120px 0;
                    border: 1px solid;
                    border-left: none;
                }

                &::after {
                    box-sizing: border-box;
                    content: '';
                    position: absolute;
                    left: 0;
                    top: 50%;
                    translate: 0 -50%;
                    height: 6px;
                    width: 56px;
                    border-radius: 0 3px 3px 0;
                    border: 2px solid;
                    border-left: none;
                    background-color: currentColor;
                    background-image: linear-gradient(to right, #ffd3d7, #ffa4ac);
                    background-size: 0;
                    background-repeat: no-repeat;
                    transition: background-size 0.15s;
                }

                h4 {
                    position: relative;
                    left: 20px;
                    bottom: 20px;
                    margin: 0;
                    padding: 2px 4px 0;
                    color: #666;
                    background-color: var(--secondary);

                    &::before {
                        content: '';
                        position: absolute;
                        left: calc(100% - 1em);
                        bottom: 0;
                        height: 2px;
                        width: 80px;
                        border-radius: 2px;
                        background-image: linear-gradient(to right, transparent, currentColor);
                        background-size: 0;
                        background-repeat: no-repeat;
                        opacity: 0;
                        transition: background-size 0.3s ease-out, opacity 0.15s;
                    }
                }
            }

            &:hover {
                header::after {
                    background-size: 100%;
                }

                h4::before {
                    background-size: 100%;
                    opacity: 1;
                    transition: background-size 0.3s ease-out 0.2s, opacity 0.15s 0.2s;
                }
            }

            p {
                position: absolute;
                margin: 0;
            }

            .p1 {
                top: 10px;
                right: 180px;
            }

            .p2 {
                top: calc(10px + 1.5em);
                right: 120px;
            }

            .p3 {
                bottom: calc(15px + 1.5em);
                right: 45%;
            }

            .p4 {
                bottom: 15px;
                right: 45%;
            }
        }

        .code-section {
            display: flex;
            height: 100%;
            flex: 0 0 80px;
            flex-direction: column;

            summary {
                position: relative;
                font-family: var(--defaultFont);
                font-size: 0.8rem;
                filter: brightness(1);
                transition: 0.4s;

                &::before {
                    position: absolute;
                    pointer-events: none;
                    content: '';
                    right: 0;
                    top: 50%;
                    translate: 0 -50%;
                    width: 6px;
                    height: 4px;
                    border-radius: 4px;
                    background-color: var(--code-Attr);
                    box-shadow: inset 0 0 2px rgba(20, 20, 20, 0.4);
                    opacity: 0;
                    transition: opacity 0.2s;
                }

                &:hover {
                    filter: brightness(1.25);
                    padding: 2px 8px 2px 0;

                    &::before {
                        opacity: 1;
                        transition: opacity 0.4s ease-out 0.3s;
                    }
                }
            }
        }
    }
}

/* ================= 代码折叠区 ================= */
/* --- 展示框 --- */
.code-section details {
    margin: 0 0 0 auto;
    width: fit-content;

    &::details-content {
        display: none;
        position: absolute;
        width: 75%;
        bottom: 50%;
        left: 0;
        background: #f7f6f5;
        border-radius: 1px;
        border: 1px solid #ddd;
        box-shadow: 0 0 0 4px var(--secondary);
        padding: 1rem;
        font-family: Consolas, monospace;
        font-size: 0.85rem;
        line-height: 1.4;
        z-index: 5;
        opacity: 0;
        transform: scale(0) translateX(50%);
        transform-origin: right bottom;
        transition:
            transform 0.6s cubic-bezier(0.16, 1, 0.3, 1),
            opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
            display 1s allow-discrete,
            content-visibility 1s allow-discrete;
    }

    article:first-child &::details-content {
        bottom: unset;
        top: 50%;
        transform-origin: right top;
    }

    &:open::details-content {
        display: block;
        opacity: 1;
        transform: scale(1);

        @starting-style {
            opacity: 0;
            transform: scale(0) translateX(50%);
        }
    }
}

.code-content {
    color: var(--primary);
    white-space: pre-wrap;
    word-break: break-all;

    /* 高亮 span */
    .hl-k {
        color: var(--code-Main);
    }

    .hl-s {
        color: var(--code-Str);
    }

    .hl-t {
        color: var(--code-Sel);
    }

    .hl-p {
        color: var(--code-Attr);
    }
}

/* --- 复制按钮 --- */
.copy-btn {
    display: inline-block;
    position: absolute;
    bottom: 0.3rem;
    right: 0.3rem;
    width: 24px;
    aspect-ratio: 1 / 1;
    border-radius: 50%;

    &:focus-visible {
        background: none;
    }

    &:disabled {
        cursor: default;
    }

    svg {
        color: #96ce54;
        position: absolute;
        pointer-events: none;
        inset: 0;
        padding: 3px;
        top: 50%;
        left: 50%;
        translate: -50% -50%;
        width: 100%;
        height: 100%;
        opacity: 0;
        transform: scale(0.5);
        transition: opacity 0.3s ease-out, transform 0.4s ease-out;
    }

    lottie-player {
        position: absolute;
        inset: 0;
        filter: invert(50%);
        opacity: 0.4;
        transition: filter 0.4s, opacity 0.2s;
    }

    &:hover lottie-player {
        filter: invert(53%) sepia(5%) saturate(3894%) hue-rotate(10deg) brightness(104%) contrast(92%);
        opacity: 0.8;
    }

    /* 气泡提示 */
    .tooltip {
        font-family: var(--defaultFont);
        position: absolute;
        top: 50%;
        right: 100%;
        background: linear-gradient(to right, #20202060, transparent);
        color: var(--secondary);
        font-size: 0.8rem;
        padding: 2px 6px;
        border-radius: 2px;
        white-space: nowrap;
        pointer-events: none;
        z-index: 1;
        opacity: 0;
        translate: 0 -50%;
        transform: translateX(50%);
    }

    /* 复制成功状态切换 */
    &.copied {

        svg {
            opacity: 0.8;
            transform: scale(1);
        }

        lottie-player {
            opacity: 0;
        }

        .tooltip {
            opacity: 1;
            transform: translateX(0);
            transition: 0.4s;
        }
    }
}

/* ====== 嗷！ ====== */
main {
    timeline-scope: --list-scroll;
}

#font-list {
    scroll-timeline-name: --list-scroll;
    scroll-timeline-axis: block;
    scroll-behavior: smooth;
}

.fake-scrollbar {
    position: absolute;
    bottom: 0;
    right: 30%;
    rotate: 10deg;
    width: 30px;
    height: 50%;
    align-items: center;
    perspective: 240px;
    perspective-origin: -50%;
    transform-style: preserve-3d;
    pointer-events: none;
}

.center-mask {
    position: absolute;
    width: 200%;
    height: 100%;
    top: 0;
    right: 0;
    background: linear-gradient(transparent, var(--bg), transparent);
    transform: translateZ(-2px);
}

.dial-cylinder {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    animation: roll-cylinder linear forwards;
    animation-timeline: --list-scroll;
}

.dial-cylinder>div {
    position: absolute;
    color: #999;
    font-family: "Dotted Songti Diamond", monospace;
    font-size: 0.8em;
    width: 100%;
    height: var(--face-height);
    top: 50%;
    margin-top: calc(var(--face-height) * -0.5);
    text-align: end;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    padding-right: 4px;
    transform:
        rotateX(calc(var(--index) * (360deg / var(--face-count)))) translateZ(var(--radius));
}

/* === 刻度线 === */
.hud-line {
    background-color: #002FA7;
    height: 2px;
    border-radius: 2px;
}

/* --- 数字 --- */
.hud-num {
    position: relative;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 10px;
    font-weight: 400;
    color: #888;
    letter-spacing: 1px;

    &::before {
        content: '';
        position: absolute;
        border-radius: 2px;
        left: 105%;
        top: 50%;
        translate: 0 -50%;
        width: 16px;
        height: 1px;
        background-color: currentColor;
    }
}

/* 中刻度 */
.hud-line.medium {
    width: 10px;
}

/* 短刻度 */
.hud-line.short {
    width: 4px;
    opacity: 0.4;
}

@keyframes roll-cylinder {
    from {
        transform: rotateX(0deg);
    }

    to {
        transform: rotateX(360deg);
    }
}