/* Scene Builder (composer). Classes are prefixed cmp-. Tokens only; artwork colours live in the SVG art. */

/* ---------------------------------------------------------------- gallery */

.cmp-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--s-5);
}
.cmp-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 90ms ease-out, box-shadow 90ms ease-out;
}
.cmp-card:hover { transform: translate(-1px, -1px); box-shadow: var(--shadow-md); }
.cmp-card:active { transform: translate(1px, 1px); box-shadow: none; }
.cmp-card:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.cmp-card-thumb {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--surface-sunken);
  border-bottom: var(--bw) solid var(--line);
}
.cmp-card-thumb img { display: block; max-width: 100%; max-height: 100%; width: 100%; height: auto; object-fit: contain; }
.cmp-card-thumb.is-plan img { width: auto; height: 100%; }
.cmp-card-mode {
  position: absolute;
  left: 8px;
  top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px 2px 6px;
  font: 700 11px/1.5 var(--font-ui);
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--r-pill);
}
.cmp-card-body { display: flex; align-items: flex-start; gap: var(--s-2); padding: 10px 8px 0 14px; min-width: 0; }
.cmp-card-titles { flex: 1 1 auto; min-width: 0; }
.cmp-card-title { font: 600 var(--fs-lg)/1.25 var(--font-display); }
.cmp-card-sub { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 2px; }
.cmp-card-meta { padding: 4px 14px 12px; font-size: var(--fs-xs); color: var(--text-2); }
.cmp-dot { color: var(--text-muted); }
.cmp-card-new {
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 220px;
  padding: var(--s-5);
  text-align: center;
  font: inherit;
  background: transparent;
  border-style: dashed;
  box-shadow: none;
}
.cmp-card-new:hover { background: var(--magenta-soft); box-shadow: none; }

.cmp-empty { max-width: 860px; margin: var(--s-6) auto 0; }
.cmp-starters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-4);
  margin-top: var(--s-5);
}
.cmp-starter {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: var(--s-5);
  text-align: left;
  font: inherit;
  color: var(--text);
  background: var(--c-soft);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: transform 90ms ease-out, box-shadow 90ms ease-out;
}
.cmp-starter:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 0 var(--shadow-color); }
.cmp-starter:active { transform: translate(2px, 2px); box-shadow: var(--shadow-sm); }
.cmp-starter-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 4px;
  color: var(--on-candy);
  background: var(--c);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.cmp-starter-title { font: 600 var(--fs-xl)/1.2 var(--font-display); }
.cmp-starter-text { font-size: var(--fs-sm); color: var(--text-2); line-height: 1.45; }
@media (max-width: 900px) { .cmp-starters { grid-template-columns: 1fr; } }

.cmp-picker { display: flex; flex-direction: column; gap: var(--s-3); min-height: 0; }
.cmp-picker-list { max-height: 52vh; }
.cmp-picker-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 0;
  cursor: pointer;
}
.cmp-picker-item:hover { background: var(--hover); }
.cmp-picker-item .list-item-title,
.cmp-picker-item .list-item-sub { display: block; }
.cmp-picker-item .list-item-title { font-family: var(--font-script); font-weight: 700; }
.cmp-picker-num {
  flex: none;
  min-width: 34px;
  padding: 2px 6px;
  text-align: center;
  font: 700 var(--fs-sm)/1.4 var(--font-ui);
  color: var(--text);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
/* strip colour code: what the scene's INT/EXT and time of day mean on the stripboard */
.cmp-picker-num[data-color] { background: var(--c-soft); border: 1.5px solid var(--line); }
.cmp-strip-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  vertical-align: -1px;
  background: var(--c-soft);
  border: 1.5px solid var(--line);
  border-radius: 2px;
}

/* ---------------------------------------------------------------- editor layout */

.cmp-docname { min-width: 120px; max-width: 260px; font-weight: 700; }
.cmp-editor { position: relative; }
.cmp-workspace { display: flex; flex: 1 1 auto; min-height: 0; min-width: 0; }
.cmp-stage-wrap {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  padding: var(--s-3);
  background: var(--surface-2);
}
.cmp-well { flex: 1 1 auto; outline: none; touch-action: none; }
.cmp-well:focus-visible { box-shadow: 0 0 0 3px var(--focus); }
.cmp-svg { display: block; user-select: none; -webkit-user-select: none; }
.cmp-tool-pan .cmp-svg { cursor: grab; }
.cmp-tool-path .cmp-svg,
.cmp-tool-wall .cmp-svg { cursor: crosshair; }
.cmp-tool-text .cmp-svg { cursor: text; }

