/* ==========================================================================
   MASTER-UI-ENGINE — Visual lab chrome
   Page rules for showcase/index.html only. The lab is the tool that browses
   the previews, so it keeps its own dark UI: these rules style the command
   palette, the shortcut affordance and the studio entry point. Nothing here
   styles a component, and no component class is redefined.
   Colours come from the lab's own :root ramp in index.html; durations,
   easings and movement distances come from design-tokens/motion/scale.css
   (linked through engine.css).
   ========================================================================== */

/* ---- search affordance: the visible door to the palette ---- */
.kbd-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--motion-colors);
}
.kbd-trigger:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.kbd-trigger kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
  color: var(--muted);
}
.kbd-trigger svg {
  width: 13px;
  height: 13px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}
/* [data-short] is the compact label, shown only when the header runs out of
   room; the full phrase is .trigger-words. Both live on the same button so the
   kbd chip never gets pushed off the edge. */
.kbd-trigger [data-short] {
  display: none;
}
@media (max-width: 1180px) {
  .kbd-trigger .trigger-words {
    display: none;
  }
  .kbd-trigger [data-short] {
    display: inline;
  }
}

/* ---- studio entry point ---- */
.studio-link {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 14px;
  padding: 9px 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 12px;
  text-decoration: none;
  transition: var(--motion-colors);
}
.studio-link strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
}
.studio-link small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}
.studio-link:hover {
  border-color: var(--accent);
  border-style: solid;
}
.studio-link .dot {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
}

/* ---- command palette ---- */
.palette-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh 16px 16px;
  background: rgba(4, 7, 10, 0.62);
}
.palette-overlay[hidden] {
  display: none;
}
.palette {
  display: flex;
  flex-direction: column;
  width: min(660px, 100%);
  max-height: min(60vh, 460px);
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  animation: lab-palette-in var(--duration-base) var(--ease-standard);
}
@keyframes lab-palette-in {
  from {
    opacity: 0;
    transform: translateY(calc(var(--reveal-shift) / -2));
  }
}
.palette-input {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  padding: 0 14px;
  min-height: 52px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.palette-input svg {
  width: 16px;
  height: 16px;
  flex: none;
  stroke: var(--muted);
  fill: none;
  stroke-width: 2;
}
.palette-input input {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  padding: 0;
}
.palette-input input::placeholder {
  color: var(--muted);
  opacity: 1;
}
.palette-input kbd {
  flex: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
  color: var(--muted);
}
.palette-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 6px;
  list-style: none;
}
.palette-sec {
  padding: 10px 10px 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}
.p-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 12px;
  width: 100%;
  min-height: 46px;
  padding: 7px 10px;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: var(--motion-colors);
}
.p-row[aria-selected="true"],
.p-row:hover {
  background: var(--accent-soft);
}
.p-row[aria-selected="true"] {
  box-shadow: inset 0 0 0 1px var(--accent);
}
.p-name {
  grid-column: 1;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.p-meta {
  grid-column: 1;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.p-tags {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  min-width: 0;
  white-space: nowrap;
}
.p-tag {
  flex: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
}
.p-row .p-key {
  font-size: 11px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.palette-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  flex: none;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 11px;
  color: var(--muted);
}
.palette-foot span {
  white-space: nowrap;
}
.palette-empty {
  padding: 22px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
body.palette-locked {
  overflow: hidden;
}
@media (max-width: 700px) {
  .palette-overlay {
    padding: 8vh 10px 10px;
  }
  .palette {
    max-height: 76vh;
  }
  /* Region chips cannot share a line with the name at this width, so they drop
     below it and wrap; max-width alone would let them overflow the name. */
  .p-row {
    align-items: start;
    row-gap: 5px;
  }
  .p-tags {
    grid-column: 1 / -1;
    grid-row: auto;
    justify-content: flex-start;
    flex-wrap: wrap;
    white-space: normal;
  }
}
