/* =========================================================================
 * ikun_test 子站设计系统
 *
 * 只服务于人格测试子站。令牌取值对齐主站 assets/css/theme-heroui.css，
 * 保证从主站点过来视觉不断层；但不引入主站的布局规则（那会把子站骨架弄坏）。
 *
 * 加载顺序约定：heroui.min.css（可选，只为主站卡片兼容）→ test-ui.css
 * 子站页面不需要也不应该引 front.all.css / theme-heroui.css。
 *
 * 断点：1080 / 860 / 640 / 460
 * ========================================================================= */

:root {
    /* 色板 */
    --bg: #F6F6F7;
    --bg-grad: radial-gradient(900px 420px at 50% -12%, rgba(15, 143, 131, .12), transparent 70%);
    --card: #FFFFFF;
    --card-soft: #F4F4F5;
    --card-hover: #FBFBFC;
    --text: #24292E;
    --text-2: #5F6672;
    --text-3: #9AA1AC;
    --primary: #0F8F83;
    --primary-hover: #0B756B;
    --primary-soft: rgba(15, 143, 131, .10);
    --border: #E7E7EA;
    --border-hover: #D3D3D8;

    /* 语义色：结果等级用 */
    --ok: #16A34A;
    --warn: #F59E0B;
    --danger: #DC2626;
    --info: #2563EB;

    /* 形状 */
    --radius: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --radius-pill: 999px;

    /* 阴影 */
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-sm: 0 2px 4px rgba(16, 24, 40, .06);
    --shadow-hover: 0 2px 4px rgba(16, 24, 40, .06), 0 16px 36px rgba(16, 24, 40, .10);

    /* 字体 */
    --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC",
                 "Microsoft YaHei", system-ui, sans-serif;
    --font-num: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    /* 布局 */
    --wrap: 1080px;
    --gap: 16px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    background-color: var(--bg);
    background-image: var(--bg-grad);
    background-repeat: no-repeat;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; line-height: 1.3; letter-spacing: -.01em; }

img { max-width: 100%; height: auto; }

/* 键盘可达性：只在键盘导航时显示焦点环，鼠标点击不显示 */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
    border-radius: 4px;
}

/* 屏幕阅读器专用 */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* =========================================================================
 * 骨架
 * ========================================================================= */

.wrap {
    width: 100%;
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 0 24px;
}

/* 子站顶栏：轻量，只放 logo + 导航 */
.subnav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(246, 246, 247, .86);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}

.subnav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: 60px;
}

.subnav-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 650;
    font-size: 15px;
    text-decoration: none;
    white-space: nowrap;
}

.subnav-brand:hover { text-decoration: none; color: var(--primary); }

.subnav-brand img {
    width: 30px; height: 30px;
    border-radius: 9px;
    background: var(--card);
    object-fit: contain;
    box-shadow: var(--shadow-xs);
}

.subnav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}
.subnav-links::-webkit-scrollbar { display: none; }

.subnav-links a {
    padding: 7px 13px;
    border-radius: var(--radius-pill);
    color: var(--text-2);
    font-size: 13.5px;
    white-space: nowrap;
    transition: background .15s, color .15s;
}

.subnav-links a:hover {
    background: var(--card);
    color: var(--primary);
    text-decoration: none;
}

.subnav-links a[aria-current="page"] {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

/* =========================================================================
 * 首页 hero
 * ========================================================================= */

.hero {
    padding: 52px 0 30px;
    text-align: center;
}

.hero-logo {
    display: block;
    width: 88px; height: 88px;
    margin: 0 auto 18px;
    border-radius: 24px;
    background: var(--card);
    object-fit: contain;
    box-shadow: var(--shadow-xs);
}

.hero h1 {
    margin-bottom: 12px;
    font-size: 36px;
    font-weight: 700;
    line-height: 1.2;
}

.hero-desc {
    max-width: 620px;
    margin: 0 auto;
    font-size: 15px;
    line-height: 1.75;
    color: var(--text-2);
}

/* hero 底部的实时数据条 */
.hero-stats {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px 28px;
    margin-top: 22px;
    font-size: 13px;
    color: var(--text-3);
}

.hero-stats b {
    color: var(--primary);
    font-family: var(--font-num);
    font-size: 15px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.hero-stats .live-dot {
    display: inline-block;
    width: 6px; height: 6px;
    margin-right: 6px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, .14);
    animation: pulse 2s ease-in-out infinite;
    vertical-align: 1px;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: .35; }
}

/* =========================================================================
 * 区块标题
 * ========================================================================= */

