/**
 * 商城通用动效：字体呼吸 / 标题光泽 / 按钮弹性与光扫
 * 尊重 prefers-reduced-motion
 */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0s !important;
        scroll-behavior: auto !important;
    }
}

@keyframes ui-fade-up {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes ui-reveal {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
        filter: blur(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

@keyframes ui-page-dim {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes ui-window-in {
    from {
        opacity: 0;
        transform: translateY(22px) scale(0.975);
        filter: blur(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

@keyframes ui-text-breathe {
    0%, 100% {
        letter-spacing: -0.01em;
        opacity: 1;
    }
    50% {
        letter-spacing: 0.03em;
        opacity: 0.92;
    }
}

@keyframes ui-gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes ui-btn-shine {
    0% { transform: translateX(-120%) skewX(-18deg); }
    100% { transform: translateX(220%) skewX(-18deg); }
}

@keyframes ui-float-soft {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

@keyframes ui-nav-pulse {
    0%, 100% { box-shadow: 0 6px 16px rgba(10, 132, 255, 0.22); }
    50% { box-shadow: 0 8px 22px rgba(10, 132, 255, 0.38); }
}

/* 页面切换：淡入滑入 / 淡出滑出 */
html.js-page-motion body {
    animation: none;
    opacity: 0;
    transform: translateX(36px);
}

html.js-page-motion body.page-enter-active,
html.js-page-motion body.page-shown,
html.js-page-motion body.page-leave:not(.page-leave-active) {
    opacity: 1;
    transform: translateX(0);
}

html.js-page-motion body.page-enter-active {
    transition:
        opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

html.js-page-motion body.page-leave-active {
    opacity: 0;
    transform: translateX(-36px);
    pointer-events: none;
    transition:
        opacity 0.38s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 无 JS 时仍保留缓慢显现 */
body {
    animation: ui-page-dim 1.2s ease both;
}

.menubar {
    opacity: 0;
    animation: ui-reveal 1.15s cubic-bezier(0.22, 1, 0.36, 1) 0.15s both;
}

.window,
.desktop > .window,
body > .window {
    opacity: 0;
    animation: ui-window-in 1.35s cubic-bezier(0.22, 1, 0.36, 1) 0.35s both;
}

.titlebar {
    opacity: 0;
    animation: ui-fade-up 1s cubic-bezier(0.22, 1, 0.36, 1) 0.55s both;
}

/* 侧栏/内容不再整体 opacity:0，避免表格文字动效在「看不见」时播完 */
.sidebar,
.body > .sidebar {
    animation: ui-fade-up 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.45s both;
}

.content,
.body > .content,
.main,
.login-wrap {
    animation: ui-fade-up 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.5s both;
}

.nav a,
.nav-item {
    animation: ui-fade-up 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.nav a:nth-child(1), .nav-item:nth-child(1) { animation-delay: 0.55s; }
.nav a:nth-child(2), .nav-item:nth-child(2) { animation-delay: 0.62s; }
.nav a:nth-child(3), .nav-item:nth-child(3) { animation-delay: 0.69s; }
.nav a:nth-child(4), .nav-item:nth-child(4) { animation-delay: 0.76s; }
.nav a:nth-child(5), .nav-item:nth-child(5) { animation-delay: 0.83s; }
.nav a:nth-child(6), .nav-item:nth-child(6) { animation-delay: 0.9s; }
.nav a:nth-child(7), .nav-item:nth-child(7) { animation-delay: 0.97s; }
.nav a:nth-child(8), .nav-item:nth-child(8) { animation-delay: 1.04s; }
.nav a:nth-child(9), .nav-item:nth-child(9) { animation-delay: 1.11s; }
.nav a:nth-child(10), .nav-item:nth-child(10) { animation-delay: 1.18s; }
.nav a:nth-child(n+11), .nav-item:nth-child(n+11) { animation-delay: 1.25s; }

/* 标题渐变：勿用 currentColor（配合 color:transparent 会导致字几乎看不见） */
h1, h2, h3,
.h1,
.login-card h2,
.panel h3,
.titlebar .title {
    background-image: linear-gradient(
        105deg,
        #1d1d1f 0%,
        #0a84ff 35%,
        #af52de 55%,
        #1d1d1f 80%
    );
    background-size: 220% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    animation: ui-gradient-shift 7s ease-in-out infinite, ui-float-soft 4.5s ease-in-out infinite;
}

.menubar .brand {
    /* 顶栏品牌保持继承色，避免浅色/深色菜单对比度问题 */
    background-image: none;
    background-clip: border-box;
    -webkit-background-clip: border-box;
    color: inherit;
    -webkit-text-fill-color: currentColor;
    animation: none;
}

p, label, .sub, .side-label, .hint, .muted,
.card .name, .card .price, .bag-tag,
.stat-row, th, td, .chip, .badge, .alert {
    transition:
        color 0.25s ease,
        opacity 0.25s ease,
        letter-spacing 0.35s ease,
        transform 0.25s ease,
        text-shadow 0.25s ease;
}

.login-card p:not(.tr-running):not(.tr-chars),
.content .sub:not(.tr-running):not(.tr-chars),
.login-wrap p:not(.tr-running):not(.tr-chars) {
    animation: ui-text-breathe 6s ease-in-out infinite;
}

label:hover,
.side-label:hover {
    letter-spacing: 0.06em;
    color: #0a84ff;
}

a:not(.btn):not(.nav-item):not(.chip) {
    transition: color 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}

a:not(.btn):not(.nav-item):not(.chip):hover {
    transform: translateY(-1px);
}

/* 导航 / 分类按钮：弹性 + 光扫（对齐 .btn） */
.nav a,
.nav-item {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    transition:
        background 0.22s ease,
        color 0.22s ease,
        transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.22s ease,
        letter-spacing 0.22s ease,
        filter 0.22s ease;
}

.nav a::after,
.nav-item::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 45%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    transform: translateX(-120%) skewX(-18deg);
    pointer-events: none;
    z-index: 1;
}

.nav a > *,
.nav-item > * {
    position: relative;
    z-index: 2;
}

/* 选择器权重需高于上方通用 a:hover，否则分类只会上移 1px */
.nav a:not(.btn):not(.nav-item):not(.chip):hover,
.nav-item:hover {
    transform: translateX(4px) scale(1.03);
    letter-spacing: 0.02em;
    filter: brightness(1.04);
    box-shadow: 0 6px 16px rgba(10, 132, 255, 0.18);
}

.nav a:hover::after,
.nav-item:hover::after {
    animation: ui-btn-shine 0.7s ease;
}

.nav a:active,
.nav-item:active {
    transform: translateX(2px) scale(0.98);
    filter: brightness(0.97);
}

.nav a.active,
.nav-item.active {
    animation: ui-nav-pulse 2.8s ease-in-out infinite;
}

.nav a.active:not(.btn):not(.nav-item):not(.chip):hover,
.nav-item.active:hover {
    transform: translateX(4px) scale(1.03);
    filter: brightness(1.08);
    box-shadow: 0 10px 22px rgba(10, 132, 255, 0.4);
}

/* 分类按钮错落入场 */
.sidebar .nav a {
    opacity: 0;
    animation: ui-reveal 0.75s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.sidebar .nav a:nth-child(1) { animation-delay: 0.08s; }
.sidebar .nav a:nth-child(2) { animation-delay: 0.12s; }
.sidebar .nav a:nth-child(3) { animation-delay: 0.16s; }
.sidebar .nav a:nth-child(4) { animation-delay: 0.20s; }
.sidebar .nav a:nth-child(5) { animation-delay: 0.24s; }
.sidebar .nav a:nth-child(6) { animation-delay: 0.28s; }
.sidebar .nav a:nth-child(7) { animation-delay: 0.32s; }
.sidebar .nav a:nth-child(8) { animation-delay: 0.36s; }
.sidebar .nav a:nth-child(9) { animation-delay: 0.40s; }
.sidebar .nav a:nth-child(10) { animation-delay: 0.44s; }
.sidebar .nav a:nth-child(11) { animation-delay: 0.48s; }
.sidebar .nav a:nth-child(12) { animation-delay: 0.52s; }
.sidebar .nav a:nth-child(13) { animation-delay: 0.56s; }
.sidebar .nav a:nth-child(14) { animation-delay: 0.60s; }
.sidebar .nav a:nth-child(15) { animation-delay: 0.64s; }
.sidebar .nav a:nth-child(16) { animation-delay: 0.68s; }
.sidebar .nav a:nth-child(n+17) { animation-delay: 0.72s; }

/* 入场结束后再播 active 脉动，避免两套 animation 互顶 */
.sidebar .nav a.active {
    animation:
        ui-reveal 0.75s cubic-bezier(0.22, 1, 0.36, 1) both,
        ui-nav-pulse 2.8s ease-in-out 1s infinite;
}

/* 卡片 */
.card {
    transition:
        transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.28s ease,
        border-color 0.28s ease;
}

.card:hover {
    transform: translateY(-4px) scale(1.01);
}

.card:hover .name {
    letter-spacing: 0.02em;
}

.card:hover .price {
    transform: scale(1.04);
    transform-origin: left bottom;
}

/* 按钮：弹性 + 光扫 */
.btn,
button.btn,
a.btn,
button[type="submit"].btn {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    transition:
        transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.22s ease,
        filter 0.22s ease,
        background-color 0.22s ease,
        letter-spacing 0.22s ease;
    will-change: transform;
}

.btn::after,
button.btn::after,
a.btn::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 45%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.45),
        transparent
    );
    transform: translateX(-120%) skewX(-18deg);
    pointer-events: none;
    z-index: 1;
}

.btn:hover:not(:disabled),
button.btn:hover:not(:disabled),
a.btn:hover {
    transform: translateY(-2px) scale(1.03);
    filter: brightness(1.08);
    letter-spacing: 0.04em;
    box-shadow: 0 10px 22px rgba(10, 132, 255, 0.35);
}

.btn:hover:not(:disabled)::after,
button.btn:hover:not(:disabled)::after,
a.btn:hover::after {
    animation: ui-btn-shine 0.75s ease;
}

.btn:active:not(:disabled),
button.btn:active:not(:disabled),
a.btn:active {
    transform: translateY(0) scale(0.97);
    filter: brightness(0.96);
    letter-spacing: 0;
}

.btn.on:hover:not(:disabled) {
    box-shadow: 0 10px 22px rgba(52, 199, 89, 0.35);
}

.btn.off:hover:not(:disabled) {
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
    filter: brightness(1.02);
}

.btn:disabled {
    transform: none !important;
    animation: none !important;
}

.btn:disabled::after {
    display: none;
}

/* 次要按钮 / chip */
.btn.secondary:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.1);
}

.chip {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    transition:
        transform 0.2s ease,
        background 0.2s ease,
        color 0.2s ease,
        letter-spacing 0.2s ease,
        box-shadow 0.2s ease;
}

.chip::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 45%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.45),
        transparent
    );
    transform: translateX(-120%) skewX(-18deg);
    pointer-events: none;
    z-index: 1;
}

.chip:hover {
    transform: translateY(-2px) scale(1.05);
    letter-spacing: 0.03em;
    box-shadow: 0 6px 14px rgba(0, 122, 255, 0.18);
}

.chip:hover::after {
    animation: ui-btn-shine 0.7s ease;
}

/* 积分徽章等：入场 + 悬停光扫 + 数字轻微呼吸 */
.badges .badge,
.content .badge {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    opacity: 0;
    animation: ui-reveal 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.45s both;
    transition:
        transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.22s ease,
        filter 0.22s ease,
        letter-spacing 0.22s ease,
        background 0.22s ease;
}

.badges .badge:nth-child(2) { animation-delay: 0.55s; }
.badges .badge:nth-child(3) { animation-delay: 0.65s; }

.badges .badge::after,
.content .badge::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 45%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.55),
        transparent
    );
    transform: translateX(-120%) skewX(-18deg);
    pointer-events: none;
    z-index: 1;
}

