/* The headboard builder: the stage (2D drawing and 3D view) and the panel beside it.
   Colours come from tokens.css only. Square controls, hairlines, no shadows. */

.builder [hidden] { display: none !important; }
.builder { padding: var(--space-7) 0 var(--space-9); }
.builder__grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(340px, 1fr); gap: var(--space-7); align-items: start; }
@media (min-width: 744px) and (max-width: 1100px) { .builder__grid { grid-template-columns: minmax(0, 1.3fr) minmax(280px, 1fr); gap: var(--space-5); } }
@media (max-width: 743px) { .builder { padding: var(--space-5) 0 var(--space-7); } .builder__grid { grid-template-columns: 1fr; gap: var(--space-5); } }

/* ---------- the stage ---------- */
.builder__stage { position: sticky; top: calc(var(--header-height) + var(--space-3)); display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }
@media (max-width: 743px) { .builder__stage { position: static; } }
.stage { position: relative; height: min(66vh, 680px); min-height: 360px; background: var(--surface-raised); border: var(--hairline) solid var(--line); touch-action: none; user-select: none; -webkit-user-select: none; overflow: hidden; }
@media (max-width: 743px) { .stage { height: 62vh; min-height: 340px; } }
.stage > svg { width: 100%; height: 100%; display: block; }
.view3d { position: absolute; inset: 0; background: var(--surface-band); }
/* in 3D without a frame: the view sits straight on the page (builder.js: SHOW_ROOM, FADE_EDGES) */
.stage--3d { background: transparent; border-color: transparent; }
.stage--3d .view3d { background: transparent; }
/* the fade: the view dissolves into the page on all four sides */
.stage--fade .view3d {
  background: transparent;
  -webkit-mask-image: linear-gradient(to right, transparent, rgba(0,0,0,.12) 2.5%, rgba(0,0,0,.45) 6.5%, rgba(0,0,0,.82) 11%, #000 16%, #000 84%, rgba(0,0,0,.82) 89%, rgba(0,0,0,.45) 93.5%, rgba(0,0,0,.12) 97.5%, transparent), linear-gradient(to bottom, transparent, rgba(0,0,0,.12) 2.5%, rgba(0,0,0,.45) 6.5%, rgba(0,0,0,.82) 11%, #000 16%, #000 84%, rgba(0,0,0,.82) 89%, rgba(0,0,0,.45) 93.5%, rgba(0,0,0,.12) 97.5%, transparent);
  mask-image: linear-gradient(to right, transparent, rgba(0,0,0,.12) 2.5%, rgba(0,0,0,.45) 6.5%, rgba(0,0,0,.82) 11%, #000 16%, #000 84%, rgba(0,0,0,.82) 89%, rgba(0,0,0,.45) 93.5%, rgba(0,0,0,.12) 97.5%, transparent), linear-gradient(to bottom, transparent, rgba(0,0,0,.12) 2.5%, rgba(0,0,0,.45) 6.5%, rgba(0,0,0,.82) 11%, #000 16%, #000 84%, rgba(0,0,0,.82) 89%, rgba(0,0,0,.45) 93.5%, rgba(0,0,0,.12) 97.5%, transparent);
  -webkit-mask-composite: source-in; mask-composite: intersect;
}
/* handles over the 3D view of a footstool, pouffe or ottoman, and the ruler they show (js: view3d-pieces) */
.h3d { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.h3d__ruler { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.h3d__ruler path { fill: none; stroke: var(--brand); stroke-width: 1; stroke-linecap: square; vector-effect: non-scaling-stroke; }
.h3d__tag { position: absolute; left: 0; top: 0; padding: 4px 10px; background: var(--brand); color: var(--on-brand); font-family: var(--font-utility); font-size: 13px; line-height: 18px; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none; }
.h3d__handle { position: absolute; left: -14px; top: -14px; display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; margin: 0; padding: 0; border: 1.5px solid var(--brand); border-radius: 50%; background: var(--surface-raised); color: var(--brand); cursor: grab; pointer-events: auto; touch-action: none; transition: background-color .15s ease, color .15s ease, scale .15s ease; }
.h3d__handle::before { content: ""; position: absolute; inset: -10px; border-radius: 50%; } /* a bigger area to catch a finger */
.h3d__handle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.h3d__handle:hover, .h3d__handle.is-active { background: var(--brand); color: var(--on-brand); scale: 1.12; }
.h3d__handle.is-active { cursor: grabbing; }
.h3d__handle:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .h3d__handle { transition: none; } }
.sizes--boxes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-3) var(--space-4); }
.sizes--boxes .ctl { grid-template-columns: 1fr; row-gap: var(--space-1); }
.sizes--boxes .ctl + .ctl { margin-top: 0; }
.sizes--boxes .ctl > .num { grid-column: 1; grid-row: 2; }
.view3d canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; outline: none; }
.view3d canvas.grabbing { cursor: grabbing; }
.view3d canvas:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.stage__toggle { position: absolute; right: var(--space-3); bottom: var(--space-3); z-index: 1; min-width: 44px; min-height: 36px; padding: 0 var(--space-3); border: var(--hairline) solid var(--line-control); border-radius: var(--radius-none); background: var(--surface); color: var(--ink-strong); font-family: var(--font-utility); font-size: 13px; letter-spacing: 0.04em; cursor: pointer; box-shadow: var(--shadow-float); }
.stage__toggle:hover { border-color: var(--line-strong); }
.stage__toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.stage__toggle[hidden] { display: none; }
.readout { position: absolute; left: 50%; top: var(--space-3); transform: translateX(-50%); padding: 6px 14px; background: var(--brand); color: var(--on-brand); font-family: var(--font-utility); font-size: 15px; font-variant-numeric: tabular-nums; opacity: 0; pointer-events: none; transition: opacity .15s ease; white-space: nowrap; }
.readout small { margin-left: 4px; opacity: .8; }
.readout.on { opacity: 1; }
.stage__msg { position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center; margin: 0; padding: var(--space-5); text-align: center; font-family: var(--font-utility); color: var(--ink-muted); background: color-mix(in srgb, var(--surface-raised) 86%, transparent); }
.stage__msg[hidden] { display: none; }
.caption { margin: 0; font-family: var(--font-utility); font-size: 14px; line-height: 20px; color: var(--ink-strong); }
.hint { margin: 0; font-family: var(--font-utility); font-size: 13px; line-height: 18px; color: var(--ink-muted); }

