/* Guest Course Styles - Clean Modern Design */

/* Базовые стили для тренажера */
#typing-text {
    font-family: 'Courier New', monospace;
    word-break: break-all;
    overflow-wrap: break-word;
    font-size: 2rem; /* Увеличенный размер по умолчанию */
}

@media (min-width: 640px) {
    #typing-text {
        font-size: 2.5rem; /* Еще крупнее на больших экранах */
    }
}

/* Фокус на тренажере */
#typing-trainer:focus {
    outline: none;
}

#typing-trainer:focus #typing-text {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.letter-item {
    display: inline-block;
    position: relative;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 0 1px;
    padding: 2px 1px;
    border-radius: 6px;
    font-size: inherit; /* Наследует размер от родителя */
    border-bottom: 3px solid transparent !important; /* Прозрачная рамка для предотвращения "дёрганья" */
    vertical-align: baseline; /* Выравнивание по базовой линии */
    line-height: 1.5em; /* Высота строки для правильного отображения - используем em для соответствия размеру шрифта */
    min-height: 1.5em; /* Минимальная высота для всех элементов, включая пробелы - равна line-height */
}

/* Специальная обработка для пробелов - делаем их видимыми на всю высоту */
/* Пробел должен занимать всю высоту строки, как обычный символ */
/* Для пустых элементов (пробелов) используем псевдоэлемент */
.letter-item:empty {
    min-width: 0.3em;
    min-height: 1em;
    line-height: 1em;
    vertical-align: baseline;
}

/* Для элементов с пробелом используем псевдоэлемент для визуализации на всю высоту */
.letter-item:empty::before {
    content: '\00A0'; /* Неразрывный пробел */
    display: inline-block;
    height: 1em;
    line-height: 1em;
    vertical-align: baseline;
    width: 0.3em;
    visibility: visible;
}

/* Для элементов, содержащих только пробел (обычный или неразрывный) */
.letter-item:has-text(" ") {
    min-height: 1em;
    line-height: 1em;
    vertical-align: baseline;
}

/* Альтернативный способ: если элемент содержит только пробел, делаем его видимым */
.letter-item {
    white-space: pre; /* Сохраняем пробелы */
}

/* Для элементов с пробелом - делаем их видимыми на всю высоту через line-height */
.letter-item:has(> :only-child:empty),
.letter-item:has-text(" ") {
    line-height: 1em;
    min-height: 1em;
}

/* Если элемент содержит только пробел, показываем его через псевдоэлемент */
.letter-item:has-text(" ")::after,
.letter-item:has-text("\u00A0")::after {
    content: '\00A0';
    display: inline-block;
    height: 1em;
    line-height: 1em;
    vertical-align: baseline;
    width: 0.3em;
}

.letter-item.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(99, 102, 241, 0.2));
    border-bottom: 3px solid;
    border-image: linear-gradient(90deg, rgb(59, 130, 246), rgb(99, 102, 241)) 1;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
    animation: pulse-active 1.5s ease-in-out infinite;
}

.letter-item.correct {
    color: rgb(34, 197, 94);
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(16, 185, 129, 0.15));
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.2);
}

.letter-item.error {
    color: rgb(239, 68, 68);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(220, 38, 38, 0.2));
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
    animation: shake 0.3s ease, error-pulse 0.3s ease;
}

.letter-item.newline {
    color: rgb(148, 163, 184);
    font-weight: bold;
}

.letter-item.tab {
    color: rgb(148, 163, 184);
    font-weight: bold;
}

.tab-space {
    display: inline-block;
    width: 2em;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0) rotate(0deg);
    }
    25% {
        transform: translateX(-4px) rotate(-2deg);
    }
    75% {
        transform: translateX(4px) rotate(2deg);
    }
}

@keyframes pulse-active {
    0%, 100% {
        background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(99, 102, 241, 0.2));
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    }
    50% {
        background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(99, 102, 241, 0.3));
        box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
    }
}

@keyframes error-pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 6px 20px rgba(239, 68, 68, 0.7);
    }
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.animate-shimmer {
    animation: shimmer 2s infinite;
}

