/* ============================================================
   kikkua · 儿童导航
   私有类统一 kd- 前缀，只作用于本页。
   断点：手机（默认）/ 大手机·小平板 560 / 平板横屏 900 / 桌面 1200 / 大屏 1440
   ============================================================ */

.kd-page {
    --kd-max: 1180px;
    --kd-pad: 14px;
    --kd-tone: var(--accent);
    --kd-tone-soft: var(--accent-glow);
    display: flex;
    flex-direction: column;
    /* 复用 .page 的入场动画会把 transform 留在元素上，使 fixed 子元素（toast / 回到顶部）
       以本页为定位基准。这里换成纯透明度淡入，不建立 fixed 包含块。 */
    animation: kdPageFade 0.4s var(--ease-out) both;
    background:
        radial-gradient(ellipse 70% 46% at 8% -6%, rgba(13, 148, 136, 0.07) 0%, transparent 68%),
        radial-gradient(ellipse 62% 42% at 96% 4%, rgba(245, 158, 11, 0.07) 0%, transparent 64%),
        radial-gradient(ellipse 80% 50% at 50% 104%, rgba(124, 58, 237, 0.045) 0%, transparent 70%),
        var(--bg-primary);
    background-attachment: fixed;
}

/* ── 顶栏 ── */
@keyframes kdPageFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.kd-header .kd-header-inner {
    max-width: var(--kd-max);
    padding: 0 var(--kd-pad);
    gap: 8px;
}

.kd-hbtn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 34px;
    padding: 0 11px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast),
        color var(--transition-fast), transform var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.kd-hbtn i { font-style: normal; }

.kd-hbtn svg { flex: 0 0 auto; }

.kd-hbtn:hover {
    border-color: var(--accent-light);
    color: var(--accent-dark);
    background: var(--accent-glow);
}

.kd-hbtn:active { transform: scale(0.95); }

.kd-hbtn.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 4px 14px rgba(13, 148, 136, 0.24);
}

.kd-hbtn.is-active svg { fill: currentColor; }

.kd-hbtn-count {
    display: inline-grid;
    place-items: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--amber);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.kd-hbtn-count[hidden] { display: none; }

/* ── 主容器 ── */
.kd-main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: var(--kd-max);
    margin: 0 auto;
    padding: 0 var(--kd-pad) calc(26px + env(safe-area-inset-bottom));
}

.kd-body {
    flex: 1 0 auto;
    margin-bottom: 26px;
    animation: kdFade 0.35s var(--ease-out) both;
}

@keyframes kdFade {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* ── Hero ── */
.kd-hero {
    padding: 24px 0 2px;
    text-align: center;
}

.kd-hero-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(22px, 4.8vw, 32px);
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.01em;
    line-height: 1.25;
}

.kd-hero-sub {
    margin: 8px 0 0;
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.6;
}

/* ── 搜索 ── */
.kd-search {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 520px;
    height: 48px;
    margin: 16px auto 0;
    padding: 0 8px 0 14px;
    background: var(--bg-primary);
    border: 1.5px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast),
        background var(--transition-fast);
}

.kd-search:focus-within {
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.kd-search-icon {
    display: flex;
    flex: 0 0 auto;
    color: var(--text-muted);
    transition: color var(--transition-fast);
}

.kd-search:focus-within .kd-search-icon { color: var(--accent); }

.kd-search-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    font-family: inherit;
    font-size: 15px;
    color: var(--text-primary);
}

.kd-search-input::placeholder { color: var(--text-muted); }

.kd-search-input::-webkit-search-cancel-button,
.kd-search-input::-webkit-search-decoration { display: none; }

.kd-search-clear {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.kd-search-clear:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.kd-search-clear:active { transform: scale(0.92); }

.kd-search-clear[hidden] { display: none; }

/* ── 分类胶囊 ── */
.kd-chips {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding: 13px 30px 4px 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent 100%);
    mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent 100%);
}

.kd-chips::-webkit-scrollbar { display: none; }

.kd-chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 36px;
    padding: 0 13px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    scroll-snap-align: start;
    transition: background var(--transition-fast), border-color var(--transition-fast),
        color var(--transition-fast), transform var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.kd-chip:hover {
    border-color: var(--accent-light);
    color: var(--accent-dark);
}

.kd-chip:active { transform: scale(0.95); }

.kd-chip.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 4px 14px rgba(13, 148, 136, 0.22);
}

/* ── 分组 ── */
.kd-sec { margin-top: 22px; }

.kd-sec-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding: 0 2px;
}

.kd-sec-icon {
    font-size: 17px;
    line-height: 1;
}

.kd-sec-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.01em;
}

.kd-sec-count {
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.kd-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
}

