/**
 * 黑客论坛风格模板 - 响应式设计
 * 针对不同设备尺寸的优化样式
 */

/* ==========================================================================
   移动设备优先的响应式断点
   ========================================================================== */

/* 超小屏幕 (手机, 小于 576px) */
@media (max-width: 575.98px) {
    /* 全局布局 */
    .container {
        padding: 0 1rem;
    }
    
    .main-content {
        min-height: calc(100vh - 150px); /* 移动端调整高度 */
        padding: 1rem 0;
    }
    
    .main-container {
        padding: 1rem;
    }
    
    .content-wrapper {
        display: block;
        width: 100%;
    }
    
    /* 导航栏 */
    .blog-nav {
        padding: 0.75rem 1rem;
    }
    
    .nav-menu {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        height: 100vh;
        background: #0a0a0a;
        border-right: 1px solid #333333;
        flex-direction: column;
        padding: 2rem 0;
        transition: left 0.3s ease;
        z-index: 1000;
        overflow-y: auto;
    }
    
    .nav-menu.active {
        left: 0;
    }
    
    .nav-item {
        width: 100%;
        margin: 0;
    }
    
    .nav-link {
        display: block;
        padding: 1rem 2rem;
        border-bottom: 1px solid #333333;
    }
    
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: transparent;
        border: 1px solid #333333;
        border-radius: 6px;
        color: #cccccc;
        cursor: pointer;
        transition: all 0.3s ease;
    }
    
    .mobile-menu-toggle:hover {
        border-color: #00ff41;
        color: #00ff41;
    }
    
    .mobile-menu-toggle span {
        display: block;
        width: 20px;
        height: 2px;
        background: currentColor;
        position: relative;
        transition: all 0.3s ease;
    }
    
    .mobile-menu-toggle span::before,
    .mobile-menu-toggle span::after {
        content: '';
        position: absolute;
        width: 100%;
        height: 2px;
        background: currentColor;
        transition: all 0.3s ease;
    }
    
    .mobile-menu-toggle span::before {
        top: -6px;
    }
    
    .mobile-menu-toggle span::after {
        bottom: -6px;
    }
    
    .mobile-menu-toggle.active span {
        background: transparent;
    }
    
    .mobile-menu-toggle.active span::before {
        top: 0;
        transform: rotate(45deg);
    }
    
    .mobile-menu-toggle.active span::after {
        bottom: 0;
        transform: rotate(-45deg);
    }
    
    /* 系统状态面板 */
    .system-status-panel {
        margin-bottom: 1.5rem;
    }
    
    .status-header {
        padding: 0.75rem 1rem;
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .status-indicators {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .status-content {
        padding: 1rem;
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .status-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .progress-bar {
        width: 100%;
    }
    
    /* 欢迎横幅 */
    .welcome-banner {
        padding: 2rem 1rem;
        margin-bottom: 2rem;
    }
    
    .banner-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }
    
    .banner-title {
        font-size: 1.8rem;
    }
    
    .title-prefix {
        font-size: 1rem;
    }
    
    .banner-subtitle {
        font-size: 1rem;
    }
    
    .banner-stats {
        justify-content: center;
        gap: 1.5rem;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    .terminal-window {
        margin-top: 1rem;
    }
    
    .terminal-body {
        padding: 0.75rem;
        font-size: 0.8rem;
    }
    
    /* 轮播图 */
    .slideshow-container {
        height: 250px;
    }
    
    .slide-overlay {
        padding: 1rem;
    }
    
    .slide-title {
        font-size: 1.2rem;
        margin-bottom: 0.5rem;
    }
    
    .slide-excerpt {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .slide-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .slideshow-controls {
        top: 0.5rem;
        right: 0.5rem;
    }
    
    .control-btn {
        width: 32px;
        height: 32px;
    }
    
    /* 文章列表 */
    .posts-container.grid-view {
        grid-template-columns: 1fr;
    }
    
    .posts-container.list-view .post-card {
        grid-template-columns: 1fr;
    }
    
    .post-card {
        margin-bottom: 1rem;
    }
    
    .card-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .card-meta {
        font-size: 0.8rem;
    }
    
    .post-title {
        font-size: 1.1rem;
        line-height: 1.4;
    }
    
    .post-excerpt {
        font-size: 0.9rem;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .post-tags {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .tag-item {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }
    
    .card-footer {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .post-stats {
        width: 100%;
        justify-content: space-between;
    }
    
    .post-actions {
        width: 100%;
        justify-content: center;
    }
    
    /* 技术栈 */
    .tech-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .tech-item {
        padding: 1rem;
    }
    
    .tech-icon {
        font-size: 2rem;
        margin-bottom: 0.75rem;
    }
    
    .tech-name {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
    }
    
    /* 侧边栏 */
    .sidebar {
        order: -1;
    }
    
    .widget {
        margin-bottom: 1.5rem;
    }
    
    .widget-title {
        font-size: 1rem;
        padding: 0.75rem 1rem;
    }
    
    .widget-content {
        padding: 1rem;
    }
    
    /* 分页 */
    .pagination-wrapper {
        margin-top: 2rem;
    }
    
    .pagination {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .pagination-controls {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }
    
    .pagination-controls a {
        min-width: 40px;
        height: 40px;
        font-size: 0.9rem;
    }
    
    /* 文章详情页 */
    .article-detail {
        padding: 1rem;
    }
    
    .article-header {
        padding: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .article-title {
        font-size: 1.5rem;
        line-height: 1.3;
    }
    
    .article-meta {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .article-toc {
        position: static;
        width: 100%;
        margin-bottom: 2rem;
        max-height: 200px;
    }
    
    .toc-content {
        max-height: 150px;
    }
    
    .article-content {
        margin-left: 0;
    }
    
    .content-body {
        font-size: 0.95rem;
        line-height: 1.6;
    }
    
    .content-body h1 {
        font-size: 1.5rem;
    }
    
    .content-body h2 {
        font-size: 1.3rem;
    }
    
    .content-body h3 {
        font-size: 1.1rem;
    }
    
    .content-body pre {
        font-size: 0.8rem;
        padding: 1rem;
        overflow-x: auto;
    }
    
    .content-body table {
        font-size: 0.8rem;
    }
    
    .article-actions {
        flex-direction: column;
        gap: 1rem;
    }
    
    .action-group {
        width: 100%;
        justify-content: center;
    }
    
    .article-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    /* 评论区 */
    .comments-section {
        margin-top: 2rem;
    }
    
    .comment-form {
        padding: 1rem;
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .comment-item {
        padding: 1rem;
    }
    
    .comment-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .comment-actions {
        margin-top: 1rem;
        justify-content: flex-start;
    }
    
    /* 页脚 */
    .blog-footer {
        padding: 2rem 1rem 1rem;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }
    
    .footer-section {
        margin-bottom: 1.5rem;
    }
    
    .footer-links {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .footer-bottom {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    /* 特殊效果调整 */
    .matrix-rain {
        display: none; /* 在小屏幕上隐藏矩阵雨效果以提升性能 */
    }

    .particle-container {
        display: none;
    }

    .mouse-follower {
        display: none;
    }
    
    /* 性能优化：简化动画 */
    .reduced-motion * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .reduced-motion .matrix-rain {
        display: none !important;
    }
    
    /* 懒加载图片在移动端的优化 */
    .content-body img[data-src] {
        background: linear-gradient(45deg, #1a1a1a 25%, transparent 25%), 
                    linear-gradient(-45deg, #1a1a1a 25%, transparent 25%), 
                    linear-gradient(45deg, transparent 75%, #1a1a1a 75%), 
                    linear-gradient(-45deg, transparent 75%, #1a1a1a 75%);
        background-size: 20px 20px;
        background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
        min-height: 200px;
    }
    
    /* 性能警告在移动端的样式 */
    .performance-warning {
        position: fixed !important;
        top: 1rem !important;
        left: 1rem !important;
        right: 1rem !important;
        transform: none !important;
        z-index: 9999;
        font-size: 0.8rem;
    }
}

/* 小屏幕 (手机横屏, 576px 到 767.98px) */
@media (min-width: 576px) and (max-width: 767.98px) {
    .container {
        padding: 0 1.5rem;
    }
    
    .main-container {
        padding: 1.5rem;
    }
    
    .banner-title {
        font-size: 2.2rem;
    }
    
    .slideshow-container {
        height: 300px;
    }
    
    .tech-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .posts-container.grid-view {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .article-stats {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 中等屏幕 (平板, 768px 到 991.98px) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .container {
        padding: 0 2rem;
    }
    
    .content-wrapper {
        display: block;
        width: 100%;
    }
    
    .banner-content {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }
    
    .banner-title {
        font-size: 2.3rem;
    }
    
    .slideshow-container {
        height: 350px;
    }
    
    .posts-container.grid-view {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .tech-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .article-toc {
        position: static;
        width: 100%;
        margin-bottom: 2rem;
    }
    
    .article-content {
        margin-left: 0;
    }
    
    .mobile-menu-toggle {
        display: none;
    }
    
    .nav-menu {
        position: static;
        width: auto;
        height: auto;
        background: transparent;
        border: none;
        flex-direction: row;
        padding: 0;
        overflow: visible;
    }
    
    .nav-item {
        width: auto;
        margin: 0 0.5rem;
    }
    
    .nav-link {
        display: inline-block;
        padding: 0.5rem 1rem;
        border: none;
    }
}

/* 大屏幕 (桌面, 992px 到 1199.98px) */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .container {
        max-width: 960px;
    }
    
    .content-wrapper {
        display: block;
        width: 100%;
    }
    
    .posts-container.grid-view {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .tech-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* 超大屏幕 (大桌面, 1200px 及以上) */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
    
    .content-wrapper {
        display: block;
        width: 100%;
    }
    
    .posts-container.grid-view {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .tech-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    
    .banner-title {
        font-size: 3rem;
    }
    
    .slideshow-container {
        height: 450px;
    }
}

/* 超宽屏幕 (1400px 及以上) */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
    
    .banner-title {
        font-size: 3.5rem;
    }
    
    .slideshow-container {
        height: 500px;
    }
}

/* ==========================================================================
   打印样式
   ========================================================================== */

@media print {
    /* 隐藏不必要的元素 */
    .blog-nav,
    .sidebar,
    .article-actions,
    .comments-section,
    .blog-footer,
    .back-to-top,
    .system-status-panel,
    .slideshow-controls,
    .slide-indicators,
    .view-controls,
    .mobile-menu-toggle {
        display: none !important;
    }
    
    /* 调整布局 */
    .main-container {
        padding: 0;
        margin: 0;
    }
    
    .content-wrapper {
        display: block;
        width: 100%;
    }
    
    .article-detail {
        padding: 0;
    }
    
    .article-content {
        margin-left: 0;
    }
    
    /* 调整颜色 */
    body {
        background: white !important;
        color: black !important;
    }
    
    .article-header,
    .article-content,
    .post-card {
        background: white !important;
        border: 1px solid #cccccc !important;
        color: black !important;
    }
    
    .article-title,
    .post-title {
        color: black !important;
    }
    
    /* 调整字体 */
    body {
        font-family: 'Times New Roman', serif !important;
        font-size: 12pt !important;
        line-height: 1.5 !important;
    }
    
    .article-title {
        font-size: 18pt !important;
        margin-bottom: 12pt !important;
    }
    
    .content-body h1 {
        font-size: 16pt !important;
    }
    
    .content-body h2 {
        font-size: 14pt !important;
    }
    
    .content-body h3 {
        font-size: 12pt !important;
    }
    
    /* 调整间距 */
    .content-body p {
        margin-bottom: 6pt !important;
    }
    
    .content-body pre {
        background: #f5f5f5 !important;
        border: 1px solid #cccccc !important;
        padding: 6pt !important;
        font-size: 10pt !important;
    }
    
    /* 分页控制 */
    .article-header {
        page-break-after: avoid;
    }
    
    .content-body h1,
    .content-body h2,
    .content-body h3 {
        page-break-after: avoid;
    }
    
    .content-body pre,
    .content-body blockquote {
        page-break-inside: avoid;
    }
}

/* ==========================================================================
   高对比度模式
   ========================================================================== */

@media (prefers-contrast: high) {
    :root {
        --primary-color: #00ff00;
        --background-color: #000000;
        --text-color: #ffffff;
        --border-color: #ffffff;
    }
    
    body {
        background: var(--background-color) !important;
        color: var(--text-color) !important;
    }
    
    .post-card,
    .widget,
    .article-header,
    .article-content {
        border-color: var(--border-color) !important;
    }
    
    .nav-link,
    .post-title a,
    .article-title {
        color: var(--text-color) !important;
    }
    
    .nav-link:hover,
    .post-title a:hover {
        color: var(--primary-color) !important;
    }
}

/* ==========================================================================
   减少动画模式
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .matrix-rain,
    .particle-container,
    .typing-animation,
    .scan-line {
        display: none !important;
    }
}

/* ==========================================================================
   暗色模式偏好
   ========================================================================== */

@media (prefers-color-scheme: light) {
    /* 如果用户偏好浅色模式，可以在这里添加浅色主题样式 */
    /* 但由于这是黑客主题，我们保持暗色风格 */
}

/* ==========================================================================
   触摸设备优化
   ========================================================================== */

@media (hover: none) and (pointer: coarse) {
    /* 增大触摸目标 */
    .nav-link,
    .action-btn,
    .control-btn,
    .view-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* 移除悬停效果 */
    .post-card:hover,
    .nav-link:hover,
    .action-btn:hover {
        transform: none;
        box-shadow: none;
    }
    
    /* 优化滚动 */
    .nav-menu,
    .toc-content,
    .widget-content {
        -webkit-overflow-scrolling: touch;
    }
}

/* ==========================================================================
   横屏模式优化
   ========================================================================== */

@media (orientation: landscape) and (max-height: 500px) {
    .welcome-banner {
        padding: 1rem;
    }
    
    .banner-title {
        font-size: 1.5rem;
    }
    
    .slideshow-container {
        height: 200px;
    }
    
    .system-status-panel {
        margin-bottom: 1rem;
    }
}

/* ==========================================================================
   可访问性增强
   ========================================================================== */

/* 焦点指示器 */
.nav-link:focus,
.action-btn:focus,
.control-btn:focus,
.view-btn:focus,
input:focus,
textarea:focus,
button:focus {
    outline: 2px solid #00ff41;
    outline-offset: 2px;
}

/* 跳转链接 */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #00ff41;
    color: #000000;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 10000;
    font-family: 'Fira Code', monospace;
}

.skip-link:focus {
    top: 6px;
}

/* 屏幕阅读器专用文本 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 高对比度边框 */
@media (prefers-contrast: high) {
    .post-card,
    .widget,
    .nav-link,
    .action-btn {
        border: 2px solid currentColor;
    }
}

/* ==========================================================================
   性能优化
   ========================================================================== */

/* 在低端设备上禁用复杂动画 */
@media (max-width: 768px) {
    .matrix-rain,
    .particle-container,
    .scan-line {
        display: none;
    }
    
    .post-card,
    .widget,
    .tech-item {
        transition: none;
    }
    
    .post-card:hover {
        transform: none;
    }
}

/* GPU 加速优化 */
.slideshow-container,
.slides-wrapper,
.nav-menu {
    transform: translateZ(0);
    will-change: transform;
}

/* 图片懒加载占位符 */
.lazy-loading {
    background: linear-gradient(90deg, #333333 25%, #444444 50%, #333333 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ==========================================================================
   调试辅助 (开发环境)
   ========================================================================== */

/* 在开发环境中显示断点信息 */
.debug-breakpoint {
    position: fixed;
    top: 0;
    right: 0;
    background: #ff0000;
    color: #ffffff;
    padding: 0.25rem 0.5rem;
    font-family: monospace;
    font-size: 0.8rem;
    z-index: 10000;
    display: none;
}

@media (max-width: 575.98px) {
    .debug-breakpoint::after {
        content: 'XS';
    }
}

@media (min-width: 576px) and (max-width: 767.98px) {
    .debug-breakpoint::after {
        content: 'SM';
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .debug-breakpoint::after {
        content: 'MD';
    }
}

@media (min-width: 992px) and (max-width: 1199.98px) {
    .debug-breakpoint::after {
        content: 'LG';
    }
}

@media (min-width: 1200px) {
    .debug-breakpoint::after {
        content: 'XL';
    }
}

/* 开发环境启用调试信息 */
body.debug .debug-breakpoint {
    display: block;
}