/* Login-gated interactive Globe. Kept separate so map styling can be tuned
   without digging through the main tree stylesheet. */

.globe-modal {
  width: min(1180px, 96vw);
  max-height: min(90dvh, 820px);
  padding: 28px 32px 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 140;
  background:
    radial-gradient(circle at 18% 8%, rgba(61,156,163,0.10), transparent 34%),
    radial-gradient(circle at 82% 4%, rgba(201,169,97,0.12), transparent 30%),
    var(--glass-strong);
}

.globe-modal > h2,
.globe-modal > .sub {
  flex-shrink: 0;
}

.globe-modal > .sub {
  position: relative;
  color: var(--gold-text);
}

.globe-modal > .sub::after {
  content: "❊";
  display: block;
  margin: 8px auto 0;
  width: 72px;
  color: rgba(168,136,56,0.82);
  letter-spacing: 10px;
  font-size: 12px;
  line-height: 1;
}

.globe-modal > .globe-lock,
.globe-modal > .globe-loading {
  flex: 1;
  min-height: 0;
}

.globe-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  gap: 20px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.globe-map-column {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.globe-stage {
  position: relative;
  min-height: 0;
  height: 100%;
  flex: 1;
  max-height: min(56dvh, 520px);
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(168,136,56,0.38);
  background:
    radial-gradient(circle at 50% 43%, rgba(61,156,163,0.28), rgba(61,156,163,0.08) 46%, transparent 66%),
    radial-gradient(circle at 50% 48%, rgba(251,247,236,0.70), rgba(232,220,192,0.20) 62%, rgba(121,94,64,0.10) 100%),
    linear-gradient(145deg, rgba(255,255,255,0.74), rgba(232,220,192,0.42));
  box-shadow:
    inset 0 0 88px rgba(61,156,163,0.16),
    inset 0 0 0 1px rgba(255,255,255,0.46),
    0 18px 44px rgba(47,37,20,0.10);
}

.globe-stage::before,
.globe-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.globe-stage::before {
  z-index: 1;
  opacity: 0.05;
  background-image:
    radial-gradient(circle at 18% 22%, rgba(0,0,0,0.80) 0 1px, transparent 1px),
    radial-gradient(circle at 72% 66%, rgba(0,0,0,0.62) 0 1px, transparent 1px);
  background-size: 18px 18px, 23px 23px;
}

.globe-stage::after {
  z-index: 1;
  box-shadow:
    inset 0 0 80px rgba(52,37,18,0.16),
    inset 0 0 18px rgba(255,255,255,0.42);
}

.globe-tools {
  position: absolute;
  top: 10px;
  right: 10px;
  left: auto;
  z-index: 3;
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 12px;
  background: var(--glass-strong);
  border: 1px solid rgba(168,136,56,0.34);
  box-shadow: 0 10px 26px rgba(47,37,20,0.12);
  backdrop-filter: blur(14px);
}

.globe-tool {
  min-width: 44px;
  height: 44px;
  padding: 0 12px;
  border-radius: 7px;
  border: 1px solid rgba(168,136,56,0.32);
  background: rgba(255,255,255,0.72);
  color: var(--ink);
  cursor: pointer;
  font-family: inherit;
  font-size: 17px;
  line-height: 1;
}

.globe-tool-reset {
  font-size: 12px;
  padding: 0 8px;
}

.globe-tool:hover,
.globe-tool:focus-visible {
  background: rgba(201,169,97,0.20);
  border-color: var(--gold);
}

#globe-svg {
  width: 100%;
  height: 100%;
  min-height: 320px;
  display: block;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#globe-svg:active {
  cursor: grabbing;
}

#globe-sphere {
  fill: rgba(61,156,163,0.14);
  stroke: rgba(61,156,163,0.74);
  stroke-width: 1.55;
  filter: drop-shadow(0 0 18px rgba(61,156,163,0.34));
}

#globe-graticule {
  fill: none;
  stroke: rgba(122,96,31,0.32);
  stroke-width: 0.82;
}

.globe-country {
  fill: rgba(51,43,29,0.065);
  stroke: rgba(251,247,236,0.72);
  stroke-width: 0.42;
  transition: fill 0.18s ease, stroke 0.18s ease;
}

.globe-country.family-country {
  fill: rgba(61,156,163,0.28);
  stroke: rgba(122,96,31,0.48);
  stroke-width: 0.56;
}

.globe-state {
  fill: none;
  stroke: rgba(43,43,43,0.22);
  stroke-width: 0.44;
  opacity: 0;
  pointer-events: none;
}

.globe-zoomed .globe-country {
  stroke: rgba(255,255,255,0.82);
  stroke-width: 0.58;
}

.globe-zoomed .globe-country.family-country {
  fill: rgba(61,156,163,0.14);
  stroke: rgba(122,96,31,0.58);
}

