/* ---- app layout ----
   Phones and tablets: the map fills the screen, tabs along the bottom, and
   the other tabs are screens over the map. Wide screens: tabs become a rail
   on the left with the screens in a panel beside it. */
#map {
  position: fixed;
  inset: 0;
  background: var(--map-bg);
  z-index: 0;
}

/* Fades in once the first view has loaded (map.js). */
#map .maplibregl-canvas-container {
  opacity: 0;
  transition: opacity 0.5s ease;
}

#map.drawn .maplibregl-canvas-container {
  opacity: 1;
}

#tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1200;
  height: var(--tabbar-h);
  padding: 0 max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-top: 1px solid var(--border);
}
.tab {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 0.68rem;
  padding: 6px 0;
  transition: color 0.2s;
}
.tab svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.3s var(--spring);
}
.tab.active {
  color: var(--text);
  font-weight: 600;
}
.tab.active svg {
  transform: translateY(-2px) scale(1.08);
}
.tab:active svg {
  transform: scale(0.9);
}
.tab-share i {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  margin-top: -18px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--ink-text);
  box-shadow: var(--shadow);
  transition:
    transform 0.3s var(--spring),
    background 0.2s;
}
.tab-share i svg {
  width: 24px;
  height: 24px;
}
.tab-share.active i {
  background: var(--accent);
  color: var(--accent-ink);
  transform: scale(1.06);
}
.tab-share.active svg,
.tab-share:active svg {
  transform: none;
}
.tab-share:active i {
  transform: scale(0.92);
}

/* Screens fade and rise in; leaving, they fade back out. visibility waits
   for the fade before hiding. */
.screen {
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  right: 0;
  bottom: var(--tabbar-h);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg);
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 32px max(20px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 16px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px);
  transition:
    opacity 0.22s var(--ease),
    transform 0.32s var(--ease),
    visibility 0s linear 0.32s;
}
.screen.active {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition:
    opacity 0.22s var(--ease),
    transform 0.32s var(--ease),
    visibility 0s;
}
/* Detail and edit screens slide in from the right, over the tab screens. */
.screen.stacked {
  z-index: 1100;
  transform: translateX(100%);
  opacity: 1;
}
.screen.stacked.active {
  transform: none;
}
.screen > * {
  flex-shrink: 0;
}
.screen > *:not(.screen-head) {
  width: 100%;
  max-width: 620px;
  align-self: center;
}
.screen-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 620px;
  align-self: center;
}
.screen-head h1 {
  font-size: 2.3rem;
  line-height: 1.1;
}
.screen.active .screen-head h1 {
  animation: rise-in 0.45s var(--ease);
}
.back-btn {
  align-self: flex-start !important;
  width: auto !important;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  font-size: 1rem;
  padding: 4px 0;
}
.group-title {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.04em;
  margin-top: 6px;
}
.group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.empty {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: center;
  padding: 24px 12px;
}

/* ---- over the map ---- */
.glass {
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
#map-head {
  position: fixed;
  z-index: 900;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  border-radius: 18px;
  padding: 12px 16px 10px;
  transition:
    opacity 0.25s var(--ease),
    transform 0.35s var(--ease);
}
body:not([data-tab="map"]) #map-head {
  opacity: 0;
  transform: translateY(-20px);
  pointer-events: none;
}
.map-stats {
  display: flex;
  gap: 22px;
  margin-top: 4px;
}
.map-stat {
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  color: var(--text);
}
.map-stat b {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.6rem;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.map-stat span {
  font-size: 0.72rem;
  color: var(--muted);
}

.card {
  position: fixed;
  z-index: 950;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  bottom: calc(var(--tabbar-h) + 12px);
  max-height: 46dvh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 14px 16px 8px;
  animation: rise-in 0.35s var(--spring);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px;
}
.card-title {
  font-size: 1.3rem;
}
.card-flat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
}

/* ---- toast: what a new person unlocked ---- */
.toast {
  position: fixed;
  z-index: 3100;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 16px);
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.45;
  animation: rise-in 0.35s var(--ease);
  transition: opacity 0.3s;
}
.toast.leaving {
  opacity: 0;
}
@media (min-width: 900px) {
  .toast {
    left: calc(50% + var(--rail-w) / 2);
    bottom: 24px;
  }
}
