/* ==================================================================
   КОНСТРУКТОР — страница /configurator
   Палитра сверху, доска и состав сборки снизу.
   ================================================================== */

.builder { padding-bottom: clamp(3rem, 7vw, 6rem); }
.builder__defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.builder__palette, .builder__stage, .builder__hint { user-select: none; -webkit-user-select: none; }

.builder__palette {
    display: grid;
    grid-template-columns: 1.25fr 1fr;
    gap: 2rem 3rem;
    padding: 2rem;
    background: #f6f5f2;
}

.builder__label {
    display: flex; align-items: center; gap: .7rem;
    margin-bottom: 1rem;
    font-size: 1.05rem; font-weight: 400; letter-spacing: .08em; text-transform: uppercase;
    color: var(--ink);
}
.builder__label span {
    display: inline-grid; place-items: center;
    width: 1.7rem; height: 1.7rem; border-radius: 50%;
    background: var(--ink); color: #fff; font-size: .8rem; letter-spacing: 0;
}
.builder__sublabel {
    margin: 1.3rem 0 .6rem;
    font-size: .78rem; font-weight: 400; letter-spacing: .1em; text-transform: uppercase;
    color: var(--muted);
}

/* формы рамок */
.builder__styles { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.builder__style {
    display: flex; flex-direction: column; align-items: flex-start;
    padding: .45rem .8rem; border: 1px solid var(--line); background: #fff;
    line-height: 1.2; transition: border-color .2s, background .2s;
}
.builder__style b { font-weight: 500; font-size: .85rem; letter-spacing: .08em; color: var(--ink); }
.builder__style small { font-size: .7rem; color: var(--muted); }
.builder__style:hover { border-color: var(--ink); }
.builder__style.is-active { border-color: var(--ink); background: var(--ink); }
.builder__style.is-active b, .builder__style.is-active small { color: #fff; }

/* детали на палитре */
.builder__pieces { display: flex; flex-wrap: wrap; gap: .6rem; }
.piece {
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: .35rem;
    min-width: 92px; padding: .7rem .7rem .55rem;
    background: #fff; border: 1px solid transparent;
    cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
    transition: transform .2s var(--ease), border-color .2s, box-shadow .2s;
}
.piece:hover { transform: translateY(-3px); border-color: var(--line); box-shadow: 0 8px 22px rgba(0, 0, 0, .06); }
.piece:active { cursor: grabbing; }
.piece.is-off { opacity: .3; cursor: not-allowed; transform: none; box-shadow: none; }
.piece__pic { display: grid; place-items: center; height: 66px; pointer-events: none; }
.piece__pic svg { height: 100%; width: auto; max-width: 150px; }
.piece--insert .piece__pic { height: 58px; }
.piece__name { font-size: .78rem; line-height: 1.25; text-align: center; color: var(--ink-2); max-width: 120px; }

/* глазури */
.swatches { display: flex; flex-wrap: wrap; gap: .45rem; }
.swatch {
    width: 28px; height: 28px; border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 45%), var(--sw);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
    cursor: grab; touch-action: none;
    transition: transform .15s var(--ease), box-shadow .15s;
}
.swatch:hover { transform: scale(1.12); }
.swatch.is-active { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12), 0 0 0 2px #fff, 0 0 0 3.5px var(--ink); }
.swatch--ghost { display: block; width: 40px; height: 40px; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); }

.builder__hint { margin: 1.1rem 0 1.4rem; font-size: .9rem; text-align: center; }

/* доска и состав */
.builder__work { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 2rem; align-items: start; }