/* ---------- segmented buttons ---------- */
.seg { display: inline-flex; }
.seg button { min-height: 40px; min-width: 44px; padding: 0 var(--space-4); margin: 0 0 0 -1px; border: var(--hairline) solid var(--line-control); border-radius: var(--radius-none); background: var(--surface); color: var(--ink-strong); font-family: var(--font-utility); font-size: 13px; letter-spacing: 0.04em; cursor: pointer; }
.seg button:first-child { margin-left: 0; }
.seg button:hover { border-color: var(--line-strong); position: relative; }
.seg button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); position: relative; }
.seg button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; position: relative; z-index: 1; }
.seg--wide { display: flex; }
.seg--wide button { flex: 1; }

/* ---------- the panel ---------- */
.builder__panel { display: flex; flex-direction: column; gap: var(--space-6); min-width: 0; }
/* the steps: a numbered bar on top, one step shown at a time, Back and Next under it */
.steps ol { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; padding: 0; list-style: none; border-bottom: var(--hairline) solid var(--line); }
.steps--3 ol { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.steps li { display: flex; }
.steps button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; min-height: 56px; margin: 0 0 -1px; padding: var(--space-2) var(--space-2) var(--space-3) 0; border: 0; border-bottom: 2px solid transparent; border-radius: var(--radius-none); background: none; color: var(--ink-muted); font-family: var(--font-utility); font-size: 13px; line-height: 18px; letter-spacing: 0.04em; text-align: left; cursor: pointer; }
.steps__n { font-size: 11px; letter-spacing: 0.16em; }
.steps button:hover { color: var(--ink-strong); }
.steps button[aria-current="step"] { color: var(--ink-strong); border-bottom-color: var(--brand); font-weight: 500; }
.steps button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.step { display: flex; flex-direction: column; gap: var(--space-6); min-width: 0; }
.step > .card:first-child { padding-top: 0; border-top: 0; }
.step__nav { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding-top: var(--space-5); border-top: var(--hairline) solid var(--line); }
.more { margin-top: var(--space-4); }
.more > summary { padding: var(--space-2) 0; font-family: var(--font-utility); font-size: 14px; line-height: 20px; color: var(--ink-strong); text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; cursor: pointer; }
.more > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.more[open] > summary { margin-bottom: var(--space-3); }
.card { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; padding-top: var(--space-5); border-top: var(--hairline) solid var(--line); }
.card__h { margin: 0; font-family: var(--font-utility); font-size: 13px; line-height: 18px; font-weight: 500; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-strong); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.rooms legend { padding: 0; margin-bottom: var(--space-2); font-family: var(--font-utility); font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: 0.02em; color: var(--ink-strong); }
.rooms > div { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-5); }

.shapes { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: var(--space-2); }
.shape { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px 8px; border: var(--hairline) solid var(--line-control); background: var(--surface-raised); cursor: pointer; }
.shape input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.shape svg { width: 100%; height: 46px; fill: var(--surface-band); stroke: var(--ink-strong); stroke-width: 12; stroke-linejoin: round; }
.shape span { font-family: var(--font-utility); font-size: 12px; line-height: 16px; letter-spacing: 0.04em; color: var(--ink-muted); }
.shape:hover { border-color: var(--line-strong); }
.shape:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); background: var(--brand-soft); }
.shape:has(input:checked) span { color: var(--ink-strong); }
.shape:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }

