/* RF4 Spots — страница «Карта». Тёмная тема проекта (переменные из style.css),
   ничего внешнего: картинка карты + canvas-оверлей.

   Слои карты (снизу вверх):
     .map-frame  → <img> бумажной карты
                 → <canvas> (полигоны зон, точки, подписи)
                 → .map-tooltip
*/

.map-page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 18px 28px;
}

/* ─────────────────────────── верхняя панель ─────────────────────────── */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-2);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 12px;
  white-space: nowrap;
  transition: border-color .15s, background-color .15s, color .15s;
}

.back-link:hover {
  border-color: #3a4b50;
  background: var(--bg-3);
  color: var(--text);
}

/* ─────────────────────────── панель управления ─────────────────────────── */

.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 12px;
}

.map-select { width: 260px; max-width: 100%; }

.map-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  padding-bottom: 7px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
  user-select: none;
}

.check input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: #6fc394;
  cursor: pointer;
}

.map-meta {
  margin-left: auto;
  padding-bottom: 5px;
  color: var(--muted);
  font: 11.5px/1.4 var(--mono);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.map-meta strong { color: var(--text-dim); font-weight: 600; }

/* ─────────────────────────── раскладка ─────────────────────────── */

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 352px;
  gap: 14px;
  align-items: start;
}

/* ─────────────────────────── сама карта ─────────────────────────── */

.map-frame {
  position: relative;
  width: min(100%, calc(100vh - 240px));
  min-width: 0;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0a0e0f;
  box-shadow: 0 10px 32px rgba(0, 0, 0, .38);
}

.map-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.map-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: manipulation;
}

.map-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  background: var(--bg-1);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .3px;
}

.map-loading::after {
  content: "";
  width: 14px;
  height: 14px;
  margin-left: 8px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: map-spin .8s linear infinite;
}

@keyframes map-spin { to { transform: rotate(360deg); } }

.map-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 24px;
  background: var(--bg-1);
  text-align: center;
}

.map-empty h2 { font-size: 15px; font-weight: 600; }
.map-empty p { color: var(--muted); font-size: 12px; line-height: 1.5; }

/* подсказка при наведении на точку */
.map-tooltip {
  position: absolute;
  z-index: 5;
  max-width: 260px;
  padding: 5px 8px;
  border: 1px solid #3c4c50;
  border-radius: 6px;
  background: rgba(10, 14, 15, .95);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
  color: var(--text);
  font: 11.5px/1.35 var(--mono);
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 10px));
}

.map-tooltip .tip-coord { color: var(--coords); font-weight: 600; }
.map-tooltip .tip-dim { color: var(--muted); }

/* точка у верхнего края: подсказка уходит вниз, чтобы не обрезалась */
.map-tooltip.is-below { transform: translate(-50%, 12px); }

/* ─────────────────────────── боковая панель ─────────────────────────── */

.map-side {
  position: sticky;
  top: calc(var(--topbar-h) + 14px);
  display: flex;
  flex-direction: column;
  gap: 11px;
  height: max(320px, calc(100vh - 240px));
  padding: 12px 13px 13px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-1);
  scrollbar-width: thin;
  scrollbar-color: #2c3a3e transparent;
}

.side-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.side-title {
  color: var(--muted-2);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.side-hint { color: var(--muted-2); font-size: 10px; }

.spot-empty p { color: var(--muted); font-size: 12px; line-height: 1.55; }
.spot-empty-sub { margin-top: 8px; color: var(--muted-2) !important; font-size: 11px !important; }

/* быстрый выбор самых горячих точек (альтернатива клику по canvas) */

.hot-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

.hot-list .side-title { display: block; }

.hot-items { display: flex; flex-direction: column; gap: 4px; }

.hot-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 7px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: var(--bg-2);
  color: var(--text-dim);
  font: 11.5px/1.3 var(--mono);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}

