/* =============================================================================
   ACHIEVEMENTS PAGE - "Trophy Hall Museum" Redesign
   Premium collectible showcase with dramatic presentation
   ============================================================================= */

/* -----------------------------------------------------------------------------
   CUSTOM PROPERTIES - Refined Rarity System
   ----------------------------------------------------------------------------- */
:root {
    /* Rarity metallic palette */
    --ach-common: #71717a;
    --ach-common-shimmer: linear-gradient(135deg, #a1a1aa 0%, #71717a 50%, #d4d4d8 100%);
    --ach-common-glow: rgba(161, 161, 170, 0.3);

    --ach-uncommon: #2563eb;
    --ach-uncommon-shimmer: linear-gradient(135deg, #60a5fa 0%, #2563eb 50%, #93c5fd 100%);
    --ach-uncommon-glow: rgba(37, 99, 235, 0.4);

    --ach-rare: #7c3aed;
    --ach-rare-shimmer: linear-gradient(135deg, #a78bfa 0%, #7c3aed 50%, #c4b5fd 100%);
    --ach-rare-glow: rgba(124, 58, 237, 0.45);

    --ach-legendary: #d97706;
    --ach-legendary-shimmer: linear-gradient(135deg, #fbbf24 0%, #d97706 50%, #fcd34d 100%);
    --ach-legendary-glow: rgba(217, 119, 6, 0.5);

    /* Museum atmosphere */
    --ach-glass: rgba(255, 255, 255, 0.7);
    --ach-glass-border: rgba(255, 255, 255, 0.3);
    --ach-spotlight: radial-gradient(ellipse 600px 400px at var(--mouse-x, 50%) var(--mouse-y, 30%), rgba(251, 191, 36, 0.04) 0%, transparent 70%);

    /* Timing */
    --ach-ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ach-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-bs-theme="dark"],
body.dark-mode {
    --ach-glass: rgba(30, 41, 59, 0.8);
    --ach-glass-border: rgba(255, 255, 255, 0.08);

    /* Enhanced glows in dark mode */
    --ach-common-glow: rgba(161, 161, 170, 0.25);
    --ach-uncommon-glow: rgba(96, 165, 250, 0.35);
    --ach-rare-glow: rgba(167, 139, 250, 0.4);
    --ach-legendary-glow: rgba(251, 191, 36, 0.45);
}

/* -----------------------------------------------------------------------------
   PAGE CONTAINER - Museum Hall
   ----------------------------------------------------------------------------- */
.achievements-hall {
    position: relative;
    min-height: 100vh;
    padding: 0;
    overflow-x: hidden;
}

.achievements-hall::before {
    content: '';
    position: fixed;
    inset: 0;
    background: var(--ach-spotlight);
    pointer-events: none;
    z-index: 0;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

/* -----------------------------------------------------------------------------
   HERO HEADER - Grand Entrance
   ----------------------------------------------------------------------------- */
.achievements-hero {
    position: relative;
    padding: 4rem 0 3rem;
    text-align: center;
    margin-bottom: 2rem;
}

.achievements-hero::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 2px;
    background: var(--ach-legendary-shimmer);
    border-radius: 1px;
}

.achievements-title {
    font-size: clamp(2.5rem, 6vw, 4rem);
    font-weight: 900;
    letter-spacing: -0.03em;
    color: var(--theme-text-primary);
    margin-bottom: 0.5rem;
    line-height: 1;
}

.achievements-title-accent {
    display: block;
    font-size: 0.35em;
    font-weight: 500;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--theme-text-muted);
    margin-top: 0.75rem;
}

.achievements-flippy {
    max-width: 600px;
    margin: 1.5rem auto 0;
}

/* -----------------------------------------------------------------------------
   STATS RIBBON - Floating Progress Bar
   ----------------------------------------------------------------------------- */
.stats-ribbon {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--ach-glass);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--ach-glass-border);
    padding: 1rem 0;
    margin-bottom: 3rem;
    transition: box-shadow 0.3s ease;
}

.stats-ribbon.is-stuck {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.stats-ribbon-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3rem;
    flex-wrap: wrap;
}

.stat-block {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--theme-text-primary);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.stat-value--highlight {
    background: var(--ach-legendary-shimmer);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--theme-text-muted);
}

