/* ========================================
   ACHIEVEMENT NOTIFICATION SYSTEM
   Integrado DENTRO del widget
   ======================================== */

/* Container - Dentro del widget, entre mensaje y footer */
.achievement-notifications {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 10px 0;
    margin-bottom: 35px; /* Evita tapar la barra de logros inferior */
    min-height: 0;
}

/* Ocultar cuando está vacío */
.achievement-notifications:empty {
    margin: 0;
    display: none;
}

/* Notificación individual */
.achievement-notification {
    display: flex;
    align-items: center; /* Centrado vertical absoluto */
    gap: 15px; /* Más espacio para una lectura limpia */
    padding: 12px 15px; /* Incrementado padding vertical para equilibrio visual */
    background: var(--bg-solid);
    /* Solid Background */
    /* border-left removed to avoid visual noise */
    border-left: none;
    position: relative;
    transform: translateY(-10px);
    opacity: 0;
    transition: all 0.3s ease-out;
    overflow: hidden;
}

.achievement-notification.show {
    transform: translateY(0);
    opacity: 1;
}

.achievement-notification.hiding {
    transform: translateY(10px);
    opacity: 0;
}

/* Icono del logro */
/* Icono del logro */
/* Icono del logro */
.achievement-notification .achievement-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    padding: 0;
    transform: translateY(-8px); /* Nudge hacia arriba más agresivo */
}

/* Target img directly */
/* Target img directly */
.achievement-notification .achievement-icon img {
    /* Force clean image */
    all: initial !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    display: block !important;
    filter: none !important;
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    transform: none !important;
}

/* Contenido del logro */
.achievement-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px; /* Reducido el gap interno para que el bloque sea más compacto */
    justify-content: center;
    z-index: 2;
    position: relative;
}

/* Label: "LOGRO DESBLOQUEADO" */
.achievement-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    font-weight: 800;
    color: var(--cyber-cyan, #00f0ff);
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    overflow: visible; /* Ensure shadows don't get clipped */
    align-items: center;
    gap: 6px;
    line-height: normal; /* Restore normal line height */
    padding-bottom: 2px; /* Small buffer */
    white-space: nowrap; 
}

.achievement-label::before {
    content: '>>';
    /* DecoraciA3n terminal */
    opacity: 0.7;
}

/* Achievement Name - Marquee Bounce */
.achievement-name {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    /* Reduced from 0.85rem */
    font-weight: 800;
    /* Reduced from 900 */
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    /* Reduced from 1px */
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    /* Lighter outline (1px) */
    white-space: nowrap;
    overflow: hidden;
    max-width: 100%; /* Usar todo el ancho disponible dentro del contenedor */
    display: block;
    line-height: 1.2;
    padding-right: 5px; /* Pequeño buffer para evitar que la última letra toque el borde */
}

.achievement-name span {
    display: inline-block;
    padding-right: 20px; /* Buffer crítico: asegura que la animación llegue al final real del texto */
    vertical-align: middle; /* Ensure vertical alignment */
}

.achievement-name span.marquee-active {
    /* Bounce animation: only if class added via JS */
    animation: marquee-bounce 6s ease-in-out infinite alternate;
}

/* Pause on hover */
.achievement-notification:hover .achievement-name span.marquee-active {
    animation-play-state: paused;
}

@keyframes marquee-bounce {
    0%, 20% {
        transform: translateX(0);
    }
    100% {
        /* Se mueve exactamente lo necesario para mostrar el final + el padding de seguridad */
        transform: translateX(calc(-100% + 250px)); 
    }
}

/* Description Container - Mask for marquee */
.achievement-desc {
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.78rem;
    /* Reduced from 0.85rem */
    font-weight: 700;
    /* Bold */
    color: #fff;
    /* White instead of dim */
    white-space: nowrap;
    overflow: hidden;
    position: relative;
    max-width: 100%;
    /* Usar todo el ancho disponible y confiar en overflow hidden */
    display: block;
    line-height: 1.2;
    /* Tighter line height */
}

