/*
 * Room Paint Visualizer — the stage, the toolbar and the swatch board. Source: sites/dreamy-tools/
 * tools/room-paint-visualizer/tool.css (Dash repo); loaded after core/tools.css on this tool only.
 * ⚠️ Every input/select/button stays ≥ 16px (iPhone zooms the page on a smaller field — fenced).
 */
.pv { display: grid; grid-template-columns: 1fr; gap: 18px; }
.pv > * { min-width: 0; }
@media (min-width: 860px) {
  .pv { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 26px; align-items: start; }
  .pv-main { position: sticky; top: 16px; }
}

/* ── the photo ─────────────────────────────────────────────────────────── */
.pv-stage {
  position: relative; display: flex; justify-content: center; align-items: center;
  border-radius: 20px; padding: 10px; min-height: 260px;
  background: radial-gradient(120% 90% at 50% 0%, #f6f1e8 0%, #e9e1d4 100%);
}
.pv-frame {
  position: relative; display: inline-block; max-width: 100%; line-height: 0;
  border-radius: 14px; overflow: hidden; box-shadow: 0 18px 44px rgba(43, 37, 34, .22);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.pv-photo, .pv-canvas {
  display: block; width: auto; height: auto; max-width: 100%; max-height: min(74vh, 860px);
}
.pv-stage[data-mode="fill"] .pv-frame { cursor: crosshair; touch-action: manipulation; }
.pv-stage[data-mode="brush"] .pv-frame, .pv-stage[data-mode="erase"] .pv-frame { cursor: none; touch-action: none; }
.pv-stage[data-mode="compare"] .pv-frame { cursor: ew-resize; touch-action: none; }
.pv-before { position: absolute; inset: 0; width: 100%; height: 100%; clip-path: inset(0 calc(100% - var(--pv-cut, 50%)) 0 0); }
.pv-split { position: absolute; inset: 0; pointer-events: none; }
.pv-split::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: var(--pv-cut, 50%); width: 3px; margin-left: -1.5px;
  background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .15), 0 0 12px rgba(0, 0, 0, .25);
}
.pv-knob {
  position: absolute; top: 50%; left: var(--pv-cut, 50%); width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border-radius: 50%; background: #fff; box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
}
.pv-knob::before {
  content: "‹ ›"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font: 700 18px/1 system-ui, sans-serif; color: var(--chqt-ink); letter-spacing: 2px;
}
.pv-tag {
  position: absolute; top: 12px; left: 12px; padding: 4px 10px; border-radius: 999px; line-height: 1.3;
  background: rgba(20, 16, 14, .62); color: #fff; font-size: 13px; font-weight: 600; letter-spacing: .03em;
}
.pv-tag--r { left: auto; right: 12px; }
.pv-cursor {
  position: absolute; left: 0; top: 0; border-radius: 50%; pointer-events: none;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .45); transform: translate(-50%, -50%);
}
.pv-hint {
  position: absolute; left: 50%; top: 20px; transform: translateX(-50%); margin: 0; z-index: 2;
  padding: 8px 14px; border-radius: 999px; background: rgba(20, 16, 14, .72); color: #fff;
  font-size: 14.5px; line-height: 1.3; font-weight: 600; text-align: center; width: max-content;
  max-width: calc(100% - 32px); pointer-events: none; transition: opacity .35s;
}
.pv-hint--off { opacity: 0; }
.pv-own {
  position: absolute; right: 20px; bottom: 20px; z-index: 2; display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: 16px; font-weight: 700; min-height: 44px; padding: 8px 16px 8px 12px; cursor: pointer;
  border: 0; border-radius: 999px; background: #fffdf9; color: var(--chqt-ink); box-shadow: 0 6px 20px rgba(0, 0, 0, .28);
}
.pv-own:focus-visible { outline: 3px solid rgba(215, 157, 50, .8); outline-offset: 2px; }
.pv-stage[data-mode="compare"] .pv-own { display: none; }
.pv-drop {
  position: absolute; inset: 10px; border-radius: 14px; border: 3px dashed var(--chqt-accent);
  background: rgba(255, 253, 249, .88); display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: var(--chqt-accent); z-index: 3;
}
.pv-stage.pv-busy .pv-frame::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 42px; height: 42px; margin: -21px;
  border-radius: 50%; border: 4px solid rgba(255, 255, 255, .5); border-top-color: #fff; animation: pv-spin .8s linear infinite;
}
@keyframes pv-spin { to { transform: rotate(360deg); } }

