/* ============================================================
   dsp.css — "Image Processing Laboratory"

   The pipeline builder is the only genuinely new furniture here;
   everything else reuses the shared bench. @import must stay first.
   ============================================================ */

@import url("color.css");

/* Processing results are meant to be inspected pixel by pixel. */
.dsp-grid canvas,
.dsp-thumb { image-rendering: pixelated; }

/* ============================================================
   The pipeline
   ============================================================ */

.dsp-pipeline {
  background: var(--cam-sunk);
  padding: 1rem;
  max-height: 760px;
  overflow-y: auto;
  display: grid;
  gap: 0;
}

.dsp-stage {
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  gap: 0 1rem;
  background: var(--cam-panel);
  border-radius: var(--cam-r);
  box-shadow: var(--cam-shadow-sm);
  padding: 0.85rem 1rem 1rem;
  transition: box-shadow 0.3s var(--cam-ease);
}
.dsp-stage:hover { box-shadow: var(--cam-shadow); }
.dsp-stage.is-final { box-shadow: var(--cam-shadow), 0 0 0 2px var(--cam-a); }

.dsp-stage-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  padding-bottom: 0.6rem;
  margin-bottom: 0.7rem;
  border-bottom: 1px solid var(--cam-rule);
}
.dsp-stage-n {
  font-family: var(--cam-mono);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--cam-a);
}
.dsp-stage-name {
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--cam-ink);
  flex: 1;
  min-width: 0;
}
.dsp-stage-ms {
  font-family: var(--cam-mono);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  color: var(--cam-muted);
}
.dsp-stage-btns { display: flex; gap: 0.25rem; }

.dsp-mini {
  font-size: 0.78rem;
  line-height: 1;
  width: 24px; height: 24px;
  padding: 0;
  background: var(--cam-panel-2);
  color: var(--cam-soft);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.25s var(--cam-ease), color 0.25s var(--cam-ease),
              transform 0.15s var(--cam-ease);
}
.dsp-mini:hover:not([disabled]) {
  color: var(--cam-a);
  background: var(--cam-a-soft);
}
.dsp-mini:active:not([disabled]) { transform: scale(0.9); }
.dsp-mini[disabled] { opacity: 0.28; cursor: not-allowed; }
.dsp-mini:focus-visible { outline: 3px solid var(--cam-a); outline-offset: 2px; }

.dsp-thumb {
  width: 138px;
  height: auto;
  display: block;
  border-radius: var(--cam-r-sm);
  box-shadow: 0 0 0 1px var(--cam-rule);
  background: var(--cam-sunk);
}

.dsp-stage-body { min-width: 0; }

.dsp-param {
  display: grid;
  grid-template-columns: 4.6rem minmax(0, 1fr) 3.6rem;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.15rem;
}
.dsp-param-label {
  font-size: 0.76rem;
  color: var(--cam-soft);
}
.dsp-param-val {
  font-family: var(--cam-mono);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--cam-a);
  text-align: right;
}

.dsp-explain {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--cam-muted);
  margin: 0.6rem 0 0;
}

.dsp-arrow {
  text-align: center;
  font-size: 1rem;
  color: var(--cam-a);
  opacity: 0.45;
  line-height: 1;
  padding: 0.42rem 0;
}

/* The add-operation select, styled like the other controls. */
.dsp-add {
  width: 100%;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--cam-ink);
  background: var(--cam-panel-2);
  border: none;
  border-radius: var(--cam-r-sm);
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  transition: background 0.25s var(--cam-ease);
}
.dsp-add:hover { background: color-mix(in srgb, var(--cam-a) 12%, var(--cam-panel-2)); }
.dsp-add:focus-visible { outline: 3px solid var(--cam-a); outline-offset: 2px; }

/* ============================================================
   Custom kernel editor
   ============================================================ */

.dsp-kgrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-bottom: 0.7rem;
}
.dsp-kcell {
  width: 100%;
  font-family: var(--cam-mono);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--cam-ink);
  background: var(--cam-panel-2);
  border: none;
  border-radius: var(--cam-r-sm);
  padding: 0.48rem 0.1rem;
  -moz-appearance: textfield;
  transition: background 0.2s var(--cam-ease), box-shadow 0.2s var(--cam-ease);
}
.dsp-kcell::-webkit-outer-spin-button,
.dsp-kcell::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.dsp-kcell:hover { background: color-mix(in srgb, var(--cam-a) 8%, var(--cam-panel-2)); }
.dsp-kcell:focus {
  outline: none;
  background: var(--cam-panel);
  box-shadow: 0 0 0 2px var(--cam-a);
}

/* ============================================================
   Panel-grid aspect ratios

   Matched to what each bay draws — a row of N square panels plus two
   label lines — so the canvas is not mostly empty. panelGrid centres
   its content, so being slightly off is harmless.
   ============================================================ */

.dsp-row3 { aspect-ratio: 2.8 / 1; }
.dsp-row4 { aspect-ratio: 3.6 / 1; }
.dsp-row4-narrow { aspect-ratio: 2.6 / 1; }

@media (max-width: 700px) {
  .dsp-row3 { aspect-ratio: 2.2 / 1; }
  .dsp-row4 { aspect-ratio: 2.8 / 1; }
  .dsp-stage { grid-template-columns: 100px minmax(0, 1fr); }
  .dsp-thumb { width: 100px; }
  .dsp-pipeline { max-height: none; padding: 0.6rem; }
}