.achievement-desc>span {
    display: inline-block;
    padding-left: 0;
}

.achievement-desc>span.marquee-active {
    animation: marquee 10s linear infinite;
}

/* Dentro del widget, desactivamos el scroll horizontal para evitar que el texto se salga del div
   cuando se encadenan varios logros. El overlay superior mantiene su animación original. */
.achievement-notifications .achievement-name span.marquee-active,
.achievement-notifications .achievement-desc>span.marquee-active {
    animation: none;
}

.achievement-notification:hover .achievement-desc>span.marquee-active {
    animation-play-state: paused;
}

@keyframes marquee {
    0% {
        transform: translateX(0);
    }

    10% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-100%);
    }
}

/* Barra de progreso de tiempo - 7 segundos */
.achievement-timer {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--cyber-red);
    box-shadow: 0 0 4px var(--cyber-red);
    animation: timer-shrink 11s linear forwards;
}

@keyframes timer-shrink {
    from {
        width: 100%;
    }

    to {
        width: 0%;
    }
}

/* ==================== RAREZAS ====================
   Colores sincronizados con los bordes de tier1-5.png
   ================================================== */

/* Common - Gris (tier1) */
.achievement-notification[data-rarity="common"] {
    --rarity-color: #8a8a8a;
    /* Rarity border removed */
}

.achievement-notification[data-rarity="common"] .achievement-label {
    color: var(--rarity-color);
    text-shadow: none;
}

/* Timer Override Removed */

/* Uncommon - Verde (tier2) */
.achievement-notification[data-rarity="uncommon"] {
    --rarity-color: #4caf50;
    /* Rarity border removed */
}

.achievement-notification[data-rarity="uncommon"] .achievement-label {
    color: var(--rarity-color);
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 0 3px var(--rarity-color);
}

/* Timer Override Removed */

/* Rare - Azul (tier3) */
.achievement-notification[data-rarity="rare"] {
    --rarity-color: #2196f3;
    /* Rarity border removed */
}

.achievement-notification[data-rarity="rare"] .achievement-label {
    color: var(--rarity-color);
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 0 4px var(--rarity-color);
}

/* Timer Override Removed */

/* Epic - Violeta (tier4) */
.achievement-notification[data-rarity="epic"] {
    --rarity-color: #9c27b0;
    /* Rarity border removed */
}

.achievement-notification[data-rarity="epic"] .achievement-label {
    color: var(--rarity-color);
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 0 8px var(--rarity-color);
    /* Stronger glow + outline */
}

.achievement-notification[data-rarity="epic"] .achievement-name {
    color: #fff;
}

/* Timer Override Removed */

/* Legendary - Naranja (tier5) */
.achievement-notification[data-rarity="legendary"] {
    --rarity-color: #ff9800;
    /* Rarity border removed */
}

.achievement-notification[data-rarity="legendary"] .achievement-label {
    color: var(--rarity-color);
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 0 10px var(--rarity-color);
}

.achievement-notification[data-rarity="legendary"] .achievement-name {
    color: var(--rarity-color);
    text-shadow: 0 0 5px rgba(255, 106, 0, 0.4);
}

/* Timer Override Removed */

@keyframes legendary-glow {
    0% {
        box-shadow: 0 0 5px rgba(255, 204, 0, 0.5);
    }

    50% {
        box-shadow: 0 0 15px rgba(255, 204, 0, 0.8);
    }

    100% {
        box-shadow: 0 0 5px rgba(255, 204, 0, 0.5);
    }
}

/* Achievement Progress Bar */
.achievement-progress {
    width: 100%;
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.achievement-progress-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    text-align: right;
}

.achievement-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.achievement-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--cyber-cyan, #00f0ff), #ffffff);
    box-shadow: 0 0 5px var(--cyber-cyan, #00f0ff);
    transition: width 1s ease-out;
}