.progress-track {
    flex: 1;
    max-width: 300px;
    height: 6px;
    background: var(--theme-surface-3);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: var(--ach-legendary-shimmer);
    border-radius: 3px;
    position: relative;
    transition: width 1s var(--ach-ease-out-expo);
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.4) 50%, transparent 100%);
    animation: shimmer 2s infinite;
}

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

/* -----------------------------------------------------------------------------
   CATEGORY SECTION - Gallery Wing
   ----------------------------------------------------------------------------- */
.gallery-wing {
    margin-bottom: 4rem;
    animation: wing-enter 0.8s var(--ach-ease-out-expo) both;
}

.gallery-wing:nth-child(1) { animation-delay: 0s; }
.gallery-wing:nth-child(2) { animation-delay: 0.1s; }
.gallery-wing:nth-child(3) { animation-delay: 0.2s; }
.gallery-wing:nth-child(4) { animation-delay: 0.3s; }
.gallery-wing:nth-child(5) { animation-delay: 0.4s; }
.gallery-wing:nth-child(6) { animation-delay: 0.5s; }

@keyframes wing-enter {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wing-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--theme-border-color);
}

.wing-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--theme-surface-2);
    border-radius: 12px;
    font-size: 1.25rem;
    color: var(--ach-legendary);
    position: relative;
    overflow: hidden;
}

.wing-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 40%, rgba(255, 255, 255, 0.1) 50%, transparent 60%);
    transform: translateX(-100%);
}

.gallery-wing:hover .wing-icon::before {
    animation: icon-shine 0.6s ease;
}

@keyframes icon-shine {
    to { transform: translateX(100%); }
}

.wing-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--theme-text-primary);
    margin: 0;
    letter-spacing: -0.02em;
}

.wing-count {
    margin-left: auto;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--theme-text-muted);
    background: var(--theme-surface-2);
    padding: 0.4rem 1rem;
    border-radius: 100px;
}

/* -----------------------------------------------------------------------------
   TROPHY GRID - Exhibit Display
   ----------------------------------------------------------------------------- */
.trophy-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* -----------------------------------------------------------------------------
   TROPHY CARD - Individual Exhibit
   ----------------------------------------------------------------------------- */
.trophy-card {
    position: relative;
    background: var(--ach-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--ach-glass-border);
    border-radius: 20px;
    overflow: hidden;
    transition:
        transform 0.4s var(--ach-ease-out-expo),
        box-shadow 0.4s var(--ach-ease-out-expo);
    animation: card-reveal 0.6s var(--ach-ease-out-expo) both;
    animation-delay: calc(var(--card-index, 0) * 0.05s);
}

@keyframes card-reveal {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.trophy-card:hover {
    transform: translateY(-8px);
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.15),
        0 8px 16px rgba(0, 0, 0, 0.1);
}

/* Rarity ribbon - metallic edge accent */
.trophy-ribbon {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.trophy-ribbon--common { background: var(--ach-common-shimmer); }
.trophy-ribbon--uncommon { background: var(--ach-uncommon-shimmer); }
.trophy-ribbon--rare { background: var(--ach-rare-shimmer); }
.trophy-ribbon--legendary {
    background: var(--ach-legendary-shimmer);
    height: 4px;
}

/* Legendary pulse effect */
.trophy-card--legendary::before {
    content: '';
    position: absolute;
    inset: -1px;
    background: var(--ach-legendary-shimmer);
    border-radius: 20px;
    z-index: -1;
    opacity: 0;
    filter: blur(8px);
    transition: opacity 0.4s ease;
}

.trophy-card--legendary:hover::before {
    opacity: 0.5;
    animation: legendary-pulse 2s ease-in-out infinite;
}

@keyframes legendary-pulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.02); }
}

/* Locked state */
.trophy-card--locked {
    opacity: 0.65;
}

.trophy-card--locked .trophy-pedestal {
    filter: grayscale(0.7) brightness(0.85);
}

.trophy-card--locked:hover {
    transform: translateY(-4px);
    opacity: 0.8;
}

/* -----------------------------------------------------------------------------
   TROPHY PEDESTAL - Icon Display
   ----------------------------------------------------------------------------- */
.trophy-pedestal {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem 1rem;
}

.trophy-icon {
    position: relative;
    width: 100px;
    height: 100px;
    transition: transform 0.4s var(--ach-ease-spring);
}

