/*
 * Прототип клиентской страницы «Подтверждение макета и выбор доставки».
 * Палитра, шрифт и скругления сняты с боевого сайта brickme.ru
 * (токены --brick-red, --ocean-blue, --ink, шрифт Manrope, кнопки-пилюли).
 *
 * Внимание: пиктограммы в комментариях внутри style запрещены правилами
 * проекта (комментарий из style уезжает в разметку) — здесь их нет.
 */

/* ---------- Токены brickme.ru ---------- */
:root {
    --brick-red: #ff3213;
    --brick-red-hover: #e62b0f;
    --ocean-blue: #0341ae;
    --sun-yellow: #ffd500;
    --lime-green: #72cb3b;

    --ink: #111827;
    --ink-2: #4b5563;
    --ink-3: #8b93a1;

    --bg-page: #fff;
    --surface-card: #f7f7f9;
    --line: #e6e6ea;

    --radius-large: 22px;
    --radius-card: 20px;
    --radius-field: 14px;

    --shadow-card: 0 10px 30px rgba(17, 24, 39, .06);
    --shadow-red: 0 14px 30px rgba(255, 50, 19, .35);

    --page-max: 640px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--surface-card);
    color: var(--ink);
    font-family: Manrope, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Каркас страницы ---------- */
.page {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 0 16px 48px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    /* Без backdrop-filter: он поднимает шапку над затемнением попапа. */
    background: var(--bg-page);
    border-bottom: 1px solid var(--line);
}

.topbar__inner {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-weight: 800;
    font-size: 20px;
    letter-spacing: -.02em;
    color: var(--ink);
    text-decoration: none;
}

.logo b {
    color: var(--brick-red);
}

.topbar__order {
    margin-left: auto;
    font-size: 13px;
    color: var(--ink-3);
    font-weight: 600;
    white-space: nowrap;
}

/* Переключатель демо-заказа: только для показа заказчику, на бою его нет. */
.demo-switch {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, .55);
    border-radius: 999px;
    padding: 3px 3px 3px 10px;
}

.demo-switch__label {
    font-size: 12px;
    color: var(--ink-2);
    font-weight: 700;
}

.demo-switch button {
    border: none;
    background: none;
    cursor: pointer;
    /* Ширина по содержимому: тут и цифры заказа, и слова «работает»/«упала». */
    min-width: 24px;
    height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 13px;
    line-height: 24px;
    white-space: nowrap;
    color: var(--ink-2);
    font-family: inherit;
}

.demo-switch button[aria-pressed="true"] {
    background: var(--ink);
    color: #fff;
}

/* ---------- Полоса шагов ---------- */
.steps {
    display: flex;
    gap: 8px;
    padding: 18px 0 20px;
}

.steps__item {
    flex: 1;
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-3);
    text-align: center;
}

.steps__bar {
    height: 5px;
    border-radius: 999px;
    background: var(--line);
    margin-bottom: 7px;
    transition: background .25s;
}

.steps__item.is-done .steps__bar {
    background: var(--lime-green);
}

.steps__item.is-done {
    color: var(--ink-2);
}

.steps__item.is-current .steps__bar {
    background: var(--brick-red);
}

.steps__item.is-current {
    color: var(--ink);
}

/* ---------- Карточка ---------- */
.card {
    background: var(--bg-page);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 20px;
    margin-bottom: 16px;
}

h1 {
    font-size: 26px;
    line-height: 1.2;
    letter-spacing: -.02em;
    font-weight: 800;
    margin: 0 0 10px;
}

h2 {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -.01em;
    margin: 0 0 8px;
}

p {
    margin: 0 0 12px;
    color: var(--ink-2);
}

p.lead {
    color: var(--ink-2);
    font-size: 16px;
}

.muted {
    color: var(--ink-3);
    font-size: 13px;
}

/* ---------- Шаг 1: макет ---------- */
.render {
    position: relative;
    background: var(--bg-page);
    border: 1px solid var(--line);
    border-radius: var(--radius-large);
    overflow: hidden;
    margin-bottom: 16px;
}

.render img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

.render__badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: var(--ocean-blue);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 999px;
}

/* Памятка «на что посмотреть» — тон обращения к клиенту как на сайте. */
.checklist {
    list-style: none;
    margin: 0 0 4px;
    padding: 0;
}

.checklist li {
    position: relative;
    padding-left: 26px;
    margin-bottom: 8px;
    color: var(--ink-2);
    font-size: 15px;
}

.checklist li::before {
    content: "";
    position: absolute;
    left: 6px;
    top: 9px;
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--brick-red);
}

