/* ============================================
    ACHIEVEMENTS - BASE
    Container + Header + Stats + Progress + Map + Nodes
    ============================================ */

/* CONTAINER */
.st-ach-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    background: var(--bg-void);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.6s var(--ease-out);
}

@media (min-width: 600px) {
    .st-ach-container {
        left: 50%;
        transform: translateX(-50%);
        max-width: 480px;
        border-left: 1px solid var(--border-default);
        border-right: 1px solid var(--border-default);
    }
}

.st-ach-scroll-content {
    flex: 1;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    min-height: 0;
    padding: 20px;
    padding-top: calc(120px + env(safe-area-inset-top, 20px));
    padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
}

.st-ach-scroll-content::-webkit-scrollbar { width: 6px; }
.st-ach-scroll-content::-webkit-scrollbar-track { background: transparent; }
.st-ach-scroll-content::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 3px; }

/* LOADING */
.st-ach-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    gap: 16px;
}

.st-ach-spinner {
    width: 50px;
    height: 50px;
    border: 2px solid var(--metal);
    border-top-color: var(--accent);
    border-right-color: var(--accent);
    border-radius: 50%;
    animation: achSpin 0.8s linear infinite;
}

@keyframes achSpin { to { transform: rotate(360deg); } }

.st-ach-loading-text {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

/* HEADER */
.st-ach-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    text-align: center;
    padding: max(16px, env(safe-area-inset-top, 16px)) 20px 12px;
    background: linear-gradient(180deg, rgba(0,0,0,0.98) 0%, rgba(0,0,0,0.96) 50%, rgba(0,0,0,0.85) 75%, transparent 100%);
    pointer-events: none;
}

.st-ach-header > * { pointer-events: auto; }

.st-ach-title {
    font-family: var(--font-display);
    font-size: clamp(2.2rem, 7vw, 3rem);
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.2em;
    margin-bottom: 6px;
    text-shadow: 2px 2px 0 #000, 0 0 30px var(--gold-glow);
    animation: titleGlow 3s ease-in-out infinite;
}

@keyframes titleGlow {
    0%, 100% { text-shadow: 2px 2px 0 #000, 0 0 30px var(--gold-glow); }
    50% { text-shadow: 2px 2px 0 #000, 0 0 50px var(--gold-glow), 0 0 80px rgba(255, 215, 0, 0.3); }
}

.st-ach-subtitle {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-tertiary);
    letter-spacing: 0.25em;
    text-transform: uppercase;
}

/* STATS */
.st-ach-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: var(--bg-card);
    border: 2px solid var(--border-strong);
    margin-bottom: 20px;
    position: relative;
    clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
}

.st-ach-stats::before,
.st-ach-stats::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: linear-gradient(180deg, transparent, var(--border-default) 20%, var(--border-default) 80%, transparent);
}

.st-ach-stats::before { left: 33.33%; }
.st-ach-stats::after { left: 66.66%; }

.st-ach-stat {
    text-align: center;
    padding: 14px 8px;
}

.st-ach-stat-value {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
    text-shadow: 2px 2px 0 #000;
}

.st-ach-stat-best .st-ach-stat-value {
    color: var(--gold);
    text-shadow: 2px 2px 0 #000, 0 0 15px var(--gold-glow);
}

.st-ach-stat-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

/* PROGRESS GLOBAL */
.st-ach-progress-global {
    padding: 16px;
    background: var(--bg-card);
    border: 2px solid var(--border-default);
    margin-bottom: 24px;
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}

.st-ach-progress-label {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
}

.st-ach-progress-label span:last-child {
    color: var(--gold);
    font-family: var(--font-mono);
}

.st-ach-progress-track {
    height: 12px;
    background: var(--metal-dark);
    border: 1px solid var(--border-default);
    overflow: hidden;
    border-radius: 6px;
}

.st-ach-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--metal-bright) 0%, var(--accent) 40%, var(--gold) 100%);
    transition: width 1s var(--ease-out);
    box-shadow: 0 0 12px var(--gold-glow);
    position: relative;
}

.st-ach-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6));
    animation: progressShine 2s ease-in-out infinite;
}

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

/* MAP */
.st-ach-map {
    position: relative;
    margin-bottom: 24px;
    padding: 20px 0;
}

.st-ach-connector-svg {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 1;
    overflow: visible;
}

.st-ach-connector-path {
    stroke-dasharray: 3000;
    stroke-dashoffset: 3000;
    animation: drawLine 2.5s var(--ease-out) forwards;
}

@keyframes drawLine {
    from { stroke-dashoffset: 3000; }
    to { stroke-dashoffset: calc(3000 - var(--progress) * 30); }
}

.st-ach-milestones {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* NODES */
.st-ach-node {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-primary) 100%);
    border: 2px solid var(--border-default);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
    opacity: 0;
    transform: translateY(20px);
}

.st-ach-node.animate-in {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.6s ease, transform 0.6s var(--ease-out);
}

.st-ach-node-left {
    margin-right: 10%;
    flex-direction: row;
}

.st-ach-node-right {
    margin-left: 10%;
    flex-direction: row-reverse;
    text-align: right;
}

.st-ach-node-right .st-ach-node-info { align-items: flex-end; }

.st-ach-node-unlocked {
    border-color: var(--gold);
    background: linear-gradient(135deg, rgba(201, 169, 97, 0.15) 0%, var(--bg-primary) 100%);
    box-shadow: 0 4px 20px var(--gold-glow), inset 0 0 20px rgba(201, 169, 97, 0.05);
}

