/* Шторка корзины в шапке — панель «Корзина» из tovarCard/proto18.html.
   Правила перенесены 1:1, классы прототипа с префиксом dk- (без префикса
   .link, .qty, .sm и т.п. совпадают с bootstrap и старым CSS сайта).
   Без блока «до бесплатной доставки» и «Дополните образ». */

.dk-cart[hidden],
.dk-cart [hidden] {
    display: none;
}

.dk-cart {
    --c-ink: #2B2721;
    --c-ink-soft: #6E6558;
    --c-surface-alt: #F1ECE3;
    --c-surface-soft: #FAF7F2;
    --c-border: #E4DACB;
    --c-border-control: #8C8375;
    --c-accent-dark: #5F6449;
    --c-sale: #A8402F;
    --c-scrim: rgba(43, 39, 33, .45);
}

.dk-cart,
.dk-cart * {
    box-sizing: border-box;
}

/* Слои выше кружка чата (z-index 2147483640), как у шторок карточки товара. */
.dk-scrim {
    position: fixed;
    inset: 0;
    background: var(--c-scrim);
    z-index: 2147483645;
    animation: dk-fadein .2s ease-out;
}

/* Десктоп — .dlg.side шириной 440px, мобильная — .dlg.sheet (ниже). */
.dk-dlg {
    position: fixed;
    z-index: 2147483646;
    top: 0;
    bottom: 0;
    right: 0;
    width: 440px;
    max-width: 100%;
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0, 0, 0, .25);
    animation: dk-slidein .22s ease-out;
    font-family: 'Montserrat', system-ui, sans-serif;
    font-size: 15px;
    line-height: 22px;
    color: var(--c-ink);
    text-align: left;
    -webkit-font-smoothing: antialiased;
    font-variant-numeric: tabular-nums;
}

.dk-dlg:focus {
    outline: none;
}

/* Сбросы прототипа; :where — нулевая специфичность, классы ниже их перебивают. */
.dk-dlg :where(button) {
    font: inherit;
    color: inherit;
    cursor: pointer;
    background: none;
    border: 0;
    padding: 0;
    text-align: left;
    line-height: inherit;
}

/* :focus-visible вне :where — иначе «button:focus» из bootstrap.min.css сильнее
   и с клавиатуры рисуется его чёрная рамка вместо рамки прототипа. */
.dk-dlg :where(button, a):focus-visible {
    outline: 2px solid var(--c-accent-dark);
    outline-offset: 2px;
}

/* bootstrap.min.css: «button:focus { outline: auto 5px }» — рамка после каждого
   клика мышью по −/+. В прототипе рамка только для клавиатуры (правило выше),
   при клике и касании её нет. */
.dk-dlg :where(button, a):focus:not(:focus-visible) {
    outline: none;
}

.dk-dlg :where(h2, p) {
    margin: 0;
}

@keyframes dk-fadein {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes dk-slidein {
    from { transform: translateX(40px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

@keyframes dk-sheetin {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

.dk-dlg-head {
    flex-shrink: 0;
    padding: 4px 8px 4px 24px;
    touch-action: none;
}

.dk-grabber {
    display: none;
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--c-border-control);
    margin: 8px auto 4px;
}

.dk-dlg-row {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 52px;
}

.dk-dlg-title {
    flex: 1;
    font-size: 20px;
    line-height: 28px;
    font-weight: 500;
}

.dk-ic-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 22px;
    position: relative;
    flex-shrink: 0;
}

.dk-ic-btn:hover {
    background: var(--c-surface-soft);
}

.dk-ic {
    display: block;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.dk-ic20 {
    width: 20px;
    height: 20px;
}

.dk-ic24 {
    width: 24px;
    height: 24px;
}

.dk-dlg-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 8px 24px 24px;
}

.dk-dlg-foot {
    flex-shrink: 0;
    padding: 16px 24px calc(16px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--c-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dk-mut {
    color: var(--c-ink-soft);
}

.dk-sm {
    font-size: 15px;
    line-height: 22px;
}

.dk-lookrow {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--c-border);
}

.dk-ph {
    background: var(--c-surface-alt);
    position: relative;
    overflow: hidden;
}

.dk-lookrow .dk-ph {
    width: 56px;
    height: 75px;
    flex-shrink: 0;
    border-radius: 4px;
}

.dk-pimg {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    object-position: center;
    color: transparent;
    z-index: 1;
    pointer-events: none;
}

/* Цена строки — как .pdp-price-row в карточке товара (pdp.css): те же цвета,
   начертание, зачёркивание и рамка процента, шрифты меньше (карточка: 20 / 15 / 13). */
.dk-price-row {
    display: flex;
    align-items: baseline;
    gap: 0 8px;
    flex-wrap: wrap;
}

.dk-price {
    font-size: 15px;
    line-height: 22px;
    font-weight: 600;
    color: var(--c-ink);
}

.dk-price--sale {
    color: var(--c-sale);
}

.dk-price-old {
    color: var(--c-ink-soft);
    font-size: 13px;
    line-height: 18px;
    text-decoration: line-through;
    font-weight: 400;
}

.dk-price-discount {
    font-size: 12px;
    line-height: 18px;
    color: var(--c-ink-soft);
    font-weight: 400;
    border: 1px solid var(--c-ink-soft);
    border-radius: 4px;
    padding: 0 6px;
}

/* Скелетон на время пересчёта (+/−/«Удалить»): цифры прячутся, на их месте
   плашка того же размера — вёрстка не прыгает. Пульс — shimmer прототипа
   (прозрачность 0.4 → 1), только зациклен, пока идёт запрос. */
.dk-price-row.is-calc > *,
.dk-total-value.is-calc {
    color: transparent;
    text-decoration-color: transparent;
    border-color: transparent;
    background: var(--c-surface-alt);
    border-radius: 4px;
    animation: dk-skel .7s ease-in-out infinite alternate;
}

@keyframes dk-skel {
    from { opacity: .4; }
    to { opacity: 1; }
}

.dk-qty {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--c-border-control);
    border-radius: 8px;
}

.dk-qty button {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dk-qty button[disabled] {
    cursor: default;
    opacity: .4;
}

.dk-qty span {
    min-width: 28px;
    text-align: center;
    font-weight: 500;
}

.dk-link {
    text-decoration: underline;
    text-underline-offset: 3px;
    color: var(--c-accent-dark);
    font-size: 15px;
    line-height: 22px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.dk-btn-main,
.dk-btn-out {
    font-size: 16px;
    line-height: 24px;
    height: 52px;
    width: 100%;
    border-radius: 8px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.dk-btn-main {
    background: var(--c-ink);
    color: #fff;
    border: 2px solid var(--c-ink);
    position: relative;
}

.dk-btn-main:hover {
    color: #fff;
    text-decoration: none;
    filter: brightness(1.3);
}

.dk-btn-out {
    background: #fff;
    color: var(--c-ink);
    border: 1px solid var(--c-ink);
}

.dk-btn-out:hover {
    color: var(--c-ink);
    text-decoration: none;
    background: var(--c-surface-soft);
}

/* Мобильная — .dlg.sheet: снизу, скругление сверху, ручка, закрытие свайпом по шапке. */
@media (max-width: 991px) {
    .dk-dlg {
        top: auto;
        left: 0;
        width: auto;
        max-height: 90%;
        border-radius: 16px 16px 0 0;
        animation: dk-sheetin .22s ease-out;
    }

    .dk-grabber {
        display: block;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dk-scrim,
    .dk-dlg,
    .dk-price-row.is-calc > *,
    .dk-total-value.is-calc {
        animation: none;
    }
}
