/* tool-related.css
 *
 * R1 工具页底部"相关工具"组件样式。
 *
 * 设计原则：
 *   - PC ≥ 768px：CSS Grid 自适应列数（auto-fit, minmax(240px, 1fr)），密集时 3-4 列
 *   - 移动 < 768px：横向滚动 + scroll-snap，节省纵向高度（手机滑屏更轻松）
 *   - 卡片与 modern-ui 主色调一致（蓝紫渐变 + 暖色 tag 提示）
 *   - 暗色模式整体反色
 */

.related-tools {
    margin: 40px 0 24px;
    padding: 24px 22px;
    background: linear-gradient(135deg, #fafbff 0%, #f4f7ff 100%);
    border: 1px solid #e3eaff;
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.04);
}

.related-tools-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.related-tools-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.3;
}

.related-tools-emoji {
    font-size: 22px;
}

.related-tools-more {
    font-size: 13px;
    color: #4f46e5;
    text-decoration: none;
    font-weight: 500;
    flex-shrink: 0;
}

.related-tools-more:hover {
    color: #3730a3;
    text-decoration: underline;
}

/* ---------------- 卡片网格（PC） ---------------- */
.related-tools-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.related-tool-card {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 14px 14px 12px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    text-decoration: none !important;
    color: #1e293b;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    min-height: 76px;
}

.related-tool-card:hover {
    transform: translateY(-2px);
    border-color: #c7d2fe;
    box-shadow: 0 8px 22px rgba(79, 70, 229, 0.12);
    text-decoration: none !important;
    color: #1e293b;
}

.related-tool-card:focus {
    outline: 2px solid #4f46e5;
    outline-offset: 2px;
}

.related-tool-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    border-radius: 10px;
}

.related-tool-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.related-tool-title {
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.related-tool-desc {
    font-size: 12px;
    color: #64748b;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.related-tool-tag {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 11px;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 999px;
    color: #b45309;
    background: #fef3c7;
    font-weight: 600;
    white-space: nowrap;
}

.related-tool-card[data-reason="seo"] .related-tool-tag {
    color: #4338ca;
    background: #e0e7ff;
}

.related-tool-card[data-reason="same-category"] .related-tool-tag {
    color: #64748b;
    background: #f1f5f9;
}

/* ---------------- 移动端：横向滚动 ---------------- */
@media (max-width: 767px) {
    .related-tools {
        margin: 28px -10px 18px;     /* 让左右 negative margin 顶到屏幕边 */
        padding: 18px 12px 16px;
        border-radius: 12px;
    }

    .related-tools-head {
        padding: 0 4px;
        margin-bottom: 12px;
    }

    .related-tools-title {
        font-size: 16px;
    }

    .related-tools-list {
        display: flex;
        grid-template-columns: none;
        gap: 10px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding: 4px 4px 12px;
        /* 隐藏滚动条但保留可滚动性 */
        scrollbar-width: thin;
    }

    .related-tools-list::-webkit-scrollbar {
        height: 4px;
    }

    .related-tools-list::-webkit-scrollbar-thumb {
        background: rgba(99, 102, 241, 0.25);
        border-radius: 2px;
    }

    .related-tool-card {
        flex: 0 0 78%;
        max-width: 280px;
        scroll-snap-align: start;
        min-height: 72px;
    }

    .related-tool-icon {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }
}

/* ---------------- 暗色模式 ---------------- */
body.dark-mode .related-tools,
html.dark-mode .related-tools {
    background: linear-gradient(135deg, #1e293b 0%, #1e1b4b 100%);
    border-color: #312e81;
}

body.dark-mode .related-tools-title,
html.dark-mode .related-tools-title {
    color: #e2e8f0;
}

body.dark-mode .related-tools-more,
html.dark-mode .related-tools-more {
    color: #a5b4fc;
}

body.dark-mode .related-tool-card,
html.dark-mode .related-tool-card {
    background: #0f172a;
    border-color: #1e293b;
    color: #e2e8f0;
}

body.dark-mode .related-tool-card:hover,
html.dark-mode .related-tool-card:hover {
    border-color: #4338ca;
    box-shadow: 0 8px 22px rgba(99, 102, 241, 0.25);
    color: #f8fafc;
}

body.dark-mode .related-tool-icon,
html.dark-mode .related-tool-icon {
    background: linear-gradient(135deg, #312e81 0%, #1e1b4b 100%);
}

body.dark-mode .related-tool-title,
html.dark-mode .related-tool-title {
    color: #f1f5f9;
}

body.dark-mode .related-tool-desc,
html.dark-mode .related-tool-desc {
    color: #94a3b8;
}

body.dark-mode .related-tool-tag,
html.dark-mode .related-tool-tag {
    color: #fcd34d;
    background: rgba(252, 211, 77, 0.12);
}

body.dark-mode .related-tool-card[data-reason="seo"] .related-tool-tag,
html.dark-mode .related-tool-card[data-reason="seo"] .related-tool-tag {
    color: #a5b4fc;
    background: rgba(165, 180, 252, 0.12);
}

body.dark-mode .related-tool-card[data-reason="same-category"] .related-tool-tag,
html.dark-mode .related-tool-card[data-reason="same-category"] .related-tool-tag {
    color: #94a3b8;
    background: rgba(148, 163, 184, 0.12);
}
