/* ========== СТИЛИ ДЛЯ ТРЕНИРОВОК ПО ФИЗИКЕ ========== */

/* Анимации */
@keyframes physicsFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes physicsPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 15px rgba(237, 137, 54, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 8px 25px rgba(237, 137, 54, 0.4);
    }
}

@keyframes wordBlockAppear {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(15px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes cloneAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 0.9;
        transform: scale(1.1);
    }
}

/* Контейнер тренировки */
.physics-training-container {
    animation: physicsFadeIn 0.4s ease-out;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

/* Термин тренировки */
.training-term {
    background: linear-gradient(135deg, #fffaf0 0%, #fff5eb 100%);
    border-left: 4px solid #ed8936;
    padding: 15px;
    border-radius: 12px;
    margin: 10px 0;
    line-height: 1.5;
    font-size: 16px;
    color: #2d3748;
}

.training-term strong {
    color: #c05621;
    font-weight: 700;
}

/* Контейнер для пропусков */
.gaps-container {
    display: flex;
    gap: 12px;
    margin: 20px 0;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    min-height: 100px;
    flex-shrink: 0;
}

/* Пропуски для слов - ФИКСИРОВАННЫЙ РАЗМЕР */
.training-gap {
    flex: 1;
    min-width: 130px;
    width: 130px;
    height: 65px;
    min-height: 65px;
    max-height: 65px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 15px;
    color: #4a5568;
    font-weight: 500;
    position: relative;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}

/* Пустые пропуски */
.training-gap:empty {
    background: #f8f9fa !important;
    border: 2px dashed #e2e8f0 !important;
}

/* Заполненные пропуски */
.training-gap:not(:empty) {
    background: #f0fff4 !important;
    border: 2px solid #48bb78 !important;
}

/* Сбрасываем стили для пропусков без содержимого */
.training-gap:empty,
.training-gap:has(> :not(div)) {
    background: #f8f9fa !important;
    border: 2px dashed #e2e8f0 !important;
}

.training-gap:hover:empty {
    background: #fffaf0;
    border-color: #f6ad55;
}

.training-gap.touch-highlight {
    background: #fffaf0 !important;
    border: 3px solid #ed8936 !important;
}

/* Контейнер для содержимого пропуска */
.training-gap > div {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 6px;
    box-sizing: border-box;
}

/* Текст в пропуске */
.training-gap span {
    flex: 1;
    text-align: center;
    font-weight: 600;
    color: #2d3748;
    line-height: 1.2;
    display: flex;
    align-items: center;
    justify-content: center;
    word-break: break-word;
    hyphens: auto;
}

/* Кнопка удаления */
.training-gap .remove-word-btn {
    background: #fed7d7;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    min-width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    color: #c53030;
    font-weight: bold;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
    margin: 0;
    line-height: 1;
    z-index: 20;
}

.training-gap .remove-word-btn:hover {
    background: #feb2b2;
    transform: scale(1.1);
}

.training-gap .remove-word-btn:active {
    transform: scale(0.95);
}

/* Блоки слов */
.word-block {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    font-weight: 600;
    cursor: grab;
    user-select: none;
    transition: all 0.3s ease;
    text-align: center;
    min-height: 60px;
    height: 60px;
    width: 100%;
    word-break: break-word;
    hyphens: auto;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    touch-action: none;
    line-height: 1.2;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.3);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    margin: 0;
    font-size: 14px;
}

/* Скрытые блоки слов */
.word-block[style*="display: none"] {
    display: none !important;
}

.word-block:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.word-block:active {
    cursor: grabbing;
    opacity: 0.7;
    transform: scale(0.95) !important;
}

/* Стили для клона при перетаскивании */
#physics-dragging-clone {
    position: fixed;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 10000;
    transform: scale(1.1);
    opacity: 0.9;
    border: 2px solid white;
    animation: cloneAppear 0.2s ease-out;
    padding: 4px;
    word-break: break-word;
    text-align: center;
    line-height: 1.2;
}

/* Контейнер для блоков слов */
.word-blocks-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 16px;
    border: 1px solid #e9ecef;
    min-height: auto;
    max-height: 35vh;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
    user-select: none;
    margin-bottom: 15px;
    flex-shrink: 1;
    align-items: start;
}

/* Стилизация скроллбара */
.word-blocks-container::-webkit-scrollbar {
    width: 4px;
}

.word-blocks-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 2px;
}

.word-blocks-container::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%);
    border-radius: 2px;
}

/* Анимация появления блоков */
.word-block {
    animation: wordBlockAppear 0.4s ease-out;
    animation-fill-mode: both;
}

.word-block:nth-child(1) { animation-delay: 0.1s; }
.word-block:nth-child(2) { animation-delay: 0.2s; }
.word-block:nth-child(3) { animation-delay: 0.3s; }
.word-block:nth-child(4) { animation-delay: 0.4s; }
.word-block:nth-child(5) { animation-delay: 0.5s; }
.word-block:nth-child(6) { animation-delay: 0.6s; }

