/* ============================================================================
   shared/curve-editor.css — the SHARED curve & gradient sub-editor.

   Four features reference "the shared curve editor" (particles, clouds,
   cloud-material, materials) and until now none of them had one — every
   "edit curve →" was a toast. This is the surface those buttons open, defined
   once so the fifth caller reuses it instead of drawing a fifth widget
   (rule-of-three-extract.md).

   Two levels, in the atomic-design sense:
     .crv     MOLECULE — the parameter row: live thumbnail + name + open
     .crve    ORGANISM — the editor popover: plot, keys, and the key inspector

   Both compose the existing atoms (.btn .inp .num .selin .val) rather than
   restyling them, and every colour is a token — the plot's ink, its grid and its
   accent all come from the theme, so a theme edit moves this with everything else.
   ========================================================================== */

/* ---- MOLECULE · the parameter row ---------------------------------------- */
/* Reads as one control: the thumbnail IS the affordance, so the whole row is the
   click target rather than a separate button competing with it for emphasis. */
.crv { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 4px 0 0;
  background: var(--well); border-radius: var(--r-input, 8px); cursor: pointer;
  box-shadow: inset 0 0 0 1px transparent; }
.crv:hover { box-shadow: inset 0 0 0 1px var(--border-subtle); }
.crv:focus-visible { outline: none; box-shadow: inset 0 0 0 1.5px var(--accent); }
.crv.is-open { box-shadow: inset 0 0 0 1.5px var(--accent); }
.crv .crv-th { width: 46px; height: 22px; flex: none; margin-left: 4px; border-radius: 4px;
  background: var(--bg); display: block; }
.crv .crv-nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 11.5px Consolas, 'Cascadia Mono', monospace; color: var(--text2); }
.crv .crv-go { flex: none; color: var(--faint); font-size: 11px; padding-right: 4px; }
.crv:hover .crv-go { color: var(--accent-text); }
/* unset — a ref that points at nothing states so, and still opens (to author one) */
.crv.is-unset .crv-nm { color: var(--faint); font-style: italic; }
/* read-only: a derived or locked curve is faint and does not offer the affordance */
.crv.is-readonly { cursor: default; }
.crv.is-readonly:hover { box-shadow: inset 0 0 0 1px transparent; }
.crv.is-readonly .crv-nm { color: var(--muted); }
.crv.is-readonly .crv-go { display: none; }

/* ---- ORGANISM · the editor popover --------------------------------------- */
/* z-index 240 puts this in the popover band (see the layer order documented in
   color-picker.css). The picker sits ABOVE this deliberately: the colour swatch
   in the stop row opens it from inside this popover. */
.crve { position: absolute; z-index: 240; width: 320px; background: var(--panel);
  border-radius: var(--r-panel, 12px); box-shadow: 0 18px 48px rgba(0, 0, 0, .55);
  padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.crve-head { display: flex; align-items: center; gap: 8px; }
.crve-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; color: var(--ink); font-weight: 600; }
.crve-sub { font: 10.5px Consolas, monospace; color: var(--faint); }

/* the plot well — the input surface, so it sits at the deepest surface step */
.crve-plot { background: var(--well); border-radius: var(--r-card, 9px); display: block;
  width: 100%; height: 168px; touch-action: none; cursor: crosshair; }
.crve-plot .g { stroke: var(--divider); stroke-width: 1; }
.crve-plot .gx { stroke: var(--line); stroke-width: 1; }
.crve-plot .ln { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.crve-plot .fillA { fill: var(--accent-soft); }
.crve-plot .k { fill: var(--panel); stroke: var(--accent); stroke-width: 2; cursor: grab; }
.crve-plot .k:hover { fill: var(--accent-soft); }
.crve-plot .k.on { fill: var(--accent); stroke: var(--accent); }
.crve-plot .ax { fill: var(--faint); font: 9.5px Consolas, monospace; }

/* the key inspector — only what the selection has, never a dead row */
.crve-rows { display: flex; flex-direction: column; gap: 6px; }
.crve-row { display: grid; grid-template-columns: 62px 1fr; align-items: center; gap: 8px; }
.crve-row > label { font-size: 11.5px; color: var(--muted); }
/* the colour cell holds BOTH ways in — the swatch (pick by eye) and the hex
   field (type a known value, or author alpha the RGB picker cannot express) */
.crve-c { display: flex; align-items: center; gap: 6px; min-width: 0; }
.crve-c .swatch { flex: none; width: 26px; height: 22px; cursor: pointer; }
.crve-c .inp { flex: 1; min-width: 0; height: 22px; }
.crve-hint { font-size: 11px; color: var(--faint); line-height: 1.45; }
.crve-hint b { color: var(--text2); font-weight: 600; }
.crve-foot { display: flex; align-items: center; gap: 6px; }
.crve-foot .sp { flex: 1; }

/* ---- the gradient variant: same frame, a ramp instead of a plot ----------- */
.crve-ramp { height: 34px; border-radius: var(--r-card, 9px); position: relative; cursor: crosshair;
  /* the checker shows stop alpha honestly rather than compositing it on the panel */
  background-image: linear-gradient(45deg, var(--bg) 25%, transparent 25%),
    linear-gradient(-45deg, var(--bg) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--bg) 75%),
    linear-gradient(-45deg, transparent 75%, var(--bg) 75%);
  background-size: 10px 10px; background-position: 0 0, 0 5px, 5px -5px, -5px 0; }
.crve-ramp i { position: absolute; inset: 0; border-radius: var(--r-card, 9px); display: block; }
.crve-stops { position: relative; height: 18px; }
.crve-stops s { position: absolute; top: 0; width: 12px; height: 12px; margin-left: -6px; border-radius: 3px;
  box-shadow: 0 0 0 1.5px var(--panel), 0 0 0 2.5px var(--faint); cursor: grab; }
.crve-stops s.on { box-shadow: 0 0 0 1.5px var(--panel), 0 0 0 2.5px var(--accent); }

/* the thumbnail used by the .crv row and by the catalogue bench */
.crv-th .tln { fill: none; stroke: var(--accent-text); stroke-width: 1.5; }
.crv-th .tfl { fill: var(--accent-soft); }
