/* ==========================================================
   Виджеты: «Луна стаи» (слева) и чат поддержки (справа снизу)
   Палитра и шрифты взяты из app.css сайта
   ========================================================== */
:root {
    --w-gold: #e8a841;
    --w-gold-hi: #edb967;
    --w-gold-dim: #8b6527;
    --w-night: #0b1928;
    --w-night-deep: #040c14;
    --w-night-mid: #1e2e3e;
    --w-night-line: #2b4259;
    --w-ink: #0c0c0c;
    --w-text: #ffffffe5;
    --w-text-dim: #ffffff99;
    --w-text-faint: #ffffff66;
    --w-red: #eb5e5e;
    --w-green: #3fc28a;
    --w-sans: Montserrat, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    --w-display: "Bebas Neue Cyrillic", Impact, "Arial Narrow", sans-serif;
}

/* ---------------- Луна стаи ---------------- */
.wolf-moon {
    position: fixed;
    z-index: 40;
    top: calc(50% + 28px);
    /* по центру свободного поля слева от контента шириной 1200px */
    left: max(16px, calc((100vw - 1200px) / 4 - 110px));
    width: 220px;
    transform: translateY(-50%);
    display: none;
    font-family: var(--w-sans);
    color: var(--w-text);
}

/* показываем, только когда слева реально есть место */
@media (min-width: 1720px) {
    .wolf-moon { display: block; }
}

.wolf-moon__card {
    position: relative;
    overflow: hidden;
    padding: 20px 18px 18px;
    border-radius: 16px;
    background:
        radial-gradient(120% 70% at 50% 0%, #13283d 0%, transparent 70%),
        linear-gradient(180deg, var(--w-night) 0%, var(--w-night-deep) 100%);
    border: 1px solid #e8a84126;
}

.wolf-moon__title {
    margin: 0;
    font-family: var(--w-display);
    font-size: 26px;
    line-height: 28px;
    letter-spacing: .5px;
    color: var(--w-text);
    text-align: center;
}

.wolf-moon__lead {
    text-wrap: balance;
    margin: 4px 0 0;
    font-size: 12px;
    line-height: 16px;
    color: var(--w-text-dim);
    text-align: center;
}

.wolf-moon__sky {
    position: relative;
    height: 170px;
    margin: 10px -18px 0;
}

.wolf-moon__sky svg {
    display: block;
    width: 100%;
    height: 100%;
}

.wolf-moon__star {
    fill: #fff;
    animation: wm-twinkle 3.4s ease-in-out infinite;
}

.wolf-moon__star:nth-child(2n) { animation-delay: -1.1s; animation-duration: 4.1s; }
.wolf-moon__star:nth-child(3n) { animation-delay: -2.3s; animation-duration: 2.8s; }

@keyframes wm-twinkle {
    0%, 100% { opacity: .9; }
    50% { opacity: .25; }
}

.wolf-moon__halo {
    transition: opacity .8s ease;
}

.wolf-moon__lit {
    fill: url(#wmMoonGrad);
    transition: d .9s ease;
}

.wolf-moon__wolf {
    fill: var(--w-night-deep);
}

.wolf-moon.is-full .wolf-moon__halo {
    animation: wm-howl 1.2s ease-in-out 3;
}

@keyframes wm-howl {
    0%, 100% { opacity: .55; }
    50% { opacity: 1; }
}

.wolf-moon__amount {
    margin-top: 4px;
    font-family: var(--w-display);
    font-size: 34px;
    line-height: 36px;
    letter-spacing: .6px;
    color: var(--w-gold);
    text-align: center;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.wolf-moon__amount small {
    font-size: 20px;
    color: var(--w-gold-hi);
    margin-left: 4px;
}

.wolf-moon__phase {
    margin-top: 10px;
}

.wolf-moon__phase-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    line-height: 14px;
    color: var(--w-text-dim);
}

.wolf-moon__phase-row b {
    font-weight: 600;
    color: var(--w-text);
}

.wolf-moon__bar {
    height: 4px;
    margin-top: 6px;
    border-radius: 4px;
    background: #ffffff1a;
    overflow: hidden;
}

.wolf-moon__bar span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--w-gold-dim), var(--w-gold));
    transition: width .9s ease;
}