.cmp-rail { position: absolute; left: calc(var(--s-3) + 10px); top: calc(var(--s-3) + 10px); z-index: 5; }
.cmp-rail .tool-btn { --c: var(--magenta); }
.cmp-zoom {
  right: calc(var(--s-3) + 10px);
  bottom: calc(var(--s-3) + 10px);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
}
.cmp-zoom-val {
  min-width: 52px;
  padding: 4px 6px;
  font: 700 var(--fs-sm)/1 var(--font-ui);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.cmp-zoom-val:hover { background: var(--hover); }
.cmp-hintbar,
.cmp-coach {
  left: 50%;
  bottom: calc(var(--s-3) + 12px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 220px);
  padding: 7px 14px;
  font-size: var(--fs-sm);
  pointer-events: none;
}
.cmp-coach { color: var(--text-2); }
.cmp-aibar {
  left: 50%;
  top: calc(var(--s-3) + 12px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 6px 8px 6px 12px;
  font-size: var(--fs-sm);
  background: var(--c-soft);
}
.cmp-ghost {
  position: fixed;
  z-index: var(--z-popover);
  width: 86px;
  height: 86px;
  margin: -43px 0 0 -43px;
  padding: 6px;
  pointer-events: none;
  background: var(--surface);
  border: var(--bw) solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  opacity: 0.92;
}
.cmp-ghost img { width: 100%; height: 100%; object-fit: contain; }

/* stage drawing (SVG) */
.cmp-paper-shadow { fill: var(--shadow-color); }
.cmp-paper-edge { fill: none; stroke: var(--line); stroke-width: 2px; vector-effect: non-scaling-stroke; pointer-events: none; }
.cmp-nohit, .cmp-guides, .cmp-ai-preview { pointer-events: none; }
.cmp-item { cursor: move; }
.cmp-tool-pan .cmp-item, .cmp-tool-path .cmp-item, .cmp-tool-wall .cmp-item, .cmp-tool-text .cmp-item { cursor: inherit; }
.cmp-item.is-locked { cursor: default; }
.cmp-item.is-ghost { opacity: 0.55; }
.cmp-sel,
.cmp-sel-union,
.cmp-sel-path,
.cmp-sel-stem,
.cmp-marquee,
.cmp-guide,
.cmp-draft-wall {
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
.cmp-sel { fill: none; stroke: var(--magenta); stroke-width: 2px; }
.cmp-sel.is-locked { stroke: var(--text-muted); stroke-dasharray: 5 4; }
.cmp-sel-union { fill: none; stroke: var(--magenta); stroke-width: 1.5px; stroke-dasharray: 6 4; }
.cmp-sel-path { fill: none; stroke: var(--magenta); stroke-width: 6px; stroke-opacity: 0.35; stroke-linecap: round; stroke-linejoin: round; }
.cmp-sel-stem { stroke: var(--magenta); stroke-width: 2px; }
.cmp-handle { fill: var(--surface); stroke: var(--line); stroke-width: 2px; vector-effect: non-scaling-stroke; }
.cmp-handle:hover { fill: var(--magenta); }
.cmp-handle-nw, .cmp-handle-se { cursor: nwse-resize; }
.cmp-handle-ne, .cmp-handle-sw { cursor: nesw-resize; }
.cmp-handle-rot { fill: var(--magenta); cursor: grab; }
.cmp-selection circle.cmp-handle:not(.cmp-handle-rot) { cursor: grab; fill: transparent; stroke: var(--magenta); stroke-width: 3px; }
.cmp-selection circle.cmp-handle:not(.cmp-handle-rot):hover { fill: var(--magenta); fill-opacity: 0.3; }
.cmp-marquee { fill: var(--magenta-soft); fill-opacity: 0.35; stroke: var(--magenta); stroke-width: 1.5px; stroke-dasharray: 5 4; }
.cmp-guide { stroke: var(--magenta); stroke-width: 1px; }
.cmp-draft-wall { stroke: var(--magenta); stroke-opacity: 0.7; vector-effect: none; stroke-linecap: square; }

.cmp-g-thirds { stroke: #FFFFFF; stroke-opacity: 0.75; stroke-width: 1.5px; vector-effect: non-scaling-stroke; stroke-dasharray: 8 6; }
.cmp-g-safe { fill: none; stroke: #FFFFFF; stroke-opacity: 0.6; stroke-width: 1.5px; vector-effect: non-scaling-stroke; stroke-dasharray: 4 4; }
.cmp-g-safe.is-title { stroke: #FFE45C; stroke-opacity: 0.85; }
.cmp-g-label { fill: #FFFFFF; font-family: var(--font-ui); font-weight: 700; paint-order: stroke; stroke: #1B1530; stroke-width: 3px; stroke-opacity: 0.6; }
.cmp-g-bars { fill: #000000; fill-opacity: 0.82; }
.cmp-g-cropmask { fill: #0B0716; fill-opacity: 0.5; }
.cmp-g-crop { fill: none; stroke: #FFE45C; stroke-width: 2.5px; vector-effect: non-scaling-stroke; }
.cmp-g-croptag { fill: #FFE45C; stroke: #1B1530; stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.cmp-g-croptext { fill: #1B1530; font-family: var(--font-ui); font-weight: 800; }

.cmp-text-edit {
  position: absolute;
  z-index: 6;
  min-width: 140px;
  padding: 6px 8px;
  font-family: var(--font-ui);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  background: var(--surface);
  border: var(--bw) solid var(--magenta);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-md);
  resize: none;
  outline: none;
}

/* ---------------------------------------------------------------- library */

.cmp-lib {
  display: flex;
  flex-direction: column;
  flex: none;
  width: 272px;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.cmp-lib-head { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-3); border-bottom: 1px solid var(--border); }
.cmp-lib-cats { display: flex; flex-wrap: wrap; gap: 4px; }
.cmp-cat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 5px;
  font: 600 var(--fs-xs)/1.4 var(--font-ui);
  color: var(--text-2);
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--r-pill);
  cursor: pointer;
}
.cmp-cat svg { color: var(--c-ink); }
.cmp-cat:hover { background: var(--c-soft); color: var(--text); }
.cmp-cat.is-active { color: var(--on-candy); background: var(--c); border-color: var(--line); }
.cmp-cat.is-active svg { color: var(--on-candy); }
.cmp-cat:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.cmp-lib-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-content: start;
  gap: 6px;
  flex: 1 1 auto;
  min-height: 0;
  padding: var(--s-3);
  overflow-y: auto;
}
.cmp-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  min-width: 0;
  padding: 4px 4px 5px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  cursor: grab;
  touch-action: none;
}
.cmp-tile:hover { border-color: var(--line); box-shadow: var(--shadow-sm); transform: translate(-1px, -1px); }
.cmp-tile:active { cursor: grabbing; }
.cmp-tile:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.cmp-tile.is-wide { grid-column: span 3; flex-direction: row; align-items: center; gap: 8px; }
.cmp-tile.is-current { border-color: var(--magenta); box-shadow: 0 0 0 1.5px var(--magenta); }
.cmp-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--paper);
  border-radius: var(--r-xs);
}
.cmp-thumb.is-dark { background: var(--line); }
.cmp-thumb img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.cmp-thumb.is-backdrop { flex: none; width: 112px; aspect-ratio: 16 / 9; }
.cmp-thumb.is-backdrop img { object-fit: cover; }
.cmp-tile-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  line-height: 1.3;
  text-align: center;
  color: var(--text-2);
}
.cmp-tile.is-wide .cmp-tile-name { font-size: var(--fs-sm); font-weight: 600; text-align: left; color: var(--text); flex: 1 1 auto; }
.cmp-tile-badge {
  flex: none;
  padding: 1px 7px;
  font: 700 10px/1.5 var(--font-ui);
  color: var(--on-candy);
  background: var(--magenta);
  border: 1.5px solid var(--line);
  border-radius: var(--r-pill);
}
.cmp-lib-empty { grid-column: 1 / -1; margin: var(--s-4) 0; text-align: center; font-size: var(--fs-sm); color: var(--text-muted); }
.cmp-lib-foot { padding: 8px var(--s-3); font-size: var(--fs-xs); color: var(--text-muted); border-top: 1px solid var(--border); }

/* ---------------------------------------------------------------- inspector and layers */

.cmp-aside {
  display: flex;
  flex-direction: column;
  height: calc(100% + 2 * var(--s-4));
  margin: calc(-1 * var(--s-4));
  min-height: 0;
}
.cmp-aside > .tabs, .cmp-aside > [role='tablist'] { flex: none; padding: 0 var(--s-3); }
.cmp-aside-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.cmp-insp-title { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 700; }
.cmp-insp-title > :last-child { flex: 1 1 auto; min-width: 0; }
.cmp-insp-icon, .cmp-layer-icon {
  display: grid;
  place-items: center;
  flex: none;
  color: var(--on-candy);
  background: var(--c);
  border: 1.5px solid var(--line);
}
.cmp-insp-icon { width: 30px; height: 30px; border-radius: var(--r-sm); }
.cmp-insp-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.cmp-grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.cmp-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.cmp-params { display: flex; flex-direction: column; gap: 10px; }
.cmp-swatches { display: flex; flex-wrap: wrap; gap: 5px; }
.cmp-swatch {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 80ms ease-out;
}
.cmp-swatch:hover { transform: scale(1.12); }
.cmp-swatch.is-active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--line); }
.cmp-swatch:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.cmp-keys { margin: 0; padding: 0 0 0 2px; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-xs); color: var(--text-2); }

.cmp-layers { padding: var(--s-3); }
.cmp-layer-list { gap: 2px; }
.cmp-layer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 2px;
  cursor: pointer;
}
.cmp-layer.is-hidden .cmp-layer-name { color: var(--text-muted); text-decoration: line-through; }
.cmp-layer-grip { flex: none; color: var(--text-muted); cursor: grab; }
.cmp-layer-icon { width: 22px; height: 22px; border-radius: var(--r-xs); }
.cmp-layer-name { flex: 1 1 auto; min-width: 0; font-size: var(--fs-sm); }
.cmp-layer-group {
  margin-left: 4px;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-2);
  background: var(--surface-sunken);
  border-radius: var(--r-pill);
}

@media (max-width: 1100px) {
  .cmp-lib { width: 220px; }
  .cmp-lib-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cmp-tile.is-wide { grid-column: span 2; }
  .cmp-thumb.is-backdrop { width: 84px; }
}
