/*
 * Подборка кейсов (js/choice.js): пилюля в шапке, строка в мобильном меню, скрепка на кейсе, страница /choice/.
 */

/* ---------- шапка: счётчик + скрепка ---------- */
.choice-pill {
    box-sizing: border-box;
    height: var(--cta-h);
    margin-left: -33px; /* у .menu__info gap 45px — пилюля стоит вплотную к «Связаться с нами» */
    margin-right: -45px; /* за пилюлей — бургер нулевой ширины (на десктопе), его отступ не нужен: край шапки = край колонки услуг */
    padding: 0 var(--cta-inset) 0 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--color-alt);
    border-radius: 999px;
    color: var(--color-primary);
    font-size: 15px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    transition: border-color .35s ease, color .35s ease, transform .35s var(--cta-ease);
}

.choice-pill__count {
    min-width: 1ch;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.choice-pill__icon {
    width: var(--cta-circle);
    height: var(--cta-circle);
    flex: 0 0 var(--cta-circle);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--color-alt);
    color: var(--color-primary);
    transition: background-color .35s ease, color .35s ease, transform .35s var(--cta-ease);
}

.choice-clip {
    width: 18px;
    height: 18px;
}

.choice-pill:hover .choice-pill__icon {
    transform: rotate(-12deg);
}

.choice-pill.is-empty {
    border-color: #ececec;
    color: #c4c4c4;
}

.choice-pill.is-empty .choice-pill__icon {
    background: #efefef;
    color: var(--color-whte);
}

.choice-pill.is-bump {
    animation: choice-bump .5s var(--cta-ease);
}

@keyframes choice-bump {
    40% { transform: scale(1.12); }
}

/* ---------- мобильное меню: строка подборки внизу ---------- */
.choice-mpill {
    box-sizing: border-box;
    margin: 20px 16px 24px;
    min-height: 52px;
    padding: 4px 4px 4px 22px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--color-alt);
    border-radius: 999px;
    color: var(--color-primary);
    text-decoration: none;
    --cta-circle: 42px;
}

.choice-mpill__text {
    flex: 1;
    font-size: 18px;
}

.choice-mpill__count {
    font-size: 16px;
    font-weight: 500;
}

.choice-mpill.is-empty {
    border-color: #ececec;
    color: #a9a9a9;
}

.choice-mpill.is-empty .choice-mpill__text {
    text-align: center;
}

.choice-mpill.is-empty .choice-pill__icon {
    background: #efefef;
    color: var(--color-whte);
}

/* ---------- кейс: круглая кнопка со скрепкой у левого края (js/choice.js) ----------
   Размер 1 — маленький без подписи, размер 2 — крупный с подписью (круг всегда размера 2, размер 1 = scale, рост от центра).
   Покой: из-за левого края торчит 60% круга размера 1. Наведение: круг едет по дуге окружности вправо-вниз
   и одновременно растёт до размера 2, доворачиваясь; подпись появляется в конце.
   Кейс уже в подборке (.is-in): раскрытый круг того же размера, внутри — пилюля со счётчиком «перейти к подборке»
   и «убрать из подборки»; свёрнутый — по-прежнему скрепка.
   Путь — offset-path (--arc): из-за края по прямой до покоя, дальше дуга; точка пути = центр круга,
   начало координат пути — левый верхний угол круга (центр в покое по Y = s2/2). --d-rest — доля пути до покоя.
   Наведение — класс .is-hover (js/choice.js, только мышь): на телефоне тап включал бы :hover и сразу открывал ссылку.
   Телефон: первый тап раскрывает круг (.is-open), второй — добавляет; тап мимо — сворачивает.
   Слои: .choice-badge — неподвижная зона у края (ловит наведение, пока круг едет); __track — путь;
   __disc — поворот и масштаб; внутри __btn (сам круг: добавить) и __panel (содержимое «в подборке»).
   Первый показ за сессию (.is-intro): выкатывается из-за края, по дуге раскрывается, держится и возвращается. */
