/* =============================================
   badge.bar v2 - Y2K Chrome Holographic Vault
   ============================================= */

/* --- CSS Custom Properties --- */
:root {
    --chrome-silver: #C0C0C0;
    --liquid-mercury: #E8E8E8;
    --deep-obsidian: #0A0A14;
    --holo-magenta: #FF2D9B;
    --holo-cyan: #00E5FF;
    --holo-gold: #FFD700;
    --foil-green: #39FF14;
    --brushed-gunmetal: #2C2C3A;
    --chrome-white: #FFFFFF;
    --chrome-dark: #808080;

    --hex-size: clamp(120px, 15vw, 200px);
    --hex-gap: 4px;

    --mouse-x: 50%;
    --mouse-y: 50%;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--deep-obsidian);
    color: var(--liquid-mercury);
    font-family: 'Exo 2', sans-serif;
    font-weight: 400;
    font-size: clamp(14px, 1.2vw, 18px);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    position: relative;
}

/* --- Scan-line CRT overlay --- */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 1px,
        rgba(0, 0, 0, 0.03) 1px,
        rgba(0, 0, 0, 0.03) 2px
    );
    opacity: 0.4;
    pointer-events: none;
    z-index: 10000;
}

/* --- Chrome Meta-Frame --- */
#chrome-frame {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

#chrome-border-top,
#chrome-border-bottom,
#chrome-border-left,
#chrome-border-right {
    position: absolute;
    background: linear-gradient(135deg, var(--chrome-silver), var(--chrome-white), var(--chrome-dark));
}

#chrome-border-top {
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    animation: borderDrawHorizontal 400ms 200ms ease-out forwards;
}

#chrome-border-bottom {
    bottom: 0;
    left: 0;
    height: 3px;
    width: 0%;
    animation: borderDrawHorizontal 300ms 900ms ease-out forwards;
}

#chrome-border-left {
    top: 0;
    left: 0;
    width: 3px;
    height: 0%;
    animation: borderDrawVertical 300ms 600ms ease-out forwards;
}

#chrome-border-right {
    top: 0;
    right: 0;
    width: 3px;
    height: 0%;
    animation: borderDrawVertical 300ms 600ms ease-out forwards;
}

@keyframes borderDrawHorizontal {
    from { width: 0%; }
    to { width: 100%; }
}

@keyframes borderDrawVertical {
    from { height: 0%; }
    to { height: 100%; }
}

/* --- Chrome Title Bar --- */
#chrome-titlebar {
    position: fixed;
    top: 3px;
    left: 3px;
    right: 3px;
    height: 42px;
    background: linear-gradient(180deg, #D8D8D8 0%, var(--chrome-silver) 40%, #A0A0A0 100%);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 12px;
    z-index: 101;
    pointer-events: none;
    opacity: 0;
    animation: fadeIn 200ms 800ms ease forwards;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.6),
        inset 0 -1px 0 rgba(0, 0, 0, 0.2),
        0 2px 4px rgba(0, 0, 0, 0.3);
}

#window-controls {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.window-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    opacity: 0;
    transform: scale(0);
}

.dot-close {
    background: #FF5F57;
    box-shadow: inset 0 -1px 1px rgba(0, 0, 0, 0.2);
    animation: dotBounce 300ms 900ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.dot-minimize {
    background: #FFBD2E;
    box-shadow: inset 0 -1px 1px rgba(0, 0, 0, 0.2);
    animation: dotBounce 300ms 1000ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.dot-maximize {
    background: #28CA41;
    box-shadow: inset 0 -1px 1px rgba(0, 0, 0, 0.2);
    animation: dotBounce 300ms 1100ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes dotBounce {
    from { opacity: 0; transform: scale(0); }
    to { opacity: 1; transform: scale(1); }
}

#address-bar {
    flex: 1;
    height: 26px;
    background: var(--chrome-white);
    border: 1px solid #999;
    border-radius: 3px;
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 13px;
    color: var(--deep-obsidian);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

#address-text {
    white-space: nowrap;
}

#address-cursor {
    animation: cursorBlink 600ms steps(2) infinite;
    color: var(--deep-obsidian);
    font-weight: bold;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

#status-indicators {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.status-indicator {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    color: var(--deep-obsidian);
    display: flex;
    align-items: center;
    gap: 4px;
    letter-spacing: 0.05em;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-dot.online {
    background: var(--foil-green);
    animation: statusBlink 2s ease-in-out infinite;
}

.status-dot.connected {
    background: var(--holo-cyan);
    animation: statusBlink 2.5s ease-in-out infinite 0.5s;
}

@keyframes statusBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- Logotype --- */
#logotype-container {
    position: relative;
    z-index: 50;
    text-align: center;
    padding-top: 70px;
    padding-bottom: 30px;
}

#logotype {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: clamp(24px, 5vw, 72px);
    letter-spacing: 0.15em;
    background: linear-gradient(135deg, var(--chrome-silver), var(--chrome-white), var(--chrome-dark));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
    display: inline-block;
    position: relative;
    opacity: 0;
    animation: logoAppear 600ms 1400ms ease forwards;
}

