/* Tray builder (Shop page). Uses the site's theme variables. */

.builder {
    max-width: 1400px;
    margin: 0 auto;
}

.builder-modes {
    display: inline-flex;
    gap: 0.25rem;
    padding: 0.25rem;
    margin-bottom: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
}

.builder-modes button {
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--gray-700);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.builder-modes button.active {
    background: var(--accent);
    color: #fff;
}

/* Toolbar sits full-width above; below it, the 3D view and the piece editor
   sit side by side (view on the left, editor on the right) on anything wide
   enough — narrower screens stack them instead. The piece list + checkout
   are their own full-width block underneath both. */
.builder-stage {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    max-width: 1200px;
    margin: 0 auto;
}

.builder-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
    gap: 0.85rem;
    align-items: start;
}

.builder-viewcol {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    min-width: 0;
}

/* The editor pane beside the view — its content is the same .bp-card /
   .bp-edit markup used everywhere else in the panel. */
.builder-editor {
    min-width: 0;
}

/* No tray picked yet — nothing to edit, so the view takes the full row. */
.builder-row.no-editor {
    grid-template-columns: minmax(0, 1fr);
}

@media (max-width: 860px) {
    .builder-row {
        grid-template-columns: minmax(0, 1fr);
    }
}

.builder-view {
    position: relative;
    height: min(58vh, 620px);
    min-height: 320px;
    border-radius: 14px;
    overflow: hidden;
    background: linear-gradient(180deg, #f4f4f6 0%, #cfd0d6 100%);
    border: 1px solid var(--gray-200);
}

.builder-canvas-wrap {
    position: absolute;
    inset: 0;
    outline: none;
    touch-action: none;
}

.builder-canvas-wrap canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.builder-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    color: #55565c;
    font-weight: 600;
    pointer-events: none;
}

/* The hint text sits in its own thin bar under the 3D view. */
.builder-viewbar {
    margin-top: -0.25rem;
}

.builder-hint {
    font-size: 0.78rem;
    color: var(--gray-700);
}

/* The view-angle buttons float directly on the 3D view itself — that
   background is light, so a dark toolbar row below it made them hard to
   spot. Sized/positioned to stay clear of the canvas edges on phones too. */
.builder-view-tools {
    position: absolute;
    right: 0.6rem;
    bottom: 0.6rem;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.35rem;
    max-width: calc(100% - 1.2rem);
}

.builder-view-tools button {
    padding: 0.35rem 0.7rem;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.9);
    color: #2a2a2e;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.builder-view-tools button:hover {
    background: #fff;
    border-color: var(--accent-light);
}

.builder-view-tools button.active {
    border-color: var(--accent);
    background: #fff;
    color: var(--accent);
}

.builder-panel {
    display: grid;
    gap: 1rem;
}

.bp-scroll {
    display: grid;
    gap: 0.85rem;
}

.bp-footer {
    padding: 1.1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
}

.bp-footer .bp-toast:empty {
    display: none;
}

.bp-card {
    padding: 1.1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
}

.bp-card h3 {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.85rem;
    font-size: 1rem;
    font-weight: 700;
}

.bp-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
}

.bp-label {
    margin: 0.85rem 0 0.4rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--gray-700);
}

.bp-label:first-of-type {
    margin-top: 0;
}

.bp-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.bp-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 4.6rem;
    padding: 0.5rem 0.8rem;
    border: 2px solid var(--gray-200);
    border-radius: 9px;
    background: var(--surface-2);
    color: var(--primary);
    font: inherit;
    font-weight: 600;
    line-height: 1.25;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.bp-chip small {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
}

.bp-chip:hover:not(:disabled) {
    border-color: var(--accent-light);
}

.bp-chip.active {
    border-color: var(--accent);
    background: rgba(255, 107, 53, 0.12);
}

.bp-chip:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.bp-note {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--gray-700);
}

.bp-note.warn {
    color: #ffb199;
}

.bp-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
}

.bp-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-700);
}

.bp-field input,
.bp-field select {
    padding: 0.55rem 0.7rem;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--primary);
    font: inherit;
    font-size: 0.95rem;
    font-weight: 500;
}

.bp-field input:focus,
.bp-field select:focus {
    outline: none;
    border-color: var(--accent);
}

.bp-field input:disabled {
    opacity: 0.45;
}

.bp-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.9rem;
}

.bp-btn {
    padding: 0.55rem 1rem;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--primary);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.bp-btn:hover {
    border-color: var(--accent-light);
}

.bp-btn.danger:hover {
    border-color: #e5484d;
    color: #ff9a9d;
}

.bp-btn.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.bp-btn.primary:hover {
    background: var(--accent-light);
}

.bp-btn.big {
    width: 100%;
    padding: 0.9rem 1rem;
    font-size: 1.05rem;
}