.hot-item:hover { border-color: #3a4b50; background: var(--bg-3); }

.hot-coord { color: var(--coords); font-weight: 600; }
.hot-meta { color: var(--muted); font-size: 10.5px; }

/* выбранная точка */

.spot { display: flex; flex-direction: column; gap: 0; }

.spot-coord-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.spot-coord-box { display: flex; flex-direction: column; gap: 1px; min-width: 0; }

.spot-coord-label {
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .8px;
  text-transform: uppercase;
}

.spot-coord {
  color: var(--coords);
  font: 600 24px/1.1 var(--mono);
  letter-spacing: .5px;
  font-variant-numeric: tabular-nums;
}

.spot-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0 0;
  padding: 7px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--bg-2);
}

.spot-facts div { min-width: 0; }

.spot-facts dt {
  color: var(--muted-2);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: .7px;
  text-transform: uppercase;
}

.spot-facts dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.3;
}

.spot-posts-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 14px 0 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

.spot-posts-count { color: var(--muted); font: 11px var(--mono); }

.spot-posts { display: flex; flex-direction: column; gap: 8px; }

.post-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 9px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--bg-2);
}

.post-card-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted-2);
  font-size: 10px;
  line-height: 1.3;
}

.post-card-top .post-source { text-transform: uppercase; letter-spacing: .4px; }
.post-card-date { white-space: nowrap; font-variant-numeric: tabular-nums; }

.post-card-text {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-dim);
  font-size: 11.5px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow-wrap: anywhere;
}

.post-card-chips { display: flex; flex-wrap: wrap; gap: 4px; }

.post-chip {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-3);
  color: var(--muted);
  font: 10px/1.55 var(--mono);
}

.post-chip-fish { border-color: #2f4f3b; color: #a6e6bc; }
.post-chip-weight { border-color: #4a3f28; color: #e2c179; }

.post-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 10.5px;
}

.post-card-author { color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.post-card-link { color: var(--accent); text-decoration: none; white-space: nowrap; }
.post-card-link:hover { text-decoration: underline; }

.spot-posts-state {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

/* легенда */

.side-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

.legend-ramp { display: flex; flex-direction: column; gap: 3px; }

.legend-bar {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, #3f8f63 0%, #7fb45a 30%, #e0b64a 55%, #e08a3c 78%, #d95f45 100%);
}

.legend-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted-2);
  font: 10px var(--mono);
  font-variant-numeric: tabular-nums;
}

.legend-caption,
.legend-zone { color: var(--muted-2); font-size: 10.5px; line-height: 1.4; }

.legend-swatch {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 6px;
  border: 1px dashed #6fc394;
  border-radius: 2px;
  background: rgba(111, 195, 148, .18);
  vertical-align: -1px;
}

/* дополнительное уведомление (в style.css есть только error/demo) */

.notice-info {
  border-color: #2f4a3b;
  background: #131e18;
  color: #b6d9c4;
}

/* ─────────────────────────── адаптив ─────────────────────────── */

@media (max-width: 1120px) {
  .map-layout { grid-template-columns: minmax(0, 1fr); }
  .map-side { position: static; height: auto; max-height: none; }
  .map-frame { width: min(100%, 780px); }
}

@media (max-width: 640px) {
  .map-page { padding: 10px 12px 22px; }
  .map-toolbar { gap: 10px; }
  .map-select { width: 100%; }
  .map-meta { margin-left: 0; text-align: left; }
  .map-checks { gap: 12px; }
  .map-frame { width: 100%; }
}

.posts-load-btn { margin-top: 10px; }

/* Сводка по точке: лучшие наживки и веса уловов */
.spot-baits {
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--line, #23302b);
  border-radius: 8px;
  background: rgba(111, 195, 148, 0.05);
}
.spot-baits-title {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2, #7f8f88);
  margin-bottom: 6px;
}
.spot-baits-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 3px;
}
.spot-baits-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  line-height: 1.35;
}
.spot-bait-name {
  color: var(--text, #e7eeea);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.spot-bait-count {
  color: var(--coords, #f0c674);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.spot-baits-weight {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted-2, #7f8f88);
}