.choice-badge {
    --s2: 124px;                /* размер 2 */
    --s1: .613;                 /* размер 1 = 76px */
    /* центр: за краем (-88, 62) → покой (8, 62), торчит 60% круга 76px → раскрыт (78, 92).
       Дуга стартует горизонтально и загибается вниз: окружность R ≈ 96.7px, сектор ≈ 46° */
    --arc: path("M -88 62 L 8 62 A 96.67 96.67 0 0 1 78 92");
    --d-rest: 55.1%;            /* 96px прямой из 174px пути */
    --zone-w: 164px;            /* зона наведения раскрытого круга */
    --zone-h: 178px;
    --r-hide: -540deg;
    --r-rest: -215deg;
    --y: -100%;
    --t: .55s;
    position: fixed;
    left: 0;
    top: calc(var(--header, 80px) + 190px);
    z-index: calc(var(--index-1) - 1); /* над контентом кейса, под шапкой, меню и формой заявки */
    width: calc(var(--s2) * var(--s1) * .6); /* зона наведения = видимая часть круга в покое */
    height: var(--s2);
    translate: 0 var(--y);
    visibility: hidden;
    transition: visibility 0s linear .6s;
}

.choice-badge.is-shown {
    visibility: visible;
    transition: none;
}

/* при наведении зона накрывает всю дугу — курсор не «теряет» круг, пока он едет */
.choice-badge.is-shown.is-hover::after {
    content: "";
    position: absolute;
    z-index: 0; /* под кругом — иначе забирает клики */
    left: 0;
    top: 0;
    width: var(--zone-w);
    height: var(--zone-h);
}

.choice-badge__track {
    position: absolute;
    z-index: 1;
    left: 0;
    top: 0;
    width: var(--s2);
    height: var(--s2);
    /* путь — на внешнем слое: offset применяется после rotate/scale, на круге путь крутился бы вместе с ним */
    offset-path: var(--arc);
    offset-rotate: 0deg;
    offset-distance: 0%;
    transition: offset-distance var(--t) ease-in-out;
}

.choice-badge.is-shown .choice-badge__track {
    offset-distance: var(--d-rest);
}

.choice-badge.is-shown.is-hover .choice-badge__track,
.choice-badge.is-open .choice-badge__track {
    offset-distance: 100%;
}

.choice-badge__disc {
    position: relative;
    width: var(--s2);
    height: var(--s2);
    border-radius: 50%;
    rotate: var(--r-hide);
    scale: var(--s1);
    transition: rotate var(--t) ease, scale var(--t) ease;
}

.choice-badge.is-shown .choice-badge__disc {
    rotate: var(--r-rest);
}

/* раскрыт: наведение и секунда после клика */
.choice-badge.is-shown.is-hover .choice-badge__disc,
.choice-badge.is-open .choice-badge__disc {
    rotate: 0deg;
    scale: 1;
}

/* сам круг */
.choice-badge__btn {
    position: absolute;
    inset: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: rgba(var(--color-alt--rgb), .7);
    color: var(--color-primary);
    font: inherit;
    cursor: pointer;
    transition: background-color .35s ease, color .35s ease;
    -webkit-tap-highlight-color: transparent;
}

.choice-badge.is-shown.is-hover .choice-badge__btn,
.choice-badge.is-open .choice-badge__btn {
    background: var(--color-alt); /* раскрыт — без прозрачности */
}

/* кейс в подборке — сочный зелёный, скрепка белая (в раскрытом виде её сменяет панель) */
.choice-badge__btn.is-active {
    background: var(--color-alt);
    color: var(--color-whte);
}

.choice-badge__btn svg {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    transition: opacity .2s ease;
}

/* подпись — под скрепкой, вне потока: скрепка всегда в центре круга */
.choice-badge__label {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(50% + 26px);
    padding: 0 14px;
    font-size: 10px;
    line-height: 1.2;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}

