/* =========================================
   Block: Ecosystem
   ========================================= */

.ecosystem {
    padding: 96px 0;
    background: #f2f2f2;
    overflow: hidden; /* предотвращает горизонтальный скролл от hex-grid */
}

/* --- Header row --- */
.ecosystem__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 56px;
}

.ecosystem__intro {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
    margin-bottom: 72px;
}

.ecosystem__label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--color-primary);
}

.ecosystem__heading {
    font-size: clamp(26px, 4vw, 52px);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.05;
    color: var(--color-text);
}

.ecosystem__scroll-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-family: var(--font-data);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    transition: color 0.2s ease;
    margin-top: 4px;
}

.ecosystem__scroll-link svg { transition: transform 0.3s ease; }

@media (hover: hover) {
    .ecosystem__scroll-link:hover { color: var(--color-primary); }
    .ecosystem__scroll-link:hover svg { transform: translateY(4px); }
}

/* =========================================
   Переключение desktop (hex) / mobile (card)
   ========================================= */

/* Desktop: показываем hex, скрываем card-grid */
.ecosystem__card-grid { display: none; }

/* Мобиль/планшет (≤1080px): скрываем hex, показываем card-grid */
@media (max-width: 1080px) {
    .js-hex-grid-desktop { display: none !important; }
    .ecosystem__card-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

@media (max-width: 400px) {
    .ecosystem__card-grid { gap: 8px; }
}

/* =========================================
   Honeycomb Grid (desktop)
   ========================================= */

.ecosystem__hex-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.hex-row { display: flex; gap: 0; }

.hex-row--offset {
    margin-top: -58px;
    margin-left: 122px;
}

/* Ряд с карточкой Perlite Holding — центрированный, третья строка */
.hex-row--holding {
    margin-top: -58px;
    justify-content: center;
}

.hex-wrap {
    position: relative;
    width: 220px;
    height: 254px;
    flex-shrink: 0;
    margin: 0 7px;
}

.hex-card {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 1;
    -webkit-clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    text-decoration: none;
    transition: transform 0.35s ease;
    background: #ffffff;
}

/* =========================================
   Стрелка-подсказка + блик
   ========================================= */

@keyframes hint-bounce {
    0%, 100% { transform: translateY(0)    scale(1);    }
    40%       { transform: translateY(-6px) scale(1.08); }
    70%       { transform: translateY(-2px) scale(1.03); }
}

/* Маленький зелёный значок ↗ на каждом гексагоне */
.hex-wrap::after {
    content: '';
    position: absolute;
    top: 20%;
    right: -3px;
    width: 26px;
    height: 26px;
    background: var(--color-primary);
    border-radius: 50%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 10L10 2M10 2H5M10 2v5' stroke='white' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-size: 12px;
    background-repeat: no-repeat;
    background-position: center;
    box-shadow: 0 2px 10px rgba(84,187,144,0.45);
    animation: hint-bounce 2.4s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
    animation-delay: calc(var(--i, 0) * 0.35s);
    z-index: 10;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* Световой блик — косой луч проходит по карточке */
@keyframes hex-shine {
    0%,  30% { transform: translateX(-160%) skewX(-20deg); opacity: 0; }
    33%       { opacity: 1; }
    58%       { transform: translateX(240%)  skewX(-20deg); opacity: 0; }
    100%      { transform: translateX(240%)  skewX(-20deg); opacity: 0; }
}

/* Блик поверх карточки — clip-path обрезает по форме гексагона */
.hex-card::before {
    content: '';
    position: absolute;
    top: -10%; left: 0;
    width: 60%;
    height: 120%;
    background: linear-gradient(
        105deg,
        transparent             20%,
        rgba(255,255,255,0.06)  35%,
        rgba(255,255,255,0.42)  50%,
        rgba(255,255,255,0.06)  65%,
        transparent             80%
    );
    transform: translateX(-160%) skewX(-20deg);
    animation: hex-shine 5s ease-in-out infinite;
    /* блик приходит в середине цикла свечения */
    animation-delay: calc(var(--i, 0) * 0.45s + 1.4s);
    pointer-events: none;
    z-index: 4;
}

/* Hover */
@media (hover: hover) {
    /* Значок прячется — карточка сама показывает что внутри */
    .hex-wrap:hover::after { opacity: 0; }
    .hex-wrap:hover .hex-card::before { animation-play-state: paused; }

    .hex-card:hover {
        transform: translateY(-6px) scale(1.03);
        z-index: 2;
    }
    .hex-card:hover .hex-card__overlay { background: rgba(0,0,0,0.45); }
    .hex-card:hover .hex-card__logo    { filter: blur(5px) brightness(0.6); transform: scale(1.08); }
    .hex-card:hover .hex-card__name,
    .hex-card:hover .hex-card__cta     { opacity: 1; transform: translateY(0); }
}

.hex-card__logo {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    /* 60% ширины гексагона — логотип вписывается без обрезки по бокам */
    background-size: 60% auto;
    background-repeat: no-repeat;
    background-position: center center;
    transition: filter 0.45s ease, transform 0.45s ease;
}

.hex-card__overlay {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 24px;
    background: rgba(0,0,0,0);
    transition: background 0.35s ease;
}

@media (hover: hover) {
    .hex-card:hover .hex-card__overlay {
        background: rgba(0,0,0,0.45);
    }
}

.hex-card__name {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    text-align: center;
    line-height: 1.3;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease 0.05s, transform 0.3s ease 0.05s;
}

.hex-card__cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease 0.1s, transform 0.3s ease 0.1s;
}

/* Описание в hex-улье — скрыто по умолчанию, появляется на hover */
.hex-card__desc {
    font-size: 11px;
    line-height: 1.5;
    color: rgba(255,255,255,0.80);
    font-weight: 400;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 140px;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.3s ease 0.08s, transform 0.3s ease 0.08s;
}

@media (hover: hover) {
    .hex-card:hover .hex-card__desc {
        opacity: 1;
        transform: translateY(0);
    }
}

/* GSAP скрывает карточки сам через gsap.set — не скрываем в CSS */

/* =========================================
   Notice
   ========================================= */

.ecosystem__notice {
    position: relative;
    margin-top: 48px;
    padding: 28px 44px 28px 32px;
    background: #eef6f1;
    border-radius: 16px;
}

.ecosystem__notice-body { display: flex; flex-direction: column; gap: 10px; }

.ecosystem__notice-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.5;
}