/* ── the toolbar ───────────────────────────────────────────────────────── */
.pv-bar {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; margin-top: 12px;
  background: var(--chqt-ink); border-radius: 18px; padding: 5px;
}
.pv-tool {
  font: inherit; font-size: 16px; min-height: 56px; cursor: pointer; border: 0; border-radius: 14px;
  background: transparent; color: #f4ede4; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; padding: 6px 2px; line-height: 1.1; -webkit-tap-highlight-color: transparent;
}
.pv-tool b { font-size: 20px; font-weight: 400; }
.pv-tool small { font-size: 12.5px; font-weight: 600; letter-spacing: .01em; white-space: nowrap; }
.pv-tool[aria-pressed="true"] { background: #fffdf9; color: var(--chqt-ink); }
.pv-tool:disabled { opacity: .38; cursor: default; }
.pv-tool:focus-visible, .pv-sw:focus-visible, .pv-sample:focus-visible { outline: 3px solid rgba(215, 157, 50, .8); outline-offset: 2px; }

/* ── the side panel ────────────────────────────────────────────────────── */
.pv-side { display: flex; flex-direction: column; gap: 14px; }
.pv-step { background: var(--chqt-cream); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.pv-h { margin: 0; font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 10px; }
.pv-n {
  flex: 0 0 28px; height: 28px; border-radius: 50%; background: var(--chqt-accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 15px;
}
.pv-upload { justify-content: center; position: relative; }
.pv-upload input { font-size: 16px; } /* an input does not inherit it, and under 16px iPhone zooms */
.pv-upload:focus-within { outline: 3px solid rgba(184, 80, 66, .45); outline-offset: 2px; }
.pv-samples { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pv-sample {
  font: inherit; font-size: 16px; cursor: pointer; padding: 0; overflow: hidden; border-radius: 12px;
  border: 2px solid transparent; background: #fff; color: var(--chqt-ink); display: flex; flex-direction: column;
}
.pv-sample img { display: block; width: 100%; height: 76px; object-fit: cover; }
.pv-sample span { font-size: 13.5px; font-weight: 600; padding: 6px 4px; }
.pv-sample[aria-pressed="true"] { border-color: var(--chqt-accent); }

.pv-current { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 12px; padding: 10px 12px; border: 1px solid var(--chqt-line); }
.pv-chip { flex: 0 0 48px; height: 48px; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.pv-current strong { display: block; font-size: 17px; }
.pv-current small { display: block; color: var(--chqt-muted); font-size: 14px; }
.pv-fams button { padding: 8px 12px; }
.pv-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 8px; }
.pv-sw {
  font-size: 16px; aspect-ratio: 1; min-height: 44px; border-radius: 12px; cursor: pointer; padding: 0;
  border: 0; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); transition: transform .12s;
}
.pv-sw:hover { transform: translateY(-2px); }
.pv-sw[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--chqt-paper), 0 0 0 5px var(--chqt-ink); }
.pv-custom { display: grid; grid-template-columns: minmax(0, 1fr) 56px; gap: 8px; }
.pv-picker { position: relative; }
.pv-picker input {
  width: 56px; height: 51px; padding: 0; border: 1.5px solid var(--chqt-line); border-radius: 12px;
  background: #fff; cursor: pointer; font-size: 16px;
}
.pv-range { display: grid; grid-template-columns: 90px minmax(0, 1fr) 30px; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.pv-range input { width: 100%; min-height: 44px; accent-color: var(--chqt-accent); font-size: 16px; }
.pv-range output { text-align: right; font-variant-numeric: tabular-nums; color: var(--chqt-muted); }
.pv-walls { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pv-walls:empty { display: none; }
.pv-walls li { display: flex; align-items: center; gap: 4px; background: #fff; border: 1px solid var(--chqt-line); border-radius: 999px; padding: 0 2px 0 4px; }
.pv-walls button {
  font: inherit; font-size: 16px; min-height: 44px; border: 0; background: none; cursor: pointer;
  color: var(--chqt-ink); display: inline-flex; align-items: center; gap: 8px; padding: 0 8px;
}
.pv-walls i { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.pv-walls .pv-x { color: var(--chqt-muted); padding: 0 12px; }
.pv .chqt-actions { margin-top: 0; }

/* ── phones: the photo edge to edge, and the colors right under it (no scrolling away to
   change color and back to tap), one swipeable row each ── */
@media (max-width: 859px) {
  .chqt[data-tool="room-paint-visualizer"] { padding: 12px; }
  .pv { gap: 12px; }
  .pv-stage { padding: 0; background: none; min-height: 200px; }
  .pv-photo, .pv-canvas { max-height: 62vh; }
  .pv-own { right: 10px; bottom: 10px; }
  .pv-hint { top: 10px; }
  .pv-step--color { order: -1; padding: 12px; gap: 10px; }
  .pv-step .pv-n { display: none; }
  .pv-step--color .pv-h { display: none; }
  .pv-fams, .pv-swatches { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding: 3px 3px 5px; margin: -3px; }
  .pv-fams::-webkit-scrollbar, .pv-swatches::-webkit-scrollbar { display: none; }
  .pv-fams button { flex: 0 0 auto; white-space: nowrap; }
  .pv-swatches { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 46px; }
  .pv-current { padding: 8px 10px; }
  .pv-chip { flex-basis: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .pv-hint, .pv-sw { transition: none; }
  .pv-stage.pv-busy .pv-frame::after { animation: none; }
}