/* a control: its name, a slider, and the number */
.ctl { display: grid; grid-template-columns: minmax(0, 1fr) 104px; column-gap: var(--space-4); row-gap: 0; align-items: center; }
.ctl + .ctl { margin-top: var(--space-2); }
.ctl > label { grid-column: 1 / -1; font-family: var(--font-utility); font-size: 14px; line-height: 20px; color: var(--ink-strong); }
.ctl--arch > label { color: var(--ink-muted); }
.ctl > input[type="range"] { grid-column: 1; grid-row: 2; width: 100%; margin: 0; }
.ctl > .num { grid-column: 2; grid-row: 2; }
.num { display: flex; align-items: center; border: var(--hairline) solid var(--line-control); background: var(--surface-raised); }
.num:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }
.num input { width: 100%; min-width: 0; height: 36px; padding: 0 0 0 var(--space-2); border: 0; background: transparent; color: var(--ink); font-family: var(--font-utility); font-size: 15px; text-align: right; font-variant-numeric: tabular-nums; outline: none; -moz-appearance: textfield; appearance: textfield; }
.num input::-webkit-outer-spin-button, .num input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num .u { padding: 0 var(--space-2) 0 var(--space-1); font-family: var(--font-utility); font-size: 12px; color: var(--ink-muted); min-width: 22px; }
.ctl select { grid-column: 1 / -1; }
.ctl--check { display: block; margin-top: var(--space-3); }
.presets { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: var(--space-2) 0 var(--space-3); font-family: var(--font-utility); font-size: 13px; color: var(--ink-muted); }
.presets button { min-height: 36px; min-width: 44px; padding: 0 var(--space-3); border: var(--hairline) solid var(--line-control); border-radius: var(--radius-none); background: var(--surface); color: var(--ink-strong); font-family: var(--font-utility); font-size: 13px; cursor: pointer; }
.presets button:hover { border-color: var(--line-strong); }
.presets button[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); }
.presets .num { width: 92px; }
.presets .num input { height: 32px; }

/* sliders: a hairline track and a square handle */
input[type="range"] { -webkit-appearance: none; appearance: none; height: 32px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 1px; background: var(--line-control); }
input[type="range"]::-moz-range-track { height: 1px; background: var(--line-control); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -9px; border: 0; border-radius: var(--radius-none); background: var(--brand); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: var(--radius-none); background: var(--brand); }
input[type="range"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.linkbtn { align-self: flex-start; margin: var(--space-2) 0 0; padding: var(--space-2) 0; border: 0; background: none; color: var(--ink-strong); font-family: var(--font-utility); font-size: 14px; text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; cursor: pointer; }
.linkbtn:hover { color: var(--brand-hover); }
.linkbtn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.check { display: flex; align-items: flex-start; gap: var(--space-3); font-family: var(--font-utility); font-size: 14px; line-height: 20px; color: var(--ink); cursor: pointer; }
.check input { margin-top: 0; width: 20px; height: 20px; flex: none; accent-color: var(--brand); }
.check[hidden] { display: none; }
.note { margin: 0; font-size: 15px; line-height: 24px; color: var(--ink-muted); }

/* ---------- the quote ---------- */
.eh-quote { max-width: none; }
.form { display: flex; flex-direction: column; gap: var(--space-4); }
.form__row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
@media (max-width: 480px) { .form__row { grid-template-columns: 1fr; } }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.eh-notice { max-width: none; box-shadow: none; }

/* ---------- the drawing ---------- */
.art .floor { fill: var(--surface-band); }
.art .floor-line { stroke: var(--line-strong); }
.art .board { stroke: var(--ink-strong); stroke-linejoin: round; }
.art .frame { fill: var(--surface-band); stroke: var(--line-control); }
.art .mattress { fill: var(--surface); stroke: var(--line-control); fill-opacity: .94; }
.art .hidden-edge { fill: none; stroke: var(--ink-muted); }
.art .pillow { stroke: var(--accent); stroke-dasharray: 6 5; }
.art .pillow-t { fill: var(--accent); font-family: var(--font-utility); stroke: var(--surface-raised); paint-order: stroke; }
.art .dim, .art .ext { stroke: var(--ink-muted); fill: none; }
.art .ext { opacity: .6; }
.art .dim-t { fill: var(--ink-strong); font-family: var(--font-utility); stroke: var(--surface-raised); paint-order: stroke; stroke-linejoin: round; }
.art .dimmed { opacity: .25; }
.art .hdl { cursor: grab; outline: none; }
.art .hdl .halo { fill: var(--brand); opacity: .14; }
.art .hdl .knob { fill: var(--surface-raised); stroke: var(--brand); }
.art .hdl .glyph { fill: none; stroke: var(--brand); stroke-linecap: round; stroke-linejoin: round; }
.art .hdl:focus-visible .knob { stroke-width: 3.2; }
.art .hdl.active .halo { opacity: .3; }
body.dragging, body.dragging * { cursor: grabbing !important; }