/* ---------- Кнопки (пилюли brickme.ru) ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    cursor: pointer;
    border: none;
    border-radius: 999px;
    padding: .95rem 1.9rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    transition: transform .2s, box-shadow .2s, background .2s, color .2s;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--brick-red);
    color: #fff;
    box-shadow: var(--shadow-red);
}

.btn-primary:hover {
    background: var(--brick-red-hover);
}

.btn-primary[disabled] {
    background: #f0b8ae;
    box-shadow: none;
    cursor: not-allowed;
}

.btn-secondary {
    background: transparent;
    color: var(--ocean-blue);
    border: 2px solid var(--ocean-blue);
}

.btn-ghost {
    background: transparent;
    color: var(--ink-2);
    padding: .7rem 1rem;
    font-weight: 600;
}

.btn-ghost:hover {
    color: var(--ink);
}

.btn-tg {
    background: #0088cc;
    color: #fff;
    box-shadow: 0 12px 30px rgba(0, 136, 204, .35);
}

.btn-full {
    width: 100%;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.back-row {
    display: flex;
    justify-content: center;
    margin-top: 6px;
}

/* ---------- Шаг 2: доставка ---------- */
.tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    background: var(--surface-card);
    border-radius: 999px;
    padding: 5px;
    margin-bottom: 16px;
}

.tabs button {
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 999px;
    padding: 11px 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    color: var(--ink-2);
    line-height: 1.2;
    transition: background .2s, color .2s, box-shadow .2s;
}

.tabs button[aria-selected="true"] {
    background: var(--bg-page);
    color: var(--ink);
    box-shadow: 0 2px 8px rgba(17, 24, 39, .1);
}

.tabs button span {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--ink-3);
}

/*
 * Контейнер карты. Размер живёт ЗДЕСЬ и только здесь, поэтому он одинаков
 * для боевого виджета СДЭК и для подмены: оба слоя растянуты в размер
 * контейнера. Подставят настоящие ключи — блок останется той же высоты,
 * и вёрстка вокруг не поедет.
 */
.map-box {
    position: relative;
    width: 100%;
    height: 420px;
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-field);
    overflow: hidden;
    background: var(--surface-card);
}

.map-box__layer {
    position: absolute;
    inset: 0;
}

.map-box__layer[hidden] {
    display: none !important;
}

.map-box__pic {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: filter .2s;
}

/* Подпись поверх карты. */
.map-box__hint {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 10px;
    background: rgba(255, 255, 255, .94);
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-2);
    text-align: center;
}

/* Состояние «карта не загрузилась»: та же коробка, картинка приглушена. */
.map-box.is-down .map-box__pic {
    filter: grayscale(1) contrast(.85) opacity(.55);
}

.map-box.is-down .map-pins,
.map-box.is-down .map-box__hint {
    display: none;
}

.map-box.is-down .map-box__down {
    display: flex;
}

.map-box__down {
    position: absolute;
    inset: 0;
    /* Видна только в состоянии «карта не загрузилась». */
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    gap: 4px;
}

.map-box__down-title {
    font-size: 17px;
    font-weight: 800;
    color: var(--ink);
}

.map-box__down-text {
    font-size: 14px;
    color: var(--ink-2);
    max-width: 320px;
}

/* Метки пунктов выдачи поверх карты-подмены. */
.map-pins {
    position: absolute;
    inset: 0;
}

.map-pin {
    position: absolute;
    transform: translate(-50%, -100%);
    width: 26px;
    height: 34px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    line-height: 0;
}

.map-pin::before {
    content: "";
    display: block;
    width: 26px;
    height: 26px;
    border-radius: 999px 999px 999px 2px;
    background: var(--brick-red);
    border: 3px solid #fff;
    box-shadow: 0 3px 8px rgba(17, 24, 39, .35);
    transform: rotate(-45deg);
}

.map-pin[aria-pressed="true"]::before {
    background: var(--ocean-blue);
    width: 30px;
    height: 30px;
}

.pvz-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pvz-empty {
    border: 1px dashed var(--line);
    border-radius: var(--radius-field);
    padding: 16px;
    text-align: center;
    font-size: 14px;
    color: var(--ink-3);
}

/* Подсказки городов под полем ввода. */
.suggest {
    position: relative;
}

.suggest__list {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 10;
    background: var(--bg-page);
    border: 1px solid var(--line);
    border-radius: var(--radius-field);
    box-shadow: 0 12px 28px rgba(17, 24, 39, .14);
    overflow: hidden;
    max-height: 240px;
    overflow-y: auto;
}

.suggest__item {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 15px;
    color: var(--ink);
    padding: 11px 14px;
    cursor: pointer;
}

.suggest__item:hover,
.suggest__item.is-active {
    background: #f3f7ff;
}

.suggest__item small {
    color: var(--ink-3);
    font-size: 12px;
    margin-left: 6px;
}

.pvz-item {
    text-align: left;
    background: var(--bg-page);
    border: 2px solid var(--line);
    border-radius: var(--radius-field);
    padding: 12px 14px;
    cursor: pointer;
    font-family: inherit;
    transition: border-color .2s;
}

.pvz-item:hover {
    border-color: var(--brick-red);
}

