/* Spawn — adaptive shell: phone + desktop */

:root {
  --preview-bar-h: 0px;
  --desktop-nav-h: 56px;
  --desktop-sidebar-w: 248px;
  --desktop-sidebar-w-collapsed: 72px;
  --content-max: 1280px;
}

body.onboarding-open { overflow: hidden; }
body.nav-open { overflow: hidden; }

/* === DESKTOP TOP BAR === */
.desktop-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 120;
  flex-shrink: 0;
  align-items: center;
  gap: var(--space-4);
  height: var(--desktop-nav-h);
  padding: 0 var(--space-5);
  background: rgba(8, 8, 12, 0.94);
  border-bottom: 1px solid var(--border-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.desktop-topbar__menu {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  flex-shrink: 0;
  transition: border-color var(--motion), background var(--motion);
}
.desktop-topbar__menu:hover {
  border-color: rgba(0, 212, 238, 0.4);
  background: var(--surface-raised);
}

.desktop-topbar__brand {
  font-family: var(--font-cyber);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--accent-bright);
}

.desktop-topbar__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.desktop-topbar__screen {
  display: none;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-secondary);
}

/* === DESKTOP SIDEBAR === */
.desktop-sidebar {
  display: none;
}

body.view-desktop .desktop-sidebar {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  align-self: stretch;
  width: var(--desktop-sidebar-w);
  min-height: calc(100dvh - var(--preview-bar-h));
  padding: var(--space-5) var(--space-4);
  background:
    linear-gradient(180deg, rgba(0, 212, 238, 0.06) 0%, transparent 32%),
    rgba(10, 10, 16, 0.98);
  border-right: 1px solid var(--border-strong);
  transition: width var(--duration-normal) var(--ease-smooth), padding var(--duration-normal) var(--ease-smooth);
  overflow: hidden;
}

body.view-desktop.sidebar-collapsed {
  --desktop-sidebar-w: var(--desktop-sidebar-w-collapsed);
}

.desktop-sidebar__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--space-6);
  padding: 0 var(--space-1);
  min-width: 0;
}

body.view-desktop.sidebar-collapsed .desktop-sidebar__head {
  flex-direction: column;
  gap: 10px;
  padding: 0;
  margin-bottom: var(--space-5);
}

.desktop-sidebar__brand-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: background var(--motion), border-color var(--motion);
}

.desktop-sidebar__brand-btn:hover {
  background: var(--surface);
  border-color: var(--border);
}

body.view-desktop.sidebar-collapsed .desktop-sidebar__brand-btn {
  flex: 0;
  justify-content: center;
  padding: 6px;
}

.desktop-sidebar__mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-alt) 100%);
  color: #041016;
  font-family: var(--font-cyber);
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 0 20px rgba(0, 212, 238, 0.25);
}

.desktop-sidebar__wordmark {
  font-family: var(--font-cyber);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--accent-bright);
  white-space: nowrap;
  transition: opacity var(--duration-fast) var(--ease-smooth), max-width var(--duration-normal) var(--ease-smooth);
  max-width: 160px;
  overflow: hidden;
}

body.view-desktop.sidebar-collapsed .desktop-sidebar__wordmark {
  opacity: 0;
  max-width: 0;
}

.desktop-sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.desktop-sidebar__section {
  display: block;
  padding: 0 var(--space-3) var(--space-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  transition: opacity var(--duration-fast) var(--ease-smooth), max-height var(--duration-normal) var(--ease-smooth);
  max-height: 24px;
  overflow: hidden;
}

body.view-desktop.sidebar-collapsed .desktop-sidebar__section {
  opacity: 0;
  max-height: 0;
  padding: 0;
}

.desktop-sidebar__item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  text-align: left;
  transition: background var(--motion), color var(--motion), border-color var(--motion), transform var(--motion);
}

.desktop-sidebar__item svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  flex-shrink: 0;
}

.desktop-sidebar__copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
  transition: opacity var(--duration-fast) var(--ease-smooth), max-width var(--duration-normal) var(--ease-smooth);
  max-width: 180px;
}

body.view-desktop.sidebar-collapsed .desktop-sidebar__copy {
  opacity: 0;
  max-width: 0;
}

body.view-desktop.sidebar-collapsed .desktop-sidebar__item {
  justify-content: center;
  gap: 0;
  padding: 12px;
}

