/* Home Page Specific Styles */
body,
html {
    margin: 0;
    margin-top: 0 !important; /* ФИКС: убираем дефолтный margin-top браузера */
    padding: 0;
    font-family: 'SF Pro', sans-serif; /* Используем основной шрифт проекта */
    background-color: #E6DFFF; /* Убираем var(--tg-theme-bg-color) */
    color: #000000; /* Убираем var(--tg-theme-text-color) */
    overscroll-behavior-y: contain; /* Предотвращает "потягивание" страницы на мобильных */
    /* ФИКС СКРОЛЛА: отключаем скролл страницы */
    height: 100%;
    overflow: hidden;
    position: fixed;
    width: 100%;
}

.home-container {
    /* Адаптивная ширина вместо фиксированной 390px */
    width: 100%;
    max-width: min(90vw, 500px); /* Динамическая ширина, максимум 500px */
    margin: 0 auto;
    padding-left: 20px;
    padding-right: 20px;
    background: #f7f3ff;
    overflow-x: hidden;
    box-sizing: border-box;
    
    /* ФИКС СКРОЛЛА: включаем скролл только у контейнера */
    height: calc(100vh - 75px); /* Уменьшаем высоту на высоту футера (~75px) */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    
    /* Скрываем скроллбар, но оставляем возможность скроллить */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE и Edge */
    
    /* Центрирование контента с учетом футера */
    display: flex;
    flex-direction: column;
    justify-content: center !important;
    min-height: calc(100vh - 75px); /* Минимальная высота за вычетом футера */
    
    /* Safe area для Telegram WebApp */
    padding-bottom: var(--tg-safe-area-inset-bottom, 0px);
}

/* Скрываем скроллбар для WebKit браузеров (Chrome, Safari) */
.home-container::-webkit-scrollbar {
    display: none;
}

/* Header Section */
.home-header {
    margin-bottom: 25px;
    overflow: visible; /* Позволяет содержимому выходить за границы без обрезания */
    width: 100%;
}