.ecosystem__notice-text {
    font-size: 14px;
    color: var(--color-text-muted);
    line-height: 1.7;
}

/* Крестик — всегда в правом верхнем углу */
.ecosystem__notice-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--color-text-muted);
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

@media (hover: hover) {
    .ecosystem__notice-close:hover { color: var(--color-text); }
}

.ecosystem__notice.is-hidden { display: none; }

/* GSAP */
.js-anim-fade-up {
    opacity: 0;
    transform: translateY(32px);
    transition: opacity 0.6s ease var(--delay, 0s), transform 0.6s ease var(--delay, 0s);
}

.js-anim-fade-up.is-visible { opacity: 1; transform: translateY(0); }

/* =========================================
   Средний десктоп — уменьшаем hex чтоб не было overflow
   4 × (180+14) + 98 = 874px ≤ контейнер 1164px ✓
   ========================================= */

@media (max-width: 1260px) and (min-width: 1081px) {
    .hex-wrap { width: 180px; height: 208px; }
    .hex-row--offset { margin-top: -48px; margin-left: 98px; }
    .hex-row--holding { margin-top: -48px; }
}

/* =========================================
   Планшет + мобиль — карточки-плитки вместо сот
   (≤1080px: все планшеты и телефоны)
   ========================================= */

@media (max-width: 1080px) {
    .ecosystem { padding: 56px 0 48px; }

    .ecosystem__intro { gap: 12px; margin-bottom: 36px; }

    .ecosystem__scroll-link { font-size: 11px; }

    /* 2-колоночная сетка — без разрывов */
    .ecosystem__hex-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        align-items: start;
    }

    .hex-row,
    .hex-row--offset,
    .hex-row--holding { display: contents; margin: 0; }

    .hex-wrap {
        position: static;
        width: 100%;
        height: auto;
        margin: 0;
        filter: none;
        animation: none;
    }

    /* Значок скрыт на мобиле — в карточке уже есть стрелка */
    .hex-wrap::after { display: none; }

    /* ── Карточка: светлая зона лого + тёмная полоска имени ── */
    .hex-card {
        position: relative;
        top: auto; right: auto; bottom: auto; left: auto;
        width: 100%;
        height: auto;
        -webkit-clip-path: none;
        clip-path: none;
        border-radius: 18px;
        background: #ffffff;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        text-decoration: none;
        border: 1px solid rgba(0,0,0,0.07);
        box-shadow: 0 2px 12px rgba(0,0,0,0.08), 0 8px 32px rgba(0,0,0,0.06);
        animation: none;
        transform: none !important;
        transition: box-shadow 0.25s ease, transform 0.25s ease;
    }

    /* Лого — крупное, нейтральный светлый фон */
    .hex-card__logo {
        position: relative;
        width: 100%;
        height: 130px;
        background-color: #f4f6f5;
        /* auto по ширине, 62% от высоты зоны — любой логотип вписывается без обрезки */
        background-size: auto 62%;
        background-position: center center;
        filter: none !important;
        transform: none !important;
        transition: none;
        flex-shrink: 0;
        border-left: none;
    }

    /* Нейтральный белый низ — никаких цветных фонов */
    .hex-card__overlay {
        position: relative;
        top: auto; right: auto; bottom: auto; left: auto;
        height: auto;
        padding: 10px 12px 12px;
        background: #ffffff;
        border-top: 1px solid rgba(0,0,0,0.06);
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
        gap: 4px;
    }

    .hex-card__name {
        opacity: 1 !important;
        transform: none !important;
        font-size: 12px;
        font-weight: 700;
        color: #1a1a1a;
        text-align: left;
        transition: none;
        line-height: 1.25;
        letter-spacing: 0.01em;
        width: 100%;
    }

    .hex-card__desc {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        font-size: 10px;
        line-height: 1.45;
        color: #374151;
        font-weight: 400;
        width: 100%;
        margin-top: 1px;
        margin-bottom: 4px;
        max-height: calc(10px * 1.45 * 2);
    }

    .hex-card__cta {
        opacity: 1 !important;
        color: var(--color-primary);
        transition: none;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        align-self: flex-end;
        margin-top: auto;
    }

    .hex-card__cta svg { width: 13px; height: 13px; }
    .hex-card__cta-text { display: none; }

    /* Стрелка периодически подталкивает вправо — "иди сюда" */
    @keyframes arrow-nudge {
        0%, 60%, 100% { transform: translateX(0);   opacity: 1;    }
        75%            { transform: translateX(5px);  opacity: 0.5;  }
        85%            { transform: translateX(-2px); opacity: 1;    }
        95%            { transform: translateX(2px);  opacity: 0.8;  }
    }

    .hex-card__cta {
        animation: arrow-nudge 3s ease-in-out infinite;
        animation-delay: calc(var(--i, 0) * 0.4s);
    }

    /* Тап */
    .hex-card:active {
        transform: scale(0.97) !important;
        box-shadow: 0 1px 6px rgba(0,0,0,0.1);
    }

    /* Notice */
    .ecosystem__notice {
        padding: 16px 40px 16px 16px;
        margin-top: 24px;
    }
}

@media (max-width: 400px) {
    .ecosystem__hex-grid { gap: 8px; }
    .hex-card { border-radius: 16px; }
    .hex-card__logo { height: 110px; }
}
