/**
 * CloudBlue 云蓝主题样式
 * ai-bot.cn 风格复刻：扁平、横向卡片、明暗双模式
 * 所有颜色走 CSS 变量，切换 <html> class 即换肤
 */

/* ============ 主题变量 ============ */
:root {
    --theme-color: #5961f9;
    --theme-color-soft: #eef0ff;
    --radius: 10px;
    --gap: 14px;
    --link-cols: 5;
    --max-width: 1400px;
}

/* 浅色模式 */
html.io-grey-mode {
    --bg: #f9f9f9;
    --bg-soft: #ffffff;
    --card-bg: #ffffff;
    --card-border: #ececf0;
    --text: #2c2e2f;
    --text-muted: #8b8d90;
    --header-bg: rgba(255, 255, 255, .88);
    --nav-bg: rgba(255, 255, 255, .9);
    --nav-border: #e8e8ee;
    --input-bg: #ffffff;
    --glow: radial-gradient(circle at 20% 0%, rgba(89, 97, 249, .18), transparent 45%),
            radial-gradient(circle at 82% 12%, rgba(120, 200, 255, .16), transparent 42%),
            radial-gradient(circle at 55% 40%, rgba(180, 140, 255, .10), transparent 50%);
    color-scheme: light;
}

/* 深色模式 */
html.io-black-mode {
    --bg: #2c2e2f;
    --bg-soft: #222426;
    --card-bg: #303335;
    --card-border: #3c3e40;
    --text: #f2f3f5;
    --text-muted: #9a9c9f;
    --theme-color-soft: #33365f;
    --header-bg: rgba(36, 38, 40, .9);
    --nav-bg: rgba(48, 51, 53, .92);
    --nav-border: #3c3e40;
    --input-bg: #282a2d;
    --glow: radial-gradient(circle at 20% 0%, rgba(89, 97, 249, .22), transparent 45%),
            radial-gradient(circle at 82% 12%, rgba(60, 120, 200, .14), transparent 42%),
            radial-gradient(circle at 55% 40%, rgba(120, 80, 200, .10), transparent 50%);
    color-scheme: dark;
}

/* ============ 基础 ============ */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    color: var(--text);
    background-color: var(--bg);
    background-repeat: no-repeat;
    background-size: cover;
    background-attachment: fixed;
    background-position: center;
    transition: background-color .2s, color .2s;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
svg.icon { width: 1em; height: 1em; }

/* 顶部光斑背景（缩小：550px -> 240px，更收敛） */
.header-glow {
    position: fixed;
    inset: 0 0 auto 0;
    height: 240px;
    background-image: var(--glow);
    pointer-events: none;
    z-index: 0;
    opacity: .75;
}

/* ============ 顶部栏 ============ */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px clamp(16px, 4vw, 40px);
    background: var(--header-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--nav-border);
}
.site-logo {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
}
.site-logo img { width: 28px; height: 28px; border-radius: 7px; object-fit: contain; }
.header-actions { display: flex; align-items: center; gap: 14px; }
.site-nav { display: flex; align-items: center; gap: 18px; }
.site-nav a { color: var(--text-muted); font-size: 13px; transition: color .15s; }
.site-nav a:hover { color: var(--theme-color); }
.mode-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--nav-border);
    border-radius: 8px;
    background: var(--nav-bg);
    color: var(--text);
    cursor: pointer;
    transition: color .15s, border-color .15s, transform .15s;
}
.mode-toggle:hover { color: var(--theme-color); border-color: var(--theme-color); transform: rotate(-12deg); }
/* 明暗图标按模式显示 */
html.io-grey-mode .mode-toggle .icon-sun { display: none; }
html.io-black-mode .mode-toggle .icon-moon { display: none; }

/* ============ 主体 ============ */
.site-main {
    position: relative;
    z-index: 1;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 30px clamp(16px, 4vw, 40px) 60px;
}

/* 时钟 / 一言 */
.clock { text-align: center; margin-bottom: 18px; }
.clock-time {
    display: block;
    font-size: 40px;
    font-weight: 600;
    letter-spacing: 2px;
    line-height: 1.2;
}
.clock-date { font-size: 13px; color: var(--text-muted); }
.yan { text-align: center; color: var(--text-muted); font-size: 13px; margin: 10px 0 0; }

/* ============ 搜索区 ============ */
.search { width: 100%; max-width: 720px; margin: 0 auto 22px; }
.search-form {
    display: flex;
    align-items: center;
    height: 50px;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .06);
    overflow: hidden;
    transition: border-color .15s, box-shadow .15s;
}
.search-form:focus-within { border-color: var(--theme-color); box-shadow: 0 6px 24px rgba(89, 97, 249, .18); }
.search-icon { display: flex; align-items: center; padding-left: 16px; color: var(--text-muted); }
.search-input {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0 14px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 15px;
}
.search-input::placeholder { color: var(--text-muted); }
.search-btn {
    height: 100%;
    padding: 0 26px;
    border: 0;
    background: var(--theme-color);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: filter .15s;
}
.search-btn:hover { filter: brightness(1.08); }

