/* ====== Грамматические таблицы - CSS стили ====== */

/* ====== Красивая панель word-order ====== */
.word-order-panel {
    border: none !important;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin: 5px 0 25px 0;
    overflow: hidden;
    transition: all 0.3s ease;
    background: #ffffff;
    position: relative;
}

.word-order-panel:hover {
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
    transform: translateY(-3px);
}

.word-order-panel .panel-heading {
    background: #4A7BB7;
    border: none !important;
    border-radius: 0 !important;
    padding: 20px 30px; /* Увеличил вертикальный отступ для лучшего размещения увеличенного заголовка */
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
}

.word-order-panel .panel-heading:hover {
    background: #3A6BA7; /* Немного темнее основного цвета для эффекта при наведении */
}

.word-order-panel .panel-heading h4 {
    color: #ffffff !important;
    margin: 0;
    font-weight: 700; /* Увеличил вес шрифта для большей заметности */
    font-size: 2.2em; /* Увеличил размер шрифта до уровня h1 */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    line-height: 1.2; /* Оптимальная высота строки для лучшей читаемости */
}

.word-order-panel .panel-heading h4 u {
    text-decoration: none;
    position: relative;
    padding-bottom: 5px;
}

.word-order-panel .panel-heading h4 u::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, #ffffff 0%, #edfafa 100%);
    border-radius: 2px;
    opacity: 0.8;
}

.word-order-panel .collapse-icon {
    color: #ffffff !important;
    font-size: 1.4em; /* Увеличил размер для соответствия увеличенному заголовку */
    transition: transform 0.3s ease;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

.word-order-panel .panel-heading:not(.collapsed) .collapse-icon {
    transform: rotate(180deg);
}

.word-order-panel .panel-body {
    padding: 35px;
    background: #ffffff;
    border-radius: 0 0 15px 15px;
    position: relative;
    max-height: 2000px; /* Достаточно для развернутого состояния */
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.word-order-panel.collapsed .panel-body {
    max-height: 110px; /* Ограничиваем высоту для свернутого состояния */
    overflow: hidden;
    position: relative;
}

.word-order-panel.collapsed .panel-body::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70px;
    background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 90%);
    pointer-events: none;
}

.word-order-panel .fiveo-article-text {
    font-size: 1.15em;
    line-height: 1.8;
    color: #2d3748;
}

.word-order-panel .fiveo-article-text p {
    margin-bottom: 25px;
    text-align: justify;
    position: relative;
}

/* Стили для обычного текста абзаца - без особой стилизации первой буквы */

/* Блок с примерами */
.word-order-panel .example-block {
    background: #8BAED8; /* Более светлый вариант синего #4A7BB7 */
    padding: 25px;
    border-radius: 12px;
    margin: 25px 0;
    box-shadow: 0 8px 25px rgba(74, 123, 183, 0.25); /* Тень под цвет основного синего */
    position: relative;
    overflow: hidden;
}

.word-order-panel .example-block::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.35) 0%, transparent 70%); /* Немного ярче градиент */
    pointer-events: none;
}

.word-order-panel .example-content {
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative;
    z-index: 1;
}

.word-order-panel .examples-text {
    flex: 0 0 65%;
}

.word-order-panel .example-illustration {
    flex: 0 0 35%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.word-order-panel .example-image {
    width: 100%;
    max-width: 300px;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(26, 54, 96, 0.25); /* Тень согласованная с новой цветовой схемой */
    background: rgba(255, 255, 255, 0.5); /* Немного светлее фон */
    padding: 8px;
}

.word-order-panel .example-block h5 {
    color: #1a3660; /* Более темный оттенок синего для контраста */
    font-weight: 700;
    margin-bottom: 15px;
    font-size: 1.2em;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
    position: relative;
    z-index: 1;
}

.word-order-panel .example-list {
    list-style: none;
    padding: 0;
    margin: 0;
    position: relative;
    z-index: 1;
}

.word-order-panel .example-list li {
    background: rgba(255, 255, 255, 0.4);
    color: #1a3660; /* Более темный оттенок синего для контраста */
    padding: 12px 20px;
    margin: 8px 0;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1.1em;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.3);
}

.word-order-panel .example-list li:hover {
    background: rgba(255, 255, 255, 0.6);
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(26, 54, 96, 0.15);
}

.word-order-panel .example-list li::before {
    content: "→";
    margin-right: 10px;
    font-weight: bold;
    color: #1a3660; /* Согласуем с цветом текста */
}

/* Стили для подчеркивания слов в примерах */
.word-order-panel .example-list .subject {
    text-decoration: underline;
    text-decoration-style: solid;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    text-decoration-color: #1a3660; /* Более темный оттенок синего */
}

.word-order-panel .example-list .verb {
    text-decoration: underline;
    text-decoration-style: double;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    text-decoration-color: #4A7BB7; /* Основной синий цвет */
}

