/* Магазин / Shop — catalogue + physical-book checkout.
   Deliberately self-contained: no dependency on the legacy template's grid,
   so the shop pages render the same wherever they are embedded. */

.shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 24px;
    margin: 24px 0 40px;
}

.shop-card {
    display: flex;
    flex-direction: column;
    border: 1px solid #e6e6e6;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}

.shop-card__img {
    display: block;
    width: 100%;
    height: 220px;
    object-fit: contain;
    background: #fafafa;
    padding: 12px;
}

.shop-card__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 220px;
    background: #fafafa;
    font-size: 48px;
    color: #c9c9c9;
}

.shop-card__body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    padding: 16px;
    gap: 8px;
}

.shop-card__name { font-weight: 600; line-height: 1.3; }
.shop-card__note { font-size: 13px; color: #777; }
.shop-card__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: auto;
    padding-top: 12px;
}
.shop-card__price { font-size: 20px; font-weight: 700; white-space: nowrap; }

.shop-btn {
    display: inline-block;
    padding: 10px 18px;
    border: 0;
    border-radius: 6px;
    background: #d61c2e;
    color: #fff;
    font: inherit;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
}
.shop-btn:hover { background: #b81726; color: #fff; }
.shop-btn[disabled] { opacity: .5; cursor: default; }
.shop-btn--ghost { background: transparent; border: 1px solid #d61c2e; color: #d61c2e; }
.shop-btn--ghost:hover { background: #d61c2e; color: #fff; }

.shop-oos { font-size: 13px; color: #999; }

/* ── checkout ─────────────────────────────────────────────────────────── */

.shop-checkout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 32px;
    align-items: start;
    margin: 24px 0 48px;
}
@media (max-width: 860px) {
    .shop-checkout { grid-template-columns: 1fr; }
}

.shop-fieldset { border: 0; margin: 0 0 28px; padding: 0; }
.shop-fieldset > legend {
    padding: 0;
    margin-bottom: 12px;
    font-size: 17px;
    font-weight: 600;
}

.shop-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.shop-field { display: flex; flex-direction: column; gap: 4px; }
.shop-field > span { font-size: 13px; color: #666; }
.shop-field input,
.shop-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d5d5d5;
    border-radius: 6px;
    font: inherit;
    background: #fff;
}
.shop-field input:focus,
.shop-field textarea:focus { outline: 2px solid #d61c2e33; border-color: #d61c2e; }

.shop-cities { list-style: none; margin: 8px 0 0; padding: 0; border: 1px solid #e6e6e6; border-radius: 6px; }
.shop-cities:empty { display: none; }
.shop-cities li { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid #f0f0f0; }
.shop-cities li:last-child { border-bottom: 0; }
.shop-cities li:hover { background: #fdf2f3; }
.shop-cities__region { color: #999; font-size: 13px; }

.shop-options { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.shop-option {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
}
.shop-option:hover { border-color: #d61c2e; }
.shop-option__name { font-weight: 600; }
.shop-option__meta { font-size: 13px; color: #777; }
.shop-option__cost { margin-left: auto; white-space: nowrap; font-weight: 600; }

/* Courier stays open; пункты выдачи collapse behind a count and a filter —
   a big city returns hundreds of them. */
.shop-optgroup { display: flex; flex-direction: column; gap: 8px; }
.shop-optgroup__head {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 0;
    border: 0;
    background: none;
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    color: inherit;
}
.shop-optgroup__head::after {
    content: '▾';
    margin-left: auto;
    color: #999;
    transition: transform .15s ease;
}
.shop-optgroup__head[aria-expanded="false"]::after { transform: rotate(-90deg); }
.shop-optgroup__count {
    padding: 1px 8px;
    border-radius: 10px;
    background: #f0f0f0;
    font-size: 13px;
    font-weight: 400;
    color: #666;
}
.shop-optgroup__body { display: flex; flex-direction: column; gap: 8px; }
.shop-optgroup__empty { font-size: 14px; color: #777; padding: 4px 2px; }

.shop-filter {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d5d5d5;
    border-radius: 6px;
    font: inherit;
    background: #fff;
}
.shop-filter:focus { outline: 2px solid #d61c2e33; border-color: #d61c2e; }

.shop-summary {
    border: 1px solid #e6e6e6;
    border-radius: 10px;
    padding: 20px;
    background: #fafafa;
    position: sticky;
    top: 16px;
}
.shop-summary__line { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.shop-summary__total {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #e0e0e0;
    font-size: 18px;
    font-weight: 700;
}
.shop-summary .shop-btn { width: 100%; margin-top: 18px; text-align: center; }

.shop-msg { margin-top: 12px; font-size: 14px; min-height: 20px; }
.shop-msg--error { color: #d61c2e; }
.shop-msg--ok { color: #1a7f37; }

.shop-note { color: #777; font-size: 14px; }
.shop-hidden { display: none !important; }

/* ── Корзина ─────────────────────────────────────────────────────────────── */

.shop-cartbar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 12px 16px;
    margin: 0 0 24px;
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    background: #fafafa;
}

.shop-cartbar[hidden] { display: none; }

/* Two actions per card: add to basket, or the original straight-to-checkout buy. */
.shop-card__buy { display: flex; gap: 8px; flex-wrap: wrap; }

.shop-cart__line {
    display: grid;
    grid-template-columns: 1fr auto auto auto auto;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid #eee;
}

.shop-cart__name { font-weight: 600; }
.shop-cart__price, .shop-cart__sum { white-space: nowrap; }
.shop-cart__sum { font-weight: 600; min-width: 90px; text-align: right; }

.shop-cart__qty { display: flex; align-items: center; gap: 4px; }

.shop-qty__btn {
    width: 32px;
    height: 32px;
    border: 1px solid #d6d6d6;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.shop-qty__btn:hover { border-color: #d61c2e; color: #d61c2e; }

.shop-qty__input {
    width: 56px;
    height: 32px;
    text-align: center;
    border: 1px solid #d6d6d6;
    border-radius: 6px;
}

.shop-cart__remove {
    border: 0;
    background: none;
    color: #aaa;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.shop-cart__remove:hover { color: #d61c2e; }

.shop-cart__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin: 24px 0 8px;
}

.shop-cart__total { font-size: 20px; font-weight: 600; }
.shop-cart__actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* The five-column line collapses to name-over-controls on narrow screens. */
@media (max-width: 640px) {
    .shop-cart__line {
        grid-template-columns: 1fr auto auto;
        row-gap: 8px;
    }
    .shop-cart__name { grid-column: 1 / -1; }
    .shop-cart__sum { min-width: 0; }
}

/* ── Акции ───────────────────────────────────────────────────────────────── */

.shop-promo {
    margin: 16px 0 0;
    padding: 12px 16px;
    border: 1px dashed #d61c2e;
    border-radius: 8px;
    background: #fff7f7;
}

.shop-promo__line { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.shop-promo__line + .shop-promo__line { margin-top: 6px; }

.shop-promo__badge {
    flex: 0 0 auto;
    padding: 2px 8px;
    border-radius: 4px;
    background: #d61c2e;
    color: #fff;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.shop-summary__line--gift { color: #d61c2e; }
