/* ==========================================================================
   Dock Designer — interactive configurator + LGPC compliance engine
   Loaded only on /dock-designer/
   ========================================================================== */

.dz {
  --panel: #10240F;
  --panel-2: #17330F;
  --panel-line: rgba(255, 255, 255, .13);
  --pass: #4EA65B;
  --warn: #D9A22B;
  --fail: #C7563C;
}

/* ---------- shell ---------- */
.dz-shell {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--paper);
  box-shadow: var(--shadow-lg);
}
@media (max-width: 1040px) { .dz-shell { grid-template-columns: 1fr; } }

/* ---------- stage ---------- */
.dz-stage {
  background: linear-gradient(170deg, #0E2410, #0A1A0C);
  display: flex;
  flex-direction: column;
  min-height: 520px;
  order: 2;
}
@media (max-width: 1040px) {
  .dz-stage { order: -1; min-height: 0; position: sticky; top: var(--header-h); z-index: 5; }
}

.dz-tabs {
  display: flex; align-items: center; gap: .3rem;
  padding: .7rem .8rem; border-bottom: 1px solid var(--panel-line);
  background: rgba(0, 0, 0, .25);
}
.dz-tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  color: rgba(255, 255, 255, .62); font-family: var(--ff-body);
  font-size: .78rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  padding: .5rem .85rem; border-radius: var(--r-sm); transition: all .2s var(--ease);
  display: inline-flex; align-items: center; gap: .45rem;
}
.dz-tab svg { width: 15px; height: 15px; }
.dz-tab:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.dz-tab[aria-selected="true"] { background: var(--gold-500); color: var(--green-900); }
.dz-tabs .dz-spacer { margin-left: auto; }
.dz-mini {
  appearance: none; cursor: pointer; border: 1px solid var(--panel-line);
  background: rgba(255, 255, 255, .07); color: #DCEAD8;
  font-size: .72rem; font-weight: 600; letter-spacing: .04em;
  padding: .5rem .7rem; border-radius: var(--r-sm); display: inline-flex; align-items: center; gap: .4rem;
  transition: all .2s var(--ease);
}
.dz-mini svg { width: 14px; height: 14px; }
.dz-mini:hover { background: var(--gold-500); color: var(--green-900); border-color: var(--gold-500); }

/* The height here must NOT depend on the canvas. The renderer sizes the canvas
   from wrap.clientHeight, so a content-driven height would feed back and grow
   the canvas without bound on every redraw. */
.dz-canvas-wrap {
  position: relative; flex: 0 0 auto;
  height: clamp(340px, 58vh, 620px);
  display: grid; place-items: center; padding: .8rem; overflow: hidden;
}
@media (max-width: 1040px) { .dz-canvas-wrap { height: clamp(260px, 44vh, 460px); } }
.dz-canvas-wrap canvas {
  max-width: 100%; max-height: 100%; border-radius: var(--r-sm);
  touch-action: none; display: block;
}
#dz-photo-canvas { cursor: grab; }
#dz-photo-canvas.dragging { cursor: grabbing; }
.dz-hint {
  position: absolute; left: 50%; bottom: .9rem; transform: translateX(-50%);
  background: rgba(8, 20, 9, .82); backdrop-filter: blur(6px);
  color: #CFE0CA; font-size: .74rem; padding: .42rem .8rem; border-radius: 100px;
  pointer-events: none; white-space: nowrap; border: 1px solid var(--panel-line);
}
@media (max-width: 620px) { .dz-hint { font-size: .68rem; } }

