/* ============================================================
   ОСНОВНЫЕ СТИЛИ
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: #FFFDF8;
}

/* ============================================================
   HEADER — ЭФФЕКТ ПРИ СКРОЛЛЕ
   ============================================================ */
header {
    background: #FFFDF8;
    transition: background 0.3s ease, backdrop-filter 0.3s ease, box-shadow 0.3s ease;
}

header.scrolled {
    background: rgba(255, 253, 248, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

/* ============================================================
   АНИМАЦИИ
   ============================================================ */
.fade-up {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeUp 0.8s ease forwards;
}

@keyframes fadeUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-left {
    opacity: 0;
    transform: translateX(-30px);
    animation: fadeLeft 0.8s ease forwards;
}

@keyframes fadeLeft {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.fade-right {
    opacity: 0;
    transform: translateX(40px) scale(0.97);
    animation: fadeRight 0.8s ease forwards;
}

@keyframes fadeRight {
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.scale-in {
    opacity: 0;
    transform: scale(0.98);
    animation: scaleIn 0.8s ease forwards;
}

@keyframes scaleIn {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================================
   КАРТОЧКИ УСЛУГ
   ============================================================ */
.service-card {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeUp 0.6s ease forwards;
}

.service-card:nth-child(1) {
    animation-delay: 0.05s;
}

.service-card:nth-child(2) {
    animation-delay: 0.10s;
}

.service-card:nth-child(3) {
    animation-delay: 0.15s;
}

.service-card:nth-child(4) {
    animation-delay: 0.20s;
}

.service-card:nth-child(5) {
    animation-delay: 0.25s;
}

.service-card:nth-child(6) {
    animation-delay: 0.30s;
}

/* ============================================================
   ОБЛОЖКА КАРТОЧКИ — ПОЗИЦИОНИРОВАНИЕ ВВЕРХ/СЕРЕДИНА
   ============================================================ */
.service-cover-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    overflow: hidden;
    background: #E8DED4;
}

.service-cover-wrapper .service-cover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    transition: transform 0.7s ease;
}

.service-card:hover .service-cover-wrapper .service-cover {
    transform: scale(1.05);
}

/* ============================================================
   МИНИАТЮРЫ В КАРТОЧКАХ — КВАДРАТНЫЕ
   ============================================================ */
.thumbnail {
    position: relative;
    aspect-ratio: 1/1;
    overflow: hidden;
    border-radius: 0.75rem;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    cursor: pointer;
}

.thumbnail .thumbnail-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
}

.thumbnail.active {
    border-color: #7E3D46;
    opacity: 1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.thumbnail:not(.active) {
    border-color: transparent;
    opacity: 0.65;
}

.thumbnail:not(.active):hover {
    opacity: 1;
}

/* ============================================================
   МОДАЛЬНОЕ ОКНО
   ============================================================ */
#serviceModal {
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#serviceModal:not(.hidden) {
    display: flex !important;
    opacity: 1;
}

.modal-content {
    transform: scale(0.95);
    transition: transform 0.25s ease;
    max-width: 1200px;
    width: 100%;
    height: 90vh;
    max-height: 90vh;
}

#serviceModal:not(.hidden) .modal-content {
    transform: scale(1);
}

/* Стрелки навигации в модалке */
#modalPrev,
#modalNext {
    opacity: 0;
    transition: opacity 0.3s ease, background 0.3s ease, transform 0.3s ease;
    z-index: 20;
    padding: 12px;
    border-radius: 50%;
    background: rgba(52, 52, 52, 0.4);
    color: white;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    cursor: pointer;
    border: none;
    outline: none;
}

#serviceModal:not(.hidden) #modalPrev,
#serviceModal:not(.hidden) #modalNext {
    opacity: 1;
}

#modalPrev:hover,
#modalNext:hover {
    background: rgba(52, 52, 52, 0.6);
    transform: translateY(-50%) scale(1.1);
}

#modalPrev {
    left: 20px;
    top: 60%;
    transform: translateY(-50%);
}

#modalNext {
    right: 20px;
    top: 60%;
    transform: translateY(-50%);
}

/* Мобильная версия модалки */
@media (max-width: 768px) {
    .modal-content {
        max-height: 80vh;
        max-width: 95vw;
        border-radius: 1.5rem;
        height: 80vh;
    }

    #modalMainImage {
        min-height: 200px;
        aspect-ratio: 4/3;
    }

    #modalPrev,
    #modalNext {
        padding: 8px;
        width: 40px;
        height: 40px;
    }

    #modalPrev svg,
    #modalNext svg {
        width: 20px;
        height: 20px;
    }

    #modalPrev {
        left: 8px;
        top: 55%;
    }

    #modalNext {
        right: 8px;
        top: 55%;
    }
}