.bp-list {
    display: grid;
    gap: 0.35rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.bp-list button {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    padding: 0.5rem 0.7rem;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--primary);
    font: inherit;
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
}

.bp-list button:hover {
    border-color: var(--gray-200);
}

.bp-list button.active {
    border-color: var(--accent);
}

.bp-list .price {
    font-family: 'JetBrains Mono', monospace;
    white-space: nowrap;
    color: var(--gray-700);
}

.bp-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin: 0.9rem 0;
    padding-top: 0.75rem;
    border-top: 1px solid var(--gray-200);
    font-size: 1.15rem;
    font-weight: 700;
}

.bp-total span:last-child {
    font-family: 'JetBrains Mono', monospace;
}

.bp-buy {
    display: grid;
    grid-template-columns: 5.5rem 1fr;
    gap: 0.6rem;
    align-items: end;
}

.bp-toast {
    margin-top: 0.6rem;
    font-size: 0.85rem;
    color: #7ee2a8;
    min-height: 1.2em;
}

.bp-lead {
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--gray-700);
}

/* Cart drawer: build layout under the item name */
.cart-item-detail {
    margin-top: 0.25rem;
    font-size: 0.78rem;
    color: var(--gray-700);
}

.cart-item-detail summary {
    cursor: pointer;
    color: var(--accent);
}

.cart-item-detail ul {
    margin: 0.35rem 0 0;
    padding-left: 1rem;
    line-height: 1.5;
}

/* The tray sizes get their own full-width row and simply wrap — a sideways
   scroll here read as things being cut off, so every size is just visible. */
.bt-group.bt-scroll {
    flex: 0 0 100%;
}

@media (max-width: 480px) {
    .bp-buy {
        grid-template-columns: 4.5rem 1fr;
    }

    .bp-btn.big {
        padding: 0.7rem 1rem;
    }
}

/* Round two-line tag editor */
.bp-tagrow {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.bp-tagrow .tag-circle-input {
    flex: none;
}

.bp-tagrow .tag-circle-input.is-off {
    opacity: 0.45;
}

/* Blocks are blue, fillers are green — the tray/height controls keep the
   site's orange. Consistent everywhere a piece's kind shows up, so the
   builder reads at a glance instead of being a wall of grey. */
:root {
    --block-color: #4dabf7;
    --block-color-dim: rgba(77, 171, 247, 0.14);
    --filler-color: #51cf66;
    --filler-color-dim: rgba(81, 207, 102, 0.14);
}

.bt-kind-b .bt-label { color: var(--block-color); }
.bt-kind-f .bt-label { color: var(--filler-color); }

.bt-kind-b .bt-chip:not(:disabled) { border-color: rgba(77, 171, 247, 0.55); }
.bt-kind-f .bt-chip:not(:disabled) { border-color: rgba(81, 207, 102, 0.55); }

.bt-kind-b .bt-chip:hover:not(:disabled) { border-color: var(--block-color); background: var(--block-color-dim); }
.bt-kind-f .bt-chip:hover:not(:disabled) { border-color: var(--filler-color); background: var(--filler-color-dim); }

/* Panel v2: editor on top, compact controls, piece list */
.bp-card h3 small {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-700);
}

.bp-label span,
.bp-sub span {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
    opacity: 0.8;
}

.bp-note .warn,
.bp-note.warn {
    color: #ffb199;
}

.bp-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.9rem;
    padding: 0.05rem 0.4rem;
    border-radius: 6px;
    background: var(--accent);
    color: #17171a;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    font-weight: 700;
}

.bp-cell-b { background: var(--block-color); }
.bp-cell-f { background: var(--filler-color); }

.bp-edit {
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.12);
}

.bp-edit-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.7rem;
}

.bp-edit-head h3 {
    margin: 0;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.bp-edit-head h3 small {
    margin-left: 0;
}

.bp-btn.small {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
}

.bp-sub {
    margin: 0.9rem 0 0.4rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--gray-700);
}

.bp-edit-head + .bp-sub {
    margin-top: 0;
}

.bp-seg {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    border: 2px solid var(--gray-200);
    border-radius: 9px;
    overflow: hidden;
}

.bp-seg button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 0.5rem;
    border: none;
    background: var(--surface-2);
    color: var(--primary);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.bp-seg button + button {
    border-left: 2px solid var(--gray-200);
}

.bp-seg button.on {
    background: var(--accent);
    color: #fff;
}

.bp-ico {
    display: inline-block;
    width: 0.9rem;
    height: 0.9rem;
    border: 2px solid currentColor;
}

.bp-ico.round {
    border-radius: 50%;
}

.bp-ico.square {
    border-radius: 2px;
}

.bp-hole-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
    gap: 0.6rem;
    margin-top: 0.7rem;
}

