/* 文章预览抽屉的桌面宽度，移动端会在媒体查询中改为底部弹窗。 */
:root {
    --article-preview-width: min(42vw, 760px);
}

/* 外层只负责拦截点击和控制透明度，不改变原页面已有布局。 */
.article-preview {
    position: fixed;
    inset: 0;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity .12s linear;
}

.article-preview.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* 遮罩覆盖全页，点击遮罩由 JS 关闭预览。 */
.article-preview-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(16, 19, 22, .22);
    display: block;
}

/* 宽屏从右侧滑入，iframe 内容直接加载文章页，减少模板侵入。 */
.article-preview-sheet {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface);
    border-left: 1px solid var(--line);
    border-radius: 12px 0 0 12px;
    box-shadow: -18px 0 42px rgba(0, 0, 0, .16);
    transform: translate3d(100%, 0, 0);
    transition: transform .28s ease;
    will-change: transform;
}

.article-preview.is-open .article-preview-sheet {
    transform: translate3d(0, 0, 0);
}

.article-preview-head {
    display: flex;
    gap: .75rem;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
    padding: .85rem .9rem;
    border-bottom: 1px solid var(--line-soft);
}

/* 标题需要单行省略，避免长标题挤压右侧按钮。 */
.article-preview-title-wrap {
    min-width: 0;
}

.article-preview-title {
    margin: 0;
    color: var(--text);
    font-size: .98rem;
    font-weight: 760;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.article-preview-actions {
    display: inline-flex;
    gap: .45rem;
    flex: 0 0 auto;
}

/* 预览内的操作按钮可以有中圆角，和主题主体直角风格区分开。 */
.article-preview-open,
.article-preview-close {
    display: inline-flex;
    height: 38px;
    min-width: 38px;
    padding: 0 .65rem;
    align-items: center;
    justify-content: center;
    color: var(--text-soft);
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
}

.article-preview-open:hover,
.article-preview-close:hover {
    color: #fff;
    text-decoration: none;
    background: var(--brand);
    border-color: var(--brand);
}

.article-preview-frame {
    width: 100%;
    flex: 1 1 auto;
    border: 0;
    background: var(--bg);
}

@media (min-width: 1025px) {
    /* 桌面端只占右侧宽度，左侧页面仍可作为背景参照。 */
    .article-preview-sheet {
        width: var(--article-preview-width);
    }
}

@media (max-width: 1024px) {
    /* 窄屏改为底部抽屉，占 95vh，保留顶部一点原页面上下文。 */
    .article-preview {
        inset: 0;
        width: auto;
    }

    .article-preview-backdrop {
        background: rgba(16, 19, 22, .34);
    }

    .article-preview-sheet {
        top: auto;
        left: 0;
        width: 100%;
        height: 95vh;
        border-left: 0;
        border-top: 1px solid var(--line);
        border-radius: 12px 12px 0 0;
        transform: translate3d(0, 100%, 0);
    }

    .article-preview.is-open .article-preview-sheet {
        transform: translate3d(0, 0, 0);
    }
}