.globe-zoomed .globe-state {
  opacity: 0.92;
}

.globe-pin {
  cursor: pointer;
  outline: none;
}

.globe-pin-halo {
  fill: rgba(184,89,94,0.16);
  stroke: rgba(168,136,56,0.32);
  stroke-width: 1.1;
  opacity: 0;
  transition: opacity 0.16s ease, r 0.16s ease;
}

.globe-pin-dot {
  fill: var(--rose);
  stroke: #fff7e8;
  stroke-width: 1.8;
  filter:
    drop-shadow(0 2px 8px rgba(184,89,94,0.40))
    drop-shadow(0 0 3px rgba(255,247,232,0.52));
}

.globe-pin-count {
  font-family: 'Cormorant Garamond', serif;
  font-size: 9px;
  font-weight: 700;
  fill: #fff7e8;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.globe-pin-label {
  font-size: 11px;
  font-weight: 700;
  fill: var(--gold-text);
  stroke: rgba(251,247,236,0.92);
  stroke-width: 3.4px;
  paint-order: stroke;
  text-anchor: middle;
  pointer-events: none;
}

.globe-pin:hover .globe-pin-dot,
.globe-pin:focus-visible .globe-pin-dot,
.globe-pin.selected .globe-pin-dot {
  fill: #9f3037;
  stroke: #fff7e8;
  stroke-width: 2.4;
}

.globe-pin:hover .globe-pin-halo,
.globe-pin:focus-visible .globe-pin-halo,
.globe-pin.selected .globe-pin-halo {
  fill: rgba(184,89,94,0.30);
  stroke: rgba(122,96,31,0.72);
  opacity: 1;
}

.globe-pin.selected .globe-pin-halo {
  fill: rgba(201,169,97,0.20);
  stroke: rgba(122,96,31,0.86);
  stroke-width: 1.8;
}

.globe-hint {
  flex-shrink: 0;
  max-width: none;
  padding: 9px 11px;
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(251,247,236,0.94), rgba(232,220,192,0.64));
  border: 1px solid rgba(168,136,56,0.30);
  color: rgba(0,0,0,0.86);
  font-size: 12.5px;
  line-height: 1.35;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(47,37,20,0.07);
}

.globe-uses-sidebar .globe-hint {
  max-width: none;
}

.globe-zoomed .globe-hint {
  opacity: 0.85;
}

/* Floating card only on narrow layouts — desktop uses the right panel */
.globe-popover {
  position: absolute;
  z-index: 2;
  width: min(270px, calc(100% - 24px));
  max-height: min(40vh, 270px);
  overflow: auto;
  padding: 14px 16px;
  border-radius: 14px;
  background:
    radial-gradient(circle at 20% 0%, rgba(61,156,163,0.12), transparent 42%),
    rgba(251,247,236,0.98);
  border: 1px solid rgba(168,136,56,0.38);
  box-shadow:
    inset 3px 0 0 rgba(168,136,56,0.42),
    0 18px 46px rgba(47,37,20,0.20);
}

.globe-uses-sidebar .globe-popover {
  display: none !important;
}

.globe-popover[hidden],
.globe-content[hidden],
.globe-lock[hidden],
.globe-loading[hidden] {
  display: none !important;
}

.globe-pop-title,
.globe-detail-title {
  font-size: 22px;
  line-height: 1.15;
  color: var(--ink);
  font-weight: 700;
}

.globe-pop-sub,
.globe-detail-sub {
  margin-top: 4px;
  font-size: 14px;
  color: rgba(0,0,0,0.74);
}

.globe-pop-kicker,
.globe-detail-kicker,
.globe-side-kicker,
.globe-city-list-title {
  margin-top: 10px;
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold-text);
}

.globe-person-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.globe-person-link,
.globe-city-item {
  border: 1px solid rgba(168,136,56,0.30);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.72), rgba(246,238,220,0.50));
  color: var(--ink);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.globe-person-link {
  padding: 11px 12px;
  font-size: 16px;
  min-height: 44px;
}

.globe-popover .globe-person-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.globe-popover .globe-person-link {
  width: 100%;
  text-align: left;
  min-height: 48px;
}

/* The narrow/mobile popover shows the same kind chips as the desktop rail so
   "Born here / Lived / Current" reads consistently on every layout. */
.globe-popover .globe-place-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.globe-person-link:hover,
.globe-person-link:focus,
.globe-city-item:hover,
.globe-city-item:focus {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.82), rgba(201,169,97,0.18));
  border-color: rgba(168,136,56,0.52);
  box-shadow: 0 6px 16px rgba(47,37,20,0.08);
}

/* R8: visible focus ring for keyboard users on the accessible city/person lists. */
.globe-person-link:focus-visible,
.globe-city-item:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