/* ---------- verdict bar ---------- */
.dz-verdict {
  display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
  padding: .85rem 1rem; border-top: 1px solid var(--panel-line);
  background: rgba(0, 0, 0, .3);
}
.dz-badge {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: var(--ff-display); font-size: .93rem; font-weight: 700;
  padding: .45rem .9rem; border-radius: 100px; flex: none;
}
.dz-badge svg { width: 16px; height: 16px; }
.dz-badge.ok { background: rgba(78, 166, 91, .2); color: #8FD69B; border: 1px solid rgba(78, 166, 91, .5); }
.dz-badge.no { background: rgba(199, 86, 60, .2); color: #F0A28C; border: 1px solid rgba(199, 86, 60, .5); }
.dz-verdict-note { font-size: .8rem; color: #B4CBAF; line-height: 1.45; }

/* ---------- control rail ---------- */
.dz-rail {
  background: var(--paper); border-right: 1px solid var(--line);
  max-height: 78vh; overflow-y: auto; order: 1;
}
@media (max-width: 1040px) { .dz-rail { max-height: none; border-right: 0; border-top: 1px solid var(--line); } }

.dz-step { border-bottom: 1px solid var(--line-2); padding: 1.15rem 1.25rem; }
.dz-step:last-child { border-bottom: 0; }
.dz-steplabel {
  font-family: var(--ff-body); font-size: .715rem; font-weight: 700;
  letter-spacing: .15em; text-transform: uppercase; color: var(--muted);
  margin: 0 0 .9rem; display: flex; align-items: center; gap: .55rem;
}
.dz-steplabel .n {
  width: 20px; height: 20px; border-radius: 50%; background: var(--green-600); color: #fff;
  display: grid; place-items: center; font-size: .68rem; flex: none; letter-spacing: 0;
}

/* segmented choices */
.dz-seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: .4rem; }
.dz-seg.c2 { grid-template-columns: 1fr 1fr; }
.dz-seg.c3 { grid-template-columns: repeat(3, 1fr); }
.dz-seg.c4 { grid-template-columns: repeat(4, 1fr); }
.dz-opt {
  appearance: none; cursor: pointer; text-align: center;
  border: 1.5px solid var(--line); background: var(--paper); border-radius: var(--r-sm);
  padding: .6rem .3rem; font-family: var(--ff-body); font-size: .76rem; font-weight: 600;
  color: var(--ink-2); transition: all .18s var(--ease); line-height: 1.25;
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
}
.dz-opt small { font-size: .63rem; font-weight: 500; color: var(--muted); letter-spacing: .02em; }
.dz-opt:hover { border-color: var(--green-500); background: var(--green-50); }
.dz-opt[aria-pressed="true"] { border-color: var(--green-600); background: var(--green-600); color: #fff; }
.dz-opt[aria-pressed="true"] small { color: rgba(255, 255, 255, .8); }
.dz-opt svg { width: 26px; height: 18px; }
.dz-opt .sw { width: 100%; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.16); }

/* sliders */
.dz-field { margin-bottom: .95rem; }
.dz-field:last-child { margin-bottom: 0; }
.dz-field label {
  display: flex; align-items: baseline; justify-content: space-between; gap: .6rem;
  font-size: .8rem; font-weight: 600; color: var(--ink-2); margin-bottom: .4rem;
}
.dz-field label .val {
  font-family: var(--ff-display); font-size: .95rem; color: var(--green-700);
  font-variant-numeric: tabular-nums;
}
.dz-field label .val.over { color: var(--fail); }
.dz-field input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 26px;
  background: transparent; cursor: pointer; display: block; margin: 0;
}
.dz-field input[type="range"]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 3px; background: var(--green-100);
}
.dz-field input[type="range"]::-moz-range-track {
  height: 5px; border-radius: 3px; background: var(--green-100);
}
.dz-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px; margin-top: -7.5px;
  border-radius: 50%; background: var(--green-600); border: 3px solid #fff;
  box-shadow: 0 1px 5px rgba(15, 36, 16, .35); transition: transform .15s var(--ease);
}
.dz-field input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%; background: var(--green-600);
  border: 3px solid #fff; box-shadow: 0 1px 5px rgba(15, 36, 16, .35);
}
.dz-field input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.16); }
.dz-field input[type="range"]:focus-visible { outline: none; }
.dz-field input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(41, 95, 45, .28); }

