/* styles-freebuild.css — Phase D4: free-build mode with a live narrator
   (ui/freebuild.js). Tokens only (styles.css / styles-v2.css), so light and
   dark both come from the theme. Layout is a container query on the free-
   build root: narrator beside the workbench when there is room for both,
   stacked — narrator first, latest entry only — when there is not. */

.fb-root{container-type:inline-size;display:flex;flex-direction:column;gap:12px;min-width:0}

/* ---- bar ---- */
.fb-bar{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}
.fb-bar-title{min-width:0;flex:1 1 220px}
.fb-bar-title b{font-size:14px;font-weight:600;color:var(--ink-2);line-height:1.4}
.fb-bar-actions{display:flex;gap:8px;flex-wrap:wrap}
.fb-bar-actions .btn{font-size:13px;padding:6px 12px}
.fb-bar-actions .btn:disabled{opacity:.5;cursor:not-allowed}

/* ---- grid ---- */
.fb-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:14px;align-items:start;min-width:0}
.fb-grid > *{min-width:0}
.fb-wb{margin-top:0}
/* stacked: the narrator sits ABOVE the workbench, so a placement's entry
   lands right next to the canvas it came from */
.fb-narrator{order:-1}

/* ---- narrator ---- */
.fb-narrator{
  display:flex;flex-direction:column;gap:10px;
  background:var(--surface);border:1px solid var(--rule);border-left:3px solid var(--accent);
  border-radius:8px;padding:12px 14px;box-shadow:var(--elev-1);
}
.fb-narrator-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.fb-narrator-head b{font-size:14px;font-weight:700;color:var(--ink)}
.fb-narrator-sub{font-size:11.5px;color:var(--ink-3);flex:1 1 auto;min-width:0}
.fb-more{margin-left:auto;font-size:12px;padding:3px 10px}
.fb-dot{width:8px;height:8px;border-radius:50%;background:var(--good);flex:none;
  box-shadow:0 0 0 3px color-mix(in srgb,var(--good) 22%,transparent)}

.fb-summary{margin:0;font-size:13px;line-height:1.45;color:var(--ink-2);
  padding:7px 10px;border-radius:6px;background:var(--surface-2);overflow-wrap:anywhere}
.fb-summary-label{font-weight:700;color:var(--ink)}
.fb-summary-body{font-family:var(--mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);font-size:12.5px}

.fb-hints[hidden]{display:none}
.fb-hint-text{margin:0 0 6px;font-size:13px;color:var(--ink-2);line-height:1.45}
.fb-chips{display:flex;flex-wrap:wrap;gap:6px}
.fb-chip{
  font:inherit;font-size:12.5px;font-weight:600;cursor:pointer;
  padding:5px 11px;min-height:32px;border-radius:999px;
  border:1px solid color-mix(in srgb,var(--accent) 45%,var(--rule));
  background:var(--accent-soft);color:var(--accent);
}
.fb-chip:hover:not(:disabled){background:color-mix(in srgb,var(--accent) 18%,var(--surface))}
.fb-chip:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.fb-chip:disabled{opacity:.45;cursor:not-allowed}

/* ---- feed ---- */
.fb-feed{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px;
  overflow-y:auto;overscroll-behavior:contain;min-width:0}
.fb-empty{font-size:13px;color:var(--ink-3);padding:10px;border:1px dashed var(--rule-2);border-radius:6px;text-align:center}
.fb-entry{
  display:grid;grid-template-columns:34px minmax(0,1fr);gap:10px;align-items:start;
  padding:10px;border-radius:8px;border:1px solid var(--rule);background:var(--surface-2);
  transition:background-color .9s ease,border-color .9s ease,box-shadow .9s ease;
}
.fb-badge{
  width:34px;height:34px;border-radius:7px;display:flex;align-items:center;justify-content:center;
  font-weight:800;font-size:12.5px;letter-spacing:-.02em;
  background:var(--accent);color:var(--on-accent);
}
.fb-remove .fb-badge,.fb-clear.fb-entry .fb-badge{background:var(--surface-3);color:var(--ink-2)}
.fb-resize .fb-badge,.fb-batch .fb-badge{background:var(--warn-soft);color:var(--warn)}
.fb-entry-body{min-width:0;display:flex;flex-direction:column;gap:4px}
.fb-entry-title{font-size:13.5px;font-weight:700;color:var(--ink);line-height:1.35}
.fb-entry-body p{margin:0;font-size:13px;line-height:1.45;color:var(--ink-2);overflow-wrap:anywhere}
.fb-k{display:block;font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--ink-3);margin-bottom:1px}
.fb-did{color:var(--ink) !important}
.fb-note{font-size:12.5px !important;color:var(--good) !important;
  padding:5px 8px;border-radius:5px;background:var(--good-soft)}
.fb-state code{font-family:var(--mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  font-size:12.5px;color:var(--ink);background:var(--surface);border:1px solid var(--rule);
  border-radius:4px;padding:1px 5px;display:inline-block;max-width:100%;overflow-wrap:anywhere}

/* the entry that just landed — a fade, never a transform */
.fb-entry.fb-flash{
  background:var(--accent-soft);border-color:var(--accent);
  box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 22%,transparent);
  transition:none;
}
:root[data-reduced-motion="true"] .fb-entry{transition:none}
@media (prefers-reduced-motion: reduce){.fb-entry{transition:none}}

/* stacked: only the latest entry unless the learner opens the history */
.fb-narrator:not(.fb-expanded) .fb-entry ~ .fb-entry{display:none}
.fb-narrator.fb-expanded .fb-feed{max-height:420px}

/* ---- wide: narrator beside the workbench, sticky, full history ---- */
@container (min-width: 900px){
  .fb-grid{grid-template-columns:minmax(0,1fr) clamp(280px,32%,340px)}
  .fb-narrator{
    order:0;position:sticky;top:calc(var(--topbar-h, 56px) + 12px);
    max-height:calc(100vh - var(--topbar-h, 56px) - 24px);
  }
  .fb-feed{flex:1 1 auto;min-height:0}
  .fb-narrator:not(.fb-expanded) .fb-entry ~ .fb-entry{display:grid}
  .fb-narrator .fb-entry ~ .fb-entry{opacity:.86}
  .fb-more{display:none}
  /* the canvas column is narrower than the full Build view here */
  .fb-wb .wb-inline{grid-template-columns:minmax(0,1fr) !important}
  .fb-wb .wb-inline .palette{grid-template-columns:repeat(auto-fill,minmax(46px,1fr))}
}

/* ---- phone ---- */
@container (max-width: 480px){
  .fb-narrator{padding:10px 11px}
  .fb-entry{grid-template-columns:28px minmax(0,1fr);gap:8px;padding:8px}
  .fb-badge{width:28px;height:28px;font-size:11px}
  .fb-bar-actions{width:100%}
  .fb-bar-actions .btn{flex:1 1 0}
  .fb-narrator-sub{display:none}
}
