/* Dashboard layout generator. Loaded only on /tools/dashboard-layout/.
   Site tokens come from site.css; the stage uses its own --z-* tokens,
   set by layout-tool.js from the layout's colours, so the preview matches
   the export rather than the site theme. */

.lt {
  display: grid;
  grid-template-columns: 20rem minmax(0, 1fr);
  gap: var(--s-4);
  align-items: start;
  animation: rise 1s 0.2s var(--ease) both;
}

@media (max-width: 62rem) {
  .lt { grid-template-columns: 1fr; }
  .lt-work { order: -1; }
}

/* ---------------------------------------------------------------- panel */

.lt-panel { display: grid; gap: var(--s-2); }

@media (min-width: 62rem) {
  .lt-panel { position: sticky; top: 5rem; }
}

.lt-group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--s-3);
  display: grid;
  gap: 0.85rem;
}

.lt-group__title {
  font-size: var(--t-md);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.lt-group__title span { font-family: var(--mono); font-size: var(--t-xs); font-weight: 500; color: var(--marker); }

.lt-situations { margin: 0; }

.lt-subhead {
  margin: 0.2rem 0 -0.35rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.lt-field { display: grid; gap: 0.35rem; font-size: var(--t-sm); }

.lt-field > span { color: var(--ink-soft); font-weight: 500; display: flex; justify-content: space-between; }

.lt-field output { font-family: var(--mono); font-size: var(--t-xs); color: var(--ink); }

.lt-select,
.lt-input {
  width: 100%;
  font: inherit;
  font-size: var(--t-sm);
  padding: 0.6rem 0.75rem;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
}

.lt-select:focus-visible,
.lt-input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.lt-custom { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.lt-custom[hidden] { display: none; }

.lt-range input { width: 100%; accent-color: var(--accent); }

.lt-check, .lt-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--t-sm);
  cursor: pointer;
}

.lt-check input, .lt-toggle input { accent-color: var(--accent); width: 1rem; height: 1rem; }

.lt-swatches { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }

.lt-swatches .lt-swatch { min-width: 0; }

.lt-swatch {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font: inherit;
  font-size: var(--t-sm);
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.lt-swatch:hover { border-color: var(--ink); }
.lt-swatch[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.lt-swatch__chip {
  width: 1.9rem;
  height: 1.3rem;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.lt-swatch__chip i { width: 0.45rem; height: 0.6rem; border-radius: 2px; }

.lt-colors { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }

.lt-color { display: grid; justify-items: center; gap: 0.25rem; font-size: var(--t-xs); color: var(--ink-soft); cursor: pointer; }

.lt-color input {
  width: 100%;
  height: 2rem;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

.lt-exports { display: grid; gap: 0.5rem; }

.lt-exports .button { width: 100%; }

.lt-note { font-size: var(--t-xs); color: var(--ink-soft); margin: 0; line-height: 1.55; }

/* ---------------------------------------------------------------- workspace */

.lt-work { display: grid; gap: var(--s-2); min-width: 0; }

.lt-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.lt-toolbar__add, .lt-toolbar__right { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

.lt-toolbar__add .lt-select { width: auto; min-width: 11rem; }

.lt-toggle {
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
}

.lt-iconbtn {
  width: 2.3rem;
  height: 2.3rem;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.lt-iconbtn:hover { border-color: var(--ink); }
.lt-iconbtn--danger:hover { border-color: var(--marker); color: var(--marker); }

.lt-stage-wrap {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(0.75rem, 2.5vw, 2rem);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
}

.lt-stage {
  position: relative;
  width: min(100%, calc(70vh * var(--ar, 1.777)));
  aspect-ratio: var(--ar, 1.777);
  margin-inline: auto;
  container-type: inline-size;
  background: var(--z-bg);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(20, 33, 58, 0.08), 0 24px 48px -24px rgba(20, 33, 58, 0.35);
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.3s ease;
}

/* The grid shows while dragging, or when switched on. */
.lt-grid { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.2s ease; }
.lt-grid i { position: absolute; background: var(--z-accent); opacity: 0.06; }
.lt-stage.is-dragging .lt-grid,
.lt-stage.show-grid .lt-grid { opacity: 1; }

.lt-zone {
  position: absolute;
  border-radius: var(--z-r);
  background: var(--z-card);
  box-shadow: var(--z-shadow);
  color: var(--z-ink);
  font-family: var(--body);
  font-size: max(10px, var(--fs));
  line-height: 1.3;
  cursor: grab;
  touch-action: none;
  outline: none;
  transition: left 0.14s ease, top 0.14s ease, width 0.14s ease, height 0.14s ease, background-color 0.3s ease, box-shadow 0.2s ease;
}

.lt-stage.is-dragging .lt-zone.is-selected { cursor: grabbing; }

.lt-zone__body {
  position: absolute;
  inset: 0;
  overflow: hidden;
  padding: 0.9em;
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  border-radius: inherit;
}

.lt-zone__label { font-weight: 600; color: var(--z-accent); white-space: nowrap; }

.lt-zone__job { font-size: 0.86em; color: color-mix(in srgb, var(--z-ink) 62%, transparent); }

.lt-stage:not(.show-labels) .lt-zone__body > * { visibility: hidden; }

/* One-row zones: name and job on one line. */
.lt-zone--rule .lt-zone__body,
.lt-zone--dashed .lt-zone__body { flex-direction: row; align-items: center; gap: 0.8em; }

.lt-zone--rule .lt-zone__job,
.lt-zone--dashed .lt-zone__job { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.lt-zone--rule {
  background: transparent;
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--z-ink) 14%, transparent);
  border-radius: 0;
}

.lt-zone--rule::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: min(5cqw, 100%);
  height: max(2px, 0.25cqw);
  background: var(--z-accent);
}

.lt-zone--dashed {
  background: transparent;
  box-shadow: none;
  border: 1px dashed color-mix(in srgb, var(--z-ink) 32%, transparent);
}

/* Solid accent: the title banner, and the answer when highlighted. */
.lt-zone--fill { background: var(--z-accent); }
.lt-zone--fill .lt-zone__label { color: var(--z-on-accent); }
.lt-zone--fill .lt-zone__job { color: color-mix(in srgb, var(--z-on-accent) 75%, transparent); }

.lt-zone:hover { box-shadow: var(--z-shadow), 0 0 0 1px color-mix(in srgb, var(--z-accent) 45%, transparent); }

.lt-zone.is-overlap { box-shadow: 0 0 0 2px var(--marker); }

.lt-zone.is-selected { box-shadow: var(--z-shadow), 0 0 0 2px #2546d1; }

.lt-zone:focus-visible { box-shadow: 0 0 0 3px #2546d1; }

/* Resize handles, only on the selected zone. */
.lt-h {
  position: absolute;
  width: 12px;
  height: 12px;
  margin: -6px;
  background: #fff;
  border: 2px solid #2546d1;
  border-radius: 3px;
  display: none;
  z-index: 2;
}

@media (pointer: coarse) {
  .lt-h { width: 20px; height: 20px; margin: -10px; border-radius: 6px; }
}

.lt-zone.is-selected .lt-h { display: block; }

.lt-h--n  { top: 0; left: 50%; cursor: ns-resize; }
.lt-h--s  { top: 100%; left: 50%; cursor: ns-resize; }
.lt-h--e  { top: 50%; left: 100%; cursor: ew-resize; }
.lt-h--w  { top: 50%; left: 0; cursor: ew-resize; }
.lt-h--ne { top: 0; left: 100%; cursor: nesw-resize; }
.lt-h--sw { top: 100%; left: 0; cursor: nesw-resize; }
.lt-h--nw { top: 0; left: 0; cursor: nwse-resize; }
.lt-h--se { top: 100%; left: 100%; cursor: nwse-resize; }

.lt-meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-soft);
}

/* ---------------------------------------------------------------- info */

.lt-info { display: grid; grid-template-columns: 1.2fr 1fr; gap: var(--s-2); }

@media (max-width: 48rem) {
  .lt-info { grid-template-columns: 1fr; }
}

.lt-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--s-3);
}

.lt-why { color: var(--ink-soft); font-size: var(--t-sm); margin-bottom: var(--s-3); }

.lt-selected { border-top: 1px dashed var(--line-strong); padding-top: var(--s-2); }

.lt-selected__title {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  font-size: var(--t-sm);
  margin-bottom: 0.5rem;
}

.lt-selected__title span { font-family: var(--mono); font-weight: 500; font-size: var(--t-xs); color: var(--ink-soft); }

.lt-selected__row { display: flex; gap: 0.5rem; }

.lt-selected__job, .lt-selected__empty { font-size: var(--t-sm); color: var(--ink-soft); margin: 0.6rem 0 0; }

.lt-checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }

.lt-check-item {
  position: relative;
  padding-left: 1.5rem;
  font-size: var(--t-sm);
  line-height: 1.45;
  animation: rise 0.4s var(--ease) both;
}

.lt-check-item::before {
  position: absolute;
  left: 0;
  top: 0.05rem;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
}

.lt-check-item--ok::before    { content: "✓"; background: #0f9d8a; }
.lt-check-item--warn::before  { content: "!"; background: var(--marker); }
.lt-check-item--error::before { content: "×"; background: #d6456b; }
.lt-check-item--tip::before   { content: "i"; background: var(--ink-soft); font-style: italic; font-family: Georgia, serif; }
.lt-check-item--tip { color: var(--ink-soft); }

/* ---------------------------------------------------------------- how-to */

.lt-howto { display: grid; gap: 0.5rem; }

.lt-howto details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 0.85rem var(--s-3);
}

.lt-howto summary { cursor: pointer; font-weight: 600; font-size: var(--t-sm); }

.lt-howto ol { margin: 0.75rem 0 0.25rem; padding-left: 1.2rem; font-size: var(--t-sm); color: var(--ink-soft); display: grid; gap: 0.35rem; }

.lt-howto em { font-style: normal; color: var(--ink); }

/* On a small stage there is only room for each zone's name. */
@container (max-width: 520px) {
  .lt-zone__job { display: none; }
}