.choice-badge.is-shown.is-hover .choice-badge__label,
.choice-badge.is-open .choice-badge__label {
    opacity: 1;
    transition-delay: calc(var(--t) - .1s);
}

.choice-badge__btn.is-busy {
    cursor: progress;
}

/* в подборке и раскрыт: вместо скрепки — пилюля со счётчиком, «перейти к подборке» и «убрать из подборки» (в 2 строки) */
.choice-badge__panel {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding-top: 4px;
    border-radius: 50%;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility 0s linear .2s;
}

.choice-badge.is-in.is-shown.is-hover .choice-badge__panel,
.choice-badge.is-in.is-open .choice-badge__panel {
    opacity: 1;
    visibility: visible;
    transition: opacity .25s ease calc(var(--t) - .15s), visibility 0s;
}

.choice-badge.is-in.is-shown.is-hover .choice-badge__btn > *,
.choice-badge.is-in.is-open .choice-badge__btn > * {
    opacity: 0;
    transition-delay: 0s;
}

.choice-badge__go {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    color: var(--color-primary);
    text-decoration: none;
}

.choice-badge__pill {
    box-sizing: border-box;
    height: 30px;
    padding: 0 2px 0 11px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #7fb31f;
    border-radius: 999px;
    background: var(--color-whte);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    transition: transform .3s var(--cta-ease);
}

.choice-badge__pill-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--color-alt);
}

.choice-badge__pill-icon svg {
    width: 14px;
    height: 14px;
}

.choice-badge__go-text {
    font-size: 9px;
    line-height: 1.15;
}

.choice-badge__go:hover .choice-badge__pill {
    transform: scale(1.05);
}

.choice-badge__remove {
    position: relative;
    top: 8px; /* чуть ниже «перейти к подборке», остальное содержимое круга не сдвигается */
    padding: 2px 6px;
    border: 0;
    background: none;
    color: var(--color-whte);
    font: inherit;
    font-size: 10px;
    line-height: 1.15;
    cursor: pointer;
}

.choice-badge__remove:hover {
    text-decoration: underline;
}

/* первый показ за сессию: из-за края → покой → по дуге раскрывается → держится → обратно по дуге */
.choice-badge.is-intro .choice-badge__track {
    animation: choice-badge-intro-path 3.6s linear both;
}

.choice-badge.is-intro .choice-badge__disc {
    animation: choice-badge-intro-btn 3.6s linear both;
}

.choice-badge.is-intro:not(.is-in) .choice-badge__label,
.choice-badge.is-intro.is-in .choice-badge__panel {
    visibility: visible;
    animation: choice-badge-intro-label 3.6s linear both;
}

.choice-badge.is-intro.is-in .choice-badge__btn svg {
    animation: choice-badge-intro-clip 3.6s linear both;
}

@keyframes choice-badge-intro-path {
    0%   { offset-distance: 0%; animation-timing-function: cubic-bezier(.22, 1, .36, 1); }
    22%  { offset-distance: var(--d-rest); animation-timing-function: ease-in-out; }
    40%, 72% { offset-distance: 100%; animation-timing-function: ease-in-out; }
    90%, 100% { offset-distance: var(--d-rest); }
}

@keyframes choice-badge-intro-btn {
    0%   { rotate: var(--r-hide); scale: var(--s1); animation-timing-function: cubic-bezier(.22, 1, .36, 1); }
    22%  { rotate: var(--r-rest); scale: var(--s1); animation-timing-function: ease-in-out; }
    40%, 72% { rotate: 0deg; scale: 1; animation-timing-function: ease-in-out; }
    90%, 100% { rotate: var(--r-rest); scale: var(--s1); }
}

@keyframes choice-badge-intro-label {
    0%, 38%  { opacity: 0; }
    44%, 68% { opacity: 1; }
    74%, 100% { opacity: 0; }
}