.word-order-panel .example-list .object {
    text-decoration: underline;
    text-decoration-style: dashed;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    text-decoration-color: #3A6BA7; /* Темнее основного синего */
}

/* Анимация появления контента */
.word-order-panel .panel-body.collapsing,
.word-order-panel .panel-body.collapse.in {
    animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ====== Стили для сворачивающейся панели ====== */
.word-order-panel .panel-toggle {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    background: rgba(74, 123, 183, 0.8);
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    cursor: pointer;
    z-index: 10;
    font-size: 0.85em;
    transition: all 0.3s ease;
    user-select: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.word-order-panel .panel-toggle:hover {
    background: rgba(58, 107, 167, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.word-order-panel .toggle-text {
    margin-right: 6px;
    font-weight: 500;
}

.word-order-panel .toggle-icon {
    font-size: 0.9em;
    transition: transform 0.3s ease;
}

/* Адаптивные стили для кнопки на мобильных */
@media (max-width: 576px) {
    .word-order-panel .panel-toggle {
        padding: 3px 8px;
        font-size: 0.75em;
    }
    
    .word-order-panel.collapsed .panel-body {
        max-height: 80px; /* Меньшая высота на мобильных */
    }
}

/* ====== Базовая сетка ====== */
.scheme {
    max-width: 800px;
    margin: 40px auto;
    font-family: sans-serif;
    user-select: none;
    /* не выделяем текст по ошибке */
    display: grid;
    gap: 2px;
    /* разделение между строками */
}

.grid-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    /* пять одинаковых колонок */
    gap: 2px;
    /* тонкая «сеточная» линия */
}

/* Отключаем Bootstrap псевдоэлементы для grid-сетки */
.grid-row::before,
.grid-row::after {
    display: none !important;
}

.cell {
    position: relative;
    /* для псевдо-элемента tooltip */
    padding: 12px 16px;
    /* увеличиваем отступы */
    text-align: center;
    background: #f4f4f8;
    border-radius: 4px;
    cursor: default;
    transition: background .25s, transform .25s;
    font-size: 1.2em;
    /* увеличиваем размер шрифта */
}

/* ====== Заголовок строки-схемы ====== */
.grid-row.header .cell {
    font-weight: 700;
    /* убираем фиксированный цвет, чтобы применялись цвета столбцов */
}

/* ====== Цветовые блоки по столбцам ====== */
/* Subject - мягкий голубой + одинарное подчёркивание */
.cell:nth-child(1) {
    background: #e3f2fd;
}

.cell:nth-child(1):not(:empty)::before {
    content: '';
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: fit-content;
    min-width: 60%;
    height: 2px;
    background: black;
}

/* Verb - мягкий зелёный + двойное подчёркивание */
.cell:nth-child(2) {
    background: #e8f5e8;
}

.cell:nth-child(2):not(:empty)::before,
.transform-cell:not(:empty)::after {
    content: '';
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: fit-content;
    min-width: 60%;
    height: 4px;
    background-image: 
        linear-gradient(to right, black 0%, black 100%),
        linear-gradient(to right, black 0%, black 100%);
    background-size: 100% 1px, 100% 1px;
    background-position: 0 0, 0 3px;
    background-repeat: no-repeat;
    z-index: 0;
}

/* Object/Complement - мягкий персиковый + прерывистое подчёркивание */
.cell:nth-child(3) {
    background: #fff3e0;
}

.cell:nth-child(3):not(:empty)::before {
    content: '';
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: fit-content;
    min-width: 60%;
    height: 2px;
    background-image: repeating-linear-gradient(to right, black 0 8px, transparent 8px 12px);
    background-size: 12px 2px;
}

/* Where - мягкий розовый + точка-тире подчёркивание только у текста */
.cell:nth-child(4) {
    background: #fce4ec;
}

.cell:nth-child(4):not(:empty)::before {
    content: '';
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: fit-content;
    min-width: 60%;
    height: 2px;
    background-image: repeating-linear-gradient(to right, black 0 2px, transparent 2px 4px, black 4px 12px, transparent 12px 14px);
    background-size: 14px 2px;
}

/* When - мягкий лавандовый + точка-тире подчёркивание только у текста */
.cell:nth-child(5) {
    background: #f3e5f5;
}

.cell:nth-child(5):not(:empty)::before {
    content: '';
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: fit-content;
    min-width: 60%;
    height: 2px;
    background-image: repeating-linear-gradient(to right, black 0 2px, transparent 2px 4px, black 4px 12px, transparent 12px 14px);
    background-size: 14px 2px;
}

/* Убрано выделение по клику для Positive form */

/* ====== Анимация для negative form ====== */
.scheme.negative {
    position: relative;
}

/* Скрываем вторую строку изначально */
.scheme.negative .example-2 {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1;
    opacity: 0;
    transform: translateY(0);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

/* Показываем вторую строку при активации */
.scheme.negative.show-contraction .example-2 {
    opacity: 1;
    transform: translateY(calc(100% + 4px)); /* сдвигаем вниз на высоту строки + gap */
    pointer-events: auto;
}

/* ====== Анимация для positive form ====== */
.scheme.positive {
    position: relative;
    transition: all 0.5s ease;
    margin-bottom: 20px;
}

/* Базовые стили для ячеек с разными состояниями видимости */
.scheme.positive .cell {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

/* Стадия 1: Показываем только первый столбец (Subject) */
.scheme.positive[data-stage="1"] .cell:nth-child(1) {
    opacity: 1;
    transform: translateY(0);
}

/* Стадия 2: Показываем первый и второй столбцы (Subject + Verb) */
.scheme.positive[data-stage="2"] .cell:nth-child(1),
.scheme.positive[data-stage="2"] .cell:nth-child(2) {
    opacity: 1;
    transform: translateY(0);
}

/* Стадия 3: Показываем первые три столбца (Subject + Verb + Object) */
.scheme.positive[data-stage="3"] .cell:nth-child(1),
.scheme.positive[data-stage="3"] .cell:nth-child(2),
.scheme.positive[data-stage="3"] .cell:nth-child(3) {
    opacity: 1;
    transform: translateY(0);
}

/* Стадия 4: Показываем все столбцы */
.scheme.positive[data-stage="4"] .cell {
    opacity: 1;
    transform: translateY(0);
}

/* Задержка для четвертого и пятого столбцов в стадии 4 */
.scheme.positive[data-stage="4"] .cell:nth-child(4) {
    transition-delay: 0s;
}

.scheme.positive[data-stage="4"] .cell:nth-child(5) {
    transition-delay: 0.5s; /* Задержка для пятого столбца */
}

/* Стили для контролов стадий анимации positive form */
.stage-controls.positive {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    gap: 10px;
    position: relative;
}

.stage-controls .stage-btn,
.stage-controls.positive .stage-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f0f0f0;
    border: 2px solid #ddd;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.stage-controls .stage-btn:hover,
.stage-controls.positive .stage-btn:hover {
    background: #e0e0e0;
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}

.stage-controls .stage-btn.active,
.stage-controls.positive .stage-btn.active {
    background: #4A7BB7;
    color: white;
    border-color: #3A6BA7;
    box-shadow: 0 3px 10px rgba(74,123,183,0.4);
}

/* Индикатор авто-анимации для positive form */
#auto-positive-indicator {
    display: flex;
    align-items: center;
    margin-left: 10px;
    color: #4A7BB7;
    animation: spin 1.5s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Стили для описаний этапов positive form */
.positive-explanation {
    background: #f9f9f9;
    border-radius: 10px;
    padding: 15px 20px;
    margin: 20px 0 30px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

.positive-explanation .stage-description {
    display: none;
    animation: fadeIn 0.5s ease;
}

.positive-explanation .stage-description.active {
    display: block;
}

.positive-explanation h4 {
    color: #4A7BB7;
    margin-top: 0;
    font-weight: bold;
    border-bottom: 2px solid rgba(74,123,183,0.2);
    padding-bottom: 8px;
    margin-bottom: 15px;
}

.positive-explanation ul {
    padding-left: 20px;
}

.positive-explanation li {
    margin-bottom: 8px;
}

.animation-trigger.positive {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.btn-animate.positive {
    background: #4A7BB7;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 30px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(74,123,183,0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-animate.positive:hover {
    background: #3A6BA7;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(74,123,183,0.4);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Анимация для ячейки глагола при трансформации */
.transform-cell {
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.transform-cell::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(232, 245, 232, 0.4); /* Светлый фон для подсветки анимации */
    opacity: 0;
    border-radius: 4px;
    transition: opacity 0.6s ease;
    pointer-events: none;
    z-index: -1;
}

.transform-cell[data-transition-to] {
    z-index: 5; /* Поднимаем ячейку над остальными на время анимации */
}

.transform-cell[data-transition-to]::after {
    opacity: 1;
}

/* Стили для контролов для отрицательной формы */
.stage-controls {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    gap: 10px;
    position: relative;
}

#auto-transform-indicator {
    display: flex;
    align-items: center;
    margin-left: 10px;
    color: #4A7BB7;
    animation: spin 1.5s linear infinite;
}

/* Стили для описаний этапов negative form */
.transform-explanation {
    background: #f9f9f9;
    border-radius: 10px;
    padding: 15px 20px;
    margin: 20px 0 30px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

.transform-explanation .stage-description {
    display: none;
    animation: fadeIn 0.5s ease;
}

.transform-explanation .stage-description.active {
    display: block;
}

.transform-explanation h4 {
    color: #4A7BB7;
    margin-top: 0;
    font-weight: bold;
    border-bottom: 2px solid rgba(74,123,183,0.2);
    padding-bottom: 8px;
    margin-bottom: 15px;
}

.transform-explanation ul {
    padding-left: 20px;
}

.transform-explanation li {
    margin-bottom: 8px;
}

/* Стиль для кнопки запуска трансформации для Negative form */
.animation-trigger.transform {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.btn-animate.transform {
    background: #4A7BB7;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 30px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(74,123,183,0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-animate.transform:hover {
    background: #3A6BA7;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(74,123,183,0.4);
}

/* Анимация для деталей глагола (вторая таблица) */
.verb-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 1.5em;
    overflow: visible;
}

.verb-part {
    position: relative;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
    display: inline-block;
    margin: 0 2px;
}

/* Стили для вспомогательного глагола do */
.verb-part.aux {
    color: #2E7D32;
    font-weight: bold;
    opacity: 0;
    transform: translateY(-20px);
}

/* Стили для отрицания not */
.verb-part.neg {
    color: #D32F2F;
    font-weight: bold;
    opacity: 0;
    transform: translateY(-20px);
    margin: 0 3px;
}

/* Стили для апострофа */
.verb-part.apostrophe {
    color: #D32F2F;
    font-weight: bold;
    opacity: 0;
    transform: translateY(-20px);
    margin-left: 0;
    margin-right: 0;
    position: absolute;
}

/* Стили для основного глагола drink */
.verb-part.main-part {
    color: #333;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Стадии анимации */
/* Стадия 1: Показываем только основной глагол */
.transform-cell[data-transition-to="1"] .verb-part.aux,
.transform-cell[data-transition-to="1"] .verb-part.neg,
.transform-cell[data-transition-to="1"] .verb-part.apostrophe {
    opacity: 0;
    transition: all 0.3s ease-out;
}

.transform-cell[data-transition-to="1"] .verb-part.main-part {
    transform: translateX(0);
}

/* Стадия 2: Добавляем do */
.transform-cell[data-transition-to="2"] .verb-part.aux {
    opacity: 1;
    transform: translateY(5px);
}

.transform-cell[data-transition-to="2"] .verb-part.main-part {
    transform: translateX(5px);
}

.transform-cell[data-transition-to="2"] .verb-part.neg,
.transform-cell[data-transition-to="2"] .verb-part.apostrophe {
    opacity: 0;
}

/* Стадия 3: Добавляем not */
.transform-cell[data-transition-to="3"] .verb-part.aux {
    opacity: 1;
    transform: translateY(0) translateX(-5px);
}

.transform-cell[data-transition-to="3"] .verb-part.neg {
    opacity: 1;
    transform: translateY(0);
}

.transform-cell[data-transition-to="3"] .verb-part.apostrophe {
    opacity: 0;
}

.transform-cell[data-transition-to="3"] .verb-part.main-part {
    transform: translateX(10px);
}

/* Стадия 4: Контракция до don't */
.transform-cell[data-transition-to="4"] .verb-part.aux {
    opacity: 1;
    transform: translateY(0) translateX(0);
}

.transform-cell[data-transition-to="4"] .verb-part.neg {
    opacity: 0;
    transform: translateY(20px);
}

.transform-cell[data-transition-to="4"] .verb-part.apostrophe {
    opacity: 1;
    transform: translateY(0);
}

.transform-cell[data-transition-to="4"] .verb-part.main-part {
    transform: translateX(5px);
}

/* Состояния для разных этапов */
.scheme.transform[data-stage="1"] .verb-part.aux,
.scheme.transform[data-stage="1"] .verb-part.neg,
.scheme.transform[data-stage="1"] .verb-part.apostrophe {
    display: none;
}

.scheme.transform[data-stage="2"] .verb-part.aux {
    display: inline-block;
    opacity: 1;
    transform: translateY(0);
}

.scheme.transform[data-stage="2"] .verb-part.neg,
.scheme.transform[data-stage="2"] .verb-part.apostrophe {
    display: none;
}

.scheme.transform[data-stage="3"] .verb-part.aux,
.scheme.transform[data-stage="3"] .verb-part.neg {
    display: inline-block;
    opacity: 1;
    transform: translateY(0);
}

.scheme.transform[data-stage="3"] .verb-part.apostrophe {
    display: none;
}

.scheme.transform[data-stage="4"] .verb-part.aux,
.scheme.transform[data-stage="4"] .verb-part.apostrophe {
    display: inline-block;
    opacity: 1;
    transform: translateY(0);
}

.scheme.transform[data-stage="4"] .verb-part.neg {
    display: none;
}

/* Продолжение существующих стилей... */