/* Точки навигации */
.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 253, 248, 0.5);
    transition: all 0.2s ease;
    cursor: pointer;
}

.dot.active {
    width: 32px;
    background: #FFFDF8;
}

/* Скролл в модалке */
#modalInfo::-webkit-scrollbar {
    width: 4px;
}

#modalInfo::-webkit-scrollbar-track {
    background: transparent;
}

#modalInfo::-webkit-scrollbar-thumb {
    background: #B08B57;
    border-radius: 4px;
}

/* Модальное изображение — фиксированный размер с object-contain */
#modalMainImage {
    position: relative;
    background: #E8DED4;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 4/3;
    min-height: 400px;
    overflow: hidden;
    flex-shrink: 0;
}

#modalMainImage img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Модальные миниатюры — КВАДРАТНЫЕ */
#modalThumbnails {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    flex: 1;
    align-content: start;
}

#modalThumbnails .modal-thumb {
    position: relative;
    aspect-ratio: 1/1;
    overflow: hidden;
    border-radius: 0.75rem;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    cursor: pointer;
}

#modalThumbnails .modal-thumb .modal-thumb-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
}

#modalThumbnails .modal-thumb.border-\[\#7E3D46\] {
    border-color: #7E3D46;
}

#modalThumbnails .modal-thumb:not(.border-\[\#7E3D46\]):hover {
    border-color: rgba(126, 61, 70, 0.5);
}

/* ============================================================
   WORKSHOPS — ИКОНКИ
   ============================================================ */
.workshop-icon {
    width: 60px;
    height: 60px;
    min-width: 60px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 1rem;
    background: #7E3D46;
    color: #FFFDF8;
    transition: transform 0.3s ease;
}

.group:hover .workshop-icon {
    transform: scale(1.1);
}

/* ============================================================
   СТРЕЛКИ НАВИГАЦИИ В МОДАЛКЕ
   ============================================================ */
#modalPrev,
#modalNext {
    opacity: 0;
    transition: opacity 0.3s ease, background 0.3s ease, transform 0.3s ease;
    z-index: 20;
    padding: 12px;
    border-radius: 50%;
    background: rgba(52, 52, 52, 0.4);
    color: white;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    cursor: pointer;
    border: none;
    outline: none;
    /* Позиционирование через absolute, top и transform уже заданы в HTML через классы */
}

#serviceModal:not(.hidden) #modalPrev,
#serviceModal:not(.hidden) #modalNext {
    opacity: 1;
}

#modalPrev:hover,
#modalNext:hover {
    background: rgba(52, 52, 52, 0.6);
    transform: translateY(-50%) scale(1.1);
}

/* Мобильная версия */
@media (max-width: 768px) {

    #modalPrev,
    #modalNext {
        padding: 8px;
        width: 40px;
        height: 40px;
    }

    #modalPrev svg,
    #modalNext svg {
        width: 20px;
        height: 20px;
    }
}

/* ============================================================
   УБИРАЕМ ОБВОДКУ У АКТИВНОЙ МИНИАТЮРЫ НА СТРАНИЦЕ И В МОДАЛКЕ
   ============================================================ */
.thumbnail.active {
    border-color: transparent !important;
    opacity: 1;
    box-shadow: none !important;
}

.thumbnail.active .thumbnail-img {
    outline: 2px solid #7E3D46;
    outline-offset: 2px;
}

/* Для модальных миниатюр - убираем обводку */
.modal-thumb.border-\[\#7E3D46\] {
    border-color: transparent !important;
}

.modal-thumb.border-\[\#7E3D46\] .modal-thumb-img {
    outline: 2px solid #7E3D46;
    outline-offset: 2px;
}

/* ============================================================
   МОДАЛЬНОЕ ОКНО - МОБИЛЬНАЯ ВЕРСИЯ
   ============================================================ */

