/* ============================================================
   Black Rock Labs — Layout Builder editor chrome
   Visual design lifted from the approved mockup.html.
   Standalone: defines all tokens; does not require ../styles.css.
   ============================================================ */

:root {
  --gold: #e0b64f;
  --ink: #0c1114;
  --panel: #10161b;
  --card: #171f26;
  --line: rgba(255, 255, 255, 0.08);
  --txt: #f4f6f7;
  --muted: rgba(255, 255, 255, 0.55);
  --reuse: #3e7a44;
  --retrofit: #b98d2f;
  --netnew: #c8332f;
  --existing: #6d7378;
}

* { box-sizing: border-box; margin: 0; }

[hidden] { display: none !important; }

body {
  font-family: "Source Sans 3", sans-serif;
  background: var(--ink);
  color: var(--txt);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Drag states (editor.js toggles these on <body>) */
body.is-dragging,
body.is-touch-dragging {
  user-select: none;
  -webkit-user-select: none;
}
body.is-dragging { cursor: grabbing; }

/* ------------------------------------------------------------
   Toolbar
   ------------------------------------------------------------ */
.bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1.1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: "Cormorant Garamond", serif;
  font-weight: 600;
  font-size: 1.15rem;
}
.brand i { width: 3px; height: 17px; background: var(--gold); }
.brand__sub {
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  margin-left: 0.3rem;
}
.doc { font-size: 0.85rem; color: var(--muted); }
.doc b { color: var(--txt); font-weight: 600; }
.bar .spacer { flex: 1; }

