/* SneckWorld — нижняя панель карты */

/* Прячем стандартные элементы Pl3xMap */
#sidebar,
.leaflet-control-zoom,
.leaflet-control-coordinates,
.leaflet-control-link {
  display: none !important;
}

#sw-toolbar,
#sw-players-panel {
  position: fixed;
  z-index: 1000;
  background: rgba(18, 18, 22, 0.82);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  font: 600 14px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #eeeeee;
}

#sw-toolbar {
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  max-width: calc(100vw - 32px);
  user-select: none;
  animation: sw-bar-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes sw-bar-in {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

#sw-toolbar [hidden] {
  display: none !important;
}

/* Миры */
.sw-worlds {
  position: relative;
  display: flex;
  gap: 2px;
  padding: 2px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
}

.sw-world-indicator {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: 0;
  border-radius: 8px;
  background: #fad282;
  box-shadow: 0 2px 8px rgba(250, 210, 130, 0.25);
  pointer-events: none;
}

.sw-worlds.ready .sw-world-indicator {
  transition: transform 0.3s cubic-bezier(0.3, 0.9, 0.3, 1), width 0.3s cubic-bezier(0.3, 0.9, 0.3, 1);
}

.sw-world {
  position: relative;
  border: 0;
  background: none;
  color: #dddddd;
  padding: 8px 11px;
  border-radius: 8px;
  font: inherit;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.25s, transform 0.12s;
}

.sw-world:active {
  transform: scale(0.94);
}

.sw-world:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sw-world.active,
.sw-world.active:hover {
  background: transparent;
  color: #2a2112;
}

/* Разделители и кнопки */
.sw-sep {
  width: 1px;
  height: 22px;
  margin: 0 4px;
  background: rgba(255, 255, 255, 0.12);
}

.sw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  min-width: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: #eeeeee;
  font: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.2s, opacity 0.2s, transform 0.12s;
}

.sw-btn:active:not(:disabled) {
  transform: scale(0.9);
}

.sw-btn svg {
  transition: transform 0.25s cubic-bezier(0.3, 0.9, 0.3, 1);
  width: 18px;
  height: 18px;
}

.sw-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sw-btn:disabled {
  opacity: 0.35;
  background: none;
  cursor: default;
}

.sw-btn.open {
  background: rgba(250, 210, 130, 0.15);
  color: #fad282;
}

.sw-btn.open svg {
  transform: scale(1.12);
}

.sw-count {
  display: inline-block;
  font-variant-numeric: tabular-nums;
}

.sw-count.bump {
  animation: sw-bump 0.35s ease;
}

@keyframes sw-bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.3); color: #fad282; }
  100% { transform: scale(1); }
}

/* Координаты */
.sw-coords {
  padding: 0 8px;
  color: #b5b5b5;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.sw-coords b {
  display: inline-block;
  min-width: 4.5ch;
  color: #ffffff;
  font-weight: 600;
}

.sw-dot {
  margin: 0 8px 0 2px;
  color: #777777;
}

/* Список игроков */
#sw-players-panel {
  top: 16px;
  left: 16px;
  bottom: 16px;
  width: 290px;
  max-width: calc(100vw - 32px);
  display: flex;
  flex-direction: column;
  padding: 14px 10px 8px;
  border-radius: 16px;
  font-weight: 500;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-16px) scale(0.98);
  transform-origin: left center;
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.3, 0.9, 0.3, 1), visibility 0s linear 0.25s;
}

#sw-players-panel.open {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.3, 0.9, 0.3, 1), visibility 0s;
}

.sw-pp-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px 12px;
}

.sw-pp-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 20px;
  color: #ffffff;
}

.sw-pp-sub {
  margin-top: 2px;
  font-size: 12px;
  line-height: 16px;
  color: #9a9a9a;
}

.sw-pp-online {
  font-size: 13px;
  line-height: 20px;
  color: #a8a8a8;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.sw-pp-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 10px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #9a9a9a;
  cursor: text;
  transition: border-color 0.15s;
}

.sw-pp-search:focus-within {
  border-color: rgba(250, 210, 130, 0.6);
}

.sw-pp-search svg {
  flex: none;
  width: 16px;
  height: 16px;
}

.sw-pp-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: none;
  color: #ffffff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
}

.sw-pp-search input::placeholder {
  color: #8a8a8a;
}

.sw-pp-search input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.sw-pp-list {
  flex: 1;
  overflow-y: auto;
  margin: 0 -4px;
  padding: 0 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.sw-pp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: #eeeeee;
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sw-pp-row:hover {
  background: rgba(255, 255, 255, 0.07);
}

.sw-pp-row:disabled {
  opacity: 0.4;
  cursor: default;
  background: none;
}

.sw-pp-row.following {
  background: rgba(250, 210, 130, 0.12);
  color: #fad282;
}

.sw-pp-row img {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 5px;
  image-rendering: pixelated;
}

.sw-pp-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sw-pp-world {
  flex: none;
  font-size: 12px;
  color: #a8a8a8;
}

.sw-pp-empty {
  padding: 16px 8px;
  color: #8a8a8a;
  text-align: center;
  font-size: 13px;
}

/* Телефоны */
@media (max-width: 560px) {
  #sw-toolbar {
    bottom: 10px;
  }
  .sw-coords,
  .sw-coords-sep {
    display: none !important;
  }
  #sw-players-panel {
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 70px;
    width: auto;
    max-width: none;
  }
}