@keyframes choice-badge-intro-clip {
    0%, 36%  { opacity: 1; }
    42%, 70% { opacity: 0; }
    76%, 100% { opacity: 1; }
}

@media (max-width: 769px) {
    .choice-badge {
        --s2: 140px;            /* раскрыт крупнее — под палец */
        --s1: .4;               /* 56px */
        /* центр: за краем (-68, 70) → покой (6, 70), торчит 60% круга 56px → раскрыт (82, 146): четверть окружности R 76 */
        --arc: path("M -68 70 L 6 70 A 76 76 0 0 1 82 146");
        --d-rest: 38.3%;        /* 74px прямой из 193px пути */
        --zone-w: 140px;
        --zone-h: 186px;
        --y: -50%;
        top: 40%;
    }

    .choice-badge__btn svg {
        width: 40px;
        height: 40px;
    }

    .choice-badge__label {
        top: calc(50% + 26px);
        font-size: 12px;
    }

    .choice-badge__go-text {
        font-size: 11px;
    }

    .choice-badge__remove {
        font-size: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .choice-badge.is-intro .choice-badge__track,
    .choice-badge.is-intro .choice-badge__disc,
    .choice-badge.is-intro .choice-badge__label,
    .choice-badge.is-intro .choice-badge__panel,
    .choice-badge.is-intro .choice-badge__btn svg {
        animation: none;
    }
}

/* ---------- /choice/: шапка ---------- */
.choice-intro .intro__info {
    min-height: 320px;
}

.choice-intro__count {
    margin: 8px 0 20px;
    color: var(--color-alt);
    font-size: 20px;
    line-height: 1.3;
}

/* иконка «поделиться» квадратная, а не как стрелка */
.choice-intro__btn[data-choice-share] > span > span:before {
    width: 16px;
    height: 16px;
}

.choice-intro__actions {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 14px;
    align-self: start;
}

.choice-intro__actions[hidden] {
    display: none;
}

.choice-intro__btn {
    width: 100%;
}

.choice-intro__btn > span {
    width: 100%; /* размеры — стандартные (css/cta-button.css), как у «Нужен похожий проект?» на кейсе */
}

.choice-intro__btn.is-busy {
    opacity: .6;
    pointer-events: none;
}

.choice-share {
    padding: 16px;
    border-radius: 20px;
    background: rgba(var(--color-whte--rgb), .08);
}

.choice-share__url {
    box-sizing: border-box;
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgba(var(--color-whte--rgb), .25);
    border-radius: 12px;
    background: transparent;
    color: var(--color-whte);
    font: inherit;
    font-size: 14px;
}

.choice-share__hint {
    margin-top: 10px;
    color: rgba(var(--color-whte--rgb), .7);
    font-size: 14px;
    line-height: 1.4;
}

/* ---------- /choice/: список ---------- */
.choice {
    padding: 56px 0 96px;
    background: var(--color-whte);
}

.choice__notice {
    margin-bottom: 28px;
    padding: 16px 24px;
    border-radius: 16px;
    background: rgba(var(--color-alt--rgb), .14);
    font-size: 17px;
    transition: opacity .6s ease, transform .6s ease;
}

.choice__notice.is-hidden {
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
}

.choice-item {
    position: relative;
    display: grid;
    grid-template-columns: minmax(220px, 360px) 1fr auto;
    gap: 36px;
    align-items: start;
    padding: 32px 0;
    border-bottom: 1px solid var(--color-gry);
    transition: opacity .35s ease, transform .35s ease;
}

.choice-item:first-child {
    padding-top: 0;
}

.choice-item.is-removing {
    opacity: 0;
    transform: translateX(-24px);
}

.choice-item__image {
    display: block;
    aspect-ratio: 4 / 3;
    border-radius: 24px;
    overflow: hidden;
    background: #f3f3f3;
}

.choice-item__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .6s var(--cta-ease);
}

