/* ============================================
   FLIP КАРТКИ ЕКСПЕРТІВ
   3D перевертання карток при кліку
   ============================================ */

/* КОНТЕЙНЕР КАРТКИ З ПЕРСПЕКТИВОЮ */
.expert-card {
    perspective: 1000px;
    cursor: pointer;
    transition: none;
    box-shadow: none;
}

.expert-card:hover {
    transform: none;
    box-shadow: none;
}

.expert-card:active {
    transform: none;
}

/* ВНУТРІШНЯ ОБГОРТКА ДЛЯ FLIP */
.expert-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 450px;
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
    transform-style: preserve-3d;
}

/* FLIP СТАН */
.expert-card.flipped .expert-card-inner {
    transform: rotateY(180deg);
}

/* ЛИЦЬОВА ТА ЗАДНЯ СТОРОНИ */
.expert-card-front,
.expert-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    overflow: hidden;
    background: #e9e9e9;
    border: 1px solid var(--color-border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.3s ease;
}

/* ЛИЦЬОВА СТОРОНА */
.expert-card-front {
    z-index: 2;
    transform: rotateY(0deg);
}

/* ФОТО ТА КОНТЕНТ НА FRONT */
.expert-card-front .expert-photo {
    width: 100%;
    height: 250px;
    flex-shrink: 0;
}

.expert-card-front .expert-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px 20px 20px;
    min-height: 200px;
}

/* ІМ'Я ТА СПЕЦІАЛІЗАЦІЯ */
.expert-card-front .expert-name {
    margin-bottom: 8px;
    text-align: center;
}

.expert-card-front .expert-specialization {
    flex: 1;
    margin-bottom: 16px;
}

/* ТЕКСТОВЕ ПОСИЛАННЯ "ДЕТАЛЬНІШЕ" */
.expert-detail-link {
    display: block;
    color: #d32f2f;
    font-size: 0.9375rem;
    font-family: 'Roboto', sans-serif;
    font-weight: 500;
    text-decoration: underline;
    text-align: center;
    cursor: pointer;
    transition: color 0.3s ease, text-decoration-color 0.3s ease;
    padding-bottom: 4px;
}

.expert-detail-link:hover {
    color: #b71c1c;
    text-decoration-color: #b71c1c;
}

/* КНОПКА "ДЕТАЛЬНІШЕ" */
.expert-detail-btn {
    display: block;
    width: 100%;
    background: none;
    border: none;
    color: #d32f2f;
    font-size: 0.9375rem;
    font-family: 'Roboto', sans-serif;
    font-weight: 500;
    text-decoration: underline;
    text-align: center;
    cursor: pointer;
    transition: color 0.3s ease, text-decoration-color 0.3s ease;
    padding: 4px 0;
    font-family: inherit;
}

.expert-detail-btn:hover {
    color: #b71c1c;
    text-decoration-color: #b71c1c;
}

