/* Dynamic Island — общий верхний навигатор special-страниц.
   Одна тёмная капсула без рамки, разделённая вертикальными линиями.
   Сегменты образуют единую форму: у первого скруглён только левый край,
   у последнего — только правый, средний прямой. */

.island {
    position: fixed;
    top: clamp(14px, 2.4vh, 22px);
    left: 50%;
    z-index: 40;
    max-width: calc(100vw - 24px);
    opacity: 1;
    transform: translateX(-50%);
    /* `backwards` держит стартовое состояние только на время задержки,
       поэтому без JS островок всё равно остаётся видимым. */
    animation: island-enter 0.7s cubic-bezier(0.22, 1.2, 0.36, 1) 0.05s backwards;
}

@keyframes island-enter {
    from {
        opacity: 0;
        transform: translate(-50%, -10px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0) scale(1);
    }
}

.island__nav {
    position: relative;
    display: flex;
    align-items: stretch;
    padding: 0;
    isolation: isolate;
    border: 0;
    border-radius: 999px;
    background:
        radial-gradient(ellipse 90% 140% at 50% -40%, rgba(130, 190, 255, 0.16), rgba(130, 190, 255, 0) 62%),
        linear-gradient(150deg, rgba(12, 23, 41, 0.96) 0%, rgba(19, 37, 63, 0.93) 56%, rgba(27, 52, 86, 0.91) 100%);
    box-shadow:
        0 18px 40px -18px rgba(12, 28, 52, 0.6),
        0 2px 9px rgba(16, 35, 60, 0.16),
        0 0 24px rgba(80, 145, 210, 0.12);
    -webkit-backdrop-filter: blur(22px) saturate(150%);
    backdrop-filter: blur(22px) saturate(150%);
    transition:
        transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Блики — фоновая полоса внутри псевдоэлемента. Она обрезается радиусом
   капсулы без overflow: hidden, поэтому заливка активного сегмента может
   перекрыть тёмный край материнского блока. */
.island__nav::before,
.island__nav::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
    border-radius: inherit;
    pointer-events: none;
    background-image: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(214, 238, 255, 0.18) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    background-repeat: no-repeat;
    background-size: 34% 100%;
    background-position: -40% 0;
}

/* Блик при наведении на капсулу. */
.island__nav::before {
    opacity: 0;
}

/* Блик при появлении островка. */
.island__nav::after {
    animation: island-sheen 0.9s ease 0.4s 1;
}

@keyframes island-sheen {
    from {
        background-position: -40% 0;
    }
    to {
        background-position: 140% 0;
    }
}

@keyframes island-hover-sheen {
    0% {
        opacity: 0;
        background-position: -40% 0;
    }
    18% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        background-position: 140% 0;
    }
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    .island__nav:hover {
        transform: translateY(-2px);
        box-shadow:
            0 22px 48px -18px rgba(12, 28, 52, 0.68),
            0 3px 12px rgba(16, 35, 60, 0.18),
            0 0 30px rgba(80, 145, 210, 0.16);
    }

    .island__nav:hover::before {
        animation: island-hover-sheen 0.9s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .island__item:not(.is-coming):hover .island__label {
        transform: scale(1.06);
    }
}

/* Тонкая линия активной вкладки: переезжает между сегментами, а не
   появляется на новом месте скачком. */
.island__indicator {
    position: absolute;
    bottom: 5px;
    left: 0;
    z-index: 1;
    width: 22px;
    height: 2px;
    border-radius: 999px;
    background-color: #182734;
    opacity: 0;
    pointer-events: none;
    transform: translateX(0);
    transition:
        transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        width 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        background-color 0.35s ease,
        opacity 0.25s ease;
}

/* Первичную установку делаем без проезда слева: линия сразу встаёт
   под активную вкладку, а анимируется уже при переключениях. */
.island__nav:not([data-active-key]) .island__indicator {
    transition: none;
}

.island__nav[data-active-key="missu"] .island__indicator {
    opacity: 1;
    background-color: #182734;
}

.island__nav[data-active-key="guide"] .island__indicator {
    opacity: 1;
    background-color: #d5e2ed;
}

.island__nav[data-active-key="soon"] .island__indicator {
    opacity: 1;
    background-color: #d2dae3;
}

