/*
 * AMEDDIAS world map.
 * Uses the theme variables (--red, --ink, …) with fallback values, in case the
 * plugin runs with another theme.
 */

.map-stage {
  position: relative;
}

.map-wrap {
  position: relative;
  background: var(--map-bg, #faf7ef);
  border: 1px solid var(--sepia, #bcae95);
  border-radius: 16px;
  padding: 8px;
  overflow: hidden;
  box-shadow:
    0 22px 45px -14px rgba(45, 34, 18, 0.38),
    0 8px 18px -8px rgba(45, 34, 18, 0.28),
    inset 0 0 40px rgba(120, 95, 55, 0.10);
}

#world-map {
  display: block;
  width: 100%;
  height: auto;
  /* Reserve the map height before it is drawn (no layout shift). */
  aspect-ratio: 984 / 456;
  cursor: grab;
  /* One finger scrolls the page; the two-finger pinch is handled by map.js. */
  touch-action: pan-x pan-y;
}

#world-map:active { cursor: grabbing; }

.map-error {
  padding: 24px;
  margin: 0;
  color: var(--red-dark, #7d0a13);
}

/* Gesture hint, touch screens only */
.map-hint {
  display: none;
  margin: 10px 0 0;
  text-align: center;
  font-family: var(--font-label, monospace);
  font-size: 12px;
  color: var(--muted, #6f6455);
}

@media (hover: none) and (pointer: coarse) {
  .map-hint { display: block; }
}

.pin { cursor: pointer; }

/* Hover card container */
#map-tooltip {
  position: absolute;
  z-index: 15;
  pointer-events: none;
}

/* --- Person card (hover and click) --- */
.pin-card {
  width: 250px;
  white-space: normal;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(15, 25, 35, 0.28);
  font-family: inherit;
  text-align: start;
}

.pin-card__photo {
  width: 100%;
  height: 132px;
  object-fit: cover;
  display: block;
  background: #d7dde1;
}

.pin-card__bar {
  background: var(--red, #a5321f);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pin-card__name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.pin-card__country {
  font-family: var(--font-label, monospace);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  opacity: 0.9;
  margin-top: 2px;
}

.pin-card__body {
  padding: 12px 14px 14px;
}

.pin-card__photo--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading, monospace);
  font-size: 44px;
  color: var(--paper, #f7f3e9);
  background: var(--ink, #2b2620);
}

.pin-card__text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted, #6f6455);
  margin: 0 0 10px;
}

.pin-card__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--red, #a5321f);
  text-decoration: none;
}

.pin-card__link:hover { text-decoration: underline; }

.pin-card__more {
  margin: 8px 0 0;
  font-size: 12px;
  font-style: italic;
  color: var(--muted, #6f6455);
}

/* Carousel of people within the same country (pinned card) */
.pin-card__nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #eee;
}

.pin-card__nav-btn {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid var(--sepia, #bcae95);
  background: transparent;
  color: var(--ink, #2b2620);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  border-radius: 2px;
}

.pin-card__nav-btn:hover { background: rgba(43, 38, 32, 0.08); }

.pin-card__dots {
  display: flex;
  align-items: center;
  gap: 5px;
}

.pin-card__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--paper-dark, #e8e1d1);
}

.pin-card__dot.is-active {
  background: var(--red, #a5321f);
}

/* Card pinned on click */
#pin-card-layer { position: absolute; inset: 0; pointer-events: none; }

.pin-card--pinned {
  position: absolute;
  transform: translate(-50%, calc(-100% - 18px));
  pointer-events: auto;
  z-index: 20;
}

.pin-card--pinned::after {
  content: "";
  position: absolute;
  left: calc(50% + var(--arrow-offset, 0px));
  bottom: -8px;
  width: 16px;
  height: 16px;
  background: #fff;
  transform: translateX(-50%) rotate(45deg);
  box-shadow: 6px 6px 12px rgba(15, 25, 35, 0.12);
}

/* when the pin is near the top edge, the card opens downwards */
.pin-card--pinned--below {
  transform: translate(-50%, 18px);
}

.pin-card--pinned--below::after {
  top: -8px;
  bottom: auto;
  box-shadow: -6px -6px 12px rgba(15, 25, 35, 0.12);
}

.pin-card__close {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

/*
 * On phones the map keeps its aspect ratio (it used to have a fixed 400px
 * height, but since it is drawn to fit the width that left empty bands above
 * and below it).
 */
@media (max-width: 600px) {
  .pin-card, .pin-card--pinned { width: 210px; }
}

/* Right-to-left languages: the "→" arrow points in the reading direction. */
[dir="rtl"] .pin-card__link svg { transform: scaleX(-1); }