#logotype::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--holo-gold), transparent);
    opacity: 0.6;
}

@keyframes logoAppear {
    from {
        opacity: 0;
        filter: blur(8px);
    }
    to {
        opacity: 1;
        filter: blur(0);
    }
}

/* --- Loading bar (decorative) --- */
#loading-bar-container {
    width: 200px;
    height: 6px;
    margin: 12px auto 0;
    background: var(--brushed-gunmetal);
    border: 1px solid var(--chrome-dark);
    border-radius: 3px;
    overflow: hidden;
    opacity: 0;
    animation: fadeIn 300ms 2000ms ease forwards;
}

#loading-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--foil-green), var(--holo-cyan));
    animation: loadingFill 3s 2200ms linear infinite;
}

@keyframes loadingFill {
    0% { width: 0%; }
    90% { width: 100%; }
    100% { width: 0%; }
}

/* --- Honeycomb Gallery --- */
#honeycomb-gallery {
    position: relative;
    z-index: 10;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 40px 80px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0;
}

.hex-row {
    display: flex;
    justify-content: center;
    gap: var(--hex-gap);
    width: 100%;
}

.hex-row:nth-child(even) {
    margin-top: calc(var(--hex-size) * -0.25);
    margin-left: calc(var(--hex-size) * 0.5 + var(--hex-gap) / 2);
}

.hex-row:nth-child(odd) {
    margin-top: calc(var(--hex-size) * -0.25);
}

.hex-row:first-child {
    margin-top: 0;
}

/* --- Hexagon Badge --- */
.hex-badge {
    width: var(--hex-size);
    height: calc(var(--hex-size) * 1.1547);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 150ms ease, filter 150ms ease;
    opacity: 0;
    transform: scale(0);
}

.hex-badge.visible {
    animation: hexAppear 500ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes hexAppear {
    from {
        opacity: 0;
        transform: scale(0);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.hex-badge:hover {
    transform: scale(1.05);
    z-index: 20;
}

.hex-badge-inner {
    width: 100%;
    height: 100%;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--brushed-gunmetal);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.hex-badge-inner::before {
    content: '';
    position: absolute;
    inset: 3px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: linear-gradient(135deg, var(--chrome-silver), var(--chrome-white), var(--chrome-dark));
    z-index: 0;
}

.hex-badge-inner::after {
    content: '';
    position: absolute;
    inset: 5px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--brushed-gunmetal);
    z-index: 1;
}

/* Badge icon content */
.hex-badge-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px;
    width: 100%;
    height: 100%;
}

.badge-icon {
    font-size: calc(var(--hex-size) * 0.3);
    line-height: 1;
    margin-bottom: 4px;
}

.badge-label {
    font-family: 'Orbitron', sans-serif;
    font-weight: 500;
    font-size: clamp(8px, 0.8vw, 11px);
    letter-spacing: 0.1em;
    color: var(--liquid-mercury);
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90%;
}

/* Holographic foil overlay */
.hex-foil-overlay {
    position: absolute;
    inset: 0;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: conic-gradient(
        from calc(var(--foil-angle, 0) * 1deg),
        var(--holo-magenta),
        var(--holo-cyan),
        var(--holo-gold),
        var(--foil-green),
        var(--holo-magenta)
    );
    opacity: 0.3;
    transition: opacity 200ms ease;
    z-index: 3;
    pointer-events: none;
    mix-blend-mode: overlay;
}

.hex-badge:hover .hex-foil-overlay {
    opacity: 0.6;
}

/* Rarity border glow */
.hex-badge::after {
    content: '';
    position: absolute;
    inset: -4px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    opacity: 0;
    transition: opacity 200ms ease;
    z-index: -1;
    filter: blur(8px);
}

.hex-badge:hover::after {
    opacity: 0.4;
}

.hex-badge[data-rarity="S"]::after { background: var(--holo-magenta); }
.hex-badge[data-rarity="A"]::after { background: var(--holo-cyan); }
.hex-badge[data-rarity="B"]::after { background: var(--holo-gold); }
.hex-badge[data-rarity="C"]::after { background: var(--foil-green); }

.hex-badge[data-rarity="S"] .hex-badge-inner::before {
    background: linear-gradient(135deg, var(--holo-magenta), var(--chrome-silver), var(--holo-magenta));
}
.hex-badge[data-rarity="A"] .hex-badge-inner::before {
    background: linear-gradient(135deg, var(--holo-cyan), var(--chrome-silver), var(--holo-cyan));
}
.hex-badge[data-rarity="B"] .hex-badge-inner::before {
    background: linear-gradient(135deg, var(--holo-gold), var(--chrome-silver), var(--holo-gold));
}
.hex-badge[data-rarity="C"] .hex-badge-inner::before {
    background: linear-gradient(135deg, var(--foil-green), var(--chrome-silver), var(--foil-green));
}

/* Glint animation */
.hex-glint {
    position: absolute;
    inset: 0;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    z-index: 4;
    pointer-events: none;
    overflow: hidden;
}

.hex-glint::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        -45deg,
        transparent 40%,
        rgba(255, 255, 255, 0.5) 49%,
        rgba(255, 255, 255, 0.5) 51%,
        transparent 60%
    );
    transform: translateX(-100%);
    opacity: 0;
}

