/* Deck Framing Designer — the plan and the 3D view get the width.
 *
 * The plan, the 3D view and the review items take the main column; the
 * section inspector and the list of sections sit beside them on a desktop
 * and under them on a phone. Lumber colours are fixed: they say what a
 * member is and must read the same on every theme and on paper.
 */

.product[data-product="deck-designer"] {
  --dk-line: color-mix(in srgb, var(--text) 18%, transparent);
  --dk-focus: #2563eb;
  --dk-warn: #b45309;
  --dk-bad: #b42318;
}

.dk-plan-pane { max-width: none; }
.dk-live {
  position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.dk-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 21rem;
  gap: 1rem;
  align-items: start;
}
.dk-main, .dk-side { display: grid; gap: .6rem; min-width: 0; }
.dk-side { gap: .8rem; }

.dk-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .6rem;
  padding: .35rem;
  border: 1px solid var(--dk-line);
  border-radius: var(--radius);
  background: var(--surface);
}
.dk-toolbar .input { width: auto; min-width: 0; padding-block: .3rem; }
.dk-group, .dk-segmented { display: inline-flex; flex-wrap: wrap; gap: .3rem; }
.dk-toolbar [aria-pressed="true"] {
  background: color-mix(in srgb, var(--dk-focus) 14%, var(--surface));
  border-color: var(--dk-focus);
}
.dk-check { display: inline-flex; gap: .45rem; align-items: center; font-size: .92rem; }

/* ── Plan and 3D ────────────────────────────────────────────────────── */

/* Plan above, 3D below: side by side, both would be too narrow to work in. */
.dk-stages { display: grid; grid-template-columns: minmax(0, 1fr); gap: .6rem; }
.dk-stages[data-view="both"] .dk-stage-3d { height: min(56vh, 30rem); }
.dk-stages[data-view="plan"] .dk-stage-3d { display: none; }
.dk-stages[data-view="3d"] .dk-stage-plan { display: none; }
.dk-stage {
  position: relative;
  border: 1px solid var(--dk-line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #f4f1e8;
  height: min(68vh, 40rem);
  min-height: 22rem;
}
.dk-stage-3d { background: #dfe9f0; touch-action: none; }
.dk-stage-3d canvas { display: block; width: 100%; height: 100%; }
.dk-3d-note { position: absolute; inset: auto 0 0 0; margin: 0; padding: .6rem .8rem; font-size: .9rem; color: var(--muted); }
.dk-3d-note[hidden] { display: none; }
.dk-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  outline: none;
}
.dk-canvas:focus-visible { box-shadow: inset 0 0 0 3px var(--dk-focus); }

/* ── Cards ──────────────────────────────────────────────────────────── */

.dk-card {
  display: grid;
  gap: .6rem;
  padding: .9rem;
  border: 1px solid var(--dk-line);
  border-radius: var(--radius);
  background: var(--surface);
  min-width: 0;
}
.dk-card h3 { margin: 0; font-size: 1.05rem; }
.dk-card h4 { margin: 0; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.dk-card .field-help { margin: 0; }
.dk-field { display: grid; gap: .2rem; margin: 0; min-width: 0; }
.dk-field .input { width: 100%; min-width: 0; }
.dk-row { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.dk-group-box {
  display: grid;
  gap: .5rem;
  padding: .55rem .7rem .7rem;
  border: 1px solid var(--dk-line);
  border-radius: calc(var(--radius) / 1.5);
}
.dk-stair { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .4rem; align-items: center; }
.dk-stair select { grid-column: 1 / -1; }
.dk-stair .input { width: 100%; min-width: 0; }
.dk-facts { display: grid; grid-template-columns: auto 1fr; gap: .15rem .8rem; margin: 0; font-variant-numeric: tabular-nums; }
.dk-facts dt { color: var(--muted); font-size: .88rem; }
.dk-facts dd { margin: 0; font-weight: 600; }
.dk-card .tool-actions { margin: 0; }
.dk-card .tone-bad { color: var(--dk-bad); }

.dk-section-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .2rem; }
.dk-section {
  display: grid;
  gap: .1rem;
  width: 100%;
  padding: .35rem .5rem;
  font: inherit;
  font-size: .92rem;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) / 1.5);
  cursor: pointer;
}
.dk-section:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
.dk-section[aria-pressed="true"] { border-color: var(--dk-focus); background: color-mix(in srgb, var(--dk-focus) 10%, transparent); }
.dk-section:focus-visible { outline: 3px solid var(--dk-focus); outline-offset: 1px; }
.dk-section-name { font-weight: 600; }
.dk-section-meta { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.dk-checks { gap: .4rem; }
.dk-check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.dk-check-item {
  padding: .4rem .6rem;
  font-size: .9rem;
  background: color-mix(in srgb, var(--dk-focus) 6%, var(--surface));
  border-left: 3px solid var(--dk-focus);
  border-radius: 4px;
}
.dk-check-item.tone-warn { border-left-color: var(--dk-warn); background: color-mix(in srgb, var(--dk-warn) 9%, var(--surface)); }
.dk-check-item.tone-bad { border-left-color: var(--dk-bad); background: color-mix(in srgb, var(--dk-bad) 9%, var(--surface)); font-weight: 600; }
.dk-stamp { margin: 0; font-size: .85rem; color: var(--muted); }

/* ── Framing and materials ──────────────────────────────────────────── */

.dk-table { width: 100%; border-collapse: collapse; margin: .4rem 0 1rem; font-variant-numeric: tabular-nums; }
.dk-table th, .dk-table td { padding: .4rem .5rem; text-align: left; border-bottom: 1px solid var(--dk-line); vertical-align: middle; }
.dk-table thead th { font-size: .82rem; color: var(--muted); font-weight: 600; }
.dk-table .num { text-align: right; white-space: nowrap; }
.dk-table tfoot th { font-size: 1rem; }
.dk-price .input { width: 6.5rem; min-width: 0; padding-block: .25rem; }
.dk-sources { color: var(--muted); font-size: .9rem; display: grid; gap: .3rem; }
.dk-settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .8rem 1rem; margin: .6rem 0; }
.dk-table-wrap { overflow-x: auto; max-width: 100%; }

