/* Logo hạng kiểu F: thẻ hologram nổi 3D, mỗi hạng một hiệu ứng riêng.
   HTML do tierBadgeSvg (tier-badge.js) / tier_badge (_tier_badge.html) tạo:
   .tb (khung: dày 3D, hào quang, lơ lửng) > [.tb-ring premium] .tb-face (mặt thẻ) > hiệu ứng + .tb-emb + .tb-txt.
   Màu kim loại tính từ màu hạng admin đặt (--tb-c). */
.tb {
    --hi: color-mix(in srgb, var(--tb-c) 45%, #FFFFFF);
    --lo: color-mix(in srgb, var(--tb-c) 62%, #000000);
    --edge: color-mix(in srgb, var(--tb-c) 40%, #000000);
    --glow: color-mix(in srgb, var(--tb-c) 70%, transparent);
    --glow0: color-mix(in srgb, var(--tb-c) 0%, transparent);
    --tx: #FFFFFF;
    --ts: 0 -1px 0 rgba(0, 0, 0, .5);
    position: relative; display: inline-flex; box-sizing: border-box; vertical-align: middle; flex-shrink: 0;
    overflow: hidden; line-height: 1; white-space: nowrap; user-select: none;
    font-family: Inter, system-ui, sans-serif; color: var(--tx);
    box-shadow: var(--thick);
    animation: tb-aura 2.6s ease-in-out infinite;
}
.tb.tb-light { --tx: color-mix(in srgb, var(--tb-c) 22%, #1C1400); --ts: 0 1px 0 rgba(255, 255, 255, .65); }

.tb-face { position: relative; flex: 1; display: flex; align-items: center; overflow: hidden; border-radius: inherit;
    background: linear-gradient(135deg, var(--hi) 0%, var(--tb-c) 50%, var(--lo) 100%); }
.tb-face::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .75), inset 0 0 0 1px rgba(255, 255, 255, .25); }

/* Nhũ hologram chạy */
.tb-foil { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: overlay;
    background: linear-gradient(110deg, rgba(255,255,255,0) 20%, rgba(255,255,255,.9) 34%, rgba(255,255,255,0) 48%, rgba(255,255,255,.55) 64%, rgba(255,255,255,0) 80%);
    background-size: 220% 100%; animation: tb-foil 3s linear infinite; }

/* Biểu tượng: đồng xu lật mỗi 6 giây */
.tb-emb { position: relative; display: flex; align-items: center; justify-content: center; flex-shrink: 0; border-radius: 50%;
    color: #FFFFFF;
    background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.55), rgba(255,255,255,.1) 45%, rgba(0,0,0,.25) 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.7), inset 0 -2px 4px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.3);
    animation: tb-flip 6s ease-in-out infinite; }
.tb-emb svg { display: block; filter: drop-shadow(0 1px 0 rgba(0,0,0,.4)); }
.tb-txt { position: relative; display: flex; flex-direction: column; }
.tb-name { font-weight: 900; letter-spacing: .08em; text-shadow: var(--ts); }
.tb-micro { font-weight: 700; letter-spacing: .18em; opacity: .8; }