.builder__stage {
    position: relative;
    display: grid; place-items: center;
    min-height: 440px; padding: 2.5rem 1.5rem 4rem;
    background:
        radial-gradient(circle at 1px 1px, rgba(0, 0, 0, .07) 1px, transparent 0) 0 0 / 22px 22px,
        #fbfaf8;
    border: 1px dashed transparent;
    transition: border-color .2s, background-color .2s;
}
.is-building .builder__stage { border-color: #cfcac2; }
.builder__stage.is-over { border-color: var(--accent); background-color: #f3f7f2; }

.builder__board { display: grid; place-items: center; width: 100%; }
.board-svg { display: block; max-width: 100%; height: auto; }

.builder__empty {
    display: grid; place-items: center;
    width: min(100%, 360px); aspect-ratio: 1.6;
    border: 1.5px dashed #c9c4bb; border-radius: 999px;
    color: var(--muted); font-size: .95rem; text-align: center; padding: 1rem;
}

.slot-empty { fill: rgba(255, 255, 255, .55); stroke: rgba(0, 0, 0, .3); stroke-width: 1.4; stroke-dasharray: 4 4; }
.slot-plus { stroke: rgba(0, 0, 0, .35); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.slot-hit { fill: transparent; stroke: transparent; stroke-width: 3; cursor: pointer; touch-action: none; transition: stroke .15s; }
.slot-hit.is-full { cursor: grab; }
.slot-hit:hover { stroke: rgba(0, 0, 0, .18); }
.slot-hit.is-selected { stroke: var(--accent); stroke-dasharray: 6 4; }
.drag-insert .slot-hit, .drag-move .slot-hit, .drag-color .slot-hit.is-full { stroke: rgba(135, 163, 134, .55); stroke-dasharray: 5 4; }
.slot-hit.is-over { stroke: var(--accent) !important; stroke-dasharray: none !important; stroke-width: 4; }

.builder__tools {
    position: absolute; left: 50%; bottom: 1rem; transform: translateX(-50%);
    display: flex; border: 1px solid var(--line); background: #fff;
}
.builder__tools[hidden] { display: none; }
.builder__tool { padding: .45rem .9rem; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.builder__tool + .builder__tool { border-left: 1px solid var(--line); }
.builder__tool.is-active { color: #fff; background: var(--ink); }

.builder__ghost {
    position: fixed; left: 0; top: 0; z-index: 1000;
    pointer-events: none;
    margin: -34px 0 0 -34px;
    width: 68px; height: 68px;
    filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .22));
}
.builder__ghost.is-frame { width: 150px; margin: -34px 0 0 -75px; }
.builder__ghost svg { width: 100%; height: 100%; }
.builder__ghost .swatch--ghost { margin: 14px; }
.is-building, .is-building * { cursor: grabbing !important; user-select: none; }

/* состав сборки */
.builder__summary { padding: 1.6rem; border: 1px solid var(--line); position: sticky; top: 1.5rem; }
.builder__lines { list-style: none; margin: 0 0 1.2rem; padding: 0; }
.line {
    display: flex; align-items: flex-start; gap: .65rem;
    padding: .6rem 0; border-bottom: 1px solid var(--line);
    font-size: .9rem; line-height: 1.4; color: var(--ink-2); cursor: pointer;
}
.line--frame { cursor: default; }
.line b { font-weight: 500; color: var(--ink); }
.line i { color: var(--muted); }
.line.is-selected { color: var(--ink); }
.line.is-selected .line__dot { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--accent); }
.line__dot { flex: none; width: 16px; height: 16px; margin-top: .15rem; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.line--empty .line__dot { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .3); }
.line__remove { margin-left: auto; padding: 0 .3rem; font-size: 1.2rem; line-height: 1; color: var(--muted); }
.line__remove:hover { color: var(--ink); }

.builder__total { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 1.1rem; color: var(--ink-2); }
.builder__total b { font-size: 1.5rem; font-weight: 300; color: var(--ink); }

.builder__buy { display: flex; gap: .6rem; }
.builder__buy .btn { flex: 1; justify-content: center; }
.builder__buy .btn:disabled { opacity: .35; cursor: not-allowed; }
.builder__buy .btn:disabled:hover { background: var(--bg-dark); }

.builder__status { min-height: 1.4em; margin: .8rem 0 0; font-size: .85rem; }
.builder__status.is-alert { color: #c0392b; animation: builderShake .4s; }
@keyframes builderShake {
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}
.builder__added { margin: .3rem 0 0; font-size: .88rem; color: var(--accent-dk); }
.builder__added a { text-decoration: underline; }
.builder__reset { margin-top: 1rem; font-size: .82rem; color: var(--muted); text-decoration: underline; }
.builder__reset:hover { color: var(--ink); }
.builder__note { margin: 1rem 0 0; font-size: .75rem; line-height: 1.5; }

@media (max-width: 960px) {
    .builder__palette { grid-template-columns: 1fr; padding: 1.4rem; }
    .builder__work { grid-template-columns: 1fr; }
    .builder__summary { position: static; }
    .builder__stage { min-height: 300px; padding: 1.5rem 1rem 3.8rem; }
}
@media (max-width: 560px) {
    .builder__palette { padding: 1.1rem; margin-inline: calc(var(--gutter) * -0.5); }
    .builder__styles { display: grid; grid-template-columns: repeat(5, 1fr); gap: .3rem; }
    .builder__style { align-items: center; padding: .5rem .2rem; }
    .builder__style b { font-size: .72rem; letter-spacing: .04em; }
    .builder__style small { display: none; }
    .builder__pieces { flex-wrap: nowrap; gap: .4rem; }
    .piece { min-width: 0; flex: 1 1 0; padding: .5rem .3rem; }
    .piece__name { overflow-wrap: anywhere; }
    .piece__pic { height: 50px; }
    .piece--insert .piece__pic { height: 46px; }
    .piece__name { font-size: .72rem; }
    .swatch { width: 30px; height: 30px; }
}

/* ==================================================================
   Фото-версия: вкладки, фильтры, вырезки на доске
   ================================================================== */

.builder__tabs { display: flex; flex-wrap: wrap; gap: 0; margin-bottom: .8rem; border-bottom: 1px solid var(--line); }
.builder__tab {
    padding: .5rem .9rem; margin-bottom: -1px;
    font-size: .82rem; letter-spacing: .04em; color: var(--muted);
    border-bottom: 2px solid transparent; transition: color .2s, border-color .2s;
}
.builder__tab:hover { color: var(--ink); }
.builder__tab.is-active { color: var(--ink); border-bottom-color: var(--ink); }

.builder__chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .9rem; min-height: 0; }
.builder__chips:empty { display: none; }
.chip {
    padding: .25rem .7rem; border: 1px solid var(--line); background: #fff; border-radius: 999px;
    font-size: .72rem; letter-spacing: .06em; color: var(--ink-2);
}
.chip:hover { border-color: var(--ink); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip--dot {
    width: 24px; height: 24px; padding: 0;
    background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 45%), var(--sw);
    border-color: rgba(0, 0, 0, .12);
}
.chip--dot.is-active { background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 45%), var(--sw); box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--ink); }

