/* style.css — cookbook/4-rich-3col-header — `.demo-mini-builder--rich-3col-header`.
 *
 * Self-contained chrome variant (W6.C.B.4). Pair this file with init.js
 * (sibling) and dist/builder.css + dist/builder.js, and you have a fully-
 * working Builder mount in 4 files. NO shared mini-builder.css. NO
 * examples.css. The `.demo-mini-builder--rich-3col-header` rules below
 * ARE the variant — copy them verbatim into your own stylesheet.
 *
 * ─── Buyer use case ─────────────────────────────────────────────────
 * Full SaaS feel. Three sub-systems wired (widgets · canvas · settings)
 * PLUS an in-wrapper header strip with action buttons. This is the FIRST
 * cookbook entry where Save / Undo / Redo / Export / Preview live INSIDE
 * the engine's own chrome, not in a host-supplied toolbar above the
 * wrapper. Pick this when your host app delegates the whole top of the
 * editor to BuilderJS.
 *
 * ─── In-wrapper header vs host toolbar ─────────────────────────────
 * `2-compact-2col` and `3-compact-3col` ship a `.demo-host-toolbar`
 * convention — the action button(s) live OUTSIDE the wrapper, in the
 * host page's own bar. That works when the variant has no header slot.
 *
 * `4-rich-3col-header` is the alternative: the variant declares a 48 px
 * `__header` slot at the top, sized as the first row of the grid. Action
 * buttons live INSIDE the wrapper. Buyers learn ONE rule — "if the
 * variant has a header slot, put the chrome there; otherwise host
 * toolbar above". The handlers stay identical either way (button click →
 * `builder.<method>()`).
 *
 * ─── Constructor (no null args) ─────────────────────────────────────
 *   new Builder({
 *       mainContainer:     '#YourCanvas',
 *       widgetsContainer:  '#YourWidgets',
 *       settingsContainer: '#YourSettings',
 *   });
 * All three sub-systems mount cleanly. Same shape as `3-compact-3col`;
 * the only difference is where the action row lives.
 *
 * ─── Tokens consumed (already exposed by dist/builder.css) ──────────
 *   --bjs-bg, --bjs-bg-subtle, --bjs-border, --bjs-border-light,
 *   --bjs-radius-lg, --bjs-radius-md, --bjs-text, --bjs-text-secondary,
 *   --bjs-fs-sm, --bjs-fs-base, --bjs-space-1, --bjs-space-2,
 *   --bjs-space-3, --bjs-primary.
 */

/* ─── Base wrapper (5-slot grid; canvas-only fallback) ─────────────── */
.demo-mini-builder {
    display: grid;
    width: 100%;
    height: 520px;
    border: 1px solid var(--bjs-border);
    border-radius: var(--bjs-radius-lg);
    background: var(--bjs-bg);
    color: var(--bjs-text);
    font-size: var(--bjs-fs-base);
    overflow: hidden;
    box-sizing: border-box;
    grid-template-areas: "canvas";
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}

.demo-mini-builder *,
.demo-mini-builder *::before,
.demo-mini-builder *::after { box-sizing: border-box; }

.demo-mini-builder__header,
.demo-mini-builder__widgets,
.demo-mini-builder__canvas,
.demo-mini-builder__settings {
    overflow: auto;
    min-height: 0;
    min-width: 0;
}

.demo-mini-builder__header {
    grid-area: header;
    background: var(--bjs-bg-subtle);
    border-bottom: 1px solid var(--bjs-border-light);
    padding: 0 var(--bjs-space-3);
    display: flex;
    align-items: center;
    gap: var(--bjs-space-2);
    font-size: var(--bjs-fs-sm);
    color: var(--bjs-text-secondary);
}

.demo-mini-builder__widgets {
    grid-area: widgets;
    background: var(--bjs-bg-subtle);
    border-right: 1px solid var(--bjs-border-light);
    padding: var(--bjs-space-2);
}

.demo-mini-builder__canvas {
    grid-area: canvas;
    background: var(--bjs-bg);
    position: relative;
}