.dz-num {
  display: flex; align-items: center; gap: .5rem;
}
.dz-num input[type="number"] {
  width: 100%; padding: .62rem .7rem; border: 1px solid var(--line);
  border-radius: var(--r-sm); font-size: .95rem; font-family: var(--ff-display);
  color: var(--green-800); background: var(--paper);
}
.dz-num input[type="number"]:focus {
  outline: none; border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(41, 95, 45, .13);
}
.dz-num .unit { font-size: .78rem; color: var(--muted); font-weight: 600; flex: none; }

.dz-select {
  width: 100%; padding: .58rem .7rem; border: 1px solid var(--line);
  border-radius: var(--r-sm); font-size: .82rem; font-family: var(--ff-body);
  font-weight: 600; color: var(--green-800); background: var(--paper);
}
.dz-select:focus {
  outline: none; border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(41, 95, 45, .13);
}

/* ---------- sub-headings and notes inside a step ---------- */
.dz-sublabel {
  font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin: 1rem 0 .5rem;
  display: flex; align-items: center; gap: .5rem;
}
.dz-sublabel:first-child { margin-top: 0; }
.dz-partner {
  font-size: .58rem; letter-spacing: .06em; background: var(--green-50);
  color: var(--green-700); border: 1px solid var(--green-100);
  padding: .12rem .38rem; border-radius: 99px; text-transform: none; font-weight: 600;
}
.dz-note {
  display: flex; gap: .45rem; align-items: flex-start;
  font-size: .715rem; line-height: 1.45; color: var(--muted); margin: .7rem 0 0;
}
.dz-note svg { flex: none; margin-top: .08rem; }
.dz-note.warn { color: var(--fail); }
.dz-blurb { font-size: .74rem; line-height: 1.5; color: var(--muted); margin: -.4rem 0 .85rem; }
.dz-spec {
  font-size: .74rem; line-height: 1.5; color: var(--green-800); margin: -.5rem 0 .3rem;
  background: var(--green-50); border-radius: var(--r-sm); padding: .5rem .6rem;
  font-variant-numeric: tabular-nums;
}
.dz-spec .muted { color: var(--muted); font-weight: 500; }
.dz-chosen { font-size: .76rem; color: var(--ink-2); margin: .7rem 0 0; }
.dz-chosen b { color: var(--green-700); }