/* Тень для текста на мобильных */
.text-shadow-lg {
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

/* Мобильная версия модалки */
@media (max-width: 768px) {
    #serviceModal .modal-content {
        height: 100vh;
        max-height: 100vh;
        border-radius: 1.5rem !important;
        max-width: 100vw;
        width: 100%;
        overflow: hidden;
        background: #FAF7F2 !important;
    }

    #serviceModal #modalMainImage {
        width: 100% !important;
        height: 100% !important;
        min-height: auto;
        aspect-ratio: auto;
        border-radius: 1.5rem 1.5rem 0 0 !important;
        flex: 1;
        background: #E8DED4;
        align-items: flex-start !important;
        justify-content: center;
        padding-top: 0;
    }

    #serviceModal #modalMainImage img {
        max-height: 100%;
        width: 100%;
        height: auto;
        object-fit: contain;
        object-position: top center;
    }

    /* Затемнение градиент для заголовка */
    #serviceModal #modalMainImage .image-gradient {
        position: absolute;
        inset: 0;
        background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3) 0%, transparent 30%, transparent 70%, rgba(0, 0, 0, 0.2) 100%);
        pointer-events: none;
        border-radius: 1.5rem 1.5rem 0 0;
    }

    /* Стрелки на мобильных */
    #serviceModal #modalPrev,
    #serviceModal #modalNext {
        padding: 10px;
        width: 44px;
        height: 44px;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border: 1px solid rgba(255, 255, 255, 0.15);
    }

    #serviceModal #modalPrev:hover,
    #serviceModal #modalNext:hover {
        background: rgba(0, 0, 0, 0.6);
    }

    #serviceModal #modalPrev svg,
    #serviceModal #modalNext svg {
        width: 22px;
        height: 22px;
    }

    #serviceModal #modalPrev {
        left: 12px;
    }

    #serviceModal #modalNext {
        right: 12px;
    }

    /* Точки на мобильных - скрываем */
    #serviceModal #modalDots {
        display: none;
    }

    /* Контейнер для миниатюр и ссылки */
    #modalThumbnailsMobile {
        position: absolute;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        padding: 12px 12px 16px 12px !important;
        z-index: 20;
        background: linear-gradient(to top, rgba(250, 247, 242, 1) 60%, rgba(250, 247, 242, 0) 100%);
        border-radius: 0 0 1.5rem 1.5rem;
    }

    #modalThumbnailsMobileGrid {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px !important;
        width: 100%;
    }

    #modalThumbnailsMobile .modal-thumb-mobile {
        position: relative;
        aspect-ratio: 1/1 !important;
        overflow: hidden;
        border-radius: 0.5rem;
        border: 2px solid transparent;
        transition: all 0.3s ease;
        cursor: pointer;
        background: #E8DED4;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0;
        flex-shrink: 0;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    #modalThumbnailsMobile .modal-thumb-mobile.active {
        border-color: #7E3D46;
        box-shadow: 0 0 20px rgba(126, 61, 70, 0.3);
        transform: scale(1.05);
    }

    #modalThumbnailsMobile .modal-thumb-mobile img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center top;
    }

    #modalThumbnailsMobile .modal-thumb-mobile .thumb-overlay {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.05);
        transition: background 0.3s ease;
        pointer-events: none;
    }

    #modalThumbnailsMobile .modal-thumb-mobile.active .thumb-overlay {
        background: rgba(126, 61, 70, 0.1);
    }

    /* Мобильная ссылка "Узнать подробнее" */
    #modalThumbnailsMobile .service-details-btn {
        margin-top: 10px;
        font-size: 0.9rem;
        padding: 10px 16px;
        border-radius: 0.75rem;
        background: #7E3D46;
        color: #FFFDF8 !important;
        border: none;
        transition: all 0.3s ease;
        font-weight: 600;
        letter-spacing: 0.3px;
        box-shadow: 0 4px 12px rgba(126, 61, 70, 0.3);
    }

    #modalThumbnailsMobile .service-details-btn:hover {
        background: #6D333C;
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(126, 61, 70, 0.4);
    }

    #modalThumbnailsMobile .service-details-btn:active {
        transform: scale(0.97);
    }

    #modalThumbnailsMobile .service-details-btn svg {
        stroke: #FFFDF8;
    }

    /* Заголовок на мобильных - над миниатюрами, без фона */
    #modalTitleMobile {
        position: absolute;
        bottom: calc(12px + 8px + (100vw / 4 - 8px) + 10px + 44px + 12px) !important;
        /* bottom + gap + высота миниатюры + margin-top + высота ссылки + отступ */
        left: 16px !important;
        right: 16px !important;
        font-size: 3rem !important;
        font-weight: 700 !important;
        color: #ffffff;
        text-shadow: 0 2px 8px rgba(78, 78, 78, 0.5);
        z-index: 15;
        line-height: 1.2;
        background: none !important;
        padding: 0 !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        max-width: 100%;
        display: block;
    }
}