/* Кнопки тренировки */
.physics-menu-btn {
    flex: 2;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    border: none;
    border-radius: 12px;
    padding: 16px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.3);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.physics-menu-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(72, 187, 120, 0.4);
}

.physics-menu-btn:active:not(:disabled) {
    transform: translateY(0);
}

.physics-menu-btn-secondary {
    flex: 1;
    background: #f8f9fa;
    color: #333;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.physics-menu-btn-secondary:hover {
    background: #e9ecef;
    border-color: #ed8936;
    color: #ed8936;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.physics-menu-btn-secondary:active {
    transform: translateY(0);
}

/* Контейнер для кнопок */
.training-buttons {
    display: flex;
    gap: 12px;
    margin-top: 15px;
    flex-shrink: 0;
}

/* Результаты тренировки */
.training-results-container {
    animation: physicsFadeIn 0.5s ease-out;
    padding: 25px !important;
}

/* Контейнер полоски прогресса */
.physics-progress-container {
    width: 100%;
    margin-bottom: 15px;
    padding: 0;
    box-sizing: border-box;
    flex-shrink: 0;
}

/* Нижний дисплей */
.lower-display {
    background: white;
    padding: 15px;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    max-height: 45vh;
}

/* Запрет выделения */
.physics-training-container,
.gaps-container,
.training-gap,
.word-blocks-container,
.word-block {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Предотвращение скролла страницы при перетаскивании */
body.dragging-active {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* ========== АДАПТИВНОСТЬ ========== */

@media (max-width: 768px) {
    .training-gap {
        min-width: 110px;
        width: 110px;
        height: 60px;
        min-height: 60px;
        max-height: 60px;
        font-size: 14px;
    }
    
    .word-block {
        min-height: 55px;
        height: 55px;
        font-size: 13px;
        padding: 6px 4px;
    }
    
    .word-blocks-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 12px;
        max-height: 30vh;
    }
    
    .training-buttons {
        flex-direction: column;
        gap: 8px;
    }
    
    .physics-menu-btn,
    .physics-menu-btn-secondary {
        width: 100%;
        padding: 14px;
        font-size: 15px;
    }
    
    #physics-dragging-clone {
        width: 45px;
        height: 45px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .training-gap {
        min-width: 100px;
        width: 100px;
        height: 55px;
        min-height: 55px;
        max-height: 55px;
        font-size: 13px;
    }
    
    .training-gap .remove-word-btn {
        width: 20px;
        height: 20px;
        min-width: 20px;
        font-size: 12px;
    }
    
    .word-block {
        min-height: 50px;
        height: 50px;
        font-size: 12px;
        padding: 4px;
    }
    
    .word-blocks-container {
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 10px;
        max-height: 28vh;
    }
    
    .physics-menu-btn,
    .physics-menu-btn-secondary {
        padding: 12px;
        font-size: 14px;
    }
    
    #physics-dragging-clone {
        width: 40px;
        height: 40px;
        font-size: 12px;
    }
}

@media (max-width: 350px) {
    .training-gap {
        min-width: 90px;
        width: 90px;
        font-size: 12px;
    }
    
    .word-block {
        min-height: 45px;
        height: 45px;
        font-size: 11px;
    }
}

@media (max-height: 700px) {
    .training-gap {
        height: 55px;
        min-height: 55px;
        max-height: 55px;
    }
    
    .word-block {
        min-height: 50px;
        height: 50px;
    }
    
    .word-blocks-container {
        max-height: 28vh;
    }
}

@media (max-height: 600px) {
    .training-gap {
        height: 50px;
        min-height: 50px;
        max-height: 50px;
    }
    
    .word-block {
        min-height: 45px;
        height: 45px;
    }
    
    .word-blocks-container {
        max-height: 25vh;
    }
}

/* Ландшафтная ориентация */
@media (orientation: landscape) and (max-height: 500px) {
    .training-gap {
        height: 45px;
        min-height: 45px;
        max-height: 45px;
        min-width: 85px;
        width: 85px;
    }
    
    .word-block {
        min-height: 40px;
        height: 40px;
        font-size: 11px;
    }
    
    .word-blocks-container {
        grid-template-columns: repeat(3, 1fr);
        max-height: 22vh;
        padding: 8px;
        gap: 6px;
    }
    
    .training-buttons {
        flex-direction: row;
        gap: 6px;
    }
    
    .physics-menu-btn,
    .physics-menu-btn-secondary {
        padding: 8px;
        font-size: 12px;
    }
    
    #physics-dragging-clone {
        width: 35px;
        height: 35px;
        font-size: 10px;
    }
}

/* Улучшения для touch-устройств */
@media (hover: none) and (pointer: coarse) {
    .word-block:hover,
    .training-gap:hover {
        transform: none !important;
    }
}

/* Классы для оптимизации размера текста */
.word-block[data-length="short"] {
    font-size: 16px;
}

.word-block[data-length="medium"] {
    font-size: 14px;
}

.word-block[data-length="long"] {
    font-size: 12px;
}

.word-block[data-length="very-long"] {
    font-size: 11px;
}