* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { display: flex; flex-direction: column; }

header {
  padding: 12px 16px;
  background: #1a1a1a;
  color: #fff;
  border-bottom: 1px solid #333;
}
header h1 { margin: 0 0 8px; font-size: 18px; font-weight: 600; }
#count { font-size: 13px; color: #aaa; }
.credit { font-size: 12px; color: #888; margin-top: 6px; }
.credit a { color: #ccc; text-decoration: none; }
.credit a:hover { color: #fff; text-decoration: underline; }

#date-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
}
.date-btn {
  padding: 6px 12px;
  font-size: 13px;
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 16px;
  cursor: pointer;
  white-space: nowrap;
}
.date-btn.active { background: #e8543e; color: #fff; border-color: #e8543e; }
.date-btn:hover:not(.active) { background: #f5f5f5; }
.date-btn-short { display: none; }
@media (max-width: 640px) {
  .date-btn-long { display: none; }
  .date-btn-short { display: inline; }
  #date-picker { gap: 4px; padding: 8px 12px; }
  .date-btn { padding: 6px 10px; }
}

#search-row {
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.search-scope {
  display: inline-flex;
  border: 1px solid #ccc;
  border-radius: 14px;
  overflow: hidden;
  background: #f7f7f7;
}
.search-scope-btn {
  border: none;
  background: transparent;
  padding: 5px 12px;
  font-size: 12px;
  font-family: inherit;
  color: #555;
  cursor: pointer;
  white-space: nowrap;
}
.search-scope-btn + .search-scope-btn { border-left: 1px solid #e0e0e0; }
.search-scope-btn:hover { background: #eee; }
.search-scope-btn.active {
  background: #e8543e;
  color: #fff;
}
#search {
  width: 100%;
  max-width: 320px;
  padding: 7px 12px 7px 32px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid #ccc;
  border-radius: 16px;
  background-color: #f7f7f7;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>");
  background-repeat: no-repeat;
  background-position: 10px center;
  background-size: 14px 14px;
  outline: none;
  transition: border-color 0.1s, background-color 0.1s;
}
#search:focus {
  border-color: #e8543e;
  background-color: #fff;
}
@media (max-width: 640px) {
  #search-row { padding: 6px 12px; }
  #search { max-width: none; font-size: 14px; }
}

/* Map + sidebar layout: row on desktop, column (sidebar as bottom sheet)
   on mobile. Flex parent (#map-stage) is itself a flex-1 child of body
   so it claims the space below the date picker. */
#map-stage {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-height: 0;
}
#map { flex: 1; min-width: 0; }
#sidebar {
  width: 360px;
  border-left: 1px solid #e0e0e0;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-header {
  padding: 8px 8px 8px 14px;
  border-bottom: 1px solid #e0e0e0;
  background: #fff;
  font-size: 12px;
  color: #555;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sidebar-hide-btn {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: #888;
  font-size: 22px;
  line-height: 1;
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
}
.sidebar-hide-btn:hover { background: #f0f0f0; color: #222; }

/* Floating "show" button — appears only when the sidebar is hidden. */
#sidebar-show-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font: 600 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  z-index: 5;
}
#sidebar-show-btn:hover { background: #333; }
.sidebar-show-btn-icon { font-size: 16px; line-height: 1; }
#map-stage { position: relative; }
#map-stage.sidebar-hidden #sidebar { display: none; }
#map-stage.sidebar-hidden #sidebar-show-btn { display: inline-flex; }
.sidebar-empty {
  padding: 24px 16px;
  color: #888;
  font-size: 13px;
  text-align: center;
}
.sidebar-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidebar-row {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #ececec;
  cursor: pointer;
  background: #fff;
  align-items: stretch;
  text-align: left;
  width: 100%;
  border: none;
  border-bottom: 1px solid #ececec;
  font: inherit;
  color: inherit;
}
.sidebar-row:hover { background: #f5f5f5; }
.sidebar-row[aria-selected="true"] {
  background: #fff;
  border-left: 3px solid #e8543e;
  padding-left: 9px;
}
.sidebar-row.is-past {
  opacity: 0.5;
}
.sidebar-row.is-past:hover {
  opacity: 0.85;
}
.sidebar-row.is-past[aria-selected="true"] {
  opacity: 1;
}
.sidebar-row-thumb {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  border-radius: 6px;
  background: #ddd center/cover no-repeat;
  overflow: hidden;
}
.sidebar-row-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.sidebar-row-body { flex: 1; min-width: 0; }
.sidebar-row-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sidebar-row-meta {
  font-size: 11.5px;
  color: #666;
  line-height: 1.35;
}
.sidebar-row-cap {
  display: inline-block;
  padding: 1px 5px;
  background: #f5e0e0;
  color: #c00;
  border-radius: 3px;
  font-size: 10px;
  margin-left: 4px;
}
.sidebar-detail {
  display: none;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid #eee;
}
.sidebar-row[aria-selected="true"] .sidebar-detail { display: block; }
.sidebar-detail-img {
  width: 100%;
  border-radius: 6px;
  margin-bottom: 8px;
  display: block;
  max-height: 200px;
  object-fit: cover;
}
.sidebar-detail-stats {
  display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0;
}
.sidebar-detail-stat {
  font-size: 10.5px;
  background: #f0f0f0;
  color: #333;
  padding: 2px 7px;
  border-radius: 8px;
}
.sidebar-detail-where {
  font-size: 12px;
  color: #555;
  margin-bottom: 8px;
}
.sidebar-detail-desc {
  font-size: 12px;
  line-height: 1.5;
  color: #333;
  white-space: pre-wrap;
  margin-bottom: 10px;
  max-height: 240px;
  overflow-y: auto;
}
.sidebar-detail-rsvp {
  display: inline-block;
  padding: 6px 14px;
  background: #e8543e;
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
}
.sidebar-detail-rsvp:hover { background: #d3422e; }

@media (max-width: 640px) {
  /* Tighter header so the map keeps more vertical room. */
  header { padding: 8px 12px; }
  header h1 { font-size: 16px; margin-bottom: 4px; }
  #count { font-size: 12px; }
  .credit { font-size: 11px; margin-top: 3px; }
  .tab-nav a { padding: 8px 12px; font-size: 13px; }

  /* Thumbnails are useful on desktop where the sidebar has width to spare,
     but on a phone they compete with the map for vertical space. */
  .sidebar-row-thumb { display: none; }

  #map-stage { flex-direction: column; }
  #sidebar {
    width: 100%;
    height: 33vh;          /* lower third of the viewport */
    min-height: 200px;     /* don't collapse below ~2 rows */
    border-left: none;
    border-top: 1px solid #e0e0e0;
  }
}

#error { color: #c00; padding: 16px; }

.popup { font-size: 13px; line-height: 1.4; }
.popup-title { font-weight: 600; margin-bottom: 4px; font-size: 14px; }
.popup-meta { color: #555; margin-bottom: 4px; }
.popup-host { color: #777; font-size: 12px; margin-bottom: 6px; }
.popup-rsvp {
  display: inline-block;
  padding: 4px 10px;
  background: #e8543e;
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  font-weight: 600;
}
.popup-cap {
  display: inline-block;
  padding: 1px 6px;
  background: #f5e0e0;
  color: #c00;
  border-radius: 3px;
  font-size: 11px;
  margin-left: 4px;
}

/* --- Tab nav (shared by map + gallery pages) --- */
.tab-nav {
  display: flex;
  background: #111;
  border-bottom: 1px solid #333;
}
.tab-nav a {
  flex: 1;
  text-align: center;
  padding: 10px 12px;
  color: #aaa;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
}
.tab-nav a.active {
  color: #fff;
  border-bottom-color: #e8543e;
  background: #1a1a1a;
}
.tab-nav a:hover:not(.active) {
  color: #fff;
  background: #1a1a1a;
}

/* --- Gallery grid --- */
#gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  padding: 12px;
  overflow-y: auto;
  flex: 1;
  background: #f5f5f5;
}
.tile {
  display: flex;
  flex-direction: column;
  align-self: start;        /* don't let grid stretch us to row height */
  min-height: 300px;        /* 220 img + ~80 body, guarantees the wrap can't be compressed */
  background: #fff;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transition: transform 0.15s, box-shadow 0.15s;
}
.tile-img-wrap, .tile-overlay {
  border-radius: 8px 8px 0 0; /* keep the top corners rounded without overflow:hidden */
}
.tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.tile.is-past { opacity: 0.45; }
.tile.is-past:hover { opacity: 1; }
.tile-img-wrap {
  display: block;
  width: 100%;
  height: 220px;           /* fallback for the % padding / aspect-ratio dance */
  aspect-ratio: 1 / 1;     /* square at any column width */
  background: #ddd;
  overflow: hidden;
  position: relative;
  flex: 0 0 auto;          /* don't let the flex parent collapse us */
}

.tile-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.92) 60%);
  color: #fff;
  padding: 14px 14px 12px;
  opacity: 0;
  transition: opacity 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  pointer-events: none;
}
.tile:hover .tile-overlay,
.tile:focus .tile-overlay {
  opacity: 1;
  pointer-events: auto;
}
.overlay-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 2px;
}
.overlay-when { font-size: 12px; color: #ddd; }
.overlay-where { font-size: 12px; color: #ccc; }
.overlay-host { font-size: 11px; color: #aaa; margin-top: 2px; }
.overlay-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.overlay-stat {
  font-size: 10.5px;
  background: rgba(255,255,255,0.12);
  padding: 2px 6px;
  border-radius: 8px;
  color: #fff;
}
.overlay-desc {
  font-size: 11.5px;
  line-height: 1.45;
  color: #e0e0e0;
  margin-top: 6px;
  flex: 1;
  overflow-y: auto;
}
.overlay-cta {
  margin-top: auto;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  text-align: right;
}

/* On touch devices hover is wonky; let the under-image meta carry the load
   and keep the overlay off so the tap goes straight to RSVP. */
@media (hover: none) {
  .tile-overlay { display: none; }
}
.tile-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tile-body {
  padding: 10px 12px 12px;
}
.tile-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile-host {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile-meta {
  font-size: 12px;
  color: #555;
  line-height: 1.4;
}
.tile-host {
  font-size: 12px;
  color: #888;
  margin-top: 4px;
}
.tile-cap {
  display: inline-block;
  padding: 1px 6px;
  background: #f5e0e0;
  color: #c00;
  border-radius: 3px;
  font-size: 10px;
  margin-left: 4px;
  font-weight: 500;
  vertical-align: middle;
}
.empty {
  grid-column: 1 / -1;
  padding: 32px;
  text-align: center;
  color: #888;
  font-size: 14px;
}