.demo-mini-builder__settings {
    grid-area: settings;
    background: var(--bjs-bg-subtle);
    border-left: 1px solid var(--bjs-border-light);
    padding: var(--bjs-space-2);
}

/* ─── Variant: --rich-3col-header ── 3-col + header actions row ──────
 *
 * Two-row · three-column grid:
 *
 *   ┌─────────── header (48 px) ────────────┐
 *   ├──────┬─────────────────────┬─────────┤
 *   │ wid- │     canvas          │ settings │
 *   │ gets │    (1fr · auto-grow)│   (280) │
 *   │ (220)│                     │          │
 *   └──────┴─────────────────────┴─────────┘
 *
 * Sidebars sized for SaaS app-chrome at 1280 px+ — 220 px widgets,
 * 280 px settings (vs `--compact-3col`'s 200 / 240). The wider settings
 * column gives format controls more breathing room because the header
 * action row absorbed the host toolbar's "advanced controls live up
 * here" affordance.
 */
.demo-mini-builder--rich-3col-header {
    grid-template-areas:
        "header  header  header"
        "widgets canvas  settings";
    grid-template-rows: 48px 1fr;
    grid-template-columns: 220px 1fr 280px;
}

/* ─── Header action row ──────────────────────────────────────────────
 *
 * Title on the left (`__title`) takes the leading slot; spacer pushes
 * the action buttons to the right. Each `__action` is a flat-tone
 * button with hover / focus / active states pulled from the same
 * tokens the engine's own chrome uses, so the row never reads as a
 * second design system grafted on top.
 *
 * `__action--primary` is reserved for the Save button — accent
 * background, white label — so the buyer's eye lands on the most-used
 * action without reading every label. Other actions stay neutral.
 *
 * `[hidden]` honours the `disabled` state: actions that aren't
 * applicable right now (e.g. Undo when history is empty) get
 * `disabled` set — a buyer-supplied `history:change` event listener
 * (see `events/3-history-change/`) toggles those flags reactively.
 */
.demo-mini-builder__title {
    flex: 1;
    margin-right: auto;
    font-weight: 600;
    color: var(--bjs-text);
    font-size: var(--bjs-fs-base);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.demo-mini-builder__actions {
    display: inline-flex;
    align-items: center;
    gap: var(--bjs-space-1);
}

.demo-mini-builder__action {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid var(--bjs-border-light);
    background: var(--bjs-bg);
    color: var(--bjs-text);
    padding: 4px 10px;
    border-radius: var(--bjs-radius-md);
    font: inherit;
    font-size: var(--bjs-fs-sm);
    line-height: 1.2;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease,
                color 120ms ease, transform 60ms ease;
}
.demo-mini-builder__action:hover {
    background: var(--bjs-bg-subtle);
    border-color: var(--bjs-border);
}
.demo-mini-builder__action:focus-visible {
    outline: 2px solid var(--bjs-primary);
    outline-offset: 2px;
}
.demo-mini-builder__action:active {
    transform: translateY(1px);
}
.demo-mini-builder__action[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.demo-mini-builder__action--primary {
    background: var(--bjs-primary);
    border-color: var(--bjs-primary);
    color: #fff;
}
.demo-mini-builder__action--primary:hover {
    filter: brightness(0.92);
    background: var(--bjs-primary);
    border-color: var(--bjs-primary);
}

/* Preview-mode flag: when the action row toggles `is-previewing`,
 * the Preview button's label flips to "Edit" via JS, and the wrapper
 * gets a subtle inset shadow so the buyer SEES they're in a non-
 * editable mode. Optional polish — drop this rule if you don't want
 * the visual cue. */
.demo-mini-builder.is-previewing .demo-mini-builder__canvas {
    box-shadow: inset 0 0 0 2px var(--bjs-primary);
}

@media (prefers-reduced-motion: reduce) {
    .demo-mini-builder, .demo-mini-builder *,
    .demo-mini-builder__action { transition: none; }
}
