/* ProtestPulse Layout — Firehose-first, view-switched layout */

/* Reset & base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-base);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- Top bar ---- */
#top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: 0 var(--space-xl);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  height: 56px;
}

/* View tabs removed — feed-only layout */
#view-tabs { display: none; }

/* ---- Views ---- */
.view {
  display: none;
  margin-top: 56px; /* header only */
}

.view.active {
  display: block;
}

/* ---- Firehose view ---- */
#view-firehose {
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

/* Everything scrolls with the feed — only header sticks */
#firehose-feed {
  min-height: 0;
}

/* ---- Map view ---- */
#view-map {
  position: relative;
}

#view-map.active {
  display: block;
}

#map-container {
  position: relative;
  z-index: 0;
  height: calc(100vh - 56px - 41px);
  width: 100%;
}

/* Contain Leaflet's internal z-index stack below header/tabs */
.leaflet-top, .leaflet-bottom {
  z-index: 5 !important;
}

.map-sidebar {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 320px;
  max-height: calc(100vh - 56px - 41px - 24px);
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  z-index: 10;
}

.map-sidebar h3 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-bright);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}

.map-sidebar h3 span {
  font-family: var(--font-data, var(--font-mono));
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 400;
}

/* ---- News view ---- */
#view-news {
  overflow: hidden;
}

#news-feed {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

/* ---- Scroll regions ---- */
.feed-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

/* ---- Share queue tray — fixed bottom ---- */
#share-queue-tray {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-tray);
  background: var(--bg-raised);
  border-top: 1px solid var(--border);
  transition: transform var(--duration-normal) var(--ease-default);
}

#share-queue-tray.collapsed .tray-body,
#share-queue-tray.collapsed .tray-actions {
  display: none;
}

#share-queue-tray.expanded .tray-body {
  max-height: 240px;
  overflow-y: auto;
}

/* ---- Modal centering ---- */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  max-width: 480px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
}

/* ---- Mobile (<768px) ---- */
@media (max-width: 767px) {
  #top-bar {
    padding: var(--space-xs) var(--space-md);
    gap: var(--space-xs);
    flex-wrap: wrap;
    height: auto;
    min-height: 56px;
  }

  /* Pulse mini takes full width on second line */
  #pulse-mini {
    display: flex;
    gap: 12px;
    font-size: 12px;
    margin-left: 0;
    order: 10; /* push to second row */
    width: 100%;
    padding-top: var(--space-xs);
    border-top: 1px solid var(--border);
  }

  /* Hide connection status + source health on mobile — too noisy */
  #connection-status { display: none; }
  #source-health { display: none; }

  /* View tabs hidden — feed only */
  #view-tabs { display: none; }

  /* Views: two-line header */
  .view {
    margin-top: 80px;
  }

  /* Map container: full viewport minus header and bottom tabs */
  #map-container {
    height: calc(100vh - 80px - 56px);
  }

  /* Event sidebar: collapsible peek mode at bottom */
  .map-sidebar {
    position: absolute;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 50px;
    overflow: hidden;
    transition: max-height 0.3s ease;
    border-radius: 12px 12px 0 0;
  }

  .map-sidebar.expanded {
    max-height: 60vh;
    overflow-y: auto;
  }

  /* Share queue above bottom tabs */
  #share-queue-tray {
    bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }

  /* Filter pills: horizontal scroll */
  #firehose-filters {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .filter-pill {
    min-height: var(--touch-min);
  }
}

/* ---- Scrollbar styling ---- */
.feed-scroll::-webkit-scrollbar,
#firehose-feed::-webkit-scrollbar {
  width: 6px;
}

.feed-scroll::-webkit-scrollbar-track,
#firehose-feed::-webkit-scrollbar-track {
  background: transparent;
}

.feed-scroll::-webkit-scrollbar-thumb,
#firehose-feed::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}

.feed-scroll::-webkit-scrollbar-thumb:hover,
#firehose-feed::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}