/* HOVER ЕФЕКТ ДЛЯ FRONT */
.expert-card:hover .expert-card-front {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.expert-card:hover .expert-card-back {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* ЗАДНЯ СТОРОНА */
.expert-card-back {
    transform: rotateY(180deg);
    align-items: flex-start;
    justify-content: flex-start;
    padding: 32px 24px;
}

/* КОНТЕНТ НА ЗАДНІЙ СТОРОНІ */
.expert-bio-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.expert-name-back {
    font-size: 1.125rem;
    font-family: 'Roboto', sans-serif;
    font-weight: 600;
    color: #2a2a2a;
    margin: 0 0 12px 0;
    text-align: center;
    line-height: 1.4;
}

.expert-bio-text {
    font-size: 0.9375rem;
    font-family: 'Roboto', sans-serif;
    line-height: 1.6;
    color: #333333;
    text-align: justify;
}

.expert-bio-text p {
    margin: 0 0 6px 0;
}

.expert-bio-text p:last-child {
    margin-bottom: 0;
}

/* ============================================
   АДАПТИВНІСТЬ - ПЛАНШЕТИ (769px - 1024px)
   ============================================ */
@media (min-width: 768px) and (max-width: 1024px) {
    .expert-card-inner {
        min-height: 420px;
    }

    .expert-card-front .expert-photo {
        height: 280px;
    }

    .expert-card-front .expert-card-content {
        padding: 20px 16px 18px;
        min-height: 180px;
    }

    .expert-card-back {
        padding: 28px 20px;
    }

    .expert-name-back {
        font-size: 1.125rem;
        font-family: 'Roboto', sans-serif;
    }

    .expert-bio-text {
        font-size: 0.875rem;
        font-family: 'Roboto', sans-serif;
        text-align: justify;
    }

    .expert-detail-link {
        font-size: 0.875rem;
        font-family: 'Roboto', sans-serif;
    }
}

/* ============================================
   АДАПТИВНІСТЬ - МОБІЛЬНІ (480px - 768px)
   ============================================ */
@media (min-width: 480px) and (max-width: 767px) {
    .expert-card-inner {
        min-height: 400px;
    }

    .expert-card-front .expert-photo {
        height: 50%;
    }

    .expert-card-front .expert-card-content {
        padding: 16px 12px 14px;
        min-height: 160px;
    }

    .expert-card-back {
        padding: 24px 18px;
    }

    .expert-name-back {
        font-size: 1.0625rem;
        font-family: 'Roboto', sans-serif;
    }

    .expert-bio-text {
        font-size: 0.8125rem;
        font-family: 'Roboto', sans-serif;
        line-height: 1.5;
        text-align: justify;
    }

    .expert-bio-text p {
        margin: 0 0 6px 0;
    }

    .expert-detail-link {
        font-size: 0.8125rem;
        font-family: 'Roboto', sans-serif;
    }
}

/* ============================================
   АДАПТИВНІСТЬ - МАЛІ МОБІЛЬНІ (до 479px)
   ============================================ */
@media (max-width: 767px) {
    .expert-card-inner {
        min-height: 430px;
    }

    .expert-card-front .expert-photo {
        height: 50%;
    }

    .expert-card-front .expert-card-content {
        padding: 18px 16px 16px;
        min-height: 150px;
    }

    .expert-card-back {
        padding: 20px 16px;
    }

    .expert-name-back {
        font-size: 1rem;
        font-family: 'Roboto', sans-serif;
    }

    .expert-bio-text {
        font-size: 0.609rem;
        font-family: 'Roboto', sans-serif;
        line-height: 1.5;
        text-align: justify;
    }

    .expert-bio-text p {
        margin: 0 0 6px 0;
    }

    .expert-card-front .expert-name {
        font-size: 0.667rem;
        font-family: 'Roboto', sans-serif;
        text-align: center;
    }

    .expert-detail-link {
        font-size: 0.875rem;
        font-family: 'Roboto', sans-serif;
    }

    /* Дозволити вертикальний scroll для контенту на задній стороні */
    .expert-bio-content {
        touch-action: pan-y;
    }
}

/* ============================================
   iOS SAFARI ОПТИМІЗАЦІЯ
   ============================================ */
@supports (-webkit-touch-callout: none) {
    .expert-card {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }

    .expert-card-inner {
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
        -webkit-transform-style: preserve-3d;
        transform-style: preserve-3d;
    }

    .expert-card-front,
    .expert-card-back {
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }

    .expert-bio-content {
        -webkit-overflow-scrolling: touch;
    }
}

/* ============================================
   DARK THEME
   ============================================ */
[data-theme="dark"] .expert-card-front,
[data-theme="dark"] .expert-card-back {
    background: var(--color-bg-gray);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .expert-card:hover .expert-card-front,
[data-theme="dark"] .expert-card:hover .expert-card-back {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .expert-name-back {
    color: var(--color-text);
}

[data-theme="dark"] .expert-bio-text {
    color: var(--color-text-light);
}

[data-theme="dark"] .expert-detail-link {
    color: #d32f2f;
}

[data-theme="dark"] .expert-detail-link:hover {
    color: #b71c1c;
}

@media (prefers-color-scheme: dark) {

    [data-theme="auto"] .expert-card-front,
    [data-theme="auto"] .expert-card-back {
        background: var(--color-bg-gray);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    }

    [data-theme="auto"] .expert-card:hover .expert-card-front,
    [data-theme="auto"] .expert-card:hover .expert-card-back {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    }

    [data-theme="auto"] .expert-name-back {
        color: var(--color-text);
    }

    [data-theme="auto"] .expert-bio-text {
        color: var(--color-text-light);
    }

    [data-theme="auto"] .expert-detail-link {
        color: #d32f2f;
    }

    [data-theme="auto"] .expert-detail-link:hover {
        color: #b71c1c;
    }
}