.globe-side {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1.35fr) minmax(0, 0.65fr);
  gap: 12px;
  overflow: hidden;
}

.globe-side > .globe-side-kicker {
  margin-top: 0;
  margin-bottom: -2px;
}

.globe-detail,
.globe-city-list-wrap,
.globe-lock,
.globe-loading {
  border-radius: 14px;
  border: 1px solid rgba(168,136,56,0.28);
  background:
    radial-gradient(circle at 12% 0%, rgba(61,156,163,0.08), transparent 40%),
    rgba(255,255,255,0.52);
  padding: 16px 18px;
}

.globe-detail {
  min-height: 0;
  max-height: none;
  border-color: rgba(168,136,56,0.34);
  background:
    radial-gradient(circle at 0% 0%, rgba(184,89,94,0.10), transparent 42%),
    rgba(255,255,255,0.66);
  box-shadow:
    inset 4px 0 0 rgba(168,136,56,0.66),
    0 10px 24px rgba(47,37,20,0.07);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.globe-detail .globe-detail-title,
.globe-detail .globe-detail-sub,
.globe-detail .globe-detail-kicker,
.globe-detail .globe-cluster-hint {
  flex-shrink: 0;
}

.globe-detail .globe-person-list {
  display: grid;
  grid-template-columns: 1fr;
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: auto;
  gap: 8px;
  padding-right: 5px;
  margin-top: 10px;
}

.globe-detail .globe-person-link {
  width: 100%;
  text-align: left;
  padding: 12px;
  font-size: 16px;
  line-height: 1.22;
  min-height: 54px;
}

.globe-person-name {
  display: block;
  font-weight: 700;
}

.globe-place-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.globe-place-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  line-height: 1;
  color: rgba(24,56,58,0.92);
  background: rgba(61,156,163,0.14);
  border: 1px solid rgba(61,156,163,0.28);
}

.globe-place-chip.kind-born {
  color: rgba(126,55,59,0.9);
  background: rgba(184,89,94,0.12);
  border-color: rgba(184,89,94,0.24);
}

/* Current residence gets a subtle live "hearth" treatment — a warm rose with a
   filled leading dot so the place someone lives now reads at a glance. */
.globe-place-chip.kind-current {
  color: rgba(126,55,59,0.95);
  background: rgba(184,89,94,0.18);
  border-color: rgba(184,89,94,0.42);
  font-weight: 700;
}

.globe-place-chip.kind-current::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--rose);
  flex-shrink: 0;
}

.globe-place-chip.kind-buried,
.globe-place-chip.kind-died {
  color: rgba(72,56,42,0.85);
  background: rgba(121,94,64,0.12);
  border-color: rgba(121,94,64,0.24);
}

/* Heirloom-gold for the ancestral places — estate and shrine. */
.globe-place-chip.kind-estate,
.globe-place-chip.kind-shrine {
  color: rgba(108,82,28,0.95);
  background: rgba(201,169,97,0.18);
  border-color: rgba(168,136,56,0.40);
}

body.lang-fa .globe-place-chip.kind-current::before {
  margin-right: 0;
  margin-left: 6px;
}

.globe-loading,
.globe-lock {
  text-align: center;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  min-height: 220px;
  background:
    radial-gradient(circle at 50% 18%, rgba(61,156,163,0.12), transparent 42%),
    linear-gradient(145deg, rgba(255,255,255,0.72), rgba(232,220,192,0.50));
  box-shadow: inset 0 0 38px rgba(201,169,97,0.10);
}

.globe-lock .btn {
  margin-top: 0;
}

.globe-state-pending .globe-lock {
  border-color: rgba(184,89,94,0.38);
  box-shadow:
    inset 0 0 38px rgba(184,89,94,0.10),
    inset 4px 0 0 rgba(184,89,94,0.48);
}

.globe-city-list-wrap {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.32);
}

.globe-city-list {
  display: grid;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 3px 6px 3px 2px;
  scroll-padding-top: 8px;
}

.globe-city-item {
  width: 100%;
  padding: 12px;
  text-align: left;
  min-height: 52px;
}

.globe-city-item.selected {
  border-color: rgba(168,136,56,0.58);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.80), rgba(184,89,94,0.12));
  box-shadow:
    inset 4px 0 0 rgba(168,136,56,0.78),
    0 6px 16px rgba(47,37,20,0.08);
}

.globe-cluster {
  cursor: pointer;
  outline: none;
}

.globe-cluster-halo {
  fill: rgba(61,156,163,0.20);
  stroke: rgba(168,136,56,0.32);
  stroke-width: 1.2;
  transition: opacity 0.18s ease, r 0.18s ease;
}

.globe-cluster-dot {
  fill: rgba(43,133,140,0.96);
  stroke: #fff7e8;
  stroke-width: 2;
  filter:
    drop-shadow(0 3px 10px rgba(46,121,127,0.42))
    drop-shadow(0 0 4px rgba(255,247,232,0.40));
  transition: fill 0.18s ease;
}

