/*
 * Колесо фортуни (Stepanikdev/FortuneWheel).
 * Стилі самодостатні: жодних залежностей від css теми petshop,
 * усі класи з префіксом fw__, щоб нічого не перетнулося.
 *
 * Геометрія: 12 секторів по 30°, вказівник зверху (12 година).
 * Сектор i займає [i*30 - 15; i*30 + 15), тому сектор 0 відцентрований угору,
 * а щоб зупинитись на секторі k, колесо треба повернути на -(k*30) градусів.
 */

.fw,
.fwp {
    --fw-green: #4a9d3f;
    --fw-green-dark: #2f6b28;
    --fw-cream: #fdf6e3;
    --fw-ink: #23301f;
    --fw-gold: #e0a03c;

    position: fixed;
    inset: 0;
    z-index: 10050;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
}

.fw.is-open {
    display: flex;
}

.fw__overlay {
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 14, .72);
}

.fw__modal {
    position: relative;
    width: 100%;
    max-width: 520px;
    margin: auto;
    padding: 28px 20px 24px;
    border-radius: 20px;
    background: linear-gradient(180deg, #ffffff 0%, #f4fbf1 100%);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
    text-align: center;
}

.fw__close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--fw-ink);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    opacity: .55;
    transition: opacity .15s ease;
}

.fw__close:hover {
    opacity: 1;
}

/*Помітна плашка, щоб тестову прокрутку не сплутати з бойовою*/
.fw__test {
    margin: -12px -20px 14px;
    padding: 8px 12px;
    border-radius: 20px 20px 0 0;
    background: #ffca3a;
    color: #4a3a00;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.fw__title {
    margin-bottom: 6px;
    font-size: 22px;
    font-weight: 700;
    color: var(--fw-green-dark);
}

.fw__subtitle {
    margin-bottom: 18px;
    font-size: 14px;
    line-height: 1.45;
    color: #55624f;
}

/* --- колесо --- */

.fw__stage {
    position: relative;
    width: 100%;
    max-width: 380px;
    /*Відступ згори — щоб вказівник не наїжджав на заголовок, коли підзаголовок сховано*/
    margin: 12px auto 0;
    aspect-ratio: 1 / 1;
}

.fw__pointer {
    position: absolute;
    top: -4px;
    left: 50%;
    z-index: 3;
    width: 0;
    height: 0;
    margin-left: -13px;
    border-left: 13px solid transparent;
    border-right: 13px solid transparent;
    border-top: 26px solid var(--fw-gold);
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35));
}

.fw__wheel {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 8px solid var(--fw-green-dark);
    box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .6), 0 10px 30px rgba(0, 0, 0, .25);
    background:
        repeating-conic-gradient(from -15deg,
            rgba(47, 107, 40, .35) 0deg 0.45deg,
            transparent 0.45deg 30deg),
        repeating-conic-gradient(from -15deg,
            var(--fw-cream) 0deg 30deg,
            #d6ecca 30deg 60deg);
    transform: rotate(0deg);
    transition: transform 5s cubic-bezier(.17, .67, .16, 1);
    will-change: transform;
}

.fw__sector {
    position: absolute;
    inset: 0;
    transform: rotate(calc(var(--fw-sector) * 30deg));
    pointer-events: none;
}

/*
 * Вміст сектора живе на вузькій смузі вздовж бісектриси: від обода (top: 0)
 * до центра колеса (height: 50%). Назва повернута на 90°, тобто читається
 * уздовж радіуса — інакше довгі назви на кшталт «Лімітований стікер пак Vitomax»
 * лягають упоперек і налазять на сусідні сектори.
 */
.fw__sector_inner {
    position: absolute;
    top: 0;
    left: 50%;
    width: 22%;
    margin-left: -11%;
    height: 50%;
}

/*
 * max-width: none обов'язковий: тема petshop має глобальне `img { max-width: 100% }`,
 * і без цього картинка обмежується шириною смуги сектора.
 * Розмір у відсотках, а не в px — щоб картинки масштабувались разом із колесом на мобільних.
 */
.fw__sector_img {
    position: absolute;
    top: 6%;
    left: 50%;
    width: 50%;
    height: auto;
    max-width: none;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    transform: translateX(-50%);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .2));
}

/*
 * Смуга сектора — це відрізок обід → центр. Картинка займає її початок,
 * втулка з кнопкою «Крутити» з'їдає кінець, тож назві лишається середина.
 * width тут — довжина вздовж радіуса (елемент повернутий), і вона обмежена
 * так, щоб текст не заліз під втулку; задовге ім'я обрізається трикрапкою.
 */