@keyframes bounce-in {
    0% {
        opacity: 0;
        transform: scale(0.3) rotate(-10deg);
    }
    50% {
        transform: scale(1.1) rotate(5deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

.animate-bounce-in {
    animation: bounce-in 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Клавиатура */
.keyboard-key {
    user-select: none;
    cursor: default;
    position: relative;
    transition: all 0.15s ease;
}

.keyboard-key.active {
    background: linear-gradient(135deg, rgb(59, 130, 246), rgb(99, 102, 241)) !important;
    color: white !important;
    transform: scale(1.1) translateY(-2px);
    z-index: 10;
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.5), 0 0 0 2px rgba(59, 130, 246, 0.3);
    animation: key-press 0.3s ease-out;
}

.keyboard-key.error {
    background: linear-gradient(135deg, rgb(239, 68, 68), rgb(220, 38, 38)) !important;
    color: white !important;
    animation: keyError 0.3s ease;
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.5);
}

/* Подсветка текущей клавиши (как в main.js) */
.keyboard-key.current-key-active {
    /* Убрана обводка для лучшей видимости */
    /* box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.6) !important; */
    /* border-color: rgba(34, 197, 94, 0.8) !important; */
    /* animation: pulse-correct 1.5s ease-in-out infinite; */
}

@keyframes pulse-correct {
    0%, 100% {
        box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.6);
    }
    50% {
        box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.4);
    }
}

@keyframes pulse-correct-blue {
    0%, 100% {
        box-shadow: 0 0 0 4.5px rgba(59, 130, 246, 0.6), 0 0 0 6px rgba(59, 130, 246, 0.3);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.7), 0 0 0 9px rgba(59, 130, 246, 0.4);
    }
}

/* Активная клавиша с наивысшим z-index */
.keyboard-key.current-key-active {
    position: relative !important;
    z-index: 9999 !important;
}

@keyframes keyError {
    0%, 100% {
        transform: scale(1) rotate(0deg);
    }
    25% {
        transform: scale(1.2) rotate(-5deg);
    }
    75% {
        transform: scale(1.2) rotate(5deg);
    }
}

@keyframes key-press {
    0% {
        transform: scale(1) translateY(0);
    }
    50% {
        transform: scale(1.15) translateY(-3px);
    }
    100% {
        transform: scale(1.1) translateY(-2px);
    }
}

/* Адаптивность */
@media (max-width: 768px) {
    #typing-text {
        font-size: 1.25rem;
    }
    
    .keyboard-key {
        font-size: 0.75rem;
        padding: 0.5rem 0.25rem;
        min-width: 30px;
        height: 40px;
    }
}

/* Темная тема */
[data-theme="dark"] .letter-item.active {
    background: rgba(59, 130, 246, 0.25);
    border-bottom-color: rgb(96, 165, 250);
}

[data-theme="dark"] .letter-item.correct {
    color: rgb(74, 222, 128);
    background: rgba(74, 222, 128, 0.15);
}

[data-theme="dark"] .letter-item.error {
    color: rgb(248, 113, 113);
    background: rgba(248, 113, 113, 0.2);
}

/* Темная тема для клавиатуры - используем те же цвета, что и в светлой теме */
[data-theme="dark"] #keyboard .keyboard-key {
    background: rgba(255, 255, 255, 0.8) !important;
    background-color: rgba(255, 255, 255, 0.8) !important;
    background-image: none !important;
    border-color: rgba(226, 232, 240, 0.6) !important;
}

[data-theme="dark"] #keyboard .keyboard-key:not(.active):not(.error):not(.current-key-active):not([class*="finger-"]) {
    background: rgba(255, 255, 255, 0.8) !important;
    background-color: rgba(255, 255, 255, 0.8) !important;
    background-image: none !important;
}

[data-theme="dark"] #keyboard .keyboard-key:not(.active):not(.error):not(.current-key-active) span {
    color: #1f2937 !important; /* Черный цвет текста, как в светлой теме */
}

/* Активная клавиша (при нажатии) */
[data-theme="dark"] #keyboard .keyboard-key.active {
    background: linear-gradient(135deg, rgb(59, 130, 246), rgb(99, 102, 241)) !important;
    background-color: transparent !important;
    color: white !important;
}

[data-theme="dark"] #keyboard .keyboard-key.active span {
    color: white !important;
}

/* Клавиша с ошибкой */
[data-theme="dark"] #keyboard .keyboard-key.error {
    background: linear-gradient(135deg, rgb(239, 68, 68), rgb(220, 38, 38)) !important;
    background-color: transparent !important;
    color: white !important;
}

[data-theme="dark"] #keyboard .keyboard-key.error span {
    color: white !important;
}

/* Подсветка текущей клавиши (следующая для ввода) */
[data-theme="dark"] #keyboard .keyboard-key.current-key-active {
    /* Убрана обводка для лучшей видимости */
    /* box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.6) !important; */
    /* border-color: rgba(34, 197, 94, 0.8) !important; */
    background: rgba(255, 255, 255, 0.8) !important;
    background-color: rgba(255, 255, 255, 0.8) !important;
    background-image: none !important;
}

[data-theme="dark"] #keyboard .keyboard-key.current-key-active span {
    color: #1f2937 !important; /* Черный цвет текста, как в светлой теме */
    font-weight: 700 !important;
}

