/* leaflet-area-selection — 2.0-native rewrite styles (readable class names). */

/* Toggle button — surface tokens like every other control, so it themes
   with the app for free (no dedicated dark override in styles.css). */
.area-select-control button {
  appearance: none;
  font-family: inherit;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  margin: 1px;
  width: 30px;
  height: 30px;
  box-sizing: content-box;
  cursor: pointer;
  background-color: var(--surface);
  box-shadow: rgb(0 0 0 / 65%) 0 1px 5px;
  position: relative;
}
/* The polygon glyph is a dark-on-transparent PNG. It sits on its own layer
   so dark mode can invert JUST the glyph — inverting the whole button (the
   old approach) flipped the now-dark surface background back to white. */
.area-select-control button::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('/areas/static/img/area-icon.png');
  background-size: cover;
}
[data-theme="dark"] .area-select-control button::after {
  filter: invert(1) hue-rotate(180deg);
}
.area-select-control button:hover,
.area-select-control button:focus {
  background-color: var(--hover-color);
  transition: background-color 0.2s ease-out;
}
.area-select-control button.active {
  background-color: var(--primary-color);
}

/* crosshair cursor while drawing; hide attribution to avoid stray clicks */
.area-select-drawing {
  cursor: crosshair;
}
.area-select-drawing .leaflet-control-attribution {
  display: none;
}

/* Existing area polygons stay visible but stop intercepting clicks/hover for
   the whole draw+adjust session — they'd otherwise pop up over the shape
   being drawn. Leaflet's own stylesheet sets pointer-events:auto on
   path.leaflet-interactive with higher specificity than a plain pane rule,
   so this has to target the same path selector to win the cascade. The
   vertex/ghost handles live in the marker pane, untouched. */
.area-select-active .leaflet-pane > svg path.leaflet-interactive {
  pointer-events: none;
}

/* vertex handles */
.area-select-vertex {
  width: 16px;
  height: 16px;
  border: 1px solid #0e4e73;
  background-color: #fff;
  cursor: move;
  box-sizing: border-box;
}
.area-select-vertex:hover,
.area-select-vertex.active {
  background-color: #0e4e73;
}

/* mid-point (ghost) insert handles */
.area-select-ghost {
  width: 14px;
  height: 14px;
  background-color: #c0c0c0;
  opacity: 0.5;
  cursor: copy;
  box-sizing: border-box;
}
.area-select-ghost.active {
  opacity: 0.9;
}

/* enlarge touch target on coarse pointers */
@media (hover: none) and (pointer: coarse) {
  .area-select-vertex::after {
    content: '';
    display: block;
    width: 100%;
    height: 100%;
    padding: 15px;
    margin: -15px 0 0 -15px;
  }
}

/* animated rectangle-sweep outline */
.leaflet-overlay-pane path.rect-progress-line {
  stroke-dasharray: 10;
  animation: area-select-dash 10s linear infinite;
}

@keyframes area-select-dash {
  to { stroke-dashoffset: 1000; }
}
