.specialty-nav {
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.7);
    padding: 8px 8px;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    max-width: 1400px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin: 20px auto;
    border-radius: 12px;
    border: 1px solid #1659d9;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.3s ease-in-out;
}


/* Гнучка адаптивна сітка */
.specialty-nav ul {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 8px;
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Вирівнювання елементів списку */
.specialty-nav li {
    display: flex;
    justify-content: center;
}


.specialty-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    padding: 0;
    list-style: none;
}


/* Порожні елементи для вирівнювання */
.empty-specialty {
    border: none;
    border-radius: 10px;
    min-height: 30px;
    visibility: visible;
    background: rgba(49, 130, 206, 0.08);
    border-left: 2px solid #3182ce;
    border-right: 2px solid #3182ce;
    color: #2c3e50;
}


/* Кнопки навігації */
.specialty-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 4px;
    width: 100%;
    min-height: 35px;
    background: rgba(49, 130, 206, 0.08);
    color: #2c3e50;
    border-radius: 10px;
    border-left: 2px solid #3182ce !important;
    border-right: 2px solid #3182ce !important;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.25s ease;
    border-top: 1px solid rgba(246, 242, 242, 0.75) !important;
    border-bottom: 1px solid #f8f5f5 !important;
    position: relative;
}

/* Внутрішній контейнер для тексту */
.specialty-nav a span {
    display: block;
    flex: 1;
    font-size: 0.9rem;
    text-align: center;
    line-height: 1.3;
    white-space: normal;
    margin-left: 40px;
}

/* Іконка завжди зліва */
.specialty-nav a i {
    font-size: 1.1em;
    color: #4a90e2;
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
}

/* Ефекти при наведенні */
.specialty-nav a:hover {
    background: #4a90e2;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
    border-color: transparent;
}

.specialty-nav a:hover i {
    color: white;
}