.trophy-card:hover .trophy-icon {
    transform: scale(1.1) translateY(-4px);
}

.trophy-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
    transition: filter 0.4s ease;
    cursor: pointer;
}

/* Rarity-specific glow on hover */
.trophy-card--common:hover .trophy-icon img {
    filter: drop-shadow(0 0 20px var(--ach-common-glow)) drop-shadow(0 8px 16px rgba(0, 0, 0, 0.2));
}

.trophy-card--uncommon:hover .trophy-icon img {
    filter: drop-shadow(0 0 24px var(--ach-uncommon-glow)) drop-shadow(0 8px 16px rgba(0, 0, 0, 0.2));
}

.trophy-card--rare:hover .trophy-icon img {
    filter: drop-shadow(0 0 28px var(--ach-rare-glow)) drop-shadow(0 8px 16px rgba(0, 0, 0, 0.2));
}

.trophy-card--legendary:hover .trophy-icon img {
    filter: drop-shadow(0 0 32px var(--ach-legendary-glow)) drop-shadow(0 8px 16px rgba(0, 0, 0, 0.2));
}

/* Unlocked badge */
.trophy-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--theme-success), #059669);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    box-shadow:
        0 2px 8px rgba(16, 185, 129, 0.4),
        0 0 0 2px var(--ach-glass);
    animation: badge-pop 0.5s var(--ach-ease-spring) both;
}

@keyframes badge-pop {
    0% { transform: scale(0) rotate(-180deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* -----------------------------------------------------------------------------
   TROPHY INFO - Details Section
   ----------------------------------------------------------------------------- */
.trophy-info {
    padding: 0 1.5rem 1.25rem;
    text-align: center;
}

.trophy-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--theme-text-primary);
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.trophy-desc {
    font-size: 0.85rem;
    color: var(--theme-text-secondary);
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

.trophy-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--theme-text-muted);
}

.trophy-meta i {
    font-size: 0.7rem;
    opacity: 0.7;
}

.trophy-unlock-date {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--theme-success);
    margin-top: 0.5rem;
}

.trophy-event {
    font-size: 0.75rem;
    color: var(--theme-text-muted);
    font-style: italic;
}

/* -----------------------------------------------------------------------------
   TROPHY ACTIONS - Footer Buttons
   ----------------------------------------------------------------------------- */
.trophy-actions {
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--ach-glass-border);
    display: flex;
    gap: 0.5rem;
}

.trophy-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
}

.trophy-btn--primary {
    background: linear-gradient(135deg, var(--theme-primary), var(--theme-info));
    color: white;
}

.trophy-btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 166, 156, 0.35);
    color: white;
}

.trophy-btn--secondary {
    background: var(--theme-surface-2);
    color: var(--theme-text-secondary);
}

.trophy-btn--secondary:hover {
    background: var(--theme-surface-3);
    color: var(--theme-text-primary);
}

.trophy-btn:disabled,
.trophy-btn--disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* -----------------------------------------------------------------------------
   LEADERBOARD - Hall of Fame
   ----------------------------------------------------------------------------- */
.hall-of-fame {
    margin-top: 5rem;
    margin-bottom: 3rem;
}

.fame-container {
    max-width: 700px;
    margin: 0 auto;
    background: var(--ach-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--ach-glass-border);
    border-radius: 24px;
    overflow: hidden;
}

.fame-header {
    background: linear-gradient(135deg, rgba(217, 119, 6, 0.1) 0%, rgba(124, 58, 237, 0.05) 100%);
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--ach-glass-border);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.fame-icon {
    font-size: 1.5rem;
    color: var(--ach-legendary);
}

.fame-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--theme-text-primary);
    margin: 0;
}

.fame-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fame-entry {
    display: flex;
    align-items: center;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--theme-border-color);
    transition: background-color 0.2s ease;
}

.fame-entry:last-child {
    border-bottom: none;
}

.fame-entry:hover {
    background: var(--theme-surface-2);
}

.fame-rank {
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--theme-text-muted);
}

.fame-rank--gold {
    color: #fbbf24;
    font-size: 1.25rem;
}

.fame-rank--silver {
    color: #94a3b8;
    font-size: 1.2rem;
}

