/* public/css/achievements-style.css */

/* ФИКС СКРОЛЛА - БЛОКИРОВКА СТРАНИЦЫ */
html, body {
    overflow: hidden;
    position: fixed;
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    font-family: 'SF Pro', sans-serif;
    background-color: var(--tg-theme-bg-color, #f7f3ff);
    color: var(--tg-theme-text-color, #333333);
    overscroll-behavior: none !important;
    -webkit-overscroll-behavior: none !important;
    touch-action: pan-y !important;
}

.achievements-container {
    /* ФИКС СКРОЛЛА - ВКЛЮЧАЕМ СКРОЛЛ КОНТЕЙНЕРА */
    height: calc(100vh - 75px); /* Уменьшаем высоту на высоту футера (~75px) как в home-style.css */
    min-height: calc(100vh - 75px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    
    /* СКРЫВАЕМ ПОЛОСУ ПРОКРУТКИ */
    scrollbar-width: none;
    -ms-overflow-style: none;
    
    max-width: 390px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start !important; /* ФИКС: убираем автоскролл к центру при переполнении */
    padding-left: 20px;
    padding-right: 20px;
    padding-top: calc(var(--top-offset, 24px) - 75px); /* Отнимаем полную высоту футера (75px) для правильного центрирования */
    padding-bottom: 60px; /* Увеличенный отступ с учетом подписей к достижениям (2-3 строки текста) */
    box-sizing: border-box;
    background-color: inherit;
    overscroll-behavior: none !important;
    -webkit-overscroll-behavior: none !important;
    touch-action: pan-y !important;
}

/* СКРЫВАЕМ СКРОЛЛБАР В WEBKIT */
.achievements-container::-webkit-scrollbar {
    display: none;
}

.achievements-header {
    text-align: center;
    margin-bottom: 30px;
}

.achievements-main-image {
    width: 220px; /* Размер как в profile.php */
    height: auto;
    margin-bottom: -30px;
}

.achievements-header h1 {
    font-family: 'Soyuz Grotesk', sans-serif;
    font-size: 32px; /* Размер как на других страницах */
    font-weight: 700;
    color: var(--tg-theme-text-color, #2c2c2c);
    margin: 0;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); /* Уменьшил минимальную ширину колонки */
    gap: 15px 5px; /* Уменьшил отступы между элементами */
    justify-items: center;
    transform: translateY(10px);
}

.achievement-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 80px; /* Уменьшил ширину элемента */
    cursor: pointer;
    transition: transform 0.1s ease;
}

/* Анимация нажатия только для активных достижений */
.achievement-item.earned:active {
    transform: scale(0.92);
}

.achievement-item.earned:active .achievement-badge {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(141, 79, 255, 0.5);
    background-color: rgba(141, 79, 255, 0.85);
    border-color: #8B5CF6;
}

/* Разные курсоры для активных и неактивных достижений */
.achievement-item.earned {
    cursor: pointer;
}

.achievement-item.locked {
    cursor: not-allowed;
}

/* Hover только для активных достижений */
.achievement-item.earned:hover {
    transform: translateY(-2px);
}

/* Неактивные достижения не реагируют на hover */
.achievement-item.locked:hover {
    transform: none;
}

.achievement-badge {
    width: 60px; /* Уменьшил размер бэджа */
    height: 60px;
    border-radius: 50%;
    background-color: rgba(86, 76, 126, 0.08); /* Цвет фона для неактивного достижения (светлый) */
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px; /* Уменьшил отступ снизу */
    overflow: hidden; /* Чтобы изображение не вылезало */
    border: 3px solid transparent; /* Для возможной обводки */
    transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.1s ease, box-shadow 0.1s ease;
    position: relative; /* Для корректного позиционирования shimmer-эффекта */
    box-sizing: content-box; /* Учитываем размер границы */
}

.achievement-badge img {
    width: 75%; 
    height: 75%;
    object-fit: contain;
    opacity: 0.6; /* Приглушенные неактивные, но с сохранением цвета */
    transition: opacity 0.3s ease;
}

.achievement-item.earned .achievement-badge {
    background-color: rgba(141, 79, 255, 0.67); /* Фиолетовый фон для полученных (пример, как в profile) */
    border-color: #9B6BF5; /* Добавляем фиолетовую обводку для полученных достижений */
    /* Можно добавить градиент или специфичные цвета для каждого достижения позже */
}

.achievement-item.earned .achievement-badge img {
    filter: grayscale(0%);
    opacity: 1;
}

.achievement-name {
    font-family: 'BaseFont', 'SF Pro', sans-serif;
    font-size: 9px;
    color: var(--tg-theme-hint-color, #5f5f5f); /* Цвет текста для названий */
    line-height: 1.3;
    max-width: 100%;
    word-wrap: break-word;
}

.no-achievements {
    grid-column: 1 / -1; /* Занимает всю ширину грида */
    text-align: center;
    font-size: 16px;
    color: var(--tg-theme-hint-color, #888888);
    padding: 20px;
}

/* Анимации (если нужны) */
.animate-fade-in {
    opacity: 0;
    animation: fadeIn 0.5s ease-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Shimmer effect for earned achievements */
.shimmer-effect {
    position: absolute;
    top: -3px; /* Учитываем обводку */
    left: -150%; /* Начинаем за пределами элемента */
    width: calc(100% + 6px); /* Увеличиваем на ширину обводки с обеих сторон */
    height: calc(100% + 6px); /* Увеличиваем на ширину обводки с обеих сторон */
    background: linear-gradient(
        90deg, 
        rgba(255, 255, 255, 0) 0%, 
        rgba(255, 255, 255, 0.3) 50%, /* Цвет блика */
        rgba(255, 255, 255, 0) 100%
    );
    animation: shine 8s infinite; /* Имя анимации, длительность, повторение */
    z-index: 2; /* Увеличиваем z-index, чтобы быть над всеми элементами */
    pointer-events: none; /* Чтобы не мешал кликам по элементу */
}

@keyframes shine {
    0% {
        left: -150%;
    }
    20% { /* Пауза в начале */
        left: -150%;
    }
    40% { /* Движение блика */
        left: 150%;
    }
    100% { /* Пауза в конце, перед следующим циклом */
        left: 150%;
    }
} 

/* Принудительная светлая тема для страницы достижений */
html.app-force-light body,
body.app-force-light {
    background-color: #f7f3ff !important; /* Светлый фон страницы */
    color: #333333 !important;
}

html.app-force-light body .achievements-container,
body.app-force-light .achievements-container {
    background-color: #f7f3ff !important; /* Светлый фон контейнера */
}

html.app-force-light body .achievements-header h1,
body.app-force-light .achievements-header h1 {
    color: #2c2c2c !important; /* Темный цвет заголовка */
}

html.app-force-light body .achievement-name,
body.app-force-light .achievement-name {
    color: #5f5f5f !important; /* Цвет текста для названий */
}

html.app-force-light body .no-achievements,
body.app-force-light .no-achievements {
    color: #888888 !important; /* Цвет для сообщения об отсутствии достижений */
}

/* Явные стили для светлой темы при автоопределении */
html:not(.dark-theme) body,
body:not(.dark-theme) {
    background-color: #f7f3ff !important; /* Светлый фон страницы */
    color: #333333 !important;
}

html:not(.dark-theme) body .achievements-container,
html:not(.dark-theme) .achievements-container,
body:not(.dark-theme) .achievements-container {
    background-color: #f7f3ff !important; /* Светлый фон контейнера */
}

html:not(.dark-theme) body .achievements-header h1,
html:not(.dark-theme) .achievements-header h1,
body:not(.dark-theme) .achievements-header h1 {
    color: rgb(86, 76, 126) !important; /* Темный цвет заголовка */
}

html:not(.dark-theme) body .achievement-name,
html:not(.dark-theme) .achievement-name,
body:not(.dark-theme) .achievement-name {
    color: rgba(86, 76, 126, 0.92) !important; /* Цвет текста для названий */
}

html:not(.dark-theme) body .no-achievements,
html:not(.dark-theme) .no-achievements,
body:not(.dark-theme) .no-achievements {
    color: rgba(86, 76, 126, 0.92) !important; /* Цвет для сообщения об отсутствии достижений */
}

/* Отступы для fullscreen-mode */
html.fullscreen-mode .achievements-container,
body.fullscreen-mode .achievements-container {
    padding-top: var(--top-offset);
    padding-bottom: var(--top-offset);
}

/* Масштабирование страницы достижений на длинных экранах */
@media (min-width: 430px) and (max-width: 500px) {
    .achievements-container {
        transform: scale(1.13) !important;
        padding-bottom: 80px !important; /* Увеличен с учетом подписей */
    }
    
    /* ИСПРАВЛЕНИЕ: Корректируем min-height body с учетом масштаба */
    html, body {
        min-height: calc(100vh * 1.13) !important;
        height: calc(100vh * 1.13) !important;
    }
    
    /* ИСПРАВЛЕНИЕ: Переопределяем padding-bottom для страницы достижений */
    body {
        padding-bottom: calc((95px * 1.13) + env(safe-area-inset-bottom, 0px)) !important;
    }
    
    /* КРИТИЧЕСКОЕ ИСПРАВЛЕНИЕ: Переопределяем calc() из footer-style.css */
    html body {
        padding-bottom: calc((95px * 1.13) + env(safe-area-inset-bottom, 0px)) !important;
    }
    
    /* Дополнительная специфичность */
    body.has-footer {
        padding-bottom: calc((95px * 1.13) + env(safe-area-inset-bottom, 0px)) !important;
    }
}

@media (min-width: 500px) and (max-width: 600px) {
    .achievements-container {
        transform: scale(1.2) !important;
        padding-bottom: 80px !important; /* Увеличен с учетом подписей */
    }
    
    /* ИСПРАВЛЕНИЕ: Корректируем min-height body с учетом масштаба */
    html, body {
        min-height: calc(100vh * 1.2) !important;
        height: calc(100vh * 1.2) !important;
    }
    
    /* ИСПРАВЛЕНИЕ: Переопределяем padding-bottom для страницы достижений */
    body {
        padding-bottom: calc((95px * 1.2) + env(safe-area-inset-bottom, 0px)) !important;
    }
    
    /* КРИТИЧЕСКОЕ ИСПРАВЛЕНИЕ: Переопределяем calc() из footer-style.css */
    html body {
        padding-bottom: calc((95px * 1.2) + env(safe-area-inset-bottom, 0px)) !important;
    }
    
    /* Дополнительная специфичность */
    body.has-footer {
        padding-bottom: calc((95px * 1.2) + env(safe-area-inset-bottom, 0px)) !important;
    }
}

@media (min-width: 600px) {
    .achievements-container {
        transform: scale(1.3) !important;
        padding-bottom: 80px !important; /* Увеличен с учетом подписей */
    }
    
    /* ИСПРАВЛЕНИЕ: Корректируем min-height body с учетом масштаба */
    html, body {
        min-height: calc(100vh * 1.3) !important;
        height: calc(100vh * 1.3) !important;
    }
    
    /* ИСПРАВЛЕНИЕ: Переопределяем padding-bottom для страницы достижений */
    body {
        padding-bottom: calc((95px * 1.3) + env(safe-area-inset-bottom, 0px)) !important;
    }
    
    /* КРИТИЧЕСКОЕ ИСПРАВЛЕНИЕ: Переопределяем calc() из footer-style.css */
    html body {
        padding-bottom: calc((95px * 1.3) + env(safe-area-inset-bottom, 0px)) !important;
    }
    
    /* Дополнительная специфичность */
    body.has-footer {
        padding-bottom: calc((95px * 1.3) + env(safe-area-inset-bottom, 0px)) !important;
    }
}

body {
    padding-bottom: calc(95px + env(safe-area-inset-bottom, 0px)) !important;
}

/* Переопределение для iPhone 16 Pro Max и подобных устройств */
@media (min-width: 430px) and (max-width: 500px) {
    body {
        padding-bottom: calc((95px * 1.13) + env(safe-area-inset-bottom, 0px)) !important;
    }
}
@media (max-height: 400px) {
    .achievements-container {
        padding-bottom: calc(var(--tg-safe-area-inset-bottom, 95px) + 180px) !important; /* Увеличен отступ с учетом подписей */
    }
}

/* Отступы для маленьких экранов по высоте - по аналогии с home-style.css */
@media (max-height: 660px) {
    .achievements-container {
        justify-content: flex-start !important; /* Отменяем центрирование как в home-style.css */
        padding-top: 20px !important; /* Добавляем отступ сверху */
        padding-bottom: 90px !important; /* Увеличиваем отступ снизу для футера и подписей к достижениям */
        min-height: calc(100vh - 40px) !important; /* Минимальная высота с учетом отступов */
        height: calc(100vh - 40px) !important; /* Высота с учетом отступов */
    }
}

/* ===== СПЕЦИАЛЬНЫЕ РАЗМЕРЫ ДЛЯ КОНКРЕТНЫХ ИЗОБРАЖЕНИЙ ===== */
.achievement-badge img[src*="Beginner.png"],
.achievement-badge img[src*="Favorite-meditations.png"],
.achievement-badge img[src*="My-rhythm.png"] {
    width: 100% !important;
    height: 100% !important;
}

.achievement-badge img[src*="dbt-card.svg"] {
    width: 70% !important;
    height: 70% !important;
}