/* Активний стан кнопки при скролі */
.specialty-nav a.active {
    background: #007bff !important;
    color: white !important;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.specialty-nav a.active i {
    color: white !important;
}


.specialty-a2b-section {
    padding: 2rem 1rem;
    background: #f8fbff;
    border-radius: 1rem;
    margin: auto;
}

.specialty-a2b-title {
    text-align: center;
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.specialty-a2b-subtitle {
    text-align: center;
    font-size: 1rem;
    color: #555;
    margin-bottom: 1.5rem;
}

.specialty-group-heading {
    font-size: 1.2rem;
    color: #004488;
    margin: 1rem 0 0.8rem;
    font-weight: 600;
}

.specialty-a2b-grid {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.specialty-a2b-block {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    border: 1px solid rgba(12, 182, 232, 0.74);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    padding: 0.4rem 0.6rem;
    gap: 0.5rem;
    flex-wrap: wrap;
}


.specialty-a2b-left,
.specialty-a2b-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
	text-align: left;
    font-size: 1rem;
    font-weight: 500;
    flex: 1 1 45%;
    padding: 0.2rem 0.4rem;
    border-radius: 0.5rem;
}

.specialty-block-leftwrap {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1 1 45%;
}


.specialty-a2b-icon {
    font-size: 1.2rem;
}

.specialty-a2b-code,
.specialty-a2b-code-new {
    font-weight: bold;
    font-size: 1.2rem;
    color: #222;
}

.specialty-a2b-arrow {
    font-size: 1.2rem;
    color: #666;
    text-align: center;
    width: 1.5rem;
}

.specialty-a2b-left,
.specialty-a2b-right {
    min-height: 2.5rem;
    line-height: 1.2;
}

/* Прогрес-бар для навігаційних кнопок */
.specialty-nav a {
    position: relative;
    overflow: hidden;
}

.nav-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    width: 0%;
    background: linear-gradient(90deg, #ffb74d, #ff9800);
    transition: width 0.15s ease-out;
    border-radius: 0 0 10px 10px;
    z-index: 1;
}

.specialty-nav a.active .nav-progress {
    box-shadow: 0 0 10px rgba(255, 183, 77, 0.8);
}

/* Альтернативний варіант: прогрес зверху */
.nav-progress.top {
    top: 0;
    bottom: auto;
    border-radius: 10px 10px 0 0;
}

/* Група D — Бізнес, адміністрування та право */
.group-d .specialty-a2b-left {
    background: #e1efff;
}

.group-d .specialty-a2b-right {
    background: #e5fbe0;
}

/* Група F — Інформаційні технології */
.group-f .specialty-a2b-left {
    background: #ffe9f0;
}

.group-f .specialty-a2b-right {
    background: #e0f5ff;
}

/* Група G — Інженерія, виробництво та будівництво */
.group-g .specialty-a2b-left {
    background: #f3f0ff;
}

.group-g .specialty-a2b-right {
    background: #e3ffe3;
}

/* Група J — Транспорт та послуги */
.group-j .specialty-a2b-left {
    background: #fff2dc;
}

.group-j .specialty-a2b-right {
    background: #e7f7ff;
}


.specialty-block-icon {
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
    margin-right: 0.2rem;
    border-radius: 50%;
    border: 2px solid var(--group-color, #ccc);
    padding: 2px;
}


/* Основний контейнер */
.specialty-container {
    display: flex;
    flex-wrap: wrap;
    margin: 40px auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    max-width: none;
    width: 100%;
    align-items: center;
}

/* Контейнер для дзеркальних блоків */
.specialty-container.reverse {
    flex-direction: row-reverse;
}

/* Блок зображення */
.specialty-image {
    flex: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border-right: 2px solid #ddd;
}

.specialty-container.reverse .specialty-image {
    border-left: 2px solid #ddd;
    border-right: none;
}

.specialty-container,
.specialty-container.reverse {
    display: flex;
    align-items: stretch;
}


.specialty-image img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    border: 1px solid #1659d9;
}

/* Контейнер контенту */
.specialty-content {
    flex: 2;
    padding: 20px;
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.specialty-content h2 {
    font-size: 26px;
    margin-top: 5px;
    margin-bottom: 15px;
    color: #2c3e50;
}

.specialty-content h2 i {
    margin-right: 10px;
    color: #007bff;
}


.specialty-content p {
    font-size: 16px;
    color: #161515;
    margin: 8px 0px;
    text-align: justify;
    text-indent: 12px;
}

/* Освітні програми */
.program-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.program-item {
    display: flex;
    justify-content: space-between;
    border-left: 3px solid #3182ce;
    align-items: center;
    padding: 12px;
    margin-top: 15px;
    border-radius: 10px;
    background: #f8f9fa;
    transition: 0.3s ease-in-out;
    gap: 10px;
}

.program-item span {
    flex-grow: 1;
    white-space: normal;
    text-align: left;
    font-weight: 500;
}

.program-item button {
    background: #007bff;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    transition: 0.3s;
    display: flex;
    align-items: center;
}

.program-item button i {
    font-size: 14px;
}

.program-item button:hover {
    background: #0056b3;
}

/* Телефонні номери */
.phone-numbers {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 20px;
}

.phone-numbers a {
    text-decoration: none;
    color: #00c;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.phone-numbers a:hover {
    text-decoration: underline;
}


/* Початковий стан анімованих елементів */
.animate {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backface-visibility: hidden; /* Виправляє розмиття */
    transform-style: preserve-3d;
    filter: blur(0); /* Примушує браузер правильно рендерити текст */
}

/* Видимий стан */
.animate.visible {
    opacity: 1;
    transform: translateY(0);
}


/* Послідовність анімації */
.specialty-content h2 {
    transition-delay: 0.1s;
}

.specialty-content p {
    transition-delay: 0.2s;
}

.program-item:nth-child(1) {
    transition-delay: 0.3s;
}

.program-item:nth-child(2) {
    transition-delay: 0.4s;
}

.program-item:nth-child(3) {
    transition-delay: 0.5s;
}

.phone-numbers a:nth-child(1) {
    transition-delay: 0.6s;
}

.phone-numbers a:nth-child(2) {
    transition-delay: 0.7s;
}

.phone-numbers a:nth-child(3) {
    transition-delay: 0.8s;
}


/* Адаптація */
@media (max-width: 1024px) {
    .specialty-container,
    .specialty-container.reverse {
        flex-direction: column;
        width: 95%;
    }

    .specialty-image {
        flex: 1;
        padding: 10px;
        border-right: none;
        border-bottom: 2px solid #ddd;
    }

    .specialty-content {
        padding: 30px;
    }

    .program-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .program-item button {
        align-self: flex-end;
    }

}


/* Для мобільних пристроїв (до 992px) - список знаходиться вгорі */
@media (max-width: 992px) {
    .specialty-nav {
        position: static;
        padding: 0;
        margin: 0 auto;
        background: #fff;
        max-width: 90%;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        border-right: none !important;
    }

    .specialty-list {
        display: block !important;
        position: static;
        padding: 0;
    }

    .specialty-nav a {
        display: flex;
        align-items: center;
        gap: 6px;
        min-height: 35px;
        padding: 1px 10px;
        margin: 3px 5px;
        font-size: 15px;
        border-radius: 10px;
        background: rgba(49, 130, 206, 0.08);
        border-left: 3px solid #3182ce !important;
        transition: all 0.3s ease-in-out;
        touch-action: manipulation;
        border-right: none !important;
    }

    /* Відступи для першого та передостаннього елемента */
    .specialty-list li:first-child {
        margin-top: 3px;
    }

    .specialty-list li:nth-last-child(2) {
        margin-bottom: 3px;
    }

    /* Стилі іконок */
    .specialty-nav a i {
        font-size: 1em;
        color: #007bff;
    }

    /* Приховуємо останні 4 елементи у списку */
    .specialty-list li:nth-last-child(-n+1) {
        display: none;
    }
}

/* Оптимізація для ще менших екранів (до 768px) */
@media (max-width: 768px) {
    .specialty-a2b-block {

        align-items: stretch;
        padding: 0.6rem;
    }

    .specialty-a2b-left,
    .specialty-a2b-right {
        min-height: 3.8rem; /* або більше, 4.2rem для 3 рядків */
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        flex-direction: column;
    }

    .specialty-a2b-arrow {
        width: 100%;
        text-align: center;
        transform: rotate(90deg);
        margin: 0.4rem 0;
    }

    .specialty-a2b-code,
    .specialty-a2b-code-new {
        font-size: 0.95rem;
    }

    .specialty-content {
        padding: 20px;
    }

    .specialty-container.reverse {
        flex-direction: column;
    }

    .specialty-image {
        border-right: none;
        border-bottom: 2px solid #ddd;
    }

    .specialty-container.reverse .specialty-image {
        border-left: none;
        border-bottom: 2px solid #ddd;
    }

    .specialty-content h2 {
        font-size: 18px;
        text-align: center;
    }

    .specialty-content p {
        font-size: 14px;
    }

    .program-item {
        flex-direction: column;
        align-items: stretch;
    }

    .program-item button {
        width: 100%;
        justify-content: center;
    }

    .phone-numbers {
        align-items: center; /* Центруємо телефони */
        text-align: center;
    }
}


