/* Base typography, generic controls, popups and helpers (split from styles.css) */

.info.legend [title] {
  cursor: help;
}

.leaflet,
.easy-button-button,
.leaflet-control,
.button,
.leaflet-control-zoom-in,
.leaflet-control-zoom-out,
.leaflet-container,
.legend,
.info,
input[type="text" i],
.aqdrp-panel {
  font-family: "Inter", Arial, Helvetica, sans-serif !important;
  font-optical-sizing: auto !important;
  font-style: normal !important;
  font-weight: 300 !important;
}

#map_subtitle {
  font-weight: 500 !important;
  color: var(--text-secondary) !important;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  background-color: var(--surface-btn);
  border: 1px solid var(--surface-bar-border);
  box-shadow: var(--shadow-control);
  padding: 4px 6px;
}

#map_subtitle:hover {
  background-color: var(--surface-btn-hover) !important;
}

#map_subtitle.ts-viewing {
  color: var(--accent) !important;
}

.leaflet-control,
.easy-button-button {
  opacity: 0;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, opacity 0.4s ease, transform 0.4s ease;
}

body.fa-ready .leaflet-control,
body.fa-ready .easy-button-button {
  opacity: 1;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, opacity 0.3s ease;
}

/* popup name */
.pName {
  font-size: larger;
  font-weight: bolder;
}

.easy-button-button {
  font-size: medium;
  padding: 0 !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  min-width: 28px;
  min-height: 28px;
}

.leaflet-container,
.leaflet-tooltip {
  font-size: smaller !important;
}

.leaflet-container b,
.leaflet-tooltip b,
.leaflet-container strong,
.leaflet-tooltip strong,
.leaflet-container .pName {
  font-weight: bold !important;
}

#language_toggle>div>button {
  line-height: unset;
}

/* OTHER */

.leaflet-popup-content input[type="text" i] {
  text-align: center;
  width: 38ch;
}

.leaflet-map-pane {
  display: none;
}

.layer_group_title {
  padding: 0.1rem 0 0.1rem 0;
}

.leaflet-top,
.leaflet-bottom {
  z-index: unset !important;
}

.button {
  color: var(--text-primary);
  background-color: var(--surface-btn);
  border-width: 1px;
  border-radius: 99rem;
  cursor: pointer;
  margin-top: 5px;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.button:hover {
  background-color: var(--surface-btn-hover);
  transition: 0.3s;
}

.leaflet-bar a:hover {
  background-color: var(--surface-btn-hover) !important;
}

.leaflet-bar,
.easy-button-container,
.leaflet-control-zoom,
.leaflet-control-scale {
  z-index: 1000 !important;
}

.leaflet-control-layers-expanded .leaflet-control-layers-list {
  font-weight: 500;
  color: var(--text-secondary) !important;
}

.zone-popup {
  width: 280px;
  white-space: normal;
  word-wrap: break-word;
}

.leaflet-control-attribution {
  text-align: right;
  z-index: 1;
  max-width: 900px;
  font-size: small;
}

.info .legend .tooltip .pm_legend .leaflet-control {
  opacity: 0.95;
}

.leaflet-control-layers {
  background-color: var(--surface-control-floating) !important;
  /* Theme-invariant chrome border: #6f90b3 in both themes (no dark override), so it lives on :root as --border-control. */
  border: 1px solid var(--border-control) !important;
  z-index: 1000 !important;
}

.info.legend,
#monitor-type-legend {
  background-color: var(--surface-btn);
  border: 1px solid var(--surface-bar-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-control);
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  color: var(--text-primary);
  z-index: 400;
}

.info.legend #monitor-type-legend {
  background-color: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.info.legend.firework-legend {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Draggable legends: grab anywhere on a legend to reposition it; double-click snaps it back to its default corner. */
.info.legend {
  cursor: grab;
}

.info.legend.legend-dragging,
.info.legend.legend-dragging * {
  cursor: grabbing !important;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.info.legend.legend-dragging {
  z-index: 900; /* above other corner controls (attribution etc.) while being moved */
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  /* .leaflet-control transitions transform over 0.4s; the legend must follow the cursor exactly */
  transition: none !important;
}

/* Reset button that overlays the legend's top-right corner once it has been moved.
   Transparent until the legend is hovered, so it never shifts or hides the legend content. */
.legend-reset-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  display: none;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--border-control, #6f90b3);
  border-radius: 50%;
  background: var(--surface-btn, rgba(255, 255, 255, 0.9));
  color: var(--text-primary, #333333);
  font-size: 12px;
  line-height: 1;
  cursor: pointer !important; /* .info.legend [title] sets cursor: help */
  z-index: 1;
  opacity: 0; /* invisible until the legend is hovered */
  transition: opacity 0.2s ease;
  pointer-events: none; /* let drags pass through while invisible */
}

.legend-reset-btn.legend-reset-btn-visible {
  display: flex;
}

/* Reveal the button while the legend is hovered (or the button itself is focused) */
.info.legend:hover .legend-reset-btn,
.info.legend .legend-reset-btn:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

.legend-reset-btn:hover {
  background: var(--surface-btn-hover, #e6e6e6);
}

/* The reset button is pointless while the legend is being dragged */
.info.legend.legend-dragging .legend-reset-btn {
  display: none !important;
}

#help_button button:focus {
  outline: none;
}

.leaflet .legend {
  color: var(--text-primary) !important;
}

/* Hide-all-controls: fade out controls but keep the toggle (marked .controls-toggle) visible. */
.controls-hidden .leaflet-control:not(.controls-toggle):not(.leaflet-control-attribution),
.controls-hidden .easy-button-button:not(.controls-toggle) {
  opacity: 0 !important;
  pointer-events: none !important;
  color: var(--accent) !important;
}

/* Dark mode */

body.dark-mode .leaflet-popup-content input[type="text" i] {
  background-color: var(--input-bg);
  color: var(--input-text);
  border-color: var(--text-primary);
}

body.dark-mode #map_subtitle {
  font-weight: 500 !important;
  color: var(--text-primary) !important;
  background-color: var(--surface-control-floating) !important;
  border: 1px solid var(--surface-bar-border);
}

body.dark-mode #map_subtitle:hover {
  background-color: var(--surface-btn-hover) !important;
}

body.dark-mode #map_subtitle.ts-viewing {
  color: var(--accent) !important;
}

body.dark-mode .leaflet-control-layers-expanded .leaflet-control-layers-list {
  color: var(--text-primary) !important;
}