/* ── 卡片 ── */
.kd-card {
    position: relative;
    border-radius: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast),
        border-color var(--transition-fast), background var(--transition-fast);
}

.kd-card-link {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100%;
    padding: 11px 11px 9px;
    color: inherit;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.kd-card-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--kd-tone-soft);
    font-size: 20px;
    line-height: 1;
    transition: transform var(--transition-fast);
}

.kd-card-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1 1 auto;
}

.kd-card-name {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding-right: 28px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    letter-spacing: 0.01em;
}

.kd-note {
    font-style: normal;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 1px 5px;
    border-radius: 5px;
    background: var(--kd-tone-soft);
    color: var(--kd-tone);
    white-space: nowrap;
}

.kd-card-desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.55;
    color: var(--text-muted);
}

.kd-card-host {
    margin-top: auto;
    padding-top: 2px;
    font-size: 10.5px;
    color: var(--text-muted);
    opacity: 0.72;
    letter-spacing: 0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 收藏 */
.kd-fav {
    position: absolute;
    top: 7px;
    right: 6px;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #c9c9d2;
    cursor: pointer;
    transition: color var(--transition-fast), background var(--transition-fast),
        transform var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.kd-fav:hover {
    color: var(--amber);
    background: var(--amber-glow);
}

.kd-fav:active { transform: scale(0.88); }

.kd-fav.is-on { color: var(--amber); }

.kd-fav.is-on svg { fill: currentColor; }

/* 随机高亮 */
.kd-card.is-lucky {
    border-color: var(--amber);
    box-shadow: 0 0 0 3px var(--amber-glow), 0 12px 26px rgba(245, 158, 11, 0.16);
    animation: kdPop 0.52s var(--ease-out) 2;
}

@keyframes kdPop {
    0%, 100% { transform: none; }
    50% { transform: translateY(-4px) scale(1.015); }
}

/* 分类色 */
.kd-card[data-tone="mint"]  { --kd-tone: #0d9488; --kd-tone-soft: rgba(13, 148, 136, 0.10); }
.kd-card[data-tone="sky"]   { --kd-tone: #0284c7; --kd-tone-soft: rgba(2, 132, 199, 0.10); }
.kd-card[data-tone="grape"] { --kd-tone: #7c3aed; --kd-tone-soft: rgba(124, 58, 237, 0.10); }
.kd-card[data-tone="ocean"] { --kd-tone: #2563eb; --kd-tone-soft: rgba(37, 99, 235, 0.10); }
.kd-card[data-tone="sun"]   { --kd-tone: #c2770a; --kd-tone-soft: rgba(245, 158, 11, 0.13); }
.kd-card[data-tone="peach"] { --kd-tone: #ea580c; --kd-tone-soft: rgba(234, 88, 12, 0.10); }
.kd-card[data-tone="rose"]  { --kd-tone: #db2777; --kd-tone-soft: rgba(219, 39, 119, 0.10); }
.kd-card[data-tone="leaf"]  { --kd-tone: #15803d; --kd-tone-soft: rgba(22, 163, 74, 0.10); }
.kd-card[data-tone="clay"]  { --kd-tone: #b45309; --kd-tone-soft: rgba(180, 83, 9, 0.10); }
.kd-card[data-tone="slate"] { --kd-tone: #475569; --kd-tone-soft: rgba(71, 85, 105, 0.10); }

/* ── 空状态 / 加载 / 提示 ── */
.kd-empty {
    padding: 54px 20px 60px;
    text-align: center;
}

.kd-empty-emoji {
    font-size: 44px;
    line-height: 1;
}

.kd-empty-title {
    margin-top: 12px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.kd-empty-hint {
    margin-top: 6px;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-muted);
}

.kd-empty-btn {
    height: 40px;
    margin-top: 16px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(13, 148, 136, 0.24);
    -webkit-tap-highlight-color: transparent;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.kd-empty-btn:hover { box-shadow: 0 6px 18px rgba(13, 148, 136, 0.3); }

.kd-empty-btn:active { transform: scale(0.96); }

.kd-loading {
    padding: 64px 0;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

.kd-toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom));
    z-index: 200;
    max-width: min(82vw, 340px);
    padding: 10px 18px;
    border-radius: 999px;
    background: rgba(26, 26, 30, 0.9);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 12px);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.kd-toast.is-on {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ── 回到顶部 ── */
.kd-top {
    position: fixed;
    right: 16px;
    bottom: calc(20px + env(safe-area-inset-bottom));
    z-index: 150;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: rgba(252, 249, 245, 0.94);
    color: var(--text-secondary);
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(10px) scale(0.92);
    pointer-events: none;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: opacity 0.22s ease, transform 0.22s ease, color var(--transition-fast),
        border-color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.kd-top.is-on {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

.kd-top:hover {
    color: var(--accent-dark);
    border-color: var(--accent-light);
}

.kd-top:active { transform: scale(0.92); }

/* ── 页脚 ── */
.kd-foot {
    margin-top: 0;
    padding-top: 18px;
    border-top: 1px dashed var(--border);
    text-align: center;
    font-size: 11.5px;
    line-height: 1.9;
    color: var(--text-muted);
}

.kd-foot p { margin: 0; }

/* ── 视觉隐藏（屏幕阅读器） ── */
.kd-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ── 键盘焦点 ── */
.kd-card-link:focus-visible,
.kd-chip:focus-visible,
.kd-hbtn:focus-visible,
.kd-fav:focus-visible,
.kd-empty-btn:focus-visible,
.kd-search-clear:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* 只有真正支持悬停的设备才做浮起 */
@media (hover: hover) and (pointer: fine) {
    .kd-card:hover {
        transform: translateY(-3px);
        border-color: var(--kd-tone);
        box-shadow: 0 10px 26px rgba(26, 26, 30, 0.09);
        background: #fffdfb;
    }

    .kd-card:hover .kd-card-icon { transform: scale(1.06) rotate(-3deg); }
}

/* ══════════════════════════════════════════
   560px+（大手机 / 小平板：卡片转横排）
   ══════════════════════════════════════════ */
@media (min-width: 560px) {
    .kd-page { --kd-pad: 18px; }

    .kd-hero { padding-top: 30px; }

    .kd-grid {
        gap: 12px;
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }

    .kd-card-link {
        flex-direction: row;
        align-items: center;
        gap: 11px;
        padding: 13px 12px 13px 13px;
    }

    .kd-card-icon { flex: 0 0 42px; }

    .kd-card-name { padding-right: 20px; }

    .kd-card-host { padding-top: 1px; }
}

/* ══════════════════════════════════════════
   768px+（平板竖屏）
   ══════════════════════════════════════════ */
@media (min-width: 768px) {
    .kd-page { --kd-pad: 22px; }

    .kd-sec { margin-top: 26px; }

    .kd-sec-title { font-size: 18px; }

    .kd-chip { height: 38px; font-size: 14px; }

    .kd-search { height: 50px; }
}

/* ══════════════════════════════════════════
   900px+（平板横屏 / 小笔记本）
   ══════════════════════════════════════════ */
@media (min-width: 900px) {
    .kd-grid {
        gap: 13px;
        grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
    }

    .kd-hbtn { height: 36px; font-size: 13px; padding: 0 13px; }

    /* 宽屏放得下，分类全部展开，不用横滑 */
    .kd-chips {
        flex-wrap: wrap;
        justify-content: center;
        overflow: visible;
        padding-right: 2px;
        -webkit-mask-image: none;
        mask-image: none;
    }

    .kd-chip {
        height: 34px;
        padding: 0 11px;
        gap: 4px;
        font-size: 13px;
    }

    .kd-top {
        right: 24px;
        bottom: 28px;
        width: 46px;
        height: 46px;
    }
}

/* ══════════════════════════════════════════
   1200px+（桌面）
   ══════════════════════════════════════════ */
@media (min-width: 1200px) {
    .kd-page { --kd-pad: 24px; }

    .kd-hero { padding-top: 36px; }

    .kd-grid {
        gap: 14px;
        grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
    }

    .kd-card-link { padding: 14px 13px 14px 14px; }
}

/* ══════════════════════════════════════════
   1440px+（大屏）
   ══════════════════════════════════════════ */
@media (min-width: 1440px) {
    .kd-page { --kd-max: 1240px; }
}

/* ══════════════════════════════════════════
   窄屏细节
   ══════════════════════════════════════════ */
@media (max-width: 560px) {
    .kd-hbtn { padding: 0 9px; }
}

@media (max-width: 380px) {
    .kd-page { --kd-pad: 12px; }

    .kd-grid {
        gap: 9px;
        grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
    }

    .kd-card-desc { font-size: 11.5px; }
}

@media (max-width: 340px) {
    /* 极窄屏：顶栏只留图标，给标题让位 */
    .kd-hbtn i { display: none; }

    .kd-hbtn { padding: 0 9px; gap: 0; }
}

/* ══════════════════════════════════════════
   减少动效
   ══════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    .kd-page,
    .kd-body,
    .kd-card,
    .kd-card-icon,
    .kd-toast,
    .kd-top,
    .kd-chip,
    .kd-hbtn,
    .kd-empty-btn {
        animation: none !important;
        transition: none !important;
    }

    .kd-card:hover { transform: none; }
}