/* Toolbar and card buttons read as controls, not links. */
.dk-toolbar .btn-quiet, .dk-card .btn-quiet {
  display: inline-flex;
  align-items: center;
  min-height: 2.1rem;
  padding: .25rem .65rem;
  font-size: .9rem;
  text-decoration: none;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--dk-line);
  border-radius: calc(var(--radius) / 1.5);
}
.dk-toolbar .btn-quiet:hover, .dk-card .btn-quiet:hover { border-color: var(--dk-focus); }
.dk-toolbar .btn-quiet:disabled { opacity: .5; }

@media (max-width: 960px) {
  .dk-workspace { grid-template-columns: minmax(0, 1fr); }
  .dk-stage { height: min(60vh, 30rem); }
}
@media (max-width: 520px) {
  .dk-row { grid-template-columns: 1fr; }
  .dk-bill td:nth-child(3), .dk-bill th:nth-child(3) { display: none; }
}

.dk-print { display: none; }
@media print {
  body[data-printing-scope] .dk-print[data-printing] { display: block; color: #000; font: 10pt/1.35 Helvetica, Arial, sans-serif; }
  .dk-print h2 { font-size: 14pt; margin: 0 0 .3rem; }
  .dk-print h3 { font-size: 11.5pt; margin: .8rem 0 .2rem; }
  .dk-print table { width: 100%; border-collapse: collapse; margin: .3rem 0 .8rem; }
  .dk-print th, .dk-print td { text-align: left; padding: 2pt 4pt; border-bottom: .5pt solid #aaa; }
  .dk-print img { width: 100%; height: auto; max-height: 8.2in; object-fit: contain; }
  .dk-print-page { break-after: page; }
  .dk-print-page:last-child { break-after: auto; }
}