/* Стили для заблокированных уроков */
.lesson-card.cursor-not-allowed {
    cursor: not-allowed !important;
}

.lesson-card.grayscale {
    filter: grayscale(100%);
}

/* Плавные переходы для статистики */
#stat-cpm,
#stat-errors,
#stat-time,
#final-cpm,
#final-errors,
#final-time {
    font-variant-numeric: tabular-nums;
    transition: all 0.2s ease;
}

/* Стили для современной шапки */
header {
    position: relative;
}

/* Анимация появления шапки */
@keyframes headerSlideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

header {
    animation: headerSlideDown 0.5s ease-out;
}

/* Улучшенные эффекты для кнопок в шапке */
header a[href*="register"],
header button#theme-toggle {
    position: relative;
    overflow: hidden;
}

/* Эффект ripple для кнопок */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* Плавные переходы для всех интерактивных элементов в шапке */
header a,
header button {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Улучшенный hover для навигации */
header nav a {
    position: relative;
}

/* Эффект свечения для логотипа */
header a[href*="landing"] img {
    transition: all 0.3s ease;
}

header a[href*="landing"]:hover img {
    filter: drop-shadow(0 4px 12px rgba(59, 130, 246, 0.3));
}

/* Адаптивность для шапки */
@media (max-width: 768px) {
    header {
        height: auto;
        min-height: 64px;
    }
    
    header .flex.items-center.justify-between {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    header nav {
        order: 3;
        width: 100%;
        justify-content: center;
        padding-top: 0.5rem;
        border-top: 1px solid rgba(148, 163, 184, 0.2);
    }
}

/* Современные стили для списка уроков */
.lesson-card-wrapper {
    opacity: 0;
    animation: fadeInUp 0.6s ease-out forwards;
}

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

/* Плавная пульсация для следующего урока */
@keyframes pulse-slow {
    0%, 100% {
        box-shadow: 0 10px 40px rgba(59, 130, 246, 0.2);
    }
    50% {
        box-shadow: 0 10px 40px rgba(59, 130, 246, 0.4);
    }
}

.animate-pulse-slow {
    animation: pulse-slow 3s ease-in-out infinite;
}

/* Улучшенные эффекты для карточек уроков */
.lesson-card {
    position: relative;
    will-change: transform;
}

.lesson-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 2px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0), rgba(99, 102, 241, 0));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s;
}

.lesson-card:hover::before {
    opacity: 1;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.5), rgba(99, 102, 241, 0.5));
}

/* Эффект свечения для активных карточек */
.lesson-card.border-blue-400\/80 {
    box-shadow: 0 20px 60px rgba(59, 130, 246, 0.3), 0 0 0 1px rgba(59, 130, 246, 0.1);
}

.lesson-card.border-green-400\/60 {
    box-shadow: 0 10px 30px rgba(34, 197, 94, 0.2), 0 0 0 1px rgba(34, 197, 94, 0.1);
}

/* Анимация для статусных иконок */
.lesson-status-icon {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.lesson-card:hover .lesson-status-icon {
    transform: scale(1.1) rotate(5deg);
}

/* Улучшенные эффекты для актов */
.group\/act {
    transition: all 0.3s ease;
}

.group\/act:hover {
    transform: translateY(-2px);
}

/* Адаптивность для карточек уроков */
@media (max-width: 768px) {
    .lesson-card {
        padding: 1.25rem;
    }
    
    .lesson-card h3 {
        font-size: 1rem;
    }
}

/* Стили для навигации по урокам */
#lessons-navigation {
    scrollbar-width: thin;
    scrollbar-color: rgba(59, 130, 246, 0.3) transparent;
}

#lessons-navigation::-webkit-scrollbar {
    height: 6px;
}

#lessons-navigation::-webkit-scrollbar-track {
    background: rgba(148, 163, 184, 0.1);
    border-radius: 3px;
}

#lessons-navigation::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.5);
    border-radius: 3px;
}

#lessons-navigation::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 130, 246, 0.7);
}

.lesson-nav-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: fadeInUp 0.4s ease-out backwards;
}

.lesson-nav-card:nth-child(1) { animation-delay: 0.1s; }
.lesson-nav-card:nth-child(2) { animation-delay: 0.15s; }
.lesson-nav-card:nth-child(3) { animation-delay: 0.2s; }
.lesson-nav-card:nth-child(4) { animation-delay: 0.25s; }
.lesson-nav-card:nth-child(5) { animation-delay: 0.3s; }
.lesson-nav-card:nth-child(6) { animation-delay: 0.35s; }

.lesson-nav-arrow {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.lesson-nav-link {
    min-width: fit-content;
    white-space: nowrap;
}

.lesson-nav-link:hover {
    transform: translateY(-2px);
}
