/* Bry3D demo configurators (veranda 3D, fence 2D).
   The preview on ground takes the screen; the options are a fixed-width
   sidebar on surface (340-400px, never a share of the viewport), with the
   estimate and the primary "Generate quote" pinned to its bottom. */

html, body { height: 100%; }
body.page-cfg { display: flex; flex-direction: column; min-height: 100dvh; overflow: hidden; }

/* Compact header */
.cfg-header {
    flex: none;
    height: 56px;
    display: flex;
    align-items: center;
    gap: var(--space-6);
    padding: 0 var(--space-6) 0 var(--space-4);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 20;
}
.cfg-header .brand img { height: 30px; }
.demo-switch { margin-left: var(--space-2); }
.demo-switch a { display: inline-flex; align-items: center; gap: 6px; }
.demo-switch .fmt {
    font-size: 10.5px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: var(--radius-sm);
    background: var(--hairline);
    color: var(--ink-2);
}
.demo-switch [aria-current="page"] .fmt { background: var(--surface); color: var(--blue-ink); }
.cfg-header-r { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); }

/* App */
.cfg-app {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(340px, 26vw, 400px);
}
.cfg-stage {
    position: relative;
    min-width: 0;
    min-height: 0;
    background: var(--ground);
    overflow: hidden;
}
.stage-caption {
    position: absolute;
    left: var(--space-4);
    bottom: var(--space-4);
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 6px 10px 6px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 13px;
    color: var(--ink-2);
    pointer-events: none;
}
.stage-caption b { font-weight: 600; color: var(--ink); }

[data-bry3d-viewer] { z-index: 1; }
.viewer-loading {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: var(--space-4);
    background: var(--ground);
    text-align: center;
    pointer-events: none;
    transition: opacity 0.5s var(--ease-out), visibility 0s linear 0.5s;
}
.viewer-loading.hidden { opacity: 0; visibility: hidden; }
.viewer-loading img { width: 72px; height: 72px; }
.viewer-loading p { font-size: 14px; color: var(--muted); max-width: 36ch; }
.load-line {
    width: 160px;
    height: 2px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}
.load-line::after {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 40%;
    background: var(--blue);
    animation: load-slide 1.4s var(--ease-out) infinite;
}
@keyframes load-slide {
    from { transform: translateX(-100%); }
    to { transform: translateX(260%); }
}
.viewer-loading.is-failed .load-line { display: none; }

/* Options side */
.cfg-side {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-left: 1px solid var(--border);
}
.cfg-side-head {
    flex: none;
    padding: var(--space-4) 20px var(--space-3);
    border-bottom: 1px solid var(--hairline);
}
.cfg-side-head h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.cfg-side-head p { margin-top: 2px; font-size: 13px; color: var(--muted); }
.cfg-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--space-4) 20px 20px;
    overscroll-behavior: contain;
    scrollbar-color: var(--scrollbar) var(--surface);
}
.cfg-scroll .opt-group + .opt-group { margin-top: 20px; }
.cfg-scroll::-webkit-scrollbar-track { background: var(--surface); }
.cfg-scroll::-webkit-scrollbar-thumb { border-color: var(--surface); }

.opt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
/* Name and any price on the first line (the price never drops below the name),
   the description across the full width underneath. */
.opt-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-content: start;
    align-items: baseline;
    gap: 2px 8px;
    text-align: left;
    padding: 8px 10px;
}
.opt-card .t { grid-column: 1; grid-row: 1; font-size: 14px; }
.opt-card small { grid-column: 2; grid-row: 1; font-size: 12.5px; }
.opt-card .s { grid-column: 1 / -1; grid-row: 2; font-size: 12.5px; font-weight: 400; color: var(--muted); }
.opt-card[aria-pressed="true"] .s { color: var(--ink-2); }