/* ========================================
   ACHIEVEMENT OVERLAY (Top of Screen) - Xbox One Style (REFINED v3)
   ======================================== */

.achievement-overlay,
.cp-achievement-overlay {
    position: fixed;
    top: 60px;
    left: 0;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999999;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-out;
}

.achievement-overlay.show,
.cp-achievement-overlay.show {
    opacity: 1;
    visibility: visible;
}

.achievement {
    position: relative;
    pointer-events: none;
    width: 100%;
    z-index: 100;
}

.animation {
    width: var(--banner-width, 532px);
    height: 165px;
    padding: 8px 0px 8px 0px;
    position: relative;
    margin: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    overflow: visible; /* Asegurar que el brillo/pulso no se corte */
}

/* El círculo - Adaptado a Cyberpunk Dark (Sin bordes) */
.circle {
    width: 112px;
    height: 112px;
    top: 0;
    opacity: 0;
    margin: 0 auto;
    border-radius: 100%;
    background: radial-gradient(circle, rgba(255, 58, 58, 0.2) 0%, var(--bg-panel) 70%);
    position: relative;
    overflow: hidden;
    z-index: 4;
    box-shadow: 0 0 22px rgba(0, 0, 0, 0.8);
}

.circle.circle_animate {
    animation: circle_grow_move 10.5s forwards;
}

.circle::before, .circle::after {
    content: "";
    opacity: 0;
    width: 112px;
    height: 112px;
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 50%;
    display: block;
}

.circle::before { background-color: rgba(255, 59, 69, 0.1); } 
.circle::after { background-color: rgba(0, 0, 0, 0.5); } 

.circle.circle_animate::before {
    animation: scale_circle_1 10.5s forwards;
    animation-iteration-count: 2;
}

.circle.circle_animate::after {
    animation: scale_circle_1 10.5s 0.1s forwards;
}

/* Rare Mode Overrides */
.rare .circle::after, .rare .circle::before {
    z-index: -1;
}

/* Imágenes dentro del círculo - Alineación Perfecta */
.circle .img {
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    position: absolute;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.circle .img img {
    height: 55%; /* Tamaño equilibrado para el círculo */
    width: auto;
    max-width: 65%;
    object-fit: contain;
    position: absolute; /* Stacked for trophies */
}

.circle.circle_animate .xbox_img {
    animation: logo_animate_opacity 10.5s forwards;
    z-index: 102;
}

.circle.circle_animate .trophy_animate {
    animation: trophy_animate_opacity 10.5s forwards;
}

.rare .trophy_img {
    display: none;
}

.circle .trophy_1 {
    animation: rotate_logo 6s infinite linear;
}

/* El Banner que se expande Detrás */
.banner-outer {
    display: flex;
    align-content: center;
    width: 100%;
    top: -112px; /* Pull up behind circle */
    position: relative;
    justify-content: center;
}

.banner {
    width: var(--banner-width, 532px);
    height: 112px;
    position: relative;
    left: 0;
    opacity: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    /* Rojo suave en el centro, extremos oscuros para evitar "bordes" de color */
    background: linear-gradient(90deg, 
                var(--bg-panel) 0%, 
                rgba(255, 58, 58, 0.15) 50%, 
                var(--bg-panel) 100%);
    overflow: hidden;
    border-radius: 100px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8), inset 0 0 15px rgba(255, 255, 255, 0.05);
}

.banner.banner-animate {
    animation: banner-animate 10.5s forwards;
}

/* Contenido del texto */
.achieve_disp {
    display: flex;
    flex-direction: column;
    gap: 9px; /* Gap a escala 1.5x */
    width: var(--text-width, 375px);
    position: absolute;
    justify-content: center;
    margin-left: 135px;
    left: 0;
    height: 100%;
    top: 0;
    opacity: 0;
    overflow: visible; /* Asegurar que el texto no se corte internamente */
}