.fame-rank--bronze {
    color: #d97706;
    font-size: 1.15rem;
}

.fame-player {
    flex: 1;
    margin-left: 0.5rem;
}

.fame-player a {
    color: var(--theme-text-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.fame-player a:hover {
    color: var(--theme-primary);
}

.fame-count {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: linear-gradient(135deg, var(--theme-primary), var(--theme-info));
    color: white;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.4rem 0.9rem;
    border-radius: 100px;
}

.fame-count-label {
    font-size: 0.7rem;
    font-weight: 500;
    opacity: 0.9;
}

/* CTA for unauthenticated users */
.fame-cta {
    padding: 2rem;
    text-align: center;
    background: var(--theme-surface-2);
    border-top: 1px solid var(--ach-glass-border);
}

.fame-cta p {
    margin-bottom: 1rem;
    color: var(--theme-text-secondary);
}

.fame-cta-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* -----------------------------------------------------------------------------
   MODAL ENHANCEMENTS
   ----------------------------------------------------------------------------- */
.modal .trophy-icon {
    width: 140px;
    height: 140px;
    margin: 0 auto 1.5rem;
}

.modal .trophy-icon img {
    width: 100%;
    height: 100%;
}

/* -----------------------------------------------------------------------------
   RESPONSIVE - Mobile Gallery
   ----------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    .stats-ribbon-inner {
        gap: 1.5rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .progress-track {
        max-width: 200px;
    }
}

@media (max-width: 767.98px) {
    .achievements-hero {
        padding: 3rem 0 2rem;
    }

    .achievements-title {
        font-size: 2.25rem;
    }

    .stats-ribbon {
        padding: 0.875rem 0;
    }

    .stats-ribbon-inner {
        gap: 1rem;
        justify-content: space-around;
    }

    .stat-block {
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    .progress-track {
        display: none;
    }

    .wing-header {
        flex-wrap: wrap;
    }

    .wing-count {
        margin-left: 0;
        margin-top: 0.5rem;
        width: 100%;
        text-align: center;
    }

    .trophy-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 1rem;
    }

    .trophy-icon {
        width: 80px;
        height: 80px;
    }

    .fame-entry {
        padding: 0.875rem 1.25rem;
    }

    .fame-count-label {
        display: none;
    }
}

@media (max-width: 575.98px) {
    .achievements-title {
        font-size: 1.875rem;
    }

    .wing-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .wing-title {
        font-size: 1.2rem;
    }

    .trophy-grid {
        grid-template-columns: 1fr;
    }

    .trophy-actions {
        flex-direction: column;
    }
}

/* -----------------------------------------------------------------------------
   REDUCED MOTION
   ----------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .trophy-card,
    .gallery-wing,
    .trophy-icon,
    .trophy-badge,
    .progress-fill::after,
    .wing-icon::before,
    .trophy-card--legendary::before {
        animation: none !important;
        transition: none !important;
    }
}

/* -----------------------------------------------------------------------------
   DARK MODE POLISH
   ----------------------------------------------------------------------------- */
[data-bs-theme="dark"] .trophy-card,
body.dark-mode .trophy-card {
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

[data-bs-theme="dark"] .trophy-card:hover,
body.dark-mode .trophy-card:hover {
    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.4),
        0 12px 24px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .fame-container,
body.dark-mode .fame-container {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .trophy-card--legendary:hover::before,
body.dark-mode .trophy-card--legendary:hover::before {
    opacity: 0.4;
}

/* Intensified glows in dark mode */
[data-bs-theme="dark"] .trophy-card--legendary:hover .trophy-icon img,
body.dark-mode .trophy-card--legendary:hover .trophy-icon img {
    filter:
        drop-shadow(0 0 40px var(--ach-legendary-glow))
        drop-shadow(0 0 60px var(--ach-legendary-glow))
        drop-shadow(0 8px 16px rgba(0, 0, 0, 0.3));
}

[data-bs-theme="dark"] .trophy-card--rare:hover .trophy-icon img,
body.dark-mode .trophy-card--rare:hover .trophy-icon img {
    filter:
        drop-shadow(0 0 32px var(--ach-rare-glow))
        drop-shadow(0 0 48px var(--ach-rare-glow))
        drop-shadow(0 8px 16px rgba(0, 0, 0, 0.3));
}
