/* =========================
   PROJECT ATLAS (scoped to .atlas-shell)
========================= */

:root{
  --atlas-side-width: 400px;
  --atlas-gap: 16px;
  --atlas-radius: 14px;
  --atlas-border: 1px solid #e5e7eb;
  --atlas-vh-offset: 220px; /* adjust if header height changes */
  --atlas-gutter: 12px;

  --atlas-thumb-w: 96px;
  --atlas-thumb-h: 72px;
  --atlas-item-minh: 88px;
}

/* Full-bleed breakout */
.atlas-shell{
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  padding-left: var(--atlas-gutter);
  padding-right: var(--atlas-gutter);
}

/* Main layout: sidebar + map */
.atlas-shell .atlas{
  width: 100%;
  margin: 0;
  display: grid;
  grid-template-columns: var(--atlas-side-width) minmax(0, 1fr);
  gap: var(--atlas-gap);
  align-items: stretch;
}

/* Panels */
.atlas-shell .atlas-side,
.atlas-shell .atlas-mapWrap{
  border: var(--atlas-border);
  border-radius: var(--atlas-radius);
  background: #fff;
  overflow: hidden;
}


/* =========================
   SIDEBAR (fixed column)
========================= */

.atlas-shell .atlas-side{
  padding: 14px;
  height: calc(100vh - var(--atlas-vh-offset));
  min-height: 0;                 /* important for flex scrolling */
  display: flex;
  flex-direction: column;
  overflow: hidden;              /* keep scroll inside list */
}

.atlas-shell .atlas-heading{
  margin: 0 0 6px 0;
}

.atlas-shell .atlas-lede{
  margin: 0 0 14px 0;
  opacity: .85;
}

/* Search */
.atlas-shell .atlas-search{
  width: 100%;
  padding: 10px 12px;
  border: var(--atlas-border);
  border-radius: 12px;
  font-size: 0.95rem;
  outline: none;
}

.atlas-shell .atlas-search:focus{
  border-color: #cbd5e1;
  box-shadow: 0 0 0 3px rgba(148,163,184,.25);
}

/* Meta row */
.atlas-shell .atlas-meta{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.atlas-shell .atlas-count{
  opacity: .8;
}

.atlas-shell .atlas-clear{
  border: var(--atlas-border);
  background: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: .9rem;
}

.atlas-shell .atlas-clear:hover{
  background: #f8fafc;
}


/* =========================
   LIST (scroll area)
========================= */

.atlas-shell .atlas-list{
  margin-top: 12px;
  flex: 1 1 auto;               /* fill remaining sidebar height */
  min-height: 0;                /* required for overflow in flex children */
  overflow-y: auto;
  overflow-x: hidden;

  display: flex;
  flex-direction: column;
  gap: 10px;

  padding-right: 6px;           /* room for scrollbar */
}

/* Optional: nicer scrollbar (WebKit) */
.atlas-shell .atlas-list::-webkit-scrollbar{
  width: 10px;
}
.atlas-shell .atlas-list::-webkit-scrollbar-thumb{
  background: rgba(0,0,0,0.18);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}
.atlas-shell .atlas-list::-webkit-scrollbar-track{
  background: transparent;
}

/* Individual list items (prevents squishing/crowding) */
.atlas-shell .atlas-item{
  display: flex;
  align-items: center;
  gap: 12px;

  padding: 8px;
  min-height: var(--atlas-item-minh);

  border: var(--atlas-border);
  border-radius: var(--atlas-radius);
  background: #fff;

  overflow: hidden;
  cursor: pointer;
}

.atlas-shell .atlas-item:hover{
  background: #f8fafc;
}

.atlas-shell .atlas-item.is-active{
  box-shadow: 0 0 0 2px rgba(11,79,122,0.35);
  background: rgba(11,79,122,0.04);
}

/* Thumbnails:
   supports BOTH:
   1) <div class="atlas-thumb"><img ...></div>
   2) <img class="atlas-thumb" ...>
*/
.atlas-shell .atlas-thumb{
  width: var(--atlas-thumb-w);
  height: var(--atlas-thumb-h);
  flex: 0 0 auto;

  background: #f1f5f9;
  border-radius: 12px;
  overflow: hidden;
  display: block;
}

.atlas-shell .atlas-thumb img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* If atlas-thumb is itself an <img> */
.atlas-shell img.atlas-thumb{
  object-fit: cover;
}

/* Text block */
.atlas-shell .atlas-text{
  min-width: 0; /* enables ellipsis */
  padding: 0;
}

/* Title/subtitle */
.atlas-shell .atlas-title{
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 4px 0;
  font-size: .95rem;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.atlas-shell .atlas-sub{
  opacity: .8;
  font-size: .9rem;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tags */
.atlas-shell .atlas-tags{
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.atlas-shell .atlas-tag{
  font-size: .75rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.12);
  background: rgba(0,0,0,0.02);
  opacity: .9;
}


/* =========================
   MAP (Leaflet needs fixed height)
========================= */

.atlas-shell .atlas-map{
  height: calc(100vh - var(--atlas-vh-offset));
  min-height: 520px;
  width: 100%;
}

/* Popup typography */
.atlas-shell .leaflet-popup-content{
  margin: 12px 14px;
}

.atlas-shell .popup-title{
  font-weight: 700;
  margin-bottom: 4px;
}

.atlas-shell .popup-sub{
  opacity: .75;
  margin-bottom: 8px;
}

.atlas-shell .popup-link{
  text-decoration: none;
  font-weight: 600;
}


/* =========================
   MOBILE
========================= */

@media (max-width: 980px){
  .atlas-shell .atlas{
    grid-template-columns: 1fr;
  }

  /* Sidebar above map; allow natural height */
  .atlas-shell .atlas-side{
    height: auto;
    min-height: auto;
    overflow: visible;
  }

  /* Limit list height so it scrolls */
  .atlas-shell .atlas-list{
    max-height: 360px;
  }

  /* Map smaller */
  .atlas-shell .atlas-map{
    height: 60vh;
    min-height: 420px;
  }
}