.achieve_disp.achieve_disp_animate {
    animation: textSlide 10.5s forwards;
}

.unlocked {
    width: 100%;
    color: white;
    font-weight: 600;
    font-size: 16pt;
    font-family: 'Segoe UI Semibold', 'Segoe UI', sans-serif;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 8px;
}

.score_disp {
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center; /* Centrado vertical */
    margin-bottom: 0 !important;
}

.achiev_name {
    border: none;
    outline: none;
    background: none;
    font-size: 20pt;
    color: white;
    line-height: 36px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-family: 'Segoe UI Semibold', 'Segoe UI', sans-serif;
    font-weight: 600; /* Semibold feel */
}

.acheive_score {
    margin-left: 8px;
    margin-right: 8px;
    color: white;
    font-weight: 700;
    font-size: 20pt;
    font-family: 'Segoe UI Bold', 'Segoe UI', sans-serif;
}

.gamerscore {
    display: flex;
    flex-direction: row;
    align-items: center;
    height: 36px;
}

.hyphen_sep {
    margin-right: 5px;
    color: white;
    font-size: 15pt;
    line-height: 24px;
    font-family: 'Segoe UI', sans-serif;
}

/* Diamond / Rare Animation */
.brilliant-wrap {
    display: none;
    height: 112px;
    width: 112px;
    border-radius: 50%;
    overflow: hidden;
    z-index: 101;
    opacity: 0;
}

.rare .brilliant-wrap {
    display: block;
    animation: brilliant-wrap 10.5s ease-in-out forwards;
}

.brilliant {
    height: 112px;
    width: 112px;
    background-image: url('../img/spritesheet.png');
    background-size: 16464px 112px;
    background-position: right;
    animation: brilliant 7.4s steps(147) 2s forwards;
}

/* Keyframes */

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

@keyframes scale_circle_1 {
    0% { transform: scale3d(0, 0, 0); }
    2% { opacity: 1; }
    5% { transform: scale3d(1, 1, 1); opacity: 0.8; }
    6% { opacity: 0; }
    90% { transform: scale3d(0, 0, 0); }
    92% { opacity: 1; }
    95% { transform: scale3d(1, 1, 1); opacity: 0.8; }
    96%, 100% { opacity: 0; }
}

