/* Корзина-калькулятор: круглая кнопка, выезжающая панель, список позиций.
 * Значения перенесены из самописного блока Битрикса без изменений. */

:root {
    --cart-brand: #7e1329;
    --cart-brand-light: rgba(126, 19, 41, 0.08);
    --cart-brand-glow: rgba(126, 19, 41, 0.25);
    --cart-accent: #c0dd92;
    --cart-glass: rgba(255, 255, 255, 0.72);
    --cart-glass-border: rgba(255, 255, 255, 0.45);
    --cart-glass-shadow: rgba(126, 19, 41, 0.12);
    --cart-text: #1a1a1a;
    --cart-text-soft: #777777;
    --cart-radius: 22px;
    --cart-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --cart-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* --------------------------------------------------------- круглая кнопка */
.cart-btn {
    position: fixed;
    right: clamp(14px, 2.5vw, 24px);
    bottom: clamp(14px, 2.5vw, 24px);
    width: clamp(54px, 6vw, 66px);
    height: clamp(54px, 6vw, 66px);
    background: var(--cart-brand);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10003;
    opacity: 0;
    transform: scale(0) rotate(-180deg);
    transition: transform 0.5s var(--cart-spring), opacity 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 20px var(--cart-glass-shadow), 0 0 0 0 var(--cart-brand-glow);
    -webkit-tap-highlight-color: transparent;
}

.cart-btn.active { opacity: 1; transform: scale(1) rotate(0deg); }

.cart-btn:hover {
    box-shadow: 0 8px 32px var(--cart-glass-shadow), 0 0 0 8px var(--cart-brand-glow);
    transform: scale(1.08) rotate(0deg);
}

.cart-btn:active { transform: scale(0.95) rotate(0deg); transition-duration: 0.1s; }
.cart-btn.pulse { animation: cartPulse 0.5s var(--cart-spring); }
.cart-btn.catch { animation: cartCatch 0.4s var(--cart-spring); }

.cart-icon { width: clamp(22px, 2.8vw, 28px); height: clamp(22px, 2.8vw, 28px); }

.cart-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--cart-accent);
    color: var(--cart-brand);
    font-family: "Nunito", sans-serif;
    font-weight: 800;
    font-size: 11px;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0);
    transition: transform 0.4s var(--cart-spring);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.cart-count.visible { transform: scale(1); }
.cart-count.bump { animation: countBump 0.4s var(--cart-spring); }

/* Летящая точка от карточки к корзине. */
.cart-fly-dot {
    position: fixed;
    z-index: 99999;
    pointer-events: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #f5c542;
    opacity: 0;
    filter: blur(0.5px);
}

/* ---------------------------------------------------------------- панель */
.cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 10003;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

.cart-overlay.active { opacity: 1; pointer-events: auto; }

.cart-panel {
    position: fixed;
    right: 0;
    bottom: 0;
    width: min(380px, 100%);
    height: 75vh;
    max-height: 680px;
    background: var(--cart-glass);
    backdrop-filter: blur(24px) saturate(1.6);
    -webkit-backdrop-filter: blur(24px) saturate(1.6);
    border: 1px solid var(--cart-glass-border);
    border-right: none;
    border-bottom: none;
    border-radius: var(--cart-radius) 0 0 0;
    z-index: 10004;
    display: flex;
    flex-direction: column;
    transform: translateX(105%);
    opacity: 0;
    transition: transform 0.45s var(--cart-ease), opacity 0.35s ease;
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.cart-panel.active { transform: translateX(0); opacity: 1; }

.cart-header {
    padding: 20px 22px 16px;
    font-family: "Nunito", sans-serif;
    font-weight: 800;
    font-size: 20px;
    letter-spacing: -0.02em;
    color: var(--cart-brand);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(126, 19, 41, 0.08);
}

.cart-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--cart-brand-light);
    color: var(--cart-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s var(--cart-spring);
}

