/* PFP tools (F41): the cropper page. Same language as pages.css: the white
   `main` card, grey #f0f0f0 chips that go black on hover, the dark #333
   Search button, and the Top/New segmented control. */

main.tool-page { max-width: 860px; }
main.tool-page h1 { margin-bottom: 8px; }
main.tool-page p.tool-lead {
  max-width: 620px;
  margin: 0 auto 22px;
  font-size: 1em;
  color: #666;
}

.cropper {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  text-align: left;
}

/* Crop area: the picture on a canvas, the circle cut out by a shadow. */
.crop-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background-color: #f0f0f0;
  background-image: conic-gradient(#e2e2e2 25%, transparent 0 50%, #e2e2e2 0 75%, transparent 0);
  background-size: 24px 24px;
  touch-action: none;
  cursor: grab;
  outline: none;
}
.crop-stage:focus-visible { box-shadow: 0 0 0 3px #333; }
.crop-stage.dragging { cursor: grabbing; }
.crop-stage.drop { box-shadow: 0 0 0 3px #333; }
.crop-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.crop-mask {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.6);
  outline: 2px solid rgba(255, 255, 255, 0.9);
  pointer-events: none;
}
.cropper[data-shape="square"] .crop-mask { border-radius: 0; box-shadow: none; outline-offset: -2px; }
.cropper:not(.ready) .crop-mask { display: none; }
.cropper p.crop-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  color: #666;
  font-size: 0.95em;
  text-align: center;
}
.cropper.ready p.crop-empty { display: none; }

/* Controls */
.tool-btn {
  display: inline-block;
  padding: 10px 18px;
  border: 1px solid #333;
  border-radius: 5px;
  background-color: #333;
  color: #fff;
  font-size: 1em;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.3s, box-shadow 0.3s;
}
.tool-btn:hover { background-color: #555; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); }
.tool-btn:disabled { opacity: 0.5; cursor: default; box-shadow: none; }
.crop-pick { position: relative; }
.crop-pick input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}
.crop-pick:focus-within { box-shadow: 0 0 0 3px #999; }
.cropper p.crop-or { margin: 6px 0 4px; font-size: 0.85em; color: #888; text-align: left; }

.tool-row { display: flex; align-items: center; gap: 12px; margin: 14px 0; }
.tool-row-top { align-items: flex-start; }
.tool-row-top .tool-label { padding-top: 9px; }
.tool-label { flex: none; width: 48px; font-size: 0.9em; font-weight: bold; color: #333; }
.crop-zoom { flex: 1; min-width: 0; accent-color: #333; }

/* Segmented control, as the Top/New toggle. */
.tool-seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 6px; background-color: #f0f0f0; }
.tool-seg button {
  min-width: 72px;
  padding: 6px 16px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: #333;
  font-family: inherit;
  font-size: 0.85em;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}
.tool-seg button:hover { background-color: #000; color: #fff; }
.tool-seg button.on { background-color: #333; color: #fff; }

/* Size chips, as the Category menu chips. */
.tool-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tool-chips button {
  padding: 8px 12px;
  border: 0;
  border-radius: 4px;
  background-color: #f0f0f0;
  color: #333;
  font-family: inherit;
  font-size: 0.85em;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}
.tool-chips button:hover { background-color: #000; color: #fff; }
.tool-chips button.on { background-color: #333; color: #fff; }

/* Live previews at real avatar sizes (the canvases are drawn at 2x). */
.crop-previews { display: flex; align-items: flex-end; gap: 18px; margin: 18px 0; }
.crop-previews figure { margin: 0; text-align: center; }
.crop-previews canvas { display: block; margin: 0 auto 4px; }
.crop-previews .pv-40 { width: 40px; height: 40px; }
.crop-previews .pv-77 { width: 77px; height: 77px; }
.crop-previews .pv-96 { width: 96px; height: 96px; }
.crop-previews figcaption { font-size: 0.75em; color: #888; }
.cropper:not(.ready) .crop-previews { visibility: hidden; }

.tool-primary { width: 100%; padding: 12px 18px; font-weight: bold; }
.cropper p.crop-info { min-height: 1.4em; margin: 8px 0 0; font-size: 0.8em; color: #888; text-align: left; line-height: 1.4; }

/* How-to list under the tool (inside the FAQ-style card). */
.tool-help ol { margin: 0 0 8px; padding-left: 22px; color: #555; font-size: 0.95em; line-height: 1.6; }
.tool-help ol li { margin-bottom: 4px; }
.tool-help h2 + ol { margin-top: 0; }
.tool-help ol + h2 { margin-top: 22px; }

@media (max-width: 720px) {
  .cropper { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .crop-stage { max-width: 380px; margin: 0 auto; }
}