.hex-badge.glinting .hex-glint::before {
    animation: glintSweep 0.6s ease forwards;
}

@keyframes glintSweep {
    0% { transform: translateX(-100%); opacity: 1; }
    100% { transform: translateX(100%); opacity: 0; }
}

/* --- Badge Detail Overlay --- */
#badge-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 300ms ease;
}

#badge-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 20, 0.85);
    cursor: pointer;
}

#overlay-content {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 40px;
    align-items: center;
    max-width: 900px;
    width: 90%;
    padding: 40px;
}

#overlay-badge-container {
    flex-shrink: 0;
    perspective: 1000px;
}

#overlay-badge {
    width: 280px;
    height: 323px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--brushed-gunmetal);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: badgeRotate 8s linear infinite;
    transform-style: preserve-3d;
}

#overlay-badge .hex-foil-overlay {
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    opacity: 0.5;
}

@keyframes badgeRotate {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(360deg); }
}

#overlay-badge-icon {
    font-size: 80px;
    position: relative;
    z-index: 2;
}

#overlay-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chrome-panel {
    background: var(--brushed-gunmetal);
    border: 2px solid var(--chrome-silver);
    padding: 16px 20px;
    box-shadow:
        inset 2px 2px 0 rgba(255, 255, 255, 0.15),
        inset -2px -2px 0 rgba(0, 0, 0, 0.3),
        0 4px 12px rgba(0, 0, 0, 0.5);
}

.chrome-panel h2 {
    font-family: 'Orbitron', sans-serif;
    font-weight: 500;
    font-size: clamp(16px, 2vw, 24px);
    letter-spacing: 0.15em;
    color: var(--chrome-white);
    margin-bottom: 4px;
}

#overlay-rarity-tag {
    display: inline-block;
    font-family: 'Share Tech Mono', monospace;
    font-size: 13px;
    letter-spacing: 0.05em;
    padding: 2px 10px;
    border: 1px solid;
    margin-top: 8px;
}

.rarity-S { color: var(--holo-magenta); border-color: var(--holo-magenta); }
.rarity-A { color: var(--holo-cyan); border-color: var(--holo-cyan); }
.rarity-B { color: var(--holo-gold); border-color: var(--holo-gold); }
.rarity-C { color: var(--foil-green); border-color: var(--foil-green); }

.chrome-panel p {
    font-family: 'Exo 2', sans-serif;
    font-weight: 400;
    font-size: clamp(14px, 1.2vw, 18px);
    line-height: 1.6;
    color: var(--liquid-mercury);
}

.stats-panel .stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid rgba(192, 192, 192, 0.15);
}

.stats-panel .stat-row:last-child {
    border-bottom: none;
}

.stat-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 13px;
    letter-spacing: 0.05em;
    color: var(--chrome-dark);
}

.stat-value {
    font-family: 'Share Tech Mono', monospace;
    font-size: 13px;
    letter-spacing: 0.05em;
    color: var(--liquid-mercury);
}