.search-engines { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 14px; }
.engine {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border: 1px solid transparent;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all .15s;
}
.engine:hover { background: var(--card-bg); }
.engine input { display: none; }
.engine svg, .engine img { width: 14px; height: 14px; }
.engine-name { color: var(--engine-color, var(--text-muted)); }
.engine input:checked ~ .engine-name { font-weight: 600; }
.engine:has(input:checked) { border-color: var(--theme-color); background: var(--theme-color-soft); }
.engine input:checked ~ .engine-name { color: var(--theme-color); }

/* 公告 */
.notice {
    max-width: 900px;
    margin: 0 auto 20px;
    padding: 10px 16px;
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    background: var(--card-bg);
    font-size: 13px;
    color: var(--text-muted);
}

/* ============ 一级分类锚点导航 ============ */
.category-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 auto 24px;
    padding: 10px 12px;
    background: var(--nav-bg);
    border: 1px solid var(--nav-border);
    border-radius: 12px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.category-nav:empty { display: none; }
.cat-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 13px;
    border-radius: 18px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.cat-chip:hover { border-color: var(--theme-color); color: var(--theme-color); }
.cat-chip.active { background: var(--theme-color); border-color: var(--theme-color); color: #fff; }
.cat-chip .chip-icon { display: inline-flex; width: 15px; height: 15px; }
.cat-chip .chip-icon svg, .cat-chip .chip-icon img { width: 15px; height: 15px; }

/* ============ 分组区块 ============ */
.links { display: flex; flex-direction: column; gap: 26px; }
.link-group { scroll-margin-top: 80px; }

.group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    font-size: 17px;
    font-weight: 700;
}
.group-icon { display: inline-flex; width: 20px; height: 20px; color: var(--theme-color); }
.group-icon svg, .group-icon img { width: 20px; height: 20px; }
.group-name { flex: 1; }

/* 二级分类 tab（JS 注入，横向可滑） */
.subtabs {
    display: flex;
    gap: 6px;
    margin: -4px 0 14px;
    padding-bottom: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}
.subtabs::-webkit-scrollbar { display: none; }
.subtab {
    flex: 0 0 auto;
    padding: 5px 12px;
    border: 1px solid var(--card-border);
    border-radius: 16px;
    background: var(--card-bg);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all .15s;
}
.subtab:hover { border-color: var(--theme-color); color: var(--theme-color); }
.subtab.active { background: var(--theme-color); border-color: var(--theme-color); color: #fff; }

/* ============ 卡片网格 ============ */
.link-group .card-grid,
.link-group.cards-ready {
    display: grid;
    grid-template-columns: repeat(var(--link-cols), minmax(0, 1fr));
    gap: var(--gap);
}
/* JS 未介入前，_link-card 直接作为 grid item；用 :where 兼容 */
.link-group > .link-card { min-width: 0; }

.link-card {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 0;
    min-height: 86px;
    padding: 12px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    transition: border-color .15s, transform .15s, box-shadow .15s;
}
.link-card:hover {
    border-color: var(--theme-color);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(89, 97, 249, .12);
    text-decoration: none;
}
.card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 52px;
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: var(--theme-color-soft);
    overflow: hidden;
}
.card-icon svg, .card-icon img { width: 34px; height: 34px; object-fit: contain; }
.card-icon .letter {
    font-size: 16px;
    font-weight: 700;
    color: var(--theme-color);
    text-transform: uppercase;
}
.card-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.card-name {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
/* VPN 徽章：替代原来的黄色感叹号 */
/* VPN 标识：自定义 VPN 文字标（随主题 assets/vpn.svg） */
.vpn-badge {
    display: inline-block;
    flex: 0 0 auto;
    width: 44px;
    height: auto;
    margin-left: 6px;
    vertical-align: middle;
    opacity: .92;
}
/* 图标缺失时的内联盾牌回退 */
.vpn-badge-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 5px;
    color: #fff;
    background: #5961f9;
}
html.io-black-mode .vpn-badge-fallback { background: #7b83ff; }
.link-card:hover .card-name { color: var(--theme-color); }
.card-desc {
    margin-top: 2px;
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* ============ 底部 ============ */
.site-footer {
    position: relative;
    z-index: 1;
    padding: 24px 16px 30px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}
.site-footer a { margin: 0 5px; }

/* ============ 响应式 ============ */
@media (max-width: 1100px) { :root { --link-cols: 4; } }
@media (max-width: 860px)  { :root { --link-cols: 3; } }
@media (max-width: 640px) {
    :root { --link-cols: 2; --gap: 10px; }
    .site-header { padding: 10px 14px; }
    .site-nav { gap: 12px; }
    .site-nav a { font-size: 12px; }
    .site-main { padding: 20px 14px 40px; }
    .clock-time { font-size: 32px; }
    .search-form { height: 46px; }
    .search-btn { padding: 0 18px; }
    .search-icon { padding-left: 12px; }
    .group-title { font-size: 15px; }
    .link-card { min-height: 74px; padding: 10px; gap: 10px; }
    .card-icon { flex-basis: 44px; width: 44px; height: 44px; }
    .card-icon svg, .card-icon img { width: 28px; height: 28px; }
    .card-desc { display: none; }
    .category-nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .category-nav::-webkit-scrollbar { display: none; }
}
@media (max-width: 380px) { :root { --link-cols: 1; } }
