/* cad_board.css — the board of blocks (cad_board.js). */

/* The board replaces the fixed Legacy grid and the Realistic rails. */
body.cad-board-on .workspace, body.cad-board-on #rl-shell { display: none !important; }
#cadBoard {
  flex: 1; min-height: 0; display: flex; gap: 0;
  padding: 4px; background: var(--bg); overflow: hidden;
}
.cad-bcol { display: flex; flex-direction: column; min-width: 150px; min-height: 0; }
#cadBoard [data-block] {
  position: relative; min-height: 34px; min-width: 0; overflow: hidden;
  display: flex; flex-direction: column;
  border: 1px solid var(--borderhi); background: var(--bg1);
  border-radius: var(--r);
}
#cadBoard .rl-col { background: var(--rl-rail); }
body.cad-drawer-open #cadBoard { margin-right: min(440px, 100vw); }

/* The gaps are the handles. */
.cad-split2 { flex: 0 0 6px; position: relative; z-index: 4; }
.cad-split2-v { cursor: col-resize; }
.cad-split2-h { cursor: row-resize; }
.cad-split2:hover, body.cad-resizing .cad-split2 { background: var(--accentglow); }
body.cad-resizing { user-select: none; }
body.cad-resizing iframe, body.cad-resizing canvas { pointer-events: none; }

/* Every style can show every block: the rail and card blocks borrow the
   current style's colours when Realistic is not the one on. */
body:not(.skin-realistic) {
  --rl-bg: var(--bg); --rl-rail: var(--bg1); --rl-head: var(--bg); --rl-card: var(--bg2); --rl-cardhi: var(--bg3);
  --rl-line: var(--border); --rl-linehi: var(--borderhi); --rl-text: var(--text); --rl-text2: var(--text2); --rl-text3: var(--text3);
  --rl-blue: var(--accent); --rl-green: var(--green); --rl-amber: var(--yellow); --rl-red: var(--red); --rl-teal: #17a2b8; --rl-r: var(--r);
}
/* …and the table blocks take Realistic's colours when it is. */
body.skin-realistic {
  --bg: var(--rl-bg); --bg1: var(--rl-rail); --bg2: var(--rl-card); --bg3: var(--rl-cardhi);
  --border: var(--rl-line); --borderhi: var(--rl-linehi); --text: var(--rl-text); --text2: var(--rl-text2); --text3: var(--rl-text3);
}
body.skin-realistic #cadBoard { background: var(--rl-bg); }
body.skin-compact #cadBoard { background: var(--bg1); padding: 3px; }
body.skin-compact #cadBoard [data-block] { border-color: var(--borderhi); background: var(--bg); }

/* 911 folded to its strip. */
#cadBoard .quad-bl.cad-folded { min-height: 34px; }

/* The Map button flashes the map block when the map is on the board. */
@keyframes cadFlash { 0%, 100% { box-shadow: none; } 30% { box-shadow: 0 0 0 3px var(--accent); } }
.cad-flash { animation: cadFlash .9s ease-out 2; }