#overlay-close {
    font-family: 'Share Tech Mono', monospace;
    font-size: 13px;
    letter-spacing: 0.1em;
    background: transparent;
    color: var(--chrome-silver);
    border: 1px solid var(--chrome-silver);
    padding: 10px 24px;
    cursor: pointer;
    transition: background 200ms, color 200ms;
    align-self: flex-start;
    margin-top: 8px;
}

#overlay-close:hover {
    background: var(--chrome-silver);
    color: var(--deep-obsidian);
}

/* Particle burst */
#particle-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 502;
}

.particle {
    position: absolute;
    border-radius: 50%;
    animation: particleBurst var(--duration) ease-out forwards;
    opacity: 1;
}

@keyframes particleBurst {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0.5);
        opacity: 0;
    }
}

/* --- Rarity Ticker Strip --- */
#rarity-ticker {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: linear-gradient(180deg, var(--brushed-gunmetal), #1a1a2a);
    border-top: 2px solid var(--chrome-silver);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 -2px 8px rgba(0, 0, 0, 0.5);
    z-index: 200;
    overflow: hidden;
    display: flex;
    align-items: center;
    opacity: 0;
    animation: fadeIn 400ms 2500ms ease forwards;
}

#ticker-content {
    display: flex;
    gap: 40px;
    white-space: nowrap;
    animation: tickerScroll 30s linear infinite;
    padding-left: 100%;
}

@keyframes tickerScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.ticker-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 13px;
    letter-spacing: 0.05em;
    color: var(--liquid-mercury);
    flex-shrink: 0;
}

.ticker-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.ticker-rarity {
    font-weight: bold;
}

.ticker-rarity-S { color: var(--holo-magenta); }
.ticker-rarity-A { color: var(--holo-cyan); }
.ticker-rarity-B { color: var(--holo-gold); }
.ticker-rarity-C { color: var(--foil-green); }

.ticker-time {
    color: var(--chrome-dark);
    font-size: 11px;
}

.ticker-divider {
    color: var(--chrome-dark);
    margin: 0 4px;
}

/* --- Decorative Fake UI Elements --- */
#fake-ui-elements {
    position: fixed;
    z-index: 90;
    pointer-events: none;
}

.fake-scrollbar {
    position: fixed;
    right: 8px;
    top: 60px;
    bottom: 60px;
    width: 10px;
    background: var(--brushed-gunmetal);
    border: 1px solid var(--chrome-dark);
    border-radius: 5px;
    z-index: 90;
    opacity: 0;
    animation: fadeIn 400ms 2800ms ease forwards;
}

.fake-scrollbar-thumb {
    position: absolute;
    top: 10%;
    left: 1px;
    right: 1px;
    height: 20%;
    background: linear-gradient(180deg, var(--chrome-silver), var(--chrome-dark));
    border-radius: 4px;
    animation: fakeScroll 6s ease-in-out infinite;
}

@keyframes fakeScroll {
    0%, 100% { top: 10%; }
    50% { top: 70%; }
}

.fake-spinner {
    position: fixed;
    bottom: 60px;
    right: 30px;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top-color: var(--holo-cyan);
    border-right-color: var(--holo-cyan);
    border-radius: 50%;
    z-index: 90;
    opacity: 0;
    animation: fadeIn 400ms 3000ms ease forwards, spin 1s 3000ms linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.fake-progress {
    position: fixed;
    bottom: 60px;
    left: 30px;
    width: 100px;
    height: 4px;
    background: var(--brushed-gunmetal);
    border: 1px solid var(--chrome-dark);
    border-radius: 2px;
    z-index: 90;
    overflow: hidden;
    opacity: 0;
    animation: fadeIn 400ms 3000ms ease forwards;
}

.fake-progress-fill {
    width: 0%;
    height: 100%;
    background: var(--foil-green);
    animation: loadingFill 4s ease-in-out infinite;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    #overlay-content {
        flex-direction: column;
        padding: 20px;
        gap: 20px;
    }

    #overlay-badge {
        width: 180px;
        height: 208px;
    }

    #status-indicators {
        display: none;
    }

    .fake-scrollbar,
    .fake-spinner,
    .fake-progress {
        display: none;
    }

    #honeycomb-gallery {
        padding: 20px 10px 80px;
    }
}

@media (max-width: 480px) {
    #address-bar {
        display: none;
    }
}