body.view-desktop.sidebar-collapsed .desktop-sidebar__item:hover {
  transform: none;
}

.desktop-sidebar__toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--motion), border-color var(--motion), color var(--motion), transform var(--duration-normal) var(--ease-smooth);
}

body.view-desktop .desktop-sidebar__toggle {
  display: flex;
}

.desktop-sidebar__toggle:hover {
  border-color: rgba(0, 212, 238, 0.35);
  background: var(--surface-raised);
  color: var(--text);
}

.desktop-sidebar__toggle svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  flex-shrink: 0;
  transition: transform var(--duration-normal) var(--ease-smooth);
}

body.view-desktop.sidebar-collapsed .desktop-sidebar__toggle svg {
  transform: rotate(180deg);
}

.desktop-sidebar__label {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: inherit;
}

.desktop-sidebar__desc {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  transition: color var(--motion);
}

.desktop-sidebar__item:hover {
  background: var(--surface);
  color: var(--text);
  transform: translateX(2px);
}

.desktop-sidebar__item:hover .desktop-sidebar__desc {
  color: var(--text-secondary);
}

.desktop-sidebar__item.active {
  background: var(--accent-muted);
  border-color: rgba(0, 212, 238, 0.35);
  color: var(--accent-bright);
}

.desktop-sidebar__item.active .desktop-sidebar__desc {
  color: rgba(0, 212, 238, 0.75);
}

.app-shell__content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

/* === NAV OVERLAY (desktop) === */
.nav-overlay {
  position: fixed;
  inset: 0;
  z-index: 19000;
  pointer-events: none;
  visibility: hidden;
}
.nav-overlay.open {
  pointer-events: auto;
  visibility: visible;
}

.nav-overlay__backdrop {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.28s ease;
  cursor: pointer;
}
.nav-overlay.open .nav-overlay__backdrop { opacity: 1; }

.nav-overlay__panel {
  position: absolute;
  top: var(--preview-bar-h);
  left: 0;
  bottom: 0;
  width: min(300px, 88vw);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--space-4);
  background: rgba(14, 14, 20, 0.98);
  border-right: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateX(-105%);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.nav-overlay.open .nav-overlay__panel { transform: translateX(0); }

.nav-overlay__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}
.nav-overlay__title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.nav-overlay__close {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 22px;
  line-height: 1;
}
.nav-overlay__close:hover { color: var(--text); background: var(--surface); }

.nav-overlay__item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  transition: background var(--motion), color var(--motion), border-color var(--motion);
}
.nav-overlay__item svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  flex-shrink: 0;
}
.nav-overlay__item:hover {
  background: var(--surface);
  color: var(--text);
}
.nav-overlay__item.active {
  background: var(--accent-muted);
  border-color: rgba(0, 212, 238, 0.35);
  color: var(--accent-bright);
}

/* === PHONE VIEW (compact nav — full bleed, no device frame) === */
body.view-phone {
  align-items: stretch;
  justify-content: flex-start;
}

body.view-phone .app-shell {
  width: 100%;
  max-width: none;
  height: calc(100dvh - var(--preview-bar-h));
  min-height: 0;
  margin: 0;
  border: none;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.view-phone .desktop-topbar { display: none !important; }
body.view-phone .nav-overlay { display: none !important; }

body.view-phone .tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  transform: none;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  flex-shrink: 0;
  z-index: var(--z-nav);
}

body.view-phone .tab-bar__rail {
  border-radius: 18px 18px 0 0;
  border-left: none;
  border-right: none;
  border-bottom: none;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}

body.view-phone .app-shell {
  padding-bottom: 0;
}

body.view-phone .screen {
  flex: 1;
  min-height: 0;
  padding-bottom: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.view-phone .screen.active:not(.zone-discover) {
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
}

body.view-phone .screen.zone-discover.active {
  padding-bottom: 0;
  overflow: hidden;
}

body.view-phone .screen.active {
  display: flex;
}

body.view-phone .zone-discover.active {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
/* Reserve space for the floating tab bar ONCE, at the shell level.
   Inner panels must not add their own bottom inset or the map collapses. */
body.view-phone .discover-shell {
  flex: 1 1 0;
  min-height: 0;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
}
body.view-phone #discover-map,
body.view-phone #discover-world,
body.view-phone #discover-hub {
  flex: 1 1 0;
  min-height: 0;
  padding-bottom: 0;
}

body.view-phone .discover-main {
  flex: 1;
  min-height: 0;
}

body.view-phone .discover-body {
  flex: 1;
  min-height: 0;
}

body.view-phone .galaxy-stage,
body.view-phone .world-stage,
body.view-phone .map-viewport {
  flex: 1;
  min-height: 0;
}

body.view-phone .zone-discover .map-viewport {
  min-height: 0;
}

body.view-phone .discover-toolbar {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-4);
  padding-top: max(var(--space-3), env(safe-area-inset-top));
}

