/* Core Premium Glassmorphism & Tokens */
:root {
    --bg-glass: rgba(0, 0, 0, 0.5);
    --border-glass: rgba(255, 255, 255, 0.08);
    --accent-vibrant: #ff3366; 
    --text-primary: #ffffff;
    --text-muted: #a0a0a0;
}

.glass-card {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    color: var(--text-primary);
}

.text-gradient {
    background: linear-gradient(90deg, #fff, #ff3366);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Step 1: Preview Dashboard Component */
.achievements-preview-container {
    padding: 16px;
    margin: 20px 0;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.achievements-preview-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 51, 102, 0.15);
}

.achievements-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.view-all-text {
    font-size: 0.85rem;
    color: var(--accent-vibrant);
    font-weight: 600;
}

.achievements-scroll-row {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scrollbar-width: none; /* Hide scrollbar Firefox */
}
.achievements-scroll-row::-webkit-scrollbar { display: none; } /* Hide Webkit */

.preview-badge-wrapper {
    position: relative;
    flex-shrink: 0;
}

.preview-badge {
    height: 64px;
    width: 64px;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.preview-level {
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-vibrant);
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 12px;
    font-weight: bold;
    white-space: nowrap;
}

/* Step 2: Modal Trophy Room */
.trophy-modal {
    margin: auto;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    padding: 0;
    overflow: hidden;
    position: relative;
    flex-direction: column;
    display: none; /* Hide by default */
}

.trophy-modal[open] {
    display: flex;
}

.trophy-modal::backdrop {
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}

.trophy-modal-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-glass);
    background: rgba(0,0,0,0.2);
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

.trophy-modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* Group Hierarchy */
.group-title {
    font-size: 1.1rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-top: 24px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 8px;
}
.trophy-group-section:first-child .group-title { margin-top: 0; }

.trophy-grid-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

/* Individual Trophy Card Styles */
.trophy-item {
    background: rgba(255,255,255,0.03);
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    transition: all 0.3s ease;
}

.trophy-item.unlocked {
    border-color: var(--accent-vibrant);
    box-shadow: inset 0 0 20px rgba(255, 51, 102, 0.05);
}

.trophy-item.locked img {
    filter: grayscale(100%) opacity(0.35);
}

.trophy-item img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 12px;
    transition: transform 0.3s ease;
}

.trophy-item.unlocked:hover img {
    transform: scale(1.15) rotate(5deg);
}

