/* Map container */
.map-container {
  position: relative;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--ink-muted);
  background: var(--paper-dim);
  margin: 1.2em auto;
  max-width: var(--wide-col);
  user-select: none;
}

.leaflet-full-bleed .map-container {
  min-height: 78vh;
}

.map-viewport {
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: grab;
  position: relative;
}

.map-image-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.map-image {
  display: block;
  max-width: none;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* Markers */
.map-markers {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.map-marker {
  position: absolute;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid #8b2e2e;
  background: #c0392b;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  line-height: 1;
  z-index: 10;
  opacity: 1;
}

.map-marker:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  z-index: 20;
}

.map-marker-unlinked {
  opacity: 0.7;
  cursor: default;
}

.map-marker-glyph {
  pointer-events: none;
  font-size: 11px;
}

/* Popup */
.map-popup {
  position: absolute;
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 2px;
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
  color: var(--ink);
  box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.12);
  z-index: 100;
  min-width: 140px;
  max-width: 260px;
  pointer-events: auto;
}

.map-popup-link {
  font-family: "Alegreya Sans SC", Georgia, serif;
  color: var(--rule-dark);
  font-size: 0.95rem;
  text-decoration: none;
  display: block;
  margin-bottom: 0.25rem;
}

.map-popup-link:hover {
  color: var(--rule);
  text-decoration: underline;
}

.map-popup strong {
  font-family: "Alegreya Sans SC", Georgia, serif;
  color: var(--rule-dark);
  display: block;
  margin-bottom: 0.25rem;
}

.map-popup-text {
  color: var(--ink-soft);
  font-size: 0.82rem;
  margin-bottom: 0.4rem;
}

.map-popup-actions {
  display: flex;
  gap: 2px;
  border-top: 1px solid var(--border-soft);
  padding-top: 4px;
}

.map-popup-icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-muted);
  padding: 2px 6px;
  border-radius: 2px;
  font-size: 0.85rem;
  cursor: pointer;
  line-height: 1;
  transition: color 120ms ease, background 120ms ease;
}

.map-popup-icon-btn:hover {
  background: var(--paper-dim);
  color: var(--ink);
  border-color: var(--border);
}

.map-popup-icon-btn-delete:hover {
  color: var(--rule);
  border-color: var(--rule);
  background: var(--rule);
}

/* Controls */
.map-controls {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  z-index: 50;
}

.map-zoom-btn,
.map-add-marker-btn {
  width: 30px;
  height: 30px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 2px;
  font-size: 1.1rem;
  font-family: "Alegreya Sans SC", Georgia, serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.map-zoom-btn:hover,
.map-add-marker-btn:hover {
  background: var(--paper-dim);
  border-color: var(--ink-muted);
}

.map-add-marker-btn.add-marker-active {
  background: var(--rule);
  color: var(--paper);
  border-color: var(--rule-dark);
}

/* Modal */
.map-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(42, 31, 20, 0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-modal {
  background: var(--paper);
  border: 1px solid var(--ink);
  padding: 1.5rem;
  min-width: 300px;
  max-width: 90%;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.15);
}

.map-modal h3 {
  font-family: "Alegreya Sans SC", Georgia, serif;
  color: var(--ink);
  margin: 0 0 1rem;
  font-size: 1.1rem;
  border: none;
  padding: 0;
}

.map-input,
.map-textarea,
.map-select {
  width: 100%;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.5rem;
  background: var(--paper-dim);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 2px;
  font-family: "The Antiqua", Georgia, serif;
  font-size: 0.9rem;
  box-sizing: border-box;
}

.map-input:focus,
.map-textarea:focus,
.map-select:focus {
  outline: none;
  border-color: var(--rule);
}

.map-textarea {
  min-height: 50px;
  resize: vertical;
}

.map-modal label {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-bottom: 0.15rem;
  font-family: "Alegreya Sans SC", Georgia, serif;
  font-variant: small-caps;
  letter-spacing: 0.04em;
}

.map-modal-btns {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Hover tooltip */
.map-tooltip {
  position: absolute;
  background: var(--paper);
  border: 1px solid var(--ink-muted);
  border-radius: 2px;
  padding: 4px 8px;
  font-size: 0.78rem;
  color: var(--ink);
  box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.12);
  z-index: 200;
  min-width: 100px;
  max-width: 220px;
  pointer-events: none;
}

.map-tooltip-title {
  font-family: "Alegreya Sans SC", Georgia, serif;
  color: var(--rule-dark);
  font-size: 0.82rem;
  margin-bottom: 2px;
  font-weight: bold;
}

.map-tooltip-preview {
  color: var(--ink-soft);
  font-size: 0.75rem;
  line-height: 1.3;
}

/* Right-click context menu */
.map-context-menu {
  position: absolute;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 2px;
  box-shadow: 2px 3px 8px rgba(0, 0, 0, 0.15);
  z-index: 300;
  min-width: 160px;
  padding: 3px 0;
  font-family: "The Antiqua", Georgia, serif;
}

.map-context-item {
  padding: 5px 12px;
  font-size: 0.85rem;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.map-context-item:hover {
  background: var(--paper-dim);
  color: var(--ink);
}

.map-context-item-delete {
  color: var(--rule);
  border-top: 1px solid var(--border-soft);
}

.map-context-item-delete:hover {
  background: var(--rule);
  color: var(--paper);
}

/* Temporary marker (placed before modal saves) */
.map-marker-temp {
  opacity: 0.5;
  border-style: dashed;
}

/* Popup title */
.map-popup-title {
  font-family: "Alegreya Sans SC", Georgia, serif;
  color: var(--rule-dark);
  font-size: 0.95rem;
  margin-bottom: 0.3rem;
}

/* Link button in popup */
.map-popup-btn-link {
  color: var(--accent-blue);
  border-color: var(--accent-blue);
}

.map-popup-btn-link:hover {
  background: var(--accent-blue);
  color: var(--paper);
}

/* Overlay styles for link/delete modals */
.map-delete-overlay,
.map-link-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(42, 31, 20, 0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-move-hint {
  position: absolute;
  top: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 2px;
  font-size: 0.8rem;
  font-family: "The Antiqua", Georgia, serif;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  pointer-events: none;
}

.marker-btn-move {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-muted);
  padding: 0.2rem 0.6rem;
  border-radius: 2px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: "Alegreya Sans SC", Georgia, serif;
  font-variant: small-caps;
}

.marker-btn-move:hover {
  background: var(--paper-dim);
  color: var(--ink);
}