@keyframes circle_grow_move {
    1% { opacity: 0; transform: scale(0.1); }
    4% { transform: scale(1.1); }
    5% { transform: scale(1); opacity: 1; }
    11% { transform: translate(0); background-color: var(--bg-panel); }
    24% { transform: translateX(var(--circle-translate, -140px)); background-color: #1a1a24; }
    85% { transform: translateX(var(--circle-translate, -140px)); background-color: #1a1a24; }
    89% { transform: translateX(0); background-color: var(--bg-panel); }
    94% { transform: scale(1); }
    96% { transform: scale(1.1); }
    98% { transform: scale(0.1); opacity: 1; }
    100% { transform: scale(0.1); opacity: 0; }
}

@keyframes logo_animate_opacity {
    0% { opacity: 1; }
    19% { opacity: 1; transform: scale3d(1,1,1); }
    23% { opacity: 0; }
    90% { opacity: 0; }
    95% { opacity: 1; }
    100% { opacity: 1; }
}

@keyframes trophy_animate_opacity {
    0% { opacity: 0; }
    20% { opacity: 0; }
    24% { opacity: 1; }
    90% { opacity: 1; }
    95% { opacity: 0; }
    100% { opacity: 0; }
}

@keyframes banner-animate {
    0% { width: 75px; opacity: 0; }
    2% { opacity: 0; }
    4% { opacity: 1; }
    11% { width: 75px; }
    24% { width: var(--banner-width, 355px); background: var(--bg-panel); }
    85% { width: var(--banner-width, 355px); background: var(--bg-panel); }
    89% { width: 75px; opacity: 1; }
    90%, 100% { opacity: 0; }
}

@keyframes textSlide {
    0% { transform: translateY(127px); opacity: 0; }
    20% { transform: translateY(127px); opacity: 0; }
    25% { transform: translateY(0); opacity: 1; }
    79% { transform: translateY(0); opacity: 1; }
    84% { transform: translateY(-172px); opacity: 0; }
    100% { opacity: 0; }
}

@keyframes brilliant {
    0% { background-position: 0; }
    100% { background-position: -16464px; }
}

@keyframes brilliant-wrap {
    0%, 20% { opacity: 0; }
    20.1% { opacity: 1; }
    90% { opacity: 1; }
    95%, 100% { opacity: 0; }
}

/* Data Bits Particles */
.data-bit {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--cyber-cyan);
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
}

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

/* ========================================
   BATCH ACHIEVEMENT STYLES
   ======================================== */

.achievement-notification.achievement-batch {
    background: linear-gradient(90deg, 
        rgba(20, 20, 25, 0.98) 0%, 
        rgba(35, 35, 45, 0.95) 100%
    );
    border-left: 3px solid #ffd700;
    min-height: auto;
    padding: 10px 15px; /* Sightly more compact */
}

.achievement-batch .achievement-content {
    gap: 1px; /* Tighter vertical space */
}

.achievement-batch .achievement-icons-row {
    margin-top: 3px !important;
    height: auto !important; /* Allow it to set height naturally if needed, though we set 24px in JS as well */
    min-height: 24px;
}

/* Ensure overrides from generic img selector don't break this */
.achievement-notification .achievement-content .achievement-icons-row {
     display: flex;
     flex-direction: row;
     gap: 6px;
     margin-top: 5px;
     align-items: center;
     overflow: hidden;
     height: 28px; /* Fixed height for consistency */
}

/* Small icons in the row */
.batch-icon {
    width: 24px !important;
    height: 24px !important;
    border-radius: 3px;
    object-fit: contain;
    background: rgba(0, 0, 0, 0.3) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    transition: transform 0.2s;
    /* Reset generic img styles override from above */
    display: inline-block !important;
    position: relative !important;
    filter: none !important;
    transform: none !important; 
    margin: 0 !important;
    padding: 0 !important;
}

.more-badge {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.7rem;
    color: #00f0ff;
    background: rgba(0, 240, 255, 0.1);
    border: 1px solid rgba(0, 240, 255, 0.3);
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
    font-weight: bold;
}

.batch-names span {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.7rem;
    font-weight: 400;
}

/* ========================================
   PREDICTION NOTIFICATION STYLES
   ======================================== */

.achievement-notification.prediction-notif {
    border-left: 4px solid var(--cyber-yellow);
    background: linear-gradient(90deg, 
        rgba(20, 20, 25, 0.98) 0%, 
        rgba(40, 40, 50, 0.95) 100%
    );
}

.achievement-notification.prediction-notif.participant {
    border-left-color: var(--cyber-blue);
}

.prediction-notif .achievement-icon {
    border: 2px solid var(--cyber-yellow) !important;
    border-radius: 50% !important;
    background: rgba(var(--takeru-yellow-rgb), 0.1) !important;
    box-shadow: 0 0 15px rgba(var(--takeru-yellow-rgb), 0.2) !important;
    transform: none !important; /* Overriding common nudge */
    margin-top: 4px;
}

.prediction-notif.participant .achievement-icon {
    border-color: var(--cyber-blue) !important;
    background: rgba(5, 213, 250, 0.1) !important;
    box-shadow: 0 0 15px rgba(5, 213, 250, 0.2) !important;
}

.prediction-notif .achievement-timer {
    background: var(--cyber-yellow);
}

.prediction-notif.participant .achievement-timer {
    background: var(--cyber-blue);
}