.trophy-item h5 {
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.trophy-item .description {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.3;
    margin-bottom: 12px;
}

.progress-pill {
    background: rgba(255,255,255,0.1);
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 20px;
}
.trophy-item.unlocked .progress-pill {
    background: var(--accent-vibrant);
    color: #fff;
}

/* ==========================================================================
   MASTER STAGE OVERLAY — Duolingo-style Achievement Celebration
   Layer 0: Lottie burst (full-screen background SVG animation)
   Layer 1: Center card (badge + title + hint)
   ========================================================================== */

/* --- Keyframes --- */

/* Badge entrance: 0% → overshoot 120% → settle 100% */
@keyframes badgeBounce {
    0%   { transform: scale(0);    opacity: 0; }
    55%  { transform: scale(1.2);  opacity: 1; }
    75%  { transform: scale(0.92); opacity: 1; }
    90%  { transform: scale(1.06); opacity: 1; }
    100% { transform: scale(1);    opacity: 1; }
}

/* Card slides up from slightly below center */
@keyframes cardSlideUp {
    from { transform: translateY(40px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* Label pulses with accent glow */
@keyframes labelPulse {
    0%, 100% { opacity: 0.8; letter-spacing: 3px; }
    50%       { opacity: 1;   letter-spacing: 5px; }
}

/* Hint blinks */
@keyframes hintBlink {
    0%, 100% { opacity: 0.4; }
    50%       { opacity: 0.9; }
}

/* Overlay fade in/out */
@keyframes overlayFadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes overlayFadeOut { from { opacity: 1; } to { opacity: 0; } }

/* CSS Burst fallback — radial pulse rings when Lottie is unavailable */
@keyframes cssRing {
    0%   { transform: scale(0.2); opacity: 0.9; }
    100% { transform: scale(3.5); opacity: 0;   }
}


/* --- Master Stage Overlay Shell --- */
.master-stage-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    overflow: hidden;
    animation: overlayFadeIn 0.3s ease forwards;
    cursor: pointer; /* tap-to-dismiss affordance */
}

.master-stage-overlay.master-stage-fadeout {
    animation: overlayFadeOut 0.5s ease forwards;
    pointer-events: none;
}


/* --- Layer 0: Lottie Burst Container (fills entire overlay) --- */
.master-stage-burst {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

/* CSS Burst Fallback — two expanding rings */
.master-stage-burst.master-stage-css-burst::before,
.master-stage-burst.master-stage-css-burst::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 200px; height: 200px;
    margin: -100px 0 0 -100px;
    border-radius: 50%;
    border: 4px solid var(--accent-vibrant);
    animation: cssRing 1.4s ease-out forwards;
}
.master-stage-burst.master-stage-css-burst::after {
    border-color: #ffd700;
    animation-delay: 0.25s;
}


/* --- Layer 1: Center Card --- */
.master-stage-card {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    padding: 40px 32px 32px;
    max-width: 400px;
    width: 90%;
    animation: cardSlideUp 0.45s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both;
}


/* Label: "🏆 Achievement Unlocked" */
.master-stage-label {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--accent-vibrant);
    white-space: nowrap;
    animation: labelPulse 2s ease-in-out infinite;
}


/* Badge Image — the star of the show */
.master-stage-badge {
    width: 160px;
    height: 160px;
    object-fit: contain;
    filter: drop-shadow(0 0 24px rgba(255, 51, 102, 0.6))
            drop-shadow(0 8px 16px rgba(0, 0, 0, 0.5));
    animation: badgeBounce 0.75s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}


/* Achievement Title */
.master-stage-title {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.2;
    /* Slight entrance delay so it appears after the badge settles */
    opacity: 0;
    animation: cardSlideUp 0.4s ease 0.75s forwards;
}


/* Achievement Description */
.master-stage-desc {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.4;
    opacity: 0;
    animation: cardSlideUp 0.4s ease 0.9s forwards;
}


/* Tap-to-continue hint */
.master-stage-hint {
    display: block;
    margin-top: 8px;
    font-size: 0.72rem;
    color: rgba(255,255,255,0.3);
    animation: hintBlink 1.8s ease 1.2s infinite;
}


/* ==========================================================================
   PREVIEW ROW — Dashboard Recent Achievements
   ========================================================================== */
.achievements-preview-container {
    padding: 16px;
    margin: 20px 0;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.achievements-preview-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 51, 102, 0.15);
}
.achievements-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.view-all-text {
    font-size: 0.85rem;
    color: var(--accent-vibrant);
    font-weight: 600;
}
.achievements-scroll-row {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scrollbar-width: none;
}
.achievements-scroll-row::-webkit-scrollbar { display: none; }
.preview-badge-wrapper {
    position: relative;
    flex-shrink: 0;
}
.preview-badge {
    height: 64px;
    width: 64px;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}


/* ==========================================================================
   TROPHY ROOM MODAL
   ========================================================================== */
.trophy-modal {
    margin: auto;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    padding: 0;
    overflow: hidden;
    position: relative;
    flex-direction: column;
    display: none;
}
.trophy-modal[open] { display: flex; }
.trophy-modal::backdrop {
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}
.trophy-modal-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-glass);
    background: rgba(0,0,0,0.2);
}
.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}
.trophy-modal-body {
    padding: 20px;
    overflow-y: auto;
}
.group-title {
    font-size: 1.1rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-top: 24px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 8px;
}
.trophy-group-section:first-child .group-title { margin-top: 0; }
.trophy-grid-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}
.trophy-item {
    background: rgba(255,255,255,0.03);
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    transition: all 0.3s ease;
}
.trophy-item.unlocked {
    border-color: var(--accent-vibrant);
    box-shadow: inset 0 0 20px rgba(255, 51, 102, 0.05);
}
.trophy-item.locked img { filter: grayscale(100%) opacity(0.35); }
.trophy-item img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 12px;
    transition: transform 0.3s ease;
}
.trophy-item.unlocked:hover img { transform: scale(1.15) rotate(5deg); }
.trophy-item h5 { font-size: 0.9rem; margin-bottom: 4px; }
.trophy-item .description {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.3;
    margin-bottom: 12px;
}
.progress-pill {
    background: rgba(255,255,255,0.1);
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 20px;
    color: var(--text-primary);
    display: inline-block;
}
.trophy-item.unlocked .progress-pill {
    background: var(--accent-vibrant);
    color: #fff;
}