.badges .badge > *,
.content .badge > * {
    position: relative;
    z-index: 2;
}

.badges .badge:hover,
.content .badge:hover {
    transform: translateY(-2px) scale(1.05);
    letter-spacing: 0.02em;
    filter: brightness(1.04);
    box-shadow: 0 8px 18px rgba(10, 132, 255, 0.22);
}

.badges .badge:hover::after,
.content .badge:hover::after {
    animation: ui-btn-shine 0.7s ease;
}

.badges .badge strong {
    display: inline-block;
    animation: ui-float-soft 2.8s ease-in-out infinite;
    transform-origin: center;
}

/* 表格行 */
tr {
    transition: background 0.2s ease, transform 0.2s ease;
}

/* —— 作者信息：菜单栏出现后再明显滑入；名字/QQ 由 JS 慢速打出 —— */
@keyframes ui-author-pill-in {
    from {
        opacity: 0;
        transform: translateY(28px) scale(0.92);
        filter: blur(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

.author-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    max-width: min(420px, 72vw);
}

.author-block .author {
    opacity: 0;
    transform: translateY(28px) scale(0.92);
    filter: blur(6px);
}

html:not(.js-page-motion) .author-block .author {
    opacity: 1;
    transform: none;
    filter: none;
}

.author-block.author-enter .author {
    animation: ui-author-pill-in 1.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.author-meta strong,
.author-meta span {
    min-height: 1.15em;
}

.author-meta .author-typing::after {
    content: '';
    display: inline-block;
    width: 1px;
    height: 0.85em;
    margin-left: 1px;
    vertical-align: -0.05em;
    background: currentColor;
    animation: tr-cursor-blink 0.85s step-end infinite;
}

.author-verse {
    margin: 0;
    padding: 0 4px;
    font-size: 10px;
    font-weight: 500;
    line-height: 1.45;
    text-align: center;
    color: inherit;
    opacity: 0.78;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    min-height: 1.45em;
}

.author-verse.author-verse-typing {
    opacity: 0.9;
    filter: none;
    letter-spacing: 0.02em;
    transform: none;
    animation: none;
    white-space: nowrap;
    text-overflow: clip;
}

.author-verse.author-verse-typing::after {
    content: '';
    display: inline-block;
    width: 1px;
    height: 0.9em;
    margin-left: 1px;
    vertical-align: -0.05em;
    background: currentColor;
    animation: tr-cursor-blink 0.85s step-end infinite;
}

.author-verse.author-verse-done {
    white-space: normal;
    text-overflow: unset;
    animation: ui-verse-dissolve 3.8s ease forwards;
    animation-delay: 1.4s;
}

@keyframes ui-verse-dissolve {
    0% {
        opacity: 0.9;
        filter: blur(0);
        letter-spacing: 0.02em;
        transform: translateY(0);
    }
    35% {
        opacity: 0.75;
        filter: blur(0.5px);
        letter-spacing: 0.06em;
    }
    100% {
        opacity: 0;
        filter: blur(8px);
        letter-spacing: 0.22em;
        transform: translateY(-6px);
    }
}

@media (max-width: 720px) {
    .author-verse {
        font-size: 9px;
        white-space: normal;
    }
}

@media (prefers-reduced-motion: reduce) {
    .author-block .author {
        opacity: 1;
        transform: none;
        filter: none;
        animation: none;
    }
    .author-meta .author-typing::after,
    .author-verse.author-verse-typing::after {
        display: none;
    }
    .author-verse.author-verse-done {
        animation: none;
        opacity: 0.78;
        filter: none;
        letter-spacing: 0.02em;
        transform: none;
    }
}

/* 输入框聚焦时标签跳动感 */
input:focus,
textarea:focus,
select:focus {
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    transform: scale(1.01);
}

/* 确保后台大标题始终可见（避免入场动效残留 opacity:0） */
.content > .h1 {
    opacity: 1;
}

/* 登录区、商品卡片错落入场（后台表格改由 text-reveal 负责） */
.login-card,
.content > .toolbar,
.content > .sub,
.grid .card {
    opacity: 0;
    animation: ui-reveal 1.1s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.login-card { animation-delay: 0.55s; }
.content > .toolbar { animation-delay: 0.55s; }
.content > .sub { animation-delay: 0.65s; }

.grid .card:nth-child(1) { animation-delay: 0.6s; }
.grid .card:nth-child(2) { animation-delay: 0.72s; }
.grid .card:nth-child(3) { animation-delay: 0.84s; }
.grid .card:nth-child(4) { animation-delay: 0.96s; }
.grid .card:nth-child(5) { animation-delay: 1.08s; }
.grid .card:nth-child(6) { animation-delay: 1.2s; }
.grid .card:nth-child(7) { animation-delay: 1.32s; }
.grid .card:nth-child(8) { animation-delay: 1.44s; }
.grid .card:nth-child(9) { animation-delay: 1.56s; }
.grid .card:nth-child(10) { animation-delay: 1.68s; }
.grid .card:nth-child(11) { animation-delay: 1.8s; }
.grid .card:nth-child(12) { animation-delay: 1.92s; }
.grid .card:nth-child(n+13) { animation-delay: 2.0s; }