.pvz-item[aria-pressed="true"] {
    border-color: var(--ocean-blue);
    background: #f3f7ff;
}

.pvz-item__name {
    font-weight: 700;
    font-size: 15px;
    color: var(--ink);
}

.pvz-item__addr {
    font-size: 13px;
    color: var(--ink-2);
}

.pvz-item__meta {
    font-size: 12px;
    color: var(--ink-3);
    margin-top: 4px;
}

/* Плашка с выбранным пунктом выдачи. */
.chosen {
    margin-top: 14px;
    border: 2px solid var(--lime-green);
    background: #f4fbef;
    border-radius: var(--radius-field);
    padding: 12px 14px;
}

.chosen__title {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #4e8f28;
    margin-bottom: 3px;
}

/* ---------- Поля ---------- */
.field {
    margin-bottom: 14px;
}

.field label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink-2);
    margin-bottom: 6px;
}

.field input,
.field textarea {
    width: 100%;
    font-family: inherit;
    font-size: 16px;
    color: var(--ink);
    background: var(--bg-page);
    border: 2px solid var(--line);
    border-radius: var(--radius-field);
    padding: 13px 14px;
    transition: border-color .2s;
}

.field input:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--ocean-blue);
}

.field.has-error input,
.field.has-error textarea {
    border-color: var(--brick-red);
}

.field__error {
    display: none;
    font-size: 13px;
    font-weight: 600;
    color: var(--brick-red);
    margin-top: 5px;
}

.field.has-error .field__error {
    display: block;
}

.field__hint {
    font-size: 12px;
    color: var(--ink-3);
    margin-top: 5px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ---------- Итог ---------- */
.summary {
    border: 1px solid var(--line);
    border-radius: var(--radius-field);
    overflow: hidden;
    /* Итог всегда по левому краю, даже внутри карточки с классом center. */
    text-align: left;
}

.summary__row {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 15px;
}

.summary__row:last-child {
    border-bottom: none;
}

.summary__key {
    color: var(--ink-3);
    flex: 0 0 38%;
    font-size: 13px;
    font-weight: 700;
}

.summary__val {
    flex: 1;
    font-weight: 600;
}

/* ---------- Финальный экран ---------- */
.done-mark {
    width: 64px;
    height: 64px;
    border-radius: 999px;
    background: var(--lime-green);
    margin: 4px auto 16px;
    position: relative;
}

.done-mark::after {
    content: "";
    position: absolute;
    left: 22px;
    top: 16px;
    width: 14px;
    height: 26px;
    border: solid #fff;
    border-width: 0 5px 5px 0;
    border-radius: 2px;
    transform: rotate(45deg);
}

.center {
    text-align: center;
}

/* ---------- Попап подтверждения ---------- */
.modal[hidden] {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, .55);
}

.modal__box {
    position: relative;
    background: var(--bg-page);
    border-radius: var(--radius-large);
    padding: 24px 20px 20px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 24px 60px rgba(17, 24, 39, .3);
}

.modal__box h2 {
    font-size: 20px;
    margin-bottom: 10px;
}

.modal__thumb {
    width: 96px;
    height: 96px;
    border-radius: var(--radius-field);
    object-fit: cover;
    border: 1px solid var(--line);
    display: block;
    margin: 0 auto 14px;
}

/* ---------- Подвал ---------- */
.footer-note {
    text-align: center;
    font-size: 12px;
    color: var(--ink-3);
    padding: 8px 4px 0;
}

.proto-flag {
    background: var(--sun-yellow);
    color: var(--ink);
    font-size: 12px;
    font-weight: 700;
    padding: 7px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

/*
 * Телефонный порог проекта. Пишется РОВНО так (см. CLAUDE.md):
 * второе условие ловит телефон, повёрнутый набок.
 */
@media screen and (max-width: 640px),
       screen and (orientation: landscape) and (max-height: 480px) and (max-width: 1023px) {
    .page {
        padding: 0 12px 40px;
    }

    .topbar__inner {
        padding: 10px 12px;
        gap: 8px;
    }

    .logo {
        font-size: 18px;
    }

    .topbar__order {
        font-size: 12px;
    }

    .proto-flag {
        gap: 8px;
        font-size: 11px;
    }

    .proto-flag__text {
        flex: 1 1 100%;
        text-align: center;
    }

    .card {
        padding: 16px;
        border-radius: 18px;
    }

    h1 {
        font-size: 22px;
    }

    h2 {
        font-size: 17px;
    }

    .btn {
        padding: .9rem 1.2rem;
        width: 100%;
    }

    .actions {
        gap: 8px;
    }

    .grid-2 {
        grid-template-columns: 1fr;
        gap: 0;
    }

    #cdek-widget {
        height: 340px;
    }

    .summary__key {
        flex: 0 0 42%;
    }

    .modal__box {
        padding: 20px 16px 16px;
    }
}
