/* Cumulative -- Converge "Joining From" map widget.
   Design tokens and shared furniture, carried over from the Converge break
   screen so the two read as one set. */

:root {
  --sand: #D5D1B5;
  --sand-deep: #C6C1A2;
  --cream: #E9E7D9;
  --cream-soft: #F2F1E9;
  --orange: #F05A22;
  --ink: #29271F;
  --ink-soft: rgba(41, 39, 31, .62);
  --ink-faint: rgba(41, 39, 31, .14);
  --ink-hairline: rgba(41, 39, 31, .10);
  --shadow: rgba(41, 39, 31, .16);
  --scrim: rgba(213, 209, 181, .86);
  --scrim-clear: rgba(213, 209, 181, 0);
  --font: "Helvetica Neue", Helvetica, Arial, "Segoe UI", system-ui, sans-serif;

  --land: #29271F;
  --land-line: var(--sand);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--sand);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- background motif: drifting chamfered squares ---------- */
.motif {
  position: fixed;
  inset: -10% -10%;
  z-index: 0;
  opacity: .5;
  pointer-events: none;
}
.motif-tile {
  position: absolute;
  clip-path: polygon(33% 0, 100% 0, 100% 67%, 67% 100%, 0 100%, 0 33%);
  animation: motifDrift linear infinite;
}
@keyframes motifDrift {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg); }
  100% { transform: translate3d(0, 0, 0) rotate(360deg); }
}

/* ---------- brand mark ---------- */
.mark { display: block; overflow: visible; }
.mark .petal { fill: var(--ink); transition: fill .9s ease; }
.mark .petal.lit { fill: var(--orange); }

.mark-spin .mark-group {
  transform-origin: 24px 24px;
  animation: markSpin 24s cubic-bezier(.76, 0, .24, 1) infinite;
}
@keyframes markSpin {
  0%        { transform: rotate(0deg)   scale(1); }
  20%       { transform: rotate(90deg)  scale(1); }
  22%       { transform: rotate(90deg)  scale(1.045); }
  25%       { transform: rotate(90deg)  scale(1); }
  45%, 50%  { transform: rotate(180deg) scale(1); }
  70%, 75%  { transform: rotate(270deg) scale(1); }
  95%, 100% { transform: rotate(360deg) scale(1); }
}

.wordmark { display: block; height: auto; }

/* ---------- typography ---------- */
.hero-title {
  margin: 0;
  font-size: clamp(1.9rem, 5vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.02;
  text-wrap: balance;
}
.hero-tagline {
  margin: 0;
  font-size: clamp(.78rem, 1.3vw, 1rem);
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.hero-body {
  margin: 0;
  font-size: clamp(.98rem, 1.6vw, 1.15rem);
  font-weight: 500;
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 42ch;
  text-wrap: pretty;
}
.rule {
  width: clamp(60px, 7vw, 110px);
  height: 4px;
  background: var(--orange);
  border: 0;
  margin: 0;
}

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  letter-spacing: -.015em;
  background: var(--orange);
  color: var(--cream-soft);
  border-radius: 999px;
  padding: 15px 32px;
  font-size: 1rem;
  transition: background .2s ease, color .2s ease, transform .12s ease;
}
.btn:hover:not(:disabled) { background: var(--ink); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink-faint);
  padding: 12px 22px;
  font-size: .9rem;
}
.btn.ghost:hover:not(:disabled) { background: var(--ink); color: var(--cream-soft); }

.btn.small { padding: 9px 16px; font-size: .82rem; }

:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
}

/* ---------- world map ---------- */
.map-wrap { position: relative; width: 100%; }
/* No `overflow: visible` here: the viewBox deliberately crops the Antarctic
   smear, and visible overflow would paint it back outside the viewBox. */
.world { display: block; width: 100%; height: auto; }
.world .land {
  fill: var(--land);
  stroke: var(--land-line);
  stroke-width: .4;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

/* Pins are drawn in a group that is counter-scaled, so they keep a constant
   on-screen size no matter how the map is fitted to the viewport. */
.pin-dot { fill: var(--orange); }
.pin-halo { fill: none; stroke: var(--orange); stroke-width: 1.4; opacity: 0; }
.pin-core { fill: var(--cream-soft); }

.pin.is-new .pin-dot { animation: pinDrop .62s cubic-bezier(.22, 1.2, .36, 1) both; }
.pin.is-new .pin-halo { animation: pinPulse 1.9s ease-out .18s 2 both; }

@keyframes pinDrop {
  0%   { transform: translateY(-18px) scale(.2); opacity: 0; }
  60%  { transform: translateY(0) scale(1.35); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes pinPulse {
  0%   { opacity: .85; transform: scale(.4); }
  100% { opacity: 0;   transform: scale(4.2); }
}

/* ---------- utility ---------- */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .motif-tile, .mark-spin .mark-group, .pin.is-new .pin-dot, .pin.is-new .pin-halo {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ---------- avatars ---------- */
.avatar {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
  background: var(--sand-deep);
  box-shadow: 0 0 0 1px var(--ink-hairline);
}
.avatar.is-initials {
  color: var(--cream-soft);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1;
}

/* ---------- clickable pins ---------- */
.world.is-selectable .pin { cursor: pointer; }
/* Carries the touch target. Must stay pointer-transparent to nothing -- it is
   the only part big enough to hit reliably on a phone. */
.pin-hit { fill: transparent; }
.world.is-selectable .pin:focus-visible { outline: none; }
.world.is-selectable .pin:focus-visible .pin-dot,
.world.is-selectable .pin:hover .pin-dot { stroke: var(--ink); stroke-width: 1.5; }

/* ---------- city card ---------- */
.city-card {
  position: absolute;
  z-index: 20;
  width: min(280px, 78vw);
  max-height: 320px;
  display: flex;
  flex-direction: column;
  background: var(--cream-soft);
  border-radius: 16px;
  box-shadow: 0 24px 54px -22px var(--shadow), 0 0 0 1px var(--ink-faint);
  overflow: hidden;
}
.city-card[hidden] { display: none; }

.city-head {
  position: relative;
  padding: 13px 40px 11px 15px;
  border-bottom: 1px solid var(--ink-hairline);
}
.city-place {
  margin: 0;
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: -.015em;
  line-height: 1.25;
}
.city-count {
  margin: 3px 0 0;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.city-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.city-close:hover { background: var(--sand); color: var(--ink); }

.city-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.city-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 7px;
  border-radius: 10px;
}
.city-list li + li { margin-top: 2px; }
.city-name {
  font-size: .92rem;
  font-weight: 600;
  letter-spacing: -.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* On a phone, a card tethered to a 10px dot is unusable -- become a sheet. */
.city-card.is-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  width: auto;
  max-height: 54vh;
  border-radius: 20px 20px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  animation: sheetUp .26s cubic-bezier(.22, 1.1, .36, 1) both;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .city-card.is-sheet { animation: none; }
}

/* ---------- flags ---------- */
.flag {
  flex: 0 0 auto;
  line-height: 1;
  font-size: 1em;
  /* Emoji flags have no glyph on Windows, so flags.js swaps in a country-code
     chip. Both need to occupy roughly the same room. */
}
.flag.is-code {
  font-size: .62em;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 2px 4px;
  border-radius: 4px;
  background: var(--ink);
  color: var(--cream-soft);
}
.flag.is-unknown { display: none; }

.city-place { display: flex; align-items: center; gap: 7px; }
.city-place .flag { font-size: .95rem; }