/* ── Edit layout ─────────────────────────────────────────────────── */
.cad-edit-bar[hidden] { display: none; }
.cad-edit-bar {
  flex-shrink: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 6px 12px; background: var(--accent); color: #fff;
}
.cad-edit-title { font-family: var(--cond); font-size: 13px; letter-spacing: .4px; }
.cad-edit-hint { font-size: 11.5px; opacity: .85; }
.cad-edit-shelf { display: flex; flex-wrap: wrap; gap: 5px; margin-left: auto; }
.cad-shelf-chip {
  padding: 3px 9px; border: 1px dashed rgba(255,255,255,.7); border-radius: var(--r);
  font-size: 11.5px; font-weight: 600; cursor: grab; background: rgba(0,0,0,.15);
}
.cad-shelf-chip:hover { background: rgba(0,0,0,.3); }
.cad-edit-bar .cad-bar-btn { background: rgba(0,0,0,.2) !important; color: #fff !important; border-color: rgba(255,255,255,.5) !important; }
.cad-edit-bar .cad-bar-btn.on { background: #fff !important; color: #111 !important; }
.cad-block-cover { display: none; }
body.cad-board-edit .cad-block-cover {
  position: absolute; inset: 0; z-index: 30; cursor: grab;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 10px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  outline: 2px dashed var(--accent); outline-offset: -4px;
}
.cad-block-cover span {
  font-family: var(--cond); font-weight: 700; font-size: 14px; letter-spacing: .5px; color: var(--text);
  background: var(--bg2); padding: 4px 10px; border-left: 3px solid var(--accent);
}
body.cad-board-edit #cadBoard [data-block] { min-height: 52px; }
.cad-block-cover button {
  border: 1px solid var(--borderhi); background: var(--bg2); color: var(--text); cursor: pointer;
  width: 26px; height: 26px; font-size: 13px;
}
.cad-block-cover button:hover { background: var(--reddim); border-color: var(--red); color: var(--red); }
#cadDropMark { position: fixed; z-index: 3500; pointer-events: none; background: var(--accentglow); outline: 2px solid var(--accent); }

/* ── Current call: the open call, large ─────────────────────────── */
.cad-current { flex: 1; min-height: 0; overflow-y: auto; container-type: inline-size; position: relative; }
.cad-current-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--text3); font-size: 13px; letter-spacing: .3px;
}
.cad-current:has(.inc-detail:not([style*="none"])) .cad-current-empty { display: none; }
.cad-current .inc-detail { max-height: none; border-top: 0; padding: 14px 16px 18px; overflow: visible; }
.cad-current .inc-detail:not([style*="none"]) {
  display: grid !important; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); column-gap: 18px; align-items: start;
}
.cad-current .inc-detail .dtitle { grid-column: 1 / -1; font-size: 13px; }
.cad-current .inc-detail .inc-sec-edit { grid-column: 1; grid-row: 2 / span 3; }
.cad-current .inc-detail .inc-sec-units { grid-column: 2; grid-row: 2; }
.cad-current .inc-detail .cad-timeline { grid-column: 2; grid-row: 3; }
.cad-current .inc-detail .btn-close-inc { grid-column: 2; grid-row: 4; }
.cad-current .cad-tl { max-height: min(48vh, 520px); }
@container (max-width: 620px) {
  .cad-current .inc-detail:not([style*="none"]) { grid-template-columns: minmax(0, 1fr); }
  .cad-current .inc-detail .inc-sec-edit, .cad-current .inc-detail .inc-sec-units,
  .cad-current .inc-detail .cad-timeline, .cad-current .inc-detail .btn-close-inc { grid-column: 1; grid-row: auto; }
}

/* ── Layout menu ─────────────────────────────────────────────────── */
.cad-layout-row { display: flex; align-items: center; gap: 2px; }
.cad-layout-row .cad-menu-item { flex: 1; }
.cad-mini { border: 0; background: none; color: var(--text3); cursor: pointer; padding: 4px 6px; }
.cad-mini:hover { color: var(--text); }

/* ── At a glance ─────────────────────────────────────────────────── */
.cad-glance { padding: 8px; }
.cad-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; margin-bottom: 8px; }
.cad-tile { background: var(--bg2); border: 1px solid var(--border); border-left: 3px solid var(--accent); padding: 6px 8px; border-radius: var(--r); }
.cad-tile b { display: block; font-family: var(--mono); font-size: 20px; line-height: 1.1; color: var(--text); }
.cad-tile span { font-size: 10.5px; color: var(--text2); }
.cad-tile.warn { border-left-color: var(--yellow); } .cad-tile.warn b { color: var(--yellow); }
.cad-tile.bad { border-left-color: var(--red); } .cad-tile.bad b { color: var(--red); }
.cad-tile.st { border-left-color: var(--border); } .cad-tile.st b { font-size: 16px; }
.cad-glance-depts { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.cad-glance-depts th { text-align: left; color: var(--text2); font-family: var(--cond); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; padding: 3px 4px; border-bottom: 1px solid var(--border); }
.cad-glance-depts td { padding: 3px 4px; border-bottom: 1px solid var(--border); color: var(--text); }
.cad-glance-depts i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

/* ── Scratchpad ──────────────────────────────────────────────────── */
.cad-notes {
  flex: 1; width: 100%; box-sizing: border-box; resize: none; border: 0; outline: none;
  padding: 10px 12px; background: var(--bg); color: var(--text);
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
}

/* ── Narrow screens: the columns stack ──────────────────────────── */
@media (max-width: 1040px) {
  #cadBoard { flex-direction: column; overflow-y: auto; }
  .cad-bcol { flex: none !important; }
  #cadBoard [data-block] { flex: none !important; height: 360px; }
  .cad-split2 { display: none; }
  body.cad-drawer-open #cadBoard { margin-right: 0; }
}