.wolf-moon__last {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 12px;
    background: #ffffff0d;
    font-size: 11px;
    line-height: 15px;
    color: var(--w-text-dim);
}

.wolf-moon__last strong {
    display: block;
    margin-top: 2px;
    font-family: var(--w-display);
    font-weight: 400;
    font-size: 18px;
    line-height: 20px;
    letter-spacing: .4px;
    color: var(--w-text);
}

.wolf-moon__last strong span {
    float: right;
    font-family: var(--w-sans);
    font-size: 11px;
    line-height: 20px;
    letter-spacing: 0;
    color: var(--w-text-faint);
}

.wolf-moon__last.is-new {
    animation: wm-flash 1.6s ease;
}

@keyframes wm-flash {
    0% { background: #e8a84140; }
    100% { background: #ffffff0d; }
}

.wolf-moon__cta {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    margin-top: 14px;
    border-radius: 40px;
    background: var(--w-gold);
    color: #000;
    font-family: var(--w-sans);
    font-weight: 600;
    font-size: 14px;
    letter-spacing: .3px;
    text-decoration: none;
    transition: background .2s ease;
}

.wolf-moon__cta:hover { background: var(--w-gold-hi); }
.wolf-moon__cta:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------------- Чат поддержки ---------------- */
.support-chat {
    position: fixed;
    z-index: 60;
    right: 24px;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    font-family: var(--w-sans);
    color: var(--w-text);
}

.support-chat__launcher {
    position: relative;
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--w-gold);
    color: #000;
    cursor: pointer;
    box-shadow: 0 6px 24px #e8a84140, 0 2px 8px #00000080;
    transition: transform .2s ease, background .2s ease;
}

.support-chat__launcher:hover { background: var(--w-gold-hi); transform: translateY(-2px); }
.support-chat__launcher:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

.support-chat__launcher svg {
    width: 26px;
    height: 26px;
    transition: transform .25s ease, opacity .2s ease;
}

.support-chat__launcher .ic-close {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg);
}

.support-chat.is-open .support-chat__launcher .ic-chat { opacity: 0; transform: rotate(90deg); }
.support-chat.is-open .support-chat__launcher .ic-close { opacity: 1; transform: rotate(0); }

.support-chat__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    border: 2px solid var(--w-ink);
    background: var(--w-red);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 16px;
    text-align: center;
}

.support-chat__badge[hidden] { display: none; }

.support-chat__panel {
    position: absolute;
    right: 0;
    bottom: 72px;
    display: flex;
    flex-direction: column;
    width: 360px;
    height: min(520px, calc(100vh - 140px));
    border-radius: 16px;
    border: 1px solid #ffffff1a;
    background: var(--w-ink);
    box-shadow: 0 24px 64px #000000b3;
    overflow: hidden;
    transform-origin: bottom right;
    opacity: 0;
    transform: translateY(12px) scale(.96);
    visibility: hidden;
    transition: opacity .25s ease, transform .25s ease, visibility 0s linear .25s;
}

.support-chat.is-open .support-chat__panel {
    opacity: 1;
    transform: none;
    visibility: visible;
    transition: opacity .25s ease, transform .25s ease, visibility 0s;
}

.support-chat__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 14px 16px;
    background: var(--w-night);
    border-bottom: 1px solid #ffffff14;
}

.support-chat__avatar {
    position: relative;
    flex: none;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(160deg, var(--w-gold-hi), var(--w-gold-dim));
    color: #000;
    font-family: var(--w-display);
    font-size: 22px;
    line-height: 1;
}

