/* Totemia GIS — styles for the smart border tools + enhanced draw cursor.
 * Reuses the bold map viewer tokens (gold, green, Inter 800, square corners) from
 * gis-regions.css / map-viewer.css. No new look, no decorative gradients. Kept in
 * its own file because gis-regions.css is already over the 650-line soft cap. */

:root {
  --gist-gold: #c4981f;
  --gist-green: #123c32;
  --gist-ink: #14171a;
  --gist-muted: #5b636c;
  --gist-line: #e3e6ea;
  --gist-red: #9f2f24;
  --gist-paper: #ffffff;
  --gist-font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ── Enhanced draw cursor (crosshair + snap ring + live coords) ─────────── */

/* Hide the system pointer over the map canvas while drawing, but keep a normal
 * cursor over the floating controls so they stay usable. */
.gis-draw-cursor-active.ol-viewport,
.gis-draw-cursor-active .ol-layers,
.gis-draw-cursor-active canvas {
  cursor: none;
}

.gis-draw-cursor-active .gis-editor-toolbar,
.gis-draw-cursor-active .gis-tools-panel,
.gis-draw-cursor-active .gis-editor-reshape,
.gis-draw-cursor-active .gis-legend,
.gis-draw-cursor-active .ol-zoom,
.gis-draw-cursor-active .ol-control {
  cursor: auto;
}

.gis-draw-cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  z-index: 15;
  pointer-events: none;
  will-change: left, top;
}

/* Crosshair — two gold lines with a precise gap at the exact hot-spot. */
.gis-draw-cross::before,
.gis-draw-cross::after {
  content: "";
  position: absolute;
  background: var(--gist-gold);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.65);
}

.gis-draw-cross::before {
  left: -1px;
  top: -13px;
  width: 2px;
  height: 26px;
}

.gis-draw-cross::after {
  top: -1px;
  left: -13px;
  height: 2px;
  width: 26px;
}

/* Soft snap ring — brightens to green when over a weldable neighbour target. */
.gis-draw-ring {
  position: absolute;
  left: -13px;
  top: -13px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(196, 152, 31, 0.55);
  background: rgba(196, 152, 31, 0.08);
  transition: transform 0.08s ease, border-color 0.1s ease, background 0.1s ease;
}

.gis-draw-cursor.snapped .gis-draw-ring {
  border-color: #2f6f4f;
  background: rgba(47, 111, 79, 0.18);
  transform: scale(1.18);
}

/* Brush gap-close cursor — a gold ring sized to the brush radius; centred on the
 * pointer. Vertices it covers light up and weld to the neighbour on release. */
.gis-brush-cursor {
  position: absolute;
  z-index: 16;
  border-radius: 50%;
  border: 2px solid var(--gist-gold);
  background: rgba(196, 152, 31, 0.12);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5);
  pointer-events: none;
  transform: translate(-50%, -50%);
  will-change: left, top;
}

.gis-brush-cursor[hidden] {
  display: none;
}

