/* ===== NAVBAR 遮盖问题紧急修复方案 v3.0 ===== */
/* 此文件专门解决 "Professional Tool Collection" 标题被导航栏遮盖的问题 */

/* 1. 强制覆盖现有样式，确保修复生效 */
.tools-section {
    padding-top: 160px !important;
    margin-top: 0 !important;
    position: relative !important;
}

/* 2. 为不同设备提供精确的导航栏间距 */

/* 桌面端 (1200px+) */
@media (min-width: 1200px) {
    .tools-section {
        padding-top: 170px !important;
    }
}

/* 笔记本/小桌面 (992px - 1199px) */
@media (max-width: 1199px) and (min-width: 992px) {
    .tools-section {
        padding-top: 165px !important;
    }
}

/* 平板横屏 (768px - 991px) */
@media (max-width: 991px) and (min-width: 768px) {
    .tools-section {
        padding-top: 160px !important;
    }
}

/* 平板竖屏/大手机 (481px - 767px) */
@media (max-width: 767px) and (min-width: 481px) {
    .tools-section {
        padding-top: 150px !important;
    }
}

/* 手机 (320px - 480px) */
@media (max-width: 480px) {
    .tools-section {
        padding-top: 140px !important;
    }
}

/* 超小屏 (320px以下) */
@media (max-width: 319px) {
    .tools-section {
        padding-top: 135px !important;
    }
}

/* 3. 标题容器特别保护 */
.tools-section .container {
    position: relative !important;
    z-index: 10 !important;
}

.tools-section h2#tools-title,
.tools-section h2[data-i18n="toolsCollection"] {
    position: relative !important;
    z-index: 11 !important;
    scroll-margin-top: 180px !important;
    margin-top: 0 !important;
    padding-top: 20px !important;
}

/* 4. 确保在所有主题下都清晰可见 */
[data-theme="dark"] .tools-section h2 {
    text-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.8),
        0 0 10px rgba(255, 71, 66, 0.3) !important;
}

/* 5. 导航栏高度检测和动态调整 */
.tools-section::before {
    content: "" !important;
    display: block !important;
    height: 80px !important;
    margin-top: -80px !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* 6. 浏览器特定修复 */

/* Safari 修复 */
@supports (-webkit-appearance: none) {
    .tools-section {
        padding-top: calc(160px + 10px) !important;
    }
}

/* Firefox 修复 */
@-moz-document url-prefix() {
    .tools-section {
        padding-top: calc(160px + 5px) !important;
    }
}

/* Chrome/Edge 修复 */
@supports (display: flex) {
    .tools-section {
        padding-top: 160px !important;
    }
}

/* 7. 高对比度模式支持 */
@media (prefers-contrast: high) {
    .tools-section h2 {
        background: #ffffff !important;
        color: #000000 !important;
        -webkit-text-fill-color: #000000 !important;
        padding: 0.5rem 1rem !important;
        border-radius: 8px !important;
        border: 2px solid #000000 !important;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3) !important;
    }
    
    [data-theme="dark"] .tools-section h2 {
        background: #000000 !important;
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff !important;
        border-color: #ffffff !important;
    }
}

/* 8. 减少动效模式支持 */
@media (prefers-reduced-motion: reduce) {
    .tools-section,
    .tools-section h2,
    .tools-section * {
        transition: none !important;
        animation: none !important;
    }
}

/* 9. 超宽屏幕支持 (1920px+) */
@media (min-width: 1920px) {
    .tools-section {
        padding-top: 180px !important;
    }
}

/* 10. 打印样式修复 */
@media print {
    .tools-section {
        padding-top: 0 !important;
        margin-top: 2rem !important;
    }
    
    .navbar {
        display: none !important;
    }
}

/* 11. 紧急回退方案 - 如果所有CSS变量失效 */
html:not([data-css-vars-supported]) .tools-section {
    padding-top: 160px !important;
}

/* 12. 调试工具（生产环境请删除这一段） */
/*
.tools-section.debug-mode::after {
    content: 'Navbar clearance: ' attr(data-clearance) 'px';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 71, 66, 0.9);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0 0 8px 8px;
    font-size: 12px;
    font-weight: bold;
    z-index: 9999;
    pointer-events: none;
}
*/

/* 13. 最后的保险措施 - 最小安全间距 */
.tools-section {
    min-height: calc(100vh - 160px) !important;
}

.tools-section .container > *:first-child {
    margin-top: 0 !important;
}

/* 14. 确保标题在任何情况下都不会被遮盖 */
@media (max-height: 600px) {
    /* 小高度屏幕的特殊处理 */
    .tools-section {
        padding-top: calc(25vh) !important;
        min-padding-top: 120px !important;
    }
}

/* 15. 处理动态内容可能改变导航栏高度的情况 */
.navbar:has(.user-dropdown.open) + * .tools-section,
.navbar:has(.lang-dropdown:hover) + * .tools-section,
.navbar:has(.nav-menu.active) + * .tools-section {
    padding-top: calc(160px + 20px) !important;
}

/* 16. 最终确保 - 如果页面有滚动，标题始终可见 */
html {
    scroll-padding-top: 160px !important;
}

body {
    scroll-padding-top: 160px !important;
}

/* 完成标记 */
.tools-section[data-navbar-fix="applied"] {
    /* 标记此修复已应用，可用于JS检测 */
    position: relative;
}