/* Picplacer placement tool — layered on top of site.css */

.studio { padding: var(--space-5) 0 var(--space-6); }

.studio-head { max-width: 62ch; margin-bottom: var(--space-5); }
/* Get the tool itself above the fold on a small phone. */
@media (max-width: 620px) {
  .studio { padding-top: var(--space-3); }
  .studio-head { margin-bottom: var(--space-3); }
  .studio-head .lede { font-size: 1rem; }
}
.studio-head h1 { font-size: var(--step-3); margin-bottom: var(--space-2); }
.studio-head .lede { font-size: var(--step-1); color: var(--ink-muted); }
.engine-line {
  font-size: 0.8125rem; color: var(--ink-faint);
  display: inline-flex; align-items: center; gap: 8px; margin: 0;
}
.engine-line::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-faint); flex: 0 0 auto;
}
.engine-line[data-engine="ready"]::before { background: #34c759; }
.engine-line[data-engine="mock"]::before { background: var(--accent); }
.engine-line[data-engine="down"]::before { background: #ff453a; }

.studio-grid { display: grid; gap: clamp(20px, 3vw, 36px); grid-template-columns: 1fr; align-items: start; }
/* Grid items default to min-width:auto, which would let the horizontally
   scrolling gallery strip widen the whole column past the viewport. */
.studio-grid > * { min-width: 0; }
@media (min-width: 1000px) { .studio-grid { grid-template-columns: minmax(340px, 0.95fr) 1.05fr; } }

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: clamp(20px, 3vw, 32px);
  box-shadow: var(--shadow-soft);
}

.step + .step { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--hairline); }
.step h2 {
  font-family: var(--font-ui); font-size: 0.9375rem; font-weight: 600;
  letter-spacing: 0; display: flex; align-items: center; gap: 10px;
  margin-bottom: var(--space-3);
}
.step-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 0.75rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- Source picker ---------- */

.dropzone {
  position: relative;
  border: 1px dashed var(--hairline);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  min-height: 190px;
  display: grid; place-items: center;
  padding: var(--space-3); text-align: center;
  cursor: pointer; overflow: hidden;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.dropzone:hover, .dropzone[data-drag="true"] { border-color: var(--accent); background: var(--accent-soft); }
.dropzone[data-has-image="true"] { border-style: solid; padding: 0; background: var(--bg-sunken); cursor: default; }
.dropzone[data-error="true"] { border-color: #ff453a; border-style: solid; background: rgba(255, 69, 58, 0.06); }

.dropzone-error {
  display: grid; gap: 8px; justify-items: center; text-align: center;
  color: #ff453a; max-width: 42ch;
}
.dropzone-error p { margin: 0; font-size: 0.9375rem; font-weight: 500; }
.dropzone-error .hint { color: var(--ink-muted); font-weight: 400; line-height: 1.5; }
.dropzone img { max-height: 320px; width: auto; margin-inline: auto; }
.dropzone-empty { color: var(--ink-muted); display: grid; gap: 6px; justify-items: center; }
.dropzone-empty p { margin: 0; font-size: 0.9375rem; }
.hint { font-size: 0.8125rem; color: var(--ink-faint); margin: 0; }
.or-line { margin: var(--space-3) 0 10px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: var(--space-2); }
.file-btn { cursor: pointer; }

.gallery-strip {
  min-width: 0;
  display: grid; grid-auto-flow: column; grid-auto-columns: 74px;
  gap: 10px; overflow-x: auto; padding-bottom: 6px;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
}
.gallery-strip::-webkit-scrollbar { height: 6px; }
.gallery-strip::-webkit-scrollbar-thumb { background: var(--hairline); border-radius: 3px; }
.thumb { position: relative; scroll-snap-align: start; }
.thumb input { position: absolute; opacity: 0; pointer-events: none; }
.thumb span {
  display: block; border-radius: 10px; overflow: hidden; cursor: pointer;
  box-shadow: 0 0 0 1px var(--hairline);
  transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}
.thumb img { aspect-ratio: 3 / 4; object-fit: cover; width: 100%; }
.thumb input:checked + span { box-shadow: 0 0 0 2px var(--accent); transform: translateY(-2px); }
.thumb input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- Chips ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: var(--space-3); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: 8px 14px; border-radius: 980px;
  font-size: 0.875rem; color: var(--ink-muted); cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--hairline);
  transition: all 0.2s var(--ease);
}
.chip span:hover { color: var(--ink); }
.chip input:checked + span { background: var(--ink); color: var(--bg); box-shadow: none; }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }

.two-up { display: grid; gap: var(--space-2); grid-template-columns: 1fr; }
@media (min-width: 520px) { .two-up { grid-template-columns: 1fr 1fr; } }

/* ---------- Result ---------- */

.result-panel { position: sticky; top: 88px; display: grid; gap: var(--space-3); }
@media (max-width: 999px) { .result-panel { position: static; } }

.result-stage {
  position: relative;
  background: var(--bg-sunken);
  border-radius: var(--radius);
  /* width has to be definite: with only aspect-ratio and min-height the box
     resolves its width from the height and overflows narrow viewports. */
  width: 100%;
  min-height: 280px;
  aspect-ratio: 4 / 3;
  display: grid; place-items: center;
  overflow: hidden;
}
.result-stage > * { grid-area: 1 / 1; }
.result-stage img { width: 100%; height: 100%; object-fit: contain; }
.result-stage[data-state="done"] .result-empty { display: none; }
.result-empty { text-align: center; color: var(--ink-muted); display: grid; gap: 6px; padding: var(--space-3); }
.result-empty p { margin: 0; }

.result-progress {
  position: absolute; inset: 0;
  display: grid; place-items: center; gap: 14px; align-content: center;
  background: var(--bg-sunken);
  background: color-mix(in srgb, var(--bg-sunken) 80%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: var(--ink-muted); font-size: 0.875rem;
}
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--hairline); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

.result-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.error-note {
  color: #ff453a; font-size: 0.8125rem; margin-top: 8px;
}