.support-chat__avatar::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--w-green);
    border: 2px solid var(--w-night);
}

.support-chat__who { flex: 1; min-width: 0; }

.support-chat__name {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 20px;
}

.support-chat__status {
    margin: 0;
    font-size: 12px;
    line-height: 16px;
    color: var(--w-text-dim);
}

.support-chat__close {
    flex: none;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #ffffff14;
    color: var(--w-text);
    cursor: pointer;
}

.support-chat__close:hover { background: #ffffff26; }
.support-chat__close:focus-visible { outline: 2px solid var(--w-gold); outline-offset: 2px; }

.support-chat__log {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background:
        radial-gradient(90% 50% at 100% 0%, #e8a8410f, transparent 70%),
        var(--w-ink);
}

.support-chat__day {
    align-self: center;
    margin-bottom: 4px;
    font-size: 11px;
    color: var(--w-text-faint);
}

.chat-msg {
    max-width: 82%;
    padding: 9px 12px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 19px;
    word-wrap: break-word;
    animation: chat-in .22s ease both;
}

.chat-msg--agent {
    align-self: flex-start;
    background: var(--w-night-mid);
    border-bottom-left-radius: 4px;
}

.chat-msg--user {
    align-self: flex-end;
    background: var(--w-gold);
    color: #000;
    border-bottom-right-radius: 4px;
}

.chat-msg time {
    display: block;
    margin-top: 3px;
    font-size: 10px;
    line-height: 12px;
    opacity: .6;
    text-align: right;
}

@keyframes chat-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.chat-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    background: var(--w-night-mid);
}

.chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--w-text-dim);
    animation: chat-dot 1s ease-in-out infinite;
}

.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes chat-dot {
    0%, 60%, 100% { transform: none; opacity: .5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.support-chat__quick {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 12px;
    background: var(--w-ink);
}

.support-chat__quick[hidden] { display: none; }

.support-chat__chip {
    padding: 7px 12px;
    border: 1px solid #e8a84166;
    border-radius: 40px;
    background: transparent;
    color: var(--w-gold);
    font-family: var(--w-sans);
    font-size: 12px;
    font-weight: 600;
    line-height: 16px;
    cursor: pointer;
    transition: background .2s ease;
}

.support-chat__chip:hover { background: #e8a8411a; }
.support-chat__chip:focus-visible { outline: 2px solid var(--w-gold); outline-offset: 2px; }

.support-chat__form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #ffffff14;
    background: var(--w-night);
}

.support-chat__input {
    flex: 1;
    min-height: 40px;
    max-height: 96px;
    padding: 10px 14px;
    border: 1px solid transparent;
    border-radius: 20px;
    background: #ffffff0f;
    color: var(--w-text);
    font-family: var(--w-sans);
    font-size: 14px;
    line-height: 20px;
    resize: none;
    outline: none;
}

.support-chat__input::placeholder { color: var(--w-text-faint); }
.support-chat__input:focus { border-color: #e8a84199; }

.support-chat__send {
    flex: none;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--w-gold);
    color: #000;
    cursor: pointer;
    transition: background .2s ease, opacity .2s ease;
}

.support-chat__send:hover { background: var(--w-gold-hi); }
.support-chat__send:disabled { opacity: .4; cursor: default; }
.support-chat__send:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

@media (max-width: 575px) {
    .support-chat {
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .support-chat__launcher { width: 52px; height: 52px; }

    .support-chat__panel {
        bottom: 64px;
        width: calc(100vw - 24px);
        height: min(480px, 68vh);
    }
}

@media (prefers-reduced-motion: reduce) {
    .wolf-moon__star,
    .wolf-moon.is-full .wolf-moon__halo,
    .chat-typing span,
    .chat-msg { animation: none; }

    .support-chat__panel,
    .support-chat.is-open .support-chat__panel,
    .wolf-moon__lit,
    .wolf-moon__bar span { transition: none; }
}