/* Для очень маленьких экранов */
@media (max-width: 480px) {
    #serviceModal .modal-content {
        border-radius: 1rem !important;
    }

    #serviceModal #modalMainImage {
        border-radius: 1rem 1rem 0 0 !important;
    }

    #serviceModal #modalMainImage .image-gradient {
        border-radius: 1rem 1rem 0 0;
    }

    #modalThumbnailsMobile {
        padding: 8px 8px 12px 8px !important;
        border-radius: 0 0 1rem 1rem;
    }

    #modalThumbnailsMobileGrid {
        gap: 5px !important;
    }

    #modalThumbnailsMobile .modal-thumb-mobile {
        border-radius: 0.375rem;
        border-width: 2px;
    }

    #modalTitleMobile {
        font-size: 2rem !important;
        bottom: calc(8px + 5px + (100vw / 4 - 5px) + 8px + 38px + 8px) !important;
        left: 12px !important;
        right: 12px !important;
    }

    #serviceModal #modalPrev,
    #serviceModal #modalNext {
        padding: 8px;
        width: 36px;
        height: 36px;
    }

    #serviceModal #modalPrev svg,
    #serviceModal #modalNext svg {
        width: 18px;
        height: 18px;
    }

    #serviceModal #modalPrev {
        left: 8px;
    }

    #serviceModal #modalNext {
        right: 8px;
    }

    #modalThumbnailsMobile .service-details-btn {
        font-size: 0.8rem;
        padding: 8px 12px;
        margin-top: 8px;
        border-radius: 0.5rem;
    }
}

/* Для больших мобильных экранов */
@media (min-width: 481px) and (max-width: 768px) {
    #modalThumbnailsMobileGrid {
        gap: 10px !important;
    }

    #modalThumbnailsMobile {
        padding: 16px 16px 20px 16px !important;
    }

    #modalThumbnailsMobile .modal-thumb-mobile {
        border-radius: 0.625rem;
    }

    #modalTitleMobile {
        font-size: 2rem !important;
        bottom: calc(16px + 10px + (100vw / 4 - 10px) + 12px + 48px + 16px) !important;
        left: 20px !important;
        right: 20px !important;
    }

    #modalThumbnailsMobile .service-details-btn {
        font-size: 1rem;
        padding: 12px 20px;
        margin-top: 12px;
    }
}

/* Для экранов с высотой меньше 700px (компактные телефоны) */
@media (max-height: 700px) {
    #serviceModal .modal-content {
        height: 100vh;
        max-height: 100vh;
        border-radius: 1rem !important;
    }

    #serviceModal #modalMainImage {
        border-radius: 1rem 1rem 0 0 !important;
    }

    #serviceModal #modalMainImage .image-gradient {
        border-radius: 1rem 1rem 0 0;
    }

    #modalTitleMobile {
        font-size: 2rem !important;
        bottom: calc(6px + 4px + (100vw / 4 - 4px) + 5px + 30px + 6px) !important;
        left: 10px !important;
        right: 10px !important;
    }

    #modalThumbnailsMobile {
        padding: 6px 6px 10px 6px !important;
        border-radius: 0 0 1rem 1rem;
    }

    #modalThumbnailsMobileGrid {
        gap: 4px !important;
    }

    #modalThumbnailsMobile .modal-thumb-mobile {
        border-radius: 0.25rem;
        border-width: 1.5px;
    }

    #modalThumbnailsMobile .service-details-btn {
        font-size: 0.7rem;
        padding: 5px 10px;
        margin-top: 5px;
        border-radius: 0.375rem;
    }

    #serviceModal #modalPrev,
    #serviceModal #modalNext {
        padding: 6px;
        width: 30px;
        height: 30px;
    }

    #serviceModal #modalPrev svg,
    #serviceModal #modalNext svg {
        width: 14px;
        height: 14px;
    }

    #serviceModal #modalPrev {
        left: 6px;
    }

    #serviceModal #modalNext {
        right: 6px;
    }
}

/* ===== Мобильное меню ===== */
#mobileMenu {
    transition: opacity 0.25s ease, transform 0.25s ease;
    transform-origin: top center;
}

#mobileMenu.is-open {
    display: block;
    animation: mobileMenuFade 0.25s ease;
}

@keyframes mobileMenuFade {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Блокировка прокрутки body при открытом меню */
body.mobile-menu-open {
    overflow: hidden;
}