body.view-phone .discover-search {
  flex: 1 1 100%;
  max-width: none;
}

body.view-phone .discover-stats {
  display: none;
}

/* Phone tab bar is full-width (no centering), so it slides straight down.
   This overrides the desktop translateX(-50%) hide transform in motion.css. */
body.view-phone .tab-bar.hidden {
  transform: translateY(calc(100% + 24px));
  opacity: 0;
  pointer-events: none;
}

/* Phone tab bar — keep icons centered inside the rail */
body.view-phone .tab-bar {
  height: auto;
  padding-bottom: 0;
}

body.view-phone .tab-bar__rail {
  align-items: center;
  justify-content: space-around;
  gap: 0;
  min-height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  padding: 8px 8px max(8px, env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
}

body.view-phone .tab-btn {
  flex: 1;
  min-height: 56px;
  max-height: 56px;
  justify-content: center;
  padding: 6px 4px 10px;
  overflow: visible;
}

body.view-phone .tab-btn svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

body.view-phone .tab-btn.active::after {
  bottom: 2px;
}

body.view-phone .stack-screen {
  max-width: none;
  width: 100%;
  left: 0;
  right: 0;
  transform: none;
  top: var(--preview-bar-h);
  bottom: 0;
  height: calc(100dvh - var(--preview-bar-h));
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* === DESKTOP VIEW === */
body.view-desktop {
  align-items: stretch;
  justify-content: flex-start;
}

body.view-desktop .app-shell {
  width: 100%;
  max-width: none;
  min-height: calc(100dvh - var(--preview-bar-h));
  display: flex;
  flex-direction: row;
  align-items: stretch;
}

body.view-desktop .desktop-topbar { display: flex; }

body.view-desktop .desktop-topbar__menu { display: flex; }

body.view-desktop .desktop-topbar__brand { display: none; }

body.view-desktop .desktop-topbar__screen {
  display: block;
  margin-right: auto;
}

body.view-desktop .nav-overlay { display: none !important; }

body.view-desktop .tab-bar { display: none !important; }

body.view-desktop .app-main {
  flex: 1;
  min-height: 0;
}

body.view-desktop .screen {
  flex: 1;
  min-height: calc(100dvh - var(--preview-bar-h) - var(--desktop-nav-h));
  padding-bottom: var(--space-6);
}

body.view-desktop .stack-screen {
  top: calc(var(--preview-bar-h) + var(--desktop-nav-h));
  left: var(--desktop-sidebar-w);
  right: 0;
  max-width: none;
  width: auto;
  transition: left var(--duration-normal) var(--ease-smooth);
}

body.view-desktop .zone-main .feed-list,
body.view-desktop .zone-main .screen-header,
body.view-desktop .zone-lfg .lfg-header,
body.view-desktop .zone-lfg .lfg-stage,
body.view-desktop .zone-lfg .lfg-actions,
body.view-desktop .zone-lfg .lfg-photo-bars {
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

@media (max-width: 520px) {
  .world-toolbar {
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  .world-toolbar__title {
    order: 2;
    flex: 1 1 100%;
  }
  .world-toolbar__group,
  #open-world-filters {
    order: 3;
  }
  .world-toolbar__count {
    order: 4;
    margin-left: auto;
  }
}

body.view-desktop .screen.zone-discover.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding-bottom: 0;
}

body.view-desktop .zone-discover .discover-shell {
  flex: 1;
  min-height: 0;
}

body.view-desktop .zone-discover .map-viewport {
  min-height: 0;
  flex: 1;
}

body.view-desktop .screen:not(.zone-discover) {
  padding-left: var(--space-6);
  padding-right: var(--space-6);
}

body.view-desktop .zone-admin .admin-inner {
  max-width: 1100px;
}

