/*
  Interactive widgets for "Prompting AI Images for Editability".
  Self-contained, prefixed styles (.sepw = separability inspector,
  .pbw = prompt builder). Brand tokens (--red, --ink, --line, --card ...)
  come from /blog/theme.css, which this post links alongside this file.
*/

/* Shared embed shell -------------------------------------------------------- */
.px-embed {
  margin: 2.6rem 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--white);
  box-shadow: 0 1px 2px rgba(23, 23, 31, 0.04);
  overflow: hidden;
}
.px-embed .px-fallback { margin: 0; display: block; }
.px-embed .px-fallback img { display: block; width: 100%; height: auto; border: 0; }
.px-embed.is-ready .px-fallback { display: none; }

.px-embed-head { padding: 16px 18px 0; }
.px-embed-eyebrow {
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--red);
  margin: 0 0 4px;
}
.px-embed-note {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--body);
  margin: 0;
}

/* Controls ------------------------------------------------------------------ */
.px-controls {
  padding: 14px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.px-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.px-row-label {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  flex: 0 0 auto;
}
.px-pills { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.px-pill {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-2);
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.px-pill:hover { border-color: var(--red); color: var(--red); }
.px-pill.is-active { background: var(--red); border-color: var(--red); color: #fff; }
.px-pill-group-label {
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 2px;
}
.px-pill-sep { width: 1px; align-self: stretch; background: var(--line); margin: 2px 4px; }

/* ==========================================================================
   Widget A: Separability inspector
   ========================================================================== */
.sepw-main {
  display: flex;
  gap: 18px;
  padding: 14px 18px 0;
  align-items: flex-start;
}
.sepw-stage-wrap { flex: 1 1 56%; min-width: 0; }
.sepw-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  background: #0e0e13;
}
.sepw-stage.is-loading::after {
  content: "";
  position: absolute; inset: 0;
  background: rgba(14, 14, 19, 0.5);
  z-index: 40;
}
.sepw-planes { position: absolute; inset: 0; }
.sepw-plane { position: absolute; inset: 0; transition: opacity 0.2s ease; }
.sepw-plane.is-hidden { opacity: 0; }
.sepw-plane img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; display: block; border: 0;
  pointer-events: none;
}

/* Isolate overlay: one layer on a transparency checker + reconstructed tint. */
.sepw-iso {
  position: absolute; inset: 0;
  z-index: 20;
  display: none;
  background-color: #f3f1f1;
  background-image:
    linear-gradient(45deg, #e4e0e0 25%, transparent 25%, transparent 75%, #e4e0e0 75%),
    linear-gradient(45deg, #e4e0e0 25%, transparent 25%, transparent 75%, #e4e0e0 75%);
  background-size: 18px 18px;
  background-position: 0 0, 9px 9px;
}
.sepw-stage.is-iso .sepw-iso { display: block; }
.sepw-stage.is-iso .sepw-planes { visibility: hidden; }
.sepw-iso img, .sepw-iso canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block; border: 0;
}
.sepw-iso img { object-fit: contain; }
.sepw-iso canvas {
  object-fit: contain;
  mix-blend-mode: normal;
  opacity: 0.82;
  image-rendering: auto;
  pointer-events: none;
}
.sepw-iso-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 25;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(to top, rgba(14,14,19,0.86), rgba(14,14,19,0));
}
.sepw-iso-cap {
  flex: 1 1 auto;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #fff;
}
.sepw-iso-cap b { color: #ffd9d9; }
.sepw-iso-close {
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}
.sepw-iso-close:hover { background: rgba(255,255,255,0.24); }
.sepw-iso-legend {
  position: absolute; top: 10px; left: 10px; z-index: 25;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-display);
  font-size: 0.62rem; font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
}
.sepw-iso-legend .dot {
  width: 10px; height: 10px; border-radius: 3px;
  background: var(--red);
  display: inline-block;
}

/* Panel: difficulty score + per-layer occlusion list. */
.sepw-panel { flex: 1 1 44%; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.sepw-score {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--card);
}
.sepw-score-top {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
}
.sepw-score-label {
  font-family: var(--font-display);
  font-size: 0.66rem; font-weight: 800;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
}
.sepw-score-verdict {
  font-family: var(--font-display);
  font-size: 0.86rem; font-weight: 800;
}
.sepw-score-num {
  font-family: var(--font-display);
  font-size: 1.9rem; font-weight: 800;
  line-height: 1.1; color: var(--ink);
  margin: 4px 0 2px;
}
.sepw-score-num small { font-size: 0.9rem; color: var(--muted); font-weight: 700; }
.sepw-score-sub { font-size: 0.78rem; color: var(--body); line-height: 1.4; margin: 0; }
.sepw-meter { height: 7px; border-radius: 999px; background: #e9e6e6; overflow: hidden; margin: 8px 0 0; }
.sepw-meter > i { display: block; height: 100%; width: 0; border-radius: 999px; transition: width 0.5s cubic-bezier(0.22,0.61,0.36,1), background 0.3s ease; }

.sepw-list-head {
  font-family: var(--font-display);
  font-size: 0.66rem; font-weight: 800;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 2px;
}
.sepw-list { display: flex; flex-direction: column; gap: 6px; }
.sepw-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.sepw-row:hover { border-color: var(--red); }
.sepw-row.is-selected { border-color: var(--red); background: #fdf6f6; }
.sepw-row-eye {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.8rem; line-height: 1;
}
.sepw-row.is-off { opacity: 0.55; }
.sepw-row-main { flex: 1 1 auto; min-width: 0; }
.sepw-row-name {
  font-family: var(--font-display);
  font-size: 0.82rem; font-weight: 700;
  color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sepw-row-bar { height: 5px; border-radius: 999px; background: #ececef; overflow: hidden; margin-top: 5px; }
.sepw-row-bar > i { display: block; height: 100%; background: var(--red); width: 0; border-radius: 999px; transition: width 0.5s ease; }
.sepw-row-occ {
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-size: 0.78rem; font-weight: 800;
  color: var(--ink-2);
  min-width: 40px; text-align: right;
}
.sepw-row-occ small { display: block; font-size: 0.56rem; font-weight: 700; color: var(--muted); letter-spacing: 0.04em; }

@media (max-width: 640px) {
  .sepw-main { flex-direction: column; }
  .sepw-stage-wrap, .sepw-panel { flex-basis: auto; width: 100%; }
}

/* ==========================================================================
   Widget B: Editability prompt builder
   ========================================================================== */
.pbw-main { padding: 14px 18px 0; display: flex; flex-direction: column; gap: 14px; }
.pbw-subject-row { display: flex; flex-direction: column; gap: 6px; }
.pbw-subject-row label {
  font-family: var(--font-display);
  font-size: 0.66rem; font-weight: 800;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
}
.pbw-subject {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  background: var(--white);
}
.pbw-subject:focus { outline: none; border-color: var(--red); }

.pbw-chips-head {
  font-family: var(--font-display);
  font-size: 0.66rem; font-weight: 800;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
  margin: 2px 0 -4px;
}
.pbw-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pbw-chip {
  font-family: var(--font-display);
  font-size: 0.82rem; font-weight: 700;
  color: var(--ink-2);
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px 8px 12px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.pbw-chip:hover { border-color: var(--red); }
.pbw-chip .tick {
  width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.68rem; color: transparent; line-height: 1;
}
.pbw-chip.is-on { background: var(--red); border-color: var(--red); color: #fff; }
.pbw-chip.is-on .tick { border-color: #fff; color: #fff; }

.pbw-why {
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--body);
  margin: 0;
  min-height: 1.3em;
}
.pbw-why b { color: var(--ink-2); font-weight: 700; }

.pbw-score {
  display: flex; align-items: center; gap: 12px;
}
.pbw-score-label {
  font-family: var(--font-display);
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  flex: 0 0 auto;
}
.pbw-score-meter { flex: 1 1 auto; height: 8px; border-radius: 999px; background: #e9e6e6; overflow: hidden; }
.pbw-score-meter > i { display: block; height: 100%; width: 20%; border-radius: 999px; background: var(--red); transition: width 0.4s cubic-bezier(0.22,0.61,0.36,1), background 0.3s ease; }
.pbw-score-verdict {
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-size: 0.82rem; font-weight: 800;
  min-width: 90px; text-align: right;
}

.pbw-prompt {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 12px 14px;
}
.pbw-prompt-label {
  font-family: var(--font-display);
  font-size: 0.64rem; font-weight: 800;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px;
}
.pbw-prompt-text {
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink);
  margin: 0;
  padding-right: 92px;
  word-break: break-word;
}
.pbw-copy {
  position: absolute; top: 10px; right: 10px;
  font-family: var(--font-display);
  font-size: 0.74rem; font-weight: 700;
  color: #fff; background: var(--red);
  border: 0; border-radius: 999px;
  padding: 7px 14px; cursor: pointer;
  transition: background 0.15s ease;
}
.pbw-copy:hover { background: #a24e4e; }
.pbw-copy.is-done { background: #4a8f5f; }

/* Verdict color ramp, shared helper driven by JS via inline color. */