.st-ach-node-unlocked:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px var(--gold-glow);
}

.st-ach-node-current {
    border-color: var(--accent);
    background: linear-gradient(135deg, rgba(229, 229, 229, 0.1) 0%, var(--bg-primary) 100%);
    box-shadow: 0 4px 20px var(--accent-glow);
    animation: currentPulse 2s ease-in-out infinite;
}

@keyframes currentPulse {
    0%, 100% { box-shadow: 0 4px 20px var(--accent-glow); }
    50% { box-shadow: 0 4px 30px var(--accent-glow), 0 0 40px rgba(229, 229, 229, 0.2); }
}

.st-ach-node-locked {
    opacity: 0.5;
    filter: grayscale(0.5);
}

.st-ach-node-locked:hover { opacity: 0.7; }

/* NODE CIRCLE */
.st-ach-node-circle {
    position: relative;
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    background: var(--metal-dark);
    border: 3px solid var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 
        inset 0 0 20px rgba(0, 0, 0, 0.5),
        0 4px 12px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.st-ach-node-unlocked .st-ach-node-circle {
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
    border-color: var(--gold-light);
    box-shadow: 
        inset 0 0 20px rgba(0, 0, 0, 0.3),
        0 0 25px var(--gold-glow);
}

.st-ach-node-current .st-ach-node-circle {
    background: linear-gradient(135deg, var(--accent) 0%, var(--metal) 100%);
    border-color: var(--accent);
    box-shadow: 
        inset 0 0 20px rgba(0, 0, 0, 0.3),
        0 0 25px var(--accent-glow);
}

.st-ach-node-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 50%;
    overflow: hidden;
}

.st-ach-node-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    filter: drop-shadow(1px 1px 0 #000);
    transition: transform 0.3s ease;
    pointer-events: none;
}

.st-ach-node-unlocked:hover .st-ach-node-icon img { transform: scale(1.1); }

.st-ach-node-unlocked .st-ach-node-icon img {
    filter: drop-shadow(1px 1px 0 #000) drop-shadow(0 0 6px var(--gold-glow));
}

.st-ach-node-fallback {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-shadow: 2px 2px 0 #000;
}

.st-ach-node-level {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-void);
    color: var(--gold);
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: 0.1em;
    border: 1.5px solid var(--gold);
    z-index: 5;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.st-ach-node-check {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 24px;
    height: 24px;
    background: var(--success);
    color: var(--bg-void);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    border: 2.5px solid var(--bg-primary);
    box-shadow: 0 0 10px var(--success-glow);
    z-index: 5;
    pointer-events: none;
}

.st-ach-node-pulse {
    position: absolute;
    inset: -4px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    animation: nodePulse 2s ease-out infinite;
    z-index: 1;
    pointer-events: none;
}

@keyframes nodePulse {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.4); opacity: 0; }
}

/* NODE INFO */
.st-ach-node-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.st-ach-node-days {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--gold);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    font-weight: 700;
}

.st-ach-node-locked .st-ach-node-days { color: var(--text-muted); }

.st-ach-node-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.1;
}

.st-ach-node-unlocked .st-ach-node-title {
    color: var(--gold);
    text-shadow: 0 0 10px var(--gold-glow);
}

.st-ach-node-subtitle {
    font-family: var(--font-main);
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* NODE PROGRESS */
.st-ach-node-progress {
    margin-top: 8px;
    width: 100%;
}

.st-ach-node-progress-track {
    height: 6px;
    background: var(--metal-dark);
    border: 1px solid var(--border-default);
    overflow: hidden;
    margin-bottom: 4px;
    border-radius: 3px;
}

.st-ach-node-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--metal-bright), var(--accent));
    transition: width 1s var(--ease-out);
    box-shadow: 0 0 8px var(--accent-glow);
}

.st-ach-node-progress-text {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--accent);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* NODE REWARD + LOCKED MSG */
.st-ach-node-reward {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--gold);
    letter-spacing: 0.1em;
    margin-top: 6px;
    padding: 4px 8px;
    background: rgba(201, 169, 97, 0.1);
    border-left: 3px solid var(--gold);
    display: inline-block;
    align-self: flex-start;
}

.st-ach-node-right .st-ach-node-reward {
    align-self: flex-end;
    border-left: none;
    border-right: 3px solid var(--gold);
}

.st-ach-node-locked-msg {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    margin-top: 6px;
}

/* ============================================
    OTIMIZAÇÕES DE PERFORMANCE
    ============================================ */

/* GPU Acceleration para elementos animados */
.st-ach-node,
.st-ach-node-circle,
.st-ach-node-icon img,
.st-ach-progress-fill,
.st-ach-connector-path {
    will-change: transform, opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Scroll com hardware acceleration */
.st-ach-scroll-content {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    will-change: scroll-position;
}

/* Reduz reflows em animações */
.st-ach-node.animate-in {
    transition: opacity 0.5s ease, transform 0.5s var(--ease-out);
}

/* Otimização para elementos com muitas sombras */
.st-ach-node-unlocked,
.st-ach-node-current {
    will-change: box-shadow;
}

/* Lazy load para imagens */
.st-ach-node-icon img,
.st-ach-modal-image img {
    content-visibility: auto;
}

/* Reduce motion para quem prefere */
@media (prefers-reduced-motion: reduce) {
    .st-ach-node.animate-in {
        transition: none;
    }
    .st-ach-node-pulse,
    .st-ach-node-current {
        animation: none;
    }
    .st-ach-progress-fill::after {
        animation: none;
    }
    .st-ach-title {
        animation: none;
    }
}