/* ==========================================================================
   Social Events Page
   --------------------------------------------------------------------------
   Two-column layout: scrollable list of collapsible category sections on
   the left, sticky Leaflet map on the right. Stacks on narrow screens.
   Reuses theme tokens (--plum, --blue, --green, --radius-*, --shadow-*).
   ========================================================================== */

/* --- Layout --------------------------------------------------------------- */

.social-events {
  margin: 2rem 0;
  /* Fallback — each .event-category sets --event-color inline from YAML. */
  --event-color: var(--plum);
  --event-color-tint: color-mix(in srgb, var(--event-color) 8%, transparent);
}

.social-events-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .social-events-layout {
    grid-template-columns: 1fr;
  }
}

.social-events-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

/* --- Map ------------------------------------------------------------------ */

.social-events-map-wrapper {
  position: sticky;
  top: calc(var(--nav-height) + 1.5rem);
  /* Own stacking context below the nav (z-index: 100). Without this, Leaflet's
     internal panes/controls (z-index 200–800) escape to the root context and
     paint over the sticky header — most visibly on mobile. */
  z-index: 1;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--light-gray);
  box-shadow: var(--shadow-card);
  background: var(--warm-white);
}

#social-events-map {
  height: min(70vh, 600px);
  width: 100%;
}

@media (max-width: 1024px) {
  /* Map stacks first and stays pinned under the nav while the category list
     scrolls beneath it, so tapping an event keeps the map in view. */
  .social-events-map-wrapper {
    position: sticky;
    top: calc(var(--nav-height));
    order: -1;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-card), 0 -2rem 0 0 var(--cream);
  }

  #social-events-map {
    height: min(42vh, 320px);
  }
}

/* --- Category (collapsible) ----------------------------------------------- */

.event-category {
  background: white;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--transition-fast);
}

.event-category[open] {
  box-shadow: var(--shadow-card);
}

/* Per-category --event-color is set inline by _includes/social-events/category.html
   from YAML `color:` — can be a theme var name (e.g. "blue" -> var(--blue)) or a
   raw hex value (e.g. "#7a3bff"). Fallback is plum. */

.event-category-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  background: var(--event-color-tint);
  transition: background var(--transition-fast);
}

.event-category-summary::-webkit-details-marker { display: none; }

.event-category-summary:hover,
.event-category-summary:focus-visible {
  background: color-mix(in srgb, var(--event-color) 14%, transparent);
}

.event-category-summary:focus-visible {
  outline: 2px solid var(--event-color);
  outline-offset: -2px;
}

.event-category-label {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.event-category-summary .event-category-name {
  margin: 0;
  padding: 0;
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--charcoal);
  letter-spacing: -0.01em;
}

.event-category-count {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  background: var(--event-color);
  color: white;
}

.event-category-chevron {
  width: 20px;
  height: 20px;
  color: var(--event-color);
  transition: transform var(--transition-medium);
  flex-shrink: 0;
}

.event-category[open] .event-category-chevron {
  transform: rotate(180deg);
}

.event-category-body {
  padding: 1rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.event-category-description {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--warm-gray);
  line-height: 1.5;
}

.event-category-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* --- Event card ----------------------------------------------------------- */

.event-card {
  position: relative;
  background: var(--warm-white);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  border: 1px solid transparent;
  transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
  scroll-margin-top: calc(var(--nav-height) + 1rem);
  cursor: pointer;
}

.event-card:hover {
  border-color: color-mix(in srgb, var(--event-color) 40%, transparent);
  background: white;
}

.event-card.is-active {
  border-color: var(--event-color);
  background: white;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--event-color) 18%, transparent);
}

.event-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.event-card-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--charcoal);
  margin: 0;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.event-card-price {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--event-color);
  font-weight: 600;
  flex-shrink: 0;
}

.event-card-description {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--warmer-gray);
  line-height: 1.55;
  margin: 0 0 0.6rem;
}

.event-card-meta {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0 0 0.6rem;
}

.event-card-meta-item dd {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--warmer-gray);
  line-height: 1.4;
}

.event-card-icon {
  width: 14px;
  height: 14px;
  color: var(--event-color);
  flex-shrink: 0;
  margin-top: 0.2rem;
}

.event-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--light-gray);
}

.event-card-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--event-color);
  text-decoration: none;
  font-weight: 500;
}

.event-card-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* "Show on map" is a real <button> styled like the link actions — reset the
   browser's default button chrome so it sits flush with the website/Slack links. */
.event-card-map-btn {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

.event-card-link:focus-visible,
.event-card-map-btn:focus-visible {
  outline: 2px solid var(--event-color);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* External-link chevron is added to all target="_blank" links in _base.scss —
   suppress it on Slack/website links inside event cards because we already
   show an inline icon. */
.event-card-link[target="_blank"]::after { display: none !important; }

/* --- Leaflet marker + popup theming -------------------------------------- */

/* Custom divIcon marker — coloured pin circle.
   JS sets --event-color inline per category (see category.html docs). */
.event-marker {
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid white;
  box-shadow: var(--shadow-dropdown);
  background: var(--event-color, var(--plum));
  display: flex;
  align-items: center;
  justify-content: center;
}

.event-marker::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: white;
}

.event-marker.is-active {
  transform: rotate(-45deg) scale(1.2);
  z-index: 10;
}

.leaflet-popup-content-wrapper {
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
}

.leaflet-popup-content {
  margin: 0.75rem 1rem;
  font-size: 0.9rem;
  line-height: 1.4;
}

.leaflet-popup-content .event-popup-title {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--charcoal);
  font-size: 0.95rem;
  margin: 0 0 0.25rem;
}

.leaflet-popup-content .event-popup-category {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--event-color, var(--plum));
}

/* --- Accessibility helper ------------------------------------------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Prose overrides (page layout wraps content in .prose) ---------------- */

/* .prose has `overflow-x: auto` (for wide tables/code blocks on other pages).
   Any non-visible overflow on an ancestor turns that ancestor into the scroll
   container for position: sticky, which breaks the map's stickiness. Reset it
   when .prose contains our social-events block. */
.prose:has(.social-events) {
  overflow: visible;
}

.prose .social-events h3 {
  margin: 0;
  padding-top: 0;
  border-top: 0;
}

.prose .social-events p {
  margin: 0;
}

.prose .event-category[open] {
  margin-bottom: 0;
}