/* Кто отключил анимации в системе — без них */
@media (prefers-reduced-motion: reduce) {
  #sw-toolbar,
  #sw-toolbar *,
  #sw-players-panel {
    animation: none !important;
    transition: none !important;
  }
}

/* ===== Подсказки и всплывающие окна у меток ===== */

/* Подсказка при наведении */
.leaflet-tooltip {
  padding: 6px 10px;
  background: rgba(18, 18, 22, 0.9);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(250, 210, 130, 0.35);
  border-radius: 9px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  color: #f2f2f2;
  font: 600 13px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  animation: sw-tip-in 0.15s ease-out;
}

@keyframes sw-tip-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Хвостик подсказки — в цвет фона */
.leaflet-tooltip-top:before    { border-top-color: rgba(18, 18, 22, 0.9); }
.leaflet-tooltip-bottom:before { border-bottom-color: rgba(18, 18, 22, 0.9); }
.leaflet-tooltip-left:before   { border-left-color: rgba(18, 18, 22, 0.9); }
.leaflet-tooltip-right:before  { border-right-color: rgba(18, 18, 22, 0.9); }

/* Окно по клику на метку */
.leaflet-popup-content-wrapper {
  background: rgba(18, 18, 22, 0.92);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(250, 210, 130, 0.35);
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  color: #f2f2f2;
}

.leaflet-popup-content {
  margin: 12px 14px;
  font: 500 13px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.leaflet-popup-content a {
  color: #fad282;
}

.leaflet-popup-tip {
  background: rgba(18, 18, 22, 0.92);
  box-shadow: none;
}

.leaflet-container a.leaflet-popup-close-button {
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  color: #9a9a9a;
  font: 400 18px/22px system-ui, sans-serif;
  transition: background 0.15s, color 0.15s;
}

.leaflet-container a.leaflet-popup-close-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fad282;
}

/* Иконки меток (спавн и т. п.) — подсветка при наведении */
.leaflet-marker-pane img.leaflet-marker-icon.leaflet-interactive {
  transition: filter 0.15s;
}

.leaflet-marker-pane img.leaflet-marker-icon.leaflet-interactive:hover {
  filter: brightness(1.15) drop-shadow(0 0 6px rgba(250, 210, 130, 0.7));
}

/* Во время зума возвращаем иконкам родную анимацию Leaflet, иначе они «телепортируются» */
.leaflet-zoom-anim .leaflet-marker-pane img.leaflet-marker-icon.leaflet-zoom-animated {
  transition: transform 0.25s cubic-bezier(0, 0, 0.25, 1), filter 0.15s;
}

/* ===== Фон за границей мира ===== */
#map {
  background: radial-gradient(ellipse at center, #1b1b21 0%, #0c0c0f 100%) !important;
}

body[data-sw-world="nether"] #map {
  background: radial-gradient(ellipse at center, #2a1416 0%, #100708 100%) !important;
}

body[data-sw-world="the_end"] #map {
  background: radial-gradient(ellipse at center, #1f1a2b 0%, #0c0a12 100%) !important;
}

/* ===== Копирование координат ===== */
#sw-toast {
  position: fixed;
  left: 50%;
  bottom: 72px;
  z-index: 1001;
  padding: 8px 14px;
  background: rgba(18, 18, 22, 0.9);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(250, 210, 130, 0.35);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  color: #f2f2f2;
  font: 600 13px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 0.2s, transform 0.25s cubic-bezier(0.3, 0.9, 0.3, 1);
}

#sw-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.sw-pulse {
  background: none;
  border: none;
}

.sw-pulse span {
  display: block;
  width: 100%;
  height: 100%;
  border: 2px solid #fad282;
  border-radius: 50%;
  box-sizing: border-box;
  animation: sw-pulse 0.9s ease-out forwards;
}

@keyframes sw-pulse {
  from { transform: scale(0.2); opacity: 1; }
  to   { transform: scale(1.6); opacity: 0; }
}

.sw-coords {
  cursor: help;
}

@media (max-width: 560px) {
  #sw-toast {
    bottom: 66px;
  }
}

/* ===== Узкие экраны: ужимаем панель, чтобы все кнопки влезли ===== */
@media (max-width: 440px) {
  #sw-toolbar {
    gap: 2px;
    padding: 5px;
  }
  .sw-world {
    padding: 7px 8px;
    font-size: 13px;
  }
  .sw-btn {
    min-width: 30px;
    height: 32px;
    padding: 0 5px;
  }
  .sw-sep {
    margin: 0 2px;
  }
  .sw-share {
    display: none !important;
  }
}

/* Только что появившиеся подписи игроков — без анимации перемещения */
div.leaflet-nameplates-pane div.leaflet-tooltip.sw-new {
  transition: none !important;
}