/**
 * 签到墙 - 样式二：矩阵墙
 * 布局：5行 × 16列 圆形头像矩阵 + 中央大头像 + 角落Toast
 * 头像框特效：锥形渐变旋转边框（沿圆周流转）+ 漂浮微光粒子 + 呼吸光晕脉冲
 */

/* CSS Houdini: 注册角度自定义属性，用于动画化 conic-gradient 起始角度 */
@property --ring-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

/* ============ 整体布局 ============ */
.sign-matrix-page {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.3);
}

/* ============ 中央大头像区域 ============ */
.sign-center-avatar {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    text-align: center;
    pointer-events: none;
}

.sign-center-avatar .center-ring {
    position: relative;
    width: 280px;
    height: 280px;
    border-radius: 50%;
    padding: 6px;
    background: linear-gradient(135deg, #00d2ff, #7b2ff7, #ff0080, #00d2ff);
    background-size: 400% 400%;
    animation: glow-border-rotate 4s linear infinite;
    box-shadow: 0 0 40px rgba(0, 210, 255, 0.4), 0 0 80px rgba(123, 47, 247, 0.2);
}

.sign-center-avatar .center-img-wrap {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    background: #1a1a2e;
}

.sign-center-avatar .center-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.sign-center-avatar .center-img-wrap img.switching {
    opacity: 0;
    transform: scale(0.8);
}

.sign-center-avatar .center-name {
    margin-top: 16px;
    font-size: 28px;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
    font-weight: 600;
    letter-spacing: 2px;
    transition: opacity 0.4s ease;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: 300px;
}

.sign-center-avatar .center-order {
    margin-top: 6px;
    font-size: 16px;
    color: rgba(255,255,255,0.6);
    text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* 流光边框旋转动画 */
@keyframes glow-border-rotate {
    0%   { background-position: 0% 50%; box-shadow: 0 0 40px rgba(0, 210, 255, 0.4), 0 0 80px rgba(123, 47, 247, 0.2); }
    25%  { background-position: 100% 50%; box-shadow: 0 0 40px rgba(123, 47, 247, 0.4), 0 0 80px rgba(255, 0, 128, 0.2); }
    50%  { background-position: 100% 100%; box-shadow: 0 0 40px rgba(255, 0, 128, 0.4), 0 0 80px rgba(0, 210, 255, 0.2); }
    75%  { background-position: 0% 100%; box-shadow: 0 0 40px rgba(0, 210, 255, 0.4), 0 0 80px rgba(123, 47, 247, 0.2); }
    100% { background-position: 0% 50%; box-shadow: 0 0 40px rgba(0, 210, 255, 0.4), 0 0 80px rgba(123, 47, 247, 0.2); }
}

/* ============ 矩阵网格区域 ============ */
.sign-matrix-grid {
    position: absolute;
    top: 5%;
    left: 3%;
    width: 94%;
    height: 90%;
    overflow: hidden;
}

.sign-matrix-grid .grid-scroll-wrap {
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    gap: 6px;
    padding: 10px;
    transition: transform 0.05s linear;
}

.sign-matrix-grid .grid-scroll-wrap.scrolling {
    /* transform controlled by JS for smooth scroll */
}

/* 头像格子 */
.sign-matrix-grid .avatar-cell {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    transform: scale(0);
    transition: none;
}

.sign-matrix-grid .avatar-cell.shown {
    opacity: 1;
    transform: scale(1);
}

/* 新入场动画：模糊淡入 + 弹性放大 */
.sign-matrix-grid .avatar-cell.entering {
    animation: avatar-enter 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes avatar-enter {
    0% {
        opacity: 0;
        transform: scale(0.3);
        filter: blur(8px);
    }
    60% {
        opacity: 1;
        transform: scale(1.1);
        filter: blur(1px);
    }
    80% {
        transform: scale(0.95);
        filter: blur(0);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        filter: blur(0);
    }
}

/* 头像圆形 - 锥形渐变旋转边框（蓝→紫→粉 沿圆周流转） */
.sign-matrix-grid .avatar-img-wrap {
    --ring-angle: 0deg;
    position: relative;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    overflow: hidden;
    border: none;
    padding: 3px;
    background: conic-gradient(
        from var(--ring-angle),
        #00d2ff 0%,
        #7b2ff7 33%,
        #ff0080 66%,
        #00d2ff 100%
    );
    animation: avatar-ring-spin 4s linear infinite;
    box-shadow:
        0 0 12px rgba(0, 210, 255, 0.3),
        0 0 28px rgba(123, 47, 247, 0.15),
        0 0 6px rgba(255, 0, 128, 0.1);
}

/* 锥形渐变旋转动画（通过 @property 动画化角度，实现真实圆周流转） */
@keyframes avatar-ring-spin {
    to { --ring-angle: 360deg; }
}

.sign-matrix-grid .avatar-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

/* ===== 头像粒子特效 ===== */

/* 漂浮微光粒子（多点光斑轨道浮动） */
.sign-matrix-grid .avatar-cell.shown::before {
    content: '';
    position: absolute;
    width: 3px;
    height: 3px;
    top: 45px;
    left: 45px;
    border-radius: 50%;
    z-index: 2;
    pointer-events: none;
    animation: particle-float 5s ease-in-out infinite;
    box-shadow:
        -43px -18px 0 1px   rgba(0,210,255,0.9),
         36px -32px 0 0.5px rgba(123,47,247,0.8),
         43px  12px 0 1px   rgba(255,0,128,0.7),
        -30px  38px 0 0.5px rgba(0,210,255,0.8),
         12px -43px 0 1px   rgba(255,255,255,0.6),
        -38px   8px 0 0.5px rgba(123,47,247,0.7),
         24px  40px 0 0.5px rgba(255,0,128,0.6),
        -12px -40px 0 1px   rgba(0,210,255,0.7);
}

/* 呼吸光晕脉冲 */
.sign-matrix-grid .avatar-cell.shown::after {
    content: '';
    position: absolute;
    width: 96px;
    height: 96px;
    top: -3px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
    animation: aura-breathe 3.5s ease-in-out infinite;
}

/* 粒子浮动动画 */
@keyframes particle-float {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
        opacity: 0.5;
    }
    25% {
        transform: translate(3px, -4px) rotate(90deg);
        opacity: 1;
    }
    50% {
        transform: translate(-2px, -2px) rotate(180deg);
        opacity: 0.3;
    }
    75% {
        transform: translate(4px, 3px) rotate(270deg);
        opacity: 0.9;
    }
}

/* 光晕呼吸动画 */
@keyframes aura-breathe {
    0%, 100% {
        opacity: 0.3;
        box-shadow:
            0 0 8px rgba(0,210,255,0.15),
            0 0 16px rgba(123,47,247,0.06);
    }
    50% {
        opacity: 0.7;
        box-shadow:
            0 0 16px rgba(0,210,255,0.3),
            0 0 32px rgba(123,47,247,0.12),
            0 0 48px rgba(255,0,128,0.04);
    }
}

/* 交错动画延迟（每个头像错开节奏，避免同步跳动） */
.sign-matrix-grid .avatar-cell.shown:nth-child(4n+1)::before  { animation-delay: 0s; }
.sign-matrix-grid .avatar-cell.shown:nth-child(4n+1)::after   { animation-delay: 0.2s; }
.sign-matrix-grid .avatar-cell.shown:nth-child(4n+2)::before  { animation-delay: 1.2s; }
.sign-matrix-grid .avatar-cell.shown:nth-child(4n+2)::after   { animation-delay: 0.8s; }
.sign-matrix-grid .avatar-cell.shown:nth-child(4n+3)::before  { animation-delay: 2.5s; }
.sign-matrix-grid .avatar-cell.shown:nth-child(4n+3)::after   { animation-delay: 1.5s; }
.sign-matrix-grid .avatar-cell.shown:nth-child(4n)::before    { animation-delay: 3.7s; }
.sign-matrix-grid .avatar-cell.shown:nth-child(4n)::after     { animation-delay: 2.3s; }

/* 流光边框也错开节奏 */
.sign-matrix-grid .avatar-cell:nth-child(3n+1) .avatar-img-wrap { animation-delay: 0s; }
.sign-matrix-grid .avatar-cell:nth-child(3n+2) .avatar-img-wrap { animation-delay: 1.3s; }
.sign-matrix-grid .avatar-cell:nth-child(3n)   .avatar-img-wrap { animation-delay: 2.7s; }

/* 头像下方昵称 */
.sign-matrix-grid .avatar-nick {
    margin-top: 4px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: 94px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* ============ Toast 提示（左下角 / 右下角交替） ============ */
.sign-toast {
    position: absolute;
    bottom: 60px;
    z-index: 10;
    display: flex;
    align-items: center;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 60px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    opacity: 0;
    transform: scale(0.6);
    pointer-events: none;
    transition: none;
}

.sign-toast.toast-left {
    left: 40px;
}

.sign-toast.toast-right {
    right: 40px;
}

/* Toast 弹入动画 */
.sign-toast.toast-show {
    animation: toast-bounce-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Toast 淡出动画 */
.sign-toast.toast-hide {
    animation: toast-fade-out 0.3s ease forwards;
}

@keyframes toast-bounce-in {
    0% {
        opacity: 0;
        transform: scale(0.6) translateY(20px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes toast-fade-out {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }
}

.sign-toast .toast-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.sign-toast .toast-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sign-toast .toast-info {
    display: flex;
    flex-direction: column;
}

.sign-toast .toast-nick {
    font-size: 18px;
    color: #fff;
    font-weight: 500;
    margin-bottom: 2px;
    max-width: 200px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.sign-toast .toast-label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
}

/* ============ 签到计数器（左上角） ============ */
.sign-counter {
    position: absolute;
    top: 20px;
    left: 30px;
    z-index: 8;
    display: flex;
    align-items: center;
    padding: 8px 20px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sign-counter .counter-icon {
    width: 24px;
    height: 24px;
    margin-right: 8px;
    background: linear-gradient(135deg, #00d2ff, #7b2ff7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #fff;
}

.sign-counter .counter-num {
    font-size: 22px;
    color: #fff;
    font-weight: 700;
    margin-right: 4px;
    min-width: 30px;
    text-align: center;
}

.sign-counter .counter-label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

/* ============ 等待签到提示 ============ */
.sign-waiting {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    z-index: 3;
}

.sign-waiting .waiting-icon {
    font-size: 60px;
    margin-bottom: 16px;
    animation: pulse-glow 2s ease-in-out infinite;
}

.sign-waiting .waiting-text {
    font-size: 24px;
    letter-spacing: 4px;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

/* ============ 飞行头像克隆元素 ============ */
.sign-flying-avatar {
    position: absolute;
    z-index: 20;
    pointer-events: none;
    will-change: transform, opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.sign-flying-avatar .flying-ring {
    width: 280px;
    height: 280px;
    border-radius: 50%;
    padding: 6px;
    background: linear-gradient(135deg, #00d2ff, #7b2ff7, #ff0080, #00d2ff);
    background-size: 400% 400%;
    animation: glow-border-rotate 4s linear infinite;
    box-shadow: 0 0 40px rgba(0, 210, 255, 0.4), 0 0 80px rgba(123, 47, 247, 0.2);
}

.sign-flying-avatar .flying-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    background: #1a1a2e;
}

.sign-flying-avatar .flying-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 到达中央时光晕脉冲 */
.sign-flying-avatar.glow-pulse .flying-ring {
    animation: glow-border-rotate 4s linear infinite, fly-in-glow-pulse 200ms ease-out;
}

/* 光晕脉冲（到达时） */
@keyframes fly-in-glow-pulse {
    0% {
        box-shadow: 0 0 40px rgba(0, 210, 255, 0.4), 0 0 80px rgba(123, 47, 247, 0.2);
    }
    50% {
        box-shadow: 0 0 60px rgba(0, 210, 255, 0.7), 0 0 120px rgba(123, 47, 247, 0.4), 0 0 160px rgba(255, 0, 128, 0.2);
    }
    100% {
        box-shadow: 0 0 40px rgba(0, 210, 255, 0.4), 0 0 80px rgba(123, 47, 247, 0.2);
    }
}

/* 中央信息淡入 */
@keyframes center-info-fade-in {
    0% {
        opacity: 0;
        transform: translateY(5px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 中央信息淡出 */
@keyframes center-info-fade-out {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(5px);
    }
}

.sign-center-avatar .center-name.info-fade-in,
.sign-center-avatar .center-order.info-fade-in {
    animation: center-info-fade-in 300ms ease-out forwards;
}

.sign-center-avatar .center-name.info-fade-out,
.sign-center-avatar .center-order.info-fade-out {
    animation: center-info-fade-out 300ms ease-in forwards;
}

/* 中央头像图片隐藏（飞行头像替代） */
.sign-center-avatar .center-ring {
    visibility: hidden;
}

/* 待入场的矩阵格子（不可见占位） */
.sign-matrix-grid .avatar-cell.cell-hidden {
    opacity: 0;
    transform: scale(0);
    animation: none;
}

/* ============ 响应式适配 ============ */
@media (min-width: 1920px) {
    .sign-matrix-grid .avatar-img-wrap {
        width: 110px;
        height: 110px;
        padding: 3px;
    }
    .sign-matrix-grid .avatar-cell.shown::after {
        width: 116px;
        height: 116px;
        top: -3px;
    }
    .sign-matrix-grid .avatar-cell.shown::before {
        top: 55px;
        left: 55px;
        box-shadow:
            -52px -22px 0 1px   rgba(0,210,255,0.9),
             44px -38px 0 0.5px rgba(123,47,247,0.8),
             52px  14px 0 1px   rgba(255,0,128,0.7),
            -36px  46px 0 0.5px rgba(0,210,255,0.8),
             14px -52px 0 1px   rgba(255,255,255,0.6),
            -46px  10px 0 0.5px rgba(123,47,247,0.7),
             28px  48px 0 0.5px rgba(255,0,128,0.6),
            -14px -48px 0 1px   rgba(0,210,255,0.7);
    }
    .sign-center-avatar .center-ring {
        width: 340px;
        height: 340px;
    }
    .sign-center-avatar .center-name {
        font-size: 32px;
    }
    .sign-flying-avatar .flying-ring {
        width: 340px;
        height: 340px;
    }
    .sign-matrix-grid .avatar-nick {
        max-width: 114px;
        font-size: 13px;
    }
}

@media (max-width: 1280px) {
    .sign-matrix-grid .avatar-img-wrap {
        width: 68px;
        height: 68px;
        padding: 2px;
    }
    .sign-matrix-grid .avatar-cell.shown::after {
        width: 72px;
        height: 72px;
        top: -2px;
    }
    .sign-matrix-grid .avatar-cell.shown::before {
        top: 34px;
        left: 34px;
        box-shadow:
            -32px -14px 0 0.5px rgba(0,210,255,0.9),
             26px -24px 0 0.5px rgba(123,47,247,0.8),
             32px   8px 0 0.5px rgba(255,0,128,0.7),
            -22px  28px 0 0.5px rgba(0,210,255,0.8),
              8px -32px 0 0.5px rgba(255,255,255,0.6),
            -28px   6px 0 0.5px rgba(123,47,247,0.7);
    }
    .sign-center-avatar .center-ring {
        width: 220px;
        height: 220px;
    }
    .sign-center-avatar .center-name {
        font-size: 22px;
    }
    .sign-matrix-grid .avatar-nick {
        font-size: 10px;
        max-width: 72px;
    }
    .sign-matrix-grid .grid-scroll-wrap {
        gap: 4px;
    }
    .sign-flying-avatar .flying-ring {
        width: 220px;
        height: 220px;
    }
}
