/* Trap map & details (static/org/traps.js), for the org app and Today.
   Uses org.css's tokens; both pages load org.css first. */

.tm-layer {
  position: fixed; inset: 0; z-index: 1300; background: var(--scrim);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.tm-dlg {
  background: var(--surface); color: var(--ink); border-radius: var(--r-card);
  width: 100%; max-width: 560px; max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column; box-shadow: var(--pop-shadow);
}
.tm-detail .tm-dlg { max-width: 640px; }
.tm-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 6px 20px; }
.tm-head h2 { flex: 1; min-width: 0; margin: 0; font-size: 19px; }
.tm-x { min-width: 48px; min-height: 48px; border: 0; background: none; font-size: 28px; line-height: 1; cursor: pointer; color: var(--ink2); }
.tm-body { padding: 4px 20px 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.tm-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line2); }

/* phone: a full-screen sheet */
@media (max-width: 600px) {
  .tm-layer { padding: 0; align-items: stretch; }
  .tm-dlg { max-width: none; max-height: none; height: 100dvh; border-radius: 0; }
  .tm-foot .tm-btn { flex: 1; }
}

.tm-lbl { display: block; margin: 12px 0 4px; font-size: 13px; font-weight: 600; color: var(--ink2); }
.tm-body select, .tm-body input[type=text], .tm-body textarea {
  width: 100%; box-sizing: border-box; min-height: 48px; padding: 10px 12px; font: inherit; font-size: 16px;
  border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface); color: var(--ink);
}
.tm-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 18px;
  border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.tm-btn:disabled { opacity: .6; cursor: default; }
.tm-p { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tm-danger { color: var(--danger); border-color: var(--danger-line); }
.tm-link { min-height: 48px; padding: 0 8px; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
.tm-acts { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.tm-wrap { flex-wrap: wrap; }

.tm-map {
  height: 300px; min-height: 280px; border-radius: var(--r-ctl); border: 1px solid var(--line);
  background: var(--map-ground);       /* no tiles (no signal): the outlines on a plain ground */
  overflow: hidden;
}
@media (min-height: 800px) { .tm-map { height: 340px; } }
.tm-nomap { margin: 0; padding: 12px; background: var(--warn-bg); color: var(--warn-tx); border-radius: var(--r-ctl); font-size: 14px; }
.tm-under { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; min-height: 22px; font-size: 15px; }
.tm-block { font-weight: 700; }
.tm-acc { color: var(--ink2); }
.tm-warn { color: var(--warn-tx); font-weight: 600; }
.tm-note { margin: 12px 0 0; font-size: 14px; color: var(--ink2); }
.tm-err { margin: 8px 0 0; min-height: 1em; color: var(--danger); font-weight: 600; font-size: 14px; }
.tm-err:empty { display: none; }

/* the farm's trap map on the Traps tab */
/* Leaflet's panes and controls carry z-indexes up to 1000: keep them inside
   the map, under the app's sticky header and bars (every map in /org). */
.leaflet-container { isolation: isolate; z-index: 0; }
/* taller on a desktop, so a farm's main orchard frames closer (Green Mountain Orchards) */
.tm-farm { height: clamp(320px, 48vh, 480px); margin: 4px 16px 12px; border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--map-ground); overflow: hidden; }
@media (max-width: 600px) { .tm-farm { height: 280px; margin: 4px 12px 12px; } }

/* block names (traps.js labelBlocks): map.html's look, centred on the block */
.tm-blabel { background: none; border: 0; }
.tm-blabel span { display: inline-block; transform: translate(-50%, -50%); white-space: nowrap; color: #fff;
  font-weight: 700; font-size: 13px; text-shadow: 0 0 3px #000, 0 0 2px #000; pointer-events: none; }
/* The Traps tab's map: the Map tab's block label (map.html .block-label) */
.tm-blabel-map span { position: relative; background: rgba(0, 0, 0, 0.6); border-radius: 4px; padding: 3px 7px; text-align: center;
  font-weight: 500; font-size: 12px; line-height: 1.2; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9); }
.tm-blabel-map small { display: block; font-size: 10px; opacity: 0.85; }
/* its crop key (more than one crop) */
.tm-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; max-width: 260px; padding: 6px 10px;
  background: var(--map-panel); border-radius: var(--r-sm); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  font-size: 12px; color: var(--map-panel-tx); }
.tm-legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tm-legend i { width: 12px; height: 12px; border: 2px solid; border-radius: 2px; box-sizing: border-box;
  background-clip: content-box; opacity: 0.9; }

/* details */
.tm-meta { color: var(--ink2); font-size: 15px; margin-top: 2px; }
.tm-notes { margin: 10px 0 0; white-space: pre-wrap; font-style: italic; color: var(--ink2); }
.tm-chart { position: relative; height: 200px; margin-top: 14px; }
.tm-h3 { margin: 18px 0 8px; font-size: 15px; }
.tm-who { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 2px 0 4px; }
.tm-chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--mute-bg); color: var(--mute-tx); }
.tm-chip-org { background: var(--ok-bg); color: var(--ok-tx); }
.tm-chip-grower { background: var(--info-bg); color: var(--info-tx); }
.tm-open { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--accent); }
.tm-row-link { cursor: pointer; }
.tm-row-link:hover, .tm-row-link:focus-visible { border-color: var(--accent) !important; outline: none; }
.tm-lures { margin: 0; padding-left: 18px; color: var(--ink2); font-size: 14px; }
.tm-lures li { margin: 2px 0; }

/* the visit's trap label: a button that opens the trap's menu */
.trow-label-btn { display: block; padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }

/* dark theme: Leaflet's own controls and popups in the app's colours (the map tiles stay as they are) */
[data-theme="dark"] .leaflet-bar a, [data-theme="dark"] .leaflet-bar a:hover { background: var(--surface); color: var(--ink); border-bottom-color: var(--line); }
[data-theme="dark"] .leaflet-bar { border-color: var(--line); }
[data-theme="dark"] .leaflet-popup-content-wrapper, [data-theme="dark"] .leaflet-popup-tip { background: var(--surface); color: var(--ink); }
[data-theme="dark"] .leaflet-container .leaflet-control-attribution { background: rgba(29, 35, 31, .8); color: var(--ink2); }
[data-theme="dark"] .leaflet-container .leaflet-control-attribution a { color: var(--accent); }