/* Dimension sliders */
.dim { display: grid; grid-template-columns: 48px minmax(0, 1fr) 76px; gap: 10px; align-items: center; }
.dim + .dim { margin-top: var(--space-3); }
.dim label { font-size: 14px; color: var(--ink-2); }
.dim output {
    justify-self: end;
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    min-width: 76px;
    text-align: right;
}
.dim output small { font-weight: 400; color: var(--muted); margin-left: 3px; }
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 24px;
    background: transparent;
    --fill: 50%;
}
input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--blue) var(--fill), var(--border) var(--fill));
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--border); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--blue); }
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    margin-top: -7px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--blue);
    box-shadow: 0 1px 3px rgba(21, 23, 31, 0.2);
}
input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--blue);
}
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--blue); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--blue); }

.demo-note {
    margin-top: var(--space-6);
    padding-top: var(--space-4);
    border-top: 1px solid var(--hairline);
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--muted);
}
.demo-note a { color: var(--blue-ink); text-decoration: underline; text-underline-offset: 2px; }

/* Pinned estimate */
.cfg-total {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) 20px;
    border-top: 1px solid var(--border);
    background: var(--ground);
}
.cfg-total .label { display: block; font-size: 12.5px; color: var(--muted); }
.cfg-total .amount {
    display: inline-block;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    border-radius: var(--radius-sm);
}
.cfg-total .amount.is-empty { font-size: 15px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.cfg-total .vat { font-size: 12.5px; color: var(--muted); margin-left: 4px; font-weight: 400; letter-spacing: 0; }
.cfg-total .btn { flex: none; }

/* After "Generate quote": the side panel shows where it would land */
.cfg-done { display: none; flex: 1; min-height: 0; overflow-y: auto; padding: 20px; }
.cfg-side[data-view="done"] .cfg-side-head,
.cfg-side[data-view="done"] .cfg-scroll,
.cfg-side[data-view="done"] .cfg-total { display: none; }
.cfg-side[data-view="done"] .cfg-done { display: block; }
.cfg-done h2 { font-size: 20px; letter-spacing: -0.02em; outline: none; }
.cfg-done > p { margin-top: var(--space-3); color: var(--ink-2); font-size: 15px; }
.mini-record {
    margin-top: var(--space-6);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
}
.mini-record-h {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--side);
    color: var(--side-ink);
}
.mini-record-h b { font-size: 15px; font-weight: 600; }
.mini-record-h span {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background: var(--side-wash);
}
.mini-record dl { padding: 4px 16px 8px; }
.mini-record dl > div {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: var(--space-3);
    padding: 8px 0;
    border-top: 1px solid var(--hairline);
    font-size: 14px;
}
.mini-record dl > div:first-child { border-top: 0; }
.mini-record dt { color: var(--muted); font-size: 13px; }
.mini-record dd { font-weight: 500; }
.done-actions { display: grid; gap: var(--space-2); margin-top: var(--space-6); }
.done-actions .btn { width: 100%; }

@media (max-width: 900px) {
    body.page-cfg { overflow: auto; height: auto; }
    .cfg-header { padding: 0 var(--space-3); gap: var(--space-3); }
    .cfg-header .brand img { height: 26px; }
    .cfg-header-r .lang-switch, .cfg-header-r .btn { display: none; }
    .demo-switch { margin-left: auto; }
    .demo-switch a { padding: 6px 9px; font-size: 13px; }
    .cfg-app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; }
    .cfg-stage { height: 46vh; min-height: 300px; }
    .cfg-side { border-left: 0; border-top: 1px solid var(--border); }
    .cfg-scroll { overflow: visible; padding: var(--space-4); }
    .cfg-side-head { padding: var(--space-4) var(--space-4) var(--space-3); }
    .cfg-total { position: sticky; bottom: 0; z-index: 10; padding: var(--space-3) var(--space-4); }
    .cfg-done { padding: var(--space-4); }
}
@media (max-width: 420px) {
    .demo-switch .fmt { display: none; }
    .opt-grid { grid-template-columns: minmax(0, 1fr); }
}