.choice-item__image:hover img {
    transform: scale(1.04);
}

.choice-item__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    margin-bottom: 12px;
    color: #8a8a8a;
    font-size: 14px;
}

.choice-item__num {
    color: var(--color-alt);
    font-weight: 500;
}

.choice-item__type {
    padding: 5px 12px;
    border-radius: 999px;
    background: #f3f3f3;
    color: var(--color-primary);
}

/* бирка «что это»: кейс / услуга / технология / статья */
.choice-item__kind {
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--color-alt);
    color: var(--color-primary);
    font-weight: 500;
}

/* логотипы технологий и рисунки услуг — целиком на светлом фоне */
.choice-item__image--contain {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12%;
    box-sizing: border-box;
}

.choice-item__image--contain img {
    object-fit: contain;
}

.choice-item__noimg {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #c9c9c9;
}

.choice-item__noimg .choice-clip {
    width: 56px;
    height: 56px;
}

.choice-item__title {
    display: block;
    margin-bottom: 22px;
    color: var(--color-primary);
    font-size: 26px;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
}

.choice-item__title:hover {
    color: var(--color-alt);
}

.choice-item__note {
    position: relative;
    display: block;
}

.choice-item__note-label {
    display: block;
    margin-bottom: 8px;
    color: #8a8a8a;
    font-size: 14px;
}

.choice-item__note textarea {
    box-sizing: border-box;
    width: 100%;
    min-height: 84px;
    padding: 14px 18px;
    border: 1px solid #e2e2e2;
    border-radius: 18px;
    background: #fafafa;
    color: var(--color-primary);
    font: inherit;
    font-size: 16px;
    line-height: 1.45;
    resize: none;
    overflow: hidden;
    transition: border-color .25s ease, background-color .25s ease;
}

.choice-item__note textarea:focus {
    outline: none;
    border-color: var(--color-alt);
    background: var(--color-whte);
}

.choice-item__saved {
    position: absolute;
    top: 0;
    right: 0;
    color: var(--color-alt);
    font-size: 13px;
    opacity: 0;
    transition: opacity .25s ease;
}

.choice-item__saved.is-visible {
    opacity: 1;
}

.choice-item__saved.is-error {
    color: #d9534f;
}

.choice-item__remove {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--color-gry);
    border-radius: 999px;
    background: transparent;
    color: #8a8a8a;
    font: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: color .25s ease, border-color .25s ease;
}

.choice-item__remove:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
}

/* пустая подборка */
.choice__empty {
    max-width: 560px;
    margin: 0 auto;
    padding: 24px 0;
    text-align: center;
}

.choice__empty[hidden] {
    display: none;
}

.choice__empty-icon {
    width: 88px;
    height: 88px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(var(--color-alt--rgb), .14);
    color: var(--color-alt);
}

.choice__empty-icon .choice-clip {
    width: 38px;
    height: 38px;
}

.choice__empty-title {
    margin-bottom: 12px;
    font-size: 28px;
    font-weight: 500;
}

.choice__empty-text {
    margin-bottom: 28px;
    color: #6f6f6f;
    font-size: 17px;
    line-height: 1.5;
}

.choice__empty .btn {
    display: inline-flex;
}

@media (max-width: 769px) {
    .choice {
        padding: 32px 0 64px;
    }

    .choice-item {
        grid-template-columns: 1fr;
        gap: 18px;
        padding: 24px 0;
    }

    .choice-item__title {
        font-size: 21px;
        margin-bottom: 16px;
    }

    .choice-item__remove {
        position: absolute;
        top: 36px;
        right: 12px;
        background: var(--color-whte);
        border-color: var(--color-whte);
        color: var(--color-primary);
    }

    .choice-item:first-child .choice-item__remove {
        top: 12px;
    }

    .choice-item__remove span {
        display: none;
    }

    .choice-intro__actions {
        margin-top: 24px;
    }
}