.builder__pieces { max-height: 330px; overflow-y: auto; padding: 2px 4px 4px 2px; }
.piece { width: 104px; min-width: 0; }
.piece--frame.piece--p2 { width: 150px; }
.piece--frame.piece--p3 { width: 190px; }
.piece.is-current { border-color: var(--ink); }
.piece__pic { height: 74px; width: 100%; }
.piece__pic img { max-height: 100%; max-width: 100%; width: auto; height: auto; object-fit: contain; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .12)); }
.piece--insert .piece__pic { height: 64px; }
.piece__name { font-size: .72rem; }
.piece__name b { font-weight: 500; letter-spacing: .05em; color: var(--ink); }

.photo-board { position: relative; margin: 0 auto; }
.photo-board__frame {
    position: absolute; left: 0; top: 0; transform-origin: 0 0;
    max-width: none;   /* повёрнутая рамка шире своей коробки — не ужимать */
    filter: drop-shadow(0 10px 16px rgba(0, 0, 0, .14));
    pointer-events: none;
}
.photo-slot {
    position: absolute; border-radius: 50%;
    display: grid; place-items: center;
    cursor: pointer; touch-action: none;
    transition: box-shadow .15s;
}
.photo-slot img { display: block; flex: none; max-width: none; pointer-events: none; filter: drop-shadow(0 3px 5px rgba(0, 0, 0, .18)); }
.photo-slot.is-full { cursor: grab; }
.photo-slot:not(.is-full) { background: rgba(255, 255, 255, .55); box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, .25); }
.photo-slot__plus { font-size: 2rem; font-weight: 200; color: rgba(0, 0, 0, .4); line-height: 1; }
.photo-slot.is-selected { box-shadow: 0 0 0 3px var(--accent); }
.drag-insert .photo-slot, .drag-move .photo-slot { box-shadow: 0 0 0 2px rgba(135, 163, 134, .6); }
.photo-slot.is-over { box-shadow: 0 0 0 4px var(--accent) !important; }

.builder__made { margin: .8rem 0 0; font-size: .75rem; text-align: center; }

.builder__ghost img { width: 100%; height: 100%; object-fit: contain; }
.builder__ghost.is-frame { width: 170px; height: 110px; margin: -55px 0 0 -85px; }

.line__pic { flex: none; width: 26px; height: 26px; margin-top: -.1rem; object-fit: contain; }
.line--frame .line__dot, .line--empty .line__dot { margin-inline: 5px; }

@media (max-width: 560px) {
    .builder__pieces { flex-wrap: wrap; max-height: 260px; }
    .piece { flex: 0 0 calc(33.33% - .3rem); width: auto; }
    .piece--frame.piece--p2, .piece--frame.piece--p3 { flex-basis: calc(50% - .2rem); }
    .builder__tab { padding: .45rem .55rem; font-size: .74rem; }
}