.fw__sector_name {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 82px;
    transform: translate(-50%, -50%) rotate(90deg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    font-size: 9px;
    line-height: 1;
    font-weight: 600;
    color: var(--fw-ink);
}

/*Без картинки назві дістається ще й місце під неї*/
.fw__sector_inner:not(:has(.fw__sector_img)) .fw__sector_name {
    top: 42%;
    width: 104px;
}

/* --- кнопка в центрі --- */

.fw__hub {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    width: 26%;
    height: 26%;
    margin: -13% 0 0 -13%;
    padding: 0;
    border: 5px solid #fff;
    border-radius: 50%;
    background: var(--fw-green);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .02em;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
    transition: transform .15s ease, background .15s ease;
}

.fw__hub:hover:not(:disabled) {
    background: var(--fw-green-dark);
    transform: scale(1.05);
}

.fw__hub:disabled {
    cursor: default;
    opacity: .65;
}

.fw__hub_text {
    display: block;
    padding: 0 4px;
}

/* --- результат --- */

.fw__result {
    margin-top: 20px;
    padding: 16px;
    border-radius: 14px;
    background: #ecf7e7;
}

.fw__result_label {
    font-size: 13px;
    color: #55624f;
}

.fw__result_name {
    margin: 4px 0 8px;
    font-size: 20px;
    font-weight: 700;
    color: var(--fw-green-dark);
}

.fw__result_promo {
    margin-bottom: 8px;
    font-size: 15px;
}

.fw__result_promo_code {
    display: inline-block;
    padding: 4px 10px;
    border: 1px dashed var(--fw-green-dark);
    border-radius: 8px;
    background: #fff;
    font-weight: 700;
    letter-spacing: .08em;
}

.fw__result_note {
    font-size: 13px;
    line-height: 1.45;
    color: #55624f;
}

.fw__error {
    margin-top: 16px;
    padding: 12px;
    border-radius: 12px;
    background: #fdecec;
    color: #a12b2b;
    font-size: 14px;
}

@media (max-width: 480px) {
    .fw__modal {
        padding: 24px 12px 20px;
    }

    .fw__title {
        font-size: 19px;
    }

    .fw__sector_name {
        width: 72px;
        font-size: 8px;
    }

    .fw__sector_inner:not(:has(.fw__sector_img)) .fw__sector_name {
        width: 92px;
    }

    .fw__hub {
        font-size: 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fw__wheel {
        transition-duration: .6s;
    }
}

/* --- поп-ап-анонс акції --- */

.fwp {
    position: fixed;
    inset: 0;
    z-index: 10040;
    /*Змінні вище оголошені і для .fwp, тож .fw__close всередині анонсу теж має колір*/
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.fwp.is-open {
    display: flex;
}

.fwp__overlay {
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 14, .6);
}

.fwp__modal {
    position: relative;
    width: 100%;
    max-width: 460px;
    padding: 28px 24px 26px;
    border-radius: 20px;
    border-top: 6px solid #4a9d3f;
    background: #fff;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .32);
    text-align: center;
}

.fwp__title {
    margin-bottom: 12px;
    font-size: 21px;
    font-weight: 700;
    line-height: 1.25;
    color: #2f6b28;
}

.fwp__text {
    font-size: 15px;
    line-height: 1.55;
    color: #33402f;
}

.fwp__text p {
    margin: 0 0 10px;
}

.fwp__text p:last-child {
    margin-bottom: 0;
}

@media (max-width: 480px) {
    .fwp__modal {
        padding: 24px 16px 22px;
    }

    .fwp__title {
        font-size: 18px;
    }

    .fwp__text {
        font-size: 14px;
    }
}

/*
 * Виграний подарунок на самій сторінці замовлення (не в модалці).
 * Кольори задані значеннями, а не змінними --fw-*: змінні оголошені на .fw / .fwp,
 * а цей блок JS переносить до розмітки теми, тобто за межі їхньої області видимості.
 */
.fw_won {
    margin: 0 0 20px;
    padding: 18px 20px;
    border: 1px solid #cfe6c4;
    border-radius: 14px;
    background: #ecf7e7;
    color: #23301f;
    text-align: center;
}

.fw_won__label {
    font-size: 13px;
    color: #55624f;
}

.fw_won__name {
    margin: 4px 0 8px;
    font-size: 20px;
    font-weight: 700;
    color: #2f6b28;
}

.fw_won__promo {
    margin-bottom: 8px;
    font-size: 15px;
}

.fw_won__code {
    display: inline-block;
    padding: 4px 10px;
    border: 1px dashed #2f6b28;
    border-radius: 8px;
    background: #fff;
    font-weight: 700;
    letter-spacing: .08em;
}

.fw_won__note {
    font-size: 13px;
    line-height: 1.45;
    color: #55624f;
}
