/*
 * Camping maps (js/camp-map.js), on the Friendscamp page's Map tab and the
 * Maps page: the map with its zoom and full-screen buttons, the pins (blue for
 * your camp, numbered red for friends' camps), a pin's bubble and the colour
 * guide under the map.
 */
.fc-camp-map {
  /* The map's height on the page; at the first zoom step ("whole map") it fits in it. */
  --fc-map-h: min(60vh, 440px);
  margin-top: 12px;
}
.fc-camp-map__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 8px; margin-bottom: 8px; }
.fc-camp-map__label { flex: 1 1 150px; min-width: 0; color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.fc-camp-map__tools { display: flex; gap: 6px; flex: none; }
.fc-camp-map__tool {
  min-width: 40px; height: 36px; padding: 0 10px; border: 0; border-radius: 10px;
  background: var(--chip); color: var(--ink);
  font: inherit; font-size: 19px; font-weight: 700; line-height: 1; cursor: pointer;
}
.fc-camp-map__tool--text { font-size: 13px; }
.fc-camp-map__tool:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 12%, transparent); }
.fc-camp-map__tool:disabled { opacity: .4; cursor: default; }
.fc-camp-map__viewport {
  position: relative; height: var(--fc-map-h); overflow: auto;
  border-radius: 12px; box-shadow: inset 0 0 0 1px var(--line-strong);
  /* The map's own grass colour, so the space around it looks like more map. */
  background: #818f01;
  touch-action: manipulation;
}
.fc-camp-map__viewport:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.fc-camp-map__canvas {
  position: relative; margin: 0 auto;
  /* From the second zoom step the map is at least as wide as the box, so a
     closer look can be moved sideways as well as up and down. */
  width: calc(var(--fc-map-zoom, 1) * max(100%, var(--fc-map-h) * var(--fc-map-ratio, .72)));
  aspect-ratio: var(--fc-map-ratio, .72);
}
.fc-camp-map.is-whole .fc-camp-map__canvas { width: min(100%, var(--fc-map-h) * var(--fc-map-ratio, .72)); }
/* The Map tab has room for a bigger map. */
.fc-camp-map-card .fc-camp-map { --fc-map-h: min(70vh, 640px); }
.fc-camp-map__canvas img {
  display: block; width: 100%; height: 100%;
  user-select: none; -webkit-user-select: none; -webkit-user-drag: none; -webkit-touch-callout: none;
}
.is-editable .fc-camp-map__canvas { cursor: crosshair; }
/* The pin's tip is the spot: blue for your camp, red for friends' camps. A
   black and a white edge make them stand out on the grass, the paths and the
   water, in light and dark mode alike. */
.fc-camp-map__pin { position: absolute; width: 0; height: 0; z-index: 2; pointer-events: none; }
.fc-camp-map__pin.is-own { z-index: 3; }
.fc-camp-map__pin.is-clickable { padding: 0; border: 0; background: none; }
.fc-camp-map__pin.is-clickable svg { pointer-events: auto; cursor: pointer; }
.fc-camp-map__pin.is-clickable:focus-visible { outline: none; }
.fc-camp-map__pin.is-clickable:focus-visible svg { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.fc-camp-map__pin svg { position: absolute; left: -16px; bottom: -2px; width: 32px; height: 44px; overflow: visible; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .5)); }
.fc-camp-map__pulse {
  position: absolute; left: -15px; top: -15px; width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid #2563eb; box-shadow: 0 0 0 2px #fff;
  animation: fc-map-pulse 1.8s ease-out infinite;
}
@keyframes fc-map-pulse { from { transform: scale(.35); opacity: 1; } to { transform: scale(1.5); opacity: 0; } }
.fc-camp-map__pin.is-previous { opacity: .45; z-index: 1; }
.fc-camp-map__pin.is-previous .fc-camp-map__pulse { display: none; }
@media (prefers-reduced-motion: reduce) {
  .fc-camp-map__pulse { animation: none; opacity: .9; transform: scale(.7); }
}
.fc-camp-map .fc-camp-map__caption { display: none; max-width: none; color: var(--ink); margin: 8px 0 0; font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.fc-camp-map .fc-camp-map__credit { max-width: none; margin: 6px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.4; }

/* The name of the camp a pin stands for, above the pin. */
.fc-camp-map__bubble {
  position: absolute; z-index: 5; transform: translate(-50%, calc(-100% - 52px));
  width: max-content; max-width: 220px; padding: 8px 11px; border-radius: 10px;
  background: var(--panel); color: var(--ink); box-shadow: 0 0 0 1px var(--line-strong), 0 6px 18px rgba(0, 0, 0, .28);
  font-size: 13px; line-height: 1.35; pointer-events: none;
}
.fc-camp-map__bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -6px; width: 12px; height: 12px; margin-left: -6px;
  background: var(--panel); transform: rotate(45deg); box-shadow: 1px 1px 0 var(--line-strong);
}
.fc-camp-map__bubble.is-below { transform: translate(-50%, 14px); }
.fc-camp-map__bubble.is-below::after { top: -6px; bottom: auto; box-shadow: -1px -1px 0 var(--line-strong); }
.fc-camp-map__bubble strong { display: block; font-weight: 700; overflow-wrap: anywhere; }
.fc-camp-map__bubble small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
/* Drag the map with a mouse to move around it. */
.fc-camp-map__viewport { cursor: grab; }
.fc-camp-map__viewport.is-dragging, .fc-camp-map__viewport.is-dragging .fc-camp-map__canvas { cursor: grabbing; }
.fc-camp-map__viewport.is-dragging { user-select: none; -webkit-user-select: none; }