.header-content {
    /* background-color: #FFF9E9; */ /* Убран старый фон */
    border-radius: 24px;
    padding: 20px;
    display: flex;
    align-items: center; /* Центрируем вертикально */
    justify-content: center; /* Центрируем горизонтально */
    min-height: 120px;
    height: auto; /* Автоматическая высота */
    /* background-color: rgb(255, 249, 233); */ /* Светло-желтоватый/кремовый */
    background-image: linear-gradient(to bottom right, #f9e8f569, #FFF8E6); /* Мягкий кремовый градиент */
    overflow: visible; /* Гарантирует, что содержимое не будет обрезано */
}

.header-character {
    width: 90px;
    height: auto;
    margin-right: 15px;
}

.header-text h1 {
    font-family: 'Soyuz Grotesk', sans-serif; /* Используем шрифт Soyuz Grotesk */
    font-size: 23px; /* Размер указанный пользователем */
    font-weight: 700;
    line-height: 1.2; /* Оптимальная высота строки для 23px */
    color: #4A2A7B; /* Темно-фиолетовый цвет текста */
    margin: 0;
}

.header-text {
    flex: 1; /* Занимает доступное пространство */
    text-align: left; /* Выравниваем текст по левому краю */
}

.header-text .sparkle {
    color: #FFC700; /* Желтый цвет для звездочки */
    font-size: 23px; /* Размер соответствует тексту */
    margin-left: 2px;
}

/* DBT Card Section */
.dbt-card-section {
    margin-bottom: 25px; /* Changed from 30px to 25px to match header margin */
    width: 100%;
}

/* Новый стиль для заголовка DBT Card */
.dbt-card-section h2 {
    font-size: 22px; /* Такой же как у .skills-section h2 */
    font-weight: 600; /* Такой же как у .skills-section h2 */
    color: rgb(86, 76, 126);    /* Такой же как у .skills-section h2 */
    margin-bottom: 15px; /* Такой же как у .skills-section h2 */
}

.dbt-card-status {
    /* background-color: #F2EBFF; */ /* Убран старый фон */
    border-radius: 18px;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    font-size: 17px;
    /* background-color: rgb(242, 235, 255); */ /* Светло-лавандовый */
    background-image: linear-gradient(to bottom right, #fffaecc9, #ece6fc); /* Мягкий лавандовый градиент */
    white-space: nowrap; /* Предотвращаем перенос текста для всего блока */
}

.checkmark-circle {
    width: 24px;
    height: 24px;
    background-color: #E9DFFC; /* Фоновый цвет кружка немного светлее основного фона dbt-card-status для контраста */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
}

.checkmark-icon {
    color: #7F56D9; /* Фиолетовый цвет галочки */
    font-weight: bold;
    font-size: 16px; /* Размер галочки */
    line-height: 1; /* Для лучшего центрирования */
}

.dbt-card-status .dbt-card-info {
    color: rgba(86, 76, 126, 0.92);
    white-space: nowrap; /* Предотвращаем перенос текста */
    overflow: hidden; /* Скрываем текст, который не помещается */
    text-overflow: ellipsis; /* Добавляем многоточие, если не помещается */
    margin-left: 12px; /* Увеличиваем отступ слева от статуса, чтобы он был после галочки */
}

/* Skills Section */
.skills-section { /* Добавляем явные стили для секции */
    box-sizing: border-box;
    width: 100%;
    overflow: visible; /* Предотвращаем выход содержимого за пределы этой секции */
    margin-bottom: 0; /* Убираем отступ снизу для последней секции */
}

.skills-section h2 {
    font-size: 22px;
    font-weight: 600;
    color: rgb(86, 76, 126); /* Темно-серый цвет заголовка */
    margin-bottom: 15px;
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px; /* Reduced from 10px */
    width: 100%; /* Явно указываем сетке занимать всю доступную ширину родителя */
    box-sizing: border-box; /* Оставляем, это важно */
}

.skill-card {
    border-radius: 20px;
    padding: 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: auto;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.skill-card img {
    width: 65px; /* Changed to 65px as per request */
    height: 65px; /* Changed to 65px as per request */
    margin-bottom: 8px; /* Reduced from 10px */
}

.skill-card span {
    font-size: 11px; /* Reduced from 14px */
    font-weight: 500;
    color: rgba(86, 76, 126, 0.92);
    line-height: 1.3;
    /* Добавляем эти свойства для лучшего управления текстом: */
    display: block; /* Убедимся, что span ведет себя как блок для управления шириной */
    width: 100%;    /* Занимает всю доступную ширину внутри padding'а карточки */
    word-wrap: break-word; /* Разрешает перенос длинных слов, которые не помещаются */
    overflow-wrap: break-word; /* Более современный аналог word-wrap */
    /* Можно еще добавить white-space: normal !important; если есть подозрения на другие стили */
}

/* Градиент для верхних 3х карточек навыков */
.skill-card.mindfulness {
    /* background-color: rgb(233, 223, 252); */ /* Светло-фиолетовый */
    background-image: linear-gradient(to bottom right, #eae5fd, #fdecf6); /* Мягкий фиолетовый градиент */
}

.skill-card.emotion-regulation {
    /* background-color: rgb(252, 231, 242); */ /* Светло-розовый */
    background-image: linear-gradient(to bottom right, #eae5fd, #fdecf6); /* Мягкий розовый градиент */
}

.skill-card.interpersonal-effectiveness {
    /* background-color: rgb(224, 223, 254); */ /* Светло-голубовато-фиолетовый */
    background-image: linear-gradient(to bottom right, #eae5fd, #fdecf6); /* Мягкий голубовато-фиолетовый градиент */
}

.skill-card.observation.full-width-skill {
    grid-column: 1 / -1; /* Занимает всю ширину */
    /* Общий градиент уже применен к .skill-card */
    padding: 15px;
    /* background-color: rgb(254, 251, 235); */ /* Светло-бежевый/желтоватый */
    background-image: linear-gradient(to bottom right, #fceaf3, #e5e4fe);
}

.observation-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
}

.skill-card.observation .observation-character { /* Уточнили селектор */
    width: 85px; 
    height: auto;
    margin-right: 15px;
}

.observation-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center; /* Центрируем текст и кнопку по вертикали */
    flex-grow: 1;
}

.observation-title {
    font-size: 20px;
    font-weight: 600;
    color: #4A2A7B; /* Темно-фиолетовый */
    margin: 0 0 10px 0;
}

.start-button {
    background-color: rgb(233 223 252);
    border-radius: 15px;
    padding: 8px 20px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.start-button:hover {
    background-color: #F2EBFF;
    border-color: #7F56D9;
}

/* Dark Theme Adjustments */
body.dark-theme .home-container {
    background-color: #120e29;
}

body.dark-theme .header-content {
    /* background-color: #2A1E3D; */
    /* background-image: linear-gradient(to bottom right, #302342, #251b43); /* Темный градиент */
}

body.dark-theme .header-text h1 {
    color: #E6DFFF; /* Светлый текст для заголовка */
}

body.dark-theme .dbt-card-status {
    /* background-color: #3A2E5C; */
   /* background-image: linear-gradient(to bottom right, #403361, #251b43); /* Темный градиент */
}

body.dark-theme .checkmark-circle {
    background-color: #2C1F4A; /* Темный фон кружка */
    border-color: #5A4A7D;
}

body.dark-theme .checkmark-icon {
    color: #D9CFFF;
}

body.dark-theme .dbt-card-status .dbt-card-info {
    color: #D9CFFF;
    white-space: nowrap; /* Также для темной темы */
    overflow: hidden;
    text-overflow: ellipsis;
}

body.dark-theme .skills-section h2 {
    color: #E6DFFF; /* Светлый текст для заголовка Skills */
}

body.dark-theme .skill-card {
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    /* Темный градиент для карточек, инвертированный от светлого */
    /* background: linear-gradient(180deg, rgb(40, 25, 50) 0%, rgb(45, 35, 55) 100%); */
    /* Базовый градиент для темных карточек, если специфичные не переопределят */
    background-image: linear-gradient(to bottom right, #302038, #281932);
}
body.dark-theme .skill-card span {
    color: #F5F3FF;
}

body.dark-theme .observation-title {
    color: #E6DFFF;
}

body.dark-theme .start-button {
    background-color: #3A2E5C;
    color: #E6DFFF;
    border-color: #5A4A7D;
}

body.dark-theme .start-button:hover {
    background-color: #4A3E6C;
    border-color: #7F56D9;
}

body.dark-theme .skill-card.mindfulness {
    /* background-color: #3A2E5C; */ /* Темно-фиолетовый */
    background-image: linear-gradient(to bottom right, #403361, #3A2E5C);
}
body.dark-theme .skill-card.emotion-regulation {
    /* background-color: #4A2E5C; */ /* Темно-розово-фиолетовый */
    background-image: linear-gradient(to bottom right, #503361, #4A2E5C);
}
body.dark-theme .skill-card.interpersonal-effectiveness {
    /* background-color: #2E3A5C; */ /* Темно-сине-фиолетовый */
    background-image: linear-gradient(to bottom right, #334061, #2E3A5C);
}
body.dark-theme .skill-card.observation.full-width-skill {
     /* background-color: #4A432E; */ /* Темно-желто-коричневый */
     background-image: linear-gradient(to bottom right, #504833, #4A432E);
}

body.dark-theme .dbt-card-section h2 {
    color: #E6DFFF; /* Светлый текст для заголовка DBT Card в темной теме */
}

/* Обеспечиваем правильное отображение футера */
body {
    background-color: var(--tg-theme-bg-color, #E6DFFF); /* Дублируем фон для body */
}

/* Медиа-запрос для мобильных устройств */
@media (max-width: 480px) {
    html, body {
        background-color: #f7f3ff;
    }
    
    .home-container {
        width: 100%;
        padding-bottom: 10px; /* Увеличиваем отступ для футера на мобильных устройствах */
    }
}

/* Дополнительные классы задержек для анимации */
.delay-700 { animation-delay: 0.7s; }
.delay-800 { animation-delay: 0.8s; }
.delay-900 { animation-delay: 0.9s; }
.delay-1000 { animation-delay: 1.0s; }
.delay-1100 { animation-delay: 1.1s; }
.delay-1200 { animation-delay: 1.2s; }

/* Анимация плавного появления (копируем из style.css для гарантии работы) */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.8s ease forwards;
    opacity: 0;
}

.skill-card.interpersonal-effectiveness img {
    width: 90px;
}

/* Для маленьких экранов - возвращаем фиксированную ширину */
@media (max-width: 430px) {
    .home-container {
        max-width: 390px;
        /* justify-content уже установлен в основном правиле */
    }
}

/* Для больших экранов - увеличиваем элементы */
@media (min-width: 431px) {
    .home-container {
        max-width: min(85vw, 480px); /* Больше места на больших экранах */
        padding-left: max(4vw, 24px);
        padding-right: max(4vw, 24px);
        justify-content: center; /* Центрируем на всех экранах */
    }
    
    /* Масштабируем контент */
    .header-content {
        min-height: 135px; /* Увеличено с 120px */
        padding: 24px; /* Увеличено с 20px */
    }
    
    .header-character {
        width: 100px; /* Увеличено с 90px */
        margin-right: 18px; /* Увеличено с 15px */
    }
    
    .header-text h1 {
        font-size: 25px; /* Увеличено с 23px */
        line-height: 1.25;
    }
    
    .dbt-card-section h2,
    .skills-section h2 {
        font-size: 24px; /* Увеличено с 22px */
        margin-bottom: 17px; /* Увеличено с 15px */
    }
    
    .dbt-card-status {
        padding: 17px 24px; /* Увеличено с 15px 20px */
        font-size: 18px; /* Увеличено с 17px */
        border-radius: 20px; /* Увеличено с 18px */
    }
    
    .checkmark-circle {
        width: 26px; /* Увеличено с 24px */
        height: 26px;
        margin-right: 14px; /* Увеличено с 12px */
    }
    
    .checkmark-icon {
        font-size: 17px; /* Увеличено с 16px */
    }
    
    .skills-grid {
        gap: 10px; /* Увеличено с 8px */
        margin-bottom: 22px; /* Увеличено с 20px */
    }
    
    .skill-card {
        padding: 12px; /* Увеличено с 10px */
        border-radius: 22px; /* Увеличено с 20px */
    }
    
    .skill-card img {
        width: 70px; /* Увеличено с 65px */
        height: 70px;
        margin-bottom: 10px; /* Увеличено с 8px */
    }
    
    .skill-card span {
        font-size: 12px; /* Увеличено с 11px */
        line-height: 1.35;
    }
    
    .skill-card.observation.full-width-skill {
        padding: 18px; /* Увеличено с 15px */
    }
    
    .skill-card.observation .observation-character {
        width: 95px; /* Увеличено с 85px */
        margin-right: 18px; /* Увеличено с 15px */
    }
    
    .observation-title {
        font-size: 21px; /* Увеличено с 20px */
        margin-bottom: 11px; /* Увеличено с 10px */
    }
    
    .start-button {
        padding: 9px 22px; /* Увеличено с 8px 20px */
        font-size: 17px; /* Увеличено с 16px */
        border-radius: 17px; /* Увеличено с 15px */
    }
    
    .home-header,
    .dbt-card-section {
        margin-bottom: 28px; /* Увеличено с 25px */
    }
}

/* Темная тема для больших экранов */
@media (min-width: 431px) {
    body.dark-theme .header-content {
        background-image: linear-gradient(to bottom right, #332444, #2A1E3D);
    }
    
    body.dark-theme .dbt-card-status {
        background-image: linear-gradient(to bottom right, #443461, #3A2E5C);
    }
    
    body.dark-theme .skill-card {
        background-image: linear-gradient(to bottom right, #322038, #2A1932);
        box-shadow: 0 5px 12px rgba(0,0,0,0.25);
    }
    
    body.dark-theme .skill-card.mindfulness {
        background-image: linear-gradient(to bottom right, #433361, #3A2E5C);
    }
    
    body.dark-theme .skill-card.emotion-regulation {
        background-image: linear-gradient(to bottom right, #533361, #4A2E5C);
    }
    
    body.dark-theme .skill-card.interpersonal-effectiveness {
        background-image: linear-gradient(to bottom right, #344061, #2E3A5C);
    }
    
    body.dark-theme .skill-card.observation.full-width-skill {
        background-image: linear-gradient(to bottom right, #524833, #4A432E);
    }
}

/* Масштабирование на длинных экранах */
@media (min-width: 430px) and (max-width: 500px) {
    .home-container {
        transform: scale(1.13) !important;
        height: calc(100vh - (75px * 1.13)) !important; /* Учитываем масштабированный футер */
        min-height: calc(100vh - (75px * 1.13)) !important;
    }
    body {
        padding-bottom: calc((80px * 1.13) + env(safe-area-inset-bottom, 0px)) !important;
        overflow: hidden !important; /* Блокируем скролл на iPhone 16 Pro Max */
    }
}

@media (min-width: 500px) and (max-width: 600px) {
    .home-container {
        transform: scale(1.2) !important;
        height: calc(100vh - (75px * 1.2)) !important; /* Учитываем масштабированный футер */
        min-height: calc(100vh - (75px * 1.2)) !important;
    }
    body {
        padding-bottom: calc((80px * 1.2) + env(safe-area-inset-bottom, 0px)) !important;
        overflow: hidden !important; /* Блокируем скролл на больших экранах */
    }
}

@media (min-width: 600px) {
    .home-container {
        transform: scale(1.3) !important;
        height: calc(100vh - (75px * 1.3)) !important; /* Учитываем масштабированный футер */
        min-height: calc(100vh - (75px * 1.3)) !important;
    }
    body {
        padding-bottom: calc((80px * 1.3) + env(safe-area-inset-bottom, 0px)) !important;
        overflow: hidden !important; /* Блокируем скролл на больших экранах */
    }
}

/* ИСПРАВЛЕНИЕ SAFARI: Фикс для адресной строки Safari на iOS - только для мобильных устройств */
@media (max-width: 768px) and (min-height: 430px) {
    @supports (-webkit-touch-callout: none) {
        html, body {
            height: 100% !important;
            min-height: 100% !important;
            max-height: 100% !important;
            overflow-x: hidden !important;
            position: relative !important;
        }
        
        body {
            -webkit-overflow-scrolling: touch !important;
            overscroll-behavior: none !important;
        }
        
        .home-container {
     /*       min-height: calc(100vh - 160px) !important; /* Учитываем адресную строку Safari */
            height: auto !important;
        }
    }
}

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