.bp-hole-row .bp-field input,
.bp-tagside select {
    width: 100%;
    min-width: 0;
}

.bp-tagside {
    flex: 1;
    min-width: 0;
}

.bp-tagside select {
    padding: 0.55rem 0.7rem;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--primary);
    font: inherit;
    font-size: 0.95rem;
}

.bp-tagside select:focus {
    outline: none;
    border-color: var(--accent);
}

.bp-tagside .bp-note {
    margin-top: 0.4rem;
    font-size: 0.78rem;
}

.bp-edit .bp-note {
    margin-top: 0.5rem;
    font-size: 0.8rem;
}

.bp-tray summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.9rem;
    cursor: pointer;
    list-style: none;
}

.bp-tray summary::-webkit-details-marker {
    display: none;
}

.bp-tray[open] summary {
    margin-bottom: 0.9rem;
}

.bp-link {
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 600;
}

.bp-tray[open] .bp-link {
    display: none;
}

/* piece list */
.bp-list li {
    display: flex;
    gap: 0.35rem;
}

.bp-list .bp-piece {
    flex: 1;
    min-width: 0;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "cell sum price" "cell flag flag";
    align-items: center;
    column-gap: 0.6rem;
    row-gap: 0.1rem;
    padding: 0.55rem 0.7rem;
}

.bp-list .bp-piece .bp-cell { grid-area: cell; }
.bp-list .bp-piece .bp-sum { grid-area: sum; font-size: 0.82rem; line-height: 1.35; }
.bp-list .bp-piece .price { grid-area: price; font-size: 0.82rem; }

.bp-editflag {
    grid-area: flag;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent);
}

.bp-list li.active .bp-piece {
    border-color: var(--accent);
    background: rgba(255, 107, 53, 0.1);
}

.bp-list li.bp-kind-b .bp-piece { border-left: 3px solid var(--block-color); }
.bp-list li.bp-kind-f .bp-piece { border-left: 3px solid var(--filler-color); }

.bp-list .bp-x {
    display: block;
    flex: none;
    width: 2rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--gray-700);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}

.bp-list .bp-x:hover {
    border-color: #e5484d;
    color: #ff9a9d;
}

/* Bigger, bolder tag preview in the builder panel */
.bp-tagrow .tag-circle-input {
    width: 124px;
    height: 124px;
    padding-top: 0.9rem;
}

.bp-tagrow .tag-circle-line {
    font-family: 'DM Sans', 'Arial Black', Arial, sans-serif;
    font-weight: 800;
    font-size: 1.5rem;
    color: #0d0d10;
    letter-spacing: 0.02em;
}

.bp-tagrow .tag-circle-input.is-off .tag-circle-line {
    color: var(--gray-700);
}

/* Bigger, bolder tag preview in the builder panel */
.bp-tagrow .tag-circle-input {
    width: 124px;
    height: 124px;
    padding-top: 0.9rem;
    gap: 0.35rem;
}

.bp-tagrow .tag-circle-line {
    width: 82%;
    font-family: 'DM Sans', 'Arial Black', Arial, sans-serif;
    font-weight: 800;
    font-size: 1.25rem;
    color: #0d0d10;
}

.bp-tagrow .tag-circle-input.is-off .tag-circle-line {
    color: var(--gray-700);
}

/* Floating Duplicate / Delete bar over the selected block */
.builder-pop {
    position: absolute;
    z-index: 4;
    display: flex;
    gap: 2px;
    padding: 3px;
    border-radius: 10px;
    background: rgba(20, 20, 22, 0.94);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    transform: translate(-50%, -100%);
    white-space: nowrap;
}

.builder-pop button {
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: #fff;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

.builder-pop button:hover:not(:disabled) {
    background: var(--accent);
}

.builder-pop button.danger:hover {
    background: #e5484d;
}

.builder-pop button:disabled {
    color: #8a8a90;
    cursor: not-allowed;
}

/* Toolbar above the 3D view */
.builder-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.4rem;
    padding: 0.55rem 0.7rem;
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
}

.bt-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
}

.bt-group {
    min-width: 0;
}

.bt-label {
    margin-bottom: 0.2rem;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--gray-700);
}

.bt-label span {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
    opacity: 0.8;
}

.bt-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.bt-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    padding: 0.3rem 0.5rem;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--primary);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.bt-chip small {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent);
}

.bt-chip:hover:not(:disabled) {
    border-color: var(--accent-light);
}

.bt-chip.active {
    border-color: var(--accent);
    background: rgba(255, 107, 53, 0.14);
}

.bt-chip:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.bt-msg {
    margin: 0;
    font-size: 0.82rem;
    color: #ffb199;
}

.bp-total small {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--gray-700);
}