/* Full screen: the map fills the window until it is closed. */
.fc-camp-map-open body { overflow: hidden; }
.fc-camp-map.is-fullscreen {
  --fc-map-h: calc(100vh - 128px);
  --fc-map-h: calc(100dvh - 128px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  position: fixed; inset: 0; z-index: 10015; margin: 0;
  display: flex; flex-direction: column;
  padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  background: var(--panel-2); color: var(--ink);
}
.fc-camp-map.is-fullscreen .fc-camp-map__viewport { flex: 1 1 auto; height: auto; min-height: 0; overscroll-behavior: contain; }
.fc-camp-map.is-fullscreen .fc-camp-map__caption { display: block; }
/* A bar under the map in full screen only, such as marking the camp: the
   page's own buttons under the map are out of sight then. The map makes room
   for it, so the whole map still fits at the first zoom step. */
.fc-camp-map__actions { display: none; }
.fc-camp-map.is-fullscreen:has(.fc-camp-map__actions) {
  --fc-map-h: calc(100dvh - 128px - 60px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
}
.fc-camp-map.is-fullscreen .fc-camp-map__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 10px; }
.fc-camp-map__actions p { flex: 1 1 16rem; min-width: 0; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
@media (max-width: 599px) {
  .fc-camp-map.is-fullscreen:has(.fc-camp-map__actions) {
    --fc-map-h: calc(100dvh - 128px - 100px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }
  .fc-camp-map.is-fullscreen .fc-camp-map__actions .fc-button { flex: 1 1 auto; }
}

/* The colour guide: which pin is whose. */
.fc-camp-map-guide { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-strong); }
.fc-camp-map-guide__title { margin: 0; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.fc-camp-map-guide__keys { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 6px 0 4px; color: var(--muted); font-size: 12.5px; }
.fc-camp-map-guide__keys span::before {
  content: ''; display: inline-block; width: 11px; height: 11px; margin-right: 6px; border-radius: 50%; vertical-align: -1px;
  background: #2563eb; box-shadow: 0 0 0 1.5px #111, 0 0 0 3px #fff;
}
.fc-camp-map-guide__keys .is-friend::before { background: #e11d2e; }
.fc-camp-map-guide__list { margin: 6px 0 0; padding: 0; list-style: none; }
.fc-camp-map-guide__list li { border-top: 1px solid var(--line-strong); }
.fc-camp-map-guide__list li:first-child { border-top: 0; }
.fc-camp-map-guide__item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 2px; text-align: left; color: inherit; font: inherit;
}
button.fc-camp-map-guide__item { cursor: pointer; border-radius: 8px; }
button.fc-camp-map-guide__item:hover, button.fc-camp-map-guide__item:focus-visible { background: var(--chip); }
.fc-camp-map-guide__swatch {
  flex: none; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: #2563eb; box-shadow: 0 0 0 2px #111, 0 0 0 4px #fff;
  color: #fff; font-size: 12px; font-weight: 800; line-height: 1;
}
.fc-camp-map-guide__swatch.is-friend { background: #e11d2e; }
.fc-camp-map-guide__swatch.is-off-map { opacity: .4; box-shadow: 0 0 0 2px var(--line-strong); }
.fc-camp-map-guide__text { min-width: 0; }
.fc-camp-map-guide__text strong { display: block; font-size: 14px; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.fc-camp-map-guide__text small { display: block; margin-top: 1px; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.fc-camp-map-guide__empty { display: flex; align-items: center; gap: 10px; padding: 8px 2px; color: var(--muted); font-size: 13px; }
.fc-camp-map-guide__footer { margin: 8px 0 0; color: var(--muted); font-size: 12.5px; }