/* ==================================================================
   Шире и выше: заголовок поднят, конструктор занимает больше места
   ================================================================== */

.page-configurator .page-head { padding: clamp(1.4rem, 3vw, 2.6rem) 0 1.4rem; }
.page-configurator .page-head__text { margin-top: .7rem; }
.builder.container { width: min(1440px, 100% - var(--gutter) * 2); }
.builder__palette { grid-template-columns: 1.35fr 1fr; padding: 2rem 2.4rem; }
.builder__pieces { max-height: 380px; }
.builder__hint { margin: .9rem 0 1.1rem; }
.builder__work { grid-template-columns: minmax(0, 1fr) 340px; }
.builder__stage { min-height: 500px; }

@media (max-width: 960px) {
    .builder__palette { grid-template-columns: 1fr; padding: 1.4rem; }
    .builder__work { grid-template-columns: 1fr; }
    .builder__stage { min-height: 300px; }
}
@media (max-width: 560px) {
    .builder__palette { padding: 1.1rem; }
}

/* ---- смена цвета на собранной доске: подписанные кнопки и палитра ---- */
.edit-btn {
    position: absolute; z-index: 5;
    transform: translate(-50%, -50%);
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .38rem .8rem .38rem .6rem;
    border: 0; border-radius: 999px;
    background: #fff; color: var(--ink);
    font: inherit; font-size: .74rem; line-height: 1.2; white-space: nowrap;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .2);
    cursor: pointer; transition: background .15s, color .15s, box-shadow .15s;
}
.edit-btn svg { flex: none; }
.edit-btn:hover { box-shadow: 0 0 0 2px var(--accent), 0 4px 12px rgba(0, 0, 0, .2); }
.edit-btn.is-open { background: var(--accent); color: #fff; }

/* деталь, цвет которой меняет кнопка под курсором или открытая палитра */
.photo-board__frame.is-hover, .photo-board__frame.is-target {
    filter: drop-shadow(0 0 2px var(--accent)) drop-shadow(0 0 2px var(--accent)) drop-shadow(0 10px 16px rgba(0, 0, 0, .14));
}
.photo-slot.is-hover, .photo-slot.is-target { box-shadow: 0 0 0 3px var(--accent); }

.edit-pop {
    position: absolute; z-index: 6; width: 270px;
    padding: .85rem .9rem .9rem;
    background: #fff; border-radius: 14px;
    box-shadow: 0 12px 34px rgba(0, 0, 0, .22);
    touch-action: none;
}
.edit-pop__title { display: flex; align-items: center; gap: .35rem; margin: 0 0 .7rem; font-size: .8rem; font-weight: 600; color: var(--ink); }
.picker { display: flex; gap: .6rem; }
.picker__field {
    position: relative; flex: 1; height: 150px; border-radius: 6px; cursor: crosshair;
    background:
        linear-gradient(to top, #fff, rgba(255, 255, 255, 0)),
        linear-gradient(to right, #f00, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00);
}
.picker__field::after {   /* яркость из полосы ниже */
    content: ""; position: absolute; inset: 0; border-radius: inherit;
    background: #000; opacity: var(--dim, 0); pointer-events: none;
}
.picker__dot {
    position: absolute; z-index: 1; width: 16px; height: 16px; margin: -8px 0 0 -8px;
    border: 2px solid #fff; border-radius: 50%;
    box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .55); pointer-events: none;
}
.picker__tip {
    position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
    padding: .2rem .5rem; border-radius: 6px;
    background: #fff; color: var(--ink); font-size: .7rem; font-style: normal; white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}
.picker__swatch { flex: none; width: 34px; border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.picker__bar {
    position: relative; height: 12px; margin: .9rem 4px 0; border-radius: 999px; cursor: pointer;
    background: linear-gradient(to right, #000, var(--top, #fff));
}
.picker__knob {
    position: absolute; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px;
    border: 2px solid #fff; border-radius: 50%; background: var(--ink);
    box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .4); pointer-events: none;
}
.picker__foot { display: flex; gap: .5rem; margin-top: .9rem; }
.picker__hex {
    width: 6.4rem; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 6px;
    font: inherit; font-size: .78rem; letter-spacing: .04em; text-transform: uppercase;
}
.edit-pop__reset {
    flex: 1; padding: .35rem .5rem;
    border: 1px solid rgba(0, 0, 0, .15); border-radius: 999px;
    background: none; font: inherit; font-size: .74rem; cursor: pointer;
}
.edit-pop__reset:disabled { opacity: .4; cursor: default; }