.section {
    margin-bottom: 44px;
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.section-head h2 {
    font-size: 19px;
    font-weight: 650;
    display: flex;
    align-items: center;
    gap: 9px;
}

.section-head h2 .badge-hot {
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    background: linear-gradient(135deg, #FF6B6B, #F03E3E);
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .04em;
    vertical-align: 2px;
}

.section-head p {
    margin: 0;
    font-size: 13px;
    color: var(--text-3);
}

.section-head .more {
    font-size: 13px;
    color: var(--primary);
    white-space: nowrap;
}

/* =========================================================================
 * 测试卡片
 * ========================================================================= */

.test-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--gap);
}

.test-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow-xs);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
    overflow: hidden;
}

/* 左侧色条：用测试自己的强调色，让一排卡片有辨识度 */
.test-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--card-accent, var(--primary));
    opacity: 0;
    transition: opacity .18s;
}

.test-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-hover);
    background: var(--card-hover);
}

.test-card:hover::before { opacity: 1; }

.test-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.test-card h3 {
    font-size: 16.5px;
    font-weight: 650;
    line-height: 1.4;
}

.test-card h3 a {
    color: var(--text);
    text-decoration: none;
}

.test-card h3 a:hover { color: var(--primary); }

/* 卡片右上角的排名角标（热门推荐用） */
.rank-badge {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 26px; height: 26px;
    border-radius: 9px;
    background: var(--card-soft);
    color: var(--text-3);
    font-family: var(--font-num);
    font-size: 12px;
    font-weight: 700;
}

