/* Photo to Scan - tool-specific styles.
   Loaded AFTER /assets/site.css, so everything here is scoped to the tool
   workspace (.tool) or given a ps- prefix. The page chrome (topbanner,
   header.site, .hero, .callout, footer.site) comes from the shared sheet. */

[hidden] { display: none !important; }

/* ---------- tool frame ---------- */
.tool {
  --ps-sun: var(--yellow);
  --ps-fog: #f2f2f2;
  --ps-mute: var(--ink-mute);
  --ps-edge: 3px solid var(--ink);

  border: var(--ps-edge);
  border-radius: var(--r-md);
  box-shadow: 5px 5px 0 var(--ink);
  background: var(--bg);
  overflow: hidden;
  min-height: 320px;
  margin: 24px 0 0;
}

/* ---------- step 1: pick a photo ---------- */
.tool #stage-drop { padding: 24px; display: grid; gap: 14px; justify-items: center; }
.tool .drop {
  width: 100%; min-height: 300px; display: grid; place-content: center; justify-items: center;
  gap: 8px; text-align: center; padding: 32px 20px; cursor: pointer;
  background: var(--ps-fog); border: 3px dashed var(--ink); border-radius: var(--r-sm);
}
.tool .drop strong { font-family: var(--font-display); font-size: 24px; letter-spacing: -0.02em; }
.tool .drop.over { background: var(--ps-sun); border-style: solid; }
.tool .drop:focus-within { outline: 3px solid var(--ps-sun); outline-offset: 3px; }
.tool .drop-mark { position: relative; width: 78px; height: 96px; margin-bottom: 10px; background: var(--bg); border: 2px solid var(--ink); }
.tool .drop-mark i { position: absolute; width: 16px; height: 16px; background: var(--ps-sun); border: 3px solid var(--ink); }
.tool .drop-mark i:nth-child(1) { top: -9px; left: -9px; }
.tool .drop-mark i:nth-child(2) { top: -9px; right: -9px; }
.tool .drop-mark i:nth-child(3) { bottom: -9px; right: -9px; }
.tool .drop-mark i:nth-child(4) { bottom: -9px; left: -9px; }
.tool .drop-error { margin: 0; font-weight: 600; background: var(--ps-sun); border: var(--ps-edge); padding: 8px 12px; }

/* ---------- workspace ---------- */
.tool .work { display: grid; grid-template-columns: minmax(0, 1fr) 300px; }
.tool .bed {
  position: relative; display: grid; place-items: center; padding: 20px; min-height: 360px;
  background: var(--ps-fog); border-right: var(--ps-edge); overflow: hidden;
}
.tool .bed-dark { background: var(--ink); }
.tool .bed canvas { display: block; max-width: 100%; }
.tool #crop-canvas { touch-action: none; cursor: default; }
.tool #result-canvas { box-shadow: 0 0 0 3px var(--bg); }
.tool #result-canvas.painting { cursor: crosshair; touch-action: none; }
.tool #loupe {
  position: absolute; width: 120px; height: 120px; pointer-events: none;
  border: var(--ps-edge); border-radius: 50%; background: var(--bg); box-shadow: 4px 4px 0 var(--ink);
}
.tool .busy {
  position: absolute; top: 16px; left: 16px; background: var(--ps-sun); border: var(--ps-edge);
  padding: 4px 10px; font-weight: 700;
}

/* ---------- side panel ---------- */
.tool .panel { padding: 20px; display: grid; gap: 18px; align-content: start; }
.tool .panel h2 { font-family: var(--font-display); font-weight: 800; font-size: 22px; letter-spacing: -0.01em; margin: 0; }
.tool .hint { margin: -8px 0 0; font-size: 14.5px; color: var(--ps-mute); line-height: 1.5; }
.tool .field { display: grid; gap: 8px; }
.tool .field > label,
.tool .label,
.tool .brush-tools > label { font-weight: 700; font-size: 14.5px; }
.tool .ps-note { margin: 0; font-size: 13.5px; color: var(--ps-mute); min-height: 1em; }
.tool .row { display: flex; gap: 8px; flex-wrap: wrap; }
.tool .row > .btn { flex: 1 1 auto; }

/* ---------- form controls ---------- */
.tool select, .tool input[type="range"] { width: 100%; }
.tool select {
  font: inherit; font-weight: 600; padding: 9px 10px; border: var(--ps-edge); background: var(--bg);
  border-radius: var(--r-sm); color: var(--ink);
}
.tool input[type="range"] { accent-color: var(--ink); }
.tool .check { display: flex; gap: 8px; align-items: center; font-size: 14.5px; font-weight: 500; }
.tool .check input { width: 18px; height: 18px; accent-color: var(--ink); }

/* ---------- buttons (override the shared .btn inside the workspace) ---------- */
.tool .btn {
  font: inherit; font-weight: 700; font-size: 14.5px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 14px; border: var(--ps-edge); border-radius: var(--r-sm);
  background: var(--bg); color: var(--ink);
  cursor: pointer; box-shadow: 3px 3px 0 var(--ink);
  transition: transform .06s, box-shadow .06s;
}
.tool .btn:hover { background: var(--ps-fog); color: var(--ink); transform: none; box-shadow: 3px 3px 0 var(--ink); }
.tool .btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.tool .btn:focus-visible,
.tool .btn-text:focus-visible,
.tool select:focus-visible,
.tool .seg input:focus-visible + span { outline: 3px solid var(--ps-sun); outline-offset: 2px; }
.tool .btn-primary { background: var(--ps-sun); font-size: 16px; padding: 12px 16px; }
.tool .btn-primary:hover { background: #ffe34d; }
.tool .btn-wide { width: 100%; }
.tool .btn[aria-pressed="true"] { background: var(--ink); color: var(--ps-sun); }
.tool .btn[aria-pressed="true"]:hover { background: var(--ink); color: var(--ps-sun); }
.tool .btn-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: square; }
.tool .btn-text {
  font: inherit; font-size: 14.5px; font-weight: 600; background: none; border: 0; padding: 4px 0;
  color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; justify-self: start;
}

/* ---------- segmented controls ---------- */
.tool .seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: var(--ps-edge); border-radius: var(--r-sm); overflow: hidden; }
.tool .seg label { position: relative; cursor: pointer; }
.tool .seg label + label { border-left: var(--ps-edge); }
.tool .seg input { position: absolute; opacity: 0; }
.tool .seg span { display: block; text-align: center; padding: 8px 4px; font-weight: 700; font-size: 14.5px; }
.tool .seg input:checked + span { background: var(--ps-sun); }

.tool .download { grid-template-columns: 92px 1fr; }

/* ---------- below the tool ---------- */
.local-note { font-weight: 600; font-size: 14.5px; margin: 18px 0 0; }
.how { margin-top: 48px; max-width: 760px; }
.how ol { margin: 0; padding-left: 1.3em; display: grid; gap: 12px; color: var(--ink-mute); }
.how ol strong { color: var(--ink); }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  .tool .work { grid-template-columns: 1fr; }
  .tool .bed { border-right: 0; border-bottom: var(--ps-edge); padding: 12px; min-height: 260px; }
}
@media (max-width: 420px) {
  .tool { box-shadow: 3px 3px 0 var(--ink); }
  .tool #stage-drop, .tool .panel { padding: 14px; }
  .tool .drop strong { font-size: 20px; }
}

.tool .btn.camera-btn { display: none; }
@media (pointer: coarse) { .tool .btn.camera-btn { display: inline-flex; } }

@media (prefers-reduced-motion: reduce) {
  .tool .btn { transition: none; }
}