.globe-cluster:hover .globe-cluster-dot,
.globe-cluster:focus-visible .globe-cluster-dot {
  fill: rgba(31,99,105,1);
}

.globe-cluster:hover .globe-cluster-halo,
.globe-cluster:focus-visible .globe-cluster-halo {
  fill: rgba(61,156,163,0.34);
  stroke: rgba(122,96,31,0.58);
}

/* Cluster that holds the currently selected city gets a warm highlight ring
   (only visible when such a cluster renders collapsed rather than fanned). */
.globe-cluster.contains-selected .globe-cluster-halo {
  fill: rgba(201,169,97,0.20);
  stroke: rgba(122,96,31,0.72);
  stroke-width: 1.6;
}

.globe-cluster.contains-selected .globe-cluster-dot {
  stroke: rgba(255,247,232,0.95);
}

.globe-cluster-count {
  font-family: 'Cormorant Garamond', serif;
  font-size: 12px;
  font-weight: 700;
  fill: #fff7e8;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.globe-cluster-hint {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.35;
  color: rgba(0,0,0,0.74);
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(61,156,163,0.12);
  border: 1px solid rgba(61,156,163,0.28);
}

@media (pointer: coarse) {
  .globe-pin-halo,
  .globe-cluster-halo {
    opacity: 0.42;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .globe-modal .globe-stage,
  .globe-modal .globe-side,
  .globe-modal .globe-hint {
    opacity: 0;
    transform: translateY(10px);
  }

  .globe-modal.globe-ready .globe-stage,
  .globe-modal.globe-ready .globe-side,
  .globe-modal.globe-ready .globe-hint {
    animation: globe-atlas-rise 420ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  }

  .globe-modal.globe-ready .globe-side {
    animation-delay: 80ms;
  }

  .globe-modal.globe-ready .globe-hint {
    animation-delay: 140ms;
  }

  .globe-pin.selected .globe-pin-dot {
    transform-box: fill-box;
    transform-origin: center;
    animation: globe-pin-hearth 520ms cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  @keyframes globe-atlas-rise {
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes globe-pin-hearth {
    0% { transform: scale(0.92); }
    55% { transform: scale(1.12); }
    100% { transform: scale(1); }
  }
}

.globe-city-name {
  display: block;
  font-size: 14px;
  line-height: 1.15;
}

.globe-city-count {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: rgba(0,0,0,0.78);
}

body.lang-fa .globe-hint,
body.lang-fa .globe-detail,
body.lang-fa .globe-popover,
body.lang-fa .globe-city-item,
body.lang-fa .globe-person-link {
  direction: rtl;
  text-align: right;
}

body.lang-fa .globe-tools {
  direction: ltr;
}

body.lang-fa .globe-detail .globe-person-link {
  text-align: right;
}

body.lang-fa .globe-place-chip-row {
  justify-content: flex-end;
}

body.lang-fa .globe-pop-kicker,
body.lang-fa .globe-detail-kicker,
body.lang-fa .globe-side-kicker,
body.lang-fa .globe-city-list-title {
  letter-spacing: 0;
}

@media (max-width: 879px) {
  .globe-modal {
    max-height: min(94dvh, 900px);
    overflow-y: auto;
  }

  .globe-content {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .globe-stage {
    max-height: min(48dvh, 400px);
  }

  .globe-side {
    display: block;
    max-height: none;
  }

  .globe-detail {
    display: block;
    overflow: visible;
    margin-bottom: 8px;
  }

  .globe-detail .globe-person-list {
    display: grid;
    flex: none;
    overflow: visible;
    padding-right: 0;
  }

  /* Narrow layouts show selected-city detail below the map, where it can breathe. */
  .globe-side-kicker,
  .globe-popover {
    display: none;
  }
}

@media (max-width: 760px) {
  .globe-modal {
    width: min(96vw, 560px);
    padding: 24px 14px 18px;
  }

  .globe-tools {
    top: 8px;
    right: 8px;
  }

  .globe-tool {
    min-width: 44px;
    height: 44px;
    font-size: 18px;
  }

  .globe-detail .globe-person-link {
    min-height: 44px;
    font-size: 16px;
  }

  .globe-pop-title {
    font-size: 20px;
  }

  .globe-popover {
    max-height: min(218px, calc(100% - 24px));
    padding: 13px 14px;
  }

  .globe-popover .globe-person-list {
    gap: 6px;
  }

  .globe-popover .globe-person-link {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 15px;
  }
}

@media (max-width: 480px) {
  .globe-modal {
    width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
    padding: 20px 12px 14px;
  }

  .globe-stage {
    max-height: 42dvh;
  }
}