.cart-close:hover { background: var(--cart-brand); color: #ffffff; transform: rotate(90deg) scale(1.1); }

.cart-items {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 16px;
    scroll-behavior: smooth;
}

.cart-items::-webkit-scrollbar { width: 4px; }
.cart-items::-webkit-scrollbar-track { background: transparent; }
.cart-items::-webkit-scrollbar-thumb { background: rgba(126, 19, 41, 0.15); border-radius: 4px; }

.cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    color: var(--cart-text-soft);
    font-family: "Nunito", sans-serif;
    font-size: 15px;
    text-align: center;
}

.cart-empty-icon { width: 48px; height: 48px; opacity: 0.25; }

/* ------------------------------------------------------------- позиции */
.cart-item {
    display: flex;
    align-items: center;
    padding: 12px;
    margin: 6px 0;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.04);
    font-family: "Nunito", sans-serif;
    gap: 12px;
    transition: background 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
    animation: itemSlideIn 0.4s var(--cart-spring) both;
}

.cart-item:hover {
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    transform: translateX(-2px);
}

.cart-item.removing { animation: itemSlideOut 0.35s var(--cart-ease) forwards; }

.cart-item-img {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.cart-item-info { flex: 1; min-width: 0; }

.cart-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--cart-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-item-right { display: flex; align-items: center; flex-shrink: 0; gap: 8px; }
.cart-price { font-weight: 800; font-size: 14px; color: var(--cart-brand); }

.cart-qty {
    display: flex;
    align-items: center;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(126, 19, 41, 0.12);
}

.cart-qty-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--cart-brand-light);
    color: var(--cart-brand);
    font-family: "Nunito", sans-serif;
    font-weight: 800;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
    padding: 0;
    line-height: 1;
}

.cart-qty-btn:hover { background: var(--cart-brand); color: #ffffff; }
.cart-qty-btn:active { transform: scale(0.9); }

.cart-qty-num {
    width: 26px;
    text-align: center;
    font-family: "Nunito", sans-serif;
    font-weight: 800;
    font-size: 13px;
    color: var(--cart-brand);
    background: rgba(255, 255, 255, 0.6);
}

/* --------------------------------------------------------------- итог */
.cart-footer {
    padding: 16px 22px 20px;
    font-family: "Nunito", sans-serif;
    color: var(--cart-brand);
    border-top: 1px solid rgba(126, 19, 41, 0.08);
    background: rgba(255, 255, 255, 0.4);
}

.cart-service {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    color: var(--cart-text-soft);
    margin-bottom: 10px;
}

.cart-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(126, 19, 41, 0.12), transparent);
    margin-bottom: 10px;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.02em;
}

.cart-total-value {
    font-size: 22px;
    background: linear-gradient(135deg, var(--cart-brand), #a82040);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ---------------------------------------------------------- анимации */
@keyframes cartPulse {
    0%   { transform: scale(1); }
    30%  { transform: scale(1.25); }
    60%  { transform: scale(0.92); }
    100% { transform: scale(1); }
}

@keyframes cartCatch {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.3); box-shadow: 0 0 0 12px var(--cart-brand-glow); }
    70%  { transform: scale(0.9); }
    100% { transform: scale(1); box-shadow: 0 4px 20px var(--cart-glass-shadow); }
}

@keyframes countBump {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.4); }
    100% { transform: scale(1); }
}

@keyframes itemSlideIn {
    0%   { opacity: 0; transform: translateX(40px) scale(0.9); }
    100% { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes itemSlideOut {
    0%   { opacity: 1; transform: translateX(0) scale(1); max-height: 80px; margin: 6px 0; padding: 12px; }
    100% { opacity: 0; transform: translateX(-60px) scale(0.8); max-height: 0; margin: 0; padding: 0 12px; border-width: 0; }
}

@media (max-width: 420px) {
    .cart-panel {
        width: 100%;
        height: 80vh;
        border-radius: var(--cart-radius) var(--cart-radius) 0 0;
        border-right: none;
        border-left: 1px solid var(--cart-glass-border);
        transform: translateY(105%);
    }
    .cart-panel.active { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .cart-btn, .cart-count, .cart-item { animation: none; }
    .cart-fly-dot { display: none; }
}