.tbtn {
  font: 600 0.8rem "Source Sans 3", sans-serif;
  color: var(--txt);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
}
.tbtn:hover:not(:disabled) { border-color: rgba(224, 182, 79, 0.55); }
.tbtn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.tbtn:disabled { opacity: 0.45; cursor: not-allowed; }
.tbtn--icon { width: 34px; padding: 0.45rem 0; text-align: center; }
.tbtn--gold { background: var(--gold); border-color: var(--gold); color: #1d1503; }
.tbtn--gold:hover:not(:disabled) { border-color: #f0ca6a; background: #f0ca6a; }
.tbtn--danger {
  width: 100%;
  margin-top: 0.7rem;
  background: rgba(200, 51, 47, 0.12);
  border-color: rgba(200, 51, 47, 0.5);
  color: #f0918e;
}
.tbtn--danger:hover:not(:disabled) { border-color: var(--netnew); background: rgba(200, 51, 47, 0.2); }

/* ------------------------------------------------------------
   Layout frame
   ------------------------------------------------------------ */
.wrap {
  flex: 1;
  display: grid;
  grid-template-columns: 250px 1fr 265px;
  min-height: 0;
}
.side {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 1rem;
  overflow-y: auto;
}
.side--right { border-right: 0; border-left: 1px solid var(--line); }
.side h3 {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

/* ------------------------------------------------------------
   Machine palette
   ------------------------------------------------------------ */
.pal { display: grid; gap: 0.6rem; }
.pal-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: var(--txt);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.5rem 0.65rem;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.pal-item:hover { border-color: rgba(224, 182, 79, 0.55); }
.pal-item:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.pal-item.is-armed {
  border-color: var(--gold);
  background: rgba(224, 182, 79, 0.1);
  box-shadow: 0 0 0 1px var(--gold) inset;
}
.pal-item img {
  width: 46px;
  height: 40px;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
}
.pal-item .nm { font-size: 0.82rem; font-weight: 600; line-height: 1.15; }
.pal-item .ft { font-size: 0.68rem; color: var(--muted); }
.disp-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  vertical-align: baseline;
}
.pal-hint {
  margin-top: 0.9rem;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.45;
}

/* ------------------------------------------------------------
   Stage + canvas
   ------------------------------------------------------------ */
.stage {
  position: relative;
  overflow: hidden;
  min-width: 0;
  background: radial-gradient(120% 100% at 50% 0%, #131b21 0%, #0b1014 70%);
}
#iso-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
#iso-canvas:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
#iso-canvas.pointer-focus:focus-visible { outline: none; }

.stage .zoom {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.badge {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  font-size: 0.7rem;
  color: var(--muted);
  background: rgba(16, 22, 27, 0.8);
  border: 1px solid var(--line);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  pointer-events: none;
}

/* ------------------------------------------------------------
   Inspector cards
   ------------------------------------------------------------ */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.8rem 0.9rem;
  margin-bottom: 0.9rem;
}
.card .lbl {
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.sel-name { font-family: "Prata", serif; font-size: 1.05rem; margin-bottom: 0.15rem; }
.sel-pos { font-size: 0.72rem; color: var(--muted); margin-bottom: 0.7rem; }

/* Disposition pills */
.disp { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.disp button {
  font: 600 0.68rem "Source Sans 3", sans-serif;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}
.disp button:hover:not(:disabled) { border-color: rgba(255, 255, 255, 0.3); color: var(--txt); }
.disp button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.disp button:disabled { opacity: 0.35; cursor: not-allowed; }
.disp .on-existing { background: rgba(109, 115, 120, 0.22); border-color: var(--existing); color: #c3c9ce; }
.disp .on-reuse    { background: rgba(62, 122, 68, 0.18);  border-color: var(--reuse);    color: #8fce96; }
.disp .on-retrofit { background: rgba(185, 141, 47, 0.18); border-color: var(--retrofit); color: #ffcf5c; }
.disp .on-new      { background: rgba(200, 51, 47, 0.18);  border-color: var(--netnew);   color: #f0918e; }

/* Layout score */
.stat-big { font-family: "Prata", serif; font-size: 1.7rem; }
.stat-sub { font-size: 0.55em; color: var(--muted); }
.rbar {
  display: flex;
  height: 16px;
  border-radius: 5px;
  overflow: hidden;
  margin: 0.5rem 0 0.4rem;
  font-size: 0;
  background: rgba(255, 255, 255, 0.06);
}
.rbar span { width: 0; transition: width 200ms ease; }
.rbar [data-seg="reuse"]    { background: var(--reuse); }
.rbar [data-seg="retrofit"] { background: var(--retrofit); }
.rbar [data-seg="new"]      { background: var(--netnew); }
.rkey { font-size: 0.68rem; color: var(--muted); }

/* CapEx */
.capex {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  padding: 0.28rem 0;
}
.capex b { font-weight: 600; }
.capex-total { color: var(--gold); }

/* Gold CTA below the cards */
.cta { width: 100%; margin-top: 0.4rem; padding: 0.7rem; font-size: 0.85rem; }

/* ------------------------------------------------------------
   Screen-reader-only live region
   ------------------------------------------------------------ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------
   Reduced motion
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* -- right-click context menu + details form -- */
.ctx-menu,
.ctx-form {
  position: absolute;
  z-index: 40;
  background: #171f26;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  padding: 0.35rem;
  min-width: 160px;
}

.ctx-menu button {
  display: block;
  width: 100%;
  text-align: left;
  font: 600 0.82rem "Source Sans 3", sans-serif;
  color: #f4f6f7;
  background: transparent;
  border: 0;
  border-radius: 7px;
  padding: 0.5rem 0.7rem;
  cursor: pointer;
}

.ctx-menu button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.ctx-menu .ctx-danger:hover {
  background: rgba(200, 51, 47, 0.22);
  color: #ff9d9a;
}

.ctx-form {
  width: 260px;
  padding: 0.9rem 1rem 1rem;
}

.ctx-form h4 {
  margin: 0 0 0.7rem;
  font: 600 0.9rem "Source Sans 3", sans-serif;
  color: #f4f6f7;
}

.ctx-form label {
  display: block;
  font: 600 0.66rem "Source Sans 3", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 0.6rem;
}

.ctx-form input {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.45rem 0.6rem;
  font: 400 0.85rem "Source Sans 3", sans-serif;
  color: #f4f6f7;
  background: #10161b;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  box-sizing: border-box;
}

.ctx-form input:focus {
  outline: none;
  border-color: rgba(224, 182, 79, 0.7);
}

.ctx-form__row {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.4rem;
}

.ctx-form__row button {
  font: 600 0.8rem "Source Sans 3", sans-serif;
  padding: 0.45rem 0.9rem;
  border-radius: 7px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: #f4f6f7;
}

.ctx-form__row .ctx-primary {
  background: #e0b64f;
  border-color: #e0b64f;
  color: #1d1503;
}
