/* 回到顶部按钮 */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 48px;
    height: 48px;
    background: var(--telegram);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 136, 204, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-to-top:hover {
    background: var(--telegram-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 136, 204, 0.4);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top svg {
    width: 24px;
    height: 24px;
}

/* 图片懒加载占位 */
img[loading="lazy"] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

img[loading="lazy"].loaded {
    animation: none;
    background: none;
}

/* 平滑滚动 */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* 页面加载动画 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

/* 卡片入场动画 */
.post-item {
    animation: fadeInUp 0.6s ease-out backwards;
}

.post-item:nth-child(1) { animation-delay: 0.1s; }
.post-item:nth-child(2) { animation-delay: 0.2s; }
.post-item:nth-child(3) { animation-delay: 0.3s; }
.post-item:nth-child(4) { animation-delay: 0.4s; }
.post-item:nth-child(5) { animation-delay: 0.5s; }
.post-item:nth-child(6) { animation-delay: 0.6s; }

/* 移动端优化 */
@media (max-width: 768px) {
    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 42px;
        height: 42px;
    }
    
    .back-to-top svg {
        width: 20px;
        height: 20px;
    }
}

/* 打印样式 */
@media print {
    .back-to-top,
    header,
    footer,
    nav,
    .no-print {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    a {
        color: black;
        text-decoration: underline;
    }
}

/* 无障碍优化 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus 样式优化 */
*:focus-visible {
    outline: 2px solid var(--telegram);
    outline-offset: 2px;
    border-radius: 4px;
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--telegram);
    outline-offset: 2px;
}

/* 加载状态 */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--telegram);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 选择文本样式 */
::selection {
    background-color: var(--telegram);
    color: white;
}

::-moz-selection {
    background-color: var(--telegram);
    color: white;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--telegram);
}

/* 暗色模式滚动条 */
@media (prefers-color-scheme: dark) {
    ::-webkit-scrollbar-track {
        background: #2b3842;
    }
    
    ::-webkit-scrollbar-thumb {
        background: #4a5d6f;
    }
    
    ::-webkit-scrollbar-thumb:hover {
        background: var(--telegram);
    }
}
