/* frikwork builder — page chrome.
 *
 * Deliberately thin. The control rail sits OUTSIDE #fw-preview, so it renders on stock
 * frikwork tokens and is built from real frikwork components — which means it stays
 * legible no matter how mad the theme being previewed gets, and the builder dogfoods
 * the framework it builds for. Only layout and a few bespoke widgets live here.
 */

.b-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 0;
  min-height: calc(100vh - 64px);
}

/* --- control rail --- */
.b-rail {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow-y: auto;
  padding: var(--fw-space-lg);
  border-right: 1px solid var(--fw-border);
  background: var(--fw-bg-2);
}
.b-rail__title {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 600; color: var(--fw-text-muted);
  margin: 0 0 var(--fw-space-sm);
}
.b-section { border-bottom: 1px solid var(--fw-border); padding: var(--fw-space-md) 0; }
.b-section:last-of-type { border-bottom: 0; }
.b-section > summary {
  cursor: pointer; list-style: none;
  font-weight: 600; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--fw-space-sm);
}
.b-section > summary::-webkit-details-marker { display: none; }
.b-section > summary::after {
  content: '';
  width: 7px; height: 7px;
  border-right: 2px solid var(--fw-text-muted);
  border-bottom: 2px solid var(--fw-text-muted);
  transform: rotate(45deg);
  transition: transform var(--fw-dur) ease;
}
.b-section[open] > summary::after { transform: rotate(-135deg); }
.b-section__body { padding-top: var(--fw-space-md); }

/* --- drop zone --- */
.b-drop {
  display: grid; place-items: center; gap: var(--fw-space-xs);
  padding: var(--fw-space-lg);
  text-align: center;
  border: 1px dashed var(--fw-border);
  border-radius: var(--fw-radius-md);
  color: var(--fw-text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color var(--fw-dur) ease, background var(--fw-dur) ease;
}
.b-drop:hover, .b-drop.is-over { border-color: var(--fw-brand); background: var(--fw-bg-hover); }
.b-drop img { max-width: 100%; max-height: 80px; object-fit: contain; }

/* --- swatch rows --- */
.b-swatches { display: flex; flex-wrap: wrap; gap: var(--fw-space-xs); }
.b-chip {
  width: 30px; height: 30px;
  border-radius: var(--fw-radius-sm);
  border: 1px solid var(--fw-border);
  cursor: pointer;
  padding: 0;
  transition: transform var(--fw-dur-fast) ease;
}
.b-chip:hover { transform: scale(1.12); }

.b-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: var(--fw-space-sm);
  padding: 0.35rem 0;
}
.b-row__hex {
  font-family: var(--fw-font-mono);
  font-size: 0.78rem;
  width: 100%;
  padding: 0.25rem var(--fw-space-sm);
  background: var(--fw-bg);
  color: var(--fw-text);
  border: 1px solid var(--fw-border);
  border-radius: var(--fw-radius-sm);
}
.b-row__role {
  font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--fw-text-muted); white-space: nowrap;
}
.b-swatch-btn {
  width: 26px; height: 26px; flex-shrink: 0;
  border-radius: var(--fw-radius-sm);
  border: 1px solid var(--fw-border);
  padding: 0; cursor: pointer;
}

/* --- colour wheel --- */
.b-wheel { display: block; margin: 0 auto var(--fw-space-md); cursor: crosshair; border-radius: 50%; }
.b-harmony-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--fw-space-xs); }

/* --- font list --- */
.b-fontlist { max-height: 220px; overflow-y: auto; margin-top: var(--fw-space-sm); }
.b-fontitem {
  display: block; width: 100%; text-align: left;
  padding: var(--fw-space-sm);
  background: transparent; border: 0; border-radius: var(--fw-radius-sm);
  color: var(--fw-text); cursor: pointer; font-size: 0.95rem;
}
.b-fontitem:hover { background: var(--fw-bg-hover); }
.b-fontitem.is-active { background: color-mix(in srgb, var(--fw-brand) 14%, transparent); color: var(--fw-brand-text); }
.b-fontitem small { display: block; font-size: 0.65rem; color: var(--fw-text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* --- preview --- */
.b-preview-wrap { min-width: 0; display: flex; flex-direction: column; }
.b-preview-bar {
  display: flex; align-items: center; gap: var(--fw-space-sm);
  flex-wrap: wrap;
  padding: var(--fw-space-sm) var(--fw-space-lg);
  border-bottom: 1px solid var(--fw-border);
  background: var(--fw-bg-2);
  position: sticky; top: 0; z-index: 5;
}
.b-preview-bar__spacer { flex: 1 1 auto; }

/* The live-themed region. Every --fw-* token is written here as an inline style, so
   nothing inside inherits the page's stock theme and nothing outside is affected. */
.b-preview {
  flex: 1 1 auto;
  padding: var(--fw-space-xl);
  background: var(--fw-bg);
  color: var(--fw-text);
  font-family: var(--fw-font);
  overflow-x: hidden;
}
.b-preview h1, .b-preview h2, .b-preview h3 { font-family: var(--fw-font-heading); }
.b-demo-block { margin-bottom: var(--fw-space-xl); }
.b-demo-block > h3 {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--fw-text-muted); margin: 0 0 var(--fw-space-md);
  padding-bottom: var(--fw-space-xs); border-bottom: 1px solid var(--fw-border);
}
.b-chartstrip { display: flex; gap: 2px; border-radius: var(--fw-radius-sm); overflow: hidden; }
.b-chartstrip > div {
  flex: 1; height: 44px;
  display: grid; place-items: end center;
  font-size: 0.6rem; font-weight: 600; padding-bottom: 3px;
  color: var(--fw-bg);
}

/* --- responsive: rail becomes a collapsible sheet --- */
@media (max-width: 900px) {
  .b-shell { grid-template-columns: 1fr; }
  .b-rail {
    position: static; max-height: none;
    border-right: 0; border-bottom: 1px solid var(--fw-border);
  }
  .b-preview { padding: var(--fw-space-md); }
}