.gis-draw-coords {
  position: absolute;
  left: 16px;
  top: 12px;
  padding: 2px 6px;
  background: rgba(18, 23, 18, 0.86);
  color: #fff;
  font-family: var(--gist-font);
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* ── Border tools panel (top-right, reshape mode only) ─────────────────── */

.gis-tools-panel {
  position: absolute;
  top: 12px;
  right: 10px;
  z-index: 13;
  width: max-content;
  min-width: 208px;
  max-width: min(280px, 74vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 13px;
  background: var(--gist-paper);
  border: 2px solid var(--gist-line);
  border-top: 3px solid var(--gist-gold);
  box-shadow: 0 8px 22px rgba(20, 23, 20, 0.16);
  font-family: var(--gist-font);
}

.gis-tools-title {
  color: var(--gist-green);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.gis-tools-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gis-tools-label {
  color: var(--gist-muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.gis-tools-tolval {
  color: var(--gist-green);
  font-variant-numeric: tabular-nums;
}

.gis-tools-range {
  width: 100%;
  accent-color: var(--gist-gold);
  cursor: pointer;
}

.gis-tools-grid {
  display: grid;
  gap: 8px;
}

.gis-tools-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border: 2px solid var(--gist-line);
  border-radius: 0;
  background: var(--gist-paper);
  color: var(--gist-ink);
  font-family: var(--gist-font);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  cursor: pointer;
}

.gis-tools-btn:hover {
  border-color: var(--gist-gold);
  color: var(--gist-green);
}

.gis-tools-btn.primary {
  background: var(--gist-gold);
  border-color: var(--gist-gold);
  color: #111611;
}

.gis-tools-btn.primary:hover {
  filter: brightness(1.05);
  color: #111611;
}

.gis-tools-result:empty {
  display: none;
}

.gis-tools-result {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 2px;
  border-top: 1px solid var(--gist-line);
}

.gis-tools-note {
  color: var(--gist-ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.gis-tools-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gis-tools-actions .gis-tools-btn {
  flex: 1 1 auto;
}

/* Inline save error on the reshape bar (self-intersection block). */
.gis-editor-reshape-error {
  flex: 1 1 100%;
  color: var(--gist-red);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
}

.gis-editor-reshape-error[hidden] {
  display: none;
}

/* ── Delete security modal (gis-region-delete.js) ──────────────────────────
 * Reuses the shared .gis-editor-overlay / .gis-editor-modal shell; these classes
 * only add the danger accent, the cooling-off countdown, and the passkey status
 * row. Flat status flags (left bar + 900 text), no rounded pills (Rule 1.6). */

/* Sit above the form overlay it is raised from. */
.gis-delete-overlay {
  z-index: 1100;
}

.gis-delete-modal {
  width: min(460px, 96vw);
  border-top-color: var(--gist-red);
}

.gis-delete-tag {
  color: var(--gist-red);
}

.gis-delete-head .gis-delete-glyph {
  display: inline-flex;
  flex: 0 0 auto;
  color: var(--gist-red);
}

.gis-delete-warn {
  margin: 0 0 14px;
  padding: 9px 12px;
  background: rgba(159, 47, 36, 0.07);
  border-left: 3px solid var(--gist-red);
  color: var(--gist-ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.gis-delete-countdown {
  display: block;
  margin: 0 0 12px;
  padding-left: 10px;
  border-left: 3px solid var(--gist-red);
  color: var(--gist-red);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

.gis-delete-countdown.clear {
  border-left-color: #2f6f4f;
  color: #2f6f4f;
}

.gis-delete-passkey {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  padding: 9px 12px;
  background: var(--gist-paper);
  border: 1px solid var(--gist-line);
  border-left-width: 3px;
  color: var(--gist-ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.gis-delete-passkey .gis-delete-pk-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gist-muted);
}

.gis-delete-passkey.required {
  border-left-color: var(--gist-gold);
}

.gis-delete-passkey.required .gis-delete-pk-dot {
  background: var(--gist-gold);
}

.gis-delete-passkey.none {
  border-left-color: var(--gist-muted);
  color: var(--gist-muted);
}

.gis-delete-passkey.checking {
  border-left-color: var(--gist-line);
  color: var(--gist-muted);
}

.gis-delete-passkey.checking .gis-delete-pk-dot {
  animation: gis-delete-pulse 1.1s ease-in-out infinite;
}

.gis-delete-field {
  margin-bottom: 4px;
}

@keyframes gis-delete-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .gis-draw-ring { transition: none; }
  .gis-delete-passkey.checking .gis-delete-pk-dot { animation: none; opacity: 0.6; }
}

@media (pointer: coarse) {
  .gis-tools-btn { min-height: 44px; }
}

@media (max-width: 560px) {
  .gis-tools-panel {
    top: 8px;
    right: 8px;
    min-width: 0;
    max-width: min(232px, 70vw);
  }
}