.island__item {
    position: relative;
    z-index: 2;
    display: flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    min-width: 6.2rem;
    min-height: 2.75rem;
    padding: 0 0.9rem;
    color: #bdc9d8;
    font-family: var(--font-display), -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: clamp(0.62rem, 1.35vw, 0.74rem);
    font-weight: 400;
    letter-spacing: 0.06em;
    line-height: 1;
    text-align: center;
    text-decoration: none;
    text-transform: uppercase;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: color 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Сегменты — части одной капсулы. Наружные края скругляет сама капсула
   через overflow: hidden; у сегментов собственных радиусов нет, поэтому
   между фоном капсулы и активным сегментом не остаётся тёмной прослойки. */

/* Вертикальные линии — единственный разделитель. */
.island__item + .island__item::before {
    content: "";
    position: absolute;
    top: 0.6rem;
    bottom: 0.6rem;
    left: 0;
    z-index: 1;
    width: 1px;
    pointer-events: none;
    background: rgba(202, 222, 244, 0.16);
}

.island__item.is-active::before {
    background: var(--island-active-divider, rgba(24, 39, 52, 0.16));
}

/* Заливка сегмента вынесена в отдельный слой и на 1px выходит за внешний
   край капсулы: так тёмный фон не просвечивает через скругление. */
.island__fill {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    background: linear-gradient(180deg, #e8eff5, #cdd9e4);
    background:
        linear-gradient(
            180deg,
            color-mix(in srgb, var(--item-color, #dfe9f2) 76%, #ffffff),
            color-mix(in srgb, var(--item-color, #dfe9f2) 72%, #9eafbf)
        );
    transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Тёмные сегменты имеют спокойную заливку и общий механизм смены состояния. */
.island__item[data-island-key="guide"] {
    --island-rest: #252e37;
    --island-active: var(--guide-bg-top, #34414d);
    --island-active-divider: rgba(221, 232, 242, 0.16);
}

.island__item[data-island-key="soon"] {
    --island-rest: #151a20;
    --island-active: var(--item-color, #272d35);
    --island-active-divider: rgba(221, 232, 242, 0.16);
}

.island__item:is([data-island-key="guide"], [data-island-key="soon"]):not(.is-coming) .island__fill {
    opacity: 1;
    background: var(--island-rest);
}

.island__item:is([data-island-key="guide"], [data-island-key="soon"]):not(.is-coming) .island__fill::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0;
    background: var(--island-active);
    transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.island__item:is([data-island-key="guide"], [data-island-key="soon"]):not(.is-coming).is-active .island__fill::before {
    opacity: 1;
}

.island__item.is-first .island__fill {
    left: -1px;
    border-radius: 999px 0 0 999px;
}

.island__item.is-last .island__fill {
    right: -1px;
    border-radius: 0 999px 999px 0;
}

.island__item.is-first.is-last .island__fill {
    border-radius: 999px;
}

.island__item.is-active .island__fill {
    opacity: 1;
}

.island__label {
    position: relative;
    z-index: 2;
    display: block;
    transform: scale(1);
    transform-origin: center;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Подсветка сегмента при наведении. Отдельный слой нужен, чтобы
   ледяной градиент активного сегмента не «щёлкал» сменой background. */
.island__item::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.14) 0%,
        rgba(255, 255, 255, 0.04) 100%
    );
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.island__item:not(.is-coming):hover::after {
    opacity: 1;
}

.island__item.is-first::after {
    left: -1px;
    border-radius: 999px 0 0 999px;
}

.island__item.is-last::after {
    right: -1px;
    border-radius: 0 999px 999px 0;
}

.island__item.is-first.is-last::after {
    border-radius: 999px;
}

.island__item.is-active {
    color: #182734;
}

.island__item[data-island-key="guide"]:not(.is-coming):not(.is-active) {
    color: #cbd7e2;
}

.island__item[data-island-key="guide"]:not(.is-coming).is-active {
    color: #f4f7fb;
}

.island__item.is-coming {
    color: rgba(197, 212, 231, 0.5);
    cursor: default;
}

.island__item[data-island-key="soon"]:not(.is-coming):not(.is-active) {
    color: #b8c3cf;
}

.island__item[data-island-key="soon"]:not(.is-coming).is-active {
    color: #edf2f7;
}

.island__item:not(.is-coming):not(.is-active):hover {
    color: #ffffff;
}

.island__item:focus-visible {
    outline: 2px solid rgba(160, 212, 255, 0.85);
    outline-offset: -3px;
}

.island__item.is-active:focus-visible {
    outline-color: #182734;
}

.island__item:is([data-island-key="guide"], [data-island-key="soon"]):not(.is-coming):focus-visible {
    outline-color: #dbe8f3;
}

.island__item.is-first:focus-visible {
    border-radius: 999px 0 0 999px;
}

.island__item.is-last:focus-visible {
    border-radius: 0 999px 999px 0;
}

@media (hover: none), (max-width: 56rem) {
    /* Капсула почти непрозрачная: blur на телефоне только тратит GPU
       на каждом кадре перехода, а визуально почти не читается. */
    .island__nav {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

@media (max-width: 30rem) {
    .island {
        max-width: calc(100vw - 20px);
    }

    .island__nav {
        max-width: 100%;
    }

    .island__item {
        min-width: 5.2rem;
        min-height: 2.5rem;
        padding: 0 0.55rem;
        font-size: 0.56rem;
        letter-spacing: 0.03em;
    }
}

@media (prefers-reduced-motion: reduce) {
    .island {
        opacity: 1;
        transform: translateX(-50%);
        animation: none;
    }

    .island__nav,
    .island__item,
    .island__label,
    .island__fill,
    .island__fill::before,
    .island__indicator,
    .island__item::after {
        transition: none;
    }

    .island__label {
        transform: none;
    }

    .island__nav::before,
    .island__nav::after {
        display: none;
    }
}
