/* ============================================================
   plan.css — Architecture plan tool (Phase 2 of the building
   generator). Flat black-on-white CAD/blueprint chrome, sharp
   corners, hairline rules — mirrors the furniture tool.
   ============================================================ */

.plan-body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--bg, #fff);
  color: var(--ink, #111);
  font-family: var(--sans);
  display: flex;
  flex-direction: column;
}
.plan-body .sand-bg { opacity: 0.35; }   /* keep the canvas legible over the backdrop */

/* ---------- Top bar ---------- */
.plan-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  background: #fff;
  border-bottom: 1px solid var(--ink, #111);
  z-index: 30;
}
.plan-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.plan-logo .logo-mark img { width: 22px; height: 22px; display: block; }
.plan-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.plan-bar__spacer { flex: 1 1 auto; }
.plan-hist { display: inline-flex; gap: 4px; }
.plan-actions { display: inline-flex; gap: 6px; align-items: center; }

.plan-icon {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--ink);
  background: #fff; color: var(--ink);
  font-size: 15px; line-height: 1; cursor: pointer;
  border-radius: 0;
  transition: background 120ms, color 120ms;
}
.plan-icon:hover:not(:disabled) { background: var(--ink); color: #fff; }
.plan-icon:disabled { opacity: 0.3; cursor: default; }

/* shared button look (over the brand .btn) */
.plan-bar .btn,
.plan-actions .btn {
  padding: 6px 12px;
  font-size: 13px;
  border: 1px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
}
.plan-actions .btn.is-active { background: var(--ink); color: #fff; }

/* ---------- Main split ---------- */
.plan-main {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

/* ---------- Left side panel ---------- */
.plan-side {
  flex: 0 0 286px;
  width: 286px;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid var(--ink, #111);
  overflow: hidden;
}
.plan-side__sec {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--line, #e6e4e0);
  min-height: 0;
}
.plan-browser { flex: 1 1 auto; min-height: 120px; }
.plan-tools   { flex: 0 0 auto; }
.plan-props   { flex: 0 0 auto; max-height: 38%; }
.plan-side__head {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft, #6a6a6a);
  background: var(--bg-alt, #f4f3f1);
  border-bottom: 1px solid var(--line, #e6e4e0);
}
.plan-bldg {
  font-size: 12px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 2px 4px;
  border-radius: 0;
  max-width: 130px;
}

/* Project browser tree */
.plan-tree {
  flex: 1 1 auto;
  overflow: auto;
  padding: 6px 0;
}
.plan-tree__group { margin-bottom: 2px; }
.plan-tree__grouphead {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 12px;
  font-size: 12px; font-weight: 700;
  cursor: pointer;
  user-select: none;
}
.plan-tree__grouphead:hover { background: var(--bg-alt); }
.plan-tree__caret { font-size: 9px; width: 9px; display: inline-block; transition: transform 120ms; }
.plan-tree__group.is-collapsed .plan-tree__caret { transform: rotate(-90deg); }
.plan-tree__group.is-collapsed .plan-tree__rows { display: none; }
.plan-tree__count { margin-left: auto; font-size: 10px; color: var(--muted); }

.plan-view {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 12px 4px 26px;
  font-size: 12.5px;
  cursor: pointer;
  border-left: 2px solid transparent;
}
.plan-view:hover { background: var(--bg-alt); }
.plan-view.is-active { background: var(--ink); color: #fff; border-left-color: var(--ink); }
.plan-view.is-active .plan-view__meta { color: #cfcfcf; }
.plan-view__name { flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-view__meta { font-size: 10px; color: var(--muted); white-space: nowrap; }
.plan-view__eye {
  flex: 0 0 auto; width: 18px; text-align: center; opacity: 0.55; font-size: 12px;
  background: none; border: 0; cursor: pointer; color: inherit; padding: 0;
}
.plan-view__eye:hover { opacity: 1; }
.plan-view.is-closed { opacity: 0.5; }
.plan-view__del {
  flex: 0 0 auto; width: 16px; text-align: center; opacity: 0; font-size: 12px;
  background: none; border: 0; cursor: pointer; color: inherit; padding: 0;
}
.plan-view:hover .plan-view__del { opacity: 0.6; }
.plan-view__del:hover { opacity: 1; }

.plan-browser__add {
  flex: 0 0 auto;
  display: flex; gap: 6px;
  padding: 6px 12px;
  border-top: 1px solid var(--line);
}
.plan-mini {
  flex: 1 1 auto;
  font-size: 11.5px;
  padding: 5px 6px;
  border: 1px solid var(--ink);
  background: #fff; color: var(--ink);
  cursor: pointer; border-radius: 0;
}
.plan-mini:hover { background: var(--ink); color: #fff; }
.plan-mini.is-armed { background: var(--ink); color: #fff; }

/* Tool palette */
.plan-palette {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  padding: 0;
}
.plan-tool {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 10px;
  font-size: 12.5px;
  border: 0; border-radius: 0;
  background: #fff; color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: background 100ms, color 100ms;
}
.plan-tool:hover { background: var(--bg-alt); }
.plan-tool.is-active { background: var(--ink); color: #fff; }

/* Properties */
.plan-props__body { overflow: auto; padding: 10px 12px; }
.plan-hint { font-size: 12px; color: var(--ink-soft); margin: 0; line-height: 1.5; }
.prop-row {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.prop-row label { flex: 1 1 auto; font-size: 12.5px; color: var(--ink-soft); }
.prop-row input[type="number"],
.prop-row input[type="text"],
.prop-row select {
  flex: 0 0 92px; width: 92px;
  font-size: 12.5px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 0; background: #fff;
}
.prop-row input[type="text"] { flex: 1 1 auto; width: auto; }
.prop-row--seg { gap: 4px; }
.prop-seg {
  flex: 1 1 auto; font-size: 11.5px; padding: 4px 4px;
  border: 1px solid var(--ink); background: #fff; cursor: pointer; border-radius: 0;
}
.prop-seg.is-active { background: var(--ink); color: #fff; }
.prop-del {
  width: 100%; margin-top: 4px;
  font-size: 12px; padding: 6px;
  border: 1px solid #b00020; color: #b00020; background: #fff;
  cursor: pointer; border-radius: 0;
}
.prop-del:hover { background: #b00020; color: #fff; }
.prop-add {
  width: 100%; margin-top: 6px;
  font-size: 12px; padding: 7px;
  border: 1px solid var(--ink); color: #fff; background: var(--ink);
  cursor: pointer; border-radius: 0; font-weight: 600;
}
.prop-add:hover { opacity: 0.85; }
.prop-meta { font-size: 11px; color: var(--muted); margin: 2px 0 10px; }

/* ---------- Drawing stage ---------- */
.plan-stage {
  flex: 1 1 auto;
  position: relative;
  min-width: 0;
  background:
    repeating-linear-gradient(0deg, transparent 0 23px, #00000005 23px 24px),
    #fbfbfa;
  overflow: hidden;
}
.plan-canvas-host { position: absolute; inset: 0; }
.plan-canvas-host svg { display: block; width: 100%; height: 100%; touch-action: none; }
.plan-canvas-host.tool-draw svg { cursor: crosshair; }
.plan-canvas-host.tool-pan svg { cursor: grabbing; }

.plan-viewbar {
  position: absolute; top: 10px; left: 12px;
  display: flex; align-items: baseline; gap: 8px;
  padding: 4px 10px;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--ink);
  font-size: 12px;
  pointer-events: none;
}
.plan-viewbar__name { font-weight: 700; }
.plan-viewbar__meta { font-size: 11px; color: var(--ink-soft); }

.plan-hintbar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.94);
  border-top: 1px solid var(--line);
  font-size: 12px; color: var(--ink-soft);
  pointer-events: none;
}
.plan-readout { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }

.plan-zoom {
  position: absolute; right: 12px; bottom: 38px;
  display: flex; flex-direction: column; gap: 4px;
}

.plan-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center; color: var(--ink-soft);
  background: #fbfbfa;
}
.plan-empty[hidden] { display: none; }   /* author display:flex would otherwise beat UA [hidden] */
.plan-empty__icon { font-size: 40px; }
.plan-empty h3 { margin: 4px 0 0; }
.plan-empty p { margin: 0; font-size: 13px; }

/* ---------- SVG element styling (set via classes in JS) ---------- */
.pl-outline { fill: none; stroke: #b9b3a8; stroke-width: 1.4; stroke-dasharray: 6 4; }
.pl-grid    { stroke: #00000010; stroke-width: 1; }
.pl-grid--major { stroke: #0000001c; }
.pl-axis    { stroke: #00000022; stroke-width: 1; }

.pl-wall      { fill: #2b2b2b; stroke: #000; stroke-width: 0.5; }
.pl-wall-line { stroke: #111; stroke-width: 1.4; fill: none; }
.pl-wall.is-sel, .pl-wall-line.is-sel { stroke: #1565 ; }
.is-sel { stroke: #c0392b !important; }
.pl-opening { fill: #fff; stroke: #111; stroke-width: 1; }
.pl-door-swing { fill: none; stroke: #111; stroke-width: 0.8; stroke-dasharray: 3 2; }
.pl-window { stroke: #111; stroke-width: 1; }

.pl-col   { fill: #333; stroke: #000; stroke-width: 0.6; }
.pl-gridline { stroke: #888; stroke-width: 0.8; stroke-dasharray: 10 3 2 3; }
.pl-gridbubble { fill: #fff; stroke: #111; stroke-width: 1; }
.pl-gridlabel { font: 600 11px var(--sans); fill: #111; text-anchor: middle; dominant-baseline: central; }

.pl-room { fill: #11111108; stroke: #11111133; stroke-width: 1; }
.pl-room.is-sel { stroke: #c0392b; fill: #c0392b14; }
.pl-roomtag { font: 600 12px var(--sans); fill: #111; text-anchor: middle; }
.pl-roomtag__area { font: 400 10px var(--sans); fill: #555; text-anchor: middle; }

.pl-stair { fill: none; stroke: #111; stroke-width: 1; }
.pl-stair-tread { stroke: #111; stroke-width: 0.7; }
.pl-stair-arrow { stroke: #111; stroke-width: 0.9; fill: none; }

/* ---------- glazing (windows / glass walls) ---------- */
.pl-glass      { fill: #2aa9c722; stroke: none; }
.pl-glass-line { stroke: #1f8aa6; stroke-width: 1.2; fill: none; }
.pl-window-fill { fill: #ffffffcc; stroke: none; }
.pl-facade-sel { stroke: #c0392b; stroke-width: 2.4; }

/* ---------- vertical circulation (stair / shaft / elevator) ---------- */
.pl-shaft       { fill: #f2efe7cc; stroke: #111; stroke-width: 1.1; }
.pl-shaft.is-sel { stroke: #c0392b; stroke-width: 1.6; }
.pl-elev-x      { stroke: #111; stroke-width: 0.9; }
.pl-elev-door   { stroke: #111; stroke-width: 1.6; }
.pl-vcirc-label { font: 700 11px var(--sans); fill: #111; text-anchor: middle; dominant-baseline: central; }
.pl-vcirc-hit   { fill: transparent; stroke: transparent; cursor: move; }
.pl-rot-handle  { fill: #c0392b; stroke: #fff; stroke-width: 1.5; cursor: grab; }
.pl-rot-stem    { stroke: #c0392b; stroke-width: 1; stroke-dasharray: 3 2; }
.pl-preview--bad { stroke: #c0392b; stroke-dasharray: 2 2; opacity: 0.6; }

/* perimeter note under the tool palette */
.plan-palette__note { margin: 8px 4px 0; line-height: 1.4; }

.pl-dim       { stroke: #c0392b; stroke-width: 0.9; }
.pl-dim-tick  { stroke: #c0392b; stroke-width: 0.9; }
.pl-dim-txt   { font: 600 11px var(--sans); fill: #c0392b; text-anchor: middle; }

.pl-text { font: 500 13px var(--sans); fill: #111; }

.pl-preview { stroke: #c0392b; stroke-width: 1.2; fill: none; stroke-dasharray: 5 3; pointer-events: none; }
.pl-preview-fill { fill: #c0392b18; stroke: #c0392b; stroke-width: 1; pointer-events: none; }
.pl-snap { fill: none; stroke: #c0392b; stroke-width: 1.4; pointer-events: none; }
.pl-vertex { fill: #fff; stroke: #111; stroke-width: 1; cursor: move; }
.pl-handle { fill: #c0392b; stroke: #fff; stroke-width: 1; cursor: move; }
.pl-hit { stroke: transparent; fill: transparent; stroke-width: 10; cursor: pointer; }

.pl-marker { fill: #fff; stroke: #111; stroke-width: 1; }
.pl-marker-line { stroke: #111; stroke-width: 1; stroke-dasharray: 8 4; }
.pl-marker-txt { font: 700 10px var(--sans); fill: #111; text-anchor: middle; dominant-baseline: central; }
.pl-datum { stroke: #888; stroke-width: 0.8; stroke-dasharray: 12 3; }
.pl-datum-txt { font: 600 10px var(--sans); fill: #555; }

/* ---------- Gate-lite ---------- */
.plan-gate {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.96);
}
.plan-gate[hidden] { display: none; }
.plan-gate__panel {
  max-width: 460px; width: calc(100% - 40px);
  padding: 28px 26px;
  border: 1px solid var(--ink);
  background: #fff; text-align: center;
}
.plan-gate__panel .gate__brand {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 700; margin-bottom: 14px;
}
.plan-gate__panel .logo-mark img { width: 22px; height: 22px; }
.plan-gate__panel h2 { margin: 0 0 8px; }
.plan-gate__lede { color: var(--ink-soft); font-size: 14px; line-height: 1.5; margin: 0 0 18px; }

/* highlight the new building-generator button */
.tools-actions__next { box-shadow: inset 0 0 0 1px var(--ink); }

@media (max-width: 720px) {
  .plan-side { flex-basis: 220px; width: 220px; }
  .plan-title { display: none; }
}
