/* ==========================================================================
   榜单独立页样式 - 3 级导航 + 响应式多列 + 全面显示导航
   ========================================================================== */

:root {
    --rk-primary: #1677ff;
    --rk-primary-dark: #0958d9;
    --rk-primary-light: #e6f0ff;
    --rk-bg: #f5f7fa;
    --rk-card: #ffffff;
    --rk-text: #1a1a1a;
    --rk-text-secondary: #666;
    --rk-text-tertiary: #999;
    --rk-border: #e8e8e8;
    --rk-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --rk-shadow-hover: 0 4px 16px rgba(22, 119, 255, 0.12);
    --rk-radius: 12px;
    --rk-safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
    :root {
        --rk-primary: #4096ff;
        --rk-primary-dark: #1677ff;
        --rk-primary-light: #111d2c;
        --rk-bg: #0f1115;
        --rk-card: #1a1d23;
        --rk-text: #e8e8e8;
        --rk-text-secondary: #a0a0a0;
        --rk-text-tertiary: #6a6a6a;
        --rk-border: #2a2d33;
        --rk-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
        --rk-shadow-hover: 0 4px 16px rgba(64, 150, 255, 0.2);
    }
}

.rk-app, .rk-app * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; min-width: 320px; background: var(--rk-bg); }
.rk-app {
    margin: 0 auto !important; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 15px; line-height: 1.5; color: var(--rk-text);
    background: var(--rk-bg); min-height: 100vh;
    width: 100% !important; max-width: 1200px !important;
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.04);
    overflow-x: hidden; position: relative;
}
.rk-app button, .rk-app input { font-family: inherit; font-size: inherit; color: inherit; }
.rk-app a { color: inherit; text-decoration: none; }