/* ---------- on/off switch heading an optional section ---------- */
.dz-switch { display: flex; align-items: center; gap: .6rem; cursor: pointer; }
.dz-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.dz-switch .track {
  width: 40px; height: 22px; border-radius: 99px; background: var(--line);
  flex: none; padding: 3px; transition: background .2s var(--ease);
}
.dz-switch .knob {
  display: block; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(15, 36, 16, .3); transition: transform .2s var(--ease);
}
.dz-switch input:checked + .track { background: var(--green-600); }
.dz-switch input:checked + .track .knob { transform: translateX(18px); }
.dz-switch input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(41, 95, 45, .28); }
.dz-switch .lbl { font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.dz-sub { margin-top: 1rem; }

.dz-check-inline {
  display: flex; gap: .5rem; align-items: flex-start; cursor: pointer;
  font-size: .78rem; line-height: 1.4; color: var(--ink-2); margin: .85rem 0 0;
}
.dz-check-inline input { margin-top: .15rem; accent-color: var(--green-600); flex: none; }

/* ---------- colour swatch grids ---------- */
.dz-swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: .35rem; }
.dz-swatches.tt { grid-template-columns: repeat(4, 1fr); }
.dz-swatch {
  appearance: none; cursor: pointer; padding: 0 0 .3rem; text-align: center;
  border: 1.5px solid var(--line); background: var(--paper); border-radius: var(--r-sm);
  overflow: hidden; transition: all .16s var(--ease); line-height: 1.2;
  display: flex; flex-direction: column; gap: .22rem;
}
.dz-swatch .sw {
  display: block; width: 100%; aspect-ratio: 5/3;
  border-bottom: 1px solid rgba(0, 0, 0, .12);
}
.dz-swatch .nm {
  font-size: .6rem; font-weight: 600; color: var(--ink-2); padding: 0 .18rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dz-swatch small { font-size: .53rem; color: var(--muted); font-weight: 500; }
.dz-swatch:hover { border-color: var(--green-500); }
.dz-swatch[aria-pressed="true"] {
  border-color: var(--green-600); box-shadow: 0 0 0 2px rgba(41, 95, 45, .22);
}
.dz-swatch[aria-pressed="true"] .nm { color: var(--green-700); }

/* ---------- TimberTech shade tabs ---------- */
.dz-shades { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; margin-bottom: .55rem; }
.dz-shade {
  appearance: none; cursor: pointer; text-align: left; padding: .45rem .5rem;
  border: 1.5px solid var(--line); background: var(--paper); border-radius: var(--r-sm);
  display: flex; flex-direction: column; gap: .25rem; transition: all .16s var(--ease);
}
.dz-shade .sw {
  width: 100%; height: 12px; border-radius: 2px; border: 1px solid rgba(0, 0, 0, .16);
}
.dz-shade b { font-size: .74rem; font-weight: 700; color: var(--ink-2); }
.dz-shade small { font-size: .56rem; color: var(--muted); line-height: 1.25; }
.dz-shade:hover { border-color: var(--green-500); }
.dz-shade[aria-pressed="true"] { border-color: var(--green-600); background: var(--green-50); }
.dz-shade[aria-pressed="true"] b { color: var(--green-700); }

.dz-presets { display: grid; gap: .4rem; }
.dz-preset {
  appearance: none; cursor: pointer; text-align: left; width: 100%;
  border: 1px solid var(--line); background: var(--paper); border-radius: var(--r-sm);
  padding: .62rem .75rem; transition: all .18s var(--ease);
}
.dz-preset:hover { border-color: var(--green-500); background: var(--green-50); transform: translateX(2px); }
.dz-preset b { display: block; font-family: var(--ff-display); font-size: .87rem; color: var(--ink); }
.dz-preset span { font-size: .72rem; color: var(--muted); line-height: 1.4; }

/* ---------- compliance report ---------- */
.dz-report { padding: 1.15rem 1.25rem; background: var(--sand); }
.dz-report .dz-steplabel { margin-bottom: .9rem; }
.dz-checks { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.dz-check {
  display: grid; grid-template-columns: 20px 1fr auto; gap: .6rem; align-items: start;
  padding: .6rem .7rem; border-radius: var(--r-sm); background: var(--paper);
  border: 1px solid var(--line-2); font-size: .8rem; line-height: 1.4;
}
.dz-check .ico { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; margin-top: .05rem; }
.dz-check .ico svg { width: 11px; height: 11px; color: #fff; }
.dz-check.pass .ico { background: var(--pass); }
.dz-check.warn .ico { background: var(--warn); }
.dz-check.fail .ico { background: var(--fail); }
.dz-check.fail { border-color: rgba(199, 86, 60, .45); background: #FDF4F1; }
.dz-check.warn { border-color: rgba(217, 162, 43, .4); background: #FFFBF0; }
.dz-check b { display: block; font-weight: 600; color: var(--ink); }
.dz-check span { color: var(--muted); font-size: .755rem; display: block; margin-top: .1rem; }
.dz-check .fig {
  font-family: var(--ff-display); font-size: .85rem; color: var(--ink-2);
  white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right;
}

.dz-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; margin-bottom: 1rem; }
.dz-summary > div { background: var(--paper); padding: .7rem .5rem; text-align: center; }
.dz-summary b { display: block; font-family: var(--ff-display); font-size: 1.15rem; color: var(--green-700); line-height: 1.1; font-variant-numeric: tabular-nums; }
.dz-summary b.over { color: var(--fail); }
.dz-summary span { font-size: .63rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

.dz-actions { display: grid; gap: .5rem; padding: 1.15rem 1.25rem; border-top: 1px solid var(--line-2); }
.dz-actions .btn { width: 100%; }
.dz-disclaimer {
  font-size: .715rem; color: var(--muted); line-height: 1.55; padding: 0 1.25rem 1.25rem;
}
.dz-disclaimer strong { color: var(--ink-2); }

@media (prefers-reduced-motion: reduce) {
  .dz-preset:hover { transform: none; }
}

/* ---------- 3D stage ---------- */
/* Sized entirely by CSS. The WebGL renderer writes only the drawing buffer
   (setSize with updateStyle=false), so there is no layout feedback loop. */
/* A canvas is a replaced element: with width/height auto it falls back to the
   intrinsic 300x200 and ignores the inset box, so both axes are set explicitly. */
#dz-gl {
  position: absolute; inset: 0;
  width: 100%; height: 100%; max-width: none; max-height: none;
  border-radius: 0; cursor: grab; touch-action: none;
  background: #0C1A16;
}
#dz-gl.dragging { cursor: grabbing; }
#dz-gl[hidden] { display: none; }

.dz-nogl {
  display: none; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%); max-width: 30ch; text-align: center;
  color: #CFE0CA; font-size: .82rem; line-height: 1.5;
}
.dz-stage.no-webgl .dz-nogl { display: block; }
.dz-stage.no-webgl .dz-tab[disabled] { opacity: .35; cursor: not-allowed; }

/* ---------- photoreal render panel ---------- */
.dz-render {
  padding: 1.15rem 1.25rem; border-top: 1px solid var(--line-2);
  display: grid; gap: .7rem;
}
.dz-render-lede { font-size: .82rem; line-height: 1.6; color: var(--ink-2); margin: 0; }
.dz-consent {
  display: flex; gap: .55rem; align-items: flex-start;
  font-size: .8rem; line-height: 1.45; color: var(--ink-2); cursor: pointer;
}
.dz-consent input { margin-top: .18rem; flex: 0 0 auto; accent-color: var(--green-700); }
.dz-render .btn { width: 100%; }
.dz-render-out { font-size: .8rem; line-height: 1.5; margin: 0; min-height: 0; }
.dz-render-out:empty { display: none; }
.dz-render-out.busy { color: var(--ink-2); }
.dz-render-out.ok { color: var(--green-700); }
.dz-render-out.warn { color: #A8452C; }
#dz-render-img {
  width: 100%; height: auto; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); display: block;
}
#dz-render-img[hidden], #dz-render-save[hidden] { display: none; }

/* ---------- design-rule notices ---------- */
.dz-rules {
  list-style: none; margin: 0 0 .75rem; padding: 0;
  display: grid; gap: .35rem;
}
.dz-rules li {
  display: grid; grid-template-columns: auto 1fr; gap: .1rem .5rem;
  background: var(--green-50); border-left: 3px solid var(--green-500);
  border-radius: var(--r-sm); padding: .5rem .7rem;
  font-size: .74rem; line-height: 1.4;
}
.dz-rules li b { grid-column: 1 / -1; color: var(--green-700); font-size: .76rem; }
.dz-rules li span { grid-column: 1 / -1; color: var(--ink-2); }
.dz-rules li.bad { background: rgba(199, 86, 60, .1); border-left-color: var(--fail); }
.dz-rules li.bad b { color: var(--fail); }

.dz-opt.unavailable,
.dz-opt:disabled {
  opacity: .38; cursor: not-allowed; text-decoration: line-through;
}
.dz-opt.unavailable:hover { border-color: var(--line); background: var(--paper); }