.rank-badge.top1 { background: linear-gradient(135deg, #FFD43B, #F59F00); color: #fff; }
.rank-badge.top2 { background: linear-gradient(135deg, #CED4DA, #ADB5BD); color: #fff; }
.rank-badge.top3 { background: linear-gradient(135deg, #E8A87C, #C97B4A); color: #fff; }

.test-card p {
    flex: 1;
    margin: 0 0 16px;
    font-size: 13.5px;
    line-height: 1.7;
    color: var(--text-2);
}

.test-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin-bottom: 16px;
    font-size: 12px;
    color: var(--text-3);
}

.test-tag {
    padding: 2px 9px;
    border-radius: var(--radius-pill);
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 11.5px;
    font-weight: 600;
}

.test-meta .dot-sep { color: var(--border-hover); }

.test-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.test-count {
    font-size: 12px;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
}

.test-count b {
    color: var(--text-2);
    font-weight: 650;
}

/* =========================================================================
 * 按钮
 * ========================================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 40px;
    padding: 0 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    background: var(--primary);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s, transform .12s;
}

.btn:hover {
    background: var(--primary-hover);
    color: #fff;
    text-decoration: none;
}

.btn:active { transform: translateY(1px); }

.btn[disabled], .btn.is-disabled {
    background: var(--border);
    color: var(--text-3);
    cursor: not-allowed;
    transform: none;
}

.btn-ghost {
    background: transparent;
    border-color: var(--border-hover);
    color: var(--text-2);
}
.btn-ghost:hover {
    background: var(--card);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-sm { height: 34px; padding: 0 15px; font-size: 13px; }
.btn-lg { height: 48px; padding: 0 30px; font-size: 15.5px; }

/* =========================================================================
 * 排行榜
 * ========================================================================= */

.board {
    display: grid;
    gap: var(--gap);
}

.board-card {
    padding: 20px 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow-xs);
}

.board-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.board-card-head h3 {
    font-size: 16px;
    font-weight: 650;
}

.board-card-head p {
    margin: 3px 0 0;
    font-size: 12.5px;
    color: var(--text-3);
}

.board-card-head .board-total {
    flex: 0 0 auto;
    font-family: var(--font-num);
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.board-card-head .board-total small {
    display: block;
    font-family: var(--font-sans);
    font-size: 10.5px;
    font-weight: 400;
    color: var(--text-3);
    text-align: right;
}

/* 结果分布条 */
.dist {
    display: grid;
    gap: 9px;
}

.dist-row {
    display: grid;
    grid-template-columns: 96px 1fr 62px;
    align-items: center;
    gap: 12px;
    font-size: 12.5px;
}

.dist-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-2);
}

.dist-track {
    /* 这两个元素在 rank.php 里是 <span>，必须显式 block —— 行内元素
       的 width/height 不生效，条会一直是空的（踩过）。 */
    display: block;
    height: 8px;
    border-radius: var(--radius-pill);
    background: var(--card-soft);
    overflow: hidden;
}

.dist-fill {
    display: block;
    height: 100%;
    border-radius: var(--radius-pill);
    /* 颜色由行内 style 的 --dist-color 给（见 rank.php）；
       这里的 var() 只是没设变量时的兜底。 */
    background: var(--dist-color, var(--primary));
    /* 极窄的条也要看得见，所以给一个最小宽度 */
    min-width: 3px;
    transition: width .5s cubic-bezier(.2, .8, .2, 1);
}

.dist-num {
    text-align: right;
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
    color: var(--text-3);
}

.dist-num b {
    color: var(--text-2);
    font-weight: 650;
}

/* 总榜 */
.rank-list {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: rank;
}

.rank-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 0;
    border-bottom: 1px solid var(--card-soft);
}

.rank-item:last-child { border-bottom: 0; }

.rank-no {
    flex: 0 0 28px;
    font-family: var(--font-num);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-3);
    text-align: center;
}

.rank-item:nth-child(1) .rank-no { color: #F59F00; }
.rank-item:nth-child(2) .rank-no { color: #868E96; }
.rank-item:nth-child(3) .rank-no { color: #C97B4A; }

.rank-main { flex: 1; min-width: 0; }

.rank-name {
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-name a { color: var(--text); }
.rank-name a:hover { color: var(--primary); text-decoration: none; }

.rank-sub {
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-bar {
    height: 3px;
    margin-top: 7px;
    border-radius: var(--radius-pill);
    background: var(--primary);
    opacity: .55;
}

.rank-val {
    flex: 0 0 auto;
    text-align: right;
    font-family: var(--font-num);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    color: var(--text-3);
}

.rank-val b {
    display: block;
    font-size: 15px;
    color: var(--text-2);
    font-weight: 700;
}

/* 实时播报 */
.feed {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 320px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-hover) transparent;
}

.feed li {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 9px 0;
    border-bottom: 1px dashed var(--card-soft);
    font-size: 12.5px;
    color: var(--text-2);
    line-height: 1.6;
}

.feed li:last-child { border-bottom: 0; }

.feed .feed-who {
    flex: 0 0 auto;
    color: var(--text-3);
}

.feed .feed-result {
    font-weight: 650;
    color: var(--primary);
}

.feed .feed-ago {
    margin-left: auto;
    flex: 0 0 auto;
    font-size: 11.5px;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
}

/* =========================================================================
 * 状态：空态 / 骨架 / 提示
 * ========================================================================= */

.empty {
    padding: 30px 16px;
    text-align: center;
    font-size: 13px;
    color: var(--text-3);
}

.empty-icon {
    display: block;
    margin: 0 auto 10px;
    font-size: 26px;
    opacity: .5;
}

.skeleton {
    height: 12px;
    border-radius: var(--radius-pill);
    background: linear-gradient(90deg, var(--card-soft) 25%, #EDEDF0 37%, var(--card-soft) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s ease infinite;
}

@keyframes shimmer {
    0%   { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

.notice {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--warn);
    border-radius: var(--radius-sm);
    background: #FFFBEB;
    color: #92600A;
    font-size: 13px;
    line-height: 1.7;
}

.notice[hidden] { display: none; }

/* =========================================================================
 * 页脚
 * ========================================================================= */

.footer {
    margin-top: 8px;
    padding: 30px 24px 40px;
    border-top: 1px solid var(--border);
    background: var(--card);
    text-align: center;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 26px;
    margin-bottom: 12px;
}

.footer-links a {
    font-size: 13.5px;
    color: var(--text-2);
    transition: color .15s;
}

.footer-links a:hover { color: var(--primary); text-decoration: none; }

.footer-note {
    font-size: 12px;
    color: var(--text-3);
    line-height: 1.8;
}

/* =========================================================================
 * 响应式
 * ========================================================================= */

@media (max-width: 1024px) {
    /* 横屏平板：页宽与标题降一档 */
    .wrap { padding: 0 20px; }
    .hero { padding: 40px 0 26px; }
    .hero h1 { font-size: 30px; }
    .section { margin-bottom: 36px; }
    .dist-row { grid-template-columns: 80px 1fr 54px; gap: 10px; }
}

@media (max-width: 768px) {
    /* 竖屏平板及以下：测试卡片墙收单列 */
    .test-grid { grid-template-columns: 1fr; }
    .test-card { padding: 19px; }
    .hero h1 { font-size: 26px; }
    .hero-desc { font-size: 14px; }
    .section-head h2 { font-size: 17px; }
    .board-card { padding: 17px 16px; }
    .subnav-inner { height: 54px; }
    .subnav-brand span { display: none; }
}

@media (max-width: 430px) {
    /* 手机：全局留白与字号再收一档 */
    .wrap { padding: 0 14px; }
    .hero { padding: 30px 0 20px; }
    .hero-logo { width: 72px; height: 72px; border-radius: 20px; }
    .hero h1 { font-size: 23px; }
    .hero-stats { gap: 8px 18px; font-size: 12px; }
    .test-card-foot { flex-direction: column; align-items: stretch; gap: 10px; }
    .test-card-foot .btn { width: 100%; }
    .test-count { text-align: center; }
    .dist-row { grid-template-columns: 68px 1fr 46px; font-size: 11.5px; }
    .rank-val b { font-size: 14px; }
    .footer-links { flex-direction: column; gap: 12px; }
}

/* 尊重系统的「减少动态效果」设置 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
