/**
 * Typecho 1.3 主题 - Minimalist
 * 响应式设计文件 v4.0
 *
 * @package Minimalist
 */

/* ===== 平板宽屏 (≤ 1024px) ===== */
@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr 240px;
        gap: 1.25rem;
        padding: 1.25rem 1rem;
    }

    .sidebar { top: 64px; }

    .post-thumb-link { width: 180px; }
}

/* ===== 平板竖屏 (≤ 860px) ===== */
@media (max-width: 860px) {
    .container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .sidebar { position: static; }

    .post-thumb-link { width: 160px; }
}

/* ===== 移动端 (≤ 768px) ===== */
@media (max-width: 768px) {
    :root { --max-width: 100%; }

    html, body {
        overflow-x: hidden;
        width: 100%;
    }

    body {
        font-size: 14px;
        padding-top: 50px;
    }

    .header-container {
        padding: 0 0.875rem;
        height: 50px;
    }

    .site-description { display: none; }

    .mobile-menu-toggle {
        display: flex !important;
    }

    .main-navigation {
        margin-left: 0;
        position: fixed;
        top: 0;
        right: -100%;
        width: 260px;
        height: 100vh;
        background-color: var(--bg-primary);
        border-left: 1px solid var(--border-color);
        z-index: 999;
        transition: right 0.3s cubic-bezier(0.4,0,0.2,1);
        overflow-y: auto;
        padding-top: 50px;
        flex-direction: column;
        align-items: stretch;
        box-shadow: -8px 0 24px rgba(0,0,0,0.08);
    }

    .main-navigation.active { right: 0; }

    .nav-menu {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        padding: 0.5rem 0;
    }

    .nav-item { border-bottom: 1px solid var(--bg-tertiary); }
    .nav-item:last-child { border-bottom: none; }

    .nav-item > a {
        height: auto;
        padding: 0.85rem 1.25rem;
        border-bottom: none;
        font-size: 0.925rem;
        transition: background-color 0.2s, padding-left 0.2s;
    }

    .nav-item > a:hover,
    .nav-item.current-menu-item > a {
        background-color: var(--primary-light);
        border-bottom: none;
        padding-left: 1.5rem;
        color: var(--primary-color);
    }

    .header-search-inner { padding: 0.6rem 0.875rem; }

    .slider { aspect-ratio: 16 / 7; }
    .slide-title { font-size: 0.9rem; }

    .slider-btn {
        width: 30px;
        height: 30px;
    }

    .slider-prev { left: 8px; }
    .slider-next { right: 8px; }

    .container {
        padding: 0.875rem 0.75rem;
        gap: 0.875rem;
    }

    .post-card {
        flex-direction: column;
    }

    .post-thumb-link {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .post-thumb {
        min-height: 0;
        aspect-ratio: 16 / 7;
    }

    .post-body {
        padding: 0.875rem 1rem;
    }

    .post-title { font-size: 0.975rem; }

    .post-meta {
        gap: 0.35rem 0.7rem;
        font-size: 0.76rem;
    }

    .post-excerpt {
        font-size: 0.835rem;
        -webkit-line-clamp: 2;
    }

    .read-more {
        font-size: 0.78rem;
        padding: 0.28rem 0.9rem;
    }

    .post-footer {
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .post-content h2 { font-size: 1.15rem; }
    .post-content h3 { font-size: 1.05rem; }
    .post-content img { margin: 0.875rem 0; }

    .widget { margin-bottom: 0.6rem; }

    .widget-title {
        font-size: 0.75rem;
        padding: 0.5rem 0.875rem;
    }

    .widget a {
        padding: 0.4rem 0.875rem;
        font-size: 0.82rem;
    }

    .site-footer {
        padding: 1.5rem 0.875rem 1rem;
        margin-top: 1rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .footer-bottom {
        padding-top: 1rem;
        font-size: 0.78rem;
    }

    .comment-child {
        margin-left: 1.5rem;
        padding-left: 0.75rem;
    }

    .comment-content,
    .comment-reply {
        margin-left: 0;
    }

    .comment-inputs { grid-template-columns: 1fr; }

    #comments { padding: 1.25rem 1rem; }

    .respond,
    #respond { padding: 1.25rem 1rem; }
}

/* ===== 小屏手机 (≤ 480px) ===== */
@media (max-width: 480px) {
    body { font-size: 14px; }

    .container { padding: 0.75rem; }

    .slider { aspect-ratio: 16 / 8; }

    .slide-caption { padding: 1.5rem 1rem 0.75rem; }

    .slide-title { font-size: 0.82rem; }

    .post-thumb { aspect-ratio: 16 / 6; }

    .post-body { padding: 0.75rem 0.875rem; }

    .post-title { font-size: 0.95rem; }

    .post-meta {
        flex-wrap: wrap;
        gap: 0.3rem 0.55rem;
        font-size: 0.73rem;
    }

    .post-excerpt { font-size: 0.82rem; }

    .post-content h2 { font-size: 1.1rem; }
    .post-content h3 { font-size: 1rem; }

    .post-content pre {
        padding: 0.875rem;
        margin: 0.875rem 0;
        font-size: 0.82em;
        overflow-x: scroll;
    }

    .post-content ul,
    .post-content ol { padding-left: 1.4rem; }

    .post-tags a,
    .tag-cloud .tag-item {
        padding: 0.15rem 0.5rem;
        font-size: 0.76rem;
    }

    .page-nav { gap: 0.35rem; }

    .page-nav a,
    .page-nav span {
        padding: 0.3rem 0.65rem;
        font-size: 0.82rem;
    }

    .widget { margin-bottom: 0.5rem; }

    .main-navigation { width: 230px; }

    .footer-content { gap: 1rem; }

    .slider-btn { display: none; }

    /* 单篇文章页面移动端适配 */
    .single-post {
        padding: 1.25rem 1rem;
    }

    .single-post > .post-title {
        font-size: 1.25rem;
        padding-left: 0.75rem;
    }

    .post-navigation {
        flex-direction: column;
        gap: 0.75rem;
    }

    .post-nav-next {
        text-align: left;
    }

    /* 阅读进度条 */
    .reading-progress {
        height: 2px;
    }

    /* 归档头部 */
    .archive-header {
        padding: 1.25rem 1rem;
    }

    .archive-title {
        font-size: 1.2rem;
    }

    .search-form-archive form {
        flex-direction: column;
    }
}

/* ===== 横屏优化 ===== */
@media (max-height: 500px) and (orientation: landscape) {
    .site-header { position: relative; }

    .main-navigation {
        height: 100vh;
        padding-top: 1rem;
    }

    .slider { aspect-ratio: 21 / 6; }
}

/* ===== 打印 ===== */
@media print {
    .site-header,
    .sidebar,
    .site-footer,
    .post-meta,
    .post-tags,
    .page-nav,
    .nav-overlay,
    .slider-wrap,
    .theme-toggle-wrapper,
    .reading-progress,
    .back-to-top {
        display: none;
    }

    body { padding-top: 0; }

    .container {
        display: block;
        padding: 0;
    }

    .post {
        box-shadow: none;
        border: none;
        page-break-inside: avoid;
    }

    .post-card { flex-direction: column; }
    .post-thumb-link { display: none; }

    body {
        background-color: white;
        color: black;
    }

    a {
        color: black;
        text-decoration: underline;
    }

    .post-content a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
    }
}

/* ===== 高对比度 ===== */
@media (prefers-contrast: high) {
    :root {
        --border-color: #888;
        --text-primary: #000;
        --text-secondary: #222;
    }
}

/* ===== 减少动画 ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }

    html { scroll-behavior: auto; }

    .slide { transition: none !important; }

    .sbubble { animation: none !important; opacity: 0 !important; }

    .reading-progress { transition: none !important; }

    .container { animation: none !important; }

    .error-404::before { animation: none !important; }
    .error-title { animation: none !important; }
    .error-subtitle,
    .error-description,
    .error-actions,
    .error-suggestions { animation: none !important; }
}