/* Đồng: tia lửa bay lên */
.tb-ember { position: absolute; bottom: 2px; width: 4px; height: 4px; border-radius: 50%; pointer-events: none;
    background: radial-gradient(circle, #FFF3C4 0%, #FFA94D 50%, rgba(255,120,30,0) 70%); animation: tb-ember 2.2s ease-out infinite; }
.tb-ember:nth-last-child(4) { left: 22%; --dx: -4px; }
.tb-ember:nth-last-child(3) { left: 48%; --dx: 5px; animation-delay: .7s; }
.tb-ember:nth-last-child(2) { left: 70%; --dx: -2px; animation-delay: 1.3s; }
.tb-ember:nth-last-child(1) { left: 86%; --dx: 3px; animation-delay: 1.8s; }

/* Bạc, Premium: lấp lánh */
.tb-glint { position: absolute; width: 8px; height: 8px; pointer-events: none; animation: tb-twinkle 1.9s ease-in-out infinite; }
.tb-glint::before, .tb-glint::after { content: ""; position: absolute; left: 50%; top: 50%; background: #F0F9FF; border-radius: 2px;
    transform: translate(-50%, -50%); box-shadow: 0 0 5px #BAE6FD; }
.tb-glint::before { width: 1.5px; height: 8px; } .tb-glint::after { width: 8px; height: 1.5px; }
.tb-glint:nth-last-child(4) { left: 30%; top: 3px; }
.tb-glint:nth-last-child(3) { left: 62%; bottom: 3px; animation-delay: .6s; }
.tb-glint:nth-last-child(2) { left: 84%; top: 4px; animation-delay: 1.2s; }
.tb-glint:nth-last-child(1) { left: 12%; bottom: 2px; animation-delay: 1.5s; }
.tb-premium .tb-glint::before, .tb-premium .tb-glint::after { background: #FFFBEB; box-shadow: 0 0 5px #FDE68A; }

/* Vàng: hào quang tỏa tia quanh vương miện */
.tb-rays { position: absolute; left: -56px; top: 50%; width: 150px; height: 150px; margin-top: -75px; pointer-events: none;
    background: repeating-conic-gradient(from 0deg, rgba(255,255,255,.55) 0deg 7deg, rgba(255,255,255,0) 7deg 22deg);
    mix-blend-mode: overlay; animation: tb-spin 9s linear infinite;
    -webkit-mask: radial-gradient(circle, #000 20%, transparent 68%); mask: radial-gradient(circle, #000 20%, transparent 68%); }

/* Premium: viền cầu vồng xoay + cực quang */
.tb-ring { position: absolute; left: 50%; top: 50%; width: 300px; height: 300px; margin: -150px 0 0 -150px; pointer-events: none;
    background: conic-gradient(#F472B6, #FBBF24, #34D399, #60A5FA, #A78BFA, #F472B6); animation: tb-spin 3s linear infinite; }
.tb-premium { padding: 2px; }
.tb-premium .tb-face { border-radius: calc(var(--r) - 2px); }
.tb-premium { --tx: #FDF4D7; --ts: 0 0 8px rgba(253,230,138,.7), 0 -1px 0 rgba(0,0,0,.5); }
.tb-aur { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: screen;
    background: linear-gradient(120deg, rgba(236,72,153,.55), rgba(99,102,241,.2), rgba(20,184,166,.5), rgba(168,85,247,.45), rgba(236,72,153,.55));
    background-size: 300% 100%; animation: tb-aurora 6s ease-in-out infinite; }

/* Cỡ nhỏ: dưới tên tài khoản, danh sách */
.tb-sm { --r: 6px; border-radius: var(--r); height: 20px; margin: 0 3px 3px 0;
    --thick: 1px 1px 0 var(--edge), 2px 2px 0 var(--edge), 3px 4px 6px rgba(15, 23, 42, .25); }
.tb-sm .tb-face { gap: 4px; padding: 0 7px 0 2px; }
.tb-sm .tb-emb { width: 16px; height: 16px; }
.tb-sm .tb-emb svg { width: 9px; height: 9px; }
.tb-sm .tb-name { font-size: 9.5px; }
.tb-sm .tb-ember { width: 3px; height: 3px; }
.tb-sm .tb-glint { width: 6px; height: 6px; }
.tb-sm .tb-glint::before { height: 6px; width: 1.2px; } .tb-sm .tb-glint::after { width: 6px; height: 1.2px; }
.tb-sm .tb-rays { left: -28px; width: 74px; height: 74px; margin-top: -37px; }
.tb-sm.tb-premium { padding: 1.5px; }
.tb-sm.tb-premium .tb-face { border-radius: calc(var(--r) - 1.5px); }

/* Cỡ vừa */
.tb-md { --r: 7px; border-radius: var(--r); height: 26px; margin: 0 4px 4px 0;
    --thick: 1px 1px 0 var(--edge), 2px 2px 0 var(--edge), 3px 3px 0 var(--edge), 5px 7px 10px rgba(15, 23, 42, .25); }
.tb-md .tb-face { gap: 6px; padding: 0 10px 0 3px; }
.tb-md .tb-emb { width: 20px; height: 20px; }
.tb-md .tb-emb svg { width: 12px; height: 12px; }
.tb-md .tb-name { font-size: 11px; }
.tb-md .tb-rays { left: -40px; width: 104px; height: 104px; margin-top: -52px; }

/* Cỡ lớn: thẻ nghiêng lơ lửng, di chuột thì xoay thẳng */
.tb-lg { --r: 10px; border-radius: var(--r); height: 48px; min-width: 136px; margin: 4px 8px 10px 0;
    --thick: 1px 1px 0 var(--edge), 2px 2px 0 var(--edge), 3px 3px 0 var(--edge), 4px 4px 0 var(--edge), 8px 12px 16px rgba(15, 23, 42, .3);
    animation: tb-float 4s ease-in-out infinite, tb-aura 2.6s ease-in-out infinite; transition: transform .3s ease; }
.tb-lg:hover { animation-play-state: paused; transform: perspective(500px) rotateX(0) rotateY(0) scale(1.05); }
.tb-lg .tb-face { gap: 9px; padding: 0 13px 0 8px; }
.tb-lg .tb-emb { width: 30px; height: 30px; }
.tb-lg .tb-emb svg { width: 17px; height: 17px; }
.tb-lg .tb-txt { gap: 3px; }
.tb-lg .tb-micro { font-size: 6.5px; }
.tb-lg .tb-name { font-size: 13px; }

/* Dùng thử: giấy trắng viền nét đứt, đồng hồ cát, đứng yên */
.tb-free { --tx: #475569; box-shadow: none; animation: none; }
.tb-free .tb-face { background: #FFFFFF; border: 1.5px dashed var(--tb-c); }
.tb-free .tb-face::after { display: none; }
.tb-free .tb-name { text-shadow: none; }
.tb-free .tb-emb { color: #64748B; background: #F1F5F9; box-shadow: inset 0 0 0 1px #CBD5E1; animation: none; }
.tb-free.tb-lg { transform: perspective(500px) rotateX(10deg) rotateY(-14deg); box-shadow: 6px 10px 16px rgba(15, 23, 42, .12); }

@keyframes tb-foil { 0% { background-position: 0% 50%; } 100% { background-position: 220% 50%; } }
@keyframes tb-flip { 0%, 72% { transform: perspective(200px) rotateY(0); } 88%, 100% { transform: perspective(200px) rotateY(360deg); } }
@keyframes tb-aura { 0%, 100% { box-shadow: var(--thick), 0 0 0 0 var(--glow0); } 50% { box-shadow: var(--thick), 0 0 16px 3px var(--glow); } }
@keyframes tb-ember { 0% { transform: translateY(0) scale(1); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateY(-40px) translateX(var(--dx, 4px)) scale(.3); opacity: 0; } }
@keyframes tb-twinkle { 0%, 100% { opacity: 0; transform: scale(.2) rotate(0); } 50% { opacity: 1; transform: scale(1) rotate(45deg); } }
@keyframes tb-spin { to { transform: rotate(360deg); } }
@keyframes tb-aurora { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@keyframes tb-float {
    0%, 100% { transform: perspective(500px) rotateX(10deg) rotateY(-14deg) translateY(0); }
    50% { transform: perspective(500px) rotateX(5deg) rotateY(-5deg) translateY(-3px); }
}

/* Danh sách dài (admin): bản đứng yên cho đỡ rối mắt */
.tb-still .tb, .tb-still .tb * { animation: none !important; }
.tb-still .tb-ember, .tb-still .tb-glint { display: none; }

@media (prefers-reduced-motion: reduce) {
    .tb, .tb * { animation: none !important; }
    .tb-ember, .tb-glint { display: none; }
    .tb-lg:not(.tb-free) { transform: perspective(500px) rotateX(8deg) rotateY(-10deg); }
}