/* Header - 整体 sticky */
.rk-header {
    position: sticky; top: 0; z-index: 100;
    background: var(--rk-card); border-bottom: 1px solid var(--rk-border);
    box-shadow: var(--rk-shadow);
}
.rk-header-top { display: flex; align-items: center; gap: 8px; height: 40px; padding: 8px 12px 0; }
.rk-back {
    flex: 0 0 auto; width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--rk-text); border-radius: 50%; margin-left: -4px;
    transition: background 0.15s;
}
.rk-back:active { background: var(--rk-primary-light); }
.rk-title {
    flex: 1 1 auto; margin: 0; font-size: 17px; font-weight: 600;
    color: var(--rk-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rk-count {
    flex: 0 0 auto; font-size: 12px; color: var(--rk-text-tertiary);
    background: var(--rk-bg); padding: 4px 8px; border-radius: 10px; white-space: nowrap;
}

/* Search */
.rk-search-wrap { position: relative; margin: 6px 12px 8px; }
.rk-search-icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--rk-text-tertiary); pointer-events: none;
}
.rk-search {
    width: 100%; height: 38px; padding: 0 36px 0 38px;
    border: 1px solid var(--rk-border); border-radius: 19px;
    background: var(--rk-bg); color: var(--rk-text); outline: none;
    transition: border-color 0.15s, background 0.15s;
    -webkit-appearance: none; appearance: none;
}
.rk-search:focus { border-color: var(--rk-primary); background: var(--rk-card); }
.rk-search::-webkit-search-cancel-button { -webkit-appearance: none; }
.rk-search-clear {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    width: 22px; height: 22px; border: none; border-radius: 50%;
    background: var(--rk-text-tertiary); color: #fff; font-size: 14px; line-height: 1;
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.rk-search-clear:active { transform: translateY(-50%) scale(0.9); }

/* 一级类目 - flex-wrap 全面显示 */
.rk-cats { padding: 0 12px 8px; border-bottom: 1px solid var(--rk-border); }
.rk-cats-inner {
    display: flex; flex-wrap: wrap; gap: 6px;
}
.rk-cat {
    display: inline-flex; align-items: center; gap: 5px;
    height: 30px; padding: 0 12px;
    border: 1px solid var(--rk-border); border-radius: 15px;
    background: var(--rk-card); color: var(--rk-text-secondary);
    font-size: 13px; white-space: nowrap; cursor: pointer;
    transition: all 0.18s; user-select: none;
}
.rk-cat:active { transform: scale(0.96); }
.rk-cat--active { background: var(--rk-primary); border-color: var(--rk-primary); color: #fff; font-weight: 500; }
.rk-cat--loading { color: var(--rk-text-tertiary); cursor: default; }
.rk-cat-badge { font-size: 11px; padding: 1px 5px; border-radius: 8px; background: rgba(0,0,0,0.06); }
.rk-cat--active .rk-cat-badge { background: rgba(255,255,255,0.25); }

/* 二级子分类 - flex-wrap 全面显示 */
.rk-subcats { padding: 6px 12px; border-bottom: 1px solid var(--rk-border); background: var(--rk-bg); }
.rk-subcats-label, .rk-types-label {
    font-size: 11px; color: var(--rk-text-tertiary); margin-bottom: 4px;
    text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
}
.rk-subcats-inner { display: flex; flex-wrap: wrap; gap: 6px; }
.rk-subcat {
    display: inline-flex; align-items: center; gap: 4px;
    height: 28px; padding: 0 10px;
    border: 1px solid var(--rk-border); border-radius: 14px;
    background: var(--rk-card); color: var(--rk-text-secondary);
    font-size: 12px; cursor: pointer; transition: all 0.15s; user-select: none;
}
.rk-subcat:active { transform: scale(0.95); }
.rk-subcat--active { background: var(--rk-primary); border-color: var(--rk-primary); color: #fff; font-weight: 500; }
.rk-subcat-count { font-size: 10px; opacity: 0.8; }

/* 三级类型 - flex-wrap 全面显示 */
.rk-types { padding: 6px 12px 8px; border-bottom: 1px solid var(--rk-border); background: var(--rk-bg); }
.rk-types-inner { display: flex; flex-wrap: wrap; gap: 6px; }
.rk-type {
    height: 26px; padding: 0 10px;
    border: 1px solid var(--rk-border); border-radius: 13px;
    background: var(--rk-card); color: var(--rk-text-secondary);
    font-size: 12px; cursor: pointer; transition: all 0.15s; user-select: none;
    display: inline-flex; align-items: center;
}
.rk-type:active { transform: scale(0.95); }
/* 修复：选中状态用蓝色背景+白色文字，确保对比度清晰 */
.rk-type--active { background: var(--rk-primary); border-color: var(--rk-primary); color: #fff; font-weight: 500; }

/* 面包屑 */
.rk-breadcrumb {
    padding: 8px 12px 4px; font-size: 12px; color: var(--rk-text-tertiary);
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
}
.rk-breadcrumb span { color: var(--rk-text-secondary); }
.rk-breadcrumb .rk-crumb-sep { color: var(--rk-text-tertiary); opacity: 0.5; }

/* 列表 - 响应式多列 */
.rk-main { padding: 0 12px calc(20px + var(--rk-safe-bottom)); }
.rk-list { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 480px) { .rk-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 768px) { .rk-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .rk-list { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.rk-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; max-width: 100%;
    background: var(--rk-card); border: 1px solid var(--rk-border);
    border-radius: var(--rk-radius);
    transition: box-shadow 0.15s, transform 0.06s; cursor: pointer;
}
.rk-item:active { transform: scale(0.985); box-shadow: var(--rk-shadow-hover); }
.rk-item-index {
    flex: 0 0 auto; width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px; background: var(--rk-primary-light); color: var(--rk-primary);
    font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.rk-item-title {
    flex: 1 1 auto; min-width: 0; font-size: 14px; color: var(--rk-text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rk-item-title em {
    font-style: normal; color: var(--rk-primary);
    background: rgba(22,119,255,0.12); padding: 0 2px; border-radius: 3px;
}
.rk-item-type {
    flex: 0 0 auto; font-size: 10px; color: var(--rk-text-tertiary);
    background: var(--rk-bg); padding: 2px 5px; border-radius: 4px; white-space: nowrap;
}
.rk-item-go {
    flex: 0 0 auto; width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%; background: var(--rk-primary-light); color: var(--rk-primary);
    transition: background 0.15s;
}
.rk-item:active .rk-item-go { background: var(--rk-primary); color: #fff; }
.rk-item-go svg { width: 16px; height: 16px; }

/* Status */
.rk-status { padding: 20px 12px 40px; text-align: center; color: var(--rk-text-tertiary); font-size: 13px; }
.rk-loading { display: inline-flex; align-items: center; gap: 8px; }
.rk-spinner {
    width: 16px; height: 16px; border: 2px solid var(--rk-border);
    border-top-color: var(--rk-primary); border-radius: 50%;
    animation: rk-spin 0.7s linear infinite; display: inline-block;
}
@keyframes rk-spin { to { transform: rotate(360deg); } }
.rk-empty { padding: 60px 20px; text-align: center; color: var(--rk-text-tertiary); }
.rk-empty-icon { font-size: 40px; margin-bottom: 8px; opacity: 0.4; }
.rk-empty-text { font-size: 14px; }
.rk-loadmore-hint { color: var(--rk-text-tertiary); font-size: 12px; padding: 8px 0; }

/* 回到顶部 */
.rk-totop {
    position: fixed; right: 16px; bottom: calc(20px + var(--rk-safe-bottom));
    z-index: 80; width: 42px; height: 42px; border: none; border-radius: 50%;
    background: var(--rk-card); color: var(--rk-primary);
    box-shadow: var(--rk-shadow); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: opacity 0.2s, transform 0.15s;
}
.rk-totop:active { transform: scale(0.9); }
@media (min-width: 1200px) { .rk-totop { right: calc(50% - 600px + 16px); } }

@media (hover: hover) {
    .rk-item:hover { box-shadow: var(--rk-shadow-hover); }
    .rk-cat:hover:not(.rk-cat--loading):not(.rk-cat--active) { border-color: var(--rk-primary); color: var(--rk-primary); }
    .rk-subcat:hover:not(.rk-subcat--active) { border-color: var(--rk-primary); color: var(--rk-primary); }
    .rk-type:hover:not(.rk-type--active) { border-color: var(--rk-primary); color: var(--rk-primary); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
